Make WordPress Core

Ticket #39696: 39696.diff

File 39696.diff, 927 bytes (added by rheinardkorf, 8 years ago)
  • src/wp-includes/rest-api/class-wp-rest-server.php

    diff --git src/wp-includes/rest-api/class-wp-rest-server.php src/wp-includes/rest-api/class-wp-rest-server.php
    index ec8d2a0..f989194 100644
    class WP_REST_Server { 
    544544
    545545                $embedded = array();
    546546
     547                // Get link relationships to filter on.
     548                $_embed = isset( $_GET['_embed'] ) ? array_filter( explode( ',', $_GET['_embed'] ) ) : false;
     549                $filtered_rels = empty( $_embed ) ? false : $_embed;
     550
    547551                foreach ( $data['_links'] as $rel => $links ) {
    548552                        // Ignore links to self, for obvious reasons.
    549553                        if ( 'self' === $rel ) {
    550554                                continue;
    551555                        }
    552556
     557                        // If filtered rels are specified and current $rel is not in the list, then continue.
     558                        if ( false !== $filtered_rels && ! in_array( $rel, $filtered_rels, true ) ) {
     559                                continue;
     560                        }
     561
    553562                        $embeds = array();
    554563
    555564                        foreach ( $links as $item ) {