Is it possible to override this function/class in a child theme?

You simply need to run your code on a higher priority than what the parent theme is, the default on add_action function is 10 so you can use:

function s157343_unregister_widgets() {
     unregister_widget( 'Chocolat_Widget_New_Entrys' );
}
add_action( 'widgets_init', 's157343_unregister_widgets', 20 );

This will unregister that widget. Of course, you can still create a new class that extends that widget’s class to override the methods you want and register a new widget based on that:

class my_Chocolat_Widget_New_Entrys extends Chocolat_Widget_New_Entrys() {
    public function __construct() {}
    public function widget( $args, $instance ) {}
}
add_action( 'widgets_init', create_function( '', 'return register_widget( "my_Chocolat_Widget_New_Entrys" );' ) );

Leave a Comment