wp_cache_clean_legacy_files()
No Hooks.
Return
null
. Nothing (null).
Usage
wp_cache_clean_legacy_files( $dir, $file_prefix );
- $dir (required)
- -
- $file_prefix (required)
- -
wp_cache_clean_legacy_files() wp cache clean legacy files code WPSCache 1.12.4
function wp_cache_clean_legacy_files( $dir, $file_prefix ) { global $wpdb; $dir = trailingslashit( $dir ); if ( @is_dir( $dir . 'meta' ) == false ) return false; if ( $handle = @opendir( $dir ) ) { $curr_blog_id = is_multisite() ? get_current_blog_id() : false; while ( false !== ( $file = readdir( $handle ) ) ) { if ( is_file( $dir . $file ) == false || $file == 'index.html' ) { continue; } if ( str_contains( $file, $file_prefix ) ) { if ( strpos( $file, '.html' ) ) { // delete old WPCache files immediately @unlink( $dir . $file); @unlink( $dir . 'meta/' . str_replace( '.html', '.meta', $file ) ); } else { $meta = json_decode( wp_cache_get_legacy_cache( $dir . 'meta/' . $file ), true ); if ( $curr_blog_id && $curr_blog_id !== (int) $meta['blog_id'] ) { continue; } @unlink( $dir . $file); @unlink( $dir . 'meta/' . $file); } } } closedir($handle); } }