There is no good way of doing this.
One way is to enumerate the already registered scripts, like this:
function yourplugin_add_my_stylesheet() {
global $wp_styles;
if ( $wp_styles instanceof WP_Styles ) {
// enumerate all current styles
foreach( $wp_styles->queue as $handle ) {
// use the $handle to see if it's called 'bootstrap'
$obj = $wp_styles->registered[$handle];
// or use $obj['src'] to see if `bootstrap.css` is in there
}
}
}
add_action('wp_enqueue_scripts', 'yourplugin_add_my_stylesheet');
But this will in most cases not work:
- The order of plugin loading is not know, so the offending other plugin my load after this.
- The offending other plugin my not use terms like ‘bootstrap’, or may load the css via other means, not the
wp_register_style()
method.
A possible suggestion is that your plugin gets a option page with a checkbox that allows the admin to either load the css or not. This way, if there is a conflict or duplication then one can switch off the loading of the duplicate.