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

Patterns: Fix core 'Featured' pattern category registration #40650

Merged
merged 1 commit into from
Apr 27, 2022

Conversation

Mamaduka
Copy link
Member

@Mamaduka Mamaduka commented Apr 27, 2022

What?

Resolves #40443.

PR fixes issue with missing core "Featured" patterns category.

Why?

Regression after Gutenberg started loading patterns via REST API (#39185), the _load_remote_featured_patterns method isn't called during WP initialization.

How?

Updates method that registered the category.

P.S. This will be handled via _register_core_block_patterns_and_categories when backported into WP Core.

Testing Instructions

  1. Activate the 2016 theme or any theme that doesn't register Featured pattern categories.
  2. Open a Post or Page.
  3. Open Block inserter -> Patterns Tab
  4. Confirm that the "Featured" patterns category is registered.

Screenshots or screencast

CleanShot 2022-04-27 at 15 56 09

@Mamaduka Mamaduka self-assigned this Apr 27, 2022
@Mamaduka Mamaduka added [Type] Regression Related to a regression in the latest release [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced labels Apr 27, 2022
@ndiego
Copy link
Member

ndiego commented Apr 27, 2022

I am having trouble getting this to work for me. The trick is that Twenty Twenty-Two registered the "Featured" category itself, even though it didn't have to. You need to comment out line 17 of /inc/block-patterns.php in Twenty Twenty-Two. Doing so still gives me the Uncategorized category.

@Mamaduka
Copy link
Member Author

@ndiego, That's how I was testing this fix. I forgot to mention it in the description.

You can test this with the 2016 theme. It doesn't register the featured category.

Copy link
Member

@ndiego ndiego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, my bad. I was on your branch to start testing, then got distracted with another branch. I then ended up testing on the wrong branch. 🤦‍♂️

Just tested using Twenty Sixteen and Frost. Frost uses the new method of registering patterns in the /patterns folder. Both work as advertised. 🙌

I will note that this does not work if the theme has remove_theme_support( 'core-block-patterns' ); set. I think that is ok. If they are disabling all the core patterns, then they want a custom experience and should likely register the "Featured" category themselves if they want it.

@Mamaduka
Copy link
Member Author

Ugh, my bad. I was on your branch to start testing, then got distracted with another branch. I then ended up testing on the wrong branch. 🤦‍♂️

Happens to me all the time 😅

I will note that this does not work if the theme has remove_theme_support( 'core-block-patterns' ); set.

I think this should be expected behavior.

Thanks for testing, @ndiego.

@Mamaduka Mamaduka merged commit 2e829fa into trunk Apr 27, 2022
@Mamaduka Mamaduka deleted the fix/patterns-featured-category branch April 27, 2022 13:58
@github-actions github-actions bot added this to the Gutenberg 13.2 milestone Apr 27, 2022
@priethor
Copy link
Contributor

Should we add the Backport to WP Beta/RC label to this?

@Mamaduka
Copy link
Member Author

@priethor, this requires separate Core patch, and I will create it tomorrow.

@Mamaduka
Copy link
Member Author

Core patch is ready - WordPress/wordpress-develop#2640.

pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Apr 29, 2022
Backports changes from WordPress/gutenberg#40650.

Patch fixes regression, and moves core "Featured" pattern category registration from `_load_remote_featured_patterns` into `_register_core_block_patterns_and_categories`.

Follow-up [53152].
Props mamaduka, ntsekouras.
See #55567.



git-svn-id: https://develop.svn.wordpress.org/trunk@53312 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Apr 29, 2022
Backports changes from WordPress/gutenberg#40650.

Patch fixes regression, and moves core "Featured" pattern category registration from `_load_remote_featured_patterns` into `_register_core_block_patterns_and_categories`.

Follow-up [53152].
Props mamaduka, ntsekouras.
See #55567.


Built from https://develop.svn.wordpress.org/trunk@53312


git-svn-id: http://core.svn.wordpress.org/trunk@52901 1a063a9b-81f0-0310-95a4-ce76da25c4cd
gMagicScott pushed a commit to gMagicScott/core.wordpress-mirror that referenced this pull request Apr 29, 2022
Backports changes from WordPress/gutenberg#40650.

Patch fixes regression, and moves core "Featured" pattern category registration from `_load_remote_featured_patterns` into `_register_core_block_patterns_and_categories`.

Follow-up [53152].
Props mamaduka, ntsekouras.
See #55567.


Built from https://develop.svn.wordpress.org/trunk@53312


git-svn-id: https://core.svn.wordpress.org/trunk@52901 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Type] Regression Related to a regression in the latest release
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Patterns: core 'featured' category not registered
3 participants