On this page
upload_is_user_over_quota( bool $display_message = true ): bool
Check whether a site has used its allotted upload space.
Parameters
$display_messagebool Optional-
If set to true and the quota is exceeded, a warning message is displayed.
Default:
true
Return
bool True if user is over upload space quota, otherwise false.
Source
File: wp-admin/includes/ms.php. View all references
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;
}
}
Related
Uses
| Uses | Description |
|---|---|
| size_format() wp-includes/functions.php | Converts a number of bytes to the largest unit the bytes will fit into. |
| get_space_allowed() wp-includes/ms-functions.php | Returns the upload quota for the current blog. |
| get_space_used() wp-includes/ms-functions.php | Returns the space used by the current site. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
| get_site_option() wp-includes/option.php | Retrieve an option value for the current network based on name of option. |
Used By
| Used By | Description |
|---|---|
| WP_REST_Attachments_Controller::check_upload_size() wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php | Determine if uploaded file exceeds space quota on multisite. |
| fix_import_form_size() wp-admin/includes/ms.php | Get the remaining upload space for this site. |
| check_upload_size() wp-admin/includes/ms.php | Determine if uploaded file exceeds space quota. |
| WP_Importer::is_user_over_quota() wp-admin/includes/class-wp-importer.php | Check if user has exceeded disk quota |
| wp_xmlrpc_server::mw_newMediaObject() wp-includes/class-wp-xmlrpc-server.php | Uploads a file, following your settings. |
Changelog
| Version | Description |
|---|---|
| MU (3.0.0) | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/upload_is_user_over_quota