From 521c4a81a8b834b285e2ab6ab2e13affac528b17 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Mon, 4 Mar 2019 21:13:45 +0000 Subject: [PATCH] General: Introduce `wp_is_php_version_acceptable` filter to make the check for triggering PHP version warnings stricter. The filter is only run if the wordpress.org API considers the PHP version acceptable. This ensures that other plugins or hosting providers can only make this check stricter, but not loosen it. Props j-falk, mikeschroder. Fixes #46065. git-svn-id: https://develop.svn.wordpress.org/trunk@44788 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/misc.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/wp-admin/includes/misc.php b/src/wp-admin/includes/misc.php index 83f02988d0..c580c25c92 100644 --- a/src/wp-admin/includes/misc.php +++ b/src/wp-admin/includes/misc.php @@ -2016,6 +2016,7 @@ final class WP_Privacy_Policy_Content { * Checks if the user needs to update PHP. * * @since 5.1.0 + * @since 5.1.1 Added the {@see 'wp_is_php_version_acceptable'} filter. * * @return array|false $response Array of PHP version data. False on failure. */ @@ -2054,5 +2055,22 @@ function wp_check_php_version() { 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 ); + } + return $response; }