Make WordPress Core


Ignore:
Timestamp:
10/21/2015 02:02:59 PM (10 years ago)
Author:
DrewAPicture
Message:

Filesystem: Following the introduction of the KB|MB|GB|TB_IN_BYTES constants in [35286], use them in various places in core.

Props sudar.
Fixes #22405.

File:
1 edited

Legend:

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

    r35182 r35325  
    2929
    3030    $file_size = filesize( $file['tmp_name'] );
    31     if ( $space_left < $file_size )
    32         $file['error'] = sprintf( __( 'Not enough space to upload. %1$s KB needed.' ), number_format( ($file_size - $space_left) /1024 ) );
    33     if ( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )
    34         $file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.'), get_site_option( 'fileupload_maxk', 1500 ) );
     31    if ( $space_left < $file_size ) {
     32        $file['error'] = sprintf( __( 'Not enough space to upload. %1$s KB needed.' ), number_format( ( $file_size - $space_left ) / KB_IN_BYTES ) );
     33    }
     34
     35    if ( $file_size > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
     36        $file['error'] = sprintf( __( 'This file is too big. Files must be less than %1$s KB in size.' ), get_site_option( 'fileupload_maxk', 1500 ) );
     37    }
     38
    3539    if ( upload_is_user_over_quota( false ) ) {
    3640        $file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
    3741    }
     42
    3843    if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
    3944        wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
     
    444449
    445450    if ( $space_allowed > 1000 ) {
    446         $space = number_format( $space_allowed / 1024 );
     451        $space = number_format( $space_allowed / KB_IN_BYTES );
    447452        /* translators: Gigabytes */
    448453        $space .= __( 'GB' );
Note: See TracChangeset for help on using the changeset viewer.