-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Patterns: Allow for filtering of block patterns by source #51672
Conversation
Flaky tests detected in aac252d. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5320797322
|
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.
Looks good so far. I think there are a few changes that would be good to address.
There should also be some documentation changes for register_block_pattern
- https://developer.wordpress.org/block-editor/reference-guides/block-api/block-patterns/.
$patterns = $response->get_data(); | ||
|
||
foreach ( $patterns as $pattern ) { | ||
$pattern['source'] = 'core'; |
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 think it should be more granular descriptive than just 'core' so that there are more options to use it for different things in the future.
Some suggestions based on the sources that I can see:
- 'core' (bundled with WordPress core)
- 'plugin' (plugins that register patterns can use this)
- 'theme' (I'm not sure if themes call
register_block_pattern
directly, but they could use this as the source if they do) - 'pattern-directory/theme' (declared in the theme.json and pulled from the pattern directory)
- 'pattern-directory/core' (core patterns in the pattern directory)
- 'pattern-directory/featured' (featured patterns in the pattern directory).
Might be good to get some more opinions though, as I'm not too familiar with all the different places that patterns come from.
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've pushed a few more granular source values in 694f71d.
@TimothyBJacobs it was suggested you might have some wisdom to share regarding the proposed REST API changes in this PR. If you have the time to take a look at this, it would be greatly appreciated as we're trying to get this in for 6.3 🙏 |
I've pushed a commit that adds mention of edit: rebased the PR to solve a conflict too. |
e0d5c25
to
7ea3b03
Compare
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.
This looks good to me.
There will be a PHP backport of this code to WordPress core, so that's a further opportunity to leave feedback, and we can replicate any changes back to the Gutenberg codebase.
I think the one thing missing right now is tests, so it'll be good to include some in the backport PR.
lib/compat/wordpress-6.3/class-gutenberg-rest-block-patterns-controller-6-3.php
Show resolved
Hide resolved
lib/compat/wordpress-6.3/class-gutenberg-rest-block-patterns-controller-6-3.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.
LGTM
…51672) --------- Co-authored-by: kevin940726 <kai@kaihao.dev> Co-authored-by: Daniel Richards <daniel.richards@automattic.com>
Related:
Backport PR for this change: WordPress/wordpress-develop#4697
What?
source
attributesource
attributeWhy?
The Site Editor Library has been designed to allow users a more refined experience in managing their patterns. This requires the ability to filter out core block patterns which will not be editable by users.
How?
Testing Instructions