Meta: Allow empty strings to be set by Custom Fields meta box.

Because the REST API allows meta keys to have empty values, the Custom Fields meta box should permit the same behavior.

Props charlestonsw, soulseekah, danielbachhuber.

Merges [43811] to trunk.

Fixes #43559.
Built from https://develop.svn.wordpress.org/trunk@44153


git-svn-id: http://core.svn.wordpress.org/trunk@43983 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
desrosj 2018-12-14 03:17:38 +00:00
parent 4d3f9732b1
commit dd7e2243fa
3 changed files with 2 additions and 5 deletions

View File

@ -1443,9 +1443,6 @@ function wp_ajax_add_meta() {
if ( '' == trim( $key ) ) {
wp_die( __( 'Please provide a custom field name.' ) );
}
if ( '' == trim( $value ) ) {
wp_die( __( 'Please provide a custom field value.' ) );
}
if ( ! $meta = get_metadata_by_mid( 'post', $mid ) ) {
wp_die( 0 ); // if meta doesn't exist
}

View File

@ -867,7 +867,7 @@ function add_meta( $post_ID ) {
$metavalue = trim( $metavalue );
}
if ( ( '0' === $metavalue || ! empty( $metavalue ) ) && ( ( ( '#NONE#' != $metakeyselect ) && ! empty( $metakeyselect ) ) || ! empty( $metakeyinput ) ) ) {
if ( ( ( '#NONE#' != $metakeyselect ) && ! empty( $metakeyselect ) ) || ! empty( $metakeyinput ) ) {
/*
* We have a key/value pair. If both the select and the input
* for the key have data, the input takes precedence.

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.1-alpha-44152';
$wp_version = '5.1-alpha-44153';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.