【问题标题】:How do I deregister style sheet from wordpress using functions.php?如何使用functions.php从wordpress中注销样式表?
【发布时间】:2011-12-07 10:49:42
【问题描述】:

我在这里找到了这篇关于如何在 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(' ???? ');

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

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");
}

这个注销方法是如何工作的,我需要在插件中寻找什么来获取相对名称才能让它工作。我很困惑。

感谢任何建议,谢谢!


更新

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

在此处查看插件中的 php 文件 https://gist.github.com/1442470

792 行查找 language-selector.css

【问题讨论】:

    标签: wordpress stylesheet


    【解决方案1】:

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

    更新:如果不编辑插件,或者解决丑陋的 hack,比如缓冲所有输出并在最后过滤它,就无法删除它。这就是所有样式表都应该使用 wp_enqueue_style 或 wp_register_style 的原因。

    【讨论】:

      猜你喜欢
      • 2014-09-08
      • 2017-06-20
      • 2018-09-03
      • 2014-12-22
      • 1970-01-01
      • 1970-01-01
      • 2020-12-03
      • 2012-06-27
      • 1970-01-01
      相关资源
      最近更新 更多