WP_Widget::_register()

In this article

Register all widget instances of this widget class.

Source

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();
	}
}

Changelog

VersionDescription
2.8.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.