diff --git a/lib/experimental/fonts-api/class-wp-fonts-resolver.php b/lib/experimental/fonts-api/class-wp-fonts-resolver.php index f2299c7c36831..efa66839cd39c 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;