get_dirsize() - WordPress 函数参考中文文档

返回介绍

get_dirsize()

发布于 2017-09-10 字数1984 浏览 973 评论 0

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()

User Contributed Notes

上一篇:get_delete_post_link()

下一篇:get_dropins()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!