Make WordPress Core


Ignore:
Timestamp:
03/04/2019 09:13:45 PM (5 years ago)
Author:
flixos90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/misc.php

    r44785 r44788  
    20172017 *
    20182018 * @since 5.1.0
     2019 * @since 5.1.1 Added the {@see 'wp_is_php_version_acceptable'} filter.
    20192020 *
    20202021 * @return array|false $response Array of PHP version data. False on failure.
     
    20552056    }
    20562057
     2058    if ( isset( $response['is_acceptable'] ) && $response['is_acceptable'] ) {
     2059        /**
     2060         * Filters whether the active PHP version is considered acceptable by WordPress.
     2061         *
     2062         * Returning false will trigger a PHP version warning to show up in the admin dashboard to administrators.
     2063         *
     2064         * This filter is only run if the wordpress.org Serve Happy API considers the PHP version acceptable, ensuring
     2065         * that this filter can only make this check stricter, but not loosen it.
     2066         *
     2067         * @since 5.1.1
     2068         *
     2069         * @param bool   $is_acceptable Whether the PHP version is considered acceptable. Default true.
     2070         * @param string $version       PHP version checked.
     2071         */
     2072        $response['is_acceptable'] = (bool) apply_filters( 'wp_is_php_version_acceptable', true, $version );
     2073    }
     2074
    20572075    return $response;
    20582076}
Note: See TracChangeset for help on using the changeset viewer.