wp_dashboard_browser_nag

The WordPress Core wp dashboard browser nag function.

Description

wp_dashboard_browser_nag(); 

Usage

  1. if ( !function_exists( 'wp_dashboard_browser_nag' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/dashboard.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_dashboard_browser_nag(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/dashboard.php  
  1. function wp_dashboard_browser_nag() { 
  2. $notice = ''; 
  3. $response = wp_check_browser_version(); 
  4.  
  5. if ( $response ) { 
  6. if ( $response['insecure'] ) { 
  7. /** translators: %s: browser name and link */ 
  8. $msg = sprintf( __( "It looks like you're using an insecure version of %s. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ),  
  9. sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) ) 
  10. ); 
  11. } else { 
  12. /** translators: %s: browser name and link */ 
  13. $msg = sprintf( __( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ),  
  14. sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) ) 
  15. ); 
  16.  
  17. $browser_nag_class = ''; 
  18. if ( !empty( $response['img_src'] ) ) { 
  19. $img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) )? $response['img_src_ssl'] : $response['img_src']; 
  20.  
  21. $notice .= '<div class="alignright browser-icon"><a href="' . esc_attr($response['update_url']) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>'; 
  22. $browser_nag_class = ' has-browser-icon'; 
  23. $notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>"; 
  24.  
  25. $browsehappy = 'http://browsehappy.com/'; 
  26. $locale = get_user_locale(); 
  27. if ( 'en_US' !== $locale ) 
  28. $browsehappy = add_query_arg( 'locale', $locale, $browsehappy ); 
  29.  
  30. $notice .= '<p>' . sprintf( __( '<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>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '</p>'; 
  31. $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>'; 
  32. $notice .= '<div class="clear"></div>'; 
  33.  
  34. /** 
  35. * Filters the notice output for the 'Browse Happy' nag meta box. 
  36. * @since 3.2.0 
  37. * @param string $notice The notice content. 
  38. * @param array $response An array containing web browser information. 
  39. */ 
  40. echo apply_filters( 'browse-happy-notice', $notice, $response );