Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/wp-includes/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ 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();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felixarntz @desrosj @peterwilsoncc This work, because, supports are not needed here. You just need a WP_Theme_Json object. Adding these params, means that it hits a cache that it would not before. This function is called 300+ times a page load, there some serious savings here.


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'];
Expand All @@ -371,7 +372,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();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergeyBiryukov This works well!

}

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