wp_cache_clean_expired()
No Hooks.
Return
null
. Nothing (null).
Usage
wp_cache_clean_expired( $file_prefix );
- $file_prefix (required)
- -
wp_cache_clean_expired() wp cache clean expired code WPSCache 1.12.4
function wp_cache_clean_expired($file_prefix) { global $cache_max_time, $blog_cache_dir, $wp_cache_preload_on; if ( $cache_max_time == 0 ) { return false; } // If phase2 was compiled, use its function to avoid race-conditions if(function_exists('wp_cache_phase2_clean_expired')) { if ( $wp_cache_preload_on != 1 && function_exists ('prune_super_cache')) { $dir = get_supercache_dir(); if( is_dir( $dir ) ) { prune_super_cache( $dir ); } elseif( is_dir( $dir . '.disabled' ) ) { prune_super_cache( $dir . '.disabled' ); } $_POST[ 'super_cache_stats' ] = 1; // regenerate super cache stats; } return wp_cache_phase2_clean_expired($file_prefix); } $now = time(); if ( $handle = @opendir( $blog_cache_dir ) ) { while ( false !== ( $file = readdir( $handle ) ) ) { if ( str_contains( $file, $file_prefix ) ) { if ( strpos( $file, '.html' ) ) { @unlink( $blog_cache_dir . $file); @unlink( $blog_cache_dir . 'meta/' . str_replace( '.html', '.meta', $file ) ); } elseif ( ( filemtime( $blog_cache_dir . $file ) + $cache_max_time ) <= $now ) { @unlink( $blog_cache_dir . $file ); @unlink( $blog_cache_dir . 'meta/' . $file ); } } } closedir($handle); } }