Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimcoleman/29273f4fe3aa9384373c89824b770020 to your computer and use it in GitHub Desktop.
Save kimcoleman/29273f4fe3aa9384373c89824b770020 to your computer and use it in GitHub Desktop.
Add additional colors to the Block Editor color palette.
<?php
/**
* Add additional colors to the Block Editor color palette.
* Update and insert additional colors into the $new_colors array.
*
*/
function my_custom_editor_color_palette_extended() {
$editor_settings = get_block_editor_settings( array(), 'core/edit-post' );
$new_colors = array(
array(
'name' => __( 'New Color 1', 'textdomain' ),
'slug' => 'my-new-color-1',
'color' => '#BF665E',
),
array(
'name' => __( 'New Color 2', 'textdomain' ),
'slug' => 'my-new-color-2',
'color' => '#253659',
)
);
add_theme_support( 'editor-color-palette', array_merge( $editor_settings['colors'], $new_colors ) );
}
add_action( 'after_setup_theme', 'my_custom_editor_color_palette_extended', 11 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment