I want to override some rules of a plugin css file within my own theme so next time that I updated that plugin, my settings of that plugin be in a safe place . currently I copied that css file into my theme and changed some rules.So then I need to override this rules. I think found an answer that is related to my question (HERE) but I can't understand this code. how it works?
add_filter( 'style_loader_src', 'wpse106104_replace_stylesheet', 10, 2 );
function wpse106104_replace_stylesheet( $stylesheet_src, $handle ){
if( 'plugin-script-handle' == $handle ){
$stylesheet_src = get_template_directory_uri() . '/css/themes-copy-of-plugin.css';
}
return $stylesheet_src;
}
plugin-script-handle
in this case. The handler is the first parameter ofwp_enqueue_style()
used to enqueue the stylesheet.