Skip to content

Commit

Permalink
Improving color palette backcompat (#7695)
Browse files Browse the repository at this point in the history
Improving color palette theme support backwards compatibility as of @felixarntz [comment](#7619 (comment)).
  • Loading branch information
webmandesign authored and jorgefilipecosta committed Jul 5, 2018
1 parent dd6d2c2 commit c2da797
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -1147,16 +1147,17 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
// Initialize the editor.
$gutenberg_theme_support = get_theme_support( 'gutenberg' );
$align_wide = get_theme_support( 'align-wide' );
$color_palette = current( (array) get_theme_support( 'editor-color-palette' ) );
$color_palette = (array) get_theme_support( 'editor-color-palette' );

// Backcompat for Color Palette set as multiple parameters.
if ( is_string( $color_palette ) || isset( $color_palette['color'] ) ) {
$color_palette = get_theme_support( 'editor-color-palette' );
if ( isset( $color_palette[0] ) && ( is_string( $color_palette[0] ) || isset( $color_palette[0]['color'] ) ) ) {
_doing_it_wrong(
'add_theme_support()',
__( 'Setting colors using multiple parameters is deprecated. Please pass a single parameter with an array of colors. See https://wordpress.org/gutenberg/handbook/extensibility/theme-support/ for details.', 'gutenberg' ),
'3.4.0'
);
} else {
$color_palette = current( $color_palette );
}

// Backcompat for Color Palette set through `gutenberg` array.
Expand Down

0 comments on commit c2da797

Please sign in to comment.