Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add the editor color palette to your site using wp_inline_style
add_action( 'enqueue_block_assets', 'rgc_editor_color_palette', 15 );
* Add custom colors to the site using wp_inline_style, attached to the wp-block-library stylesheet.
* Colors must be defined in your theme or functionality plugin.
function rgc_editor_color_palette() {
list( $colors, ) = (array) get_theme_support( 'editor-color-palette' );
if ( ! $colors ) {
$css = '';
foreach ( $colors as $color ) {
$css .= sprintf(
'.has-%1$s-color {color: %2$s;} .has-%1$s-background-color {background-color: %2$s;} ',
wp_add_inline_style( 'wp-block-library', $css );
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.