New custom field functionality.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1197 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-04-28 04:49:16 +00:00
parent 07a395f685
commit 95a1e1d28f
4 changed files with 723 additions and 700 deletions

View File

@ -232,8 +232,8 @@ function list_meta($meta) {
<tr $style>
<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' value='{$entry['meta_key']}' /></td>
<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='40'>{$entry['meta_value']}</textarea></td>
<td align='center'><input name='updatemeta' type='submit' id='updatemeta' tabindex='6' value='" . __('Update') ."' /></td>
<td align='center'><input name='deletemeta[{$entry['meta_id']}]' type='submit' id='deletemeta' tabindex='6' value='" . __('Delete') ."' /></td>
<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='" . __('Update') ."' /></td>
<td align='center'><input name='deletemeta[{$entry['meta_id']}]' type='submit' class='deletemeta' tabindex='6' value='" . __('Delete') ."' /></td>
</tr>
";
}
@ -256,9 +256,15 @@ function get_meta_keys() {
}
function meta_form() {
$keys = get_meta_keys();
global $wpdb, $tablepostmeta;
$keys = $wpdb->get_col("
SELECT meta_key
FROM $tablepostmeta
GROUP BY meta_key
ORDER BY meta_id DESC
LIMIT 10");
?>
<h3><?php _e('Add new custom data to this post:') ?></h3>
<h3><?php _e('Add a new custom field to this post:') ?></h3>
<table width="100%" cellspacing="3" cellpadding="3">
<tr>
<th colspan="2"><?php _e('Key') ?></th>
@ -279,7 +285,7 @@ function meta_form() {
</tr>
</table>
<p class="submit"><input type="submit" id="save" name="save" value="<?php _e('Add Custom Fields &raquo;') ?>"></p>
<p class="submit"><input type="submit" name="updatemeta" value="<?php _e('Add Custom Field &raquo;') ?>"></p>
<?php
}
@ -308,10 +314,16 @@ function add_meta($post_ID) {
}
} // add_meta
function del_meta($mid) {
function delete_meta($mid) {
global $wpdb, $tablepostmeta;
$result = $wpdb->query("DELETE FROM $tablepostmeta WHERE meta_id = '$mid'");
}
function update_meta($mid, $mkey, $mvalue) {
global $wpdb, $tablepostmeta;
return $wpdb->query("UPDATE $tablepostmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'");
}
?>

View File

@ -1,4 +1,11 @@
<?php
$messages[1] = __('Post updated');
$messages[2] = __('Custom field updated');
$messages[3] = __('Custom field deleted.');
?>
<?php if ($_GET['message']) : ?>
<div class="updated"><p><?php echo $messages[$_GET['message']]; ?></p></div>
<?php endif; ?>
<div class="wrap">
<?php
@ -47,7 +54,7 @@ $saveasdraft = '<input name="save" type="submit" id="save" tabindex="6" value="'
<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
<input type="hidden" name="action" value='<?php echo $form_action ?>' />
<?php echo $form_extra ?>
<?php if (2 > $_GET['message']) : ?>
<script type="text/javascript">
<!--
function focusit() {
@ -57,7 +64,7 @@ function focusit() {
window.onload = focusit;
//-->
</script>
<?php endif; ?>
<div id="poststuff">
<fieldset id="titlediv">
<legend><a href="http://wordpress.org/docs/reference/post/#title" title="<?php _e('Help on titles') ?>"><?php _e('Title') ?></a></legend>

File diff suppressed because it is too large Load Diff

View File

@ -353,7 +353,7 @@ textarea, input, select {
padding: .3em;
}
#postcustom #updatemeta, #postcustom #deletemeta {
#postcustom .updatemeta, #postcustom .deletemeta {
width: 90%;
margin: auto;
}