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



git-svn-id: https://develop.svn.wordpress.org/trunk@55926 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
André 2023-06-16 08:06:30 +00:00
parent 9fe8cdf126
commit be395bf73a
2 changed files with 13 additions and 1 deletions

View File

@ -287,7 +287,7 @@ function _register_remote_theme_patterns() {
return;
}
$pattern_settings = WP_Theme_JSON_Resolver::get_theme_data()->get_patterns();
$pattern_settings = wp_get_remote_theme_patterns();
if ( empty( $pattern_settings ) ) {
return;
}

View File

@ -426,3 +426,15 @@ function wp_clean_theme_json_cache() {
wp_cache_delete( 'wp_get_global_styles_custom_css', 'theme_json' );
WP_Theme_JSON_Resolver::clean_cached_data();
}
/**
* Returns the current theme's wanted patterns (slugs) to be
* registered from Pattern Directory.
*
* @since 6.3.0
*
* @return string[]
*/
function wp_get_remote_theme_patterns() {
return WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_patterns();
}