Make WordPress Core

Changeset 18676


Ignore:
Timestamp:
09/15/2011 09:41:17 AM (13 years ago)
Author:
westi
Message:

Fix Notices in default Widgets when called using the_widget(). Fixes #16761 props mfields and SergeyBiryukov

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/default-widgets.php

    r17825 r18676  
    178178    function widget( $args, $instance ) {
    179179        extract($args);
    180         $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     180        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
    181181
    182182        echo $before_widget;
     
    221221    function widget( $args, $instance ) {
    222222        extract($args);
    223         $c = $instance['count'] ? '1' : '0';
    224         $d = $instance['dropdown'] ? '1' : '0';
     223        $c = ! empty( $instance['count'] ) ? '1' : '0';
     224        $d = ! empty( $instance['dropdown'] ) ? '1' : '0';
    225225        $title = apply_filters('widget_title', empty($instance['title']) ? __('Archives') : $instance['title'], $instance, $this->id_base);
    226226
     
    376376    function widget( $args, $instance ) {
    377377        extract($args);
    378         $title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
    379         $text = apply_filters( 'widget_text', $instance['text'], $instance );
     378        $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
     379        $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance );
    380380        echo $before_widget;
    381381        if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
    382             <div class="textwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div>
     382            <div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>
    383383        <?php
    384384        echo $after_widget;
     
    427427
    428428        $title = apply_filters('widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base);
    429         $c = $instance['count'] ? '1' : '0';
    430         $h = $instance['hierarchical'] ? '1' : '0';
    431         $d = $instance['dropdown'] ? '1' : '0';
     429        $c = ! empty( $instance['count'] ) ? '1' : '0';
     430        $h = ! empty( $instance['hierarchical'] ) ? '1' : '0';
     431        $d = ! empty( $instance['dropdown'] ) ? '1' : '0';
    432432
    433433        echo $before_widget;
     
    526526            $cache = array();
    527527
    528         if ( isset($cache[$args['widget_id']]) ) {
    529             echo $cache[$args['widget_id']];
     528        if ( isset( $args['widget_id'] ) && isset( $cache[ $args['widget_id'] ] ) ) {
     529            echo $cache[ $args['widget_id'] ];
    530530            return;
    531531        }
     
    535535
    536536        $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base);
    537         if ( ! $number = absint( $instance['number'] ) )
     537        if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
    538538            $number = 10;
    539539
     
    629629            $cache = array();
    630630
    631         if ( isset( $cache[$args['widget_id']] ) ) {
    632             echo $cache[$args['widget_id']];
     631        if ( isset( $args['widget_id'] ) && isset( $cache[ $args['widget_id'] ] ) ) {
     632            echo $cache[ $args['widget_id'] ];
    633633            return;
    634634        }
     
    638638        $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']);
    639639
    640         if ( ! $number = absint( $instance['number'] ) )
     640        if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
    641641            $number = 5;
    642642
     
    706706        extract($args, EXTR_SKIP);
    707707
    708         $url = $instance['url'];
     708        $url = ! empty( $instance['url'] ) ? $instance['url'] : '';
    709709        while ( stristr($url, 'http') != $url )
    710710            $url = substr($url, 1);
     
    752752
    753753    function update($new_instance, $old_instance) {
    754         $testurl = ( isset($new_instance['url']) && ($new_instance['url'] != $old_instance['url']) );
     754        $testurl = ( isset( $new_instance['url'] ) && ( !isset( $old_instance['url'] ) || ( $new_instance['url'] != $old_instance['url'] ) ) );
    755755        return wp_widget_rss_process( $new_instance, $testurl );
    756756    }
     
    10601060    function widget($args, $instance) {
    10611061        // Get menu
    1062         $nav_menu = wp_get_nav_menu_object( $instance['nav_menu'] );
     1062        $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false;
    10631063
    10641064        if ( !$nav_menu )
    10651065            return;
    10661066
    1067         $instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     1067        $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
    10681068
    10691069        echo $args['before_widget'];
Note: See TracChangeset for help on using the changeset viewer.