如何使用functions.php从wordpress取消注册样式表?

时间:2011-12-07 10:49:43

标签: wordpress stylesheet

我在这里找到了关于如何在wordpress中取消注册样式的文章。 techotronic.de/how-to-de-register-style-sheet-wordpress/

我想的很简单,但我无法理解他想说的话。这是下面的代码......

add_action( 'wp_print_styles', 'custom_deregister_styles', 100 );

function custom_deregister_styles() {

  wp_deregister_style( 'colorbox-theme1' );

}

直接向前,为他的插件...

但如果我想从我正在使用的另一个插件中取消注册一个样式,你如何找到代码中的名字 - wp_deregister_style('????'); < / p>

我已经尝试过显而易见的样式表名称......

add_action( 'wp_print_styles', 'custom_deregister_styles', 100 );
function custom_deregister_styles() {
  wp_deregister_style( 'language-selector.css' );
}

这是我发现的另一种方法,但无法理解我的工作?

add_action("gform_enqueue_scripts", "deregister_style");
    function deregister_style(){
wp_deregister_style("gforms_css");
}

这个deregister方法是如何工作的,我需要在插件中查找以获取相对名称才能使其工作。我很困惑。

感谢任何建议!


更新

我刚刚发现我试图取消注册的样式表没有通过wp_enqueue_style或wp_register_style加载。

请参阅此插件中的php文件https://gist.github.com/1442470

language-selector.css

上查看 792

1 个答案:

答案 0 :(得分:0)

在插件文件夹中查找wp_register_stylewp_enqueue_style。您将在该函数调用中找到该名称。

更新:你不能在不编辑插件的情况下删除它,或解析为丑陋的黑客,比如缓冲所有输出并在最后过滤它。这就是wp_enqueue_style或wp_register_style应该用于所有样式表的原因。