I am developing plugin wherein I want to add bootstrap.css
to plugin setting page. But if I add css, it will get add to whole WordPress admin panel.
Is there any way to apply css to particular plugin only?
You can use get_current_screen()
to check which page is being displayed now, and if it was your plugin's page, enqueue the script.
However the easier way is to use the global variable, $pagenow
:
if(( $pagenow == 'my-plugin.php' ) {
wp_enqueue_style('my-style', 'URL-HERE' );
}
In which my-plugin.php
is the slug of your plugin screen's URL, such as:
www.example.com/wp-admin/my-plugin.php
get_the_current_screen();
, it's a much more powerful function, that also allow queries such as plugin.php?query=sample
.
Commented
Aug 1, 2017 at 5:47
get_current_screen
(not get_the_current_screen)