- Timestamp:
- 11/10/2022 10:40:59 PM (2 years ago)
- Location:
- branches/6.1
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.1
-
branches/6.1/src/wp-includes/class-wp-theme-json-resolver.php
r54779 r54800 247 247 248 248 if ( null === static::$theme || ! static::has_same_registered_blocks( 'theme' ) ) { 249 $theme_json_data = static::read_json_file( static::get_file_path_from_theme( 'theme.json' ) ); 250 $theme_json_data = static::translate( $theme_json_data, wp_get_theme()->get( 'TextDomain' ) ); 249 $theme_json_file = static::get_file_path_from_theme( 'theme.json' ); 250 if ( '' !== $theme_json_file ) { 251 $theme_json_data = static::read_json_file( $theme_json_file ); 252 $theme_json_data = static::translate( $theme_json_data, wp_get_theme()->get( 'TextDomain' ) ); 253 } else { 254 $theme_json_data = array(); 255 } 251 256 252 257 /** … … 260 265 $theme_json_data = $theme_json->get_data(); 261 266 static::$theme = new WP_Theme_JSON( $theme_json_data ); 262 } 263 264 if ( wp_get_theme()->parent() ) { 265 // Get parent theme.json. 266 $parent_theme_json_data = static::read_json_file( static::get_file_path_from_theme( 'theme.json', true ) ); 267 $parent_theme_json_data = static::translate( $parent_theme_json_data, wp_get_theme()->parent()->get( 'TextDomain' ) ); 268 $parent_theme = new WP_Theme_JSON( $parent_theme_json_data ); 269 270 /* 271 * Merge the child theme.json into the parent theme.json. 272 * The child theme takes precedence over the parent. 273 */ 274 $parent_theme->merge( static::$theme ); 275 static::$theme = $parent_theme; 267 268 if ( wp_get_theme()->parent() ) { 269 // Get parent theme.json. 270 $parent_theme_json_file = static::get_file_path_from_theme( 'theme.json', true ); 271 if ( '' !== $parent_theme_json_file ) { 272 $parent_theme_json_data = static::read_json_file( $parent_theme_json_file ); 273 $parent_theme_json_data = static::translate( $parent_theme_json_data, wp_get_theme()->parent()->get( 'TextDomain' ) ); 274 $parent_theme = new WP_Theme_JSON( $parent_theme_json_data ); 275 276 /* 277 * Merge the child theme.json into the parent theme.json. 278 * The child theme takes precedence over the parent. 279 */ 280 $parent_theme->merge( static::$theme ); 281 static::$theme = $parent_theme; 282 } 283 } 276 284 } 277 285 … … 404 412 $theme = wp_get_theme(); 405 413 } 414 415 /* 416 * Bail early if the theme does not support a theme.json. 417 * 418 * Since WP_Theme_JSON_Resolver::theme_has_support() only supports the active 419 * theme, the extra condition for whether $theme is the active theme is 420 * present here. 421 */ 422 if ( $theme->get_stylesheet() === get_stylesheet() && ! static::theme_has_support() ) { 423 return array(); 424 } 425 406 426 $user_cpt = array(); 407 427 $post_type_filter = 'wp_global_styles'; … … 583 603 if ( ! isset( static::$theme_has_support ) ) { 584 604 static::$theme_has_support = ( 585 is_readable( static::get_file_path_from_theme( 'theme.json' ) )||586 is_readable( static::get_file_path_from_theme( 'theme.json', true ) )605 static::get_file_path_from_theme( 'theme.json' ) !== '' || 606 static::get_file_path_from_theme( 'theme.json', true ) !== '' 587 607 ); 588 608 }
Note: See TracChangeset
for help on using the changeset viewer.