REST API: Allow parameters defined as `array` to be sent as CSVs.
This allows parameters that are often handled as CSVs to be properly parsed. Fixes #38586. Built from https://develop.svn.wordpress.org/trunk@39048 git-svn-id: http://core.svn.wordpress.org/trunk@38990 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4dab905dba
commit
54b378e411
|
@ -996,7 +996,7 @@ function rest_get_avatar_sizes() {
|
||||||
function rest_validate_value_from_schema( $value, $args, $param = '' ) {
|
function rest_validate_value_from_schema( $value, $args, $param = '' ) {
|
||||||
if ( 'array' === $args['type'] ) {
|
if ( 'array' === $args['type'] ) {
|
||||||
if ( ! is_array( $value ) ) {
|
if ( ! is_array( $value ) ) {
|
||||||
return new WP_Error( 'rest_invalid_param', sprintf( /* translators: 1: parameter, 2: type name */ __( '%1$s is not of type %2$s.' ), $param, 'array' ) );
|
$value = preg_split( '/[\s,]+/', $value );
|
||||||
}
|
}
|
||||||
foreach ( $value as $index => $v ) {
|
foreach ( $value as $index => $v ) {
|
||||||
$is_valid = rest_validate_value_from_schema( $v, $args['items'], $param . '[' . $index . ']' );
|
$is_valid = rest_validate_value_from_schema( $v, $args['items'], $param . '[' . $index . ']' );
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.7-beta1-39047';
|
$wp_version = '4.7-beta1-39048';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue