wp_ajax action responds with 0

Change your wp_localize_script-Call to the right Action: wp_localize_script( ‘addItemToNav’, ‘menuItems’, array( // URL to wp-admin/admin-ajax.php to process the request ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ), // generate a nonce with a unique ID “myajax-post-comment-nonce” ‘postCommentNonce’ => wp_create_nonce( ‘update_nav_items-nonce’ ), ‘action’ => ‘wp_ajax_update_nav_items’ ) ); As ‘action’ you currently Input the function Name, but that is wrong. … Read more

how to use wp_editor() here am getting empty result

Your syntax for passing the settings array is incorrect and also you have not specified the name for the textarea in the settings array which is why it returns you an empty alert. Syntax from WordPress Codex: wp_editor( $content, $editor_id, $settings = array() ); $content (string) (required) – Initial content for the editor $editor_id (string) … Read more

AJAX – SHORTINIT set to TRUE returns blank

You are using esc_attr(), which isn’t available if you use define( ‘SHORTINIT’, true ); , see source. So you either have to load the formatting.php manually or have to ditch the define( ‘SHORTINIT’, true ); – actually like the example in the thread you are referring to shows. As said in the comment, I checked … Read more

Contact form – ajax, wp_mail

From quick look at your code you seem to be omitting where you are submitting request to. By default it is just current page, which isn’t typically equipped to receive the request. Since you are using wp_ajax_ hook you need to point request at admin-ajax.php endpoint. On admin side the URL is provided in ajaxurl … Read more

Multiple wp_editor instances in custom post type using Ajax

forget about using wp_editor on such scenario.. instead use the core tinymce, something like; tinymce.init({ //selector: ‘customEditor-‘ + nextPlusSignId, editor_selector: ‘nwac_editor_’ + nextPlusSignId, mode: “specific_textareas”, media_buttons: false, menubar: false, content_css: nw.baseurl + ‘/skins/wordpress/wp-content.css’, body_class: ‘mce-content-body nwac_plus_signs_’ + nextPlusSignId + ‘_template post-type-products post-status-publish mceContentBody webkit wp-editor wp-autoresize html4-captions has-focus’, });

How to update post with Ajax (no plugin)

This question is old, but for future reference, check out the answer I gave on the original question here. The gist is: Confirmation Dialog The alert is generated in wp-admin/js/post.js and wp-includes/js/autosave.js. Theoretically, you should be able to use the following line of code in your $.post success function: wp.autosave.initialCompareString = wp.autosave.getCompareString(); But that doesn’t … Read more

Custom RPC end-point security best pratice?

I think your paradigm is not optimal. You are starting on premise of “WordPress Ajax endpoint is slow” and your solution is to “build alternate authentication scheme”. This completely spells trouble. Anything security should be reused as much as possible and coded by people specializing in security. Trade-off of reimplementing security for the sake of … Read more

Ajax resetting my global variable

Each time you’re making an ajax call, $_TEST = 0; is being evaluated again. You use the options API to manipulate your variable. function get_global_val() { $count = get_option( ‘mycount’ ); $count++; //or whatever you want to do with it update_option( ‘mycount’, $count ); die(“New value is $count”); }