Make WordPress Core


Ignore:
Timestamp:
02/08/2019 01:52:17 AM (6 years ago)
Author:
peterwilsoncc
Message:

Admin: Improve logic of PHP version check on about page.

Props noisysocks, peterwilsoncc.
See #46161.

File:
1 edited

Legend:

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

    r44627 r44735  
    16651665
    16661666    return $classes;
    1667 }
    1668 
    1669 /**
    1670  * Checks if the user needs to update PHP.
    1671  *
    1672  * @since 5.1.0
    1673  *
    1674  * @return array|false $response Array of PHP version data. False on failure.
    1675  */
    1676 function wp_check_php_version() {
    1677     $version = phpversion();
    1678     $key     = md5( $version );
    1679 
    1680     $response = get_site_transient( 'php_check_' . $key );
    1681     if ( false === $response ) {
    1682         $url = 'http://api.wordpress.org/core/serve-happy/1.0/';
    1683         if ( wp_http_supports( array( 'ssl' ) ) ) {
    1684             $url = set_url_scheme( $url, 'https' );
    1685         }
    1686 
    1687         $url = add_query_arg( 'php_version', $version, $url );
    1688 
    1689         $response = wp_remote_get( $url );
    1690 
    1691         if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
    1692             return false;
    1693         }
    1694 
    1695         /**
    1696          * Response should be an array with:
    1697          *  'recommended_version' - string - The PHP version recommended by WordPress.
    1698          *  'is_supported' - boolean - Whether the PHP version is actively supported.
    1699          *  'is_secure' - boolean - Whether the PHP version receives security updates.
    1700          *  'is_acceptable' - boolean - Whether the PHP version is still acceptable for WordPress.
    1701          */
    1702         $response = json_decode( wp_remote_retrieve_body( $response ), true );
    1703 
    1704         if ( ! is_array( $response ) ) {
    1705             return false;
    1706         }
    1707 
    1708         set_site_transient( 'php_check_' . $key, $response, WEEK_IN_SECONDS );
    1709     }
    1710 
    1711     return $response;
    17121667}
    17131668
Note: See TracChangeset for help on using the changeset viewer.