How to remove an action that is added inside a class

I don’t understand any of it but it seems to work just fine. Thank you @Buttered_Toast for mentioning the useful thread.

add_action("init", function() {
    global $wp_filter;
    foreach($wp_filter["wp"][10] as $id => $filter) {
    if(is_array($filter["function"]) && count($filter["function"]) == 2 &&
        get_class($filter["function"][0]) == "Post_Views_Counter_Columns" &&
        $filter["function"][1] == "admin_bar_maybe_add_style") {
            remove_action("wp", $id);
        }
    }
}, 99);

Leave a Comment