Make WordPress Core

#58520 closed enhancement (fixed)

Change the order of check in is_block_theme

Reported by: spacedmonkey's profile spacedmonkey Owned by: spacedmonkey's profile spacedmonkey
Milestone: 6.3 Priority: normal
Severity: normal Version: 5.8
Component: Themes Keywords: good-first-bug commit
Focuses: performance Cc:


In the method is_block_theme in WP_Theme class, a check for files in block-templates and templates. However files in block-templates where deprecated in 5.9. It is far more like that themes will have files in the templates directory. To improve performance, change the order of the lookup, to check block-templates and save a file lookup.

Attachments (1)

58520-1.diff (531 bytes) - added by nihar007 11 months ago.
Patch added

Download all attachments as: .zip

Change History (3)

11 months ago

Patch added

#1 @spacedmonkey
11 months ago

  • Keywords commit added
  • Milestone changed from Future Release to 6.3

#2 @spacedmonkey
11 months ago

  • Owner set to spacedmonkey
  • Resolution set to fixed
  • Status changed from new to closed

In 55941:

Themes: Change the order of path check in is_block_theme method.

Change check to see if the current theme is a block theme, to check the path /templates/index.html first over the deprecated path /block-templates/index.html.
As this path was deprecated in WP 5.9, it is more likely the block theme would use the current path. This saves a file_exists call which improves performance.

Props nihar007, spacedmonkey.
Fixes #58520.

Note: See TracTickets for help on using tickets.