WordPress.org

Make WordPress Core

Ticket #17323: 17323.3.diff

File 17323.3.diff, 2.0 KB (added by aaroncampbell, 7 years ago)

Should be === not !===

  • wp-admin/includes/update.php

     
    309309}
    310310add_action( 'admin_notices', 'maintenance_nag' );
    311311
     312/**
     313 * Display a nag in the footer if the user is using an outdated browser.  If
     314 * that browser is IE < 8 mention that it is insecure
     315 *
     316 * @since 3.1.2
     317 */
     318function browser_upgrade_nag() {
     319        $key = md5( $_SERVER['HTTP_USER_AGENT'] );
     320
     321        if ( false === ($response = get_site_transient('browsehappy_' . $key) ) ) {
     322
     323                $options = array(
     324                        'body'                  => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ),
     325                        'user-agent'    => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
     326                );
     327
     328                $raw_response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.0/', $options );
     329
     330                if ( is_wp_error( $raw_response ) || 200 != $raw_response['response']['code'] )
     331                        return;
     332
     333                /**
     334                 * Response should be an array with:
     335                 *  'name' - string- A user friendly browser name
     336                 *  'version' - string - The most recent version of the browser
     337                 *  'upgrade' - boolean - Whether the browser needs an upgrade
     338                 *  'insecure' - boolean - Whether the browser is deemed insecure
     339                 */
     340                $response = unserialize( $raw_response['body'] );
     341
     342                if ( ! $response )
     343                        return;
     344
     345                set_site_transient( 'browsehappy_' . $key, $response, 604800 ); // cache for 1 week
     346        }
     347
     348        if ( ! $response['upgrade'] )
     349                return;
     350
     351        if ( $response['insecure'] ) {
     352                $msg = sprintf( __( 'Your version of %s is insecure.  WordPress recommends an update.' ), $response['name'] );
     353        } else {
     354                $msg = sprintf( __( 'Your version of %s is out of date.  WordPress recommends an update.' ), $response['name'] );
     355        }
     356
     357        echo apply_filters( 'browse-happy-notice', '<div id="bh"><a href="http://browsehappy.com/" title="' . esc_attr__( 'Browse Happy' ) . '">' . esc_html( $msg ) . '</a></div>' );
     358}
     359add_action( 'admin_footer', 'browser_upgrade_nag' );
     360
    312361?>