wp_check_php_version(): array|false

In this article

Checks if the user needs to update PHP.

Return

array|false Array of PHP version data. False on failure.
  • recommended_version string
    The PHP version recommended by WordPress.
  • minimum_version string
    The minimum required PHP version.
  • is_supported bool
    Whether the PHP version is actively supported.
  • is_secure bool
    Whether the PHP version receives security updates.
  • is_acceptable bool
    Whether the PHP version is still acceptable or warnings should be shown and an update recommended.

Source

		if ( ! is_array( $response ) ) {
			return false;
		}

		set_site_transient( 'php_check_' . $key, $response, WEEK_IN_SECONDS );
	}

	if ( isset( $response['is_acceptable'] ) && $response['is_acceptable'] ) {
		/**
		 * Filters whether the active PHP version is considered acceptable by WordPress.
		 *
		 * Returning false will trigger a PHP version warning to show up in the admin dashboard to administrators.
		 *
		 * This filter is only run if the wordpress.org Serve Happy API considers the PHP version acceptable, ensuring
		 * that this filter can only make this check stricter, but not loosen it.
		 *
		 * @since 5.1.1
		 *
		 * @param bool   $is_acceptable Whether the PHP version is considered acceptable. Default true.
		 * @param string $version       PHP version checked.
		 */
		$response['is_acceptable'] = (bool) apply_filters( 'wp_is_php_version_acceptable', true, $version );
	}

	$response['is_lower_than_future_minimum'] = false;

	// The minimum supported PHP version will be updated to 7.4 in the future. Check if the current version is lower.
	if ( version_compare( $version, '7.4', '<' ) ) {
		$response['is_lower_than_future_minimum'] = true;

		// Force showing of warnings.
		$response['is_acceptable'] = false;
	}

	return $response;
}

Changelog

VersionDescription
5.1.1Added the 'wp_is_php_version_acceptable' filter.
5.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.