update_right_now_message()
- Since
- 2.5.0
- Source
wp-admin/includes/update.php:358
Compatibility
- WordPress
- since 2.5.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 update_right_now_message() 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
- Moderate
- Scaling
- Constant
- Instructions
- 37–72
- Plugin surface
- 1 hook
- Called by
- 1
Reads stored settings via get_option(), cached per request but not free on a cold cache.
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 74.
Third-party callbacks on 'update_right_now_text' run inside this call, and their cost is not bounded by anything here.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly - optionoption read or write
get_option()one call below update_right_now_message()
Further down the call graph this can also reach cache, serialize, transient and query. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 8 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost update_right_now_message() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!current_user_can() | 37 | wp_get_theme(), current_user_can(), __(), apply_filters(), get_bloginfo(), sprintf(), current_user_can() |
| always | 42–45 | wp_get_theme(), current_user_can(), __(), apply_filters(), get_bloginfo(), sprintf(), current_user_can(), get_preferred_from_update_core() |
| always | 42 | wp_get_theme(), current_user_can(), sprintf(), __(), apply_filters(), get_bloginfo(), sprintf(), current_user_can() |
current_user_can() | 47–50 | wp_get_theme(), current_user_can(), sprintf(), __(), apply_filters(), get_bloginfo(), sprintf(), current_user_can(), get_preferred_from_update_core() |
isset($cur) && $cur | 65 | wp_get_theme(), current_user_can(), __(), apply_filters(), get_bloginfo(), sprintf(), current_user_can(), get_preferred_from_update_core(), network_admin_url(), __(), sprintf() |
isset($cur) && !$cur | 67 | wp_get_theme(), current_user_can(), __(), apply_filters(), get_bloginfo(), sprintf(), current_user_can(), get_preferred_from_update_core(), network_admin_url(), __(), __(), sprintf() |
current_user_can() && isset($cur) && $cur | 70 | wp_get_theme(), current_user_can(), sprintf(), __(), apply_filters(), get_bloginfo(), sprintf(), current_user_can(), get_preferred_from_update_core(), network_admin_url(), __(), sprintf() |
current_user_can() && isset($cur) && !$cur | 72 | wp_get_theme(), current_user_can(), sprintf(), __(), apply_filters(), get_bloginfo(), sprintf(), current_user_can(), get_preferred_from_update_core(), network_admin_url(), __(), __(), sprintf() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 73 | 37–71 | 5 | 1 fewer instruction than PHP 8.5 |
| 8.5 | 74 | 37–72 | 5 | |
| 8.4 | 74 | 37–72 | 5 | |
| 8.3 | 74 | 37–72 | 5 | |
| 8.2 | 74 | 37–72 | 5 | |
| 8.1 | 74 | 37–72 | 5 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 75 | 37–72 | 5 |
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 update_right_now_message() runs, in this order:
- apply_filters( update_right_now_text )filterline 377 (+19 into the body)
Filters the text displayed in the 'At a Glance' dashboard widget.
Uses · 7
- wp_get_theme()Gets a WP_Theme object for a theme.
- current_user_can()Returns whether the current user has the specified capability.
- __()Retrieves the translation of $text.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- get_bloginfo()Retrieves information about the current site.
- get_preferred_from_update_core()Selects the first update version from the update_core option.
- network_admin_url()Retrieves the URL to the admin area for the network.
Used by · 1
- wp_dashboard_right_now()Dashboard widget that displays some basic stats about the site.
Source code
function update_right_now_message() { $theme_name = wp_get_theme(); if ( current_user_can( 'switch_themes' ) ) { $theme_name = sprintf( '<a href="themes.php">%1$s</a>', $theme_name ); } /* translators: 1: Version number, 2: Theme name. */ $content = __( 'WordPress %1$s running %2$s theme.' ); /** * Filters the text displayed in the 'At a Glance' dashboard widget. * * Prior to 3.8.0, the widget was named 'Right Now'. * * @since 4.4.0 * * @param string $content Default text. */ $content = apply_filters( 'update_right_now_text', $content ); $msg = sprintf( '<span id="wp-version">' . $content . '</span>', get_bloginfo( 'version', 'display' ), $theme_name ); if ( current_user_can( 'update_core' ) ) { $cur = get_preferred_from_update_core(); if ( isset( $cur->response ) && 'upgrade' === $cur->response ) { $msg .= sprintf( '<a href="%s" class="button" aria-describedby="wp-version">%s</a>', network_admin_url( 'update-core.php' ), /* translators: %s: WordPress version number, or 'Latest' string. */ sprintf( __( 'Update to %s' ), $cur->current ? $cur->current : __( 'Latest' ) ) ); } } echo "<p id='wp-version-message'>$msg</p>";}Changelog
Introduced in 2.5.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 7.1.0 tag, from
src/wp-admin/includes/update.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.