Created
July 11, 2022 19:24
-
-
Save Pross/1a45d92dc07d9f4dd33e0b7e33e06b80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add BB colour presets into tinymce presets. | |
* @since Forever | |
*/ | |
add_filter( 'tiny_mce_before_init', function( $init ) { | |
$default_colours = '"000000", "Black","993300", "Burnt orange","333300", "Dark olive","003300", "Dark green","003366", "Dark azure","000080", "Navy Blue","333399", "Indigo","333333", "Very dark gray","800000", "Maroon","FF6600", "Orange","808000", "Olive","008000", "Green","008080", "Teal","0000FF", "Blue","666699", "Grayish blue","808080", "Gray","FF0000", "Red","FF9900", "Amber","99CC00", "Yellow green","339966", "Sea green","33CCCC", "Turquoise","3366FF", "Royal blue","800080", "Purple","999999", "Medium gray","FF00FF", "Magenta","FFCC00", "Gold","FFFF00", "Yellow","00FF00", "Lime","00FFFF", "Aqua","00CCFF", "Sky blue","993366", "Red violet","FFFFFF", "White","FF99CC", "Pink","FFCC99", "Peach","FFFF99", "Light yellow","CCFFCC", "Pale green","CCFFFF", "Pale cyan","99CCFF", "Light sky blue","CC99FF", "Plum"'; | |
$colours = FLBuilderModel::get_color_presets(); | |
$custom_colours = ''; | |
if ( ! empty( $colours ) ) { | |
$custom_colours = '"","",'; | |
foreach ( $colours as $k => $colour ) { | |
$custom_colours .= sprintf( '"%s", "Custom %s",', ltrim( $colour, '#' ), $k + 1 ); | |
} | |
} else { | |
$custom_colours = '""'; | |
} | |
// build colour grid default+custom colors | |
$init['textcolor_map'] = '[' . $default_colours . ',' . rtrim( $custom_colours, ',' ) . ']'; | |
// enable 6th row for custom colours in grid | |
$init['textcolor_rows'] = 8; | |
return $init; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment