I’m currently developing a plugin that uses ajax functionality.

Problem: The callback isn’t fired = no data gets processed.

if ( ! is_admin() )
    add_action( 'after_setup_theme', array( 'wpseAjaxClass', 'init' ), 10 );

1 Answer
1

The answer was as stupid as simple: I wrapped the init for the class in a ! is_admin() call. This successfully prevented the callback from beeing fired.

Rule for AJAX loading

  • Load it in public
  • Don’t hide it behind a ! is_admin() call.

The 2nd line from admin-ajax.php

define( 'WP_ADMIN', true );

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *