WP_Site_Health::get_test_php_version()

Tests if the supplied PHP version is supported.


Return

(array) The test results.


Source

File: wp-admin/includes/class-wp-site-health.php

	public function get_test_php_version() {
		global $required_php_version;

		$result = array(
			'label'       => sprintf(
				/* translators: %s: The current PHP version. */
				__( 'Your site is running PHP version (%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 one of the programming languages used to build ClassicPress. Newer versions of PHP receive regular security updates and may increase your site&#8217;s performance. The minimum recommended version of PHP is %s.' ),
					$required_php_version
				)
			),
			'actions'     => sprintf(
				'<p><a href="%s" target="_blank" rel="noopener">%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: Hidden accessibility text. */
				__( '(opens in a new tab)' )
			),
			'test'        => 'php_version',
		);

		// PHP is up to date.
		if ( version_compare( PHP_VERSION, $required_php_version, '>=' ) ) {
			return $result;
		} else {
			// The PHP version is older than the recommended version.
			$result['label'] = sprintf(
				/* translators: %s: The server PHP version. */
				__( 'Your site is running on an older and unsupported version of PHP (%s), which should be updated' ),
				PHP_VERSION
			);
			$result['status'] = 'critical';

			return $result;
		}
	}

Changelog

Changelog
Version Description
5.2.0 Introduced.