Make WordPress Core

Ticket #46967: 46967.diff

File 46967.diff, 8.1 KB (added by xkon, 5 years ago)
  • src/wp-admin/includes/ajax-actions.php

    diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php
    index 0f1f0f4e04..3441945217 100644
    a b function wp_ajax_health_check_site_status_result() { 
    49674967function wp_ajax_health_check_get_sizes() {
    49684968        check_ajax_referer( 'health-check-site-status-result' );
    49694969
    4970         if ( ! current_user_can( 'install_plugins' ) || is_multisite() ) {
     4970        if ( ! current_user_can( 'install_plugins' ) ) {
    49714971                wp_send_json_error();
    49724972        }
    49734973
  • src/wp-admin/includes/class-wp-debug-data.php

    diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php
    index fe7fe60fef..ad4787c541 100644
    a b class WP_Debug_Data { 
    109109                        ),
    110110                );
    111111
    112                 if ( ! $is_multisite ) {
    113                         $info['wp-paths-sizes'] = array(
    114                                 'label'  => __( 'Directories and Sizes' ),
    115                                 'fields' => array(),
    116                         );
    117                 }
     112                $info['wp-paths-sizes'] = array(
     113                        'label'  => __( 'Directories and Sizes' ),
     114                        'fields' => array(),
     115                );
    118116
    119117                $info['wp-dropins'] = array(
    120118                        'label'       => __( 'Drop-ins' ),
    class WP_Debug_Data { 
    391389                        );
    392390                }
    393391
    394                 // Remove accordion for Directories and Sizes if in Multisite.
    395                 if ( ! $is_multisite ) {
    396                         $loading = __( 'Loading…' );
     392                if ( $is_multisite && get_site_option( 'upload_space_check_disabled' ) ) {
     393                        $uploads_quota = __( 'Unlimited' );
     394                } elseif ( $is_multisite && is_main_site() ) {
     395                        $uploads_quota = sprintf(
     396                                // Translators: 1: The value of Site upload space.
     397                                __( '%s MB' ),
     398                                get_site_option( 'blog_upload_space', 100 )
     399                        );
     400                } elseif ( $is_multisite ) {
     401                        $uploads_quota = sprintf(
     402                                // Translators: 1: The value of Site upload space.
     403                                __( '%s MB' ),
     404                                get_space_allowed()
     405                        );
     406                }
     407
     408                if ( $is_multisite ) {
     409                        $max_upload_file_size = sprintf(
     410                                // Translators: 1: The value of Max upload file size.
     411                                __( '%s KB' ),
     412                                get_site_option( 'fileupload_maxk', 1500 )
     413                        );
     414                }
    397415
     416                $loading = __( 'Loading…' );
     417
     418                if ( ! $is_multisite ) {
     419                        $info['wp-paths-sizes']['fields'] = array(
     420                                'wordpress_path' => array(
     421                                        'label' => __( 'WordPress directory location' ),
     422                                        'value' => untrailingslashit( ABSPATH ),
     423                                ),
     424                                'wordpress_size' => array(
     425                                        'label' => __( 'WordPress directory size' ),
     426                                        'value' => $loading,
     427                                        'debug' => 'loading...',
     428                                ),
     429                                'uploads_path'   => array(
     430                                        'label' => __( 'Uploads directory location' ),
     431                                        'value' => $upload_dir['basedir'],
     432                                ),
     433                                'uploads_size'   => array(
     434                                        'label' => __( 'Uploads directory size' ),
     435                                        'value' => $loading,
     436                                        'debug' => 'loading...',
     437                                ),
     438                                'themes_path'    => array(
     439                                        'label' => __( 'Themes directory location' ),
     440                                        'value' => get_theme_root(),
     441                                ),
     442                                'themes_size'    => array(
     443                                        'label' => __( 'Themes directory size' ),
     444                                        'value' => $loading,
     445                                        'debug' => 'loading...',
     446                                ),
     447                                'plugins_path'   => array(
     448                                        'label' => __( 'Plugins directory location' ),
     449                                        'value' => WP_PLUGIN_DIR,
     450                                ),
     451                                'plugins_size'   => array(
     452                                        'label' => __( 'Plugins directory size' ),
     453                                        'value' => $loading,
     454                                        'debug' => 'loading...',
     455                                ),
     456                                'database_size'  => array(
     457                                        'label' => __( 'Database size' ),
     458                                        'value' => $loading,
     459                                        'debug' => 'loading...',
     460                                ),
     461                                'total_size'     => array(
     462                                        'label' => __( 'Total installation size' ),
     463                                        'value' => $loading,
     464                                        'debug' => 'loading...',
     465                                ),
     466                        );
     467                } elseif ( $is_multisite && is_main_site() ) {
    398468                        $info['wp-paths-sizes']['fields'] = array(
    399469                                'wordpress_path' => array(
    400470                                        'label' => __( 'WordPress directory location' ),
    class WP_Debug_Data { 
    414484                                        'value' => $loading,
    415485                                        'debug' => 'loading...',
    416486                                ),
     487                                'uploads_quota'  => array(
     488                                        'label' => __( 'Site upload space' ),
     489                                        'value' => $uploads_quota,
     490                                ),
     491                                'uploads_max_file_size' => array(
     492                                        'label' => __( 'Max upload file size' ),
     493                                        'value' => $max_upload_file_size,
     494                                ),
    417495                                'themes_path'    => array(
    418496                                        'label' => __( 'Themes directory location' ),
    419497                                        'value' => get_theme_root(),
    class WP_Debug_Data { 
    443521                                        'debug' => 'loading...',
    444522                                ),
    445523                        );
     524                } else {
     525                        $info['wp-paths-sizes']['fields'] = array(
     526                                'uploads_path'  => array(
     527                                        'label' => __( 'Uploads directory location' ),
     528                                        'value' => $upload_dir['basedir'],
     529                                ),
     530                                'uploads_size'  => array(
     531                                        'label' => __( 'Uploads directory size' ),
     532                                        'value' => $loading,
     533                                        'debug' => 'loading...',
     534                                ),
     535                                'uploads_quota' => array(
     536                                        'label' => __( 'Site upload space' ),
     537                                        'value' => $uploads_quota,
     538                                ),
     539                                'uploads_max_file_size' => array(
     540                                        'label' => __( 'Max upload file size' ),
     541                                        'value' => $max_upload_file_size,
     542                                ),
     543                        );
    446544                }
    447545
    448546                // Get a list of all drop-in replacements.
    class WP_Debug_Data { 
    11171215         * @return array The sizes of the directories, also the database size and total installation size.
    11181216         */
    11191217        public static function get_sizes() {
    1120                 $size_db    = self::get_database_size();
     1218                if ( ! is_multisite() || is_multisite() && is_main_site() ) {
     1219                        $size_db = self::get_database_size();
     1220                }
     1221
    11211222                $upload_dir = wp_get_upload_dir();
    11221223
    11231224                /*
    class WP_Debug_Data { 
    11431244
    11441245                // Go through the various installation directories and calculate their sizes.
    11451246                // No trailing slashes.
    1146                 $paths = array(
    1147                         'wordpress_size' => untrailingslashit( ABSPATH ),
    1148                         'themes_size'    => get_theme_root(),
    1149                         'plugins_size'   => WP_PLUGIN_DIR,
    1150                         'uploads_size'   => $upload_dir['basedir'],
    1151                 );
     1247                if ( ! is_multisite() || is_multisite() && is_main_site() ) {
     1248                        $paths = array(
     1249                                'wordpress_size' => untrailingslashit( ABSPATH ),
     1250                                'themes_size'    => get_theme_root(),
     1251                                'plugins_size'   => WP_PLUGIN_DIR,
     1252                                'uploads_size'   => $upload_dir['basedir'],
     1253                        );
     1254                } else {
     1255                        $paths = array(
     1256                                'uploads_size' => $upload_dir['basedir'],
     1257                        );
     1258                }
    11521259
    11531260                $exclude = $paths;
    11541261                unset( $exclude['wordpress_size'] );
    class WP_Debug_Data { 
    12001307                        $all_sizes[ $name ] = $results;
    12011308                }
    12021309
    1203                 if ( $size_db > 0 ) {
    1204                         $database_size = size_format( $size_db, 2 );
     1310                if ( ! is_multisite() || is_multisite() && is_main_site() ) {
     1311                        if ( $size_db > 0 ) {
     1312                                $database_size = size_format( $size_db, 2 );
    12051313
    1206                         $all_sizes['database_size'] = array(
    1207                                 'raw'   => $size_db,
    1208                                 'size'  => $database_size,
    1209                                 'debug' => $database_size . " ({$size_db} bytes)",
    1210                         );
    1211                 } else {
    1212                         $all_sizes['database_size'] = array(
    1213                                 'size'  => __( 'Not available' ),
    1214                                 'debug' => 'not available',
    1215                         );
    1216                 }
     1314                                $all_sizes['database_size'] = array(
     1315                                        'raw'   => $size_db,
     1316                                        'size'  => $database_size,
     1317                                        'debug' => $database_size . " ({$size_db} bytes)",
     1318                                );
     1319                        } else {
     1320                                $all_sizes['database_size'] = array(
     1321                                        'size'  => __( 'Not available' ),
     1322                                        'debug' => 'not available',
     1323                                );
     1324                        }
    12171325
    1218                 if ( null !== $size_total && $size_db > 0 ) {
    1219                         $total_size    = $size_total + $size_db;
    1220                         $total_size_mb = size_format( $total_size, 2 );
     1326                        if ( null !== $size_total && $size_db > 0 ) {
     1327                                $total_size    = $size_total + $size_db;
     1328                                $total_size_mb = size_format( $total_size, 2 );
    12211329
    1222                         $all_sizes['total_size'] = array(
    1223                                 'raw'   => $total_size,
    1224                                 'size'  => $total_size_mb,
    1225                                 'debug' => $total_size_mb . " ({$total_size} bytes)",
    1226                         );
    1227                 } else {
    1228                         $all_sizes['total_size'] = array(
    1229                                 'size'  => __( 'Total size is not available. Some errors were encountered when determining the size of your installation.' ),
    1230                                 'debug' => 'not available',
    1231                         );
     1330                                $all_sizes['total_size'] = array(
     1331                                        'raw'   => $total_size,
     1332                                        'size'  => $total_size_mb,
     1333                                        'debug' => $total_size_mb . " ({$total_size} bytes)",
     1334                                );
     1335                        } else {
     1336                                $all_sizes['total_size'] = array(
     1337                                        'size'  => __( 'Total size is not available. Some errors were encountered when determining the size of your installation.' ),
     1338                                        'debug' => 'not available',
     1339                                );
     1340                        }
    12321341                }
    12331342
    12341343                return $all_sizes;