Make WordPress Core

Changeset 54998


Ignore:
Timestamp:
12/15/2022 10:53:43 PM (2 years ago)
Author:
spacedmonkey
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-template-utils.php

    r54916 r54998  
    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'];
     
    372372function _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
Note: See TracChangeset for help on using the changeset viewer.