Changeset 53072 for trunk/src/wp-includes/class-wp-theme-json-resolver.php
- Timestamp:
- 04/05/2022 09:50:13 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json-resolver.php
r52744 r53072 450 450 } 451 451 452 /** 453 * Returns the style variations defined by the theme. 454 * 455 * @since 6.0.0 456 * 457 * @return array 458 */ 459 public static function get_style_variations() { 460 $variations = array(); 461 $base_directory = get_stylesheet_directory() . '/styles'; 462 if ( is_dir( $base_directory ) ) { 463 $nested_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $base_directory ) ); 464 $nested_html_files = iterator_to_array( new RegexIterator( $nested_files, '/^.+\.json$/i', RecursiveRegexIterator::GET_MATCH ) ); 465 ksort( $nested_html_files ); 466 foreach ( $nested_html_files as $path => $file ) { 467 $decoded_file = wp_json_file_decode( $path, array( 'associative' => true ) ); 468 if ( is_array( $decoded_file ) ) { 469 $translated = static::translate( $decoded_file, wp_get_theme()->get( 'TextDomain' ) ); 470 $variation = ( new WP_Theme_JSON( $translated ) )->get_raw_data(); 471 if ( empty( $variation['title'] ) ) { 472 $variation['title'] = basename( $path, '.json' ); 473 } 474 $variations[] = $variation; 475 } 476 } 477 } 478 return $variations; 479 } 452 480 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)