How to tie built in AJAX to an add_action?

I found a way around this by not using the JS methods themselves but basically listening for their attached AJAX calls and taking it from there. This was my final code. I used the the QueryStringToHash function listed here to parse the data sent in the first place, and use this to determine if I … Read more

Load tinyMCE / wp_editor() via AJAX [duplicate]

your post here helped me figure a solution. Along with the mceInit property, I also had to retrieve the qtInit that wp_editor generates as well. The following is the relevant code within my class. Basically I have wp_editor run so that the javascript is generated. I use hooks to retrieve the javascript, so that I … Read more

Admin Notification after save_post, when ajax saving in gutenberg

Presenting Notices Gutenberg provides a mechanism for displaying notices in the form of the Notices Data package. In Gutenberg’s editors, the package’s selectors and action creators are exposed on the core/notices store, and can be accessed by any standard means therein, e.g.: useDispatch( ‘core/notices’ ) hook in functional components (including the edit() function of a … Read more

Ajax requests without JQuery

Coming back to this on a new application. I just solved this using Angular, and a similar approach could be used with vanilla JS. First, give Javascript access to the admin-ajax.php URL, something like: echo “<script type=”text/javascript”>var ajaxurl=””.admin_url(“admin-ajax.php’).”‘</script>”; Next, in functions.php, register the action you want the Ajax to perform: add_action(“wp_ajax_infiniteScroll”, “infiniteScroll”); add_action(“wp_ajax_nopriv_infiniteScroll”, “infiniteScroll”); …and … Read more

admin-ajax.php returns 0. How do I debug it and fix it?

Enable Debugging WordPress has constants defined in wp-config.php where you can print errors to the screen and log them in a separate file located /wp-content/debug.log. It looks like this: define( ‘WP_DEBUG’, true ); define( ‘WP_DEBUG_DISPLAY’, true ); define( ‘WP_DEBUG_LOG’, true ); You can then print your own information to the debug log at specific point … Read more