diff --git a/includes/admin/views/html-admin-page-status-report.php b/includes/admin/views/html-admin-page-status-report.php index b1e06a17003..9940ba697e6 100644 --- a/includes/admin/views/html-admin-page-status-report.php +++ b/includes/admin/views/html-admin-page-status-report.php @@ -13,14 +13,16 @@ if ( ! class_exists( 'WC_REST_System_Status_Controller', false ) ) { wp_die( 'Cannot load the REST API to access WC_REST_System_Status_Controller.' ); } -$system_status = new WC_REST_System_Status_Controller; -$environment = $system_status->get_environment_info(); -$database = $system_status->get_database_info(); -$active_plugins = $system_status->get_active_plugins(); -$theme = $system_status->get_theme_info(); -$security = $system_status->get_security_info(); -$settings = $system_status->get_settings(); -$pages = $system_status->get_pages(); +$system_status = new WC_REST_System_Status_Controller; +$environment = $system_status->get_environment_info(); +$database = $system_status->get_database_info(); +$database_size = $system_status->get_database_table_sizes(); +$post_type_counts = $system_status->get_post_type_counts(); +$active_plugins = $system_status->get_active_plugins(); +$theme = $system_status->get_theme_info(); +$security = $system_status->get_security_info(); +$settings = $system_status->get_settings(); +$pages = $system_status->get_pages(); ?>

@@ -302,57 +304,100 @@ $pages = $system_status->get_pages(); - - - - - - - - - - - - - - - - - $table_exists ) { + + + + + + + + + + + + + + + - - - - - - - - - - - + + $table_exists ) { ?> - + + + + + + + + + + + + + +

:
  20 ) { - echo ' ' . sprintf( __( '%1$s - We recommend using a prefix with less than 20 characters. See: %2$s', 'woocommerce' ), esc_html( $database['database_prefix'] ), '' . __( 'How to update your database table prefix', 'woocommerce' ) . '' ) . ''; - } else { - echo '' . esc_html( $database['database_prefix'] ) . ''; - } - ?> -

:
  20 ) { + echo ' ' . sprintf( __( '%1$s - We recommend using a prefix with less than 20 characters. See: %2$s', 'woocommerce' ), esc_html( $database['database_prefix'] ), '' . __( 'How to update your database table prefix', 'woocommerce' ) . '' ) . ''; + } else { + echo '' . esc_html( $database['database_prefix'] ) . ''; + } ?> -
  ' . __( 'Table does not exist', 'woocommerce' ) . '' : ''; ?>
: ' . esc_html( $database['maxmind_geoip_database'] ) . ' '; - } else { - printf( ' ' . sprintf( __( 'The MaxMind GeoIP Database does not exist - Geolocation will not function. You can download and install it manually from %1$s to the path: %2$s. Scroll down to "Downloads" and download the "Binary / gzip" file next to "GeoLite Country". Please remember to uncompress GeoIP.dat.gz and upload the GeoIP.dat file only.', 'woocommerce' ), make_clickable( 'http://dev.maxmind.com/geoip/legacy/geolite/' ), '' . $database['maxmind_geoip_database'] . '' ) . '', WC_LOG_DIR ); - } - ?>
  ' . __( 'Table does not exist', 'woocommerce' ) . '' : ''; ?>
: ' . esc_html( $database['maxmind_geoip_database'] ) . ' '; + } else { + printf( ' ' . sprintf( __( 'The MaxMind GeoIP Database does not exist - Geolocation will not function. You can download and install it manually from %1$s to the path: %2$s. Scroll down to "Downloads" and download the "Binary / gzip" file next to "GeoLite Country". Please remember to uncompress GeoIP.dat.gz and upload the GeoIP.dat file only.', 'woocommerce' ), make_clickable( 'http://dev.maxmind.com/geoip/legacy/geolite/' ), '' . $database['maxmind_geoip_database'] . '' ) . '', WC_LOG_DIR ); + } + ?>
+ + + + + + + + + + + + + + + +

name ); ?>  + data, 2 ); ?>MB, + index, 2 ); ?>MB +
+ + + + + + + + + + + + + + +

type ); ?> count ); ?>
diff --git a/includes/api/class-wc-rest-system-status-controller.php b/includes/api/class-wc-rest-system-status-controller.php index d3c96c52f09..52064d30509 100644 --- a/includes/api/class-wc-rest-system-status-controller.php +++ b/includes/api/class-wc-rest-system-status-controller.php @@ -670,6 +670,35 @@ class WC_REST_System_Status_Controller extends WC_REST_Controller { ); } + public function get_database_table_sizes() { + global $wpdb; + + $database_table_sizes = $wpdb->get_results( $wpdb->prepare( " + SELECT + table_name AS 'name', + round( ( data_length / 1024 / 1024 ), 2 ) 'data', + round( ( index_length / 1024 / 1024 ), 2 ) 'index' + FROM information_schema.TABLES + WHERE table_schema = %s + ORDER BY name ASC; + ", DB_NAME ) ); + + return is_array( $database_table_sizes ) ? $database_table_sizes : array(); + } + + /** + * Get array of counts of objects. Orders, products, etc. + * + * @return array + */ + public function get_post_type_counts() { + global $wpdb; + + $post_type_counts = $wpdb->get_results( "SELECT post_type AS 'type', count(1) AS 'count' FROM {$wpdb->posts} GROUP BY post_type;" ); + + return is_array( $post_type_counts ) ? $post_type_counts : array(); + } + /** * Get a list of plugins active on the site. *