<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[16922] trunk:
  Remove ceilings on recent comments and posts widgets and dashboard widgets
 .</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/16922">16922</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-12-14 17:58:47 +0000 (Tue, 14 Dec 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove ceilings on recent comments and posts widgets and dashboard widgets. fixes <a href="http://trac.wordpress.org/ticket/14543">#14543</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesdashboardphp">trunk/wp-admin/includes/dashboard.php</a></li>
<li><a href="#trunkwpincludesdefaultwidgetsphp">trunk/wp-includes/default-widgets.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesdashboardphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/dashboard.php (16921 => 16922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/dashboard.php        2010-12-14 17:02:29 UTC (rev 16921)
+++ trunk/wp-admin/includes/dashboard.php        2010-12-14 17:58:47 UTC (rev 16922)
</span><span class="lines">@@ -606,10 +606,8 @@
</span><span class="cx">         $start = 0;
</span><span class="cx"> 
</span><span class="cx">         $widgets = get_option( 'dashboard_widget_options' );
</span><del>-        if ( isset( $widgets['dashboard_recent_comments'] ) &amp;&amp; isset( $widgets['dashboard_recent_comments']['items'] ) )
-                $total_items = (int) $widgets['dashboard_recent_comments']['items'];
-        else
-                $total_items = 5;
</del><ins>+        $total_items = isset( $widgets['dashboard_recent_comments'] ) &amp;&amp; isset( $widgets['dashboard_recent_comments']['items'] )
+                ? absint( $widgets['dashboard_recent_comments']['items'] ) : 5;
</ins><span class="cx"> 
</span><span class="cx">         while ( count( $comments ) &lt; 5 &amp;&amp; $possible = $wpdb-&gt;get_results( &quot;SELECT * FROM $wpdb-&gt;comments c LEFT JOIN $wpdb-&gt;posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50&quot; ) ) {
</span><span class="cx"> 
</span><span class="lines">@@ -757,9 +755,7 @@
</span><span class="cx">                 $widget_options['dashboard_recent_comments'] = array();
</span><span class="cx"> 
</span><span class="cx">         if ( 'POST' == $_SERVER['REQUEST_METHOD'] &amp;&amp; isset($_POST['widget-recent-comments']) ) {
</span><del>-                $number = (int) stripslashes($_POST['widget-recent-comments']['items']);
-                if ( $number &lt; 1 || $number &gt; 30 )
-                        $number = 5;
</del><ins>+                $number = absint( stripslashes($_POST['widget-recent-comments']['items']) );
</ins><span class="cx">                 $widget_options['dashboard_recent_comments']['items'] = $number;
</span><span class="cx">                 update_option( 'dashboard_widget_options', $widget_options );
</span><span class="cx">         }
</span><span class="lines">@@ -767,7 +763,7 @@
</span><span class="cx">         $number = isset( $widget_options['dashboard_recent_comments']['items'] ) ? (int) $widget_options['dashboard_recent_comments']['items'] : '';
</span><span class="cx"> 
</span><span class="cx">         echo '&lt;p&gt;&lt;label for=&quot;comments-number&quot;&gt;' . __('Number of comments to show:') . '&lt;/label&gt;';
</span><del>-        echo '&lt;input id=&quot;comments-number&quot; name=&quot;widget-recent-comments[items]&quot; type=&quot;text&quot; value=&quot;' . $number . '&quot; size=&quot;3&quot; /&gt; &lt;small&gt;' . __( '(at most 30)' ) . '&lt;/small&gt;&lt;/p&gt;';
</del><ins>+        echo '&lt;input id=&quot;comments-number&quot; name=&quot;widget-recent-comments[items]&quot; type=&quot;text&quot; value=&quot;' . $number . '&quot; size=&quot;3&quot; /&gt;&lt;/p&gt;';
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function wp_dashboard_incoming_links() {
</span></span></pre></div>
<a id="trunkwpincludesdefaultwidgetsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/default-widgets.php (16921 => 16922)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/default-widgets.php        2010-12-14 17:02:29 UTC (rev 16921)
+++ trunk/wp-includes/default-widgets.php        2010-12-14 17:58:47 UTC (rev 16922)
</span><span class="lines">@@ -1,5 +1,4 @@
</span><span class="cx"> &lt;?php
</span><del>-
</del><span class="cx"> /**
</span><span class="cx">  * Default Widgets
</span><span class="cx">  *
</span><span class="lines">@@ -535,12 +534,8 @@
</span><span class="cx">                 extract($args);
</span><span class="cx"> 
</span><span class="cx">                 $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this-&gt;id_base);
</span><del>-                if ( !$number = (int) $instance['number'] )
-                        $number = 10;
-                else if ( $number &lt; 1 )
-                        $number = 1;
-                else if ( $number &gt; 15 )
-                        $number = 15;
</del><ins>+                if ( ! $number = absint( $instance['number'] ) )
+                         $number = 10;
</ins><span class="cx"> 
</span><span class="cx">                 $r = new WP_Query(array('posts_per_page' =&gt; $number, 'nopaging' =&gt; 0, 'post_status' =&gt; 'publish', 'ignore_sticky_posts' =&gt; true));
</span><span class="cx">                 if ($r-&gt;have_posts()) :
</span><span class="lines">@@ -582,15 +577,13 @@
</span><span class="cx"> 
</span><span class="cx">         function form( $instance ) {
</span><span class="cx">                 $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
</span><del>-                if ( !isset($instance['number']) || !$number = (int) $instance['number'] )
-                        $number = 5;
</del><ins>+                $number = isset($instance['number']) ? absint($instance['number']) : 5;
</ins><span class="cx"> ?&gt;
</span><span class="cx">                 &lt;p&gt;&lt;label for=&quot;&lt;?php echo $this-&gt;get_field_id('title'); ?&gt;&quot;&gt;&lt;?php _e('Title:'); ?&gt;&lt;/label&gt;
</span><span class="cx">                 &lt;input class=&quot;widefat&quot; id=&quot;&lt;?php echo $this-&gt;get_field_id('title'); ?&gt;&quot; name=&quot;&lt;?php echo $this-&gt;get_field_name('title'); ?&gt;&quot; type=&quot;text&quot; value=&quot;&lt;?php echo $title; ?&gt;&quot; /&gt;&lt;/p&gt;
</span><span class="cx"> 
</span><span class="cx">                 &lt;p&gt;&lt;label for=&quot;&lt;?php echo $this-&gt;get_field_id('number'); ?&gt;&quot;&gt;&lt;?php _e('Number of posts to show:'); ?&gt;&lt;/label&gt;
</span><span class="cx">                 &lt;input id=&quot;&lt;?php echo $this-&gt;get_field_id('number'); ?&gt;&quot; name=&quot;&lt;?php echo $this-&gt;get_field_name('number'); ?&gt;&quot; type=&quot;text&quot; value=&quot;&lt;?php echo $number; ?&gt;&quot; size=&quot;3&quot; /&gt;&lt;/p&gt;
</span><del>-                &lt;small&gt;&lt;?php _e('(at most 15)'); ?&gt;&lt;/small&gt;
</del><span class="cx"> &lt;?php
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -644,10 +637,8 @@
</span><span class="cx">                  $output = '';
</span><span class="cx">                  $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title']);
</span><span class="cx"> 
</span><del>-                if ( ! $number = (int) $instance['number'] )
</del><ins>+                if ( ! $number = absint( $instance['number'] ) )
</ins><span class="cx">                          $number = 5;
</span><del>-                 else if ( $number &lt; 1 )
-                         $number = 1;
</del><span class="cx"> 
</span><span class="cx">                 $comments = get_comments( array( 'number' =&gt; $number, 'status' =&gt; 'approve' ) );
</span><span class="cx">                 $output .= $before_widget;
</span><span class="lines">@@ -671,7 +662,7 @@
</span><span class="cx">         function update( $new_instance, $old_instance ) {
</span><span class="cx">                 $instance = $old_instance;
</span><span class="cx">                 $instance['title'] = strip_tags($new_instance['title']);
</span><del>-                $instance['number'] = (int) $new_instance['number'];
</del><ins>+                $instance['number'] = absint( $new_instance['number'] );
</ins><span class="cx">                 $this-&gt;flush_widget_cache();
</span><span class="cx"> 
</span><span class="cx">                 $alloptions = wp_cache_get( 'alloptions', 'options' );
</span></span></pre>
</div>
</div>

</body>
</html>