From 9ea4e8df9ffaa041fa70fb53b0b8c2ba2a2d0aad Mon Sep 17 00:00:00 2001 From: Jonny Harris Date: Thu, 15 Dec 2022 22:53:43 +0000 Subject: [PATCH] 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 --- src/wp-includes/block-template-utils.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/block-template-utils.php b/src/wp-includes/block-template-utils.php index 3b57d9afa4..826237aa18 100644 --- a/src/wp-includes/block-template-utils.php +++ b/src/wp-includes/block-template-utils.php @@ -351,7 +351,7 @@ function _add_block_template_info( $template_item ) { return $template_item; } - $theme_data = WP_Theme_JSON_Resolver::get_theme_data()->get_custom_templates(); + $theme_data = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_custom_templates(); if ( isset( $theme_data[ $template_item['slug'] ] ) ) { $template_item['title'] = $theme_data[ $template_item['slug'] ]['title']; $template_item['postTypes'] = $theme_data[ $template_item['slug'] ]['postTypes']; @@ -371,7 +371,7 @@ function _add_block_template_info( $template_item ) { */ function _add_block_template_part_area_info( $template_info ) { if ( WP_Theme_JSON_Resolver::theme_has_support() ) { - $theme_data = WP_Theme_JSON_Resolver::get_theme_data()->get_template_parts(); + $theme_data = WP_Theme_JSON_Resolver::get_theme_data( array(), array( 'with_supports' => false ) )->get_template_parts(); } if ( isset( $theme_data[ $template_info['slug'] ]['area'] ) ) {