admin管理员组文章数量:1130349
I am trying to build a wp plugin using vuejs and the bulma css framework, but it seems like it is having an impact on the whole admin area.
Is it possible to load my css only on my plugin admin page?
I am trying to build a wp plugin using vuejs and the bulma css framework, but it seems like it is having an impact on the whole admin area.
Is it possible to load my css only on my plugin admin page?
Share Improve this question edited Dec 17, 2018 at 21:58 Dan Gayle 6,1665 gold badges33 silver badges45 bronze badges asked Dec 15, 2018 at 14:14 fefefefe 8943 gold badges14 silver badges34 bronze badges 1- Did you read the documentation ? codex.wordpress/Plugin_API/Action_Reference/… – shanebp Commented Dec 15, 2018 at 20:59
1 Answer
Reset to default 1To answer the question, from the codex, listed above in the comments.
function load_custom_wp_admin_style($hook) {
// Load only on ?page=mypluginname
if($hook != 'toplevel_page_mypluginname') {
return;
}
wp_enqueue_style( 'custom_wp_admin_css', plugins_url('admin-style.css', __FILE__) );
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );
Note: If you are unsure what your $hook name is .. use this to determine your hookname. Put the code after the { from the function.
wp_die($hook);
I am trying to build a wp plugin using vuejs and the bulma css framework, but it seems like it is having an impact on the whole admin area.
Is it possible to load my css only on my plugin admin page?
I am trying to build a wp plugin using vuejs and the bulma css framework, but it seems like it is having an impact on the whole admin area.
Is it possible to load my css only on my plugin admin page?
Share Improve this question edited Dec 17, 2018 at 21:58 Dan Gayle 6,1665 gold badges33 silver badges45 bronze badges asked Dec 15, 2018 at 14:14 fefefefe 8943 gold badges14 silver badges34 bronze badges 1- Did you read the documentation ? codex.wordpress/Plugin_API/Action_Reference/… – shanebp Commented Dec 15, 2018 at 20:59
1 Answer
Reset to default 1To answer the question, from the codex, listed above in the comments.
function load_custom_wp_admin_style($hook) {
// Load only on ?page=mypluginname
if($hook != 'toplevel_page_mypluginname') {
return;
}
wp_enqueue_style( 'custom_wp_admin_css', plugins_url('admin-style.css', __FILE__) );
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );
Note: If you are unsure what your $hook name is .. use this to determine your hookname. Put the code after the { from the function.
wp_die($hook);
本文标签: Is it possible to load the css just on my plugin admin page
版权声明:本文标题:Is it possible to load the css just on my plugin admin page? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749090068a2314377.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论