Make WordPress Core

Changeset 55885


Ignore:
Timestamp:
06/06/2023 04:17:02 PM (3 years ago)
Author:
spacedmonkey
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme.php

    r55703 r55885  
    363363                        $theme_path     = $this->theme_root . '/' . $this->stylesheet;
    364364
    365                         if (
    366                                 ! file_exists( $theme_path . '/templates/index.html' )
    367                                 && ! file_exists( $theme_path . '/block-templates/index.html' ) // Deprecated path support since 5.9.0.
    368                                 && ! file_exists( $theme_path . '/index.php' )
    369                         ) {
     365                        if ( ! $this->is_block_theme() && ! file_exists( $theme_path . '/index.php' ) ) {
    370366                                $error_message = sprintf(
    371367                                        /* translators: 1: templates/index.html, 2: index.php, 3: Documentation URL, 4: Template, 5: style.css */
    … …  
    381377                                        'theme',
    382378                                        array(
    383                                                 'block_theme' => $this->is_block_theme(),
     379                                                'block_theme' => $this->block_theme,
    384380                                                'headers'     => $this->headers,
    385381                                                'errors'      => $this->errors,
Note: See TracChangeset for help on using the changeset viewer.