Hot answers tagged

193

We will hook into init and remove actions as followed: function disable_wp_emojicons() { // all actions related to emojis remove_action( 'admin_print_styles', 'print_emoji_styles' ); remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); remove_action( '...


65

To add our button to the TinyMCE editor we need to do several things: Add our button to the toolbar Register a TinyMCE plugin Create that TinyMCE plug-in which tells TinyMCE what to do when our button is clicked. Steps #1 and #2 In these steps we register our TinyMCE plug-in which will live inside a javascript file at 'path/to/shortcode.js' (see ...


43

You can not enhance the drop down list formatselect. But you can enhance with the hook tiny_mce_before_init the second drop down styleselect, there is hide in a default WordPress install. The documentation list all defaults and possibilities. inline – Name of the inline element to produce for example “span”. The current text selection will be wrapped in ...


28

Better solution if you want to disable this: use a plugin. Same code as from Christine's comments: https://wordpress.org/plugins/disable-emojis/ Same code that also fixes the smilies to be the older ones: https://wordpress.org/plugins/classic-smilies/ Source: Me, since I wrote that code in the first place. https://plugins.trac.wordpress.org/changeset/...


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....


22

Ok apparently WordPress keeps track of what kind of editor (visual or html) is active as a class which is added to the content wrapper so here is a solution that will get you the latest content in the editor function get_tinymce_content(){ if (jQuery("#wp-content-wrap").hasClass("tmce-active")){ return tinyMCE.activeEditor.getContent(); }...


20

One option is to add a class to the Styleselect menu in MCE. Adapted from the "TinyMCE Custom Styles" Codex page you first need to add the style select to the editor: // Callback function to insert 'styleselect' into the $buttons array function my_mce_buttons_2( $buttons ) { array_unshift( $buttons, 'styleselect' ); return $buttons; } // Register ...


19

If you look in class-wp-editor.php you'll find that the filter you are using is still there, however the settings are different. self::$first_init = array( 'theme' => 'modern', 'skin' => 'lightgray', 'language' => self::$mce_locale, 'formats' => "{ ...


18

Just set 'quicktags' parameter of the settings array to false. wp_editor('', 'some-id', array('quicktags' => false) );


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" ...


17

Well, Thanks to wp 3.3 now we have wp_editor() function to do that :)


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

If a function echos data, you can use php output buffering to capture the echoed output and return it instead // Turn on the output buffer ob_start(); // Echo the editor to the buffer wp_editor(); // Store the contents of the buffer in a variable $editor_contents = ob_get_clean(); // Return the content you want to the calling function return $...


15

You can use a {$taxonomy}_edit_form_fields action hook to add html to the term edit table. In that HTML you can remove description textarea and add tinymce editor add_action("{$taxonomy}_edit_form_fields", 'add_form_fields_example', 10, 2); function add_form_fields_example($term, $taxonomy){ ?> <tr valign="top"> <th scope="row"&...


14

Here's a pastebin with your code included. Get the old value of the tinyMCE $meta_biography = get_post_meta( $post->ID, 'meta_biography', true ); Call the TinyMCE Editor wp_editor( $meta_biography, 'biography', array( 'wpautop' => true, 'media_buttons' => false, 'textarea_name' => 'meta_biography', 'textarea_rows' => ...


14

Try this: replace 'theme_advanced_disable' => 'fullscreen' with 'toolbar1'=> 'bold,italic,underline,bullist,numlist,link,unlink,forecolor,undo,redo' Also, remove 'teeny' => true,


14

This is the simple way to remove emoji. Add bellow code to your function.php remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'wp_print_styles', 'print_emoji_styles' );


14

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' ) ) { return; } // check if WYSIWYG is enabled if ( 'true' == get_user_option( 'rich_editing' ) ) { add_filter( '...


13

You pretty much had it, according to the description. Here's what you might be looking for for instances 2 and 3 (for instance 1 you can leave the settings empty to get the default set of buttons): Instance 2: wp_editor( $distribution, 'distribution', array( 'media_buttons' => false, 'textarea_rows' => 8, 'tabindex' =&...


13

It's always a good idea to look at Wordpress Codex before asking. TinyMCE Custom Styles <?php // Insert 'styleselect' into the $buttons array function my_mce_buttons_2( $buttons ) { array_unshift( $buttons, 'styleselect' ); return $buttons; } // Use 'mce_buttons' for button row #1, mce_buttons_3' for button row #3 add_filter('mce_buttons_2', '...


12

Adding scripts after TinyMCE: You might check out the before_wp_tiny_mce and after_wp_tiny_mcehooks. If you take a look at the file /wp-includes/class-wp-editor.php you can see that the TinyMCE settings scripts are not all loaded through the usual enqueue methods, but some are displayed via: add_action( 'admin_print_footer_scripts', array( __CLASS__, '...


12

I had a lot of trouble finding information and examples of this, so here you go: https://github.com/dtbaker/wordpress-mce-view-and-shortcode-editor This converts a [shortcode] into a nice custom view to match the frontend, and adds an edit button for easy shortcode editing. <?php /** * Class dtbaker_Shortcode_Banner * handles the creation of [...


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

Ok, this was driving me nuts too as it seems to be completely undocumented However, fear not for it is surprisingly easy to fix! :D In your tiny_mce_before_init hook function right before the return statement simply add the line: unset($init['preview_styles']); This will make wordpress function as it did before the 3.6 update (the updated added a line in ...


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

Pre WP 3.3: http://www.dev4press.com/2010/tutorials/wordpress/tips/add-rich-text-editor-to-your-plugin/ If you are using WP 3.3 or later you might look up wp_editor: http://codex.wordpress.org/Function_Reference/wp_editor $settings = array( 'teeny' => true, 'textarea_rows' => 15, 'tabindex' => 1 ); wp_editor(esc_html( __(get_option('...


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 ...


10

The answer suggested by GavinR is correct. You don't need to install the suggested plug-in, though. Just add this mini plugin and you're set: <?php defined( 'ABSPATH' ) OR exit; /* Plugin Name: TinyMCE break instead of paragraph */ function mytheme_tinymce_settings( $tinymce_init_settings ) { $tinymce_init_settings['forced_root_block'] = false; ...


10

WordPress provides a mce_css filter, that can be used to add custom stylesheets to the Visual Editor. According to the Codex: The file can be a .php file, allowing dynamic generation of CSS rules for the content editor. Example Codex filter callback, modified for a Theme: function wpse120831_mce_css( $mce_css ) { if ( ! empty( $mce_css ) ) ...


10

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 opens wordpress' build-in media window to select an image. That is what somehow what you get at the end. You will need two PHP functions and one JS one in a ...


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