Make WordPress Core

Ticket #24051: 24051.diff

File 24051.diff, 3.6 KB (added by ericlewis, 12 years ago)
  • src/wp-includes/media-template.php

    diff --git a/src/wp-includes/media-template.php b/src/wp-includes/media-template.php
    index 5418a0a..baa8847 100644
    a b function wp_print_media_templates() { 
    156156                <# } #>
    157157                <?php if ( ! _device_can_upload() ) : ?>
    158158                        <h3 class="upload-instructions"><?php printf( __('The web browser on your device cannot be used to upload files. You may be able to use the <a href="%s">native app for your device</a> instead.'), 'https://wordpress.org/mobile/' ); ?></h3>
    159                 <?php elseif ( is_multisite() && ! is_upload_space_available() ) : ?>
     159                <?php elseif ( ! is_upload_space_available() ) : ?>
    160160                        <h3 class="upload-instructions"><?php _e( 'Upload Limit Exceeded' ); ?></h3>
    161161                        <?php
    162162                        /** This action is documented in wp-admin/includes/media.php */
  • src/wp-includes/media.php

    diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
    index 135ee95..b814a6e 100644
    a b function wp_plupload_default_settings() { 
    24922492                        'mobile'    => wp_is_mobile(),
    24932493                        'supported' => _device_can_upload(),
    24942494                ),
    2495                 'limitExceeded' => is_multisite() && ! is_upload_space_available()
     2495                'limitExceeded' => ! is_upload_space_available()
    24962496        );
    24972497
    24982498        $script = 'var _wpPluploadSettings = ' . json_encode( $settings ) . ';';
    function wp_maybe_generate_attachment_metadata( $attachment ) { 
    31373137                }
    31383138        }
    31393139}
     3140
     3141/**
     3142 * Determines if there is any upload space left in the blog's quota.
     3143 *
     3144 * @since 3.0.0
     3145 *
     3146 * @return int of upload space available in bytes
     3147 */
     3148function get_upload_space_available() {
     3149        // The default for single-site: astronomically high.
     3150        $space_available = 1024 * 1024 * 1024;
     3151        if ( is_multisite() ) {
     3152                $space_allowed = get_space_allowed() * 1024 * 1024;
     3153                if ( get_site_option( 'upload_space_check_disabled' ) )
     3154                        return $space_allowed;
     3155
     3156                $space_used = get_space_used() * 1024 * 1024;
     3157
     3158                if ( ( $space_allowed - $space_used ) <= 0 )
     3159                        return 0;
     3160
     3161                $space_available = $space_allowed - $space_used;
     3162        }
     3163        return apply_filters( 'upload_space_available', $space_available );
     3164}
     3165
     3166/**
     3167 * Determines if there is any upload space left in the current blog's quota.
     3168 *
     3169 * @since 3.0.0
     3170 * @return bool True if space is available, false otherwise.
     3171 */
     3172function is_upload_space_available() {
     3173        if ( get_site_option( 'upload_space_check_disabled' ) )
     3174                return true;
     3175
     3176        return (bool) get_upload_space_available();
     3177}
     3178 No newline at end of file
  • src/wp-includes/ms-functions.php

    diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php
    index 431ba07..129f983 100644
    a b function get_space_allowed() { 
    23232323}
    23242324
    23252325/**
    2326  * Determines if there is any upload space left in the current blog's quota.
    2327  *
    2328  * @since 3.0.0
    2329  *
    2330  * @return int of upload space available in bytes
    2331  */
    2332 function get_upload_space_available() {
    2333         $space_allowed = get_space_allowed() * 1024 * 1024;
    2334         if ( get_site_option( 'upload_space_check_disabled' ) )
    2335                 return $space_allowed;
    2336 
    2337         $space_used = get_space_used() * 1024 * 1024;
    2338 
    2339         if ( ( $space_allowed - $space_used ) <= 0 )
    2340                 return 0;
    2341 
    2342         return $space_allowed - $space_used;
    2343 }
    2344 
    2345 /**
    2346  * Determines if there is any upload space left in the current blog's quota.
    2347  *
    2348  * @since 3.0.0
    2349  * @return bool True if space is available, false otherwise.
    2350  */
    2351 function is_upload_space_available() {
    2352         if ( get_site_option( 'upload_space_check_disabled' ) )
    2353                 return true;
    2354 
    2355         return (bool) get_upload_space_available();
    2356 }
    2357 
    2358 /**
    23592326 * @since 3.0.0
    23602327 *
    23612328 * @return int of upload size limit in bytes