Hot answers tagged

75

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


39

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


21

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


20

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


18

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(); ...


16

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' => "{ ...


13

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


13

I recently got this working. You should search and replace metaname with your meta box name. The key to maintaining formatting was using wpautop(); when saving the data. add_action( 'add_meta_boxes', 'add_metaname_box'); add_action( 'save_post', 'metaname_save'); function add_metaname_box() { add_meta_box( 'metaname_id', __( 'metaname ...


11

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


10

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


10

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


10

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


10

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


9

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


9

It is almost code golf, but this is the smallest piece of code that I could up with that will create a button on the Visual editor to turn the current paragraph in a <h2> block. add_filter( 'tiny_mce_before_init', 'wpse18719_tiny_mce_before_init' ); function wpse18719_tiny_mce_before_init( $initArray ) { $initArray['setup'] = <<<JS ...


9

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' ) { ...


9

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


8

Here is a nice and fairly new (a year old) tutorial i've read a few days ago http://www.garyc40.com/2010/03/how-to-make-shortcodes-user-friendly/ He as a great example and you cal also download the source files and get a better understanding.


8

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


8

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


8

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


7

You can filter the TinyMCE body classes to add or change as needed. It's a string that's pre-populated with some things like post type, so the easiest thing to do is append your additional classes (with a preceding space). <?php function wpse_128380_tinymce_body_class( $mce ) { // you could do things here to detect whatever you need // and use ...


7

There is a button on the visual text editor built in to WordPress that will strip Microsoft Word formating. It is labeled "Paste From Word"


7

you can set the params via array on the wp_editor() function; an exmaple $settings = array( 'tinymce' => array( 'setup' => 'function (ed) { tinymce.documentBaseURL = "' . get_admin_url() . '"; }', ), 'quicktags' => TRUE, 'editor_class' => 'frontend-article-editor', 'textarea_rows' => ...


7

esc_html() and esc_textarea() are, appropriate to their names, escaping functions and really meant for display rather than sanitizing or validating. I would use wp_kses() or wp_kses_post() (which is just wp_kses() with the global $allowedposttags) to sanitize input from a wp_editor() field before saving.


7

Use the filter 'mce_external_languages'. From wp-includes/class-wp-editor.php: The following filter loads external language files for TinyMCE plugins. It takes an associative array 'plugin_name' => 'path', where path is the include path to the file. The language file should follow the same format as /tinymce/langs/wp-langs.php and ...


7

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


7

Check out this tutorial on Pro Blog Design: http://www.problogdesign.com/wordpress/user-friendly-short-codes-with-tinymce/


7

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


6

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



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