From fd96378b7fe8ac366144d8e61350f552c7235b57 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Mon, 20 Oct 2008 05:47:13 +0000 Subject: [PATCH] Update update_post_meta() and delete_post_meta() to work with post revisions. Props misterbisson. fixes #7925 git-svn-id: https://develop.svn.wordpress.org/trunk@9252 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index ac7412f215..5c61c6d713 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -548,7 +548,9 @@ function add_post_meta($post_id, $meta_key, $meta_value, $unique = false) { function delete_post_meta($post_id, $meta_key, $meta_value = '') { global $wpdb; - $post_id = absint( $post_id ); + // make sure meta is added to the post, not a revision + if ( $the_post = wp_is_post_revision($post_id) ) + $post_id = $the_post; // expected_slashed ($meta_key, $meta_value) $meta_key = stripslashes( $meta_key ); @@ -626,6 +628,10 @@ function get_post_meta($post_id, $key, $single = false) { function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') { global $wpdb; + // make sure meta is added to the post, not a revision + if ( $the_post = wp_is_post_revision($post_id) ) + $post_id = $the_post; + // expected_slashed ($meta_key) $meta_key = stripslashes($meta_key);