mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@55885 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3df744228e
commit
10bf8bb558
@ -362,11 +362,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
$this->template = $this->stylesheet;
|
||||
$theme_path = $this->theme_root . '/' . $this->stylesheet;
|
||||
|
||||
if (
|
||||
! 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' )
|
||||
) {
|
||||
if ( ! $this->is_block_theme() && ! file_exists( $theme_path . '/index.php' ) ) {
|
||||
$error_message = sprintf(
|
||||
/* 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.' ),
|
||||
@ -380,7 +376,7 @@ final class WP_Theme implements ArrayAccess {
|
||||
$this->cache_add(
|
||||
'theme',
|
||||
array(
|
||||
'block_theme' => $this->is_block_theme(),
|
||||
'block_theme' => $this->block_theme,
|
||||
'headers' => $this->headers,
|
||||
'errors' => $this->errors,
|
||||
'stylesheet' => $this->stylesheet,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user