Make WordPress Core

Changeset 41867


Ignore:
Timestamp:
10/15/2017 09:42:52 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Widgets: Move empty title checks out of the apply_filters( 'widget_title' ) calls for clarity.

See #42226.

Location:
trunk/src/wp-includes/widgets
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets/class-wp-nav-menu-widget.php

    r41162 r41867  
    4343        $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false;
    4444
    45         if ( !$nav_menu )
     45        if ( ! $nav_menu ) {
    4646            return;
     47        }
     48
     49        $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
    4750
    4851        /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    49         $instance['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 );
    5053
    5154        echo $args['before_widget'];
    5255
    53         if ( !empty($instance['title']) )
    54             echo $args['before_title'] . $instance['title'] . $args['after_title'];
     56        if ( $title ) {
     57            echo $args['before_title'] . $title . $args['after_title'];
     58        }
    5559
    5660        $nav_menu_args = array(
  • trunk/src/wp-includes/widgets/class-wp-widget-archives.php

    r41685 r41867  
    4141     */
    4242    public function widget( $args, $instance ) {
     43        $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Archives' );
     44
     45        /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
     46        $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
     47
    4348        $c = ! empty( $instance['count'] ) ? '1' : '0';
    4449        $d = ! empty( $instance['dropdown'] ) ? '1' : '0';
    4550
    46         /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    47         $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Archives' ) : $instance['title'], $instance, $this->id_base );
     51        echo $args['before_widget'];
    4852
    49         echo $args['before_widget'];
    5053        if ( $title ) {
    5154            echo $args['before_title'] . $title . $args['after_title'];
  • trunk/src/wp-includes/widgets/class-wp-widget-calendar.php

    r41162 r41867  
    5050     */
    5151    public function widget( $args, $instance ) {
     52        $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
     53
    5254        /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    53         $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
     55        $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    5456
    5557        echo $args['before_widget'];
  • trunk/src/wp-includes/widgets/class-wp-widget-categories.php

    r41685 r41867  
    4545        static $first_dropdown = true;
    4646
     47        $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Categories' );
     48
    4749        /** 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 );
     50        $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    4951
    5052        $c = ! empty( $instance['count'] ) ? '1' : '0';
     
    5355
    5456        echo $args['before_widget'];
     57
    5558        if ( $title ) {
    5659            echo $args['before_title'] . $title . $args['after_title'];
  • trunk/src/wp-includes/widgets/class-wp-widget-meta.php

    r41685 r41867  
    4343     */
    4444    public function widget( $args, $instance ) {
     45        $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Meta' );
     46
    4547        /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    46         $title = apply_filters( 'widget_title', empty($instance['title']) ? __( 'Meta' ) : $instance['title'], $instance, $this->id_base );
     48        $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    4749
    4850        echo $args['before_widget'];
     51
    4952        if ( $title ) {
    5053            echo $args['before_title'] . $title . $args['after_title'];
     
    7679            </ul>
    7780            <?php
     81
    7882        echo $args['after_widget'];
    7983    }
  • trunk/src/wp-includes/widgets/class-wp-widget-pages.php

    r41685 r41867  
    4141     */
    4242    public function widget( $args, $instance ) {
     43        $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Pages' );
    4344
    4445        /**
     
    5152         * @param mixed  $id_base  The widget ID.
    5253         */
    53         $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Pages' ) : $instance['title'], $instance, $this->id_base );
     54        $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    5455
    5556        $sortby = empty( $instance['sortby'] ) ? 'menu_order' : $instance['sortby'];
  • trunk/src/wp-includes/widgets/class-wp-widget-rss.php

    r41162 r41867  
    6969        }
    7070
    71         if ( empty($title) )
    72             $title = empty($desc) ? __('Unknown Feed') : $desc;
     71        if ( empty( $title ) ) {
     72            $title = ! empty( $desc ) ? $desc : __( 'Unknown Feed' );
     73        }
    7374
    7475        /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
  • trunk/src/wp-includes/widgets/class-wp-widget-search.php

    r41162 r41867  
    4141     */
    4242    public function widget( $args, $instance ) {
     43        $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
     44
    4345        /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    44         $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
     46        $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    4547
    4648        echo $args['before_widget'];
  • trunk/src/wp-includes/widgets/class-wp-widget-tag-cloud.php

    r41685 r41867  
    4040     */
    4141    public function widget( $args, $instance ) {
    42         $current_taxonomy = $this->_get_current_taxonomy($instance);
    43         if ( !empty($instance['title']) ) {
     42        $current_taxonomy = $this->_get_current_taxonomy( $instance );
     43
     44        if ( ! empty( $instance['title'] ) ) {
    4445            $title = $instance['title'];
    4546        } else {
    46             if ( 'post_tag' == $current_taxonomy ) {
    47                 $title = __('Tags');
     47            if ( 'post_tag' === $current_taxonomy ) {
     48                $title = __( 'Tags' );
    4849            } else {
    49                 $tax = get_taxonomy($current_taxonomy);
     50                $tax = get_taxonomy( $current_taxonomy );
    5051                $title = $tax->labels->name;
    5152            }
  • trunk/src/wp-includes/widgets/class-wp-widget-text.php

    r41779 r41867  
    193193        global $post;
    194194
     195        $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
     196
    195197        /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    196         $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
     198        $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    197199
    198200        $text = ! empty( $instance['text'] ) ? $instance['text'] : '';
Note: See TracChangeset for help on using the changeset viewer.