23

The following small plugin creates a custom button inside line 1 of the WordPress TinyMCE Version 4, tested in WP Version 3.9-beta2. The plugin has var_dump included to understand the values. It's also possible to add the button to other lines of the visual editor, only a other hook, like for line 2: mce_buttons_2. Result Plugin, PHP side - tinymce4-test....


18

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['wpsetextpattern_inline_patterns'] = '{ strong: { start: "*", end: "*", format: "bold" }, strong2: { start: "**", end: "**", format: "bold" ...


18

The dialog HTML comes from WP_Editors::wp_link_dialog() but no hooks in there. We could instead use jQuery to append the custom HTML to the link dialog and try to override e.g. the wpLink.getAttrs(), because it's very short ;-) Demo example: jQuery( document ).ready( function( $ ) { $('#link-options').append( '<div> <...


17

Regardless of what you have configured as valid children, WordPress handles p tags as well as line breaks in a very unique way. You'll probably notice eventually, if you haven't already, that when switching from the text editor to the visual editor and back that your <p> tags get stripped, similar to what occurs on the frontend. A way to block this ...


15

you can change lots of things about the tinyMCE editor at the tiny_mce_before_init filter. http://codex.wordpress.org/TinyMCE_Custom_Buttons the following will restrict your blockformats to p,h3,h4 and blockquote function wpa_45815($arr){ $arr['theme_advanced_blockformats'] = 'p,h3,h4,blockquote'; return $arr; } add_filter('tiny_mce_before_init',...


12

add_action( 'init', 'remove_editor_init' ); function remove_editor_init() { // If not in the admin, return. if ( ! is_admin() ) { return; } // Get the post ID on edit post with filter_input super global inspection. $current_post_id = filter_input( INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT ); // Get the post ID on update ...


11

Just wrote the function. It'll display the tinymce editor in every custom taxonomy description right now. Surely you can edit to show it for only some specific taxonomy. /** * Display advanced TinyMCE editor in taxonomy page */ function wpse_7156_enqueue_category() { global $pagenow, $current_screen; if( $pagenow == 'edit-tags.php' ) { ...


11

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 activeEditor = tinyMCE.get('content'); var content = 'HTML or plain text content here...'; activeEditor.setContent(content); However, if the editor is in text mode ...


10

There is a hook for that: 'mce_css'. It is called in _WP_Editors::editor_settings() and you get all loaded stylesheets comma separated as the first and only parameter. Now it is easy: Use the global variable $editor_styles (here are your theme’s and parent theme’s editor stylesheets stored already), add the time of the file’s last modification as a ...


9

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 instead, you can just overwrite that with the tiny_mce_before_init filter, like so: function wpse33318_tiny_mce_before_init( $mce_init ) { $mce_init['...


9

If you don't need wp_editor in front-end, I think its OK. Here a little bit different option settings with your tinymce init. I use this without wp_editor in front-end. <script> jQuery( document ).ready( function( $ ) { tinymce.init( { mode : "exact", elements : 'pre-details', theme: "modern", skin: "lightgray", ...


8

Background This issue revolves around the removal of empty <span></span> elements in TinyMCE when saving a post or switching between between the Visual and Text editor tabs. The problem is inherent to core functionality (as of trunk version 4.0-alpha-20140602) and is unchangeable via the standard WordPress APIs, as is mentioned in ticket #26986. ...


8

Edit As of WP 4.3 this won't work anymore. WP have completely removed the javascript for the old distraction-free mode. To use this in 4.3 versions, get a copy of javascript file from WP 4.2 release and enqueue it before using code below. You can: use 'wp_editor_settings' filter to set the '_content_editor_dfw' option to false. use 'mce_buttons' and '...


7

For posts: add_action('init', 'my_custom_init'); function my_custom_init() { remove_post_type_support( 'post', 'editor' ); } See Codex. For custom post types that you register, you can specify what 'features' it supports when you register it it use the 'supports' arguments. For custom post types that are not registered by you can use the above with '...


7

In your code, calling the action admin_init makes is_admin() unnecessary. And, if not mistaken, is_page() is meant to be used in the front-end... But the solution is the following (based on this Answer): add_filter( 'user_can_richedit', 'wpse_58501_page_can_richedit' ); function wpse_58501_page_can_richedit( $can ) { global $post; if ( 28 == $...


7

In extended toolbar view (Alt+Shift+Z), Pressing the "indent" button to a list or part of list would be make it one step more deeper


7

I had the exact same problem and found the solution to this. The problem is that the anchor plugin for TinyMCE is not being included as part of the default Wordpress install. So while Wordpress says to include: $buttons[] = 'anchor'; …that's not going to work because the TinyMCE plugin for anchors isn't there. If you go to TinyMCE's website, you can ...


7

Register the shortcode, ideally in a plugin or functions.php if you have to. add_shortcode('thumbnail', 'thumbnail_in_content'); function thumbnail_in_content($atts) { global $post; return get_the_post_thumbnail($post->ID); } Add the shortcode to you post content. [thumbnail] If you want more features, see this post or the pastebin. ADDING ...


6

I know exactly how you feel, and sadly this problem is rooted in the wordpress core code not in TinyMCE or due to browser compatility problems. I wrote a plugin that allows you to format html markup in the HTML editor, switch back and forth between it and the Visual tab without affecting the source code, and make changes in the Visual tab without breaking ...


6

Actually you can include the editor-style.css (or any other stylesheet), just pass a "content_css" value to tinymce that points to a css file: wp_editor( $content, 'editablecontent', array( 'tinymce' => array( 'content_css' => get_stylesheet_directory_uri() . '/editor-styles.css' ) ); So the original ...


6

This almost certainly happens because WordPress cannot load the TinyMCE editor files or the TinyMCE javascript code could not be run. Try these things: 1) Make sure your browser has javascript enabled! 2) Open this URL in your browser http://<yoursite>/wp-includes/js/tinymce/wp-tinymce.php You should see a lot of text, starting something like this: /...


6

This seems to do it: function allow_nbsp_in_tinymce( $mceInit ) { $mceInit['entities'] = '160,nbsp,38,amp,60,lt,62,gt'; $mceInit['entity_encoding'] = 'named'; return $mceInit; } add_filter( 'tiny_mce_before_init', 'allow_nbsp_in_tinymce' ); Also see: https://www.tinymce.com/docs/configure/content-filtering/#entities Any improvement ...


6

There are a couple of issues with your approach By using the admin_init hook you won't have any reference to the post object. This means you won't be able to get the post ID or use anything like get_the_ID because the post won't actually be loaded. You can see that in the order here https://codex.wordpress.org/Plugin_API/Action_Reference So if you run the ...


5

add_action('init', 'remove_editor_init'); function remove_editor_init() { remove_post_type_support('page', 'editor'); } You can wrap this inside your existing logic for detecting the current page template, so you only disable the editor for specific pages. See: http://codex.wordpress.org/Function_Reference/remove_post_type_support


5

I cannot offer a JavaScript solution, because I am not sure where exactly this is happening. But … we can hook into wp_insert_post_data and solve this issue in PHP: add_filter( 'wp_insert_post_data', 't5_strip_double_spaces', 20 ); function t5_strip_double_spaces( $data ) { $data['post_content'] = preg_replace( "~( \x{C2}\x{A0}|\x{C2}\x{A0} )~...


5

Best solution for what you want to accomplish which is essentially to make the next page feature more user friendly for your authors is to add a TinyMCE button that will do this for you. This may be a bit complicated so hold your hat. To avoid this answer being the length of a thesis, I have added comments in all codes to help you understand what each ...


5

So, I may or may not go to hell for this, but I made a quickfix plugin that bypasses the inline part and just opens the link editor. You can find it here. I didn't spend much time testing it, if you find problems make issues in github and I will see if I can fix it. The way it works is that I removed wplink as a plugin from tinyMCE, then added wplinkc, ...


5

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 will share my solution here with you folks. function make_mce_awesome( $init ) { /* There are easier things than make 'left/center/right align ...


5

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 sure about how to add custom CSS styles to them. Hope this code will give you a hint in which way to dig. //Modify TinyMCE editor to hide H1. function ...


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