I’m trying to pass an ajax action to /wp-admin/admin-ajax.php, however I can’t seem to get it to call any functions that use a class to encapsulate the namespace. I get the following error:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'PHP_faq_backend' not found in /wp-includes/plugin.php
My action is as follows:
add_action('wp_ajax_edit_form', array('PHP_faq_backend', 'edit_form'));
Obviously I don’t want to force this by modifying the admin-ajax.php file, but how do I get my classfiles loaded so the action will work?
Make sure you are including your class files somewhere within your WordPress theme (functions.php), or Plugin.
I usually use something like this;
The above is for registering actions from within a class instance.