WP_Widget::_register() WordPress Method
The WP_Widget::_register() method is used to register a widget with WordPress. This method takes two arguments: the widget ID and the widget name. The widget ID is used to identify the widget in the database, and the widget name is used to display the widget in the WordPress admin interface.
WP_Widget::_register() #
Register all widget instances of this widget class.
Source
File: wp-includes/class-wp-widget.php
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();
}
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 2.8.0 | Introduced. |