Skip to content
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

Closed
wants to merge 9 commits into from

Conversation

TimothyBJacobs
Copy link
Member

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.

'icon' => ( isset( $plugin['icons']['1x'] ) ? $plugin['icons']['1x'] : 'block-default' ),
'assets' => array(),
'last_updated' => $plugin['last_updated'],
'humanized_updated' => sprintf(
Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member

@dd32 dd32 left a 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.

@TimothyBJacobs
Copy link
Member Author

We'll also need a PR to update Gutenberg to use the wp/v2 namespace.

@ellatrix
Copy link
Member

@TimothyBJacobs Can we keep everything experimental? Or are these APIs fully ready?

@TimothyBJacobs
Copy link
Member Author

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.

Comment on lines +120 to +121
// There might be multiple blocks in a plugin. Only the first block is mapped.
$block_data = reset( $plugin['blocks'] );
Copy link
Contributor

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?

@ryelle
Copy link
Contributor

ryelle commented Jun 26, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants