Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. class PasteAsPlainText {
  2.  
  3. function __construct() {
  4.  
  5. add_action( 'admin_init', array( $this, 'init' ) );
  6.  
  7. }
  8.  
  9. function init() {
  10.  
  11. add_filter( 'tiny_mce_before_init', array( $this, 'forcePasteAsPlainText' ) );
  12. add_filter( 'teeny_mce_before_init', array( $this, 'forcePasteAsPlainText' ) );
  13. add_filter( 'teeny_mce_plugins', array( $this, 'loadPasteInTeeny' ) );
  14. add_filter( 'mce_buttons_2', array( $this, 'removePasteAsPlainTextButton' ) );
  15.  
  16. }
  17.  
  18. function forcePasteAsPlainText( $mceInit ) {
  19.  
  20. global $tinymce_version;
  21.  
  22. if ( $tinymce_version[0] < 4 ) {
  23. $mceInit[ 'paste_text_sticky' ] = true;
  24. $mceInit[ 'paste_text_sticky_default' ] = true;
  25. } else {
  26. $mceInit[ 'paste_as_text' ] = true;
  27. }
  28.  
  29. return $mceInit;
  30. }
  31.  
  32. function loadPasteInTeeny( $plugins ) {
  33.  
  34. return array_merge( $plugins, (array) 'paste' );
  35.  
  36. }
  37.  
  38. function removePasteAsPlainTextButton( $buttons ) {
  39.  
  40. if( ( $key = array_search( 'pastetext', $buttons ) ) !== false ) {
  41. unset( $buttons[ $key ] );
  42. }
  43.  
  44. return $buttons;
  45.  
  46. }
  47.  
  48. }
  49.  
  50. new PasteAsPlainText();
  51.  
  52. function formatTinyMCE( $in ) {
  53. $in['toolbar1'] = 'bold,custom_em,blockquote,aligncenter,link,unlink,spellchecker,undo,removeformat';
  54. return $in;
  55. }
  56. add_filter( 'tiny_mce_before_init', 'formatTinyMCE' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement