Discuss your project
Wordpress Backoffice

WordPress: Configure TinyMCE

Overriding the default TinyMCE configuration:To insert into the functions.php function myformatTinyMCE($in) { $in['remove_linebreaks']=false; $in['gecko_spellcheck']=false; $in['keep_styles']=true; $in['accessibility_focus']=true; $in['tabfocus_elements']=...

WordPress: Configure TinyMCE



Overriding the default TinyMCE configuration:

To insert into the functions.php

function myformatTinyMCE($in)
{
$in['remove_linebreaks']=false;
$in['gecko_spellcheck']=false;
$in['keep_styles']=true;
$in['accessibility_focus']=true;
$in['tabfocus_elements']='major-publishing-actions';
$in['media_strict']=false;
$in['paste_remove_styles']=false;
$in['paste_remove_spans']=false;
$in['paste_strip_class_attributes']='none';
$in['paste_text_use_dialog']=true;
$in['wpeditimage_disable_captions']=true;
$in['plugins']='inlinepopups,tabfocus,paste,media,fullscreen,wordpress,wpeditimage,wpgallery,wplink,wpdialogs,wpfullscreen';
$in['content_css']=get_template_directory_uri() . "/editor-style.css";
$in['wpautop']=true;
$in['apply_source_formatting']=false;
$in['theme_advanced_buttons1']='bold, italic, strikethrough, bullist, numlist, blockquote, justifyleft, justifycenter, justifyright, link, unlink, wp_more, spellchecker, fullscreen, wp_adv';
$in['theme_advanced_buttons2']='formatselect, fontselect, fontsizeselect,  underline, justifyfull, forecolor, pastetext, pasteword, removeformat, charmap, outdent, indent, undo, redo, wp_help';
$in['theme_advanced_buttons3']='';
$in['theme_advanced_buttons4']='';
return $in;
}

add_filter('tiny_mce_before_init', 'myformatTinyMCE' );

Reproduce this customization today

The principle of the hook remains useful, but the administration screens and WordPress APIs have evolved since the publication. Test the code in a staging environment with the exact version of the site's core, theme, and plugins.

  • Save the files and the database before making any changes.
  • Control user capabilities, nonces, input validation, and output escaping.
  • Place customizations in a dedicated plugin or a child theme to preserve updates.

Reference: official WordPress plugin development manual.

Share this article