Make WordPress Core

Ticket #38133: 38133.3.diff

File 38133.3.diff, 15.3 KB (added by joshcanhelp, 8 years ago)
  • src/wp-includes/widgets/class-wp-nav-menu-widget.php

     
    4747                if ( !$nav_menu )
    4848                        return;
    4949
     50                $title = '';
     51                if ( isset( $instance['title'] ) && '' !== $instance['title'] ) {
     52                        $title = $instance['title'];
     53                }
     54
    5055                /** 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 );
     56                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    5257
    5358                echo $args['before_widget'];
    5459
    55                 if ( !empty($instance['title']) )
    56                         echo $args['before_title'] . $instance['title'] . $args['after_title'];
     60                if ( '' !== $title ) {
     61                        echo $args['before_title'] . $title . $args['after_title'];
     62                }
    5763
    5864                $nav_menu_args = array(
    5965                        'fallback_cb' => '',
     
    94100         */
    95101        public function update( $new_instance, $old_instance ) {
    96102                $instance = array();
    97                 if ( ! empty( $new_instance['title'] ) ) {
     103                if ( isset( $new_instance['title'] ) && '' !== $new_instance['title'] ) {
    98104                        $instance['title'] = sanitize_text_field( $new_instance['title'] );
    99105                }
    100106                if ( ! empty( $new_instance['nav_menu'] ) ) {
  • src/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 = __( 'Archives' );
     49                if ( isset( $instance['title'] ) && '' !== $instance['title'] ) {
     50                        $title = $instance['title'];
     51                }
     52
    4853                /** 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 );
     54                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    5055
    5156                echo $args['before_widget'];
    52                 if ( $title ) {
     57
     58                if ( '' !== $title ) {
    5359                        echo $args['before_title'] . $title . $args['after_title'];
    5460                }
    5561
  • src/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 = '';
     56                if ( isset( $instance['title'] ) && '' !== $instance['title'] ) {
     57                        $title = $instance['title'];
     58                }
     59
    5560                /** 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 );
     61                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    5762
    5863                echo $args['before_widget'];
    59                 if ( $title ) {
     64
     65                if ( '' !== $title ) {
    6066                        echo $args['before_title'] . $title . $args['after_title'];
    6167                }
    6268                if ( 0 === self::$instance ) {
  • src/wp-includes/widgets/class-wp-widget-categories.php

     
    4444        public function widget( $args, $instance ) {
    4545                static $first_dropdown = true;
    4646
     47                $title = __( 'Categories' );
     48                if ( isset( $instance['title'] ) && '' !== $instance['title'] ) {
     49                        $title = $instance['title'];
     50                }
     51
    4752                /** 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 );
     53                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    4954
    5055                $c = ! empty( $instance['count'] ) ? '1' : '0';
    5156                $h = ! empty( $instance['hierarchical'] ) ? '1' : '0';
     
    5257                $d = ! empty( $instance['dropdown'] ) ? '1' : '0';
    5358
    5459                echo $args['before_widget'];
    55                 if ( $title ) {
     60               
     61                if ( '' !== $title ) {
    5662                        echo $args['before_title'] . $title . $args['after_title'];
    5763                }
    5864
  • src/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 = __( 'Meta' );
     48                if ( isset( $instance['title'] ) && '' !== $instance['title'] ) {
     49                        $title = $instance['title'];
     50                }
     51
    4752                /** 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 );
     53                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    4954
    5055                echo $args['before_widget'];
    51                 if ( $title ) {
     56
     57                if ( '' !== $title ) {
    5258                        echo $args['before_title'] . $title . $args['after_title'];
    5359                }
    5460                        ?>
  • src/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                $title = __( 'Pages' );
     46                if ( isset( $instance['title'] ) && '' !== $instance['title'] ) {
     47                        $title = $instance['title'];
     48                }
    4549
    4650                /**
    4751                 * Filters the widget title.
     
    5256                 * @param array  $instance An array of the widget's settings.
    5357                 * @param mixed  $id_base  The widget ID.
    5458                 */
    55                 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base );
     59                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    5660
    5761                $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby'];
    5862                $exclude = empty( $instance['exclude'] ) ? '' : $instance['exclude'];
     
    7882
    7983                if ( ! empty( $out ) ) {
    8084                        echo $args['before_widget'];
    81                         if ( $title ) {
     85                        if ( '' !== $title ) {
    8286                                echo $args['before_title'] . $title . $args['after_title'];
    8387                        }
    8488                ?>
  • src/wp-includes/widgets/class-wp-widget-recent-comments.php

     
    7575
    7676                $output = '';
    7777
    78                 $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' );
     78                $title = __( 'Recent Comments' );
     79                if ( isset( $instance['title'] ) && '' !== $instance['title'] ) {
     80                        $title = $instance['title'];
     81                }
    7982
    8083                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    8184                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
     
    100103                ) ) );
    101104
    102105                $output .= $args['before_widget'];
    103                 if ( $title ) {
     106                if ( '' !== $title ) {
    104107                        $output .= $args['before_title'] . $title . $args['after_title'];
    105108                }
    106109
  • src/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 = __( 'Recent Posts' );
     51                if ( isset( $instance['title'] ) && '' !== $instance['title'] ) {
     52                        $title = $instance['title'];
     53                }
    5154
    5255                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    5356                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
     
    7679                if ($r->have_posts()) :
    7780                ?>
    7881                <?php echo $args['before_widget']; ?>
    79                 <?php if ( $title ) {
     82                <?php if ( '' !== $title ) {
    8083                        echo $args['before_title'] . $title . $args['after_title'];
    8184                } ?>
    8285                <ul>
  • src/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
     
    5757                        return;
    5858
    5959                $rss = fetch_feed($url);
    60                 $title = $instance['title'];
     60
     61                $title = '';
     62                if ( isset( $instance['title'] ) && '' !== $instance['title'] ) {
     63                        $title = $instance['title'];
     64                }
     65
    6166                $desc = '';
    6267                $link = '';
    6368
    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) )
     69                if ( ! is_wp_error( $rss ) ) {
     70                        $desc = esc_attr( strip_tags( @html_entity_decode( $rss->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) ) ) );
     71                        if ( '' !== $title ) {
    6772                                $title = strip_tags( $rss->get_title() );
     73                        }
    6874                        $link = strip_tags( $rss->get_permalink() );
    69                         while ( stristr($link, 'http') != $link )
    70                                 $link = substr($link, 1);
     75                        while ( stristr( $link, 'http' ) != $link )
     76                                $link = substr( $link, 1 );
    7177                }
    7278
    73                 if ( empty($title) )
     79                if ( '' !== $title ) {
    7480                        $title = empty($desc) ? __('Unknown Feed') : $desc;
     81                }
    7582
    7683                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    7784                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
     
    7885
    7986                $url = strip_tags( $url );
    8087                $icon = includes_url( 'images/rss.png' );
    81                 if ( $title )
     88                if ( '' !== $title ) {
    8289                        $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>';
     90                }
    8391
    8492                echo $args['before_widget'];
    85                 if ( $title ) {
     93
     94                if ( '' !== $title ) {
    8695                        echo $args['before_title'] . $title . $args['after_title'];
    8796                }
    8897                wp_widget_rss_output( $rss, $instance );
  • src/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
     46                $title = '';
     47                if ( isset( $instance['title'] ) && '' !== $instance['title'] ) {
     48                        $title = $instance['title'];
     49                }
     50
    4551                /** 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 );
     52                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    4753
    4854                echo $args['before_widget'];
    49                 if ( $title ) {
     55
     56                if ( '' !== $title ) {
    5057                        echo $args['before_title'] . $title . $args['after_title'];
    5158                }
    5259
  • src/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
     80                if ( '' !== $title ) {
    8081                        echo $args['before_title'] . $title . $args['after_title'];
    8182                }
    8283
     
    117118        public function form( $instance ) {
    118119                $current_taxonomy = $this->_get_current_taxonomy($instance);
    119120                $title_id = $this->get_field_id( 'title' );
    120                 $instance['title'] = ! empty( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
     121                $instance['title'] = isset( $instance['title'] ) && '' !== $instance['title'] ? esc_attr( $instance['title'] ) : '';
    121122
    122123                echo '<p><label for="' . $title_id .'">' . __( 'Title:' ) . '</label>
    123124                        <input type="text" class="widefat" id="' . $title_id .'" name="' . $this->get_field_name( 'title' ) .'" value="' . $instance['title'] .'" />
  • src/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 = '';
     47                if ( isset( $instance['title'] ) && '' !== $instance['title'] ) {
     48                        $title = $instance['title'];
     49                }
    4650
    4751                /** 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 );
     52                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    4953
    50                 $widget_text = ! empty( $instance['text'] ) ? $instance['text'] : '';
     54                $widget_text = isset( $instance['text'] ) && '' !== $instance['text'] ? $instance['text'] : '';
    5155
    5256                /**
    5357                 * Filters the content of the Text widget.
     
    6266                $text = apply_filters( 'widget_text', $widget_text, $instance, $this );
    6367
    6468                echo $args['before_widget'];
    65                 if ( ! empty( $title ) ) {
     69                if ( '' !== $title ) {
    6670                        echo $args['before_title'] . $title . $args['after_title'];
    6771                } ?>
    6872                        <div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>