Themes: Replace file_exists checks with call to is_block_theme method in WP_Theme class.
In `WP_Theme` class, replace two calls to `file_exists` with a call to the method `is_block_theme`. This method `is_block_theme` does the same file exists check, but it then caches the result for improved performance. Props nihar007, spacedmonkey, mukesh27, costdev, juzar. Fixes #58405. Built from https://develop.svn.wordpress.org/trunk@55885 git-svn-id: http://core.svn.wordpress.org/trunk@55397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c613855594
commit
8a18492160
|
@ -362,11 +362,7 @@ final class WP_Theme implements ArrayAccess {
|
||||||
$this->template = $this->stylesheet;
|
$this->template = $this->stylesheet;
|
||||||
$theme_path = $this->theme_root . '/' . $this->stylesheet;
|
$theme_path = $this->theme_root . '/' . $this->stylesheet;
|
||||||
|
|
||||||
if (
|
if ( ! $this->is_block_theme() && ! file_exists( $theme_path . '/index.php' ) ) {
|
||||||
! file_exists( $theme_path . '/templates/index.html' )
|
|
||||||
&& ! file_exists( $theme_path . '/block-templates/index.html' ) // Deprecated path support since 5.9.0.
|
|
||||||
&& ! file_exists( $theme_path . '/index.php' )
|
|
||||||
) {
|
|
||||||
$error_message = sprintf(
|
$error_message = sprintf(
|
||||||
/* translators: 1: templates/index.html, 2: index.php, 3: Documentation URL, 4: Template, 5: style.css */
|
/* translators: 1: templates/index.html, 2: index.php, 3: Documentation URL, 4: Template, 5: style.css */
|
||||||
__( 'Template is missing. Standalone themes need to have a %1$s or %2$s template file. <a href="%3$s">Child themes</a> need to have a %4$s header in the %5$s stylesheet.' ),
|
__( 'Template is missing. Standalone themes need to have a %1$s or %2$s template file. <a href="%3$s">Child themes</a> need to have a %4$s header in the %5$s stylesheet.' ),
|
||||||
|
@ -380,7 +376,7 @@ final class WP_Theme implements ArrayAccess {
|
||||||
$this->cache_add(
|
$this->cache_add(
|
||||||
'theme',
|
'theme',
|
||||||
array(
|
array(
|
||||||
'block_theme' => $this->is_block_theme(),
|
'block_theme' => $this->block_theme,
|
||||||
'headers' => $this->headers,
|
'headers' => $this->headers,
|
||||||
'errors' => $this->errors,
|
'errors' => $this->errors,
|
||||||
'stylesheet' => $this->stylesheet,
|
'stylesheet' => $this->stylesheet,
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.3-alpha-55884';
|
$wp_version = '6.3-alpha-55885';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue