apply_filters( 'mce_buttons_2', array $mce_buttons_2, string $editor_id )

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


Parameters Parameters

$mce_buttons_2

(array) Second-row list of buttons.

$editor_id

(string) Unique editor identifier, e.g. 'content'. Accepts 'classic-block' when called from block editor's Classic block.


Top ↑

Source Source

File: wp-includes/class-wp-editor.php

View on Trac



Top ↑

Changelog Changelog

Changelog
Version Description
3.3.0 The $editor_id parameter was added.
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by stevenlinx

    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 2 content
    Contributed by stevenlinx

    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 );
     }
    

Top ↑

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