Skip to content

Instantly share code, notes, and snippets.

@chekle
Created July 5, 2023 20:50
Show Gist options
  • Save chekle/304e40f7a8120cf5eb5ff94f58d9089b to your computer and use it in GitHub Desktop.
Save chekle/304e40f7a8120cf5eb5ff94f58d9089b to your computer and use it in GitHub Desktop.
Custom colours swatches for WordPress WYSIWYG
/* ================== Custom colors swatches ======================== */
function my_mce4_options($init) {
$custom_colours = '
"496125", "Pounamu Green",
"F4EDD4", "Whenua",
"01AEF0", "Purū-pōuri",
"305C7D", "Kōwhai",
"EECE63", "Kōwhai 50%",
"ADC6ED", "Ōrangitea",
"F0DC9F", "Kārkitea",
"899F47", "Whero",
"444448", "Charcoal",
';
// build colour grid default+custom colors
$init['textcolor_map'] = '['.$custom_colours.']';
// change the number of rows in the grid if the number of colors changes
// 8 swatches per row
$init['textcolor_rows'] = 1;
return $init;
}
add_filter('tiny_mce_before_init', 'my_mce4_options');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment