Health Check - Version 1.2.3

Version Description

Download this release

Release Info

Developer Clorith
Plugin Icon 128x128 Health Check
Version 1.2.3
Comparing to
See all releases

Code changes from version 1.2.2 to 1.2.3

health-check.php CHANGED
@@ -9,7 +9,7 @@
9
  * Plugin URI: http://wordpress.org/plugins/health-check/
10
  * Description: Checks the health of your WordPress install.
11
  * Author: The WordPress.org community
12
- * Version: 1.2.2
13
  * Author URI: http://wordpress.org/plugins/health-check/
14
  * Text Domain: health-check
15
  */
@@ -35,7 +35,7 @@ define( 'HEALTH_CHECK_MYSQL_MIN_VERSION', '5.0' );
35
  define( 'HEALTH_CHECK_MYSQL_REC_VERSION', '5.6' );
36
 
37
  // Set the plugin version.
38
- define( 'HEALTH_CHECK_PLUGIN_VERSION', '1.2.2' );
39
 
40
  // Set the absolute path for the plugin.
41
  define( 'HEALTH_CHECK_PLUGIN_DIRECTORY', plugin_dir_path( __FILE__ ) );
9
  * Plugin URI: http://wordpress.org/plugins/health-check/
10
  * Description: Checks the health of your WordPress install.
11
  * Author: The WordPress.org community
12
+ * Version: 1.2.3
13
  * Author URI: http://wordpress.org/plugins/health-check/
14
  * Text Domain: health-check
15
  */
35
  define( 'HEALTH_CHECK_MYSQL_REC_VERSION', '5.6' );
36
 
37
  // Set the plugin version.
38
+ define( 'HEALTH_CHECK_PLUGIN_VERSION', '1.2.3' );
39
 
40
  // Set the absolute path for the plugin.
41
  define( 'HEALTH_CHECK_PLUGIN_DIRECTORY', plugin_dir_path( __FILE__ ) );
includes/class-health-check-site-status.php CHANGED
@@ -633,6 +633,60 @@ class Health_Check_Site_Status {
633
  }
634
  }
635
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
636
  public function test_ssl_support() {
637
  $supports_https = wp_http_supports( array( 'ssl' ) );
638
 
633
  }
634
  }
635
 
636
+ public function test_rest_availability() {
637
+ $cookies = wp_unslash( $_COOKIE );
638
+ $timeout = 10;
639
+ $headers = array(
640
+ 'Cache-Control' => 'no-cache',
641
+ );
642
+
643
+ // Include Basic auth in loopback requests.
644
+ if ( isset( $_SERVER['PHP_AUTH_USER'] ) && isset( $_SERVER['PHP_AUTH_PW'] ) ) {
645
+ $headers['Authorization'] = 'Basic ' . base64_encode( wp_unslash( $_SERVER['PHP_AUTH_USER'] ) . ':' . wp_unslash( $_SERVER['PHP_AUTH_PW'] ) );
646
+ }
647
+
648
+ $url = rest_url( 'wp/v2/posts' );
649
+
650
+ // We only need the first post to ensure this works, to make it low impact.
651
+ $url = add_query_arg( array(
652
+ 'per_page' => 1,
653
+ ), $url );
654
+
655
+ $r = wp_remote_get( $url, compact( 'cookies', 'headers', 'timeout' ) );
656
+
657
+ if ( is_wp_error( $r ) ) {
658
+ printf(
659
+ '<span class="error"></span> %s',
660
+ sprintf(
661
+ '%s<br>%s',
662
+ esc_html__( 'The REST API request failed due to an error.', 'health-check' ),
663
+ sprintf(
664
+ /* translators: %1$d: The HTTP response code. %2$s: The error message returned. */
665
+ esc_html__( 'Error encountered: (%1$d) %2$s', 'health-check' ),
666
+ wp_remote_retrieve_response_code( $r ),
667
+ $r->get_error_message()
668
+ )
669
+ )
670
+ );
671
+ } elseif ( 200 !== wp_remote_retrieve_response_code( $r ) ) {
672
+ printf(
673
+ '<span class="warning"></span> %s',
674
+ sprintf(
675
+ /* translators: %1$d: The HTTP response code returned. %2$s: The error message returned. */
676
+ esc_html__( 'The REST API call gave the following unexpected result: (%1$d) %2$s.', 'health-check' ),
677
+ wp_remote_retrieve_response_code( $r ),
678
+ wp_remote_retrieve_body( $r )
679
+ )
680
+ );
681
+ } else {
682
+
683
+ printf(
684
+ '<span class="good"></span> %s',
685
+ __( 'The REST API is available.', 'health-check' )
686
+ );
687
+ }
688
+ }
689
+
690
  public function test_ssl_support() {
691
  $supports_https = wp_http_supports( array( 'ssl' ) );
692
 
pages/site-status.php CHANGED
@@ -71,11 +71,18 @@ if ( ! defined( 'ABSPATH' ) ) {
71
  </tr>
72
 
73
  <tr>
74
- <td><?php esc_html_e( 'Communication with WordPress.org', 'health-check' ); ?></td>
75
- <td class="health-check-site-status-test" data-site-status="dotorg_communication">
76
- <span class="spinner is-active"></span>
77
- </td>
78
- </tr>
 
 
 
 
 
 
 
79
 
80
  <tr>
81
  <td><?php esc_html_e( 'HTTPS status', 'health-check' ); ?></td>
71
  </tr>
72
 
73
  <tr>
74
+ <td><?php esc_html_e( 'Communication with WordPress.org', 'health-check' ); ?></td>
75
+ <td class="health-check-site-status-test" data-site-status="dotorg_communication">
76
+ <span class="spinner is-active"></span>
77
+ </td>
78
+ </tr>
79
+
80
+ <tr>
81
+ <td><?php esc_html_e( 'REST API availability', 'health-check' ); ?></td>
82
+ <td class="health-check-site-status-test" data-site-status="rest_availability">
83
+ <span class="spinner is-active"></span>
84
+ </td>
85
+ </tr>
86
 
87
  <tr>
88
  <td><?php esc_html_e( 'HTTPS status', 'health-check' ); ?></td>
readme.txt CHANGED
@@ -3,7 +3,7 @@ Tags: health check
3
  Contributors: wordpressdotorg, westi, pento, Clorith
4
  Requires at least: 4.0
5
  Tested up to: 5.0
6
- Stable tag: 1.2.2
7
  License: GPLv2
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -37,6 +37,9 @@ Are you unfamiliar with how to clear your cookies? No worries, you may also clos
37
 
38
  == Changelog ==
39
 
 
 
 
40
  = v 1.2.2 =
41
  * Added Twenty Nineteen as a recognized core theme.
42
 
3
  Contributors: wordpressdotorg, westi, pento, Clorith
4
  Requires at least: 4.0
5
  Tested up to: 5.0
6
+ Stable tag: 1.2.3
7
  License: GPLv2
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
37
 
38
  == Changelog ==
39
 
40
+ = v1.2.3 =
41
+ * Added REST API availability test to the Site Status
42
+
43
  = v 1.2.2 =
44
  * Added Twenty Nineteen as a recognized core theme.
45