Update `WP_REST_Response::as_error()` to handle the new format error responses introduced in [35653].

Props danielbachhuber
Fixes #34551

Built from https://develop.svn.wordpress.org/trunk@35671


git-svn-id: http://core.svn.wordpress.org/trunk@35635 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2015-11-18 18:29:26 +00:00
parent bc41f44158
commit 407f641cf3
2 changed files with 7 additions and 3 deletions

View File

@ -243,8 +243,12 @@ class WP_REST_Response extends WP_HTTP_Response {
$error = new WP_Error; $error = new WP_Error;
if ( is_array( $this->get_data() ) ) { if ( is_array( $this->get_data() ) ) {
foreach ( $this->get_data() as $err ) { $data = $this->get_data();
$error->add( $err['code'], $err['message'], $err['data'] ); $error->add( $data['code'], $data['message'], $data['data'] );
if ( ! empty( $data['additional_errors'] ) ) {
foreach( $data['additional_errors'] as $err ) {
$error->add( $err['code'], $err['message'], $err['data'] );
}
} }
} else { } else {
$error->add( $this->get_status(), '', array( 'status' => $this->get_status() ) ); $error->add( $this->get_status(), '', array( 'status' => $this->get_status() ) );

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.4-beta4-35670'; $wp_version = '4.4-beta4-35671';
/** /**
* 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.