Source
File: wp-admin/includes/class-wp-site-health.php
public function get_test_php_version() {
$response = wp_check_php_version();
$result = array(
'label' => sprintf(
/* translators: %s: The current PHP version. */
__( 'Your site is running the current version of PHP (%s)' ),
PHP_VERSION
),
'status' => 'good',
'badge' => array(
'label' => __( 'Performance' ),
'color' => 'blue',
),
'description' => sprintf(
'<p>%s</p>',
sprintf(
/* translators: %s: The minimum recommended PHP version. */
__( 'PHP is the programming language used to build and maintain WordPress. Newer versions of PHP are faster and more secure, so staying up to date will help your site’s overall performance and security. The minimum recommended version of PHP is %s.' ),
$response ? $response['recommended_version'] : ''
)
),
'actions' => sprintf(
'<p><a href="%s" target="_blank" rel="noopener noreferrer">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
esc_url( wp_get_update_php_url() ),
__( 'Learn more about updating PHP' ),
/* translators: Accessibility text. */
__( '(opens in a new tab)' )
),
'test' => 'php_version',
);
// PHP is up to date.
if ( ! $response || version_compare( PHP_VERSION, $response['recommended_version'], '>=' ) ) {
return $result;
}
// The PHP version is older than the recommended version, but still receiving active support.
if ( $response['is_supported'] ) {
$result['label'] = sprintf(
/* translators: %s: The server PHP version. */
__( 'Your site is running an older version of PHP (%s)' ),
PHP_VERSION
);
$result['status'] = 'recommended';
return $result;
}
// The PHP version is only receiving security fixes.
if ( $response['is_secure'] ) {
$result['label'] = sprintf(
/* translators: %s: The server PHP version. */
__( 'Your site is running an older version of PHP (%s), which should be updated' ),
PHP_VERSION
);
$result['status'] = 'recommended';
return $result;
}
// Anything no longer secure must be updated.
$result['label'] = sprintf(
/* translators: %s: The server PHP version. */
__( 'Your site is running an outdated version of PHP (%s), which requires an update' ),
PHP_VERSION
);
$result['status'] = 'critical';
$result['badge']['label'] = __( 'Security' );
return $result;
}