On this page
get_space_used(): int
Returns the space used by the current site.
Return
int Used space in megabytes.
Source
File: wp-includes/ms-functions.php. View all references
function get_space_used() {
/**
* Filters the amount of storage space used by the current site, in megabytes.
*
* @since 3.5.0
*
* @param int|false $space_used The amount of used space, in megabytes. Default false.
*/
$space_used = apply_filters( 'pre_get_space_used', false );
if ( false === $space_used ) {
$upload_dir = wp_upload_dir();
$space_used = get_dirsize( $upload_dir['basedir'] ) / MB_IN_BYTES;
}
return $space_used;
}
Hooks
- apply_filters( 'pre_get_space_used',
int|false $space_used ) -
Filters the amount of storage space used by the current site, in megabytes.
Related
Uses
| Uses | Description |
|---|---|
| wp_upload_dir() wp-includes/functions.php | Returns an array containing the current upload directory’s path and URL. |
| get_dirsize() wp-includes/functions.php | Gets the size of a directory. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| upload_is_user_over_quota() wp-admin/includes/ms.php | Check whether a site has used its allotted upload space. |
| display_space_usage() wp-admin/includes/ms.php | Displays the amount of disk space used by the current site. Not used in core. |
| wp_dashboard_quota() wp-admin/includes/dashboard.php | Displays file upload quota on dashboard. |
| get_upload_space_available() wp-includes/ms-functions.php | Determines if there is any upload space left in the current blog’s quota. |
Changelog
| Version | Description |
|---|---|
| 3.5.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_space_used