Fix slashing in Custom fields values. Allow for the meta_key to be updated without changing meta_value. Use wpdb::insert in add_meta(). Fixes #12418

git-svn-id: https://develop.svn.wordpress.org/trunk@13489 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse
2010-02-28 07:12:05 +00:00
parent 1a258ebff7
commit df84c657f9
3 changed files with 10 additions and 10 deletions
+5 -4
View File
@@ -597,8 +597,7 @@ function add_meta( $post_ID ) {
return false;
wp_cache_delete($post_ID, 'post_meta');
$wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value ) VALUES (%s, %s, %s)", $post_ID, $metakey, $metavalue) );
$wpdb->insert( $wpdb->postmeta, array( 'post_id' => $post_ID, 'meta_key' => $metakey, 'meta_value' => $metavalue ) );
do_action( 'added_postmeta', $wpdb->insert_id, $post_ID, $metakey, $metavalue );
return $wpdb->insert_id;
@@ -690,8 +689,8 @@ function has_meta( $postid ) {
* @since unknown
*
* @param unknown_type $meta_id
* @param unknown_type $meta_key
* @param unknown_type $meta_value
* @param unknown_type $meta_key Expect Slashed
* @param unknown_type $meta_value Expect Slashed
* @return unknown
*/
function update_meta( $meta_id, $meta_key, $meta_value ) {
@@ -699,6 +698,8 @@ function update_meta( $meta_id, $meta_key, $meta_value ) {
$protected = array( '_wp_attached_file', '_wp_attachment_metadata', '_wp_old_slug', '_wp_page_template' );
$meta_key = stripslashes($meta_key);
if ( in_array($meta_key, $protected) )
return false;