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
This commit is contained in:
Felix Arntz 2019-03-04 21:13:45 +00:00
parent 0e59ee558d
commit 521c4a81a8
1 changed files with 18 additions and 0 deletions

View File

@ -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;
}