質問

見苦しい埋め込みを削除しようとしています <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') );
}

しかし、それが原因でこのバグのrel="noreferrer">の

他のヒント

remove_action('wp_head', array(&$this, 'recent_comments_style'));
Wordpressのは、あなたがそれを削除するか、追加するかどうかのユニークなIDを作成するために、同じ機能を使用しているため、

この作業をする必要があります。

// 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
scroll top