Make WordPress Core

Changeset 23597


Ignore:
Timestamp:
03/04/2013 02:14:23 AM (12 years ago)
Author:
SergeyBiryukov
Message:

Simplify logic in WP_Widget_Recent_Posts and WP_Widget_Recent_Comments. fixes #23089.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/default-widgets.php

    r23554 r23597  
    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;
     
    676678        extract($args, EXTR_SKIP);
    677679        $output = '';
    678         $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Comments' ) : $instance['title'], $instance, $this->id_base );
    679 
    680         if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
     680
     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
     
    718722
    719723    function form( $instance ) {
    720         $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
    721         $number = isset($instance['number']) ? absint($instance['number']) : 5;
    722 ?>
    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>
    725 
    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>
     724        $title  = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
     725        $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
     726?>
     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>
     729
     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    }
Note: See TracChangeset for help on using the changeset viewer.