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: 這個函式返回一個目錄的大小,單位是位元組。它把目錄的路徑作為唯一的引數並返回相應的大小。

獲取一個目錄的大小。

一個輔助函式,主要用於檢查一個部落格是否超過了允許的上傳空間。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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
檢視更多 >