Skip to content

Instantly share code, notes, and snippets.

@karks88
Last active August 18, 2020 15:22
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 karks88/96c39818af14b0846bd231f005a62a6d to your computer and use it in GitHub Desktop.
Save karks88/96c39818af14b0846bd231f005a62a6d to your computer and use it in GitHub Desktop.
Turn off the ability to use the custom color picker in the WordPress Gutenberg editor. Then, define your own custom color palette.
/* Define Custom Colors on the Front End */
/* white */
.has-white-color {
color:#FFFFFF;
}
.has-white-background-color {
background-color:#FFFFFF;
}
/* black */
.has-black-color {
color:#000000;
}
.has-black-background-color {
background-color:#000000;
}
/* yellow */
.has-yellow-color {
color:#ffd000;
}
.has-yellow-background-color {
background-color:#ffd000;
}
/* blue */
.has-blue-color {
color:#347ab7;
}
.has-blue-background-color {
background-color:#347ab7;
}
/* green */
.has-green-color {
color:#2e924d;
}
.has-green-background-color {
background-color:#2e924d;
}
/* gray */
.has-gray-color {
color:#464646;
}
.has-gray-background-color {
background-color:#464646;
}
/* light gray */
.has-lightgray-color {
color:#ebebeb;
}
.has-lightgray-background-color {
background-color:#ebebeb;
}
// Editor Color Palette
add_theme_support( 'editor-color-palette', array(
array(
'name' => __( 'White', 'textdomain' ),
'slug' => 'white',
'color' => '#FFFFFF',
),
array(
'name' => __( 'Black', 'textdomain' ),
'slug' => 'black',
'color' => '#000000',
),
array(
'name' => __( 'Yellow', 'textdomain' ),
'slug' => 'yellow',
'color' => '#ffd000',
),
array(
'name' => __( 'Blue', 'textdomain' ),
'slug' => 'blue',
'color' => '#347ab7',
),
array(
'name' => __( 'Green', 'textdomain' ),
'slug' => 'green',
'color' => '#2e924d',
),
array(
'name' => __( 'Gray', 'textdomain' ),
'slug' => 'gray',
'color' => '#464646',
),
array(
'name' => __( 'Light Gray', 'textdomain' ),
'slug' => 'lightgray',
'color' => '#ebebeb',
),
) );
// Disable Gutenberg Custom Colors
add_theme_support( 'disable-custom-colors' );
// Disable Gutenberg Custom Gradients
add_theme_support( 'disable-custom-gradients' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment