Skip to content

Instantly share code, notes, and snippets.

@lumpysimon
Last active December 5, 2018 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lumpysimon/9e23a38aee9020adff931ba6995de23d to your computer and use it in GitHub Desktop.
Save lumpysimon/9e23a38aee9020adff931ba6995de23d to your computer and use it in GitHub Desktop.
Configure the default WordPress TinyMCE behaviour, defaults and buttons
<?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