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

Add gutenberg_get_remote_theme_patterns function #49307

Merged
merged 2 commits into from
Mar 23, 2023

Conversation

oandregal
Copy link
Member

@oandregal oandregal commented Mar 23, 2023

Part of #45171

What?

Adds a new public function, gutenberg_get_remote_theme_patterns to query the patterns datum from theme.json.

Why?

We need to offer public APIs for consumers to add the data they need, so they don't resort to using private APIs.

How?

  • Creates a new function called gutenberg_get_remote_theme_patterns.
  • Uses the new function in place of the call to the private class WP_Theme_JSON_Resolver_Gutenberg.

Testing Instructions

  • Use any theme with theme.json and add the following:
{
  "patterns": [ "partner-logos" ]
}
  • Go to the post editor and open the inserter.
  • Search for "logos".
  • The expected result is that the pattern shows up in the list.

Also test that by removing the patterns from theme.json the pattern is not present.

@oandregal oandregal requested a review from spacedmonkey as a code owner March 23, 2023 12:49
@oandregal oandregal requested a review from ntsekouras March 23, 2023 12:49
@oandregal oandregal self-assigned this Mar 23, 2023
@oandregal oandregal added the [Type] Code Quality Issues or PRs that relate to code quality label Mar 23, 2023
@oandregal oandregal changed the title Add gutenberg_get_remote_theme_patterns function and use it in endpoint Add gutenberg_get_remote_theme_patterns function Mar 23, 2023
@oandregal
Copy link
Member Author

I'm struggling to use the feature as per the testing instructions in trunk (also in this PR). I'll update when I know more.

Copy link
Contributor

@ntsekouras ntsekouras 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, thank you!

@ntsekouras
Copy link
Contributor

I'm struggling to use the feature as per the testing instructions in trunk (also in this PR). I'll update when I know more.

Your instructions are good, but you have to ensure that the theme you're using allows remote patterns based on should_load_remote_block_patterns filter's value.

@oandregal
Copy link
Member Author

ok, updated the test instructions with a different pattern/text search and it works perfectly (both trunk and this branch). Tested empty and twentytwentythree themes.

@oandregal oandregal merged commit 12f406f into trunk Mar 23, 2023
@oandregal oandregal deleted the add/get-remote-theme-patterns branch March 23, 2023 15:37
@github-actions github-actions bot added this to the Gutenberg 15.5 milestone Mar 23, 2023
@oandregal
Copy link
Member Author

Backporting at WordPress/wordpress-develop#4543

@oandregal oandregal added the Needs PHP backport Needs PHP backport to Core label Jun 5, 2023
@ramonjd ramonjd removed the Needs PHP backport Needs PHP backport to Core label Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants