Fix Notices in default Widgets when called using the_widget(). Fixes #16761 props mfields and SergeyBiryukov
git-svn-id: http://svn.automattic.com/wordpress/trunk@18676 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
26b57f09a2
commit
7fd6ab93c3
|
@ -177,7 +177,7 @@ class WP_Widget_Search extends WP_Widget {
|
||||||
|
|
||||||
function widget( $args, $instance ) {
|
function widget( $args, $instance ) {
|
||||||
extract($args);
|
extract($args);
|
||||||
$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
|
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
|
||||||
|
|
||||||
echo $before_widget;
|
echo $before_widget;
|
||||||
if ( $title )
|
if ( $title )
|
||||||
|
@ -220,8 +220,8 @@ class WP_Widget_Archives extends WP_Widget {
|
||||||
|
|
||||||
function widget( $args, $instance ) {
|
function widget( $args, $instance ) {
|
||||||
extract($args);
|
extract($args);
|
||||||
$c = $instance['count'] ? '1' : '0';
|
$c = ! empty( $instance['count'] ) ? '1' : '0';
|
||||||
$d = $instance['dropdown'] ? '1' : '0';
|
$d = ! empty( $instance['dropdown'] ) ? '1' : '0';
|
||||||
$title = apply_filters('widget_title', empty($instance['title']) ? __('Archives') : $instance['title'], $instance, $this->id_base);
|
$title = apply_filters('widget_title', empty($instance['title']) ? __('Archives') : $instance['title'], $instance, $this->id_base);
|
||||||
|
|
||||||
echo $before_widget;
|
echo $before_widget;
|
||||||
|
@ -375,11 +375,11 @@ class WP_Widget_Text extends WP_Widget {
|
||||||
|
|
||||||
function widget( $args, $instance ) {
|
function widget( $args, $instance ) {
|
||||||
extract($args);
|
extract($args);
|
||||||
$title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
|
||||||
$text = apply_filters( 'widget_text', $instance['text'], $instance );
|
$text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance );
|
||||||
echo $before_widget;
|
echo $before_widget;
|
||||||
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
|
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
|
||||||
<div class="textwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div>
|
<div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>
|
||||||
<?php
|
<?php
|
||||||
echo $after_widget;
|
echo $after_widget;
|
||||||
}
|
}
|
||||||
|
@ -426,9 +426,9 @@ class WP_Widget_Categories extends WP_Widget {
|
||||||
extract( $args );
|
extract( $args );
|
||||||
|
|
||||||
$title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base);
|
$title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base);
|
||||||
$c = $instance['count'] ? '1' : '0';
|
$c = ! empty( $instance['count'] ) ? '1' : '0';
|
||||||
$h = $instance['hierarchical'] ? '1' : '0';
|
$h = ! empty( $instance['hierarchical'] ) ? '1' : '0';
|
||||||
$d = $instance['dropdown'] ? '1' : '0';
|
$d = ! empty( $instance['dropdown'] ) ? '1' : '0';
|
||||||
|
|
||||||
echo $before_widget;
|
echo $before_widget;
|
||||||
if ( $title )
|
if ( $title )
|
||||||
|
@ -525,8 +525,8 @@ class WP_Widget_Recent_Posts extends WP_Widget {
|
||||||
if ( !is_array($cache) )
|
if ( !is_array($cache) )
|
||||||
$cache = array();
|
$cache = array();
|
||||||
|
|
||||||
if ( isset($cache[$args['widget_id']]) ) {
|
if ( isset( $args['widget_id'] ) && isset( $cache[ $args['widget_id'] ] ) ) {
|
||||||
echo $cache[$args['widget_id']];
|
echo $cache[ $args['widget_id'] ];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,7 +534,7 @@ class WP_Widget_Recent_Posts extends WP_Widget {
|
||||||
extract($args);
|
extract($args);
|
||||||
|
|
||||||
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base);
|
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base);
|
||||||
if ( ! $number = absint( $instance['number'] ) )
|
if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
|
||||||
$number = 10;
|
$number = 10;
|
||||||
|
|
||||||
$r = new WP_Query(array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true));
|
$r = new WP_Query(array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true));
|
||||||
|
@ -628,8 +628,8 @@ class WP_Widget_Recent_Comments extends WP_Widget {
|
||||||
if ( ! is_array( $cache ) )
|
if ( ! is_array( $cache ) )
|
||||||
$cache = array();
|
$cache = array();
|
||||||
|
|
||||||
if ( isset( $cache[$args['widget_id']] ) ) {
|
if ( isset( $args['widget_id'] ) && isset( $cache[ $args['widget_id'] ] ) ) {
|
||||||
echo $cache[$args['widget_id']];
|
echo $cache[ $args['widget_id'] ];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,7 +637,7 @@ class WP_Widget_Recent_Comments extends WP_Widget {
|
||||||
$output = '';
|
$output = '';
|
||||||
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']);
|
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']);
|
||||||
|
|
||||||
if ( ! $number = absint( $instance['number'] ) )
|
if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
|
||||||
$number = 5;
|
$number = 5;
|
||||||
|
|
||||||
$comments = get_comments( array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) );
|
$comments = get_comments( array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) );
|
||||||
|
@ -705,7 +705,7 @@ class WP_Widget_RSS extends WP_Widget {
|
||||||
|
|
||||||
extract($args, EXTR_SKIP);
|
extract($args, EXTR_SKIP);
|
||||||
|
|
||||||
$url = $instance['url'];
|
$url = ! empty( $instance['url'] ) ? $instance['url'] : '';
|
||||||
while ( stristr($url, 'http') != $url )
|
while ( stristr($url, 'http') != $url )
|
||||||
$url = substr($url, 1);
|
$url = substr($url, 1);
|
||||||
|
|
||||||
|
@ -751,7 +751,7 @@ class WP_Widget_RSS extends WP_Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update($new_instance, $old_instance) {
|
function update($new_instance, $old_instance) {
|
||||||
$testurl = ( isset($new_instance['url']) && ($new_instance['url'] != $old_instance['url']) );
|
$testurl = ( isset( $new_instance['url'] ) && ( !isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) );
|
||||||
return wp_widget_rss_process( $new_instance, $testurl );
|
return wp_widget_rss_process( $new_instance, $testurl );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1059,12 +1059,12 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
|
||||||
|
|
||||||
function widget($args, $instance) {
|
function widget($args, $instance) {
|
||||||
// Get menu
|
// Get menu
|
||||||
$nav_menu = wp_get_nav_menu_object( $instance['nav_menu'] );
|
$nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false;
|
||||||
|
|
||||||
if ( !$nav_menu )
|
if ( !$nav_menu )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
|
$instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
|
||||||
|
|
||||||
echo $args['before_widget'];
|
echo $args['before_widget'];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue