Changeset 55236 for trunk/src/wp-includes/class-wp-theme.php
- Timestamp:
- 02/06/2023 07:57:41 PM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme.php
r54236 r55236 115 115 116 116 /** 117 * Is this theme a block theme. 118 * 119 * @since 6.2.0 120 * @var bool 121 */ 122 private $block_theme; 123 124 /** 117 125 * Header name from the theme's style.css after being translated. 118 126 * … … 251 259 252 260 if ( is_array( $cache ) ) { 253 foreach ( array( ' errors', 'headers', 'template' ) as $key ) {261 foreach ( array( 'block_theme', 'errors', 'headers', 'template' ) as $key ) { 254 262 if ( isset( $cache[ $key ] ) ) { 255 263 $this->$key = $cache[ $key ]; … … 276 284 $this->errors = new WP_Error( 'theme_no_stylesheet', __( 'Stylesheet is missing.' ) ); 277 285 } 278 $this->template = $this->stylesheet; 286 $this->template = $this->stylesheet; 287 $this->block_theme = false; 279 288 $this->cache_add( 280 289 'theme', 281 290 array( 282 'headers' => $this->headers, 283 'errors' => $this->errors, 284 'stylesheet' => $this->stylesheet, 285 'template' => $this->template, 291 'block_theme' => $this->block_theme, 292 'headers' => $this->headers, 293 'errors' => $this->errors, 294 'stylesheet' => $this->stylesheet, 295 'template' => $this->template, 286 296 ) 287 297 ); … … 294 304 $this->errors = new WP_Error( 'theme_stylesheet_not_readable', __( 'Stylesheet is not readable.' ) ); 295 305 $this->template = $this->stylesheet; 306 $this->block_theme = false; 296 307 $this->cache_add( 297 308 'theme', 298 309 array( 299 'headers' => $this->headers, 300 'errors' => $this->errors, 301 'stylesheet' => $this->stylesheet, 302 'template' => $this->template, 310 'block_theme' => $this->block_theme, 311 'headers' => $this->headers, 312 'errors' => $this->errors, 313 'stylesheet' => $this->stylesheet, 314 'template' => $this->template, 303 315 ) 304 316 ); … … 328 340 'theme', 329 341 array( 330 'headers' => $this->headers, 331 'errors' => $this->errors, 332 'stylesheet' => $this->stylesheet, 342 'block_theme' => $this->is_block_theme(), 343 'headers' => $this->headers, 344 'errors' => $this->errors, 345 'stylesheet' => $this->stylesheet, 333 346 ) 334 347 ); … … 364 377 'theme', 365 378 array( 366 'headers' => $this->headers, 367 'errors' => $this->errors, 368 'stylesheet' => $this->stylesheet, 369 'template' => $this->template, 379 'block_theme' => $this->is_block_theme(), 380 'headers' => $this->headers, 381 'errors' => $this->errors, 382 'stylesheet' => $this->stylesheet, 383 'template' => $this->template, 370 384 ) 371 385 ); … … 400 414 'theme', 401 415 array( 402 'headers' => $this->headers, 403 'errors' => $this->errors, 404 'stylesheet' => $this->stylesheet, 405 'template' => $this->template, 416 'block_theme' => $this->is_block_theme(), 417 'headers' => $this->headers, 418 'errors' => $this->errors, 419 'stylesheet' => $this->stylesheet, 420 'template' => $this->template, 406 421 ) 407 422 ); … … 427 442 'theme', 428 443 array( 429 'headers' => $_child->headers, 430 'errors' => $_child->errors, 431 'stylesheet' => $_child->stylesheet, 432 'template' => $_child->template, 444 'block_theme' => $_child->is_block_theme(), 445 'headers' => $_child->headers, 446 'errors' => $_child->errors, 447 'stylesheet' => $_child->stylesheet, 448 'template' => $_child->template, 433 449 ) 434 450 ); … … 446 462 'theme', 447 463 array( 448 'headers' => $this->headers, 449 'errors' => $this->errors, 450 'stylesheet' => $this->stylesheet, 451 'template' => $this->template, 464 'block_theme' => $this->is_block_theme(), 465 'headers' => $this->headers, 466 'errors' => $this->errors, 467 'stylesheet' => $this->stylesheet, 468 'template' => $this->template, 452 469 ) 453 470 ); … … 466 483 if ( ! is_array( $cache ) ) { 467 484 $cache = array( 468 'headers' => $this->headers, 469 'errors' => $this->errors, 470 'stylesheet' => $this->stylesheet, 471 'template' => $this->template, 485 'block_theme' => $this->is_block_theme(), 486 'headers' => $this->headers, 487 'errors' => $this->errors, 488 'stylesheet' => $this->stylesheet, 489 'template' => $this->template, 472 490 ); 473 491 // If the parent theme is in another root, we'll want to cache this. Avoids an entire branch of filesystem calls above. … … 763 781 $this->headers_sanitized = null; 764 782 $this->name_translated = null; 783 $this->block_theme = null; 765 784 $this->headers = array(); 766 785 $this->__construct( $this->stylesheet, $this->theme_root ); … … 1492 1511 */ 1493 1512 public function is_block_theme() { 1513 if ( isset( $this->block_theme ) ) { 1514 return $this->block_theme; 1515 } 1516 1494 1517 $paths_to_index_block_template = array( 1495 1518 $this->get_file_path( '/block-templates/index.html' ), … … 1497 1520 ); 1498 1521 1522 $this->block_theme = false; 1523 1499 1524 foreach ( $paths_to_index_block_template as $path_to_index_block_template ) { 1500 1525 if ( is_file( $path_to_index_block_template ) && is_readable( $path_to_index_block_template ) ) { 1501 return true; 1502 } 1503 } 1504 1505 return false; 1526 $this->block_theme = true; 1527 break; 1528 } 1529 } 1530 1531 return $this->block_theme; 1506 1532 } 1507 1533
Note: See TracChangeset
for help on using the changeset viewer.