Fix get unique ID function
This commit is contained in:
@@ -1306,3 +1306,26 @@ function opalestate_clean( $var ) {
|
||||
return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 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.
|
||||
*
|
||||
* @see wp_unique_id() Themes requiring WordPress 5.0.3 and greater should use this instead.
|
||||
*
|
||||
* @staticvar int $id_counter
|
||||
*
|
||||
* @param string $prefix Prefix for the returned ID.
|
||||
* @return string Unique ID.
|
||||
*/
|
||||
function opalestate_unique_id( $prefix = '' ) {
|
||||
static $id_counter = 0;
|
||||
if ( function_exists( 'wp_unique_id' ) ) {
|
||||
return wp_unique_id( $prefix );
|
||||
}
|
||||
return $prefix . (string) ++$id_counter;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user