Make WordPress Core

Ticket #27224: 27224.3.diff

File 27224.3.diff, 2.9 KB (added by jeremyfelt, 11 years ago)
  • src/wp-admin/includes/ms.php

     
    3131        if ( $space_left < $file_size )
    3232                $file['error'] = sprintf( __( 'Not enough space to upload. %1$s KB needed.' ), number_format( ($file_size - $space_left) /1024 ) );
    3333        if ( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )
    34                 $file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.'), get_site_option( 'fileupload_maxk', 1500 ) );
     34                $file['error'] = sprintf( __( 'This file is too big. Files must be less than %1$s MB in size.' ), ceil( get_site_option( 'fileupload_maxk', 1500 ) / 1024 ) );
    3535        if ( upload_is_user_over_quota( false ) ) {
    3636                $file['error'] = __( 'You have used your space quota. Please delete files before uploading.' );
    3737        }
  • src/wp-admin/network/settings.php

     
    5959        );
    6060
    6161        foreach ( $options as $option_name ) {
    62                 if ( ! isset($_POST[$option_name]) )
     62                if ( ! isset( $_POST[ $option_name ] ) ) {
    6363                        continue;
    64                 $value = wp_unslash( $_POST[$option_name] );
     64                }
     65
     66                // Convert the saved file upload maximum from MB to KB before storing.
     67                if ( 'fileupload_maxk' === $option_name ) {
     68                        $value = absint( wp_unslash( $_POST[ $option_name] ) * 1024 );
     69                } else {
     70                        $value = wp_unslash( $_POST[ $option_name ] );
     71                }
    6572                update_site_option( $option_name, $value );
    6673        }
    6774
     
    269276
    270277                        <tr>
    271278                                <th scope="row"><label for="fileupload_maxk"><?php _e( 'Max upload file size' ) ?></label></th>
    272                                 <td><?php printf( _x( '%s KB', 'File size in kilobytes' ), '<input name="fileupload_maxk" type="number" min="0" style="width: 100px" id="fileupload_maxk" value="' . esc_attr( get_site_option( 'fileupload_maxk', 300 ) ) . '" />' ); ?></td>
     279                                <td><?php printf( _x( '%s MB', 'File size in MB' ), '<input name="fileupload_maxk" type="number" min="0" step="1" style="width: 100px" id="fileupload_maxk" value="' . ceil( get_site_option( 'fileupload_maxk', 1500 ) / 1024 ) . '" />' ); ?></td>
    273280                        </tr>
    274281                </table>
    275282
  • src/wp-includes/ms-functions.php

     
    18801880                return $upload;
    18811881
    18821882        if ( strlen( $upload['bits'] )  > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )
    1883                 return sprintf( __( 'This file is too big. Files must be less than %d KB in size.' ) . '<br />', get_site_option( 'fileupload_maxk', 1500 ));
     1883                return sprintf( __( 'This file is too big. Files must be less than %d MB in size.' ) . '<br />', ceil( get_site_option( 'fileupload_maxk', 1500 ) / 1024 ) );
    18841884
    18851885        return $upload;
    18861886}