Tribe__Cache::make_key( mixed $components, string $prefix = '', bool $sort = true )
Builds a key from an array of components and an optional prefix.
Contents
Parameters
- $components
-
(mixed) (Required) Either a single component of the key or an array of key components.
- $prefix
-
(string) (Optional)
Default value: ''
- $sort
-
(bool) (Optional) Whether component arrays should be sorted or not to generate the key; defaults to
true.Default value: true
Return
(string) The resulting key.
Source
File: src/Tribe/Cache.php
public function make_key( $components, $prefix = '', $sort = true ) {
$key = '';
$components = is_array( $components ) ? $components : array( $components );
foreach ( $components as $component ) {
if ( $sort && is_array( $component ) ) {
$is_associative = count( array_filter( array_keys( $component ), 'is_numeric' ) ) < count( array_keys( $component ) );
if ( $is_associative ) {
ksort( $component );
} else {
sort( $component );
}
}
$key .= maybe_serialize( $component );
}
return $this->get_id( $prefix . md5( $key ) );
}