Make WordPress Core

Changeset 16922


Ignore:
Timestamp:
12/14/2010 05:58:47 PM (14 years ago)
Author:
nacin
Message:

Remove ceilings on recent comments and posts widgets and dashboard widgets. fixes #14543.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/dashboard.php

    r16900 r16922  
    607607
    608608    $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;
    613611
    614612    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" ) ) {
     
    758756
    759757    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']) );
    763759        $widget_options['dashboard_recent_comments']['items'] = $number;
    764760        update_option( 'dashboard_widget_options', $widget_options );
     
    768764
    769765    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>';
    771767}
    772768
  • trunk/wp-includes/default-widgets.php

    r16694 r16922  
    11<?php
    2 
    32/**
    43 * Default Widgets
     
    536535
    537536        $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;
    544539
    545540        $r = new WP_Query(array('posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => true));
     
    583578    function form( $instance ) {
    584579        $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;
    587581?>
    588582        <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
     
    591585        <p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:'); ?></label>
    592586        <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>
    594587<?php
    595588    }
     
    645638        $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']);
    646639
    647         if ( ! $number = (int) $instance['number'] )
     640        if ( ! $number = absint( $instance['number'] ) )
    648641            $number = 5;
    649         else if ( $number < 1 )
    650             $number = 1;
    651642
    652643        $comments = get_comments( array( 'number' => $number, 'status' => 'approve' ) );
     
    672663        $instance = $old_instance;
    673664        $instance['title'] = strip_tags($new_instance['title']);
    674         $instance['number'] = (int) $new_instance['number'];
     665        $instance['number'] = absint( $new_instance['number'] );
    675666        $this->flush_widget_cache();
    676667
Note: See TracChangeset for help on using the changeset viewer.