@@ -241,9 +241,9 @@ public static function get_theme_data( $deprecated = array(), $options = array()
241
241
$ options = wp_parse_args ( $ options , array ( 'with_supports ' => true ) );
242
242
243
243
if ( null === static ::$ theme || ! static ::has_same_registered_blocks ( 'theme ' ) ) {
244
- $ theme_json_file = static ::get_file_path_from_theme ( 'theme.json ' );
245
244
$ 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 ) ) {
247
247
$ theme_json_data = static ::read_json_file ( $ theme_json_file );
248
248
$ theme_json_data = static ::translate ( $ theme_json_data , $ wp_theme ->get ( 'TextDomain ' ) );
249
249
} else {
@@ -263,8 +263,8 @@ public static function get_theme_data( $deprecated = array(), $options = array()
263
263
264
264
if ( $ wp_theme ->parent () ) {
265
265
// 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 ) ) {
268
268
$ parent_theme_json_data = static ::read_json_file ( $ parent_theme_json_file );
269
269
$ parent_theme_json_data = static ::translate ( $ parent_theme_json_data , $ wp_theme ->parent ()->get ( 'TextDomain ' ) );
270
270
$ parent_theme = new WP_Theme_JSON_Gutenberg ( $ parent_theme_json_data );
@@ -670,6 +670,8 @@ public static function theme_has_support() {
670
670
* @return string The whole file path or empty if the file doesn't exist.
671
671
*/
672
672
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 ' );
673
675
$ path = $ template ? get_template_directory () : get_stylesheet_directory ();
674
676
$ candidate = $ path . '/ ' . $ file_name ;
675
677
0 commit comments