我无法覆盖“Total Control HTML5 Audio Player Basic”插件默认css文件。
我已经在里面复制了插件css默认内容style.css
文件,然后我尝试更改一些内容,但没有显示新的css规则。
我向Firebug检查过,自定义css文件是在默认文件之后加载的,所以我不明白为什么不应用新规则。
我也尝试过这个建议:Override CSS settings of plugins
add_filter( \'style_loader_src\', \'wpse106104_replace_stylesheet\' );
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;
}
但这只会带来以下错误:
Warning: Missing argument 2 for wpse106104_replace_stylesheet() in /home/me/MyServer/myproject/wp-content/themes/twentyfourteen-child/functions.php on line 451
Notice: Undefined variable: handle in /home/me/MyServer/myproject/wp-content/themes/twentyfourteen-child/functions.php on line 453
Notice: Use of undefined constant stylesheet_src - assumed \'stylesheet_src\' in /home/me/MyServer/myproject/wp-content/themes/twentyfourteen-child/functions.php on line 456
Warning: Missing argument 2 for wpse106104_replace_stylesheet() in /home/me/MyServer/myproject/wp-content/themes/twentyfourteen-child/functions.php on line 451
有什么建议吗?
最合适的回答,由SO网友:tfrommen 整理而成
如果要这样做,必须如下所示:
add_filter(\'style_loader_src\', \'wpse127340_replace_stylesheet\', 10, 2);
function wpse127340_replace_stylesheet($src, $handle){
if (\'your-plugin-script-handle\' == $handle)
return get_template_directory_uri().\'/css/themes-copy-of-plugin.css\';
return $src;
}
更换
your-plugin-script-handle
和
themes-copy-of-plugin.css
和你想要的一样。