Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add WordPress theme support for editor-color-palette, and set colours for the gutenberg colour pallete.
<?php
/**
* change_gutenberg_color_palette.
*
* Add theme support for editor-color-palette,
* and set colours for the gutenberg colour pallete.
*
* @see https://since1979.dev/wp-snippet-002-changing-the-gutenberg-color-palette/
*
* @uses add_theme_support() https://developer.wordpress.org/reference/functions/add_theme_support/
* @uses __() https://developer.wordpress.org/reference/functions/__/
* @uses array() https://www.php.net/manual/en/function.array.php
*
* @return void
*/
function change_gutenberg_color_palette() {
add_theme_support( 'editor-color-palette', array(
array(
'name' => __('Blackish', 'your-textdomain'),
'slug' => 'blackish',
'color' => '#323232',
),
array(
'name' => __('Whiteish', 'your-textdomain'),
'slug' => 'white',
'color' => '#eeeeee',
),
array(
'name' => __('White', 'your-textdomain'),
'slug' => 'white',
'color' => '#ffffff',
),
array(
'name' => __('Dark blue', 'your-textdomain'),
'slug' => 'dark-blue',
'color' => '#1d2735',
),
array(
'name' => __('Blue', 'your-textdomain'),
'slug' => 'blue',
'color' => '#00659b',
),
array(
'name' => __('Light blue', 'your-textdomain'),
'slug' => 'light-blue',
'color' => '#4999ca',
),
));
}
/**
* Hook: after_setup_theme.
*
* @uses add_action() https://developer.wordpress.org/reference/functions/add_action/
* @uses after_setup_theme https://developer.wordpress.org/reference/hooks/after_setup_theme/
*/
add_action( 'after_setup_theme' , 'change_gutenberg_color_palette' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.