mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Remove ceilings on recent comments and posts widgets and dashboard widgets. fixes #14543.
git-svn-id: http://svn.automattic.com/wordpress/trunk@16922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cf3bf584f0
commit
f4c1734b60
@ -606,10 +606,8 @@ function wp_dashboard_recent_comments() {
|
||||
$start = 0;
|
||||
|
||||
$widgets = get_option( 'dashboard_widget_options' );
|
||||
if ( isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] ) )
|
||||
$total_items = (int) $widgets['dashboard_recent_comments']['items'];
|
||||
else
|
||||
$total_items = 5;
|
||||
$total_items = isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] )
|
||||
? absint( $widgets['dashboard_recent_comments']['items'] ) : 5;
|
||||
|
||||
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" ) ) {
|
||||
|
||||
@ -757,9 +755,7 @@ function wp_dashboard_recent_comments_control() {
|
||||
$widget_options['dashboard_recent_comments'] = array();
|
||||
|
||||
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-recent-comments']) ) {
|
||||
$number = (int) stripslashes($_POST['widget-recent-comments']['items']);
|
||||
if ( $number < 1 || $number > 30 )
|
||||
$number = 5;
|
||||
$number = absint( stripslashes($_POST['widget-recent-comments']['items']) );
|
||||
$widget_options['dashboard_recent_comments']['items'] = $number;
|
||||
update_option( 'dashboard_widget_options', $widget_options );
|
||||
}
|
||||
@ -767,7 +763,7 @@ function wp_dashboard_recent_comments_control() {
|
||||
$number = isset( $widget_options['dashboard_recent_comments']['items'] ) ? (int) $widget_options['dashboard_recent_comments']['items'] : '';
|
||||
|
||||
echo '<p><label for="comments-number">' . __('Number of comments to show:') . '</label>';
|
||||
echo '<input id="comments-number" name="widget-recent-comments[items]" type="text" value="' . $number . '" size="3" /> <small>' . __( '(at most 30)' ) . '</small></p>';
|
||||
echo '<input id="comments-number" name="widget-recent-comments[items]" type="text" value="' . $number . '" size="3" /></p>';
|
||||
}
|
||||
|
||||
function wp_dashboard_incoming_links() {
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Default Widgets
|
||||
*
|
||||
@ -535,12 +534,8 @@ class WP_Widget_Recent_Posts extends WP_Widget {
|
||||
extract($args);
|
||||
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base);
|
||||
if ( !$number = (int) $instance['number'] )
|
||||
$number = 10;
|
||||
else if ( $number < 1 )
|
||||
$number = 1;
|
||||
else if ( $number > 15 )
|
||||
$number = 15;
|
||||
if ( ! $number = absint( $instance['number'] ) )
|
||||
$number = 10;
|
||||
|
||||
$r = new WP_Query(array('posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => true));
|
||||
if ($r->have_posts()) :
|
||||
@ -582,15 +577,13 @@ class WP_Widget_Recent_Posts extends WP_Widget {
|
||||
|
||||
function form( $instance ) {
|
||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
||||
if ( !isset($instance['number']) || !$number = (int) $instance['number'] )
|
||||
$number = 5;
|
||||
$number = isset($instance['number']) ? absint($instance['number']) : 5;
|
||||
?>
|
||||
<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>
|
||||
|
||||
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts 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>
|
||||
<small><?php _e('(at most 15)'); ?></small>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@ -644,10 +637,8 @@ class WP_Widget_Recent_Comments extends WP_Widget {
|
||||
$output = '';
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']);
|
||||
|
||||
if ( ! $number = (int) $instance['number'] )
|
||||
if ( ! $number = absint( $instance['number'] ) )
|
||||
$number = 5;
|
||||
else if ( $number < 1 )
|
||||
$number = 1;
|
||||
|
||||
$comments = get_comments( array( 'number' => $number, 'status' => 'approve' ) );
|
||||
$output .= $before_widget;
|
||||
@ -671,7 +662,7 @@ class WP_Widget_Recent_Comments extends WP_Widget {
|
||||
function update( $new_instance, $old_instance ) {
|
||||
$instance = $old_instance;
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['number'] = (int) $new_instance['number'];
|
||||
$instance['number'] = absint( $new_instance['number'] );
|
||||
$this->flush_widget_cache();
|
||||
|
||||
$alloptions = wp_cache_get( 'alloptions', 'options' );
|
||||
|
Loading…
Reference in New Issue
Block a user