WP_Widget_Factory::get_widget_object() WordPress Method

The WP_Widget_Factory::get_widget_object() method is used to get a Widget Object from a given widget ID. This can be useful if you need to access a widget's properties or methods from outside the widget's class.

WP_Widget_Factory::get_widget_object( string $id_base ) #

Returns the registered WP_Widget object for the given widget type.


Parameters

$id_base

(string)(Required)Widget type ID.


Top ↑

Return

(WP_Widget|null)


Top ↑

Source

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

	public function get_widget_object( $id_base ) {
		$key = $this->get_widget_key( $id_base );
		if ( '' === $key ) {
			return null;
		}

		return $this->widgets[ $key ];
	}


Top ↑

Changelog

Changelog
VersionDescription
5.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.