admin管理员组文章数量:1327465
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.
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.
Share Improve this question asked Aug 5, 2020 at 21:37 Saqib AliSaqib Ali 233 bronze badges1 Answer
Reset to default 5I'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()
本文标签: plugin developmentEnqueue script globally
版权声明:本文标题:plugin development - Enqueue script globally 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742208721a2433304.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论