apply_filters( ‘tiny_mce_before_init’, array $mce_init, string $editor_id )

Filters the TinyMCE config before init.


An array with TinyMCE config.
Unique editor identifier, e.g. 'content'. Accepts 'classic-block' when called from block editor’s Classic block.


$mce_init = apply_filters( 'tiny_mce_before_init', $mce_init, $editor_id );


3.3.0The $editor_id parameter was added.

User Contributed Notes

  1. Skip to note 2 content

    Example migrated from Codex:

    The following example adds custom style options to an existing Style dropdown.

    Note that, by default, the Style dropdown is hidden in WordPress. To show this option, you will need to add it using the mce_buttons_2 filter and load the CSS using the mce_css hook.

    function mytheme_tinymce_settings( $settings ) {
    	//First, we define the styles we want to add in format 'Style Name' => 'css classes'
    	$classes = array(
    		__('Test style 1', 'mytheme') => 'teststyle1',
    		__('Test style 2', 'mytheme') => 'teststyle2',
    		__('Test style 3', 'mytheme') => 'teststyle3',
    	//Delimit styles by semicolon in format 'Title=classes;' so TinyMCE can use it
    	if ( ! empty( $settings['theme_advanced_styles'] ) ) {
    		$settings['theme_advanced_styles'] .= ';';
    	} else {
    		//If there's nothing defined yet, define it
    		$settings['theme_advanced_styles'] = '';
    	//Loop through our newly defined classes and add them to TinyMCE
    	$class_settings = '';
    	foreach ( $classes as $name => $value ) {
    		$class_settings .= "{$name}={$value};";
    	//Add our new class settings to the TinyMCE $settings array
    	$settings['theme_advanced_styles'] .= trim( $class_settings, '; ' );
    	return $settings;
    add_filter( 'tiny_mce_before_init', 'mytheme_tinymce_settings' );

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