Make WordPress Core


Ignore:
Timestamp:
04/08/2022 05:27:42 PM (3 years ago)
Author:
spacedmonkey
Message:

REST API: Use rest_parse_embed_param function in WP_REST_Server class.

Ensure that the value get parameter _embed that is passed to the envelope_response method, is run through the rest_parse_embed_param function.

Props Spacedmonkey, johnbillion, TimothyBlynJacobs.
Fixes #54015.

File:
1 edited

Legend:

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

    r52796 r53110  
    439439        // Wrap the response in an envelope if asked for.
    440440        if ( isset( $_GET['_envelope'] ) ) {
    441             $result = $this->envelope_response( $result, isset( $_GET['_embed'] ) );
     441            $embed  = isset( $_GET['_embed'] ) ? rest_parse_embed_param( $_GET['_embed'] ) : false;
     442            $result = $this->envelope_response( $result, $embed );
    442443        }
    443444
     
    731732     *
    732733     * @since 4.4.0
     734     * @since 6.0.0 The $embed parameter can now contain a list of link relations to include
    733735     *
    734736     * @param WP_REST_Response $response Response object.
    735      * @param bool             $embed    Whether links should be embedded.
     737     * @param bool|string[]    $embed    Whether to embed all links, a filtered list of link relations, or no links.
    736738     * @return WP_REST_Response New response with wrapped data
    737739     */
Note: See TracChangeset for help on using the changeset viewer.