This only works for admin dashboard.
add_action('admin_enqueue_scripts',array($this, 'login_register96_adminscripts'));
And this only works for the user place.
add_action( 'wp_enqueue_scripts', array($this , 'login_register96_scripts') );
Is there a way I can enqueue a script globally?
Which will be operational on the whole website including admin dashboard.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
I’m not aware of any other way but to use both add_action lines, for a single function.
Example:
function my_enqueue_sripts_function_name(){
// your enqueue logic here
}
add_action('wp_enqueue_scripts', 'my_enqueue_sripts_function_name' );
add_action('admin_enqueue_scripts', 'my_enqueue_sripts_function_name' );
There’s no rule that forbids you from adding the same function on multiple hooks.
Furthermore, if you need to know which action called the function, from within the function, you can use current_action() or current_filter()
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0