WordPress.org

Make WordPress Core

Changeset 18150


Ignore:
Timestamp:
06/05/2011 03:14:51 PM (7 years ago)
Author:
ryan
Message:

Check return value of wp_check_browser_version(). Make return value consistent. Props duck_, aaroncampbell. fixes #17682

File:
1 edited

Legend:

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

    r18010 r18150  
    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'] )
     
    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     }
    1170 
    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'];
    1174 
    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';
    1177     }
    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>';
     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        }
     1171
     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'];
     1175
     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>';
     1183    }
    11821184
    11831185    echo apply_filters( 'browse-happy-notice', $notice, $response );
     
    11871189    $response = wp_check_browser_version();
    11881190
    1189     if ( $response['insecure'] )
     1191    if ( $response && $response['insecure'] )
    11901192        $classes[] = 'browser-insecure';
    11911193
     
    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
     
    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
     
    12281235
    12291236        if ( ! $response )
    1230             return;
     1237            return false;
    12311238
    12321239        set_site_transient( 'browser_' . $key, $response, 604800 ); // cache for 1 week
Note: See TracChangeset for help on using the changeset viewer.