-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Legacy widget rendering endpoint #1508
Legacy widget rendering endpoint #1508
Conversation
All the tests pass! @TimothyBJacobs – do you fancy a review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
I only have 1 small remark.
src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php
Outdated
Show resolved
Hide resolved
…controller.php Co-authored-by: Anton Vlasenko <43744263+anton-vlasenko@users.noreply.github.com>
Great suggestion @anton-vlasenko ! I just added it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good 👍
I think we should bring this in along with the change in the legacy widget that uses it. |
@draganescu |
src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php
Show resolved
Hide resolved
How will the iframe use this request? Can iframes make I'd also like to get the @TimothyBJacobs tick of approval before merging this 🙂 |
@noisysocks I think the idea is to make that request using const response = await apiFetch({ path: '...' });
const html = await response.text();
<iframe srcDoc={html} /> In that case, I think this approach is very doable and could be backward-compatible and minimal. |
@noisysocks exactly as @kevin940726 said. We may either set
@draganescu the change in the legacy widget depends on this change. We'll also have to polyfill this endpoint in the Gutenberg plugin for 5.7 and 5.8. Now that I think about it, maybe we should only add it to Gutenberg repo and not here 🤔 and then backport it on the next major release |
src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php
Outdated
Show resolved
Hide resolved
src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php
Outdated
Show resolved
Hide resolved
…controller.php Co-authored-by: Timothy Jacobs <timothy@ironbounddesigns.com>
…permission_callback value
@TimothyBJacobs thank you for reviewing! I just addressed all your feedback. |
Thanks @adamziel! The only small tweak is that the |
Last minute feedback, sorry! Did you consider incorporating this functionality into the existing |
Yes we probably should do this. That way it can be used by WordPress/gutenberg#34184, too. |
Let's continue in the Gutenberg repo then: WordPress/gutenberg#34230 |
Related to WordPress/gutenberg#33540
Trac Ticket: https://core.trac.wordpress.org/ticket/53957
This adds a
/wp/v2/widget-types/<widget type>/render
endpoint which accepts POST data and returns the same output as the previous iframe-oriented GET endpoint.Test plan:
/wp-admin/widgets.php
Alternatives considered:
ServerSideRender
– we need to render a full HTML document withwp_head()
, CSS links, maybe some additional scripts, and this is much more that I would like to return from a block rendering API.admin_init
hook handler to work withPOST
requests – it's tricky and doesn't seem right, I don't think we should stretch hooks like that. This clearly is an API request so let's treat it as such.