WordPress.org

Make WordPress Core


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.