apply_filters( ‘mce_buttons_2’, array $mce_buttons_2, string $editor_id )

Filters the second-row list of TinyMCE buttons (Visual tab).

Parameters

$mce_buttons_2array
Second-row list of buttons.
$editor_idstring
Unique editor identifier, e.g. 'content'. Accepts 'classic-block' when called from block editor’s Classic block.

Source

$mce_buttons_2 = apply_filters( 'mce_buttons_2', $mce_buttons_2, $editor_id );

Changelog

VersionDescription
3.3.0The $editor_id parameter was added.
2.0.0Introduced.

User Contributed Notes

  1. Skip to note 3 content

    Example Migrated from Codex:

    The example below will reveal the hidden “Styles” dropdown in the advanced toolbar.

    add_filter( 'mce_buttons_2', 'myplugin_tinymce_buttons' );
    
    function myplugin_tinymce_buttons( $buttons ) {
          //Add style selector to the beginning of the toolbar
          array_unshift( $buttons, 'styleselect' );
    
          return $buttons;
     }
  2. Skip to note 4 content

    Example Migrated from Codex:

    The example below will remove the text color selector from the advanced toolbar.

    add_filter( 'mce_buttons_2', 'myplugin_tinymce_buttons' );
    
    function myplugin_tinymce_buttons( $buttons ) {
          //Remove the text color selector
          $remove = 'forecolor';
    
          //Find the array key and then unset
          if ( ( $key = array_search( $remove, $buttons ) ) !== false )
    		unset( $buttons[$key] );
    
          return $buttons;
     }

    Or, if you want to remove more buttons at the same time:

    add_filter( 'mce_buttons_2', 'myplugin_tinymce_buttons' );
    
    function myplugin_tinymce_buttons( $buttons ) {
    	//Remove the format dropdown select and text color selector
    	$remove = array( 'formatselect', 'forecolor' );
    
    	return array_diff( $buttons, $remove );
     }

You must log in before being able to contribute a note or feedback.