| 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 | |
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 ); |