Skip to content

Commit 9f3e07c

Browse files
committed
Site Health: Improve messaging for PHP version status.
Previously, the status could be misleading, especially if the check against the WordPress.org API failed. The initial status message is now more neutral, and a dedicated check has been added to handle cases where the API is unreachable. Developed in #7350 Follow-up to [58832]. Props pbearne, joemcgill, mukesh27, peterwilsoncc, swb1192, krupajnanda, psykro, SergeyBiryukov, swissspidy, imranhasanraaz, amin7, flixos90, vgnavada, audrasjb, adamsilverstein, Presskopp, westonruter. Fixes #61623. git-svn-id: https://develop.svn.wordpress.org/trunk@61123 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 40bb201 commit 9f3e07c

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

src/wp-admin/includes/class-wp-site-health.php

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,8 @@ public function get_test_php_version() {
728728

729729
$result = array(
730730
'label' => sprintf(
731-
/* translators: %s: The recommended PHP version. */
732-
__( 'Your site is running a recommended version of PHP (%s)' ),
731+
/* translators: %s: The server PHP version. */
732+
__( 'Your site is running PHP %s' ),
733733
PHP_VERSION
734734
),
735735
'status' => 'good',
@@ -739,11 +739,7 @@ public function get_test_php_version() {
739739
),
740740
'description' => sprintf(
741741
'<p>%s</p>',
742-
sprintf(
743-
/* translators: %s: The minimum recommended PHP version. */
744-
__( 'PHP is one of the programming languages used to build WordPress. Newer versions of PHP receive regular security updates and may increase your site&#8217;s performance. The minimum recommended version of PHP is %s.' ),
745-
$response ? $response['recommended_version'] : ''
746-
)
742+
__( 'PHP is one of the programming languages used to build WordPress. Newer versions of PHP receive regular security updates and may increase your site&#8217;s performance.' )
747743
),
748744
'actions' => sprintf(
749745
'<p><a href="%s" target="_blank">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
@@ -755,8 +751,36 @@ public function get_test_php_version() {
755751
'test' => 'php_version',
756752
);
757753

754+
if ( ! $response ) {
755+
$result['label'] = sprintf(
756+
/* translators: %s: The server PHP version. */
757+
__( 'Unable to determine the status of the current PHP version (%s)' ),
758+
PHP_VERSION
759+
);
760+
$result['status'] = 'recommended';
761+
$result['description'] = '<p><em>' . sprintf(
762+
/* translators: %s is the URL to the Serve Happy docs page. */
763+
__( 'Unable to access the WordPress.org API for <a href="%s">Serve Happy</a>.' ),
764+
'https://codex.wordpress.org/WordPress.org_API#Serve_Happy'
765+
) . '</em></p>' . $result['description'];
766+
return $result;
767+
}
768+
769+
$result['description'] .= '<p>' . sprintf(
770+
/* translators: %s: The minimum recommended PHP version. */
771+
__( 'The minimum recommended version of PHP is %s.' ),
772+
$response['recommended_version']
773+
) . '</p>';
774+
758775
// PHP is up to date.
759-
if ( ! $response || version_compare( PHP_VERSION, $response['recommended_version'], '>=' ) ) {
776+
if ( version_compare( PHP_VERSION, $response['recommended_version'], '>=' ) ) {
777+
$result['label'] = sprintf(
778+
/* translators: %s: The server PHP version. */
779+
__( 'Your site is running a recommended version of PHP (%s)' ),
780+
PHP_VERSION
781+
);
782+
$result['status'] = 'good';
783+
760784
return $result;
761785
}
762786

0 commit comments

Comments
 (0)