Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have disabled many of the TinyMCE buttons making the two rows quite empty. Is it possible to move the remaining buttons from the second row (that is displayed when hitting the Kitchen Sink button) to the top row?

share|improve this question

1 Answer 1

Solved it.

So, in order to move the default buttons from first row to second row, we will need to hook into the mce_buttons filter:

function move_mce_buttons_to_top($buttons) {    

    $buttons[] = 'redo';
    // buttons

    return $buttons;
}
add_filter('mce_buttons', 'move_mce_buttons_to_top');

Then, to add the Paragraph drop-down to top row, we will add them as custom styles.

Firstly, let us enable the styleselect into mce_buttons (top row):

// Callback function to insert 'styleselect' into the $buttons array
function my_mce_buttons( $buttons ) {
    array_unshift( $buttons, 'styleselect' );
    return $buttons;
}
// Register our callback to the appropriate filter
add_filter('mce_buttons', 'my_mce_buttons');

And then register each item accordingly:

add_filter( 'tiny_mce_before_init', 'drop_mce_before_init' );  

function drop_mce_before_init( $settings ) {  

    $style_formats = array(  
        array(  
            'title' => 'Paragraph',  
            'block' => 'p', 
        ),  
        array(  
            'title' => 'Heading 2',  
            'block' => 'h2',  
            )
    );  

    $settings['style_formats'] = json_encode( $style_formats );  

    return $settings;  

}  

EDIT: Updated code to function properly with the P tag.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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