Make WordPress Core


Ignore:
Timestamp:
11/09/2012 10:35:42 AM (14 years ago)
Author:
westi
Message:

Multisite: Move all the functions which calculate upload space usage to wp-includes so they apply correctly with front-end editors.

Fixes #22357 props wonderboymusic.

File:
1 edited

Legend:

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

    r22378 r22497  
    291291
    292292/**
    293  * @since 3.0.0
    294  *
    295  * @return int of upload size limit in bytes
    296  */
    297 function upload_size_limit_filter( $size ) {
    298         $fileupload_maxk = 1024 * get_site_option( 'fileupload_maxk', 1500 );
    299         if ( get_site_option( 'upload_space_check_disabled' ) )
    300                 return min( $size, $fileupload_maxk );
    301 
    302         return min( $size, $fileupload_maxk, get_upload_space_available() );
    303 }
    304 /**
    305  * Determines if there is any upload space left in the current blog's quota.
    306  *
    307  * @since 3.0.0
    308  *
    309  * @return int of upload space available in bytes
    310  */
    311 function get_upload_space_available() {
    312         $space_allowed = get_space_allowed() * 1024 * 1024;
    313         if ( get_site_option( 'upload_space_check_disabled' ) )
    314                 return $space_allowed;
    315 
    316         $space_used = get_space_used() * 1024 * 1024;
    317 
    318         if ( ( $space_allowed - $space_used ) <= 0 )
    319                 return 0;
    320 
    321         return $space_allowed - $space_used;
    322 }
    323 
    324 /**
    325293 * Check whether a blog has used its allotted upload space.
    326294 *
     
    347315                return false;
    348316        }
    349 }
    350 
    351 /**
    352  * Returns the space used by the current blog.
    353  *
    354  * @since 3.5.0
    355  *
    356  * @return int Used space in megabytes
    357  */
    358 function get_space_used() {
    359         // Allow for an alternative way of tracking storage space used
    360         $space_used = apply_filters( 'pre_get_space_used', false );
    361         if ( false === $space_used ) {
    362                 $upload_dir = wp_upload_dir();
    363                 $space_used = get_dirsize( $upload_dir['basedir'] ) / 1024 / 1024;
    364         }
    365 
    366         return $space_used;
    367 }
    368 
    369 /**
    370  * Returns the upload quota for the current blog.
    371  *
    372  * @since MU
    373  *
    374  * @return int Quota in megabytes
    375  */
    376 function get_space_allowed() {
    377         $space_allowed = get_option( 'blog_upload_space' );
    378 
    379         if ( ! is_numeric( $space_allowed ) )
    380                 $space_allowed = get_site_option( 'blog_upload_space' );
    381 
    382         if ( empty( $space_allowed ) || ! is_numeric( $space_allowed ) )
    383                 $space_allowed = 50;
    384 
    385         return $space_allowed;
    386317}
    387318
Note: See TracChangeset for help on using the changeset viewer.