Changeset 35325
- Timestamp:
- 10/21/2015 02:02:59 PM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ms.php
r35182 r35325 29 29 30 30 $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 35 39 if ( upload_is_user_over_quota( false ) ) { 36 40 $file['error'] = __( 'You have used your space quota. Please delete files before uploading.' ); 37 41 } 42 38 43 if ( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) { 39 44 wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' ); … … 444 449 445 450 if ( $space_allowed > 1000 ) { 446 $space = number_format( $space_allowed / 1024);451 $space = number_format( $space_allowed / KB_IN_BYTES ); 447 452 /* translators: Gigabytes */ 448 453 $space .= __( 'GB' ); -
trunk/src/wp-includes/cache.php
r34227 r35325 692 692 echo '<ul>'; 693 693 foreach ($this->cache as $group => $cache) { 694 echo "<li><strong>Group:</strong> $group - ( " . number_format( strlen( serialize( $cache ) ) / 1024, 2 ) . 'k )</li>';694 echo "<li><strong>Group:</strong> $group - ( " . number_format( strlen( serialize( $cache ) ) / KB_IN_BYTES, 2 ) . 'k )</li>'; 695 695 } 696 696 echo '</ul>'; -
trunk/src/wp-includes/deprecated.php
r35296 r35325 3285 3285 3286 3286 $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB', 4 => 'TB' ); 3287 $log = log( $bytes, 1024);3287 $log = log( $bytes, KB_IN_BYTES ); 3288 3288 $power = (int) $log; 3289 $size = pow( 1024, $log - $power );3289 $size = pow( KB_IN_BYTES, $log - $power ); 3290 3290 3291 3291 if ( ! is_nan( $size ) && array_key_exists( $power, $units ) ) { -
trunk/src/wp-includes/functions.php
r35288 r35325 211 211 function size_format( $bytes, $decimals = 0 ) { 212 212 $quant = array( 213 // ========================= Origin ==== 214 'TB' => 1099511627776, // pow( 1024, 4) 215 'GB' => 1073741824, // pow( 1024, 3) 216 'MB' => 1048576, // pow( 1024, 2) 217 'kB' => 1024, // pow( 1024, 1) 218 'B' => 1, // pow( 1024, 0) 213 'TB' => TB_IN_BYTES, 214 'GB' => GB_IN_BYTES, 215 'MB' => MB_IN_BYTES, 216 'kB' => KB_IN_BYTES, 217 'B' => 1, 219 218 ); 220 219 -
trunk/src/wp-includes/media.php
r35289 r35325 2639 2639 $bytes = (int) $size; 2640 2640 if ( strpos( $size, 'k' ) !== false ) 2641 $bytes = intval( $size ) * 1024;2641 $bytes = intval( $size ) * KB_IN_BYTES; 2642 2642 elseif ( strpos( $size, 'm' ) !== false ) 2643 $bytes = intval($size) * 1024 * 1024;2643 $bytes = intval($size) * MB_IN_BYTES; 2644 2644 elseif ( strpos( $size, 'g' ) !== false ) 2645 $bytes = intval( $size ) * 1024 * 1024 * 1024;2645 $bytes = intval( $size ) * GB_IN_BYTES; 2646 2646 return $bytes; 2647 2647 } -
trunk/src/wp-includes/ms-functions.php
r35189 r35325 1875 1875 return $upload; 1876 1876 1877 if ( strlen( $upload['bits'] ) > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) ) 1878 return sprintf( __( 'This file is too big. Files must be less than %d KB in size.' ) . '<br />', get_site_option( 'fileupload_maxk', 1500 )); 1877 if ( strlen( $upload['bits'] ) > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) { 1878 return sprintf( __( 'This file is too big. Files must be less than %d KB in size.' ) . '<br />', get_site_option( 'fileupload_maxk', 1500 ) ); 1879 } 1879 1880 1880 1881 return $upload; … … 2279 2280 if ( false === $space_used ) { 2280 2281 $upload_dir = wp_upload_dir(); 2281 $space_used = get_dirsize( $upload_dir['basedir'] ) / 1024 / 1024;2282 $space_used = get_dirsize( $upload_dir['basedir'] ) / MB_IN_BYTES; 2282 2283 } 2283 2284 … … 2323 2324 $allowed = 0; 2324 2325 } 2325 $space_allowed = $allowed * 1024 * 1024;2326 $space_allowed = $allowed * MB_IN_BYTES; 2326 2327 if ( get_site_option( 'upload_space_check_disabled' ) ) 2327 2328 return $space_allowed; 2328 2329 2329 $space_used = get_space_used() * 1024 * 1024;2330 $space_used = get_space_used() * MB_IN_BYTES; 2330 2331 2331 2332 if ( ( $space_allowed - $space_used ) <= 0 ) … … 2354 2355 */ 2355 2356 function upload_size_limit_filter( $size ) { 2356 $fileupload_maxk = 1024* get_site_option( 'fileupload_maxk', 1500 );2357 $fileupload_maxk = KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ); 2357 2358 if ( get_site_option( 'upload_space_check_disabled' ) ) 2358 2359 return min( $size, $fileupload_maxk );
Note: See TracChangeset
for help on using the changeset viewer.