Simplify logic in WP_Widget_Recent_Posts and WP_Widget_Recent_Comments. fixes #23089.
git-svn-id: https://develop.svn.wordpress.org/trunk@23597 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
cb9f18d20f
commit
4cfc8178cf
@ -559,8 +559,10 @@ class WP_Widget_Recent_Posts extends WP_Widget {
|
|||||||
ob_start();
|
ob_start();
|
||||||
extract($args);
|
extract($args);
|
||||||
|
|
||||||
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base);
|
$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts' );
|
||||||
if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
|
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
||||||
|
$number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 10;
|
||||||
|
if ( ! $number )
|
||||||
$number = 10;
|
$number = 10;
|
||||||
$show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
|
$show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
|
||||||
|
|
||||||
@ -675,9 +677,11 @@ class WP_Widget_Recent_Comments extends WP_Widget {
|
|||||||
|
|
||||||
extract($args, EXTR_SKIP);
|
extract($args, EXTR_SKIP);
|
||||||
$output = '';
|
$output = '';
|
||||||
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Comments' ) : $instance['title'], $instance, $this->id_base );
|
|
||||||
|
|
||||||
if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
|
$title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Comments' );
|
||||||
|
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
|
||||||
|
$number = ( ! empty( $instance['number'] ) ) ? absint( $instance['number'] ) : 5;
|
||||||
|
if ( ! $number )
|
||||||
$number = 5;
|
$number = 5;
|
||||||
|
|
||||||
$comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ) );
|
$comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ) );
|
||||||
@ -717,14 +721,14 @@ class WP_Widget_Recent_Comments extends WP_Widget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function form( $instance ) {
|
function form( $instance ) {
|
||||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
$title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
|
||||||
$number = isset($instance['number']) ? absint($instance['number']) : 5;
|
$number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
|
||||||
?>
|
?>
|
||||||
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
|
<p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
|
||||||
<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>
|
<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>
|
||||||
|
|
||||||
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of comments to show:'); ?></label>
|
<p><label for="<?php echo $this->get_field_id( 'number' ); ?>"><?php _e( 'Number of comments to show:' ); ?></label>
|
||||||
<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>
|
<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>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user