get_dirsize() WordPress Function

The get_dirsize() WordPress function is used to get the size of a specified directory. This function returns the size in bytes, or false on failure.

get_dirsize( string $directory, int $max_execution_time = null ) #

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.


Top ↑

Parameters

$directory

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

$max_execution_time

(int)(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 value: null


Top ↑

Return

(int|false|null) Size in bytes if a valid directory. False if not. Null if timeout.


Top ↑

Source

File: wp-includes/functions.php

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;
}


Top ↑

Changelog

Changelog
VersionDescription
MU (3.0.0)MU (3.0.0)
5.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More