Disable default styles


#1

Hello, is there a way to disable or use a custom CSS file for your BP Media Plugin? If I use the themes CSS-files, my styles are getting overwritten by the default styles of your plugin. And I don't want to use !important in every line of Code. Do you have a filter for that? Or any other method? Kind regards, Jan


Rtmedia styles
#2

Its not there yet, we'll add it in our next release.


#3

That would be an important feature. It prevents custom styles from being deleted, if you update the plugin. Here is a solution, that i've seen in an other plugin: //load default css (in the plugin) add_action("wp_print_styles" , "xyz_load_css"); function xyz_load_css(){ if(apply_filters("xyz_load_css" , true)) { //allow theme developers to override it wp_enqueue_style ("xyz-css", PLUGIN_URL."xyz.css"); } } The theme-author can disable this default-css by placing the following code into the themes function.php (or elsewhere): add_filter( 'xyz_load_css', 'disable_xyz_css', 10, 1); function disable_xyz_css(){ return false; } And then he can style it in his files.


#4

Thanks for contributing the code. It will be included shortly.


#5

@jabre:

Just went through the code, you can disable the styles via wp_dequeue_style() function of the wordpress, so all you need to do is write this code in your theme:

add_action('wp_enqueue_scripts','custom_style_for_bp_media');  
function custom_style_for_bp_media(){  
    wp_dequeue_style('bp-media-default');  
    wp_enqueue_style('your-custom-style',plugins_url('path-to-stylesheet',__FILE__));  
}  

So now I don't think any modification is required in the original code as this functionality is there in WordPress since version 3.1. I hope it helps


#6

Correction Please use this add_action statement instead:

add_action('wp_enqueue_scripts','custom_style_for_bp_media',11);  

We need the custom function to execute after the original style is enqueued, otherwise with the same priority it may or may not work.


#7

That worked perfectly. Thanks!


#8

You're welcome :)


#9