WordPress.org

Make WordPress Core

Ticket #17682: 17682.2.diff

File 17682.2.diff, 2.6 KB (added by duck_, 7 years ago)
  • wp-admin/includes/dashboard.php

     
    2727
    2828        $response = wp_check_browser_version();
    2929
    30         if ( $response['upgrade'] ) {
     30        if ( $response && $response['upgrade'] ) {
    3131                add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' );
    3232                if ( $response['insecure'] )
    3333                        wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' );
     
    11621162        $notice = '';
    11631163        $response = wp_check_browser_version();
    11641164
    1165         if ( $response['insecure'] ) {
     1165        if ( $response && $response['insecure'] ) {
    11661166                $msg = sprintf( __( 'It looks like you\'re using an insecure version of <a href="%1$s">%2$s</a>. Using an outdated browser makes your computer unsafe.  For the best WordPress experience, please update your browser.' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ) );
    11671167        } else {
    11681168                $msg = sprintf( __( 'It looks like you\'re using an old version of <a href="%1$s">%2$s</a>. Using an outdated browser makes your computer unsafe.  For the best WordPress experience, please update your browser.' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ) );
     
    11861186function dashboard_browser_nag_class( $classes ) {
    11871187        $response = wp_check_browser_version();
    11881188
    1189         if ( $response['insecure'] )
     1189        if ( $response && $response['insecure'] )
    11901190                $classes[] = 'browser-insecure';
    11911191
    11921192        return $classes;
     
    11951195/**
    11961196 * Check if the user needs a browser update
    11971197 *
    1198  * @since 3.2
     1198 * @since 3.2.0
     1199 * @return array|bool Response array from api.wordpress.org or false on failure.
    11991200 */
    12001201function wp_check_browser_version() {
     1202        if ( ! isset( $_SERVER['HTTP_USER_AGENT'] ) )
     1203                return false;
     1204
    12011205        $key = md5( $_SERVER['HTTP_USER_AGENT'] );
    12021206
    12031207        if ( false === ($response = get_site_transient('browser_' . $key) ) ) {
     
    12151219
    12161220                /**
    12171221                 * Response should be an array with:
    1218                  *  'name' - string- A user friendly browser name
     1222                 *  'name' - string - A user friendly browser name
    12191223                 *  'version' - string - The most recent version of the browser
    12201224                 *  'current_version' - string - The version of the browser the user is using
    12211225                 *  'upgrade' - boolean - Whether the browser needs an upgrade
     
    12271231                $response = unserialize( wp_remote_retrieve_body( $response ) );
    12281232
    12291233                if ( ! $response )
    1230                         return;
     1234                        return false;
    12311235
    12321236                set_site_transient( 'browser_' . $key, $response, 604800 ); // cache for 1 week
    12331237        }