WordPress.org

Make WordPress Core

Changeset 21474


Ignore:
Timestamp:
08/08/2012 07:17:33 AM (7 years ago)
Author:
westi
Message:

Multisite: Fix the new get_space_used() function to correctly calculate Megabytes used and update some phpdoc. Props SergeyBiryukov.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/ms.php

    r21414 r21474  
    303303 * Determines if there is any upload space left in the current blog's quota.
    304304 *
     305 * @since 3.0.0
     306 *
    305307 * @return int of upload space available in bytes
    306308 */
     
    332334    $space_allowed = get_space_allowed();
    333335    if ( empty( $space_allowed ) || !is_numeric( $space_allowed ) )
    334         $space_allowed = 10;// Default space allowed is 10 MB
     336        $space_allowed = 10; // Default space allowed is 10 MB
    335337
    336338    $space_used = get_space_used();
    337339
    338     if ( ($space_allowed - $space_used ) < 0 ) {
     340    if ( ( $space_allowed - $space_used ) < 0 ) {
    339341        if ( $echo )
    340342            _e( 'Sorry, you have used your space allocation. Please delete some files to upload more files.' );
     
    345347}
    346348
     349/**
     350 * Returns the space used by the current blog.
     351 *
     352 * @since 3.5.0
     353 *
     354 * @return int Used space in megabytes
     355 */
    347356function get_space_used() {
    348357    // Allow for an alternative way of tracking storage space used
    349358    $space_used = apply_filters( 'pre_get_space_used', false );
    350359    if ( false === $space_used )
    351         $space_used = get_dirsize( BLOGUPLOADDIR );
     360        $space_used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;
    352361
    353362    return $space_used;
     
    357366 * Returns the upload quota for the current blog.
    358367 *
    359  * @return int Quota
     368 * @since MU
     369 *
     370 * @return int Quota in megabytes
    360371 */
    361372function get_space_allowed() {
     
    371382}
    372383
     384/**
     385 * Displays the amount of disk space used by the current blog. Not used in core.
     386 *
     387 * @since MU
     388 */
    373389function display_space_usage() {
    374390    $space_allowed = get_space_allowed();
     
    407423
    408424    $available = get_upload_space_available();
    409     return min( $size, $available);
     425    return min( $size, $available );
    410426}
    411427
Note: See TracChangeset for help on using the changeset viewer.