Using WordPress ‘mce_buttons_3’ PHP filter

The mce_buttons_3 WordPress PHP filter allows you to modify the third-row list of TinyMCE buttons displayed in the visual tab of the WordPress editor.

Usage

add_filter('mce_buttons_3', 'your_custom_function', 10, 2);

function your_custom_function($mce_buttons_3, $editor_id) {
    // your custom code here
    return $mce_buttons_3;
}

Parameters

  • $mce_buttons_3 (array) – Third-row list of buttons.
  • $editor_id (string) – Unique editor identifier, e.g. ‘content’. Accepts ‘classic-block’ when called from the block editor’s Classic block.

More information

See WordPress Developer Resources: mce_buttons_3

Examples

Add a custom button to the third row

This example adds a custom button with the ID my_button to the third row of TinyMCE buttons.

add_filter('mce_buttons_3', 'add_my_custom_button', 10, 2);

function add_my_custom_button($mce_buttons_3, $editor_id) {
    $mce_buttons_3[] = 'my_button';
    return $mce_buttons_3;
}

Remove the ‘Underline’ button from the third row

This example removes the ‘Underline’ button from the third row of TinyMCE buttons.

add_filter('mce_buttons_3', 'remove_underline_button', 10, 2);

function remove_underline_button($mce_buttons_3, $editor_id) {
    $key = array_search('underline', $mce_buttons_3);
    if (false !== $key) {
        unset($mce_buttons_3[$key]);
    }
    return $mce_buttons_3;
}

Rearrange buttons in the third row

This example rearranges the buttons in the third row of TinyMCE buttons.

add_filter('mce_buttons_3', 'rearrange_buttons', 10, 2);

function rearrange_buttons($mce_buttons_3, $editor_id) {
    // Rearrange the buttons as desired
    $new_mce_buttons_3 = array('button1', 'button2', 'button3');
    return $new_mce_buttons_3;
}

Add a separator between buttons in the third row

This example adds a separator between two buttons in the third row of TinyMCE buttons.

add_filter('mce_buttons_3', 'add_separator_between_buttons', 10, 2);

function add_separator_between_buttons($mce_buttons_3, $editor_id) {
    array_splice($mce_buttons_3, 2, 0, '|'); // Insert a separator after the second button
    return $mce_buttons_3;
}

Clear all buttons from the third row

This example removes all buttons from the third row of TinyMCE buttons.

add_filter('mce_buttons_3', 'clear_all_buttons', 10, 2);

function clear_all_buttons($mce_buttons_3, $editor_id) {
    return array();
}