diff --git a/src/wp-includes/block-template-utils.php b/src/wp-includes/block-template-utils.php index 88bda858f06a8..438556a7b9df5 100644 --- a/src/wp-includes/block-template-utils.php +++ b/src/wp-includes/block-template-utils.php @@ -411,7 +411,7 @@ function _add_block_template_info( $template_item ) { return $template_item; } - $theme_data = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_custom_templates(); + $theme_data = wp_get_theme_data_custom_templates(); if ( isset( $theme_data[ $template_item['slug'] ] ) ) { $template_item['title'] = $theme_data[ $template_item['slug'] ]['title']; $template_item['postTypes'] = $theme_data[ $template_item['slug'] ]['postTypes']; diff --git a/src/wp-includes/global-styles-and-settings.php b/src/wp-includes/global-styles-and-settings.php index 0f1ca5c82bb59..17ff41d002214 100644 --- a/src/wp-includes/global-styles-and-settings.php +++ b/src/wp-includes/global-styles-and-settings.php @@ -441,6 +441,18 @@ function wp_get_theme_directory_pattern_slugs() { return WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_patterns(); } +/** + * Returns the metadata for the custom templates defined by the theme via theme.json. + * + * @since 6.4.0 + * + * @return array Associative array of `$template_name => $template_data` pairs, + * with `$template_data` having "title" and "postTypes" fields. + */ +function wp_get_theme_data_custom_templates() { + return WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_custom_templates(); +} + /** * Returns the metadata for the template parts defined by the theme. *