From d6d359a1bc192225faa0686b52b7ad13aa1d07d2 Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Thu, 27 Sep 2012 20:59:57 +0000 Subject: [PATCH] Move wp_max_upload_size and dependencies to wp-includes. props johnjamesjacoby. see #21390, fixes #21867. git-svn-id: https://develop.svn.wordpress.org/trunk@22073 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/template.php | 50 --------------------------------- wp-includes/media.php | 51 +++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 51 deletions(-) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 2e32a6ffa1..10565b69d1 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -771,56 +771,6 @@ function wp_dropdown_roles( $selected = false ) { echo $p . $r; } -/** - * {@internal Missing Short Description}} - * - * @since 2.3.0 - * - * @param unknown_type $size - * @return unknown - */ -function wp_convert_hr_to_bytes( $size ) { - $size = strtolower($size); - $bytes = (int) $size; - if ( strpos($size, 'k') !== false ) - $bytes = intval($size) * 1024; - elseif ( strpos($size, 'm') !== false ) - $bytes = intval($size) * 1024 * 1024; - elseif ( strpos($size, 'g') !== false ) - $bytes = intval($size) * 1024 * 1024 * 1024; - return $bytes; -} - -/** - * {@internal Missing Short Description}} - * - * @since 2.3.0 - * - * @param unknown_type $bytes - * @return unknown - */ -function wp_convert_bytes_to_hr( $bytes ) { - $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' ); - $log = log( $bytes, 1024 ); - $power = (int) $log; - $size = pow(1024, $log - $power); - return $size . $units[$power]; -} - -/** - * {@internal Missing Short Description}} - * - * @since 2.5.0 - * - * @return unknown - */ -function wp_max_upload_size() { - $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); - $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); - $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes ); - return $bytes; -} - /** * Outputs the form used by the importers to accept the data to be imported * diff --git a/wp-includes/media.php b/wp-includes/media.php index 4e454f4ca9..f36c81c5b8 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1230,6 +1230,56 @@ function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) { return apply_filters( 'embed_googlevideo', '', $matches, $attr, $url, $rawattr ); } +/** + * {@internal Missing Short Description}} + * + * @since 2.3.0 + * + * @param unknown_type $size + * @return unknown + */ +function wp_convert_hr_to_bytes( $size ) { + $size = strtolower( $size ); + $bytes = (int) $size; + if ( strpos( $size, 'k' ) !== false ) + $bytes = intval( $size ) * 1024; + elseif ( strpos( $size, 'm' ) !== false ) + $bytes = intval($size) * 1024 * 1024; + elseif ( strpos( $size, 'g' ) !== false ) + $bytes = intval( $size ) * 1024 * 1024 * 1024; + return $bytes; +} + +/** + * {@internal Missing Short Description}} + * + * @since 2.3.0 + * + * @param unknown_type $bytes + * @return unknown + */ +function wp_convert_bytes_to_hr( $bytes ) { + $units = array( 0 => 'B', 1 => 'kB', 2 => 'MB', 3 => 'GB' ); + $log = log( $bytes, 1024 ); + $power = (int) $log; + $size = pow( 1024, $log - $power ); + return $size . $units[$power]; +} + +/** + * {@internal Missing Short Description}} + * + * @since 2.5.0 + * + * @return unknown + */ +function wp_max_upload_size() { + $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); + $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); + $bytes = apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes ); + return $bytes; +} + /** * Prints default plupload arguments. * @@ -1281,7 +1331,6 @@ function wp_plupload_default_settings() { } add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' ); - /** * Prepares an attachment post object for JS, where it is expected * to be JSON-encoded and fit into an Attachment model.