Make WordPress Core

Ticket #21867: 21867.patch

File 21867.patch, 3.0 KB (added by johnjamesjacoby, 13 years ago)
  • wp-admin/includes/template.php

     
    770770}
    771771
    772772/**
    773  * {@internal Missing Short Description}}
    774  *
    775  * @since 2.3.0
    776  *
    777  * @param unknown_type $size
    778  * @return unknown
    779  */
    780 function wp_convert_hr_to_bytes( $size ) {
    781         $size = strtolower($size);
    782         $bytes = (int) $size;
    783         if ( strpos($size, 'k') !== false )
    784                 $bytes = intval($size) * 1024;
    785         elseif ( strpos($size, 'm') !== false )
    786                 $bytes = intval($size) * 1024 * 1024;
    787         elseif ( strpos($size, 'g') !== false )
    788                 $bytes = intval($size) * 1024 * 1024 * 1024;
    789         return $bytes;
    790 }
    791 
    792 /**
    793  * {@internal Missing Short Description}}
    794  *
    795  * @since 2.3.0
    796  *
    797  * @param unknown_type $bytes
    798  * @return unknown
    799  */
    800 function wp_convert_bytes_to_hr( $bytes ) {
    801         $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
    802         $log = log( $bytes, 1024 );
    803         $power = (int) $log;
    804         $size = pow(1024, $log - $power);
    805         return $size . $units[$power];
    806 }
    807 
    808 /**
    809  * {@internal Missing Short Description}}
    810  *
    811  * @since 2.5.0
    812  *
    813  * @return unknown
    814  */
    815 function wp_max_upload_size() {
    816         $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
    817         $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
    818         $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes );
    819         return $bytes;
    820 }
    821 
    822 /**
    823773 * Outputs the form used by the importers to accept the data to be imported
    824774 *
    825775 * @since 2.0.0
  • wp-includes/media.php

     
    15371537}
    15381538add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' );
    15391539
     1540/**
     1541 * {@internal Missing Short Description}}
     1542 *
     1543 * @since 2.3.0
     1544 *
     1545 * @param unknown_type $size
     1546 * @return unknown
     1547 */
     1548function wp_convert_hr_to_bytes( $size ) {
     1549        $size  = strtolower( $size );
     1550        $bytes = (int) $size;
     1551        if ( strpos( $size, 'k' ) !== false )
     1552                $bytes = intval( $size ) * 1024;
     1553        elseif ( strpos( $size, 'm' ) !== false )
     1554                $bytes = intval($size) * 1024 * 1024;
     1555        elseif ( strpos( $size, 'g' ) !== false )
     1556                $bytes = intval( $size ) * 1024 * 1024 * 1024;
     1557        return $bytes;
     1558}
    15401559
    15411560/**
     1561 * {@internal Missing Short Description}}
     1562 *
     1563 * @since 2.3.0
     1564 *
     1565 * @param unknown_type $bytes
     1566 * @return unknown
     1567 */
     1568function wp_convert_bytes_to_hr( $bytes ) {
     1569        $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
     1570        $log   = log( $bytes, 1024 );
     1571        $power = (int) $log;
     1572        $size  = pow( 1024, $log - $power );
     1573        return $size . $units[$power];
     1574}
     1575
     1576/**
     1577 * {@internal Missing Short Description}}
     1578 *
     1579 * @since 2.5.0
     1580 *
     1581 * @return unknown
     1582 */
     1583function wp_max_upload_size() {
     1584        $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
     1585        $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
     1586        $bytes   = apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes );
     1587        return $bytes;
     1588}
     1589
     1590/**
    15421591 * Prepares an attachment post object for JS, where it is expected
    15431592 * to be JSON-encoded and fit into an Attachment model.
    15441593 *