Making WordPress.org


Ignore:
Timestamp:
05/19/2020 08:14:31 PM (6 years ago)
Author:
ocean90
Message:

Theme/Plugin Directory: Use size_format() when displaying allowed upload file size.

See #5221.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload.php

    r9886 r9887  
    202202                                                                /* translators: Maximum allowed file size. */
    203203                                                                esc_html__( 'Maximum allowed file size: %s', 'wporg-plugins' ),
    204                                                                 esc_html( self::get_max_allowed_file_size() )
     204                                                                esc_html( size_format( wp_max_upload_size() ) )
    205205                                                        );
    206206                                                        ?>
     
    251251        }
    252252
    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 
    261                 $byte_sizes       = array( 'KB', 'MB', 'GB' );
    262 
    263                 for ( $unit = - 1; $upload_size_unit > 1024 && $unit < count( $byte_sizes ) - 1; $unit ++ ) {
    264                         $upload_size_unit /= 1024;
    265                 }
    266 
    267                 if ( $unit < 0 ) {
    268                         $upload_size_unit = $unit = 0;
    269                 } else {
    270                         $upload_size_unit = (int) $upload_size_unit;
    271                 }
    272 
    273                 return $upload_size_unit . $byte_sizes[ $unit ];
    274         }
    275253}
Note: See TracChangeset for help on using the changeset viewer.