From 3cf7e98f70ba63335e6bf1fce353594bbd4a6b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Mon, 4 May 2020 14:12:36 +0200 Subject: [PATCH] Account for theme not declaring support --- lib/global-styles.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/global-styles.php b/lib/global-styles.php index bb3db97101389..619b38a27eead 100644 --- a/lib/global-styles.php +++ b/lib/global-styles.php @@ -165,20 +165,26 @@ function gutenberg_experimental_global_styles_get_theme() { // Take colors from declared theme support. $theme_colors = get_theme_support( 'editor-color-palette' )[ 0 ]; - foreach( $theme_colors as $color ) { - $global_styles_theme['theme']['color'][ $color['slug'] ] = $color['color']; + if ( is_array( $theme_colors ) ) { + foreach( $theme_colors as $color ) { + $global_styles_theme['theme']['color'][ $color['slug'] ] = $color['color']; + } } // Take gradients from declared theme support. $theme_gradients = get_theme_support( 'editor-gradient-presets' )[ 0 ]; - foreach( $theme_gradients as $gradient ) { - $global_styles_theme['theme']['gradient'][ $gradient['slug'] ] = $gradient['gradient']; + if( is_array( $theme_gradients ) ) { + foreach( $theme_gradients as $gradient ) { + $global_styles_theme['theme']['gradient'][ $gradient['slug'] ] = $gradient['gradient']; + } } // Take font-sizes from declared theme support. $theme_font_sizes = get_theme_support( 'editor-font-sizes' )[ 0 ]; - foreach( $theme_font_sizes as $font_size ) { - $global_styles_theme['theme']['font-size'][ $font_size['slug'] ] = $font_size['size']; + if( is_array( $theme_font_sizes ) ) { + foreach( $theme_font_sizes as $font_size ) { + $global_styles_theme['theme']['font-size'][ $font_size['slug'] ] = $font_size['size']; + } } return $global_styles_theme;