WP_Widget_Factory::register( string|WP_Widget $widget )
Registers a widget subclass.
Parameters
- $widget
-
(Required) Either the name of a
WP_Widgetsubclass or an instance of aWP_Widgetsubclass.
Source
File: wp-includes/class-wp-widget-factory.php
public function register( $widget ) {
if ( $widget instanceof WP_Widget ) {
$this->widgets[ $this->hash_object( $widget ) ] = $widget;
} else {
$this->widgets[ $widget ] = new $widget();
}
}
Changelog
| Version | Description |
|---|---|
| 4.6.0 | Updated the $widget parameter to also accept a WP_Widget instance object instead of simply a WP_Widget subclass name. |
| 2.8.0 | Introduced. |