upload_is_user_over_quota

函数
upload_is_user_over_quota ( $display_message = true )
参数
  • (bool) $display_message Optional. If set to true and the quota is exceeded, a warning message is displayed. Default true.
    Required:
    Default: true
返回值
  • (bool) True if user is over upload space quota, otherwise false.
定义位置
相关方法
multisite_over_quota_messageupdate_user_metaadd_user_metawp_send_user_requestwp_fix_server_vars
引入
-
弃用
-

upload_is_user_over_quota: 这个函数检查用户是否超过了他们上传媒体文件的配额。

检查一个网站是否已经使用了分配的上传空间。

function upload_is_user_over_quota( $display_message = true ) {
	if ( get_site_option( 'upload_space_check_disabled' ) ) {
		return false;
	}

	$space_allowed = get_space_allowed();
	if ( ! is_numeric( $space_allowed ) ) {
		$space_allowed = 10; // Default space allowed is 10 MB.
	}
	$space_used = get_space_used();

	if ( ( $space_allowed - $space_used ) < 0 ) {
		if ( $display_message ) {
			printf(
				/* translators: %s: Allowed space allocation. */
				__( 'Sorry, you have used your space allocation of %s. Please delete some files to upload more files.' ),
				size_format( $space_allowed * MB_IN_BYTES )
			);
		}
		return true;
	} else {
		return false;
	}
}

常见问题

FAQs
查看更多 >