本文整理汇总了PHP中wp_widget_rss_form函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_widget_rss_form函数的具体用法?PHP wp_widget_rss_form怎么用?PHP wp_widget_rss_form使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_widget_rss_form函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xpress_dashboard_rss_control
function xpress_dashboard_rss_control($widget_id, $form_inputs = array())
{
if (!($widget_options = get_option('xpress_dashboard_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] = stripslashes_deep($_POST['widget-rss'][$number]);
$widget_options[$widget_id] = wp_widget_rss_process($_POST['widget-rss'][$number]);
// title is optional. If black, 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(strip_tags($rss->get_title()));
} else {
$widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed'));
}
}
update_option('xpress_dashboard_widget_options', $widget_options);
}
wp_widget_rss_form($widget_options[$widget_id], $form_inputs);
}
示例2: form
function form($instance)
{
if (empty($instance)) {
$instance = array('title' => '', 'url' => '', 'items' => 10, 'error' => false, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0);
}
$instance['number'] = $this->number;
wp_widget_rss_form($instance);
}
示例3: wp_dashboard_rss_control
/**
* The RSS dashboard widget control.
*
* Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
* from RSS-type widgets.
*
* @since 2.5.0
*
* @param string $widget_id
* @param array $form_inputs
*/
function wp_dashboard_rss_control($widget_id, $form_inputs = array())
{
if (!($widget_options = get_option('dashboard_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 black, 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);
$cache_key = 'dash_' . md5($widget_id);
delete_transient($cache_key);
}
wp_widget_rss_form($widget_options[$widget_id], $form_inputs);
}
示例4: wp_dashboard_rss_control
/**
* The RSS dashboard widget control.
*
* Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
* from RSS-type widgets.
*
* @since unknown
*
* @param string widget_id
* @param array form_inputs
*/
function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
if ( !$widget_options = get_option( 'dashboard_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] = stripslashes_deep( $_POST['widget-rss'][$number] );
$widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] );
// title is optional. If black, fill it if possible
if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) {
require_once(ABSPATH . WPINC . '/rss.php');
$rss = fetch_rss($widget_options[$widget_id]['url']);
$widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->channel['title']));
}
update_option( 'dashboard_widget_options', $widget_options );
}
wp_widget_rss_form( $widget_options[$widget_id], $form_inputs );
}
示例5: wp_widget_rss_control
/**
* Display and process RSS widget control form.
*
* @since 2.2.0
*
* @param int $widget_args Widget number.
*/
function wp_widget_rss_control($widget_args)
{
global $wp_registered_widgets;
static $updated = false;
if (is_numeric($widget_args)) {
$widget_args = array('number' => $widget_args);
}
$widget_args = wp_parse_args($widget_args, array('number' => -1));
extract($widget_args, EXTR_SKIP);
$options = get_option('widget_rss');
if (!is_array($options)) {
$options = array();
}
$urls = array();
foreach ((array) $options as $option) {
if (isset($option['url'])) {
$urls[$option['url']] = true;
}
}
if (!$updated && 'POST' == $_SERVER['REQUEST_METHOD'] && !empty($_POST['sidebar'])) {
$sidebar = (string) $_POST['sidebar'];
$sidebars_widgets = wp_get_sidebars_widgets();
if (isset($sidebars_widgets[$sidebar])) {
$this_sidebar =& $sidebars_widgets[$sidebar];
} else {
$this_sidebar = array();
}
foreach ((array) $this_sidebar as $_widget_id) {
if ('wp_widget_rss' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number'])) {
$widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
if (!in_array("rss-{$widget_number}", $_POST['widget-id'])) {
// the widget has been removed.
unset($options[$widget_number]);
}
}
}
foreach ((array) $_POST['widget-rss'] as $widget_number => $widget_rss) {
if (!isset($widget_rss['url']) && isset($options[$widget_number])) {
// user clicked cancel
continue;
}
$widget_rss = stripslashes_deep($widget_rss);
$url = sanitize_url(strip_tags($widget_rss['url']));
$options[$widget_number] = wp_widget_rss_process($widget_rss, !isset($urls[$url]));
}
update_option('widget_rss', $options);
$updated = true;
}
if (-1 == $number) {
$title = '';
$url = '';
$items = 10;
$error = false;
$number = '%i%';
$show_summary = 0;
$show_author = 0;
$show_date = 0;
} else {
extract((array) $options[$number]);
}
wp_widget_rss_form(compact('number', 'title', 'url', 'items', 'error', 'show_summary', 'show_author', 'show_date'));
}