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.
定义位置
相关方法
get_siteimage_resizeget_sitesget_udimsrecurse_dirsize
引入
-
弃用
-

get_dirsize: 这个函数返回一个目录的大小,单位是字节。它把目录的路径作为唯一的参数并返回相应的大小。

获取一个目录的大小。

一个辅助函数,主要用于检查一个博客是否超过了允许的上传空间。

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

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2026-03-15 18:37:25

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: