get_dirsize( string $directory )
Get the size of a directory.
Description
A helper function that is used primarily to check whether a blog has exceeded its allowed upload space.
Parameters
- $directory
-
(Required) Full path of a directory.
Return
(int) Size of the directory in MB.
Source
File: wp-includes/ms-functions.php
function get_dirsize( $directory ) {
$dirsize = get_transient( 'dirsize_cache' );
if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) )
return $dirsize[ $directory ][ 'size' ];
if ( ! is_array( $dirsize ) )
$dirsize = array();
// Exclude individual site directories from the total when checking the main site,
// as they are subdirectories and should not be counted.
if ( is_main_site() ) {
$dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory, $directory . '/sites' );
} else {
$dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory );
}
set_transient( 'dirsize_cache', $dirsize, HOUR_IN_SECONDS );
return $dirsize[ $directory ][ 'size' ];
}
Changelog
Version | Description |
---|---|
WP-MU | Introduced. (3.0.0) |