[wp-trac] [WordPress Trac] #39696: REST API: Filter which links get embedded when passing the ?_embed query parameter
WordPress Trac
noreply at wordpress.org
Mon Jan 30 20:27:57 UTC 2017
#39696: REST API: Filter which links get embedded when passing the ?_embed query
parameter
-------------------------------------------------+-------------------------
Reporter: rheinardkorf | Owner:
Type: enhancement | adamsilverstein
Priority: normal | Status: assigned
Component: REST API | Milestone: Awaiting
Severity: normal | Review
Keywords: has-patch has-unit-tests needs- | Version: 4.7.1
refresh | Resolution:
| Focuses: rest-api
-------------------------------------------------+-------------------------
Changes (by jnylen0):
* keywords: 2nd-opinion needs-refresh needs-unit-tests => has-patch has-
unit-tests needs-refresh
Comment:
Thanks @rheinardkorf! This is looking better.
A few notes on [attachment:39696.2.diff]:
- This will not work for embedding objects into arrays such as a list of
posts. See: https://github.com/WordPress/wordpress-
develop/blob/4.7.1/src/wp-includes/rest-api/class-wp-rest-server.php#L430
- we need to come up with a way to pass the request object there too.
- `embed_links` is not called anywhere else in WP except for
`test_link_embedding_without_links`, so I think we should go ahead and
treat the `$request` parameter as required. Since `embed_links` is a
protected method, the only way this could break is if a plugin is
overriding `WP_REST_Server`. I am honestly not sure if we should worry
about this or not - maybe we can just add a check into the code like this:
`$embed = ( empty( $request ) ? false : $request->get_param( '_embed' )
)`.
- We might as well go ahead and use `$request->get_param` or
`$request['_embed']` - this should give us JSON and POST support for free.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39696#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list