I'm developing a plugin that I'll install for all my clients to make WordPress slightly easier to use for them. One of the things it will change is the default TinyMCE configuration. It'll add things like underline and justifyfull to the first TinyMCE row.

I know I could use other plugins like TinyMCE Advanced to alter TinyMCE for my clients, but they add a lot of unneccessary bloat which is susceptible to problems during updates. I want to make this as minimalistic as possible in order to avoid update issues.

I've written this simple code that mostly works great:

function mo_change_mce_buttons( $initArray ) {
    $initArray['theme_advanced_buttons1'] = 'bold,italic,underline,strikethrough,|,bullist,numlist,blockquote,|,justifyleft, justifycenter,justifyright,justifyfull,|,link,unlink,wp_more,|,spellchecker,fullscreen,wp_adv';
    return $initArray;
add_filter('tiny_mce_before_init', 'mo_change_mce_buttons');

This code works great except for one huge problem. It disables any TinyMCE plugins on the TinyMCE row in question (theme_advanced_buttons1). The Vipers Video Quicktags plugin for example, which adds a YouTube-button, is removed by using the code above.

How can I modify the default first TinyMCE row using simple code in my own plugin without sacrificing the possibility for other plugins to add buttons to it too?


tiny_mce_before_init is a filter that gets the whole TinyMCE configuration, but there are filters that act on smaller parts of it, like mce_buttons for only the buttons. The advantage here is that they act on arrays, so it's easy to add or remove parts from them. This is how Vipers Video Quicktags does it too.

You can change your code to the following snippet to insert the buttons at the right places and not remove buttons that other plugins have added:

add_filter( 'mce_buttons', 'wpse17686_mce_buttons' );
function wpse17686_mce_buttons( $old_buttons )
    $new_buttons = array();
    foreach ( $old_buttons as $button ) {
        $new_buttons[] = $button;
        if ( 'italic' == $button ) {
            $new_buttons[] = 'underline';
        if ( 'justifyright' == $button ) {
            $new_buttons[] = 'justifyfull';
    return $new_buttons;
  • Thanks! That solved it! I was mistakenly under the impression that mce_buttons only could add new buttons, I didn't know it could be used to change the default config. May 19 '11 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.