From a06d0350a7e36eb5aa82946f3620df1e34264202 Mon Sep 17 00:00:00 2001 From: Jonny Harris Date: Tue, 17 Jan 2023 10:47:09 +0000 Subject: [PATCH] Deprecated function --- lib/class-wp-theme-json-resolver-gutenberg.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/class-wp-theme-json-resolver-gutenberg.php b/lib/class-wp-theme-json-resolver-gutenberg.php index 8733fd13bf2c77..46c10113fc6a6b 100644 --- a/lib/class-wp-theme-json-resolver-gutenberg.php +++ b/lib/class-wp-theme-json-resolver-gutenberg.php @@ -237,9 +237,9 @@ public static function get_theme_data( $deprecated = array(), $options = array() $options = wp_parse_args( $options, array( 'with_supports' => true ) ); if ( null === static::$theme || ! static::has_same_registered_blocks( 'theme' ) ) { - $theme_json_file = static::get_file_path_from_theme( 'theme.json' ); $wp_theme = wp_get_theme(); - if ( '' !== $theme_json_file ) { + $theme_json_file = $wp_theme->get_file_path( 'theme.json' ); + if ( is_readable( $theme_json_file ) ) { $theme_json_data = static::read_json_file( $theme_json_file ); $theme_json_data = static::translate( $theme_json_data, $wp_theme->get( 'TextDomain' ) ); } else { @@ -262,8 +262,8 @@ public static function get_theme_data( $deprecated = array(), $options = array() if ( $wp_theme->parent() ) { // Get parent theme.json. - $parent_theme_json_file = static::get_file_path_from_theme( 'theme.json', true ); - if ( '' !== $parent_theme_json_file ) { + $parent_theme_json_file = $wp_theme->parent()->get_file_path( 'theme.json' ); + if ( $theme_json_file !== $parent_theme_json_file && is_readable( $parent_theme_json_file ) ) { $parent_theme_json_data = static::read_json_file( $parent_theme_json_file ); $parent_theme_json_data = static::translate( $parent_theme_json_data, $wp_theme->parent()->get( 'TextDomain' ) ); // BEGIN OF EXPERIMENTAL CODE. Not to backport to core. @@ -639,6 +639,8 @@ public static function theme_has_support() { * @return string The whole file path or empty if the file doesn't exist. */ protected static function get_file_path_from_theme( $file_name, $template = false ) { + // TODO: Remove this method from core on 6.2 release. + _deprecated_function( __METHOD__, '6.2.0' ); $path = $template ? get_template_directory() : get_stylesheet_directory(); $candidate = $path . '/' . $file_name;