Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



clean_dirsize_cache ›

Seit5.6.0
Veraltetn/v
clean_dirsize_cache ( $path )
Parameter:
  • (string) $path Full path of a directory or file.
    Erforderlich: Ja
Definiert in:
Codex:

Cleans directory size cache used by recurse_dirsize().

Removes the current directory and all parent directories from the dirsize_cache transient.


Quellcode

function clean_dirsize_cache( $path ) {
	$directory_cache = get_transient( 'dirsize_cache' );

	if ( empty( $directory_cache ) ) {
		return;
	}

	$cache_path = untrailingslashit( str_replace( ABSPATH, '', $path ) );
	unset( $directory_cache[ $cache_path ] );

	while ( DIRECTORY_SEPARATOR !== $cache_path && '.' !== $cache_path && '..' !== $cache_path ) {
		$cache_path = dirname( $cache_path );
		unset( $directory_cache[ $cache_path ] );
	}

	set_transient( 'dirsize_cache', $directory_cache );
}