diff --git a/projects/plugins/jetpack/changelog/make-load-google-fonts-more-resilient b/projects/plugins/jetpack/changelog/make-load-google-fonts-more-resilient new file mode 100644 index 0000000000000..474a586957ceb --- /dev/null +++ b/projects/plugins/jetpack/changelog/make-load-google-fonts-more-resilient @@ -0,0 +1,4 @@ +Significance: patch +Type: compat + +Google Fonts: resolve occasional bug resulting in PHP 8 with latest Gutenberg. diff --git a/projects/plugins/jetpack/modules/google-fonts/current/load-google-fonts.php b/projects/plugins/jetpack/modules/google-fonts/current/load-google-fonts.php index 193a439532aab..7181d00549e2e 100644 --- a/projects/plugins/jetpack/modules/google-fonts/current/load-google-fonts.php +++ b/projects/plugins/jetpack/modules/google-fonts/current/load-google-fonts.php @@ -46,7 +46,9 @@ function jetpack_get_google_fonts_data() { } } - return $data; + if ( is_array( $data ) && is_array( $data['fontFamilies'] ) ) { + return $data; + } } /** @@ -56,15 +58,11 @@ function jetpack_get_google_fonts_data() { * @return object[] The map of the the available Google Fonts. */ function jetpack_get_available_google_fonts_map( $google_fonts_data ) { - $font_families = isset( $google_fonts_data ) && isset( $google_fonts_data['fontFamilies'] ) - ? $google_fonts_data['fontFamilies'] - : array(); - $jetpack_google_fonts_list = array_map( function ( $font_family ) { return $font_family['name']; }, - $font_families + $google_fonts_data['fontFamilies'] ); /** This filter is documented in modules/google-fonts/wordpress-6.3/load-google-fonts.php */