WP_Widget::_register
Register all widget instances of this widget class.
Method of the class: WP_Widget{}
No Hooks.
Returns
null. Nothing (null).
Usage
$WP_Widget = new WP_Widget(); $WP_Widget->_register();
Changelog
| Since 2.8.0 | Introduced. |
WP_Widget::_register() WP Widget:: register code WP 6.8.3
public function _register() {
$settings = $this->get_settings();
$empty = true;
// When $settings is an array-like object, get an intrinsic array for use with array_keys().
if ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) {
$settings = $settings->getArrayCopy();
}
if ( is_array( $settings ) ) {
foreach ( array_keys( $settings ) as $number ) {
if ( is_numeric( $number ) ) {
$this->_set( $number );
$this->_register_one( $number );
$empty = false;
}
}
}
if ( $empty ) {
// If there are none, we register the widget's existence with a generic template.
$this->_set( 1 );
$this->_register_one();
}
}