函数文档

wpmu_checkAvailableSpace()

💡 云策文档标注

概述

wpmu_checkAvailableSpace() 是一个已弃用的 WordPress 函数,用于检查用户是否超过了管理员定义的可用上传空间。它已被 is_upload_space_available() 替代,并在空间不足时显示错误消息。

关键要点

  • 函数 wpmu_checkAvailableSpace() 自 WordPress 3.0.0 起已弃用,建议使用 is_upload_space_available() 替代。
  • 该函数调用 is_upload_space_available() 检查上传空间,如果空间不足,则通过 wp_die() 显示错误消息。
  • 错误消息使用 __() 进行本地化,并调用 size_format() 和 get_space_allowed() 来格式化空间配额。

代码示例

function wpmu_checkAvailableSpace() {
	_deprecated_function( __FUNCTION__, '3.0.0', 'is_upload_space_available()' );

	if ( ! is_upload_space_available() ) {
		wp_die( sprintf(
			/* translators: %s: Allowed space allocation. */
			__( 'Sorry, you have used your space allocation of %s. Please delete some files to upload more files.' ),
			size_format( get_space_allowed() * MB_IN_BYTES )
		) );
	}
}

注意事项

  • 由于该函数已弃用,开发者应避免在新代码中使用,并迁移到 is_upload_space_available()。
  • 函数内部使用 _deprecated_function() 标记弃用,调用时会触发相关通知。

📄 原文内容

Determines if the available space defined by the admin has been exceeded by the user.

Description

See also

Source

function wpmu_checkAvailableSpace() {
	_deprecated_function( __FUNCTION__, '3.0.0', 'is_upload_space_available()' );

	if ( ! is_upload_space_available() ) {
		wp_die( sprintf(
			/* translators: %s: Allowed space allocation. */
			__( 'Sorry, you have used your space allocation of %s. Please delete some files to upload more files.' ),
			size_format( get_space_allowed() * MB_IN_BYTES )
		) );
	}
}

Changelog

Version Description
3.0.0 Introduced.