Skip to content
Permalink
Browse files

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.

Merges [44788] to the 5.1 branch.

Props j-falk, mikeschroder.
Fixes #46065.


git-svn-id: https://develop.svn.wordpress.org/branches/5.1@44789 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
felixarntz committed Mar 4, 2019
1 parent c6cd9f8 commit 11b3b4bca896ef61255169bd788ace8fffff6bf0
Showing with 18 additions and 0 deletions.
  1. +18 −0 src/wp-admin/includes/misc.php
@@ -2016,6 +2016,7 @@ public static function add_suggested_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;
}

0 comments on commit 11b3b4b

Please sign in to comment.
You can’t perform that action at this time.