Changeset 16922 for trunk/wp-includes/default-widgets.php
- Timestamp:
- 12/14/2010 05:58:47 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/default-widgets.php
r16694 r16922 1 1 <?php 2 3 2 /** 4 3 * Default Widgets … … 536 535 537 536 $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base); 538 if ( !$number = (int) $instance['number'] ) 539 $number = 10; 540 else if ( $number < 1 ) 541 $number = 1; 542 else if ( $number > 15 ) 543 $number = 15; 537 if ( ! $number = absint( $instance['number'] ) ) 538 $number = 10; 544 539 545 540 $r = new WP_Query(array('posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => true)); … … 583 578 function form( $instance ) { 584 579 $title = isset($instance['title']) ? esc_attr($instance['title']) : ''; 585 if ( !isset($instance['number']) || !$number = (int) $instance['number'] ) 586 $number = 5; 580 $number = isset($instance['number']) ? absint($instance['number']) : 5; 587 581 ?> 588 582 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> … … 591 585 <p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:'); ?></label> 592 586 <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> 593 <small><?php _e('(at most 15)'); ?></small>594 587 <?php 595 588 } … … 645 638 $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']); 646 639 647 if ( ! $number = (int) $instance['number'])640 if ( ! $number = absint( $instance['number'] ) ) 648 641 $number = 5; 649 else if ( $number < 1 )650 $number = 1;651 642 652 643 $comments = get_comments( array( 'number' => $number, 'status' => 'approve' ) ); … … 672 663 $instance = $old_instance; 673 664 $instance['title'] = strip_tags($new_instance['title']); 674 $instance['number'] = (int) $new_instance['number'];665 $instance['number'] = absint( $new_instance['number'] ); 675 666 $this->flush_widget_cache(); 676 667
Note: See TracChangeset
for help on using the changeset viewer.