本文介绍了需要 remove_action() 方面的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试删除内置的最近评论"小部件放置在我的 中的难看的嵌入 标记,但我可以'似乎语法正确.它最初调用

I'm trying to remove the unsightly embedded <STYLE> tag the built-in Recent Comments widget puts in my <HEAD>, but I can't seem to get the syntax right. It originally calls

add_action( 'wp_head', array(&$this, 'recent_comments_style') );

添加它(在 wp-includes/default-widgets.php,第 609 行),我正在尝试撤消它.

to add it (in wp-includes/default-widgets.php, line 609), and I'm trying to undo it.

我认为应该是这样的:

remove_action('wp_head', 'WP_Widget_Recent_Comments::recent_comments_style');

但是使用我尝试过的所有变体,我仍然无法做到正确.有谁知道如何实现这一目标?

but with all the variations I've tried I still can't get it right. Does anyone know how to achieve this?

推荐答案

这是正确的代码:

add_action('wp_head', 'remove_widget_action', 1);
function remove_widget_action() {
    global $wp_widget_factory;

    remove_action( 'wp_head', array($wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style') );
}

但是,由于这个错误,它不起作用.

However, it doesn't work because of this bug.

这篇关于需要 remove_action() 方面的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 19:54