Make WordPress Core

Changeset 41093


Ignore:
Timestamp:
07/19/2017 08:11:28 PM (7 years ago)
Author:
westonruter
Message:

REST API: Add a filter to allow modifying the response *after* embedded data is added.

Merges [40961] onto 4.8 branch.
Props jnylen0.
Fixes #38964 for 4.8.1.

Location:
branches/4.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.8

  • branches/4.8/src/wp-includes/rest-api/class-wp-rest-server.php

    r40805 r41093  
    387387            // Embed links inside the request.
    388388            $result = $this->response_to_data( $result, isset( $_GET['_embed'] ) );
     389
     390            /**
     391             * Filters the API response.
     392             *
     393             * Allows modification of the response data after inserting
     394             * embedded data (if any) and before echoing the response data.
     395             *
     396             * @since 4.8.1
     397             *
     398             * @param array            $result  Response data to send to the client.
     399             * @param WP_REST_Server   $this    Server instance.
     400             * @param WP_REST_Request  $request Request used to generate the response.
     401             */
     402            $result = apply_filters( 'rest_pre_echo_response', $result, $this, $request );
    389403
    390404            $result = wp_json_encode( $result );
Note: See TracChangeset for help on using the changeset viewer.