WordPress.org

Make WordPress Core

Changeset 10979


Ignore:
Timestamp:
04/17/09 05:54:07 (6 years ago)
Author:
ryan
Message:

unregister_widget(). see #8441

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/widgets.php

    r10912 r10979  
    294294    } 
    295295 
     296    function unregister($widget_class) { 
     297        $offset = array_search($widget_class, $this->widgets); 
     298        if ( false === $offset ) 
     299            return; 
     300 
     301        array_splice($this->widgets, $offset, 1); 
     302    } 
     303 
    296304    function _register_widgets() { 
    297305        foreach ( $this->widgets as $widget ) 
     
    349357 
    350358    $wp_widget_factory->register($widget_class); 
     359} 
     360 
     361/** 
     362 * Unregister a widget 
     363 * 
     364 * Unregisters a WP_Widget widget. Useful for unregistering default widgets. 
     365 * Run within a function hooked to the widgets_init action. 
     366 * 
     367 * @since 2.8.0 
     368 * 
     369 * @see WP_Widget 
     370 * @see WP_Widget_Factory 
     371 * @uses WP_Widget_Factory 
     372 * 
     373 * @param string $widget_class The name of a class that extends WP_Widget 
     374 */ 
     375function unregister_widget($widget_class) { 
     376    global $wp_widget_factory; 
     377 
     378    $wp_widget_factory->unregister($widget_class); 
    351379} 
    352380 
Note: See TracChangeset for help on using the changeset viewer.