WP_Widget_Factory::unregister() WordPress Method

The WP_Widget_Factory::unregister() method allows you to unregister a widget from the WordPress widgets factory. This can be useful if you need to deregister a widget for some reason.

WP_Widget_Factory::unregister( string|WP_Widget $widget ) #

Un-registers a widget subclass.


Parameters

$widget

(string|WP_Widget)(Required)Either the name of a WP_Widget subclass or an instance of a WP_Widget subclass.


Top ↑

Source

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

	public function unregister( $widget ) {
		if ( $widget instanceof WP_Widget ) {
			unset( $this->widgets[ spl_object_hash( $widget ) ] );
		} else {
			unset( $this->widgets[ $widget ] );
		}
	}


Top ↑

Changelog

Changelog
VersionDescription
4.6.0Updated the $widget parameter to also accept a WP_Widget instance object instead of simply a WP_Widget subclass name.
2.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.