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 wp_get_remote_theme_patterns function #4543

Closed
wants to merge 1 commit into from
Closed

Add wp_get_remote_theme_patterns function #4543

wants to merge 1 commit into from

Conversation

oandregal
Copy link
Member

@oandregal oandregal commented Jun 5, 2023

Trac ticket https://core.trac.wordpress.org/ticket/58460
Part of WordPress/gutenberg#45171
Backports WordPress/gutenberg#49307

What?

Adds a new public function, wp_get_remote_theme_patterns to query the patterns datum from theme.json and substitutes current usage of private APIs.

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 wp_get_remote_theme_patterns.
  • Uses the new function in place of the call to the private class WP_Theme_JSON_Resolver.

Testing Instructions

  • Use TwentyTwentyThree theme and add the following to its theme.json:
{
  "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.

Commit message

Themes: add wp_get_remote_theme_patterns function.

Adds a new public function, `wp_get_remote_theme_patterns` to query the `patterns` datum from `theme.json` and substitutes current usage of private APIs.

Props ntsekouras, poena, audrasjb.
Fixes #58460

Public function to retrieve which patterns from the directory
should be registered in the block editor, according to the active theme.
Copy link

@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!

@oandregal
Copy link
Member Author

@oandregal
Copy link
Member Author

Follow-up at #4640

@colorful-tones
Copy link
Member

@oandregal I'm super curious as to what this PR is addressing. The testing notes and description leave me confused. I tried drilling through related Issues and Backport tickets, and I'm still lost.

Also, I had to Google "datum." 🤷‍♂️

I'm grateful for the work. Please explain in layperson's terms what use case or issue this PR solves.

@oandregal
Copy link
Member Author

One of the fields of theme.json is patterns. So far, there wasn't any public API to get the value of that field. This PR introduces it.

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
Development

Successfully merging this pull request may close these issues.

4 participants