WPSEO_Sitemaps_Cache_Validator::cleanup_database()
Cleanup invalidated database cache.
Метод класса: WPSEO_Sitemaps_Cache_Validator{}
Хуков нет.
Возвращает
null
. Ничего.
Использование
$result = WPSEO_Sitemaps_Cache_Validator::cleanup_database( $type, $validator );
- $type(строка|null)
- The type of sitemap to clear cache for.
По умолчанию: null - $validator(строка|null)
- The validator to clear cache of.
По умолчанию: null
Список изменений
С версии 3.2 | Введена. |
Код WPSEO_Sitemaps_Cache_Validator::cleanup_database() WPSEO Sitemaps Cache Validator::cleanup database Yoast 20.3
public static function cleanup_database( $type = null, $validator = null ) { global $wpdb; if ( is_null( $type ) ) { // Clear all cache if no type is provided. $like = sprintf( '%s%%', self::STORAGE_KEY_PREFIX ); } else { // Clear type cache for all type keys. $like = sprintf( '%1$s%2$s_%%', self::STORAGE_KEY_PREFIX, $type ); } /* * Add slashes to the LIKE "_" single character wildcard. * * We can't use `esc_like` here because we need the % in the query. */ $where = []; $where[] = sprintf( "option_name LIKE '%s'", addcslashes( '_transient_' . $like, '_' ) ); $where[] = sprintf( "option_name LIKE '%s'", addcslashes( '_transient_timeout_' . $like, '_' ) ); // Delete transients. $query = sprintf( 'DELETE FROM %1$s WHERE %2$s', $wpdb->options, implode( ' OR ', $where ) ); $wpdb->query( $query ); wp_cache_delete( 'alloptions', 'options' ); }