On this page
get_dirsize( string $directory, int $max_execution_time = null ): int|false|null
Gets 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
$directorystring Required-
Full path of a directory.
$max_execution_timeint Optional-
Maximum time to run before giving up. In seconds.
The timeout is global and is measured from the moment WordPress started to load.Default:
null
Return
int|false|null Size in bytes if a valid directory. False if not. Null if timeout.
Source
File: wp-includes/functions.php. View all references
function get_dirsize( $directory, $max_execution_time = null ) {
// Exclude individual site directories from the total when checking the main site of a network,
// as they are subdirectories and should not be counted.
if ( is_multisite() && is_main_site() ) {
$size = recurse_dirsize( $directory, $directory . '/sites', $max_execution_time );
} else {
$size = recurse_dirsize( $directory, null, $max_execution_time );
}
return $size;
}
Related
Uses
| Uses | Description |
|---|---|
| recurse_dirsize() wp-includes/functions.php | Gets the size of a directory recursively. |
| is_main_site() wp-includes/functions.php | Determines whether a site is the main site of the current network. |
| is_multisite() wp-includes/load.php | If Multisite is enabled. |
Used By
| Used By | Description |
|---|---|
| get_space_used() wp-includes/ms-functions.php | Returns the space used by the current site. |
Changelog
| Version | Description |
|---|---|
| MU (3.0.0) | MU (3.0.0) |
| 5.2.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_dirsize