The after_wp_tiny_mce WordPress action fires after any core TinyMCE editor instances are created, allowing you to modify the TinyMCE settings array.
Usage
add_action('after_wp_tiny_mce', 'your_custom_function'); function your_custom_function($mce_settings) { // your custom code here return $mce_settings; }
Parameters
$mce_settings
(array): The TinyMCE settings array.
More information
See WordPress Developer Resources: after_wp_tiny_mce
Examples
Add a custom button to the TinyMCE toolbar
To add a custom button to the TinyMCE toolbar:
add_action('after_wp_tiny_mce', 'add_custom_button'); function add_custom_button($mce_settings) { $mce_settings['toolbar1'] .= ',custom_button'; return $mce_settings; }
Remove the underline button from the TinyMCE toolbar
To remove the underline button from the TinyMCE toolbar:
add_action('after_wp_tiny_mce', 'remove_underline_button'); function remove_underline_button($mce_settings) { $mce_settings['toolbar1'] = str_replace(',underline', '', $mce_settings['toolbar1']); return $mce_settings; }
Change the default font size in the TinyMCE editor
To change the default font size in the TinyMCE editor:
add_action('after_wp_tiny_mce', 'change_default_font_size'); function change_default_font_size($mce_settings) { $mce_settings['fontsize_formats'] = '8px 10px 12px 14px 16px 18px 24px 36px 48px'; return $mce_settings; }
Disable the “Paste as text” feature in the TinyMCE editor
To disable the “Paste as text” feature in the TinyMCE editor:
add_action('after_wp_tiny_mce', 'disable_paste_as_text'); function disable_paste_as_text($mce_settings) { $mce_settings['paste_as_text'] = false; return $mce_settings; }
Set the default content direction in the TinyMCE editor
To set the default content direction (e.g., right-to-left) in the TinyMCE editor:
add_action('after_wp_tiny_mce', 'set_default_content_direction'); function set_default_content_direction($mce_settings) { $mce_settings['directionality'] = 'rtl'; return $mce_settings; }