Skip to content

Commit a06d035

Browse files
committed
Deprecated function
1 parent 71a3344 commit a06d035

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/class-wp-theme-json-resolver-gutenberg.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ public static function get_theme_data( $deprecated = array(), $options = array()
237237
$options = wp_parse_args( $options, array( 'with_supports' => true ) );
238238

239239
if ( null === static::$theme || ! static::has_same_registered_blocks( 'theme' ) ) {
240-
$theme_json_file = static::get_file_path_from_theme( 'theme.json' );
241240
$wp_theme = wp_get_theme();
242-
if ( '' !== $theme_json_file ) {
241+
$theme_json_file = $wp_theme->get_file_path( 'theme.json' );
242+
if ( is_readable( $theme_json_file ) ) {
243243
$theme_json_data = static::read_json_file( $theme_json_file );
244244
$theme_json_data = static::translate( $theme_json_data, $wp_theme->get( 'TextDomain' ) );
245245
} else {
@@ -262,8 +262,8 @@ public static function get_theme_data( $deprecated = array(), $options = array()
262262

263263
if ( $wp_theme->parent() ) {
264264
// Get parent theme.json.
265-
$parent_theme_json_file = static::get_file_path_from_theme( 'theme.json', true );
266-
if ( '' !== $parent_theme_json_file ) {
265+
$parent_theme_json_file = $wp_theme->parent()->get_file_path( 'theme.json' );
266+
if ( $theme_json_file !== $parent_theme_json_file && is_readable( $parent_theme_json_file ) ) {
267267
$parent_theme_json_data = static::read_json_file( $parent_theme_json_file );
268268
$parent_theme_json_data = static::translate( $parent_theme_json_data, $wp_theme->parent()->get( 'TextDomain' ) );
269269
// BEGIN OF EXPERIMENTAL CODE. Not to backport to core.
@@ -639,6 +639,8 @@ public static function theme_has_support() {
639639
* @return string The whole file path or empty if the file doesn't exist.
640640
*/
641641
protected static function get_file_path_from_theme( $file_name, $template = false ) {
642+
// TODO: Remove this method from core on 6.2 release.
643+
_deprecated_function( __METHOD__, '6.2.0' );
642644
$path = $template ? get_template_directory() : get_stylesheet_directory();
643645
$candidate = $path . '/' . $file_name;
644646

0 commit comments

Comments
 (0)