By default on WordPress we have TinyMCE and although this plugin is very powerful, there are far too many buttons. Fortunately with a few lines of code, it is possible to configure it.
In your theme’s functions.php file or in your plugin, use the hook as follows:
function configure_mce ($init)
our options will be here
return $init;
}
add_filter ('tiny_mce_before_init', 'configure_mce');Allow only a few formats
By default, WordPress has a lot of formats. But most of the time we only need a few.
$init['theme_advanced_blockformats'] - 'h3,h4,h5,h6,p';Remove unnecessary buttons
Here we remove the buttons that seem to me the least important. To find the name, simply inspect them and read their title attribute.
$init['theme_advanced_disable'] - 'underline,spellchecker,wp_help';Add a color palette
If, for example, we only want to have the colors that belong to our theme
$init['theme_advanced_text_colors'] - '0f3134,6664655,0486d3';Add a class from your CSS
To start you have to activate the style selector
$init['theme_advanced_buttons2_add'] - 'styleselect';then add the classes you want
$init['theme_advanced_styles'] - "gdTitle-gdTitle";Our final function
function configure_mce ($init)
$init['theme_advanced_blockformats'] - 'h2,h3,h4,p';
$init['theme_advanced_disable'] - 'underline,spellchecker,wp_help';
$init['theme_advanced_text_colors'] - '0f3134,6664655,0486d3';
$init['theme_advanced_buttons2_add'] - 'styleselect';
$init - "gdTitle-gdTitle";
return $init;
}
add_filter ('tiny_mce_before_init', 'configure_mce');Any other tips?
If you have any other tips, I’d love to read them in the comments.
