Snippet: Add Custom Colors in Editor’s Color Picker

This short snippet will add three colors (#15375c, #3366FF and #9fb83f) to color picker of WordPress editor. Its pretty useful if you allow administrators and authors to select the common colors of your website.


function wpds_custom_palette( $colors ) { 
	// Default WordPres color pallete
	$colors['theme_advanced_text_colors'] = '000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF'; 
	// New colors that we want to add
	$colors['theme_advanced_text_colors'] .= ',15375c,3366FF,9fb83f';

	// make it true to enable the "more" option
	$colors['theme_advanced_more_colors'] = false; 
	return $colors; 
add_filter('tiny_mce_before_init', 'wpds_custom_palette'); 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>