From 11599fc0573949d72847289ee68c40946be33f27 Mon Sep 17 00:00:00 2001 From: arthur791004 Date: Mon, 13 Nov 2023 22:48:05 +0900 Subject: [PATCH] Fix fatal error in WP_Fonts_Resolver::get_settings() (#56067) --- .../fonts-api/class-wp-fonts-resolver.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/experimental/fonts-api/class-wp-fonts-resolver.php b/lib/experimental/fonts-api/class-wp-fonts-resolver.php index f2299c7c368311..efa66839cd39ca 100644 --- a/lib/experimental/fonts-api/class-wp-fonts-resolver.php +++ b/lib/experimental/fonts-api/class-wp-fonts-resolver.php @@ -200,11 +200,6 @@ 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. - if ( ! 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. @@ -219,7 +214,12 @@ private static function get_settings() { ); // Make sure there are no duplicates. - $settings['typography']['fontFamilies'] = array_unique( $settings['typography']['fontFamilies'] ); + $settings['typography']['fontFamilies'] = array_unique( $settings['typography']['fontFamilies'], SORT_REGULAR ); + + // The font families from settings might become null after running the `array_unique`. + if ( ! isset( $settings['typography']['fontFamilies']['theme'] ) || ! is_array( $settings['typography']['fontFamilies']['theme'] ) ) { + $settings['typography']['fontFamilies']['theme'] = array(); + } } return $settings;