wp_dashboard_browser_nag()
- Since
- 3.2.0, 5.8.0
- Source
wp-admin/includes/dashboard.php:1712
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
- Scaling
- Constant
- Instructions
- 13–115
- Plugin surface
- 1 hook
- Called by
- 0
Reaches an outbound HTTP request via wp_remote_post().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 156.
Third-party callbacks on 'browse-happy-notice' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()called directly - transienttransient
get_site_transient()one call below wp_dashboard_browser_nag() - httpoutbound HTTP request
wp_remote_post()one call below wp_dashboard_browser_nag() - querycontent query
get_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.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 13 | wp_check_browser_version(), apply_filters() |
empty($response) && $locale === "en_US" | 62 | wp_check_browser_version(), __(), get_user_locale(), __(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters() |
empty($response) && $locale !== "en_US" | 68 | wp_check_browser_version(), __(), get_user_locale(), add_query_arg(), __(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters() |
empty($response) && $locale === "en_US" | 73 | wp_check_browser_version(), __(), get_user_locale(), __(), esc_attr(), esc_html(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters() |
!empty($response) && $locale === "en_US" | 74–77 | wp_check_browser_version(), __(), is_ssl(), esc_url(), get_user_locale(), __(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters() |
empty($response) && $locale !== "en_US" | 79 | wp_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–83 | wp_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–83 | wp_check_browser_version(), __(), esc_url(), esc_html(), sprintf(), get_user_locale(), __(), esc_url(), sprintf(), esc_attr__(), __(), apply_filters() |
!empty($response) && $locale === "en_US" | 85–88 | wp_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–89 | wp_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–94 | wp_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–94 | wp_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–98 | wp_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–100 | wp_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–104 | wp_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–109 | wp_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–115 | wp_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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 156 | 13–115 | 8 | |
| 8.5 | 156 | 13–115 | 8 | |
| 8.4 | 156 | 13–115 | 8 | |
| 8.3 | 156 | 13–115 | 8 | |
| 8.2 | 156 | 13–115 | 8 | |
| 8.1 | 156 | 13–115 | 8 | 2 fewer instructions than PHP 7.4 |
| 7.4 | 158 | 13–116 | 8 |
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:
- apply_filters( browse-happy-notice )filterline 1780 (+68 into the body)
Filters the notice output for the 'Browse Happy' nag meta box.
Uses · 10
- wp_check_browser_version()Checks if the user needs a browser update.
- __()Retrieves the translation of $text.
- esc_url()Checks and cleans a URL.
- esc_html()Escaping for HTML blocks.
- is_ssl()Determines if SSL is used.
- get_user_locale()Retrieves the locale of a user.
- add_query_arg()Retrieves a modified URL query string.
- esc_attr()Escaping for HTML attributes.
- esc_attr__()Retrieves the translation of $text and escapes it for safe use in an attribute.
- apply_filters()Calls the callback functions that have been added to a filter hook.
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.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 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.