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.

Built from https://develop.svn.wordpress.org/branches/5.1@44789


git-svn-id: http://core.svn.wordpress.org/branches/5.1@44621 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Felix Arntz 2019-03-04 21:23:51 +00:00
parent 50cc2a57f6
commit f0c5c319e4
2 changed files with 19 additions and 1 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;
}

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.1.1-alpha-44783';
$wp_version = '5.1.1-alpha-44789';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.