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
This commit is contained in:
Daryl Koopersmith 2012-09-27 20:59:57 +00:00
parent 1758d1aae3
commit d6d359a1bc
2 changed files with 50 additions and 51 deletions

View File

@ -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
*

View File

@ -1230,6 +1230,56 @@ function wp_embed_handler_googlevideo( $matches, $attr, $url, $rawattr ) {
return apply_filters( 'embed_googlevideo', '<embed type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docid=' . esc_attr($matches[2]) . '&amp;hl=en&amp;fs=true" style="width:' . esc_attr($width) . 'px;height:' . esc_attr($height) . 'px" allowFullScreen="true" allowScriptAccess="always" />', $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.