WP_Widget_Factory::_register_widgets

Advertisement

Summery Summery

Serves as a utility method for adding widgets to the registered widgets global.

Syntax Syntax

WP_Widget_Factory::_register_widgets()

Source Source

File: wp-includes/class-wp-widget-factory.php

	public function _register_widgets() {
		global $wp_registered_widgets;
		$keys       = array_keys( $this->widgets );
		$registered = array_keys( $wp_registered_widgets );
		$registered = array_map( '_get_widget_id_base', $registered );

		foreach ( $keys as $key ) {
			// Don't register new widget if old widget with the same id is already registered.
			if ( in_array( $this->widgets[ $key ]->id_base, $registered, true ) ) {
				unset( $this->widgets[ $key ] );
				continue;
			}

			$this->widgets[ $key ]->_register();
		}
	}

Advertisement

Changelog Changelog

Changelog
Version Description
2.8.0 Introduced.

Advertisement

Leave a Reply