[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:38:54 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
-------------------------------------------------+-------------------------
Comment (by rheinardkorf):
Replying to [comment:20 jnylen0]:
> - 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.
Good spot! There are 2 possible ways to address this. 1) Create a custom
mapping object in which we can pass the request object. 2) Drop array_map
and do a traditional foreach. For the sake of this problem I'm inclined
to go the latter.
> - `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' )
)`.
Which method would you like to implement the check on, `::embed_links()`
or `::response_to_data()` ?
> - We might as well go ahead and use `$request->get_param` or
`$request['_embed']` - this should give us JSON and POST support for free.
Sorry I do not follow this last one. Where would you like me to do this?
Thanks for the feedback. If you could answer those questions for me I
could work on another patch a bit later. Got some client work first today.
Cheers.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39696#comment:21>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list