Make WordPress Core

Ticket #38133: widgets2.diff

File widgets2.diff, 15.2 KB (added by hardeepasrani, 8 years ago)

Improved diff.

  • wp-includes/widgets/class-wp-nav-menu-widget.php

     
    4747                if ( !$nav_menu )
    4848                        return;
    4949
     50                $title = ( isset( $instance['title'] ) && '' !== $instance['title'] ) ? $instance['title'] : '';
    5051                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    51                 $instance['title'] = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
     52                $instance['title'] = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    5253
    5354                echo $args['before_widget'];
    5455
    55                 if ( !empty($instance['title']) )
     56                if ( isset( $instance['title'] ) && '' !== $instance['title'] )
    5657                        echo $args['before_title'] . $instance['title'] . $args['after_title'];
    5758
    5859                $nav_menu_args = array(
     
    9495         */
    9596        public function update( $new_instance, $old_instance ) {
    9697                $instance = array();
    97                 if ( ! empty( $new_instance['title'] ) ) {
     98                if ( isset( $new_instance['title'] ) && '' !== $new_instance['title'] ) {
    9899                        $instance['title'] = sanitize_text_field( $new_instance['title'] );
    99100                }
    100101                if ( ! empty( $new_instance['nav_menu'] ) ) {
  • wp-includes/widgets/class-wp-widget-archives.php

     
    4545                $c = ! empty( $instance['count'] ) ? '1' : '0';
    4646                $d = ! empty( $instance['dropdown'] ) ? '1' : '0';
    4747
     48                $title = ( isset( $instance['title'] ) && '' !== $instance['title'] ) ? $instance['title'] : __( 'Archives' );
    4849                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    49                 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Archives' ) : $instance['title'], $instance, $this->id_base );
     50                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    5051
    5152                echo $args['before_widget'];
    52                 if ( $title ) {
     53                if ( isset( $title ) && '' !== $title ) {
    5354                        echo $args['before_title'] . $title . $args['after_title'];
    5455                }
    5556
  • wp-includes/widgets/class-wp-widget-calendar.php

     
    5252         * @param array $instance The settings for the particular instance of the widget.
    5353         */
    5454        public function widget( $args, $instance ) {
     55                $title = ( isset( $instance['title'] ) && '' !== $instance['title'] ) ? $instance['title'] : '';
    5556                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    56                 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
     57                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    5758
    5859                echo $args['before_widget'];
    59                 if ( $title ) {
     60                if ( isset( $title ) && '' !== $title ) {
    6061                        echo $args['before_title'] . $title . $args['after_title'];
    6162                }
    6263                if ( 0 === self::$instance ) {
  • wp-includes/widgets/class-wp-widget-categories.php

     
    4343         */
    4444        public function widget( $args, $instance ) {
    4545                static $first_dropdown = true;
    46 
     46                $title = ( isset( $instance['title'] ) && '' !== $instance['title'] ) ? $instance['title'] : __( 'Categories' );
    4747                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    48                 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Categories' ) : $instance['title'], $instance, $this->id_base );
     48                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    4949
    5050                $c = ! empty( $instance['count'] ) ? '1' : '0';
    5151                $h = ! empty( $instance['hierarchical'] ) ? '1' : '0';
     
    5252                $d = ! empty( $instance['dropdown'] ) ? '1' : '0';
    5353
    5454                echo $args['before_widget'];
    55                 if ( $title ) {
     55                if ( isset( $title ) && '' !== $title ) {
    5656                        echo $args['before_title'] . $title . $args['after_title'];
    5757                }
    5858
  • wp-includes/widgets/class-wp-widget-meta.php

     
    4444         * @param array $instance Settings for the current Meta widget instance.
    4545         */
    4646        public function widget( $args, $instance ) {
     47                $title = ( isset( $instance['title'] ) && '' !== $instance['title'] ) ? $instance['title'] : __( 'Meta' );
    4748                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    48                 $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base );
     49                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    4950
    5051                echo $args['before_widget'];
    51                 if ( $title ) {
     52                if ( isset( $title ) && '' !== $title ) {
    5253                        echo $args['before_title'] . $title . $args['after_title'];
    5354                }
    5455                        ?>
  • wp-includes/widgets/class-wp-widget-pages.php

     
    4242         * @param array $instance Settings for the current Pages widget instance.
    4343         */
    4444        public function widget( $args, $instance ) {
    45 
     45                $title = ( isset( $instance['title'] ) && '' !== $instance['title'] ) ? $instance['title'] : __( 'Pages' );
    4646                /**
    4747                 * Filters the widget title.
    4848                 *
     
    5252                 * @param array  $instance An array of the widget's settings.
    5353                 * @param mixed  $id_base  The widget ID.
    5454                 */
    55                 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base );
     55                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    5656
    5757                $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby'];
    5858                $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
     
    7878
    7979                if ( ! empty( $out ) ) {
    8080                        echo $args['before_widget'];
    81                         if ( $title ) {
     81                        if ( isset( $title ) && '' !== $title ) {
    8282                                echo $args['before_title'] . $title . $args['after_title'];
    8383                        }
    8484                ?>
  • wp-includes/widgets/class-wp-widget-recent-comments.php

     
    7575
    7676                $output = '';
    7777
    78                 $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' );
     78                $title = ( isset( $instance['title'] ) && '' !== $instance['title'] ) ? $instance['title'] : __( 'Recent Comments' );
    7979
    8080                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    8181                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
     
    100100                ) ) );
    101101
    102102                $output .= $args['before_widget'];
    103                 if ( $title ) {
     103                if ( isset( $title ) && '' !== $title ) {
    104104                        $output .= $args['before_title'] . $title . $args['after_title'];
    105105                }
    106106
  • wp-includes/widgets/class-wp-widget-recent-posts.php

     
    4747                        $args['widget_id'] = $this->id;
    4848                }
    4949
    50                 $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' );
     50                $title = ( isset( $instance['title'] ) && '' !== $instance['title'] ) ? $instance['title'] : __( 'Recent Posts' );
    5151
    5252                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    5353                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
     
    7676                if ($r->have_posts()) :
    7777                ?>
    7878                <?php echo $args['before_widget']; ?>
    79                 <?php if ( $title ) {
     79                <?php if ( isset( $title ) && '' !== $title ) {
    8080                        echo $args['before_title'] . $title . $args['after_title'];
    8181                } ?>
    8282                <ul>
  • wp-includes/widgets/class-wp-widget-rss.php

     
    4242         * @param array $instance Settings for the current RSS widget instance.
    4343         */
    4444        public function widget( $args, $instance ) {
    45                 if ( isset($instance['error']) && $instance['error'] )
     45                if ( isset( $instance['error'] ) && $instance['error'] )
    4646                        return;
    4747
    4848                $url = ! empty( $instance['url'] ) ? $instance['url'] : '';
    49                 while ( stristr($url, 'http') != $url )
    50                         $url = substr($url, 1);
     49                while ( stristr( $url, 'http' ) != $url )
     50                        $url = substr( $url, 1 );
    5151
    52                 if ( empty($url) )
     52                if ( empty( $url ) )
    5353                        return;
    5454
    5555                // self-url destruction sequence
     
    6161                $desc = '';
    6262                $link = '';
    6363
    64                 if ( ! is_wp_error($rss) ) {
    65                         $desc = esc_attr(strip_tags(@html_entity_decode($rss->get_description(), ENT_QUOTES, get_option('blog_charset'))));
    66                         if ( empty($title) )
     64                if ( ! is_wp_error( $rss ) ) {
     65                        $desc = esc_attr( strip_tags( @html_entity_decode( $rss->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) );
     66                        if ( isset( $title ) && '' !== $title )
    6767                                $title = strip_tags( $rss->get_title() );
    6868                        $link = strip_tags( $rss->get_permalink() );
    69                         while ( stristr($link, 'http') != $link )
    70                                 $link = substr($link, 1);
     69                        while ( stristr( $link, 'http' ) != $link )
     70                                $link = substr( $link, 1 );
    7171                }
    7272
    73                 if ( empty($title) )
     73                if ( isset( $title ) && '' !== $title )
    7474                        $title = empty($desc) ? __('Unknown Feed') : $desc;
    7575
    7676                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
     
    7878
    7979                $url = strip_tags( $url );
    8080                $icon = includes_url( 'images/rss.png' );
    81                 if ( $title )
     81                if ( isset( $title ) && '' !== $title )
    8282                        $title = '<a class="rsswidget" href="' . esc_url( $url ) . '"><img class="rss-widget-icon" style="border:0" width="14" height="14" src="' . esc_url( $icon ) . '" alt="RSS" /></a> <a class="rsswidget" href="' . esc_url( $link ) . '">'. esc_html( $title ) . '</a>';
    8383
    8484                echo $args['before_widget'];
    85                 if ( $title ) {
     85                if ( isset( $title ) && '' !== $title ) {
    8686                        echo $args['before_title'] . $title . $args['after_title'];
    8787                }
    8888                wp_widget_rss_output( $rss, $instance );
  • wp-includes/widgets/class-wp-widget-search.php

     
    4242         * @param array $instance Settings for the current Search widget instance.
    4343         */
    4444        public function widget( $args, $instance ) {
     45                $title = ( isset( $instance['title'] ) && '' !== $instance['title'] ) ? $instance['title'] : '';
     46
    4547                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    46                 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
     48                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    4749
    4850                echo $args['before_widget'];
    49                 if ( $title ) {
     51                if ( isset( $title ) && '' !== $title ) {
    5052                        echo $args['before_title'] . $title . $args['after_title'];
    5153                }
    5254
  • wp-includes/widgets/class-wp-widget-tag-cloud.php

     
    4141         * @param array $instance Settings for the current Tag Cloud widget instance.
    4242         */
    4343        public function widget( $args, $instance ) {
    44                 $current_taxonomy = $this->_get_current_taxonomy($instance);
    45                 if ( !empty($instance['title']) ) {
     44                $current_taxonomy = $this->_get_current_taxonomy( $instance );
     45                if ( isset( $instance['title'] ) && '' !== $instance['title'] ) {
    4646                        $title = $instance['title'];
    4747                } else {
    4848                        if ( 'post_tag' == $current_taxonomy ) {
    4949                                $title = __('Tags');
    5050                        } else {
    51                                 $tax = get_taxonomy($current_taxonomy);
     51                                $tax = get_taxonomy( $current_taxonomy );
    5252                                $title = $tax->labels->name;
    5353                        }
    5454                }
     
    7676                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    7777
    7878                echo $args['before_widget'];
    79                 if ( $title ) {
     79                if ( isset( $title ) && '' !== $title ) {
    8080                        echo $args['before_title'] . $title . $args['after_title'];
    8181                }
    8282
     
    117117        public function form( $instance ) {
    118118                $current_taxonomy = $this->_get_current_taxonomy($instance);
    119119                $title_id = $this->get_field_id( 'title' );
    120                 $instance['title'] = ! empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
     120                $instance['title'] = isset( $instance['title'] ) && '' !== $instance['title'] ? esc_attr( $instance['title'] ) : '';
    121121
    122122                echo '<p><label for="' . $title_id .'">' . __( 'Title:' ) . '</label>
    123123                        <input type="text" class="widefat" id="' . $title_id .'" name="' . $this->get_field_name( 'title' ) .'" value="' . $instance['title'] .'" />
  • wp-includes/widgets/class-wp-widget-text.php

     
    4343         * @param array $instance Settings for the current Text widget instance.
    4444         */
    4545        public function widget( $args, $instance ) {
     46                $title = ( isset( $instance['title'] ) && '' !== $instance['title'] ) ? $instance['title'] : '';
    4647
    4748                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    48                 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
     49                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    4950
    50                 $widget_text = ! empty( $instance['text'] ) ? $instance['text'] : '';
     51                $widget_text = isset( $instance['text'] ) && '' !== $instance['text'] ? $instance['text'] : '';
    5152
    5253                /**
    5354                 * Filters the content of the Text widget.
     
    6263                $text = apply_filters( 'widget_text', $widget_text, $instance, $this );
    6364
    6465                echo $args['before_widget'];
    65                 if ( ! empty( $title ) ) {
     66                if ( isset( $title ) && '' !== $title ) {
    6667                        echo $args['before_title'] . $title . $args['after_title'];
    6768                } ?>
    68                         <div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>
     69                        <div class="textwidget"><?php echo isset( $instance['filter'] ) && '' !== $instance['filter'] ? wpautop( $text ) : $text; ?></div>
    6970                <?php
    7071                echo $args['after_widget'];
    7172        }
     
    8990                } else {
    9091                        $instance['text'] = wp_kses_post( $new_instance['text'] );
    9192                }
    92                 $instance['filter'] = ! empty( $new_instance['filter'] );
     93                $instance['filter'] = isset( $new_instance['filter'] );
    9394                return $instance;
    9495        }
    9596