Last active
December 5, 2018 11:32
-
-
Save lumpysimon/9e23a38aee9020adff931ba6995de23d to your computer and use it in GitHub Desktop.
Configure the default WordPress TinyMCE behaviour, defaults and buttons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined( 'ABSPATH' ) or die(); | |
$lumpy_lemon_tiny_mce = new lumpy_lemon_tiny_mce; | |
class lumpy_lemon_tiny_mce { | |
function __construct() { | |
add_filter( 'mce_buttons', [ $this, 'buttons' ] ); | |
add_filter( 'mce_buttons_2', [ $this, 'empty_array' ] ); | |
add_filter( 'mce_buttons_3', [ $this, 'empty_array' ] ); | |
add_filter( 'mce_buttons_4', [ $this, 'empty_array' ] ); | |
add_filter( 'tiny_mce_before_init', [ $this, 'defaults' ] ); | |
} | |
function empty_array() { | |
return []; | |
} | |
function buttons( $buttons ) { | |
return [ | |
'removeformat', | |
'pastetext', | |
'formatselect', | |
'italic', | |
'bold', | |
'alignleft', | |
'aligncenter', | |
'alignright', | |
'bullist', | |
'numlist', | |
'blockquote', | |
'link', | |
'unlink' | |
]; | |
} | |
function defaults( $init ) { | |
$init['block_formats'] = 'Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3'; | |
$init['paste_as_text'] = true; | |
return $init; | |
} | |
} // class lumpy_lemon_tiny_mce |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment