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

Allow remote pattern registration in theme.json when core patterns are disabled #2925

Closed
wants to merge 3 commits into from

Conversation

ndiego
Copy link
Member

@ndiego ndiego commented Jun 30, 2022

Fixes: WordPress/gutenberg#41282

In 6.0 we now have functionality that allows you to register selected remote patterns (from the Pattern Directory) via theme.json. While this is great, it requires you to fully enable all core and remote patterns. This can be a blocker to adoption.

Many theme authors want to have all core and remote patterns disabled by default using remove_theme_support( 'core-block-patterns' ). This ensures they are serving only patterns relevant to their theme to customers/clients.

This PR/Trac ticket removes the theme support check from the function that registers remote patterns specified in theme.json. This allows theme authors to disable core patterns but then selectively register the ones they want from the Pattern Directory. We assume that if a theme author intentionally specifies patterns in theme.json, they intend for them to be present in the pattern inserter and the check is not required.

This change will make the Pattern Directory more appealing/usable from the theme author's perspective.

Note, that while this issue is technically not a "bug", it is a pretty large blocker for Pattern Directory adoption and I feel should be considered for 6.0.1.

Trac ticket: https://core.trac.wordpress.org/ticket/56112


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.

ndiego added 2 commits June 30, 2022 07:39
…e-patterns-disabled

Allow remote pattern registration in theme.json when core patterns are disabled
@github-actions
Copy link

Hi @ndiego! 👋

Thank you for your contribution to WordPress! 💖

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description.

Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.

More information about how GitHub pull requests can be used to contribute to WordPress can be found in this blog post.

Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook.

If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook.

The Developer Hub also documents the various coding standards that are followed:

Thank you,
The WordPress Project

@ryelle
Copy link
Contributor

ryelle commented Jul 1, 2022

I think removing the get_theme_support( 'core-block-patterns' ) check makes sense here — these aren't core patterns. But the should_load_remote_block_patterns check should stay, in case someone wants to explicitly disable external API requests.

For reference, there's only 1 theme in the wp.org directory that disables the remote loading, but it loads its patterns locally.

@ndiego
Copy link
Member Author

ndiego commented Jul 4, 2022

Thanks for the feedback @ryelle! That makes good sense. I have updated the PR and added back the should_load_remote_block_patterns.

Copy link
Contributor

@ryelle ryelle left a comment

Choose a reason for hiding this comment

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

Looks good now 👍🏻

@ndiego
Copy link
Member Author

ndiego commented Jul 26, 2022

Thanks @ryelle, are you able to merge? I don't have permission on this repo. In the meantime, I will put together the corresponding PR needed on the Gutenberg side.

@audrasjb
Copy link
Contributor

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

Successfully merging this pull request may close these issues.

When removing core pattern, allow theme.json pattern slugs to be listed in inserter
3 participants