I want to override function in child theme, which is defined inside a class in parent theme.

Here is the sample code:

class A extends B{
   function __construct(){
      $this->add_ajax('sync_post_data', 'need_to_override');
   }
   //other functions
   function need_to_override(){
      //function code
   }

}

Additional Information:

Class B extends Class C and Class C is the root class where add_ajax is defined.

What I’ve tried:

  1. As the function is not pluggable so I can’t override function directly in child theme.
  2. Secondly I tried to remove ajax action and add my custom action. It throws 500 internal server error.

    remove_action( 'wp_ajax_sync_post_data', 'need_to_override' );
    add_action( 'wp_ajax_sync_post_data', 'custom_function' );
    
    function custom_function(){
       //function code with my custom modification
    }
    

Any help please…

Leave a Reply

Your email address will not be published.