wp_widget_rss_form

Display RSS widget options form.

Description

wp_widget_rss_form( (array|string) $args, (null) $inputs = null ); 

The options for what fields are displayed for the RSS form are all booleans and are as follows: url,, title, items, show_summary, show_author, 'show_date'.

Parameters (2)

0. $args (array|string)
Values for input fields.
1. $inputs — Optional. (null) => null
Override default display options.

Usage

  1. if ( !function_exists( 'wp_widget_rss_form' ) ) { 
  2. require_once ABSPATH . WPINC . '/widgets.php'; 
  3.  
  4. // Values for input fields. 
  5. $args = null; 
  6.  
  7. // Override default display options. 
  8. $inputs = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_widget_rss_form($args, $inputs); 
  12.  

Defined (1)

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

/wp-includes/widgets.php  
  1. function wp_widget_rss_form( $args, $inputs = null ) { 
  2. $default_inputs = array( 'url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true ); 
  3. $inputs = wp_parse_args( $inputs, $default_inputs ); 
  4.  
  5. $args['title'] = isset( $args['title'] ) ? $args['title'] : ''; 
  6. $args['url'] = isset( $args['url'] ) ? $args['url'] : ''; 
  7. $args['items'] = isset( $args['items'] ) ? (int) $args['items'] : 0; 
  8.  
  9. if ( $args['items'] < 1 || 20 < $args['items'] ) { 
  10. $args['items'] = 10; 
  11.  
  12. $args['show_summary'] = isset( $args['show_summary'] ) ? (int) $args['show_summary'] : (int) $inputs['show_summary']; 
  13. $args['show_author'] = isset( $args['show_author'] ) ? (int) $args['show_author'] : (int) $inputs['show_author']; 
  14. $args['show_date'] = isset( $args['show_date'] ) ? (int) $args['show_date'] : (int) $inputs['show_date']; 
  15.  
  16. if ( ! empty( $args[error] ) ) { 
  17. echo '<p class="widget-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . $args[error] . '</p>'; 
  18.  
  19. $esc_number = esc_attr( $args['number'] ); 
  20. if ( $inputs['url'] ) : 
  21. ?> 
  22. <p><label for="rss-url-<?php echo $esc_number; ?>"><?php _e( 'Enter the RSS feed URL here:' ); ?></label> 
  23. <input class="widefat" id="rss-url-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][url]" type="text" value="<?php echo esc_url( $args['url'] ); ?>" /></p> 
  24. <?php endif; if ( $inputs['title'] ) : ?> 
  25. <p><label for="rss-title-<?php echo $esc_number; ?>"><?php _e( 'Give the feed a title (optional):' ); ?></label> 
  26. <input class="widefat" id="rss-title-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][title]" type="text" value="<?php echo esc_attr( $args['title'] ); ?>" /></p> 
  27. <?php endif; if ( $inputs['items'] ) : ?> 
  28. <p><label for="rss-items-<?php echo $esc_number; ?>"><?php _e( 'How many items would you like to display?' ); ?></label> 
  29. <select id="rss-items-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][items]"> 
  30. <?php 
  31. for ( $i = 1; $i <= 20; ++$i ) { 
  32. echo "<option value='$i' " . selected( $args['items'], $i, false ) . ">$i</option>"; 
  33. ?> 
  34. </select></p> 
  35. <?php endif; if ( $inputs['show_summary'] ) : ?> 
  36. <p><input id="rss-show-summary-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][show_summary]" type="checkbox" value="1" <?php checked( $args['show_summary'] ); ?> /> 
  37. <label for="rss-show-summary-<?php echo $esc_number; ?>"><?php _e( 'Display item content?' ); ?></label></p> 
  38. <?php endif; if ( $inputs['show_author'] ) : ?> 
  39. <p><input id="rss-show-author-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][show_author]" type="checkbox" value="1" <?php checked( $args['show_author'] ); ?> /> 
  40. <label for="rss-show-author-<?php echo $esc_number; ?>"><?php _e( 'Display item author if available?' ); ?></label></p> 
  41. <?php endif; if ( $inputs['show_date'] ) : ?> 
  42. <p><input id="rss-show-date-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][show_date]" type="checkbox" value="1" <?php checked( $args['show_date'] ); ?>/> 
  43. <label for="rss-show-date-<?php echo $esc_number; ?>"><?php _e( 'Display item date?' ); ?></label></p> 
  44. <?php 
  45. endif; 
  46. foreach ( array_keys($default_inputs) as $input ) : 
  47. if ( 'hidden' === $inputs[$input] ) : 
  48. $id = str_replace( '_', '-', $input ); 
  49. ?> 
  50. <input type="hidden" id="rss-<?php echo esc_attr( $id ); ?>-<?php echo $esc_number; ?>" name="widget-rss[<?php echo $esc_number; ?>][<?php echo esc_attr( $input ); ?>]" value="<?php echo esc_attr( $args[ $input ] ); ?>" /> 
  51. <?php 
  52. endif; 
  53. endforeach;