wppaste
WordPress

wp_dashboard_browser_nag()

Since
3.2.0, 5.8.0
Source
wp-admin/includes/dashboard.php:1723
Displays the browser update nag.

Compatibility

WordPress
since 5.8.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Performance profile

How much work a call to wp_dashboard_browser_nag() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Expensive

Reaches an outbound HTTP request via wp_remote_post().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
13–115

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 156.

Plugin surface
1 hook

Third-party callbacks on 'browse-happy-notice' run inside this call, and their cost is not bounded by anything here.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • transienttransientget_site_transient()one call below wp_dashboard_browser_nag()
  • httpoutbound HTTP requestwp_remote_post()one call below wp_dashboard_browser_nag()
  • querycontent queryget_user_by()one call below wp_dashboard_browser_nag()

Further down the call graph this can also reach cache, option and serialize. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 17 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_dashboard_browser_nag() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always13wp_check_browser_version(), apply_filters()
empty($response) && $locale === "en_US"62wp_check_browser_version(), __(), get_user_locale(), __(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters()
empty($response) && $locale !== "en_US"68wp_check_browser_version(), __(), get_user_locale(), add_query_arg(), __(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters()
empty($response) && $locale === "en_US"73wp_check_browser_version(), __(), get_user_locale(), __(), esc_attr(), esc_html(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters()
!empty($response) && $locale === "en_US"74–77wp_check_browser_version(), __(), is_ssl(), esc_url(), get_user_locale(), __(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters()
empty($response) && $locale !== "en_US"79wp_check_browser_version(), __(), get_user_locale(), add_query_arg(), __(), esc_attr(), esc_html(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters()
!empty($response) && $locale !== "en_US"80–83wp_check_browser_version(), __(), is_ssl(), esc_url(), get_user_locale(), add_query_arg(), __(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters()
empty($response) && $locale === "en_US"82–83wp_check_browser_version(), __(), esc_url(), esc_html(), sprintf(), get_user_locale(), __(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters()
!empty($response) && $locale === "en_US"85–88wp_check_browser_version(), __(), is_ssl(), esc_url(), get_user_locale(), __(), esc_attr(), esc_html(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters()
empty($response) && $locale !== "en_US"88–89wp_check_browser_version(), __(), esc_url(), esc_html(), sprintf(), get_user_locale(), add_query_arg(), __(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters()
!empty($response) && $locale !== "en_US"91–94wp_check_browser_version(), __(), is_ssl(), esc_url(), get_user_locale(), add_query_arg(), __(), esc_attr(), esc_html(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters()
empty($response) && $locale === "en_US"93–94wp_check_browser_version(), __(), esc_url(), esc_html(), sprintf(), get_user_locale(), __(), esc_attr(), esc_html(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters()
5 further outcomes, up to 115 instructions
!empty($response) && $locale === "en_US"94–98wp_check_browser_version(), __(), esc_url(), esc_html(), sprintf(), is_ssl(), esc_url(), get_user_locale(), __(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters()
empty($response) && $locale !== "en_US"99–100wp_check_browser_version(), __(), esc_url(), esc_html(), sprintf(), get_user_locale(), add_query_arg(), __(), esc_attr(), esc_html(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters()
!empty($response) && $locale !== "en_US"100–104wp_check_browser_version(), __(), esc_url(), esc_html(), sprintf(), is_ssl(), esc_url(), get_user_locale(), add_query_arg(), __(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters()
!empty($response) && $locale === "en_US"105–109wp_check_browser_version(), __(), esc_url(), esc_html(), sprintf(), is_ssl(), esc_url(), get_user_locale(), __(), esc_attr(), esc_html(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters()
!empty($response) && $locale !== "en_US"111–115wp_check_browser_version(), __(), esc_url(), esc_html(), sprintf(), is_ssl(), esc_url(), get_user_locale(), add_query_arg(), __(), esc_attr(), esc_html(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev15613–1158
8.515613–1158
8.415613–1158
8.315613–1158
8.215613–1158
8.115613–11582 fewer instructions than PHP 7.4
7.415813–1168

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 1

One hook fires while wp_dashboard_browser_nag() runs, in this order:

  1. apply_filters( browse-happy-notice )filterline 1791 (+68 into the body)

    Filters the notice output for the 'Browse Happy' nag meta box.

Uses · 10

Source code

function wp_dashboard_browser_nag() {	global $is_IE; 	$notice   = '';	$response = wp_check_browser_version(); 	if ( $response ) {		if ( $is_IE ) {			$msg = __( 'Internet Explorer does not give you the best WordPress experience. Switch to Microsoft Edge, or another more modern browser to get the most from your site.' );		} elseif ( $response['insecure'] ) {			$msg = sprintf(				/* translators: %s: Browser name and link. */				__( "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." ),				sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )			);		} else {			$msg = sprintf(				/* translators: %s: Browser name and link. */				__( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ),				sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) )			);		} 		$browser_nag_class = '';		if ( ! empty( $response['img_src'] ) ) {			$img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) ) ? $response['img_src_ssl'] : $response['img_src']; 			$notice           .= '<div class="alignright browser-icon"><img src="' . esc_url( $img_src ) . '" alt="" /></div>';			$browser_nag_class = ' has-browser-icon';		}		$notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>"; 		$browsehappy = 'https://browsehappy.com/';		$locale      = get_user_locale();		if ( 'en_US' !== $locale ) {			$browsehappy = add_query_arg( 'locale', $locale, $browsehappy );		} 		if ( $is_IE ) {			$msg_browsehappy = sprintf(				/* translators: %s: Browse Happy URL. */				__( 'Learn how to <a href="%s" class="update-browser-link">browse happy</a>' ),				esc_url( $browsehappy )			);		} else {			$msg_browsehappy = sprintf(				/* translators: 1: Browser update URL, 2: Browser name, 3: Browse Happy URL. */				__( '<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 )			);		} 		$notice .= '<p>' . $msg_browsehappy . '</p>';		$notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>';		$notice .= '<div class="clear"></div>';	} 	/**	 * Filters the notice output for the 'Browse Happy' nag meta box.	 *	 * @since 3.2.0	 *	 * @param string      $notice   The notice content.	 * @param array|false $response An array containing web browser information, or	 *                              false on failure. See wp_check_browser_version().	 */	echo apply_filters( 'browse-happy-notice', $notice, $response ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores}

Changelog

Introduced in 3.2.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

5.8.0
Added a special message for Internet Explorer users.from the docblock
3.2.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-admin/includes/dashboard.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.