multisite_over_quota_message()
云策文档标注
概述
multisite_over_quota_message() 函数用于在 WordPress 多站点网络中显示存储配额已满的消息。它通过 sprintf 和 __() 函数生成本地化提示,并调用 size_format() 和 get_space_allowed() 来格式化配额信息。
关键要点
- 函数 multisite_over_quota_message() 在 WordPress 3.5.0 版本中引入,专门用于多站点环境。
- 它输出一个提示消息,告知用户已使用完分配的存储空间,并建议删除文件以继续上传。
- 函数内部使用 sprintf 和 __() 实现本地化,确保消息可根据语言设置翻译。
- 通过 get_space_allowed() 获取当前博客的上传配额,并使用 size_format() 将字节数转换为易读的单位(如 MB、GB)。
- 相关函数包括 size_format()、get_space_allowed() 和 __(),分别用于格式化大小、获取配额和翻译文本。
代码示例
function multisite_over_quota_message() {
echo '' . 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 )
) . '';
}
原文内容
Displays the out of storage quota message in Multisite.
Source
function multisite_over_quota_message() {
echo '<p>' . 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 )
) . '</p>';
}
Changelog
| Version | Description |
|---|---|
| 3.5.0 | Introduced. |