How to load wp_editor() through AJAX/jQuery

To get the quicktags to show up, you need to re instantiate them within your ajax oncomplete handler. quicktags({id : ‘editorcontentid’}); My ajax success handler looks like this; success: function(data, textStatus, XMLHttpRequest){ //append editor to dom $(‘#container’).append($(data).html()); //init quicktags quicktags({id : ‘editorcontentid’}); //init tinymce tinymce.init(tinyMCEPreInit.mceInit[‘editorcontentid’]); } I’ve managed to get the editor to load by … Read more

How to check if I am in admin-ajax.php?

Check the constant DOING_AJAX. Its definition is the first working code in wp-admin/admin-ajax.php. Some very weird plugins, like Jetpack, are defining that constant in unexpected places, so you might include a check for is_admin() as well. Example: if ( is_admin() && defined( ‘DOING_AJAX’ ) && DOING_AJAX ) { // do something } I have asked … Read more

Ajax takes 10x as long as it should/could

Yep, this is nasty issue that to have full WordPress environment you need to spend considerable time loading it. I’ve needed much better performance (for very dynamic incremental search feature) for work and what I went with is: Custom file as Ajax handler. SHORTINIT constant for limited WP core load. Very selectively loaded parts of … Read more

jQuery: Performing synchronous AJAX requests

As you’re making a synchronous request, that should be Example – http://api.jquery.com/jQuery.ajax/#example-3 PLEASE NOTE: Setting async property to false is deprecated and in the process of being removed (link). Many browsers including Firefox and Chrome have already started to print a warning in the console if you use this: Chrome: Synchronous XMLHttpRequest on the main … Read more

JavaScript implementation of Gzip

Edit There appears to be a better LZW solution that handles Unicode strings correctly at http://pieroxy.net/blog/pages/lz-string/index.html (Thanks to pieroxy in the comments). I don’t know of any gzip implementations, but the jsolait library (the site seems to have gone away) has functions for LZW compression/decompression. The code is covered under the LGPL.