Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions src/wp-includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7990,20 +7990,34 @@ function wp_raise_memory_limit( $context = 'admin' ) {
* Generates a random UUID (version 4).
*
* @since 4.7.0
* @since 7.0.0 Uses wp_rand if available.
*
* @return string UUID.
*/
function wp_generate_uuid4() {
Comment thread
aaronjorbin marked this conversation as resolved.
static $backup_randomizer = false;
$randomizer = function_exists( 'wp_rand' ) ? 'wp_rand' : $backup_randomizer;

if ( false === $randomizer ) {
try {
random_int( 0, 15705 );
$backup_randomizer = 'random_int';
} catch ( Exception $e ) {
$backup_randomizer = 'mt_rand';
}
$randomizer = $backup_randomizer;
}

return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
mt_rand( 0, 0xffff ),
mt_rand( 0, 0xffff ),
mt_rand( 0, 0xffff ),
mt_rand( 0, 0x0fff ) | 0x4000,
mt_rand( 0, 0x3fff ) | 0x8000,
mt_rand( 0, 0xffff ),
mt_rand( 0, 0xffff ),
mt_rand( 0, 0xffff )
$randomizer( 0, 0xffff ),
$randomizer( 0, 0xffff ),
$randomizer( 0, 0xffff ),
$randomizer( 0, 0x0fff ) | 0x4000,
$randomizer( 0, 0x3fff ) | 0x8000,
$randomizer( 0, 0xffff ),
$randomizer( 0, 0xffff ),
$randomizer( 0, 0xffff )
);
}

Expand Down
Loading