Make WordPress Core


Ignore:
Timestamp:
11/10/2022 10:40:59 PM (2 years ago)
Author:
flixos90
Message:

Editor: Avoid running certain logic around theme.json parsing unnecessarily for classic themes.

Here's what it does:

  • Do not load and parse theme-i18n.json schema if the theme does not have a theme.json file.
  • Fix the variable caching layer around the theme's theme.json parsing so that a parent's theme theme.json is cached as well.
  • Do not run a WP_Query for global styles for a user when the theme does not have a theme.json.

In a basic WordPress setup, this changeset improves wp_head execution time for classic themes by 10%, and overall response time for both block themes and classic themes by 4%. This may seem like a small win, but 4% reduced overall response time is actually quite a bit for one change, and it is worth mentioning that this is just one of several other little performance tweaks which are being worked on to improve performance of theme.json parsing further.

Props flixos90, manuilov, oandregal, peterwilsoncc, spacedmonkey.
Merges [54799] to the 6.1 branch.
Fixes #56945.

Location:
branches/6.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.1

  • branches/6.1/src/wp-includes/class-wp-theme-json.php

    r54778 r54800  
    29402940        $spacing_scale = _wp_array_get( $this->theme_json, array( 'settings', 'spacing', 'spacingScale' ), array() );
    29412941
    2942         if ( ! is_numeric( $spacing_scale['steps'] )
     2942        if ( ! isset( $spacing_scale['steps'] )
     2943            || ! is_numeric( $spacing_scale['steps'] )
    29432944            || ! isset( $spacing_scale['mediumStep'] )
    29442945            || ! isset( $spacing_scale['unit'] )
Note: See TracChangeset for help on using the changeset viewer.