WP_Object_Cache::is_valid_key
Serves as a utility function to determine whether a key is valid.
Метод класса: WP_Object_Cache{}
Хуков нет.
Возвращает
true|false. Whether the key is valid.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->is_valid_key( $key );
- $key(int|строка) (обязательный)
- Cache key to check for validity.
Список изменений
| С версии 6.1.0 | Введена. |
Код WP_Object_Cache::is_valid_key() WP Object Cache::is valid key WP 7.0
protected function is_valid_key( $key ) {
if ( is_int( $key ) ) {
return true;
}
if ( is_string( $key ) && trim( $key ) !== '' ) {
return true;
}
$type = gettype( $key );
if ( ! function_exists( '__' ) ) {
wp_load_translations_early();
}
$message = is_string( $key )
? __( 'Cache key must not be an empty string.' )
/* translators: %s: The type of the given cache key. */
: sprintf( __( 'Cache key must be an integer or a non-empty string, %s given.' ), $type );
_doing_it_wrong(
sprintf( '%s::%s', __CLASS__, debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 2 )[1]['function'] ),
$message,
'6.1.0'
);
return false;
}