Changeset 16922
- Timestamp:
- 12/14/2010 05:58:47 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/dashboard.php
r16900 r16922 607 607 608 608 $widgets = get_option( 'dashboard_widget_options' ); 609 if ( isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] ) ) 610 $total_items = (int) $widgets['dashboard_recent_comments']['items']; 611 else 612 $total_items = 5; 609 $total_items = isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] ) 610 ? absint( $widgets['dashboard_recent_comments']['items'] ) : 5; 613 611 614 612 while ( count( $comments ) < 5 && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) { … … 758 756 759 757 if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-recent-comments']) ) { 760 $number = (int) stripslashes($_POST['widget-recent-comments']['items']); 761 if ( $number < 1 || $number > 30 ) 762 $number = 5; 758 $number = absint( stripslashes($_POST['widget-recent-comments']['items']) ); 763 759 $widget_options['dashboard_recent_comments']['items'] = $number; 764 760 update_option( 'dashboard_widget_options', $widget_options ); … … 768 764 769 765 echo '<p><label for="comments-number">' . __('Number of comments to show:') . '</label>'; 770 echo '<input id="comments-number" name="widget-recent-comments[items]" type="text" value="' . $number . '" size="3" /> <small>' . __( '(at most 30)' ) . '</small></p>';766 echo '<input id="comments-number" name="widget-recent-comments[items]" type="text" value="' . $number . '" size="3" /></p>'; 771 767 } 772 768 -
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.