get_dirsize

函数


get_dirsize ( $directory, $max_execution_time = null )
参数
  • (string)
    $directory
    Full path of a directory.
    Required:
  • (int)
    $max_execution_time
    Maximum time to run before giving up. In seconds. The timeout is global and is measured from the moment WordPress started to load.
    Required:
    Default: null
返回值
  • (int|false|null) Size in bytes if a valid directory. False if not. Null if timeout.
定义位置
  • wp-includes/functions.php
    , line 8201
引入
弃用

Gets the size of a directory.

A helper function that is used primarily to check whether
a blog has exceeded its allowed upload space.

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