wp_clean_update_cache()
云策文档标注
概述
wp_clean_update_cache() 函数用于清除 WordPress 中插件、主题和核心的现有更新缓存,确保获取最新的更新信息。
关键要点
- 清除插件更新缓存:通过 wp_clean_plugins_cache() 或 delete_site_transient('update_plugins') 实现。
- 清除主题更新缓存:调用 wp_clean_themes_cache() 函数。
- 清除核心更新缓存:使用 delete_site_transient('update_core') 删除站点瞬态。
- 相关函数:包括 wp_clean_plugins_cache()、wp_clean_themes_cache() 和 delete_site_transient(),用于具体缓存清理操作。
- 使用场景:由 WP_Automatic_Updater::run() 和 Language_Pack_Upgrader::bulk_upgrade() 等函数调用,支持自动更新和语言包升级过程。
- 版本历史:自 WordPress 4.1.0 版本引入。
代码示例
function wp_clean_update_cache() {
if ( function_exists( 'wp_clean_plugins_cache' ) ) {
wp_clean_plugins_cache();
} else {
delete_site_transient( 'update_plugins' );
}
wp_clean_themes_cache();
delete_site_transient( 'update_core' );
}
原文内容
Clears existing update caches for plugins, themes, and core.
Source
function wp_clean_update_cache() {
if ( function_exists( 'wp_clean_plugins_cache' ) ) {
wp_clean_plugins_cache();
} else {
delete_site_transient( 'update_plugins' );
}
wp_clean_themes_cache();
delete_site_transient( 'update_core' );
}
Changelog
| Version | Description |
|---|---|
| 4.1.0 | Introduced. |