PHP includes with AJAX actions
I have the following code in my main plugin file
?php
include plugin_dir_path( __FILE__) . 'options.php';
include plugin_dir_path( __FILE__ ) . 'config.php';
include plugin_dir_path( __FILE__ ) . 'front/manage.php';
add_action( 'admin_init', 'restrict_admin', 1 );
//prepare wordpress for ajax this needs to be done early to avoid strange race conditions
add_action( 'wp_ajax_devices', 'api_list_devices' );
add_action( 'wp_ajax_profiles', 'api_list_profiles' );
add_action( 'wp_ajax_held_accounts', 'api_list_held_accounts' );
add_action( 'wp_ajax_set_profile', 'api_set_profiles' );
define('AJAX_NONCE_NAME',"title_example");
//...
I assume since adding an action just lets admin-ajax.php know it should run some action at some point later, my includes aren't even executed, but I need them to authenticate the database connection. How can I tell wordpress to do my includes for parts of wordpress like this that are beyond my control? Do I have to enqueue, all the enqueueing examples seem to apply to the front end?
Topic wp-dependencies ajax plugin-development customization Wordpress
Category Web