clean_dirsize_cache( string $path )

Cleans directory size cache used by recurse_dirsize().

Description

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

Parameters

$path

(string) (Required) Full path of a directory or file.

Source

File: wp-includes/functions.php

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

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

	$path = untrailingslashit( $path );
	unset( $directory_cache[ $path ] );

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

	set_transient( 'dirsize_cache', $directory_cache );
}

Changelog

Version Description
5.6.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/clean_dirsize_cache