Making my own custom plugin and using add_action several times without a problem with one exception. Currently function below are located in functions.php in the appropriate themes folder.
function enqueue_custom_scripts() {
error_log('enqueue_custom_scripts function is executing'); // In enqueue_custom_scripts
wp_enqueue_script('custom-ajax-script', get_stylesheet_directory_uri() . '/js/custom-ajax-script.js', array('jquery'), null, true);
wp_localize_script('custom-ajax-script', 'ajax_object', array(
'ajax_url' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('my-custom-ajax-nonce'),
));
}
add_action('wp_enqueue_scripts', 'enqueue_custom_scripts');
I have tried several version of this, in several files including plugin main file. Note: Not even the error_log trigger. The odd thing is that it works if user not logged in. Probably some stupid mistake I made so help is appreciated.