需要帮助remove_action()
-
12-09-2019 - |
题
我试图删除有碍观瞻的嵌入式 <STYLE>
标签的建在最近的评论部件放在我的 <HEAD>
, 但我似乎无法得到法权利。它最初的电话
add_action( 'wp_head', array(&$this, 'recent_comments_style') );
添加(在 wp-includes/default-widgets.php线609),和我试图撤消它。
我认为它应该是这样的:
remove_action('wp_head', 'WP_Widget_Recent_Comments::recent_comments_style');
但所有的变化,我已经试过了我还不能得到它的权利。任何人都不会知道如何实现这一目标?
可能有帮助:
解决方案
这是正确的代码:
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') );
}
然而,它不工作是因为 这个错误.
其他提示
remove_action('wp_head', array(&$this, 'recent_comments_style'));
这应工作,因为使用相同的功能以建立的唯一的标识是否删除或添加。
// remove old recentcomments inline style
add_action( 'widgets_init', 'my_remove_recent_comments_style' );
function my_remove_recent_comments_style() {
global $wp_widget_factory;
remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
}
测试。工作
现在简单:
// Remove Recent Comments Default Style
add_filter( 'show_recent_comments_widget_style', '__return_false' ); // Temp hack #14876
不隶属于 StackOverflow