Skip to content

Instantly share code, notes, and snippets.

@wormeyman
Last active December 15, 2020 20:16
Show Gist options
  • Save wormeyman/a8c10135cbae5ca48afd055c93df2aba to your computer and use it in GitHub Desktop.
Save wormeyman/a8c10135cbae5ca48afd055c93df2aba to your computer and use it in GitHub Desktop.
Add brand colors to the gutenberg color picker.
<?php
function ej_add_theme_colors_to_gutenberg()
{
add_theme_support('editor-color-palette', array(
array(
'name' => esc_attr__('AWD Orange Red', 'EricJohnson'), //brand color
'slug' => 'awd-orange-red',
'color' => '#f94341',
),
array(
'name' => esc_attr__('AWD Grey', 'EricJohnson'), //brand color
'slug' => 'awd-grey',
'color' => '#414141',
),
array(
'name' => esc_attr__('Black', 'EricJohnson'), //Default Gutenberg Color
'slug' => 'black',
'color' => '#000000',
),
array(
'name' => esc_attr__('Cyan bluish gray', 'EricJohnson'), //Default Gutenberg Color
'slug' => 'cyan-bluish-gray',
'color' => '#abb8c3',
),
array(
'name' => esc_attr__('White', 'EricJohnson'), //Default Gutenberg Color
'slug' => 'white',
'color' => '#ffffff',
),
array(
'name' => esc_attr__('Pale pink', 'EricJohnson'), //Default Gutenberg Color
'slug' => 'pale-pink',
'color' => '#f78da7',
),
array(
'name' => esc_attr__('Vivid red', 'EricJohnson'), //Default Gutenberg Color
'slug' => 'vivid-red',
'color' => '#cf2e2e',
),
array(
'name' => esc_attr__('Luminous vivid orange', 'EricJohnson'), //Default Gutenberg Color
'slug' => 'luminous-vivid-orange',
'color' => '#ff6900',
),
array(
'name' => esc_attr__('Luminous vivid amber', 'EricJohnson'), //Default Gutenberg Color
'slug' => 'luminous-vivid-amber',
'color' => '#fcb900',
),
array(
'name' => esc_attr__('Light green cyan', 'EricJohnson'), //Default Gutenberg Color
'slug' => 'light-green-cyan',
'color' => '#7bdcb5',
),
array(
'name' => esc_attr__('Vivid green cyan', 'EricJohnson'), //Default Gutenberg Color
'slug' => 'vivid-green-cyan',
'color' => '#00d084',
),
array(
'name' => esc_attr__('Pale cyan blue', 'EricJohnson'), //Default Gutenberg Color
'slug' => 'pale-cyan-blue',
'color' => '#8ed1fc',
),
array(
'name' => esc_attr__('Vivid cyan blue', 'EricJohnson'), //Default Gutenberg Color
'slug' => 'vivid-cyan-blue',
'color' => '#0693e3',
),
array(
'name' => esc_attr__('Vivid purple', 'EricJohnson'), //Default Gutenberg Color
'slug' => 'vivid-purple',
'color' => '#9b51e0',
),
));
}
add_action('after_setup_theme', 'ej_add_theme_colors_to_gutenberg'); //Fire it off!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment