WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/23/2019 03:54:16 AM (5 months 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.