Make WordPress Core


Ignore:
Timestamp:
07/08/2016 11:26:58 AM (9 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.

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.