Make WordPress Core


Ignore:
Timestamp:
06/08/2021 10:47:00 PM (5 years ago)
Author:
antpb
Message:

Administration: Introduce dashboard notice to discourage use of out of date browser.

If a browser matches Internet Explorer, the dashboard will display a notice recommending a more modern browser.

Props youknowriad, sabernhardt, afercia, SergeyBiryukov, davidbaumwald, netweb, johnbillion, jeherve.
See #48743.

File:
1 edited

Legend:

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

    r51025 r51117  
    16591659 *
    16601660 * @since 3.2.0
     1661 * @since 5.8.0 Display special message for Internet Explorer users.
     1662 *
     1663 * @global bool $is_IE
     1664 *
    16611665 */
    16621666function wp_dashboard_browser_nag() {
     1667        global $is_IE;
     1668
    16631669        $notice   = '';
    16641670        $response = wp_check_browser_version();
    16651671
    16661672        if ( $response ) {
    1667                 if ( $response['insecure'] ) {
     1673                if ( $is_IE ) {
     1674                        $msg = __( "For the best WordPress experience, please use Microsoft Edge or another modern browser instead of Internet Explorer." );
     1675                } elseif ( $response['insecure'] ) {
    16681676                        $msg = sprintf(
    16691677                                /* translators: %s: Browser name and link. */
    … …  
    16831691                        $img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) ) ? $response['img_src_ssl'] : $response['img_src'];
    16841692
    1685                         $notice           .= '<div class="alignright browser-icon"><a href="' . esc_attr( $response['update_url'] ) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>';
     1693                        $notice .= '<div class="alignright browser-icon"><img src="' . esc_attr( $img_src ) . '" alt="" /></div>';
    16861694                        $browser_nag_class = ' has-browser-icon';
    16871695                }
    … …  
    16941702                }
    16951703
    1696                 $notice .= '<p>' . sprintf(
    1697                         /* translators: 1: Browser update URL, 2: Browser name, 3: Browse Happy URL. */
    1698                         __( '<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>' ),
    1699                         esc_attr( $response['update_url'] ),
    1700                         esc_html( $response['name'] ),
    1701                         esc_url( $browsehappy )
    1702                 ) . '</p>';
     1704                if ( $is_IE ) {
     1705                        $msg_browsehappy = sprintf(
     1706                                /* translators: %s: Browse Happy URL. */
     1707                                __( 'Learn how to <a href="%s" class="update-browser-link">browse happy</a>' ),
     1708                                esc_url( $browsehappy )
     1709                        );
     1710                } else {
     1711                        $msg_browsehappy = sprintf(
     1712                                /* translators: 1: Browser update URL, 2: Browser name, 3: Browse Happy URL. */
     1713                                __( '<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>' ),
     1714                                esc_attr( $response['update_url'] ),
     1715                                esc_html( $response['name'] ),
     1716                                esc_url( $browsehappy )
     1717                        );
     1718                }
     1719
     1720                $notice .= '<p>' . $msg_browsehappy . '</p>';
    17031721                $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>';
    17041722                $notice .= '<div class="clear"></div>';
Note: See TracChangeset for help on using the changeset viewer.