Changeset 56771 for trunk/src/wp-includes/block-patterns.php
- Timestamp:
- 10/03/2023 06:17:03 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-patterns.php
r56765 r56771 342 342 343 343 foreach ( $themes as $theme ) { 344 $pattern _data= _wp_get_block_patterns( $theme );345 $dirpath 346 $text_domain 347 348 foreach ( $pattern _data['patterns']as $file => $pattern_data ) {344 $patterns = _wp_get_block_patterns( $theme ); 345 $dirpath = $theme->get_stylesheet_directory() . '/patterns/'; 346 $text_domain = $theme->get( 'TextDomain' ); 347 348 foreach ( $patterns as $file => $pattern_data ) { 349 349 if ( $registry->is_registered( $pattern_data['slug'] ) ) { 350 350 continue; … … 406 406 * @return array Block pattern data. 407 407 */ 408 409 408 function _wp_get_block_patterns( WP_Theme $theme ) { 410 if ( ! $theme->exists() ) {411 return array(412 'version' => false,413 'patterns' => array(),414 );415 }416 417 $transient_name = 'wp_theme_patterns_' . $theme->get_stylesheet();418 $version = $theme->get( 'Version' );419 409 $can_use_cached = ! wp_is_development_mode( 'theme' ); 420 410 421 411 if ( $can_use_cached ) { 422 $pattern_data = get_transient( $transient_name);423 if ( is_array( $pattern_data ) && $pattern_data['version'] === $version) {412 $pattern_data = $theme->get_pattern_cache(); 413 if ( is_array( $pattern_data ) ) { 424 414 return $pattern_data; 425 415 } 426 416 } 427 417 428 $pattern_data = array(429 'version' => $version,430 'patterns' => array(),431 );432 418 $dirpath = $theme->get_stylesheet_directory() . '/patterns/'; 419 $pattern_data = array(); 433 420 434 421 if ( ! file_exists( $dirpath ) ) { 435 422 if ( $can_use_cached ) { 436 set_transient( $transient_name,$pattern_data );423 $theme->set_pattern_cache( $pattern_data ); 437 424 } 438 425 return $pattern_data; … … 441 428 if ( ! $files ) { 442 429 if ( $can_use_cached ) { 443 set_transient( $transient_name,$pattern_data );430 $theme->set_pattern_cache( $pattern_data ); 444 431 } 445 432 return $pattern_data; … … 474 461 __FUNCTION__, 475 462 sprintf( 476 /* translators: %s: file name. */463 /* translators: 1: file name. */ 477 464 __( 'Could not register file "%s" as a block pattern ("Slug" field missing)' ), 478 465 $file … … 487 474 __FUNCTION__, 488 475 sprintf( 489 /* translators: %1s: file name; %2s: slug value found. */476 /* translators: 1: file name; 2: slug value found. */ 490 477 __( 'Could not register file "%1$s" as a block pattern (invalid slug "%2$s")' ), 491 478 $file, … … 501 488 __FUNCTION__, 502 489 sprintf( 503 /* translators: %1s: file name. */490 /* translators: 1: file name. */ 504 491 __( 'Could not register file "%s" as a block pattern ("Title" field missing)' ), 505 492 $file … … 541 528 $key = str_replace( $dirpath, '', $file ); 542 529 543 $pattern_data[ 'patterns'][$key ] = $pattern;530 $pattern_data[ $key ] = $pattern; 544 531 } 545 532 546 533 if ( $can_use_cached ) { 547 set_transient( $transient_name,$pattern_data );534 $theme->set_pattern_cache( $pattern_data ); 548 535 } 549 536
Note: See TracChangeset
for help on using the changeset viewer.