Meta: Simplify the delete all meta query in delete_metadata()
.
Merge of [42913] to the 4.7 branch. git-svn-id: https://develop.svn.wordpress.org/branches/4.7@42914 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
42b1dd5acc
commit
278641ebbc
@ -364,12 +364,11 @@ function delete_metadata($meta_type, $object_id, $meta_key, $meta_value = '', $d
|
||||
return false;
|
||||
|
||||
if ( $delete_all ) {
|
||||
$value_clause = '';
|
||||
if ( '' !== $meta_value && null !== $meta_value && false !== $meta_value ) {
|
||||
$value_clause = $wpdb->prepare( " AND meta_value = %s", $meta_value );
|
||||
$object_ids = $wpdb->get_col( $wpdb->prepare( "SELECT $type_column FROM $table WHERE meta_key = %s AND meta_value = %s", $meta_key, $meta_value ) );
|
||||
} else {
|
||||
$object_ids = $wpdb->get_col( $wpdb->prepare( "SELECT $type_column FROM $table WHERE meta_key = %s", $meta_key ) );
|
||||
}
|
||||
|
||||
$object_ids = $wpdb->get_col( $wpdb->prepare( "SELECT $type_column FROM $table WHERE meta_key = %s $value_clause", $meta_key ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user