mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
REST API: Introduce selective link embedding.
Previously the _embed flag would embed all embeddable links in a response even if only a subset of the links were necessary. Now, a list of link relations can be passed in the _embed parameter to restrict the list of embedded objects. Props rheinardkorf, adamsilverstein, jnylen0, cklosows, chrisvanpatten, TimothyBlynJacobs. Fixes #39696. git-svn-id: https://develop.svn.wordpress.org/trunk@47224 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -906,4 +906,31 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
$this->assertEquals( '/wp/v2/posts', $request->get_route() );
|
||||
$this->assertEquals( 'GET', $request->get_method() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider _dp_rest_parse_embed_param
|
||||
*/
|
||||
public function test_rest_parse_embed_param( $expected, $embed ) {
|
||||
$this->assertEquals( $expected, rest_parse_embed_param( $embed ) );
|
||||
}
|
||||
|
||||
public function _dp_rest_parse_embed_param() {
|
||||
return array(
|
||||
array( true, '' ),
|
||||
array( true, null ),
|
||||
array( true, '1' ),
|
||||
array( true, 'true' ),
|
||||
array( true, array() ),
|
||||
array( array( 'author' ), 'author' ),
|
||||
array( array( 'author', 'replies' ), 'author,replies' ),
|
||||
array( array( 'author', 'replies' ), 'author,replies ' ),
|
||||
array( array( 'wp:term' ), 'wp:term' ),
|
||||
array( array( 'wp:term', 'wp:attachment' ), 'wp:term,wp:attachment' ),
|
||||
array( array( 'author' ), array( 'author' ) ),
|
||||
array( array( 'author', 'replies' ), array( 'author', 'replies' ) ),
|
||||
array( array( 'https://api.w.org/term' ), 'https://api.w.org/term' ),
|
||||
array( array( 'https://api.w.org/term', 'https://api.w.org/attachment' ), 'https://api.w.org/term,https://api.w.org/attachment' ),
|
||||
array( array( 'https://api.w.org/term', 'https://api.w.org/attachment' ), array( 'https://api.w.org/term', 'https://api.w.org/attachment' ) ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user