Make WordPress Core

Changeset 22073


Ignore:
Timestamp:
09/27/2012 08:59:57 PM (12 years ago)
Author:
koopersmith
Message:

Move wp_max_upload_size and dependencies to wp-includes. props johnjamesjacoby. see #21390, fixes #21867.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

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

    r22053 r22073  
    12321232
    12331233/**
     1234 * {@internal Missing Short Description}}
     1235 *
     1236 * @since 2.3.0
     1237 *
     1238 * @param unknown_type $size
     1239 * @return unknown
     1240 */
     1241function wp_convert_hr_to_bytes( $size ) {
     1242    $size  = strtolower( $size );
     1243    $bytes = (int) $size;
     1244    if ( strpos( $size, 'k' ) !== false )
     1245        $bytes = intval( $size ) * 1024;
     1246    elseif ( strpos( $size, 'm' ) !== false )
     1247        $bytes = intval($size) * 1024 * 1024;
     1248    elseif ( strpos( $size, 'g' ) !== false )
     1249        $bytes = intval( $size ) * 1024 * 1024 * 1024;
     1250    return $bytes;
     1251}
     1252
     1253/**
     1254 * {@internal Missing Short Description}}
     1255 *
     1256 * @since 2.3.0
     1257 *
     1258 * @param unknown_type $bytes
     1259 * @return unknown
     1260 */
     1261function wp_convert_bytes_to_hr( $bytes ) {
     1262    $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' );
     1263    $log   = log( $bytes, 1024 );
     1264    $power = (int) $log;
     1265    $size  = pow( 1024, $log - $power );
     1266    return $size . $units[$power];
     1267}
     1268
     1269/**
     1270 * {@internal Missing Short Description}}
     1271 *
     1272 * @since 2.5.0
     1273 *
     1274 * @return unknown
     1275 */
     1276function wp_max_upload_size() {
     1277    $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
     1278    $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
     1279    $bytes   = apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes );
     1280    return $bytes;
     1281}
     1282
     1283/**
    12341284 * Prints default plupload arguments.
    12351285 *
     
    12811331}
    12821332add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' );
    1283 
    12841333
    12851334/**
Note: See TracChangeset for help on using the changeset viewer.