Make WordPress Core

Changeset 41942


Ignore:
Timestamp:
10/19/2017 01:50:56 PM (7 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

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

    r41798 r41942  
    101101 *
    102102 * @since 2.8.0
     103 * @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object
     104 *              instead of simply a `WP_Widget` subclass name.
    103105 *
    104106 * @see WP_Widget
     
    106108 * @global WP_Widget_Factory $wp_widget_factory
    107109 *
    108  * @param string $widget_class The name of a class that extends WP_Widget
    109  */
    110 function register_widget($widget_class) {
     110 * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass.
     111 */
     112function register_widget( $widget ) {
    111113    global $wp_widget_factory;
    112114
    113     $wp_widget_factory->register($widget_class);
     115    $wp_widget_factory->register( $widget );
    114116}
    115117
     
    121123 *
    122124 * @since 2.8.0
     125 * @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object
     126 *              instead of simply a `WP_Widget` subclass name.
    123127 *
    124128 * @see WP_Widget
     
    126130 * @global WP_Widget_Factory $wp_widget_factory
    127131 *
    128  * @param string $widget_class The name of a class that extends WP_Widget.
    129  */
    130 function unregister_widget($widget_class) {
     132 * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass.
     133 */
     134function unregister_widget( $widget ) {
    131135    global $wp_widget_factory;
    132136
    133     $wp_widget_factory->unregister($widget_class);
     137    $wp_widget_factory->unregister( $widget );
    134138}
    135139
     
    317321 *
    318322 * @global array $wp_registered_widgets            Uses stored registered widgets.
    319  * @global array $wp_registered_widget_controls    Stores the registered widget control (options).
     323 * @global array $wp_registered_widget_controls    Stores the registered widget controls (options).
    320324 * @global array $wp_registered_widget_updates
    321325 * @global array $_wp_deprecated_widgets_callbacks
Note: See TracChangeset for help on using the changeset viewer.