From f277e8c1680df04787f63ec5725c5366c76294e5 Mon Sep 17 00:00:00 2001 From: Clorith Date: Mon, 19 Sep 2022 15:30:09 +0000 Subject: [PATCH] Site Health: Improve the details provided by the REST API checks. The descriptions provided whenever a REST API check failed lacked details that would help in troubleshooting any issues, most notably the actual REST API endpoint that was being tested. Adding this vital piece of detail, along with a revamp of the error messages shown, where previously there was a risk that the markup of your website was included as an error message, improves the overall user experience, and gives more accurate details that can be looked when looking up how to fix or improve the behavior of the REST API. Props dingo_d, shetheliving. Fixes #54617. Built from https://develop.svn.wordpress.org/trunk@54205 git-svn-id: http://core.svn.wordpress.org/trunk@53764 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-site-health.php | 36 +++++++++++++--------- wp-includes/version.php | 2 +- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/wp-admin/includes/class-wp-site-health.php b/wp-admin/includes/class-wp-site-health.php index 302d1d112b..0db19027a0 100644 --- a/wp-admin/includes/class-wp-site-health.php +++ b/wp-admin/includes/class-wp-site-health.php @@ -2052,7 +2052,7 @@ class WP_Site_Health { ), 'description' => sprintf( '

%s

', - __( 'The REST API is one way WordPress, and other applications, communicate with the server. One example is the block editor screen, which relies on this to display, and save, your posts and pages.' ) + __( 'The REST API is one way that WordPress and other applications communicate with the server. For example, the block editor screen relies on the REST API to display and save your posts and pages.' ) ), 'actions' => '', 'test' => 'rest_availability', @@ -2090,16 +2090,18 @@ class WP_Site_Health { $result['label'] = __( 'The REST API encountered an error' ); $result['description'] .= sprintf( - '

%s

', + '

%s

%s
%s

', + __( 'When testing the REST API, an error was encountered:' ), sprintf( - '%s
%s', - __( 'The REST API request failed due to an error.' ), - sprintf( - /* translators: 1: The WordPress error message. 2: The WordPress error code. */ - __( 'Error: %1$s (%2$s)' ), - $r->get_error_message(), - $r->get_error_code() - ) + // translators: %s: The REST API URL. + __( 'REST API Endpoint: %s' ), + $url + ), + sprintf( + // translators: 1: The WordPress error code. 2: The WordPress error message. + __( 'REST API Response: (%1$s) %2$s' ), + $r->get_error_code(), + $r->get_error_message() ) ); } elseif ( 200 !== wp_remote_retrieve_response_code( $r ) ) { @@ -2108,12 +2110,18 @@ class WP_Site_Health { $result['label'] = __( 'The REST API encountered an unexpected result' ); $result['description'] .= sprintf( - '

%s

', + '

%s

%s
%s

', + __( 'When testing the REST API, an unexpected result was returned:' ), sprintf( - /* translators: 1: The HTTP error code. 2: The HTTP error message. */ - __( 'The REST API call gave the following unexpected result: (%1$d) %2$s.' ), + // translators: %s: The REST API URL. + __( 'REST API Endpoint: %s' ), + $url + ), + sprintf( + // translators: 1: The WordPress error code. 2: The HTTP status code error message. + __( 'REST API Response: (%1$s) %2$s' ), wp_remote_retrieve_response_code( $r ), - esc_html( wp_remote_retrieve_body( $r ) ) + wp_remote_retrieve_response_message( $r ) ) ); } else { diff --git a/wp-includes/version.php b/wp-includes/version.php index e66883dd6c..e4199e3d57 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-54204'; +$wp_version = '6.1-alpha-54205'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.