get_dirsize( string $directory )
Get the size of a directory.
描述
A helper function that is used primarily to check whether a blog has exceeded its allowed upload space.
参数
- $directory
-
(string)
(Required)
Full path of a directory.
返回值
(int) Size of the directory in MB.
源代码
File: wp-includes/ms-functions.php
function get_dirsize( $directory ) {
$dirsize = get_transient( 'dirsize_cache' );
if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) )
return $dirsize[ $directory ][ 'size' ];
if ( ! is_array( $dirsize ) )
$dirsize = array();
// Exclude individual site directories from the total when checking the main site,
// as they are subdirectories and should not be counted.
if ( is_main_site() ) {
$dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory, $directory . '/sites' );
} else {
$dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory );
}
set_transient( 'dirsize_cache', $dirsize, HOUR_IN_SECONDS );
return $dirsize[ $directory ][ 'size' ];
}
更新日志
Version | 描述 |
---|---|
MU | Introduced. |
相关函数
Uses
-
wp-includes/functions.php:
is_main_site() -
wp-includes/option.php:
get_transient() -
wp-includes/option.php:
set_transient() -
wp-includes/ms-functions.php:
recurse_dirsize()
Used By
-
wp-includes/ms-functions.php:
get_space_used()
你可能对这些文章感兴趣:
- wordpress函数get_the_title()用法示例
- wordpress函数get_the_posts_navigation()用法示例
- wordpress函数get_the_terms()用法示例
- wordpress函数get_the_tags()用法示例
- wordpress函数get_the_taxonomies()用法示例
- wordpress函数get_the_permalink()用法示例
- wordpress函数get_the_password_form()用法示例
- wordpress函数get_the_posts_pagination()用法示例
- wordpress函数get_the_modified_date()用法示例
- wordpress函数get_the_modified_time()用法示例
- wordpress函数get_the_modified_author()用法示例
- wordpress函数get_the_guid()用法示例
- wordpress函数get_the_ID()用法示例
- wordpress函数get_the_excerpt()用法示例
如有疑问,请前往问答中心反馈!
反馈