WordPress.org

Make WordPress Core


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.