WP_CLI::wp_hook_build_unique_id()private staticWP-CLI 1.0

Build Unique ID for storage and retrieval.

Essentially _wp_filter_build_unique_id() without needing access to _wp_filter_build_unique_id()

Метод класса: WP_CLI{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = WP_CLI::wp_hook_build_unique_id( $tag, $function, $priority );
$tag (обязательный)
-
$function (обязательный)
-
$priority (обязательный)
-

Код WP_CLI::wp_hook_build_unique_id() WP-CLI 2.8.0-alpha

private static function wp_hook_build_unique_id( $tag, $function, $priority ) {
	global $wp_filter;
	static $filter_id_count = 0;

	if ( is_string( $function ) ) {
		return $function;
	}

	if ( is_object( $function ) ) {
		// Closures are currently implemented as objects
		$function = [ $function, '' ];
	} else {
		$function = (array) $function;
	}

	if ( is_object( $function[0] ) ) {
		// Object Class Calling
		if ( function_exists( 'spl_object_hash' ) ) {
			return spl_object_hash( $function[0] ) . $function[1];
		}

		$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;
	}

	if ( is_string( $function[0] ) ) {
		// Static Calling
		return $function[0] . '::' . $function[1];
	}
}