Editor: performance enhancements to `class-wp-theme-json`.

Removes unnecessary sanitisation of hardcoded strings and avoids looping over style presets without classes or variables.

Props flixos90.
Fixes #59304.

Built from https://develop.svn.wordpress.org/trunk@56545


git-svn-id: http://core.svn.wordpress.org/trunk@56057 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
isabel_brison 2023-09-08 00:26:21 +00:00
parent f379cb7fdb
commit 43a50913d6
2 changed files with 9 additions and 3 deletions

View File

@ -1313,7 +1313,7 @@ class WP_Theme_JSON {
continue;
}
$class_name = sanitize_title( _wp_array_get( $layout_definition, array( 'className' ), false ) );
$class_name = _wp_array_get( $layout_definition, array( 'className' ), false );
$spacing_rules = _wp_array_get( $layout_definition, array( 'spacingStyles' ), array() );
if (
@ -1370,7 +1370,7 @@ class WP_Theme_JSON {
) {
$valid_display_modes = array( 'block', 'flex', 'grid' );
foreach ( $layout_definitions as $layout_definition ) {
$class_name = sanitize_title( _wp_array_get( $layout_definition, array( 'className' ), false ) );
$class_name = _wp_array_get( $layout_definition, array( 'className' ), false );
$base_style_rules = _wp_array_get( $layout_definition, array( 'baseStyles' ), array() );
if (
@ -1567,6 +1567,9 @@ class WP_Theme_JSON {
$stylesheet = '';
foreach ( static::PRESETS_METADATA as $preset_metadata ) {
if ( empty( $preset_metadata['classes'] ) ) {
continue;
}
$slugs = static::get_settings_slugs( $settings, $preset_metadata, $origins );
foreach ( $preset_metadata['classes'] as $class => $property ) {
foreach ( $slugs as $slug ) {
@ -1764,6 +1767,9 @@ class WP_Theme_JSON {
protected static function compute_preset_vars( $settings, $origins ) {
$declarations = array();
foreach ( static::PRESETS_METADATA as $preset_metadata ) {
if ( empty( $preset_metadata['css_vars'] ) ) {
continue;
}
$values_by_slug = static::get_settings_values_by_slug( $settings, $preset_metadata, $origins );
foreach ( $values_by_slug as $slug => $value ) {
$declarations[] = array(

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.4-alpha-56544';
$wp_version = '6.4-alpha-56545';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.