[wp-trac] [WordPress Trac] #39696: REST API: Filter which links get embedded when passing the ?_embed query parameter
WordPress Trac
noreply at wordpress.org
Sat Feb 18 20:06:19 UTC 2017
#39696: REST API: Filter which links get embedded when passing the ?_embed query
parameter
-------------------------------------------------+-------------------------
Reporter: rheinardkorf | Owner: jnylen0
Type: enhancement | Status: assigned
Priority: normal | Milestone: Future
Component: REST API | Release
Severity: normal | Version: 4.4
Keywords: has-patch has-unit-tests needs- | Resolution:
refresh | Focuses: rest-api
-------------------------------------------------+-------------------------
Changes (by jnylen0):
* owner: adamsilverstein => jnylen0
* version: 4.7.1 => 4.4
* milestone: Awaiting Review => Future Release
Comment:
Replying to [comment:23 rheinardkorf]:
> I believe I've now addressed your feedback from the previous patch. Let
me know if there is anything else you'd like me to do here.
After looking at this again, I think we can improve the approach further.
Instead of adding a new `$request` parameter, let's change the `$embed`
parameter to `response_to_data` as follows:
{{{#!diff
- @param bool $embed Whether links should be embedded.
+ @param bool|array $embed Which links to embed (none, all, or a specific
list).
}}}
So, we'll need to compute the value of this parameter (either `false`,
`true`, or an array) before calling `response_to_data`, and then pass it
down to `embed_links` (with a default value of `true`).
This should be a cleaner and more backwards-compatible way of making the
change here.
We can also make some further improvements to the test cases:
- Split up into multiple test methods
- Set parameters using `$request->set_query_param`,
`$request->set_json_param` etc., for all cases I listed in comment:8
- Potentially use a [https://phpunit.de/manual/current/en/writing-tests-
for-phpunit.html#writing-tests-for-phpunit.data-providers PHPUnit data
provider] to get rid of boilerplate in the tests
I'm also happy to handle any of these further improvements later.
Finally, you had asked about getting this change into 4.7.3. For this
release we are targeting fixes with potential backwards-compatibility
implications, as these need to be made sooner rather than later. Since
this is a pretty clean enhancement, and it's not quite ready yet, I think
we can hold off until 4.8 or a potential 4.7.4.
If you need this functionality in the meantime, then I would recommend
creating a plugin. Here is a
[https://gist.github.com/joehoyle/12e37c293adf2bb0ea1b potential starting
point] for such a plugin.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39696#comment:26>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list