wp_is_uuid( mixed $uuid, int $version = null ): bool
- Since
- 4.9.0
- Source
wp-includes/functions.php:7962
Validates that a UUID is valid.
Parameters
$uuidmixed- UUID to check.
$versionintoptional- Specify which version of UUID to check against. Default is none, to accept any UUID version. Otherwise, only version allowed is
4.Default:null
Return
bool- The string is a valid UUID or false on failure.
Uses · 2
- _doing_it_wrong()Marks something as being incorrectly called.
- __()Retrieves the translation of $text.
Used by · 4
- WP_Customize_Manager::establish_loaded_changeset()Establishes the loaded changeset.
- WP_Customize_Manager::setup_theme()Starts preview and customize theme.
- rest_validate_value_from_schema()Validate a value based on a schema.
- wp_is_authorize_application_password_request_valid()Checks if the Authorize Application Password request is valid.
Source
function wp_is_uuid( $uuid, $version = null ) { if ( ! is_string( $uuid ) ) { return false; } if ( is_numeric( $version ) ) { if ( 4 !== (int) $version ) { _doing_it_wrong( __FUNCTION__, __( 'Only UUID V4 is supported at this time.' ), '4.9.0' ); return false; } $regex = '/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/'; } else { $regex = '/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/'; } return (bool) preg_match( $regex, $uuid );}History
Introduced in 4.9.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.8.8 tag, from
src/wp-includes/functions.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.