wp_dashboard_rss_control

The RSS dashboard widget control.

Description

wp_dashboard_rss_control( (string) $widget_id, (array) $form_inputs = array() ); 

Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data from RSS-type widgets.

Parameters (2)

0. $widget_id (string)
The widget id.
1. $form_inputs — Optional. (array) => array()
The form inputs.

Usage

  1. if ( !function_exists( 'wp_dashboard_rss_control' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/dashboard.php'; 
  3.  
  4. // The widget id. 
  5. $widget_id = ''; 
  6.  
  7. // The form inputs. 
  8. $form_inputs = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_dashboard_rss_control($widget_id, $form_inputs); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/dashboard.php  
  1. function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { 
  2. if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) 
  3. $widget_options = array(); 
  4.  
  5. if ( !isset($widget_options[$widget_id]) ) 
  6. $widget_options[$widget_id] = array(); 
  7.  
  8. $number = 1; // Hack to use wp_widget_rss_form() 
  9. $widget_options[$widget_id]['number'] = $number; 
  10.  
  11. if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) { 
  12. $_POST['widget-rss'][$number] = wp_unslash( $_POST['widget-rss'][$number] ); 
  13. $widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] ); 
  14. $widget_options[$widget_id]['number'] = $number; 
  15.  
  16. // Title is optional. If black, fill it if possible. 
  17. if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) { 
  18. $rss = fetch_feed($widget_options[$widget_id]['url']); 
  19. if ( is_wp_error($rss) ) { 
  20. $widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed')); 
  21. } else { 
  22. $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title())); 
  23. $rss->__destruct(); 
  24. unset($rss); 
  25. update_option( 'dashboard_widget_options', $widget_options ); 
  26. $cache_key = 'dash_' . md5( $widget_id ); 
  27. delete_transient( $cache_key ); 
  28.  
  29. wp_widget_rss_form( $widget_options[$widget_id], $form_inputs );