One of my plugin have this coding,
Class Afke{
public function __construct() {
add_action( 'init', array( $this, 'setup' ), -1 );
}
function setup() {
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
}
}
I tried by removing ‘add_meta_boxes’ in theme functions.php by adding the below code,
function remove_thematic_actions(){
$bcatcf = new Afke();
remove_action( 'add_meta_boxes', array( $bcatcf, 'add_meta_boxes' ));
//remove_action( 'add_meta_boxes', 'add_meta_boxes' );
}
add_action('init','remove_thematic_actions');
But not able to remove this action. Kindly suggest me.
You have used ;
in
Afke
class, but there is no such a functionadd_meta_boxes
. Use your function like this;And, in order to remove that action you need to use;
Instead of creating a new instance, assigning the original to a variable allows to target it:
Then, elsewhere, in another plugin or in the theme’s
functions.php
: