diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 26fdd037fb..42251e5727 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -197,4 +197,121 @@ function wp_create_thumbnail($file, $max_side, $effect = '') { } } +// Some postmeta stuff +function has_meta($postid) { + global $wpdb, $tablepostmeta; + + return $wpdb->get_results(" + SELECT meta_key, meta_value, meta_id, post_id + FROM $tablepostmeta + WHERE post_id = $postid + ORDER BY meta_key,meta_id",ARRAY_A); + +} + +function list_meta($meta) { + global $post_ID; + // Exit if no meta + if (!$meta) return; + + + print " + + + + + + \n"; + + foreach ($meta as $entry) { + // TBD: Still need to add edit/del logic... + print " + + + + + \n"; + } + print " +
KeyValue 
{$entry['meta_key']}{$entry['meta_value']}Delete
\n"; +} + +// Get a list of previously defined keys +function get_meta_keys() { + global $wpdb, $tablepostmeta; + + $keys = $wpdb->get_col(" + SELECT meta_key + FROM $tablepostmeta + GROUP BY meta_key + ORDER BY meta_key"); + + return $keys; +} + +function meta_form() { + $keys = get_meta_keys(); +?> +

Add new custom data to this post:

+
+

Select existing key or enter new key

+ + + + +
+
+

Custom Value

+ + +
+
+
+ +
+query(" + INSERT INTO $tablepostmeta + (post_id,meta_key,meta_value) + VALUES ('$post_ID','$metakey','$metavalue') + "); + } +} // add_meta + +function del_meta($mid) { + global $wpdb, $tablepostmeta; + + $result = $wpdb->query("DELETE FROM $tablepostmeta WHERE meta_id = '$mid'"); +} + ?> \ No newline at end of file diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index c7c04f38f3..75efd97533 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -138,11 +138,26 @@ if ($action != 'editcomment') { } } ?> +
+Post Custom + + + +
+ +

diff --git a/wp-admin/post.php b/wp-admin/post.php index 1d5eecab45..1b9b0f1137 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -37,6 +37,20 @@ for ($i=0; $i 0) { sleep($sleep_after_edit); @@ -376,7 +392,9 @@ switch($action) { } } } // end if publish - + + add_meta($post_ID); + if ($HTTP_POST_VARS['save']) { $location = $HTTP_SERVER_VARS['HTTP_REFERER']; } else {