Changeset 5964 for trunk/wp-admin/includes/template.php
- Timestamp:
- 08/28/2007 11:13:16 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r5927 r5964 560 560 } 561 561 562 function wp_convert_hr_to_bytes( $size ) { 563 $size = strtolower($size); 564 $bytes = (int) $size; 565 if ( strpos($size, 'k') !== false ) 566 $bytes = intval($size) * 1024; 567 elseif ( strpos($size, 'm') !== false ) 568 $bytes = intval($size) * 1024 * 1024; 569 elseif ( strpos($size, 'g') !== false ) 570 $bytes = intval($size) * 1024 * 1024 * 1024; 571 return $bytes; 572 } 573 574 function wp_convert_bytes_to_hr( $bytes ) { 575 $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' ); 576 $log = log( $bytes, 1024 ); 577 $power = (int) $log; 578 $size = pow(1024, $log - $power); 579 return $size . $units[$power]; 580 } 581 562 582 function wp_import_upload_form( $action ) { 563 $size = strtolower( ini_get( 'upload_max_filesize' ) ); 564 $bytes = 0; 565 if (strpos($size, 'k') !== false) 566 $bytes = $size * 1024; 567 if (strpos($size, 'm') !== false) 568 $bytes = $size * 1024 * 1024; 569 if (strpos($size, 'g') !== false) 570 $bytes = $size * 1024 * 1024 * 1024; 571 $size = apply_filters( 'import_upload_size_limit', $size ); 583 $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); 584 $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); 585 $bytes = apply_filters( 'import_upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes ); 586 $size = wp_convert_bytes_to_hr( $bytes ); 572 587 ?> 573 588 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo attribute_escape($action) ?>"> 574 589 <p> 575 590 <?php wp_nonce_field('import-upload'); ?> 576 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?> 591 <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>) 577 592 <input type="file" id="upload" name="import" size="25" /> 578 593 <input type="hidden" name="action" value="save" />
Note: See TracChangeset
for help on using the changeset viewer.