Docs: After [37329], update the documentation for `register_widget()` and `unregister_widget()`.
Both functions can accept a `WP_Widget` instance object instead of a `WP_Widget` subclass name, same as `WP_Widget_Factory::register()` and `::unregister()`. Props behzod. Fixes #42270. git-svn-id: https://develop.svn.wordpress.org/trunk@41942 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e18b4c894b
commit
083f2abada
|
@ -100,17 +100,19 @@ $GLOBALS['_wp_deprecated_widgets_callbacks'] = array(
|
|||
* Registers a WP_Widget widget
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object
|
||||
* instead of simply a `WP_Widget` subclass name.
|
||||
*
|
||||
* @see WP_Widget
|
||||
*
|
||||
* @global WP_Widget_Factory $wp_widget_factory
|
||||
*
|
||||
* @param string $widget_class The name of a class that extends WP_Widget
|
||||
* @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass.
|
||||
*/
|
||||
function register_widget($widget_class) {
|
||||
function register_widget( $widget ) {
|
||||
global $wp_widget_factory;
|
||||
|
||||
$wp_widget_factory->register($widget_class);
|
||||
$wp_widget_factory->register( $widget );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -120,17 +122,19 @@ function register_widget($widget_class) {
|
|||
* Run within a function hooked to the {@see 'widgets_init'} action.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object
|
||||
* instead of simply a `WP_Widget` subclass name.
|
||||
*
|
||||
* @see WP_Widget
|
||||
*
|
||||
* @global WP_Widget_Factory $wp_widget_factory
|
||||
*
|
||||
* @param string $widget_class The name of a class that extends WP_Widget.
|
||||
* @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass.
|
||||
*/
|
||||
function unregister_widget($widget_class) {
|
||||
function unregister_widget( $widget ) {
|
||||
global $wp_widget_factory;
|
||||
|
||||
$wp_widget_factory->unregister($widget_class);
|
||||
$wp_widget_factory->unregister( $widget );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -316,7 +320,7 @@ function is_registered_sidebar( $sidebar_id ) {
|
|||
* @since 2.2.0
|
||||
*
|
||||
* @global array $wp_registered_widgets Uses stored registered widgets.
|
||||
* @global array $wp_registered_widget_controls Stores the registered widget control (options).
|
||||
* @global array $wp_registered_widget_controls Stores the registered widget controls (options).
|
||||
* @global array $wp_registered_widget_updates
|
||||
* @global array $_wp_deprecated_widgets_callbacks
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue