WordPress Remove buttons from the TinyMCE editor


/ Published in: PHP
Save to your folder(s)

Thanks to Tom McFarlin for this: https://gist.github.com/tommcfarlin/86e4f040bcc641a86f59


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. add_filter( 'mce_buttons_2', 'acme_remove_from_kitchen_sink');
  4. /**
  5.  * Removes the all but the formatting button from the post editor.
  6.  *
  7.  * @since 1.0.0
  8.  *
  9.  * @param array $buttons The current array buttons including the kitchen sink.
  10.  * @return array The updated array of buttons that exludes the kitchen sink.
  11.  */
  12. function acme_remove_from_kitchen_sink( $buttons ) {
  13.  
  14. $invalid_buttons = array(
  15. 'underline',
  16. 'justifyfull',
  17. 'forecolor',
  18. '|',
  19. 'pastetext',
  20. 'pasteword',
  21. 'removeformat',
  22. 'charmap',
  23. 'outdent',
  24. 'indent',
  25. 'undo',
  26. 'redo',
  27. 'wp_help'
  28. );
  29.  
  30.  
  31.  
  32. foreach ( $buttons as $button_key => $button_value ) {
  33.  
  34. if ( in_array( $button_value, $invalid_buttons ) ) {
  35. unset( $buttons[ $button_key ] );
  36. }
  37.  
  38. }
  39.  
  40. return $buttons;
  41.  
  42. }

URL: https://gist.github.com/tommcfarlin/86e4f040bcc641a86f59

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.