
How to turn on Disabled Buttons in WordPress Visual Editor
- November 20, 2015
- Leave a comment
The default text editor in WordPress is TinyMce which provides a lot of features. There are two views in TinyMce:
- Visual Editor
- HTML Editor
Sometimes, content writers don’t have the knowledge about HTML and mostly use visual editor screen. Reason being, it gives a lot of flexibility to them change the content. A bunch of buttons included in TinyMCE are disabled in WordPress but it is easy to enable them.
WordPress provides the following two filters by which you can delete the existing functionality or enable a new functionality:
- mce_buttons_2 – Second row of buttons
- mce_buttons_3 – Third row of buttons
Second Row Buttons:
There are few buttons in the second row which are disabled by default in WordPress (subscript and superscript button). If you want to enable them, use “mce_buttons_2” filter. For this, code snippet is given below:
1 2 3 4 5 6 7 8 9 |
<?php function pt_enable_more_buttons_second_row($buttons) { $buttons[] = 'sup'; $buttons[] = 'sub'; return $buttons; } add_filter('mce_buttons_2', 'pt_enable_more_buttons_second_row'); ?> |
The same filter can be used to remove buttons from the second row as well. By using the following code snippet, you can remark out the lines of buttons you need to keep and remove the rest which are of no use to you:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
<?php function pt_remove_second_row_buttons($buttons) { if(($key = array_search('formatselect', $buttons)) !== false) { unset($buttons[$key]); } if(($key = array_search('underline', $buttons)) !== false) { unset($buttons[$key]); } if(($key = array_search('justifyfull', $buttons)) !== false) { unset($buttons[$key]); } if(($key = array_search('forecolor', $buttons)) !== false) { unset($buttons[$key]); } if(($key = array_search('pastetext', $buttons)) !== false) { unset($buttons[$key]); } if(($key = array_search('pasteword', $buttons)) !== false) { unset($buttons[$key]); } if(($key = array_search('removeformat', $buttons)) !== false) { unset($buttons[$key]); } if(($key = array_search('charmap', $buttons)) !== false) { unset($buttons[$key]); } if(($key = array_search('outdent', $buttons)) !== false) { unset($buttons[$key]); } if(($key = array_search('indent', $buttons)) !== false) { unset($buttons[$key]); } if(($key = array_search('undo', $buttons)) !== false) { unset($buttons[$key]); } if(($key = array_search('redo', $buttons)) !== false) { unset($buttons[$key]); } if(($key = array_search('wp_help', $buttons)) !== false) { unset($buttons[$key]); } return $buttons; } add_filter("mce_buttons_2", "pt_remove_second_row_buttons"); ?> |
Third Row Buttons:
TinyMce have few hidden buttons in the third row. You can turn them on by utilizing “mce_buttons_3” filter. For this, code snippet is given below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?php function pt_enable_third_row_buttons($buttons) { $buttons[] = 'fontselect'; $buttons[] = 'backcolor'; $buttons[] = 'image'; $buttons[] = 'media'; $buttons[] = 'anchor'; $buttons[] = 'sub'; $buttons[] = 'sup'; $buttons[] = 'hr'; $buttons[] = 'wp_page'; $buttons[] = 'cut'; $buttons[] = 'copy'; $buttons[] = 'paste'; $buttons[] = 'newdocument'; $buttons[] = 'code'; $buttons[] = 'cleanup'; $buttons[] = 'styleselect'; return $buttons; } add_filter("mce_buttons_3", "pt_enable_third_row_buttons"); ?> |
User Comments