-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
REST API: Introduce Plugins and Block Directory endpoint #359
Conversation
'icon' => ( isset( $plugin['icons']['1x'] ) ? $plugin['icons']['1x'] : 'block-default' ), | ||
'assets' => array(), | ||
'last_updated' => $plugin['last_updated'], | ||
'humanized_updated' => sprintf( |
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.
I would like to remove this, but this is blocked by WordPress/gutenberg#14486.
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.
Yeah agreed. We can drop it in future I guess.
src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php
Outdated
Show resolved
Hide resolved
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.
A visual read through looks good to me.
I've also gone through all the permission checks, and once again, at a visual level they all look as I would expect.
Switches to the "Link Manager" plugin. Skips downloading the package and uses a filter to provide a direct download.
We'll also need a PR to update Gutenberg to use the |
@TimothyBJacobs Can we keep everything experimental? Or are these APIs fully ready? |
Thoughts on shipping experimental endpoints in core are mixed so I'm not really sure about shipping experimental endpoints in general. For this endpoint in particular, I don't think it needs to be shipped as experimental. |
// There might be multiple blocks in a plugin. Only the first block is mapped. | ||
$block_data = reset( $plugin['blocks'] ); |
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.
Probably a question for @tellyworth — How will we ensure the right block is imported here? I know Listicles is an example of this, it pulls out the List Item child block instead of the main Listicles block. The wp.org endpoint could return parent
, and we filter out based on the current block, or maybe it only returns blocks with no parent?
Created a PR for updating the namespaces in Gutenberg: WordPress/gutenberg#23528 I tested out the endpoints, and once I got this PR done ^, I was able to test out using the block directory — it all worked as expected. |
…for the prepare item test.
Original Gutenberg PR: WordPress/gutenberg#22454
This also introduces a change in
plugins_api
to not perform a trigger error if this is a json request since we don't want that to break the JSON output.Trac ticket: https://core.trac.wordpress.org/ticket/50321
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.