WordPress Version: 7.5
/**
* Display RSS widget options form.
*
* 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'.
*
* @since 2.5.0
*
* @param array|string $args Values for input fields.
* @param array $inputs Override default display options.
*/
function wp_widget_rss_form($args, $inputs = null)
{
$default_inputs = array('url' => true, 'title' => true, 'items' => true, 'show_summary' => true, 'show_author' => true, 'show_date' => true);
$inputs = wp_parse_args($inputs, $default_inputs);
extract($args);
extract($inputs, EXTR_SKIP);
$number = esc_attr($number);
$title = esc_attr($title);
$url = esc_url($url);
$items = (int) $items;
if ($items < 1 || 20 < $items) {
$items = 10;
}
$show_summary = (int) $show_summary;
$show_author = (int) $show_author;
$show_date = (int) $show_date;
if (!empty($error)) {
echo '<p class="widget-error"><strong>' . sprintf(__('RSS Error: %s'), $error) . '</strong></p>';
}
if ($inputs['url']) {
?>
<p><label for="rss-url-<?php
echo $number;
?>"><?php
_e('Enter the RSS feed URL here:');
?></label>
<input class="widefat" id="rss-url-<?php
echo $number;
?>" name="widget-rss[<?php
echo $number;
?>][url]" type="text" value="<?php
echo $url;
?>" /></p>
<?php
}
if ($inputs['title']) {
?>
<p><label for="rss-title-<?php
echo $number;
?>"><?php
_e('Give the feed a title (optional):');
?></label>
<input class="widefat" id="rss-title-<?php
echo $number;
?>" name="widget-rss[<?php
echo $number;
?>][title]" type="text" value="<?php
echo $title;
?>" /></p>
<?php
}
if ($inputs['items']) {
?>
<p><label for="rss-items-<?php
echo $number;
?>"><?php
_e('How many items would you like to display?');
?></label>
<select id="rss-items-<?php
echo $number;
?>" name="widget-rss[<?php
echo $number;
?>][items]">
<?php
for ($i = 1; $i <= 20; ++$i) {
echo "<option value='{$i}' " . selected($items, $i, false) . ">{$i}</option>";
}
?>
</select></p>
<?php
}
if ($inputs['show_summary']) {
?>
<p><input id="rss-show-summary-<?php
echo $number;
?>" name="widget-rss[<?php
echo $number;
?>][show_summary]" type="checkbox" value="1" <?php
if ($show_summary) {
echo 'checked="checked"';
}
?>/>
<label for="rss-show-summary-<?php
echo $number;
?>"><?php
_e('Display item content?');
?></label></p>
<?php
}
if ($inputs['show_author']) {
?>
<p><input id="rss-show-author-<?php
echo $number;
?>" name="widget-rss[<?php
echo $number;
?>][show_author]" type="checkbox" value="1" <?php
if ($show_author) {
echo 'checked="checked"';
}
?>/>
<label for="rss-show-author-<?php
echo $number;
?>"><?php
_e('Display item author if available?');
?></label></p>
<?php
}
if ($inputs['show_date']) {
?>
<p><input id="rss-show-date-<?php
echo $number;
?>" name="widget-rss[<?php
echo $number;
?>][show_date]" type="checkbox" value="1" <?php
if ($show_date) {
echo 'checked="checked"';
}
?>/>
<label for="rss-show-date-<?php
echo $number;
?>"><?php
_e('Display item date?');
?></label></p>
<?php
}
foreach (array_keys($default_inputs) as $input) {
if ('hidden' === $inputs[$input]) {
$id = str_replace('_', '-', $input);
?>
<input type="hidden" id="rss-<?php
echo $id;
?>-<?php
echo $number;
?>" name="widget-rss[<?php
echo $number;
?>][<?php
echo $input;
?>]" value="<?php
echo ${$input};
?>" />
<?php
}
}
}