Make WordPress Core

Changeset 44984


Ignore:
Timestamp:
03/23/2019 03:17:14 AM (7 years ago)
Author:
pento
Message:

Admin: Introduce the Site Health screens.

The Site Health tool serves two purposes:

  • Provide site owners with information to improve the performance, reliability, and security of their site.
  • Collect comprehensive debug information about the site.

By encouraging site owners to maintain their site and adhere to modern best practices, we ultimately improve the software hygeine of both the WordPress ecosystem, and the open internet as a whole.

Props Clorith, hedgefield, melchoyce, xkon, karmatosed, jordesign, earnjam, ianbelanger, wpscholar, desrosj, pedromendonca, peterbooker, jcastaneda, garyj, soean, pento, timothyblynjacobs, zodiac1978, dgroddick, garrett-eclipse, netweb, tobifjellner, pixolin, afercia, joedolson, birgire.
See #46573.

Location:
branches/5.1
Files:
7 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/5.1/Gruntfile.js

    r44740 r44984  
    264264                                        [ WORKING_DIR + 'wp-admin/js/tags-suggest.js' ]: [ './src/js/_enqueues/admin/tags-suggest.js' ],
    265265                                        [ WORKING_DIR + 'wp-admin/js/tags.js' ]: [ './src/js/_enqueues/admin/tags.js' ],
     266                                        [ WORKING_DIR + 'wp-admin/js/site-health.js' ]: [ './src/js/_enqueues/admin/site-health.js' ],
    266267                                        [ WORKING_DIR + 'wp-admin/js/theme-plugin-editor.js' ]: [ './src/js/_enqueues/wp/theme-plugin-editor.js' ],
    267268                                        [ WORKING_DIR + 'wp-admin/js/theme.js' ]: [ './src/js/_enqueues/wp/theme.js' ],
  • branches/5.1/src/wp-admin/admin-ajax.php

    r42986 r44984  
    132132        'wp-privacy-export-personal-data',
    133133        'wp-privacy-erase-personal-data',
     134        'health-check-site-status-result',
     135        'health-check-dotorg-communication',
     136        'health-check-is-in-debug-mode',
     137        'health-check-background-updates',
     138        'health-check-loopback-requests',
    134139);
    135140
  • branches/5.1/src/wp-admin/css/wp-admin.css

    r32994 r44984  
    1313@import url(site-icon.css);
    1414@import url(l10n.css);
     15@import url(site-health.css);
  • branches/5.1/src/wp-admin/includes/ajax-actions.php

    r44843 r44984  
    48364836        wp_send_json_success( $response );
    48374837}
     4838
     4839/**
     4840 * Ajax handler for site health checks on server communication.
     4841 *
     4842 * @since 5.2.0
     4843 */
     4844function wp_ajax_health_check_dotorg_communication() {
     4845        check_ajax_referer( 'health-check-site-status' );
     4846
     4847        if ( ! current_user_can( 'install_plugins' ) ) {
     4848                wp_send_json_error();
     4849        }
     4850
     4851        if ( ! class_exists( 'WP_Site_Health' ) ) {
     4852                require_once( ABSPATH . 'wp-admin/includes/class-wp-site-health.php' );
     4853        }
     4854
     4855        $site_health = new WP_Site_Health();
     4856        wp_send_json_success( $site_health->get_test_dotorg_communication() );
     4857}
     4858
     4859/**
     4860 * Ajax handler for site health checks on debug mode.
     4861 *
     4862 * @since 5.2.0
     4863 */
     4864function wp_ajax_health_check_is_in_debug_mode() {
     4865        wp_verify_nonce( 'health-check-site-status' );
     4866
     4867        if ( ! current_user_can( 'install_plugins' ) ) {
     4868                wp_send_json_error();
     4869        }
     4870
     4871        if ( ! class_exists( 'WP_Site_Health' ) ) {
     4872                require_once( ABSPATH . 'wp-admin/includes/class-wp-site-health.php' );
     4873        }
     4874
     4875        $site_health = new WP_Site_Health();
     4876        wp_send_json_success( $site_health->get_test_is_in_debug_mode() );
     4877}
     4878
     4879/**
     4880 * Ajax handler for site health checks on background updates.
     4881 *
     4882 * @since 5.2.0
     4883 */
     4884function wp_ajax_health_check_background_updates() {
     4885        check_ajax_referer( 'health-check-site-status' );
     4886
     4887        if ( ! current_user_can( 'install_plugins' ) ) {
     4888                wp_send_json_error();
     4889        }
     4890
     4891        if ( ! class_exists( 'WP_Site_Health' ) ) {
     4892                require_once( ABSPATH . 'wp-admin/includes/class-wp-site-health.php' );
     4893        }
     4894
     4895        $site_health = new WP_Site_Health();
     4896        wp_send_json_success( $site_health->get_test_background_updates() );
     4897}
     4898
     4899
     4900/**
     4901 * Ajax handler for site health checks on loopback requests.
     4902 *
     4903 * @since 5.2.0
     4904 */
     4905function wp_ajax_health_check_loopback_requests() {
     4906        check_ajax_referer( 'health-check-site-status' );
     4907
     4908        if ( ! current_user_can( 'install_plugins' ) ) {
     4909                wp_send_json_error();
     4910        }
     4911
     4912        if ( ! class_exists( 'WP_Site_Health' ) ) {
     4913                require_once( ABSPATH . 'wp-admin/includes/class-wp-site-health.php' );
     4914        }
     4915
     4916        $site_health = new WP_Site_Health();
     4917        wp_send_json_success( $site_health->get_test_loopback_requests() );
     4918}
     4919
     4920/**
     4921 * Ajax handler for site health check to update the result status.
     4922 *
     4923 * @since 5.2.0
     4924 */
     4925function wp_ajax_health_check_site_status_result() {
     4926        check_ajax_referer( 'health-check-site-status-result' );
     4927
     4928        if ( ! current_user_can( 'install_plugins' ) ) {
     4929                wp_send_json_error();
     4930        }
     4931
     4932        set_transient( 'health-check-site-status-result', wp_json_encode( $_POST['counts'] ) );
     4933
     4934        wp_send_json_success();
     4935}
  • branches/5.1/src/wp-admin/menu.php

    r43223 r44984  
    257257        $submenu['tools.php'][10] = array( __( 'Import' ), 'import', 'import.php' );
    258258        $submenu['tools.php'][15] = array( __( 'Export' ), 'export', 'export.php' );
     259        $submenu['tools.php'][20] = array( __( 'Site Health' ), 'install_plugins', 'site-health.php' );
    259260if ( is_multisite() && ! is_main_site() ) {
    260261        $submenu['tools.php'][25] = array( __( 'Delete Site' ), 'delete_site', 'ms-delete-site.php' );
  • branches/5.1/src/wp-includes/script-loader.php

    r44763 r44984  
    16381638                );
    16391639
     1640                $scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
     1641
    16401642                $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
    16411643                did_action( 'init' ) && $scripts->localize(
     
    18831885        $styles->add( 'l10n', "/wp-admin/css/l10n$suffix.css" );
    18841886        $styles->add( 'code-editor', "/wp-admin/css/code-editor$suffix.css", array( 'wp-codemirror' ) );
     1887        $styles->add( 'site-health', "/wp-admin/css/site-health$suffix.css" );
    18851888
    18861889        $styles->add( 'wp-admin', false, array( 'dashicons', 'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus', 'widgets', 'site-icon', 'l10n' ) );
Note: See TracChangeset for help on using the changeset viewer.