WordPress.org

Make WordPress Core

Ticket #17682: 17682.diff

File 17682.diff, 5.0 KB (added by aaroncampbell, 3 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'] ) { 
    1166                 $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'] ) ); 
    1167         } else { 
    1168                 $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'] ) ); 
    1169         } 
     1165        if ( $response ) { 
     1166                if ( $response['insecure'] ) { 
     1167                        $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'] ) ); 
     1168                } else { 
     1169                        $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'] ) ); 
     1170                } 
    11701171 
    1171         $browser_nag_class = ''; 
    1172         if ( !empty( $response['img_src'] ) ) { 
    1173                 $img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) )? $response['img_src_ssl'] : $response['img_src']; 
     1172                $browser_nag_class = ''; 
     1173                if ( !empty( $response['img_src'] ) ) { 
     1174                        $img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) )? $response['img_src_ssl'] : $response['img_src']; 
    11741175 
    1175                 $notice .= '<div class="alignright browser-icon"><a href="' . esc_attr($response['update_url']) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>'; 
    1176                 $browser_nag_class = ' has-browser-icon'; 
     1176                        $notice .= '<div class="alignright browser-icon"><a href="' . esc_attr($response['update_url']) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>'; 
     1177                        $browser_nag_class = ' has-browser-icon'; 
     1178                } 
     1179                $notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>"; 
     1180                $notice .= sprintf( __( '<p><a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a></p>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), 'http://browsehappy.com/' ); 
     1181                $notice .= '<p><a href="" class="dismiss">' . __( 'Dismiss' ) . '</a></p>'; 
     1182                $notice .= '<div class="clear"></div>'; 
    11771183        } 
    1178         $notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>"; 
    1179         $notice .= sprintf( __( '<p><a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a></p>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), 'http://browsehappy.com/' ); 
    1180         $notice .= '<p><a href="" class="dismiss">' . __( 'Dismiss' ) . '</a></p>'; 
    1181         $notice .= '<div class="clear"></div>'; 
    11821184 
    11831185        echo apply_filters( 'browse-happy-notice', $notice, $response ); 
    11841186} 
     
    11861188function dashboard_browser_nag_class( $classes ) { 
    11871189        $response = wp_check_browser_version(); 
    11881190 
    1189         if ( $response['insecure'] ) 
     1191        if ( $response && $response['insecure'] ) 
    11901192                $classes[] = 'browser-insecure'; 
    11911193 
    11921194        return $classes; 
     
    11961198 * Check if the user needs a browser update 
    11971199 * 
    11981200 * @since 3.2 
     1201 * 
     1202 * @return array|bool False on failure, array of browser data on success. 
    11991203 */ 
    12001204function wp_check_browser_version() { 
     1205        if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) 
     1206                return false; 
     1207 
    12011208        $key = md5( $_SERVER['HTTP_USER_AGENT'] ); 
    12021209 
    12031210        if ( false === ($response = get_site_transient('browser_' . $key) ) ) { 
     
    12151222 
    12161223                /** 
    12171224                 * Response should be an array with: 
    1218                  *  'name' - string- A user friendly browser name 
     1225                 *  'name' - string - A user friendly browser name 
    12191226                 *  'version' - string - The most recent version of the browser 
    12201227                 *  'current_version' - string - The version of the browser the user is using 
    12211228                 *  'upgrade' - boolean - Whether the browser needs an upgrade 
     
    12271234                $response = unserialize( wp_remote_retrieve_body( $response ) ); 
    12281235 
    12291236                if ( ! $response ) 
    1230                         return; 
     1237                        return false; 
    12311238 
    12321239                set_site_transient( 'browser_' . $key, $response, 604800 ); // cache for 1 week 
    12331240        }