Skip to content

Commit

Permalink
Optimization: don't check for the existence of $settings['typography'…
Browse files Browse the repository at this point in the history
…]['fontFamilies']['theme'] on every iteration of the loop.
  • Loading branch information
anton-vlasenko authored and Anton Vlasenko committed Nov 9, 2023
1 parent 5737291 commit 8e94c1c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/experimental/fonts-api/class-wp-fonts-resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ private static function get_settings() {
if ( $set_theme_structure ) {
$set_theme_structure = false;
$settings = static::set_tyopgraphy_settings_array_structure( $settings );
}

// Initialize the font families from settings if set and is an array, otherwise default to an empty array.
$settings_font_families = ( isset( $settings['typography']['fontFamilies']['theme'] ) && is_array( $settings['typography']['fontFamilies']['theme'] ) )
? $settings['typography']['fontFamilies']['theme']
: array();
// Initialize the font families from settings if set and is an array, otherwise default to an empty array.
$settings['typography']['fontFamilies']['theme'] = ( isset( $settings['typography']['fontFamilies']['theme'] ) && is_array( $settings['typography']['fontFamilies']['theme'] ) )
? $settings['typography']['fontFamilies']['theme']
: array();
}

// Initialize the font families from variation if set and is an array, otherwise default to an empty array.
$variation_font_families = ( isset( $variation['settings']['typography']['fontFamilies']['theme'] ) && is_array( $variation['settings']['typography']['fontFamilies']['theme'] ) )
Expand All @@ -214,7 +214,7 @@ private static function get_settings() {

// Merge the variation settings with the global settings.
$settings['typography']['fontFamilies']['theme'] = array_merge(
$settings_font_families,
$settings['typography']['fontFamilies']['theme'],
$variation_font_families
);

Expand Down

0 comments on commit 8e94c1c

Please sign in to comment.