wp_dashboard_rss_control( string $widget_id, array $form_inputs = array() )
- Since
- 2.5.0
- Source
wp-admin/includes/dashboard.php:1270
Description
Handles POST data from RSS-type widgets.
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.
Parameters
$widget_idstring$form_inputsarrayoptional- Default:
array()
Performance profile
How much work a call to wp_dashboard_rss_control() 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
- Constant
- Instructions
- 23–103
- Plugin surface
- None
- Called by
- 0
Reaches the database via get_user_by().
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 113.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- optionoption read or write
get_option()called directly - transienttransient
delete_transient()called directly - hookthird-party callbacks
apply_filters()one call below wp_dashboard_rss_control() - cacheobject cache
wp_cache_get()one call below wp_dashboard_rss_control() - serializeserialisation
maybe_unserialize()one call below wp_dashboard_rss_control() - querycontent query
get_user_by()one call below wp_dashboard_rss_control()
What one call costs · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_dashboard_rss_control() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 23–30 | get_option(), wp_widget_rss_form() |
isset($value) | 70–78 | get_option(), wp_unslash(), wp_widget_rss_process(), update_option(), get_user_locale(), md5(), delete_transient(), wp_widget_rss_form() |
isset($value) && is_wp_error() | 96–99 | get_option(), wp_unslash(), wp_widget_rss_process(), fetch_feed(), is_wp_error(), __(), htmlentities(), update_option(), get_user_locale(), md5(), delete_transient(), wp_widget_rss_form() |
isset($value) && !is_wp_error() | 100–103 | get_option(), wp_unslash(), wp_widget_rss_process(), fetch_feed(), is_wp_error(), ->get_title(), strip_tags(), htmlentities(), ->__destruct(), update_option(), get_user_locale(), md5(), delete_transient(), wp_widget_rss_form() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 113 instructions, 23–103 executed per call, 7 branches. The work does not change between versions.
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 · 10
- get_option()Retrieves an option value based on an option name.
- wp_unslash()Removes slashes from a string or recursively removes slashes from strings within an array.
- wp_widget_rss_process()Processes RSS feed widget data and optionally retrieve feed items.
- fetch_feed()Builds SimplePie object based on RSS or Atom feed from URL.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- __()Retrieves the translation of $text.
- update_option()Updates the value of an option that was already added.
- get_user_locale()Retrieves the locale of a user.
- delete_transient()Deletes a transient.
- wp_widget_rss_form()Displays RSS widget options form.
Source code
function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { $widget_options = get_option( 'dashboard_widget_options' ); if ( ! $widget_options ) { $widget_options = array(); } if ( ! isset( $widget_options[ $widget_id ] ) ) { $widget_options[ $widget_id ] = array(); } $number = 1; // Hack to use wp_widget_rss_form(). $widget_options[ $widget_id ]['number'] = $number; if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget-rss'][ $number ] ) ) { $_POST['widget-rss'][ $number ] = wp_unslash( $_POST['widget-rss'][ $number ] ); $widget_options[ $widget_id ] = wp_widget_rss_process( $_POST['widget-rss'][ $number ] ); $widget_options[ $widget_id ]['number'] = $number; // Title is optional. If blank, fill it if possible. if ( ! $widget_options[ $widget_id ]['title'] && isset( $_POST['widget-rss'][ $number ]['title'] ) ) { $rss = fetch_feed( $widget_options[ $widget_id ]['url'] ); if ( is_wp_error( $rss ) ) { $widget_options[ $widget_id ]['title'] = htmlentities( __( 'Unknown Feed' ) ); } else { $widget_options[ $widget_id ]['title'] = htmlentities( strip_tags( $rss->get_title() ) ); $rss->__destruct(); unset( $rss ); } } update_option( 'dashboard_widget_options', $widget_options, false ); $locale = get_user_locale(); $cache_key = 'dash_v2_' . md5( $widget_id . '_' . $locale ); delete_transient( $cache_key ); } wp_widget_rss_form( $widget_options[ $widget_id ], $form_inputs );}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/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.