Alert: 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.

WP_Widget_Factory::hash_object( WP_Widget $widget )

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


Description Description

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


Top ↑

Parameters Parameters

$widget

(WP_Widget) (Required) Widget.


Top ↑

Return Return

(string) Object hash.


Top ↑

Source 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

Top ↑

Changelog Changelog

Changelog
Version Description
4.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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