WordPress.org

Make WordPress Core

Ticket #21181: 21181.3.patch

File 21181.3.patch, 2.1 KB (added by SergeyBiryukov, 6 years ago)
  • wp-admin/includes/ms.php

     
    302302/**
    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 */
    307309function get_upload_space_available() {
     
    331333
    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.' );
    341343                return true;
     
    344346        }
    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;
    354363}
     
    356365/**
    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() {
    362373        $space_allowed = get_option( 'blog_upload_space' );
     
    370381        return $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();
    375391        $space_used = get_space_used();
     
    406422                return 0;
    407423
    408424        $available = get_upload_space_available();
    409         return min( $size, $available);
     425        return min( $size, $available );
    410426}
    411427
    412428// Edit blog upload space setting on Edit Blog page