I have used twitter bootstrap to my plugin. But after install the plugin, it is changing style of the theme that has already bootstrap. How can i avoid this conflict?
1 Answer
You should not ship general purpose styles with any public plugin.
There are two typical approaches to this:
Don't ship any styles and rely on simple/expected markup. This works for cases like widgets, with similar enough markup between different themes. Same goes for outputting in content area — any quality theme is presumed to have styling for basic elements.
Make styles precisely specific to your markup. For example only produce output inside container with class/id unique to your plugin. Since you use Bootstrap in your specific case and it uses Less (as opposed to plain CSS) it makes it easy to import and nest rules to produce such stylesheet.
function newsbox_style_and_script() { wp_enqueue_style( 'bootstrap-style', plugins_url( '/css/bootstrap.min.css', __FILE__ ),array(),'3.0.3'); } add_action( 'wp_enqueue_scripts', 'newsbox_style_and_script' );
@TomásCot