0

I am trying to remove an action that is within a class, of the parent theme. I made an example of the code I have, below. I am trying to remove the action in the child theme functions.php. I've tried multiple solutions, including defining the class into a variable like: $my_class = new My_Widget(); (that needs to be done for static functions?), but I can't find a good solution. Who can help me further understand this?

parent theme file

class My_Widget extends WP_Widget {
    public function __construct( $args = array() ) {
        add_action( 'wp_ajax_contact_owner', array( __CLASS__, 'contact_process' ) );
        add_action( 'wp_ajax_nopriv_contact_owner', array( __CLASS__, 'contact_process' ) );

    }

    public static function contact_process() {
        global $cc_options;         
        echo 'test';
    }

}

functions.php child theme

function cc_remove_action(){    
    remove_action( 'wp_ajax_contact_owner', array('My_Widget', 'contact_process' ), 11 );
    remove_action( 'wp_ajax_nopriv_contact_owner', array( 'My_Widget', 'contact_process' ), 11 );
}   
add_action( 'wp_head', 'cc_remove_action' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.