IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
2602 | 2602 | /** |
2603 | 2603 | * Determines the maximum upload size allowed in php.ini. |
2604 | 2604 | * |
| 2605 | * The optional arguments should be supplied only for testing |
| 2606 | * the function. |
| 2607 | * |
2605 | 2608 | * @since 2.5.0 |
| 2609 | * @since 4.4.0 Introduced the `$upl_max_filesize_bytes` and `$post_max_size_bytes` parameters. |
2606 | 2610 | * |
| 2611 | * @param int $upl_max_filesize_bytes A value for upload_max_filesize. |
| 2612 | * @param int $post_max_size_bytes A value for post_max_size. |
| 2613 | * |
2607 | 2614 | * @return int Allowed upload size. |
2608 | 2615 | */ |
2609 | | function wp_max_upload_size() { |
2610 | | $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); |
2611 | | $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); |
| 2616 | function wp_max_upload_size( $upl_max_filesize_bytes = null, $post_max_size_bytes = null ) { |
2612 | 2617 | |
2613 | 2618 | /** |
| 2619 | * Initialize the values, if none are provided by the tests. |
| 2620 | */ |
| 2621 | if ( is_null( $upl_max_filesize_bytes ) ) { |
| 2622 | $upl_max_filesize_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); |
| 2623 | } |
| 2624 | |
| 2625 | if ( is_null( $post_max_size_bytes ) ) { |
| 2626 | $post_max_size_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); |
| 2627 | } |
| 2628 | |
| 2629 | /** |
| 2630 | * Get an accurate max upload size. |
| 2631 | * |
| 2632 | * If one of the limits is set to 0, but the other one isn't |
| 2633 | * this value will be wrong. |
| 2634 | * PHP treats 0 values as "unlimited", so actually the limit |
| 2635 | * is the larger value in this case. |
| 2636 | * |
| 2637 | * This is handled here, to make sure the proper limit is returned. |
| 2638 | * |
| 2639 | */ |
| 2640 | |
| 2641 | // get the lower limit |
| 2642 | $upload_size_limit_bytes = min( $upl_max_filesize_bytes, $post_max_size_bytes ); |
| 2643 | |
| 2644 | // if the limit is 0, make sure to get the correct one |
| 2645 | if ( 0 === $upload_size_limit_bytes ) { |
| 2646 | $upload_size_limit_bytes = max( $upl_max_filesize_bytes, $post_max_size_bytes ); |
| 2647 | } |
| 2648 | |
| 2649 | /** |
2614 | 2650 | * Filter the maximum upload size allowed in php.ini. |
2615 | 2651 | * |
2616 | 2652 | * @since 2.5.0 |
2617 | 2653 | * |
2618 | 2654 | * @param int $size Max upload size limit in bytes. |
2619 | | * @param int $u_bytes Maximum upload filesize in bytes. |
2620 | | * @param int $p_bytes Maximum size of POST data in bytes. |
| 2655 | * @param int $upl_max_filesize_bytes Maximum upload filesize in bytes. |
| 2656 | * @param int $post_max_size_bytes Maximum size of POST data in bytes. |
2621 | 2657 | */ |
2622 | | return apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes ); |
| 2658 | return apply_filters( 'upload_size_limit', $upload_size_limit_bytes, $upl_max_filesize_bytes, $post_max_size_bytes ); |
2623 | 2659 | } |
2624 | 2660 | |
2625 | 2661 | /** |