Ticket #5221: 5221.2.patch
File 5221.2.patch, 3.3 KB (added by , 5 years ago) |
---|
-
trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload.php
201 201 printf( 202 202 /* translators: Maximum allowed file size. */ 203 203 esc_html__( 'Maximum allowed file size: %s', 'wporg-plugins' ), 204 esc_html( s elf::get_max_allowed_file_size() )204 esc_html( size_format( wp_max_upload_size() ) ) 205 205 ); 206 206 ?> 207 207 </small> … … 250 250 return ob_get_clean(); 251 251 } 252 252 253 /**254 * Returns a human readable version of the max allowed upload size.255 *256 * @return string The allowed file size.257 */258 public static function get_max_allowed_file_size() {259 $upload_size_unit = wp_max_upload_size();260 $byte_sizes = array( 'KB', 'MB', 'GB' );261 262 for ( $unit = - 1; $upload_size_unit > 1024 && $unit < count( $byte_sizes ) - 1; $unit ++ ) {263 $upload_size_unit /= 1024;264 }265 266 if ( $unit < 0 ) {267 $upload_size_unit = $unit = 0;268 } else {269 $upload_size_unit = (int) $upload_size_unit;270 }271 272 return $upload_size_unit . $byte_sizes[ $unit ];273 }274 253 } -
trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/upload.php
9 9 add_action( 'init', 'wporg_themes_upload_shortcode' ); 10 10 11 11 /** 12 * Sets upload size limit to limit theme ZIP file uploads to 10 MB. 13 */ 14 function wporg_themes_upload_size_limit() { 15 return 10 * MB_IN_BYTES; 16 } 17 add_filter( 'upload_size_limit', 'wporg_themes_upload_size_limit', 10, 0 ); 18 19 /** 12 20 * Renders the upload shortcode. 13 21 */ 14 22 function wporg_themes_render_upload_shortcode() { … … 47 55 <input type="file" id="zip_file" name="zip_file" size="25"/> 48 56 <button id="upload_button" class="button" type="submit" value="' . esc_attr__( 'Upload', 'wporg-themes' ) . '">' . esc_html__( 'Upload', 'wporg-themes' ) . '</button> 49 57 <p> 50 <small>' . sprintf( __( 'Maximum allowed file size: %s', 'wporg-themes' ), esc_html( wporg_themes_get_max_allowed_file_size() ) ) . '</small>58 <small>' . sprintf( __( 'Maximum allowed file size: %s', 'wporg-themes' ), esc_html( size_format( wp_max_upload_size() ) ) ) . '</small> 51 59 </p> 52 60 </form>'; 53 61 … … 55 63 } 56 64 57 65 /** 58 * Returns a human readable version of the max allowed upload size.59 *60 * @return string The allowed file size.61 */62 function wporg_themes_get_max_allowed_file_size() {63 $upload_size_unit = wp_max_upload_size();64 $byte_sizes = array( 'KB', 'MB', 'GB' );65 66 for ( $unit = - 1; $upload_size_unit > 1024 && $unit < count( $byte_sizes ) - 1; $unit++ ) {67 $upload_size_unit /= 1024;68 }69 if ( $unit < 0 ) {70 $upload_size_unit = $unit = 0;71 } else {72 $upload_size_unit = (int) $upload_size_unit;73 }74 return $upload_size_unit . $byte_sizes[ $unit ];75 }76 77 /**78 66 * Runs basic checks and hands off to the upload processor. 79 67 * 80 68 * @return string Failure or success message.