wp_dashboard_plugins_output( string $rss, array $args = array() )
- Since
- 2.5.0
- Source
wp-admin/includes/deprecated.php:1328
Compatibility
Deprecated in WordPress 4.8.0. Kept for back-compatibility; avoid it in new code.
- 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.
Parameters
$rssstring- The RSS feed URL.
$argsarrayoptional- Array of arguments for this RSS feed.Default:
array()
Performance profile
How much work a call to wp_dashboard_plugins_output() 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
- Heavy
- Scaling
- Scales with input
- Instructions
- 25–38
- Plugin surface
- None
- Called by
- 0
Reads stored settings via get_option(), cached per request but not free on a cold cache.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 155.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- transienttransient
get_transient()called directly - hookthird-party callbacks
do_action()one call below wp_dashboard_plugins_output() - cacheobject cache
wp_cache_get()one call below wp_dashboard_plugins_output() - optionoption read or write
get_option()one call below wp_dashboard_plugins_output()
Further down the call graph this can also reach serialize 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 · 2 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_dashboard_plugins_output() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
$plugin_slugs !== false | 25–26 | _deprecated_function(), fetch_feed(), get_transient() |
$plugin_slugs === false | 37–38 | _deprecated_function(), fetch_feed(), get_transient(), get_plugins(), array_keys(), set_transient() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 155 | 25–38 | 12 | |
| 8.5 | 155 | 25–38 | 12 | |
| 8.4 | 155 | 25–38 | 12 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 161 | 25–38 | 12 | |
| 8.2 | 161 | 25–38 | 12 | 2 fewer instructions than PHP 8.1 |
| 8.1 | 163 | 25–38 | 13 | |
| 7.4 | 163 | 25–38 | 13 |
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.
Uses · 14
- _deprecated_function()Marks a function as deprecated and inform when it has been used.
- fetch_feed()Builds SimplePie object based on RSS or Atom feed from URL.
- get_transient()Retrieves the value of a transient.
- get_plugins()Checks the plugins directory and retrieve all plugin files with plugin data.
- set_transient()Sets/updates the value of a transient.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- esc_url()Checks and cleans a URL.
- str_starts_with()Polyfill for `str_starts_with()` function added in PHP 8.0.
- str_contains()Polyfill for `str_contains()` function added in PHP 8.0.
- wp_nonce_url()Retrieves URL with nonce added to URL query.
- __()Retrieves the translation of $text.
- esc_html()Escaping for HTML blocks.
Show all 14
- esc_attr()Escaping for HTML attributes.
- _x()Retrieves translated string with gettext context.
Source code
function wp_dashboard_plugins_output( $rss, $args = array() ) { _deprecated_function( __FUNCTION__, '4.8.0' ); // Plugin feeds plus link to install them. $popular = fetch_feed( $args['url']['popular'] ); if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) { $plugin_slugs = array_keys( get_plugins() ); set_transient( 'plugin_slugs', $plugin_slugs, DAY_IN_SECONDS ); } echo '<ul>'; foreach ( array( $popular ) as $feed ) { if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() ) continue; $items = $feed->get_items(0, 5); // Pick a random, non-installed plugin. while ( true ) { // Abort this foreach loop iteration if there's no plugins left of this type. if ( 0 === count($items) ) continue 2; $item_key = array_rand($items); $item = $items[$item_key]; list($link, $frag) = explode( '#', $item->get_link() ); $link = esc_url($link); if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) ) $slug = $matches[1]; else { unset( $items[$item_key] ); continue; } // Is this random plugin's slug already installed? If so, try again. reset( $plugin_slugs ); foreach ( $plugin_slugs as $plugin_slug ) { if ( str_starts_with( $plugin_slug, $slug ) ) { unset( $items[$item_key] ); continue 2; } } // If we get to this point, then the random plugin isn't installed and we can stop the while(). break; } // Eliminate some common badly formed plugin descriptions. while ( ( null !== $item_key = array_rand($items) ) && str_contains( $items[$item_key]->get_description(), 'Plugin Name:' ) ) unset($items[$item_key]); if ( !isset($items[$item_key]) ) continue; $raw_title = $item->get_title(); $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . '&TB_iframe=true&width=600&height=800'; echo '<li class="dashboard-news-plugin"><span>' . __( 'Popular Plugin' ) . ':</span> ' . esc_html( $raw_title ) . ' <a href="' . $ilink . '" class="thickbox open-plugin-details-modal" aria-label="' . /* translators: %s: Plugin name. */ esc_attr( sprintf( _x( 'Install %s', 'plugin' ), $raw_title ) ) . '">(' . __( 'Install' ) . ')</a></li>'; $feed->__destruct(); unset( $feed ); } echo '</ul>';}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/deprecated.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.