wp_unique_id()WP 5.0.3

Gets unique ID.

This is a PHP implementation of Underscore's uniqueId method. A static variable contains an integer that is incremented with each call. This number is returned with the optional prefix. As such the returned value is not universally unique, but it is unique across the life of the PHP process.

Хуков нет.

Возвращает

Строку. Unique ID.

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

wp_unique_id( $prefix );
$prefix(строка)
Prefix for the returned ID.
По умолчанию: ''

Список изменений

С версии 5.0.3 Введена.

Код wp_unique_id() WP 6.4.3

function wp_unique_id( $prefix = '' ) {
	static $id_counter = 0;
	return $prefix . (string) ++$id_counter;
}