
网络开发中的Git:了解一个项目的典型工作流程
clean_dirsize_cache ( $path )
clean_dirsize_cache: 这个函数清除了目录大小的缓存: 当这个函数被调用时,它清除了服务器上文件和文件夹的目录大小的缓存。
清理recurse_dirsize()使用的目录大小缓存。
从`dirsize_cache`暂存器中删除当前目录和所有父目录。
function clean_dirsize_cache( $path ) { if ( ! is_string( $path ) || empty( $path ) ) { trigger_error( sprintf( /* translators: 1: Function name, 2: A variable type, like "boolean" or "integer". */ __( '%1$s only accepts a non-empty path string, received %2$s.' ), '<code>clean_dirsize_cache()</code>', '<code>' . gettype( $path ) . '</code>' ) ); return; } $directory_cache = get_transient( 'dirsize_cache' ); if ( empty( $directory_cache ) ) { return; } if ( strpos( $path, '/' ) === false && strpos( $path, '\' ) === false ) { unset( $directory_cache[ $path ] ); set_transient( 'dirsize_cache', $directory_cache ); return; } $last_path = null; $path = untrailingslashit( $path ); unset( $directory_cache[ $path ] ); while ( $last_path !== $path && DIRECTORY_SEPARATOR !== $path && '.' !== $path && '..' !== $path ) { $last_path = $path; $path = dirname( $path ); unset( $directory_cache[ $path ] ); } set_transient( 'dirsize_cache', $directory_cache ); }