Skip to content

Commit 699819c

Browse files
Deprecated get_file_path_from_theme method. (#45831)
* Deprecated function * Update lib/class-wp-theme-json-resolver-gutenberg.php Co-authored-by: Colin Stewart <[email protected]> --------- Co-authored-by: Colin Stewart <[email protected]>
1 parent 3714c11 commit 699819c

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
@@ -241,9 +241,9 @@ public static function get_theme_data( $deprecated = array(), $options = array()
241241
$options = wp_parse_args( $options, array( 'with_supports' => true ) );
242242

243243
if ( null === static::$theme || ! static::has_same_registered_blocks( 'theme' ) ) {
244-
$theme_json_file = static::get_file_path_from_theme( 'theme.json' );
245244
$wp_theme = wp_get_theme();
246-
if ( '' !== $theme_json_file ) {
245+
$theme_json_file = $wp_theme->get_file_path( 'theme.json' );
246+
if ( is_readable( $theme_json_file ) ) {
247247
$theme_json_data = static::read_json_file( $theme_json_file );
248248
$theme_json_data = static::translate( $theme_json_data, $wp_theme->get( 'TextDomain' ) );
249249
} else {
@@ -263,8 +263,8 @@ public static function get_theme_data( $deprecated = array(), $options = array()
263263

264264
if ( $wp_theme->parent() ) {
265265
// Get parent theme.json.
266-
$parent_theme_json_file = static::get_file_path_from_theme( 'theme.json', true );
267-
if ( '' !== $parent_theme_json_file ) {
266+
$parent_theme_json_file = $wp_theme->parent()->get_file_path( 'theme.json' );
267+
if ( $theme_json_file !== $parent_theme_json_file && is_readable( $parent_theme_json_file ) ) {
268268
$parent_theme_json_data = static::read_json_file( $parent_theme_json_file );
269269
$parent_theme_json_data = static::translate( $parent_theme_json_data, $wp_theme->parent()->get( 'TextDomain' ) );
270270
$parent_theme = new WP_Theme_JSON_Gutenberg( $parent_theme_json_data );
@@ -670,6 +670,8 @@ public static function theme_has_support() {
670670
* @return string The whole file path or empty if the file doesn't exist.
671671
*/
672672
protected static function get_file_path_from_theme( $file_name, $template = false ) {
673+
// TODO: Remove this method from core on 6.3 release.
674+
_deprecated_function( __METHOD__, '6.3.0' );
673675
$path = $template ? get_template_directory() : get_stylesheet_directory();
674676
$candidate = $path . '/' . $file_name;
675677

0 commit comments

Comments
 (0)