unregister_widget

Unregisters a widget.

Description

unregister_widget( (string) $widget_class ); 

Unregisters a WP_Widget widget. Useful for un-registering default widgets. Run within a function hooked to the action.

Parameters (1)

0. $widget_class (string)
The name of a class that extends WP_Widget.

Usage

  1. if ( !function_exists( 'unregister_widget' ) ) { 
  2. require_once ABSPATH . WPINC . '/widgets.php'; 
  3.  
  4. // The name of a class that extends WP_Widget. 
  5. $widget_class = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = unregister_widget($widget_class); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/widgets.php  
  1. function unregister_widget($widget_class) { 
  2. global $wp_widget_factory; 
  3.  
  4. $wp_widget_factory->unregister($widget_class);