在仪表板上显示文件上载配额。

原型

wp_dashboard_quota()

描述

在wp_dashboard_right_now()中的’activity_box_end’挂钩上运行。

返回值

(bool|null)  如果不是多站点,则为真,用户无法上载文件,或禁用空格检查选项。

源文件

路径:wp-admin/includes/dashboard.php

<?php
...
function wp_dashboard_quota() {
	if ( !is_multisite() || !current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) )
		return true;
	$quota = get_space_allowed();
	$used = get_space_used();
	if ( $used > $quota )
		$percentused = '100';
	else
		$percentused = ( $used / $quota ) * 100;
	$used_class = ( $percentused >= 70 ) ? ' warning' : '';
	$used = round( $used, 2 );
	$percentused = number_format( $percentused );
	?>
	<h3 class="mu-storage"><?php _e( 'Storage Space' ); ?></h3>
	<div class="mu-storage">
	<ul>
		<li class="storage-count">
			<?php $text = sprintf(
				/* translators: %s: number of megabytes */
				__( '%s MB Space Allowed' ),
				number_format_i18n( $quota )
			);
			printf(
				'<a href="%1$s">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
				esc_url( admin_url( 'upload.php' ) ),
				$text,
				__( 'Manage Uploads' )
			); ?>
		</li><li class="storage-count <?php echo $used_class; ?>">
			<?php $text = sprintf(
				/* translators: 1: number of megabytes, 2: percentage */
				__( '%1$s MB (%2$s%%) Space Used' ),
				number_format_i18n( $used, 2 ),
				$percentused
			);
			printf(
				'<a href="%1$s" class="musublink">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
				esc_url( admin_url( 'upload.php' ) ),
				$text,
				__( 'Manage Uploads' )
			); ?>
		</li>
	</ul>
	</div>
	<?php
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/wp_dashboard_quota/