From 8a1849216046d1e7dda1d05bd29ac5819ac99ee4 Mon Sep 17 00:00:00 2001 From: spacedmonkey Date: Tue, 6 Jun 2023 16:19:19 +0000 Subject: [PATCH] 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 --- wp-includes/class-wp-theme.php | 8 ++------ wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php index 3b520782c1..7cde57f4f9 100644 --- a/wp-includes/class-wp-theme.php +++ b/wp-includes/class-wp-theme.php @@ -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. Child themes 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, diff --git a/wp-includes/version.php b/wp-includes/version.php index 607e64feab..f499c4f05a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @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.