Load wp_editor via ajax [duplicate]

Add this to your plugin file: (you can also add it on the theme’s functions file) function ajax_wp_editor() { ?> your html form here <?php } //for all users add_action(‘wp_ajax_nopriv_ajax_wp_editor’, ‘ajax_wp_editor’); // for logged in users add_action(‘wp_ajax_ajax_wp_editor’, ‘ajax_wp_editor’); Request Ajax using this URL: [BLOG_ADDRESS]/wp-admin/admin-ajax.php?action=ajax_wp_editor

Sanitize content from wp_editor

In short: it is in dependence of your context, the data inside your editor. wp_kses() is really helpful, and you can define your custom allowed HTML tags. Alternative, you can use the default functions, like wp_kses_post or wp_kses_data. These functions are helpful in ensuring that HTML received from the user only contains white-listed elements. See … Read more

How to get the input of a TinyMCE editor when using on the front-end?

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(); }else{ return jQuery(‘#html_text_area_id’).val(); } }

How to load wp_editor via AJAX

The main problem are the missing scripts. The scripts enqueued in _WP_Editors::enqueue_scripts() are never printed. The same is true for _WP_Editors::editor_js(). So you have to do that in your AJAX callback handler. I have written a demo plugin and put it on GitHub: T5 AJAX Editor. There is one class named Ajax_Editor. Its method render() … Read more

wp_editor textarea value not updating

tinyMCE <textarea> element is initially unseen by the used serialize function: $.post( ajaxurl, $(‘#addtag’).serialize(), function(r) { // Content here. } }); You will need to call tinyMCE.triggerSave() to make it visible. Below is a simple snippet that should do the trick: jQuery(‘#submit’).mousedown( function() { tinyMCE.triggerSave(); }); This in an external file, enqueued with wp_enqueue_script(); it … Read more

Creating a wp_editor instance with custom tinyMCE buttons

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’ => 4, ‘tinymce’ => array( … Read more