-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Regression: Cannot register_block_pattern using current_screen hook. #40736
Comments
This might be related to https://github.com/WordPress/gutenberg/pull/39493/files but I am not 100% sure yet. |
Patterns are now loaded through the REST API, see bdd024e. |
@ocean90 If that's true, should there be warnings thrown when using |
Also, with this new REST API approach, there seems to be no way of limiting which patterns load for specific post types. For example if I want to load "woocommerce specific" block patterns only on |
Hey @johnstonphilip, thanks for submitting this issue! Is the use of Given the move to loading patterns through the REST API, it's unlikely that registering patterns using |
It's not something from any documentation, but just the only hook available where registering by I suppose it's fine to not do anything to fix this regression since it wasn't part of the official documentation, but anyone with knowledge of how WordPress hooks work under the hood might have done it this way to improve performance, and/or to filter patterns by any number of reasons (post_type, site editor, etc). I guess the thing to be aware of here is that this change could break implementations that are currently working. If using any other hook than |
I opened a trac ticket to add |
"should" is not the same as "must". Changing the code to throw a Is this problematic for extenders? Should registration only be with |
Here's some examples of extender usage from this search result: Most seem to use |
I've put this on the WP 6.0 project as it's a regression. |
@peterwilsoncc given the current/new implementation of patterns, I'm not sure that |
@hellofromtonya Note that the changes in bdd024e likely already broke every extender's implementations that do not use |
WordPress has a core philosophy to maintain backward compatibility, so neither a doing it wrong call or saying it's not possible is the answer. Something needs to be fixed. bdd024e removed examples of Gutenberg registering block patterns on hooks other than |
I'm not really sure how to proceed with this one.. Any thoughts @jsnajdr ? |
Ideally we should add a To be able to still register patterns the old way, on the admin screen instead of in the REST endpoint, we could:
In other words, instead of removing block pattern registration from the editor page HTML and moving it to REST completely, we would continue to support both methods. |
A combination of WordPress/wordpress-develop#2672 (Core) and #40818 (Gutenberg) should fix this. How to test: Then open a post editor for a post. The Blockmeister pattern should be visible in the Block Inserter UI. Before these patches, it wouldn't be there. You can also verify that the Blockmeister pattern is part of the initial HTML ( |
Description
On WP
5.9.4-alpha-53081
I was able to register block patterns using thecurrent_screen
hook.On WP
6.0-beta3-53305
, the same code does not register block patterns any longer.Example code:
Step-by-step reproduction instructions
5.9.4-alpha-53081
use the example code above to register a pattern on thecurrent_screen
hook.6.0-beta3-53305
, notice it no longer works, and no pattern is registered or shown in the block editor.Screenshots, screen recording, code snippet
5.9.4-alpha-53081
✅ Works as expected.6.0-beta3-53305
❌ BrokenEnvironment info
6.0-beta3-53305
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: