Make WordPress Core

Changeset 44986


Ignore:
Timestamp:
03/23/2019 03:54:16 AM (6 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:
trunk
Files:
7 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Gruntfile.js

    r44740 r44986  
    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' ],
  • trunk/src/wp-admin/admin-ajax.php

    r42986 r44986  
    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
  • trunk/src/wp-admin/css/wp-admin.css

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

    r44975 r44986  
    48594859    wp_send_json_success( $response );
    48604860}
     4861
     4862/**
     4863 * Ajax handler for site health checks on server communication.
     4864 *
     4865 * @since 5.2.0
     4866 */
     4867function wp_ajax_health_check_dotorg_communication() {
     4868    check_ajax_referer( 'health-check-site-status' );
     4869
     4870    if ( ! current_user_can( 'install_plugins' ) ) {
     4871        wp_send_json_error();
     4872    }
     4873
     4874    if ( ! class_exists( 'WP_Site_Health' ) ) {
     4875        require_once( ABSPATH . 'wp-admin/includes/class-wp-site-health.php' );
     4876    }
     4877
     4878    $site_health = new WP_Site_Health();
     4879    wp_send_json_success( $site_health->get_test_dotorg_communication() );
     4880}
     4881
     4882/**
     4883 * Ajax handler for site health checks on debug mode.
     4884 *
     4885 * @since 5.2.0
     4886 */
     4887function wp_ajax_health_check_is_in_debug_mode() {
     4888    wp_verify_nonce( 'health-check-site-status' );
     4889
     4890    if ( ! current_user_can( 'install_plugins' ) ) {
     4891        wp_send_json_error();
     4892    }
     4893
     4894    if ( ! class_exists( 'WP_Site_Health' ) ) {
     4895        require_once( ABSPATH . 'wp-admin/includes/class-wp-site-health.php' );
     4896    }
     4897
     4898    $site_health = new WP_Site_Health();
     4899    wp_send_json_success( $site_health->get_test_is_in_debug_mode() );
     4900}
     4901
     4902/**
     4903 * Ajax handler for site health checks on background updates.
     4904 *
     4905 * @since 5.2.0
     4906 */
     4907function wp_ajax_health_check_background_updates() {
     4908    check_ajax_referer( 'health-check-site-status' );
     4909
     4910    if ( ! current_user_can( 'install_plugins' ) ) {
     4911        wp_send_json_error();
     4912    }
     4913
     4914    if ( ! class_exists( 'WP_Site_Health' ) ) {
     4915        require_once( ABSPATH . 'wp-admin/includes/class-wp-site-health.php' );
     4916    }
     4917
     4918    $site_health = new WP_Site_Health();
     4919    wp_send_json_success( $site_health->get_test_background_updates() );
     4920}
     4921
     4922
     4923/**
     4924 * Ajax handler for site health checks on loopback requests.
     4925 *
     4926 * @since 5.2.0
     4927 */
     4928function wp_ajax_health_check_loopback_requests() {
     4929    check_ajax_referer( 'health-check-site-status' );
     4930
     4931    if ( ! current_user_can( 'install_plugins' ) ) {
     4932        wp_send_json_error();
     4933    }
     4934
     4935    if ( ! class_exists( 'WP_Site_Health' ) ) {
     4936        require_once( ABSPATH . 'wp-admin/includes/class-wp-site-health.php' );
     4937    }
     4938
     4939    $site_health = new WP_Site_Health();
     4940    wp_send_json_success( $site_health->get_test_loopback_requests() );
     4941}
     4942
     4943/**
     4944 * Ajax handler for site health check to update the result status.
     4945 *
     4946 * @since 5.2.0
     4947 */
     4948function wp_ajax_health_check_site_status_result() {
     4949    check_ajax_referer( 'health-check-site-status-result' );
     4950
     4951    if ( ! current_user_can( 'install_plugins' ) ) {
     4952        wp_send_json_error();
     4953    }
     4954
     4955    set_transient( 'health-check-site-status-result', wp_json_encode( $_POST['counts'] ) );
     4956
     4957    wp_send_json_success();
     4958}
  • trunk/src/wp-admin/menu.php

    r44924 r44986  
    264264    $submenu['tools.php'][10] = array( __( 'Import' ), 'import', 'import.php' );
    265265    $submenu['tools.php'][15] = array( __( 'Export' ), 'export', 'export.php' );
     266    $submenu['tools.php'][20] = array( __( 'Site Health' ), 'install_plugins', 'site-health.php' );
    266267if ( is_multisite() && ! is_main_site() ) {
    267268    $submenu['tools.php'][25] = array( __( 'Delete Site' ), 'delete_site', 'ms-delete-site.php' );
  • trunk/src/wp-includes/script-loader.php

    r44960 r44986  
    16891689        );
    16901690
     1691        $scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
     1692
    16911693        $scripts->add( 'updates', "/wp-admin/js/updates$suffix.js", array( 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
    16921694        did_action( 'init' ) && $scripts->localize(
     
    19341936    $styles->add( 'l10n', "/wp-admin/css/l10n$suffix.css" );
    19351937    $styles->add( 'code-editor', "/wp-admin/css/code-editor$suffix.css", array( 'wp-codemirror' ) );
     1938    $styles->add( 'site-health', "/wp-admin/css/site-health$suffix.css" );
    19361939
    19371940    $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.