WordPress.org

Make WordPress Core

Changeset 38012


Ignore:
Timestamp:
07/08/2016 11:26:58 AM (4 years ago)
Author:
ocean90
Message:

Boostrap: Move wp_convert_hr_to_bytes() to wp-includes/load.php.

wp_convert_hr_to_bytes() was previously defined in wp-includes/media.php because it's only used by wp_max_upload_size() in the same file.
Moving this function to load.php allows us to improve core's memory limit handling.

See #32075.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

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

    r37985 r38012  
    975975    return false;
    976976}
     977
     978/**
     979 * Converts a shorthand byte value to an integer byte value.
     980 *
     981 * @since 2.3.0
     982 * @since 4.6.0 Moved from media.php to load.php
     983 *
     984 * @param string $size A shorthand byte value.
     985 * @return int An integer byte value.
     986 */
     987function wp_convert_hr_to_bytes( $size ) {
     988    $size  = strtolower( $size );
     989    $bytes = (int) $size;
     990    if ( strpos( $size, 'k' ) !== false )
     991        $bytes = intval( $size ) * KB_IN_BYTES;
     992    elseif ( strpos( $size, 'm' ) !== false )
     993        $bytes = intval($size) * MB_IN_BYTES;
     994    elseif ( strpos( $size, 'g' ) !== false )
     995        $bytes = intval( $size ) * GB_IN_BYTES;
     996    return $bytes;
     997}
  • trunk/src/wp-includes/media.php

    r37986 r38012  
    27782778
    27792779/**
    2780  * Converts a shorthand byte value to an integer byte value.
    2781  *
    2782  * @since 2.3.0
    2783  *
    2784  * @param string $size A shorthand byte value.
    2785  * @return int An integer byte value.
    2786  */
    2787 function wp_convert_hr_to_bytes( $size ) {
    2788     $size  = strtolower( $size );
    2789     $bytes = (int) $size;
    2790     if ( strpos( $size, 'k' ) !== false )
    2791         $bytes = intval( $size ) * KB_IN_BYTES;
    2792     elseif ( strpos( $size, 'm' ) !== false )
    2793         $bytes = intval($size) * MB_IN_BYTES;
    2794     elseif ( strpos( $size, 'g' ) !== false )
    2795         $bytes = intval( $size ) * GB_IN_BYTES;
    2796     return $bytes;
    2797 }
    2798 
    2799 /**
    28002780 * Determines the maximum upload size allowed in php.ini.
    28012781 *
Note: See TracChangeset for help on using the changeset viewer.