I'm trying to customize itheme's Exchange e-commerce plugin. I'd like to add a catalogue ability - removing add to cart and buy now buttons. Since in exchange those buttons are created using their 'superwidget', I thought that the easiest way to remove those buttons is by removing the superwidget. So i created a function:
if(!function_exists('exchange_catalogue')){
function exchange_catalogue(){
unregister_widget( 'IT_Exchange_Super_Widget' );
}
}
add_filter( 'widgets_init', 'exchange_catalogue');
But I get:
Notice: Undefined index: IT_Exchange_Super_Widget in /wp-includes/widgets.php on line 1356
I checked if there is such registered widget:
$widgets = array_keys( $GLOBALS['wp_widget_factory']->widgets );
print '<pre>$widgets = ' . esc_html( var_export( $widgets, TRUE ) ) . '</pre>';
just added that to the function above, and the widget is there (listed)
$widgets = array (
...
26 => 'IT_Exchange_Super_Widget',
)
So if it exists, and my function removes it, why am I getting this notice??
Oh, and I am aware that there is an option for this, but only if you buy their expansion for ~$200, that will add an add on...
EDIT:
I tried with this:
if (isset( $GLOBALS['wp_widget_factory']->widgets['IT_Exchange_Super_Widget'] )) {
unset( $GLOBALS['wp_widget_factory']->widgets['IT_Exchange_Super_Widget'] );
}
And with
if (isset( $GLOBALS['wp_widget_factory']->widgets['IT_Exchange_Super_Widget'] )) {
unregister_widget( 'IT_Exchange_Super_Widget' );
}
But still am getting the notice.
Found the answer! :D
I just put
if(!function_exists('exchange_catalogue')){
function exchange_catalogue(){
if (isset( $GLOBALS['wp_widget_factory'])) {
$GLOBALS['wp_widget_factory']->widgets['IT_Exchange_Super_Widget'] = null;
}
}
}
This way the widget is set, but it's nothing. So it's not showing :D Simple fix if you want catalog ability for exchange shop :)