Turn delete_meta() , get_post_meta_by_id(), update_meta(), delete_post_meta_by_key() into wrappers around the metadata API. Add back compat *_postmeta actions to metadata API. Props jgadbois. see #18196
git-svn-id: http://svn.automattic.com/wordpress/trunk@18500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -1497,22 +1497,7 @@ function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') {
|
||||
* @return bool Whether the post meta key was deleted from the database
|
||||
*/
|
||||
function delete_post_meta_by_key($post_meta_key) {
|
||||
if ( !$post_meta_key )
|
||||
return false;
|
||||
|
||||
global $wpdb;
|
||||
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key));
|
||||
if ( $post_ids ) {
|
||||
$postmetaids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key ) );
|
||||
$in = implode( ',', array_fill(1, count($postmetaids), '%d'));
|
||||
do_action( 'delete_postmeta', $postmetaids );
|
||||
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id IN($in)", $postmetaids ));
|
||||
do_action( 'deleted_postmeta', $postmetaids );
|
||||
foreach ( $post_ids as $post_id )
|
||||
wp_cache_delete($post_id, 'post_meta');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return delete_metadata( 'post', null, $post_meta_key, '', true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user