WordPress.org

Make WordPress Core

Ticket #23089: 23089.3.patch

File 23089.3.patch, 3.1 KB (added by SergeyBiryukov, 5 years ago)
  • wp-includes/default-widgets.php

     
    559559                ob_start();
    560560                extract($args);
    561561
    562                 $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base);
    563                 if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
     562                $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' );
     563                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
     564                $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 10;
     565                if ( ! $number )
    564566                        $number = 10;
    565567                $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
    566568
     
    675677
    676678                extract($args, EXTR_SKIP);
    677679                $output = '';
    678                 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Comments' ) : $instance['title'], $instance, $this->id_base );
    679680
    680                 if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
     681                $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' );
     682                $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
     683                $number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
     684                if ( ! $number )
    681685                        $number = 5;
    682686
    683687                $comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ) );
     
    717721        }
    718722
    719723        function form( $instance ) {
    720                 $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
    721                 $number = isset($instance['number']) ? absint($instance['number']) : 5;
     724                $title  = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
     725                $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
    722726?>
    723                 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
    724                 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
     727                <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
     728                <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $title; ?>" /></p>
    725729
    726                 <p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of comments to show:'); ?></label>
    727                 <input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
     730                <p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of comments to show:' ); ?></label>
     731                <input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
    728732<?php
    729733        }
    730734}