WordPress.org

Make WordPress Core

Ticket #23089: 23089.2.patch

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

     
    558558                ob_start();
    559559                extract($args);
    560560
    561                 $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base);
    562                 if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
    563                         $number = 10;
     561                $title     = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Posts' ) : $instance['title'], $instance, $this->id_base );
     562                $number    = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : 10;
    564563                $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
    565564
    566565                $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) );
     
    609608
    610609        function form( $instance ) {
    611610                $title     = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
    612                 $number    = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
     611                $number    = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : 5;
    613612                $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false;
    614613?>
    615614                <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
     
    674673
    675674                extract($args, EXTR_SKIP);
    676675                $output = '';
    677                 $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Comments' ) : $instance['title'], $instance, $this->id_base );
     676                $title  = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Comments' ) : $instance['title'], $instance, $this->id_base );
     677                $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : 5;
    678678
    679                 if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
    680                         $number = 5;
    681 
    682679                $comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ) );
    683680                $output .= $before_widget;
    684681                if ( $title )
     
    716713        }
    717714
    718715        function form( $instance ) {
    719                 $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
    720                 $number = isset($instance['number']) ? absint($instance['number']) : 5;
     716                $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
     717                $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : 5;
    721718?>
    722719                <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
    723720                <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>