WPSEO_Sitemaps_Cache_Validator::get_storage_key()
Get the cache key for a certain type and page.
A type of cache would be something like 'page', 'post' or 'video'.
Example key format for sitemap type "post", page 1: wpseo_sitemap_post_1:akfw3e_23azBa .
Метод класса: WPSEO_Sitemaps_Cache_Validator{}
Хуков нет.
Возвращает
true|false|Строку
. The key where the cache is stored on. False if the key could not be generated.
Использование
$result = WPSEO_Sitemaps_Cache_Validator::get_storage_key( $type, $page );
- $type(строка|null)
- The type to get the key for. Null or self::SITEMAP_INDEX_TYPE for index cache.
По умолчанию: null - $page(int)
- The page of cache to get the key for.
По умолчанию: 1
Список изменений
С версии 3.2 | Введена. |
Код WPSEO_Sitemaps_Cache_Validator::get_storage_key() WPSEO Sitemaps Cache Validator::get storage key Yoast 24.9
public static function get_storage_key( $type = null, $page = 1 ) { // Using SITEMAP_INDEX_TYPE for sitemap index cache. $type = ( $type === null ) ? WPSEO_Sitemaps::SITEMAP_INDEX_TYPE : $type; $global_cache_validator = self::get_validator(); $type_cache_validator = self::get_validator( $type ); $prefix = self::STORAGE_KEY_PREFIX; $postfix = sprintf( '_%d:%s_%s', $page, $global_cache_validator, $type_cache_validator ); try { $type = self::truncate_type( $type, $prefix, $postfix ); } catch ( OutOfBoundsException $exception ) { // Maybe do something with the exception, for now just mark as invalid. return false; } // Build key. $full_key = $prefix . $type . $postfix; return $full_key; }