I want to replace a template from a third-party plugin included by a class function with a customized one. I am trying to override that class function by extending the parent class, but for now this just is doubling the expected output. How to remove the original function? I need to remove the filter that is added in the parent class? How to do that?
The main class looks like this:
class Import_Some_Events_Cpt {
public function __construct() {
add_filter( 'the_content', array( $this, 'some_events_meta_before_content' ) );
}
function some_events_meta_before_content( $content ) {
$event_details = $this->some_events_get_event_meta( get_the_ID() );
$content = $event_details . $content;
return $content;
}
function some_events_get_event_meta() {
//here is included the original plugin template
}
}
My extending class is looking like this:
class Import_Some_Events_Cpt_Ext extends Import_Some_Events_Cpt {
function some_events_meta_before_content( $content ) {
$event_details = $this->some_events_get_event_meta( get_the_ID() );
$content = $event_details . $content;
return $content;
}
function some_events_get_event_meta() {
//here is included the customized template
}
}
UPDATE
The original class Import_Some_Events_Cpt is instanciated in an other class:
class Import_Some_Events{
private static $instance;
public static function instance() {
if( ! isset( self::$instance ) && ! (self::$instance instanceof Import_Some_Events ) ) {
self::$instance = new Import_Some_Events;
self::$instance->setup_constants();
add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) );
self::$instance->cpt = new Import_Some_Events_Cpt();
}
return self::$instance;
}
}
This class is instanciated from a separate function:
function run_import_some_events() {
return Import_Some_Events::instance();
}
And the above function is set to a variable:
$ife_events = run_import_some_events();
The all code is in an other file than the class I want to override.
Sorry if I make mistakes, I am not a programmer.
Import_Some_Events_Cpt
?