Make WordPress Core


Ignore:
Timestamp:
11/18/2015 06:28:55 PM (9 years ago)
Author:
johnbillion
Message:

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

Props danielbachhuber
Fixes #34551

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/class-wp-rest-response.php

    r34928 r35671  
    244244
    245245        if ( is_array( $this->get_data() ) ) {
    246             foreach ( $this->get_data() as $err ) {
    247                 $error->add( $err['code'], $err['message'], $err['data'] );
     246            $data = $this->get_data();
     247            $error->add( $data['code'], $data['message'], $data['data'] );
     248            if ( ! empty( $data['additional_errors'] ) ) {
     249                foreach( $data['additional_errors'] as $err ) {
     250                    $error->add( $err['code'], $err['message'], $err['data'] );
     251                }
    248252            }
    249253        } else {
Note: See TracChangeset for help on using the changeset viewer.