diff --git a/src/wp-includes/class-wp-widget-factory.php b/src/wp-includes/class-wp-widget-factory.php index 68f4623098..ec5a96d6a9 100644 --- a/src/wp-includes/class-wp-widget-factory.php +++ b/src/wp-includes/class-wp-widget-factory.php @@ -55,35 +55,6 @@ class WP_Widget_Factory { */ private $hashed_class_counts = array(); - /** - * Hashes an object, doing fallback of `spl_object_hash()` if not available. - * - * This can be eliminated in favor of straight spl_object_hash() when 5.3 - * is the minimum requirement for PHP. - * - * @since 4.6.0 - * - * @param WP_Widget $widget Widget. - * @return string Object hash. - */ - private function hash_object( $widget ) { - if ( function_exists( 'spl_object_hash' ) ) { - return spl_object_hash( $widget ); - } else { - $class_name = get_class( $widget ); - $hash = $class_name; - if ( ! isset( $widget->_wp_widget_factory_hash_id ) ) { - if ( ! isset( $this->hashed_class_counts[ $class_name ] ) ) { - $this->hashed_class_counts[ $class_name ] = 0; - } - $this->hashed_class_counts[ $class_name ] += 1; - $widget->_wp_widget_factory_hash_id = $this->hashed_class_counts[ $class_name ]; - } - $hash .= ':' . $widget->_wp_widget_factory_hash_id; - return $hash; - } - } - /** * Registers a widget subclass. * @@ -95,7 +66,7 @@ class WP_Widget_Factory { */ public function register( $widget ) { if ( $widget instanceof WP_Widget ) { - $this->widgets[ $this->hash_object( $widget ) ] = $widget; + $this->widgets[ spl_object_hash( $widget ) ] = $widget; } else { $this->widgets[ $widget ] = new $widget(); } @@ -112,7 +83,7 @@ class WP_Widget_Factory { */ public function unregister( $widget ) { if ( $widget instanceof WP_Widget ) { - unset( $this->widgets[ $this->hash_object( $widget ) ] ); + unset( $this->widgets[ spl_object_hash( $widget ) ] ); } else { unset( $this->widgets[ $widget ] ); } diff --git a/src/wp-includes/plugin.php b/src/wp-includes/plugin.php index 1f6cacd5b4..c83ebdb81f 100644 --- a/src/wp-includes/plugin.php +++ b/src/wp-includes/plugin.php @@ -925,23 +925,7 @@ function _wp_filter_build_unique_id( $tag, $function, $priority ) { if ( is_object( $function[0] ) ) { // Object Class Calling - if ( function_exists( 'spl_object_hash' ) ) { - return spl_object_hash( $function[0] ) . $function[1]; - } else { - $obj_idx = get_class( $function[0] ) . $function[1]; - if ( ! isset( $function[0]->wp_filter_id ) ) { - if ( false === $priority ) { - return false; - } - $obj_idx .= isset( $wp_filter[ $tag ][ $priority ] ) ? count( (array) $wp_filter[ $tag ][ $priority ] ) : $filter_id_count; - $function[0]->wp_filter_id = $filter_id_count; - ++$filter_id_count; - } else { - $obj_idx .= $function[0]->wp_filter_id; - } - - return $obj_idx; - } + return spl_object_hash( $function[0] ) . $function[1]; } elseif ( is_string( $function[0] ) ) { // Static Calling return $function[0] . '::' . $function[1];