Registering AJAX callback function that is part of a class without instantiating the class in function.php

If you are using class which needs an instance of, you have to create that instance somewhere. Currently WP has no designated convention for something like that.

Common practice is to use static methods, so your hook becomes add_action('wp_ajax_my_action', array(__CLASS__, 'my_action_callback'));.

Leave a Comment