Skip to main content
18 votes
Accepted

Adding Custom Text Patterns in the WP 4.5 Visual Editor

Here's a way to test the core patch #33300.6 by Andew Ozz, through a test plugin in WP 4.5.2, to try out the text pattern filter. Demo Here's a strikethrough example using ~ $init['...
birgire's user avatar
  • 67.4k
16 votes
Accepted

How to replace the content of tinyMCE editor in both text and visual mode using jQuery?

The first thing to do is to select the active editor. Here we select the editor using its id, which is content. var activeEditor = tinyMCE.get('content'); Then we use tinyMCE's setContent: var ...
kosinix's user avatar
  • 1,474
14 votes
Accepted

Add self-closing shortcode button to TinyMCE in WP 4.6

We start by adding the custom TinyMCE Button: function add_mce_button_custom_em() { // check user permissions if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ...
Christine Cooper's user avatar
  • 8,798
11 votes
Accepted

How to add "Insert/Edit link" button in custom popup tinymce window?

So I'm answering my own question, for those that face or will face the same problem. I have added two buttons. One opens wordpress' build-in window to select a post and inserts the link. The other ...
Achillx's user avatar
  • 383
10 votes

Visual Tab Missing From Editor

Just in case anyone else is having this problem, I've found that a pretty reliable way to get your visual editor tab back after upgrading to Wordpress 4.0 is: disable all plugins Change the theme to ...
Noon Niee Nunn's user avatar
9 votes

Forcing reload of editor-style.css

I couldn't get toscho's answer to work for the current version of WordPress (4.7.2), and that seems to be because the TinyMCE init array has a cache_suffix set to 'wp-mce-' . $tinymce_version. So ...
icecold_3000's user avatar
8 votes

Creating a wp_editor instance with custom tinyMCE buttons

Just to update this as I had to dig in the wp source files $settings = array( 'tinymce' => array( 'toolbar1' => 'bold, italic', 'toolbar2' => '', ), 'wpautop' =&...
Sam's user avatar
  • 91
8 votes

Replace Taxomony Description Field with Visual/WYSIWYG Editor

For those still looking for a solution to this problem, it's worth mentioning that the Yoast SEO plugin adds a WYSIWYG editor for descriptions automatically on the taxonomy term edit screen. If you'...
jg314's user avatar
  • 511
8 votes
Accepted

Disable text tab on WordPress text-editor

For disabling the text tab for all users except administrators, you can add the following: function my_editor_settings($settings) { if ( ! current_user_can('administrator') ) { $settings['...
L.Milo's user avatar
  • 193
7 votes
Accepted

How to edit the actual paragraph dropdown in TinyMCE with custom text styles

I was having the same issue and here is what you can do. The code below disables the h1 tag from the block formats section. The same way you can disable other tags and also add your own. But I'm not ...
Vlad K.'s user avatar
  • 196
6 votes

Set tinymce direction to rtl

In wordpress, the editor will support and will be in RTL by default if you install it in an rtl language, for example, if you install wordpress with the hebrew UI the editor will be rtl by default. ...
eyal_123's user avatar
  • 101
6 votes
Accepted

Remove 'Custom..' option in tinyMCE colour swatch

Yes, it is possible to remove the custom colors option from tinyMCE. WordPress bundles a tinyMCE plugin to handle the custom colors functionality. The tiny_mce_plugins filter can be used to remove ...
Dave Romsey's user avatar
  • 17.8k
5 votes

How to Add WYSIWYG Editor (tinyMCE) to plugin options page compatible with Wordpress 3.0 and up?

<?php function my_address_function(){ if(isset($_POST['special_content'])){ update_option('special_content', $_POST['special_content']); } ?> <div class='wrap'> <h2>...
Anuj Singh Rajput's user avatar
5 votes

Stop Wordpress removing <script> tags when switching from HTML to Visual (TinyMCE)

This can be quite easily done by granting the unfiltered_html capability to whichever role you're interested in allowing SCRIPT and IFRAME tags. Obviously, as mentioned by others, there's inherent ...
Tom Auger's user avatar
  • 7,066
5 votes

Add button in TinyMCE editor to insert text

Add this to your plugin file or in functions.php file in the theme directory add_action( 'admin_enqueue_scripts', 'wpse_141344_admin_enqueue_scripts' ); add_action( 'admin_head', '...
mukto90's user avatar
  • 1,499
5 votes

Snippet: Use classes instead of inline styles for text alignment

Note This answer was originally included in @bitstarr's question above and was included as a separate answer here to comply with WPSE's Q&A model. Maybe someone else will have this issue and so i ...
cjbj's user avatar
  • 14.6k
5 votes
Accepted

Insert wp_editor on front-end with AJAX?

So, after doing some more digging, I answered my own question by "connecting the dots", so to speak. There's a lot of bits and pieces of info on this topic on StackOverflow and StackExchange, but none ...
Swen's user avatar
  • 1,374
4 votes

Uncaught ReferenceError:switchEditors is not defined

it might me entirely different solution that i am providing but it solved the problem for me. I followed these steps: Open the user that is getting error. (Wordpress admin menu > users > your ...
Rao Abid's user avatar
  • 170
4 votes

Hide "Add media", HTML editor from TinyMCE

In WordPress ver 4.9 it does not seem media buttons can be turned off using the 'tiny_mce_before_init' hook. Instead I was able to remove this using 'wp_editor_settings', like so: add_filter( '...
Ben's user avatar
  • 141
4 votes

Hide "Add media", HTML editor from TinyMCE

If you want to hide/disable/prevent/remove the "Add Media"-button in 2018 you can do the following (in essence): // probably in your functions.php remove_action('media_buttons', 'media_buttons');
Axel's user avatar
  • 162
4 votes
Accepted

Easy way to inject js in tinymce iframe?

WordPress injects its own external script files in the TinyMCE editor iframe, see for example the wp-includes/js/tinymce/plugins/wpembed/plugin.js file: (function ( tinymce ) { 'use strict'; ...
David Riccitelli's user avatar
4 votes

How to include own css on wordpress tinymce editor?

Nothing I found worked. Took me half a day on Google, but finally stumbled upon this script that works: function kwh_add_editor_style( $mceInit ) { $custom_css = get_theme_mod( 'custom_css' ); $...
AA-T's user avatar
  • 51
4 votes

How to stop editor removing space (&nbsp;) in the beginning of the paragraph

//[nbsp] shortcode function nbsp_shortcode( $atts, $content = null ) { $content = '&nbsp'; return $content; } add_shortcode( 'nbsp', 'nbsp_shortcode' ); Then call it like this: [nbsp] Instead ...
Nathaniel Flick's user avatar
4 votes

Custom TinyMCE Editor Formats in Dropdown

You can group styles using the items key - you can nest multiple times too! /* TINY MCE FORMATE */ function my_mce_before_init_insert_formats( $init_array ) { $style_formats = array( ...
kshaner's user avatar
  • 41
4 votes

Apply custom style to single word in Wordpress

Solved it... In my functions.php I should have put: array( 'title' => 'Hidden Element', 'inline' => 'span', 'classes' => 'hiddenElement', 'wrapper' ...
JohnG's user avatar
  • 334
4 votes

Using a dashicon for a custom button in TinyMCE?

I am hoping to be able to do this just through the Javascript with no additional CSS. Is this possible? I assume you only want to stay within tinymce.PluginManager.add( ... ). Here's a JS ...
birgire's user avatar
  • 67.4k
3 votes

How to use tinyMCE for user "biographical info"?

We should add js lib and init editor for id="description" function mysite_show_extra_profile_fields($user) { wp_enqueue_editor(); ?> <script> document....
Alexufo's user avatar
  • 171
3 votes

Wordpress automatically adding "&nbsp;"?

In case there is somebody still stuck with this in 2020. We had this issue after migrating a bunch of content to Wordpress. Guess what, everybody did the copy and paste thing and we end up with way ...
Bruno's user avatar
  • 31
3 votes

Creating a wp_editor instance with custom tinyMCE buttons

$args = array( 'tinymce' => array( 'toolbar1' => 'bold,italic,underline,separator,alignleft,aligncenter,alignright,separator,link,unlink,undo,redo', 'toolbar2' ...
Hardik Kalathiya's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible