Skip to content

Commit 9ea4e8d

Browse files
committed
Themes: Improve performance of _add_block_template_part_area_info and _add_block_template_info functions.
Improve performance of `_add_block_template_part_area_info` and `_add_block_template_info` function by passing the `with_supports` parameter to the `WP_Theme_JSON_Resolver::get_theme_data` method. This results in hitting an existing cache and in many less calls to get_option. Props spacedmonkey, flixos90, SergeyBiryukov, peterwilsoncc, desrosj. Fixes #57077. git-svn-id: https://develop.svn.wordpress.org/trunk@54998 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d7dd42d commit 9ea4e8d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/wp-includes/block-template-utils.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ function _add_block_template_info( $template_item ) {
351351
return $template_item;
352352
}
353353

354-
$theme_data = WP_Theme_JSON_Resolver::get_theme_data()->get_custom_templates();
354+
$theme_data = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_custom_templates();
355355
if ( isset( $theme_data[ $template_item['slug'] ] ) ) {
356356
$template_item['title'] = $theme_data[ $template_item['slug'] ]['title'];
357357
$template_item['postTypes'] = $theme_data[ $template_item['slug'] ]['postTypes'];
@@ -371,7 +371,7 @@ function _add_block_template_info( $template_item ) {
371371
*/
372372
function _add_block_template_part_area_info( $template_info ) {
373373
if ( WP_Theme_JSON_Resolver::theme_has_support() ) {
374-
$theme_data = WP_Theme_JSON_Resolver::get_theme_data()->get_template_parts();
374+
$theme_data = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_template_parts();
375375
}
376376

377377
if ( isset( $theme_data[ $template_info['slug'] ]['area'] ) ) {

0 commit comments

Comments
 (0)