Changeset 56994 for trunk/src/wp-includes/functions.php
- Timestamp:
- 10/24/2023 08:49:38 AM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r56809 r56994 7832 7832 7833 7833 /** 7834 * Generates an incremental ID that is independent per each different prefix. 7835 * 7836 * It is similar to `wp_unique_id`, but each prefix has its own internal ID 7837 * counter to make each prefix independent from each other. The ID starts at 1 7838 * and increments on each call. The returned value is not universally unique, 7839 * but it is unique across the life of the PHP process and it's stable per 7840 * prefix. 7841 * 7842 * @since 6.4.0 7843 * 7844 * @param string $prefix Optional. Prefix for the returned ID. Default empty string. 7845 * @return string Incremental ID per prefix. 7846 */ 7847 function wp_unique_prefixed_id( $prefix = '' ) { 7848 static $id_counters = array(); 7849 7850 if ( ! is_string( $prefix ) ) { 7851 wp_trigger_error( 7852 __FUNCTION__, 7853 sprintf( 'The prefix must be a string. "%s" data type given.', gettype( $prefix ) ) 7854 ); 7855 $prefix = ''; 7856 } 7857 7858 if ( ! isset( $id_counters[ $prefix ] ) ) { 7859 $id_counters[ $prefix ] = 0; 7860 } 7861 7862 $id = ++$id_counters[ $prefix ]; 7863 7864 return $prefix . (string) $id; 7865 } 7866 7867 /** 7834 7868 * Gets last changed date for the specified cache group. 7835 7869 *
Note: See TracChangeset
for help on using the changeset viewer.