@@ -237,9 +237,9 @@ public static function get_theme_data( $deprecated = array(), $options = array()
237
237
$ options = wp_parse_args ( $ options , array ( 'with_supports ' => true ) );
238
238
239
239
if ( null === static ::$ theme || ! static ::has_same_registered_blocks ( 'theme ' ) ) {
240
- $ theme_json_file = static ::get_file_path_from_theme ( 'theme.json ' );
241
240
$ 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 ) ) {
243
243
$ theme_json_data = static ::read_json_file ( $ theme_json_file );
244
244
$ theme_json_data = static ::translate ( $ theme_json_data , $ wp_theme ->get ( 'TextDomain ' ) );
245
245
} else {
@@ -262,8 +262,8 @@ public static function get_theme_data( $deprecated = array(), $options = array()
262
262
263
263
if ( $ wp_theme ->parent () ) {
264
264
// 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 ) ) {
267
267
$ parent_theme_json_data = static ::read_json_file ( $ parent_theme_json_file );
268
268
$ parent_theme_json_data = static ::translate ( $ parent_theme_json_data , $ wp_theme ->parent ()->get ( 'TextDomain ' ) );
269
269
// BEGIN OF EXPERIMENTAL CODE. Not to backport to core.
@@ -639,6 +639,8 @@ public static function theme_has_support() {
639
639
* @return string The whole file path or empty if the file doesn't exist.
640
640
*/
641
641
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 ' );
642
644
$ path = $ template ? get_template_directory () : get_stylesheet_directory ();
643
645
$ candidate = $ path . '/ ' . $ file_name ;
644
646
0 commit comments