WP_Widget_Factory::hash_object( WP_Widget $widget )

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Hashes an object, doing fallback of spl_object_hash() if not available.

Description

This can be eliminated in favor of straight spl_object_hash() when 5.3 is the minimum requirement for PHP.

Parameters

$widget

(WP_Widget) (Required) Widget.

Return

(string) Object hash.

Source

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

* @since 4.6.0 Updated the `$widget` parameter to also accept a WP_Widget instance object
	 *              instead of simply a `WP_Widget` subclass name.
	 *
	 * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass.
	 */
	public function unregister( $widget ) {
		if ( $widget instanceof WP_Widget ) {
			unset( $this->widgets[ spl_object_hash( $widget ) ] );
		} else {
			unset( $this->widgets[ $widget ] );
		}
	}

	/**
	 * Serves as a utility method for adding widgets to the registered widgets global.
	 *
	 * @since 2.8.0

Changelog

Version Description
4.6.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_widget_factory/hash_object