Wordpress replaces the plugin function with its own

I am using the woocommerce plugin on my WordPress site. There is a widget () function in the plugin, I want to call my own function, so when the site loads, not the plugin function

public function widget($args, $instance) 

my function will be called.

I think this should be done using add_filter, I cannot find out how to do this.

Plugin Files Directory:

 woocommerce/includes/widgets/class-wc-widget-layered-nav.php 
+5
source share
1 answer

please try under the code (put it in the WordPress functions.php theme)

 add_action( 'widgets_init', 'my_widget_replacement', 11 ); function my_widget_replacement() { unregister_widget( 'WC_Widget_Layered_Nav' ); register_widget( 'My_WC_Widget_Layered_Nav' ); } class My_WC_Widget_Layered_Nav extends WC_Widget_Layered_Nav { public function widget( $args, $instance ) { // your code } } 

This code may not work - it's just an idea.

+2
source

Source: https://habr.com/ru/post/1209066/


All Articles