Make WordPress Core

Changeset 61123


Ignore:
Timestamp:
11/04/2025 08:48:41 AM (3 weeks ago)
Author:
westonruter
Message:

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 https://github.com/WordPress/wordpress-develop/pull/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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-site-health.php

    r60938 r61123  
    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            ),
     
    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(
     
    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        }
Note: See TracChangeset for help on using the changeset viewer.