get_space_used()获取当前博客的空间使用量

目录

描述

Returns the space used by the current blog.

get_space_used() 描述

用法

 <?php $used get_space_used()  ?> 

get_space_used() 用法

示例

Default Usage

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
 <?php
	$quota = get_space_allowed();
	$used = get_space_used();

	if ( $used > $quota ){
	   // do something they have used more than quota
	}
?>

get_space_used() 示例

历史

  • 添加于 版本: 3.5.0

get_space_used() 历史

源文件

get_space_used 函数的代码位于 wp-includes/ms-functions.php

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Returns the space used by the current blog.
 *
 * @since 3.5.0
 *
 * @return int Used space in megabytes
 */
function get_space_used() {
	/**
	 * Filter the amount of storage space used by the current site.
	 *
	 * @since 3.5.0
	 *
	 * @param int|bool $space_used The amount of used space, in megabytes. Default false.
	 */
	$space_used = apply_filters( 'pre_get_space_used', false );
	if ( false === $space_used ) {
		$upload_dir = wp_upload_dir();
		$space_used = get_dirsize( $upload_dir['basedir'] ) / 1024 / 1024;
	}

	return $space_used;
}

get_space_used() 源文件