mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-02 17:40:01 +00:00
REST API: Allow sending an empty array to delete multi meta keys.
Previously, only `null` was supported. Fixes #50790. Props chrisvanpatten. git-svn-id: https://develop.svn.wordpress.org/trunk@49966 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -145,11 +145,15 @@ abstract class WP_REST_Meta_Fields {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = $meta[ $name ];
|
||||
|
||||
/*
|
||||
* A null value means reset the field, which is essentially deleting it
|
||||
* from the database and then relying on the default value.
|
||||
*
|
||||
* Non-single meta can also be removed by passing an empty array.
|
||||
*/
|
||||
if ( is_null( $meta[ $name ] ) ) {
|
||||
if ( is_null( $value ) || ( array() === $value && ! $args['single'] ) ) {
|
||||
$args = $this->get_registered_fields()[ $meta_key ];
|
||||
|
||||
if ( $args['single'] ) {
|
||||
@@ -172,8 +176,6 @@ abstract class WP_REST_Meta_Fields {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = $meta[ $name ];
|
||||
|
||||
if ( ! $args['single'] && is_array( $value ) && count( array_filter( $value, 'is_null' ) ) ) {
|
||||
return new WP_Error(
|
||||
'rest_invalid_stored_value',
|
||||
|
||||
Reference in New Issue
Block a user