]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/dashboard.php
Wordpress 3.0.1-scripts
[autoinstalls/wordpress.git] / wp-admin / includes / dashboard.php
index 6137a93c140e90d1f705fead7d2d6641bac1f314..8486581bec1a7aada162a95214b8bd4d913b8727 100644 (file)
@@ -28,8 +28,14 @@ function wp_dashboard_setup() {
        wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' );
 
        // Recent Comments Widget
        wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' );
 
        // Recent Comments Widget
+       if ( !isset( $widget_options['dashboard_recent_comments'] ) || !isset( $widget_options['dashboard_recent_comments']['items'] ) ) {
+               $update = true;
+               $widget_options['dashboard_recent_comments'] = array(
+                       'items' => 5,
+               );
+       }
        $recent_comments_title = __( 'Recent Comments' );
        $recent_comments_title = __( 'Recent Comments' );
-       wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments' );
+       wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments', 'wp_dashboard_recent_comments_control' );
 
        // Incoming Links Widget
        if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) {
 
        // Incoming Links Widget
        if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) {
@@ -46,7 +52,7 @@ function wp_dashboard_setup() {
        wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' );
 
        // WP Plugins Widget
        wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' );
 
        // WP Plugins Widget
-       if ( current_user_can( 'activate_plugins' ) )
+       if ( current_user_can( 'install_plugins' ) )
                wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' );
 
        // QuickPress Widget
                wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' );
 
        // QuickPress Widget
@@ -61,13 +67,13 @@ function wp_dashboard_setup() {
        if ( !isset( $widget_options['dashboard_primary'] ) ) {
                $update = true;
                $widget_options['dashboard_primary'] = array(
        if ( !isset( $widget_options['dashboard_primary'] ) ) {
                $update = true;
                $widget_options['dashboard_primary'] = array(
-                       'link' => apply_filters( 'dashboard_primary_link',  __( 'http://wordpress.org/development/' ) ),
-                       'url' => apply_filters( 'dashboard_primary_feed',  __( 'http://wordpress.org/development/feed/' ) ),
-                       'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Development Blog' ) ),
+                       'link' => apply_filters( 'dashboard_primary_link',  __( 'http://wordpress.org/news/' ) ),
+                       'url' => apply_filters( 'dashboard_primary_feed',  __( 'http://wordpress.org/news/feed/' ) ),
+                       'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ),
                        'items' => 2,
                        'show_summary' => 1,
                        'show_author' => 0,
                        'items' => 2,
                        'show_summary' => 1,
                        'show_author' => 0,
-                       'show_date' => 1
+                       'show_date' => 1,
                );
        }
        wp_add_dashboard_widget( 'dashboard_primary', $widget_options['dashboard_primary']['title'], 'wp_dashboard_primary', 'wp_dashboard_primary_control' );
                );
        }
        wp_add_dashboard_widget( 'dashboard_primary', $widget_options['dashboard_primary']['title'], 'wp_dashboard_primary', 'wp_dashboard_primary_control' );
@@ -79,7 +85,10 @@ function wp_dashboard_setup() {
                        'link' => apply_filters( 'dashboard_secondary_link',  __( 'http://planet.wordpress.org/' ) ),
                        'url' => apply_filters( 'dashboard_secondary_feed',  __( 'http://planet.wordpress.org/feed/' ) ),
                        'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
                        'link' => apply_filters( 'dashboard_secondary_link',  __( 'http://planet.wordpress.org/' ) ),
                        'url' => apply_filters( 'dashboard_secondary_feed',  __( 'http://planet.wordpress.org/feed/' ) ),
                        'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ),
-                       'items' => 5
+                       'items' => 5,
+                       'show_summary' => 0,
+                       'show_author' => 0,
+                       'show_date' => 0,
                );
        }
        wp_add_dashboard_widget( 'dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_secondary', 'wp_dashboard_secondary_control' );
                );
        }
        wp_add_dashboard_widget( 'dashboard_secondary', $widget_options['dashboard_secondary']['title'], 'wp_dashboard_secondary', 'wp_dashboard_secondary_control' );
@@ -206,8 +215,8 @@ function wp_dashboard_right_now() {
 
        $num_comm = wp_count_comments( );
 
 
        $num_comm = wp_count_comments( );
 
-       echo "\n\t".'<p class="sub">' . __('At a Glance') . '</p>';
-       echo "\n\t".'<div class="table">'."\n\t".'<table>';
+       echo "\n\t".'<div class="table table_content">';
+       echo "\n\t".'<p class="sub">' . __('Content') . '</p>'."\n\t".'<table>';
        echo "\n\t".'<tr class="first">';
 
        // Posts
        echo "\n\t".'<tr class="first">';
 
        // Posts
@@ -219,6 +228,8 @@ function wp_dashboard_right_now() {
        }
        echo '<td class="first b b-posts">' . $num . '</td>';
        echo '<td class="t posts">' . $text . '</td>';
        }
        echo '<td class="first b b-posts">' . $num . '</td>';
        echo '<td class="t posts">' . $text . '</td>';
+
+       echo '</tr><tr>';
        /* TODO: Show status breakdown on hover
        if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds.  Don't show if !current_user_can
                $post_type_texts[] = '<a href="edit-pages.php">'.sprintf( _n( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).'</a>';
        /* TODO: Show status breakdown on hover
        if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds.  Don't show if !current_user_can
                $post_type_texts[] = '<a href="edit-pages.php">'.sprintf( _n( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).'</a>';
@@ -236,31 +247,64 @@ function wp_dashboard_right_now() {
        }
        */
 
        }
        */
 
+       // Pages
+       $num = number_format_i18n( $num_pages->publish );
+       $text = _n( 'Page', 'Pages', $num_pages->publish );
+       if ( current_user_can( 'edit_pages' ) ) {
+               $num = "<a href='edit.php?post_type=page'>$num</a>";
+               $text = "<a href='edit.php?post_type=page'>$text</a>";
+       }
+       echo '<td class="first b b_pages">' . $num . '</td>';
+       echo '<td class="t pages">' . $text . '</td>';
+
+       echo '</tr><tr>';
+
+       // Categories
+       $num = number_format_i18n( $num_cats );
+       $text = _n( 'Category', 'Categories', $num_cats );
+       if ( current_user_can( 'manage_categories' ) ) {
+               $num = "<a href='edit-tags.php?taxonomy=category'>$num</a>";
+               $text = "<a href='edit-tags.php?taxonomy=category'>$text</a>";
+       }
+       echo '<td class="first b b-cats">' . $num . '</td>';
+       echo '<td class="t cats">' . $text . '</td>';
+
+       echo '</tr><tr>';
+
+       // Tags
+       $num = number_format_i18n( $num_tags );
+       $text = _n( 'Tag', 'Tags', $num_tags );
+       if ( current_user_can( 'manage_categories' ) ) {
+               $num = "<a href='edit-tags.php'>$num</a>";
+               $text = "<a href='edit-tags.php'>$text</a>";
+       }
+       echo '<td class="first b b-tags">' . $num . '</td>';
+       echo '<td class="t tags">' . $text . '</td>';
+
+       echo "</tr>";
+       do_action('right_now_content_table_end');
+       echo "\n\t</table>\n\t</div>";
+
+
+       echo "\n\t".'<div class="table table_discussion">';
+       echo "\n\t".'<p class="sub">' . __('Discussion') . '</p>'."\n\t".'<table>';
+       echo "\n\t".'<tr class="first">';
+
        // Total Comments
        $num = '<span class="total-count">' . number_format_i18n($num_comm->total_comments) . '</span>';
        $text = _n( 'Comment', 'Comments', $num_comm->total_comments );
        if ( current_user_can( 'moderate_comments' ) ) {
        // Total Comments
        $num = '<span class="total-count">' . number_format_i18n($num_comm->total_comments) . '</span>';
        $text = _n( 'Comment', 'Comments', $num_comm->total_comments );
        if ( current_user_can( 'moderate_comments' ) ) {
-               $num = "<a href='edit-comments.php'>$num</a>";
-               $text = "<a href='edit-comments.php'>$text</a>";
+               $num = '<a href="edit-comments.php">' . $num . '</a>';
+               $text = '<a href="edit-comments.php">' . $text . '</a>';
        }
        echo '<td class="b b-comments">' . $num . '</td>';
        echo '<td class="last t comments">' . $text . '</td>';
 
        echo '</tr><tr>';
 
        }
        echo '<td class="b b-comments">' . $num . '</td>';
        echo '<td class="last t comments">' . $text . '</td>';
 
        echo '</tr><tr>';
 
-       // Pages
-       $num = number_format_i18n( $num_pages->publish );
-       $text = _n( 'Page', 'Pages', $num_pages->publish );
-       if ( current_user_can( 'edit_pages' ) ) {
-               $num = "<a href='edit-pages.php'>$num</a>";
-               $text = "<a href='edit-pages.php'>$text</a>";
-       }
-       echo '<td class="first b b_pages">' . $num . '</td>';
-       echo '<td class="t pages">' . $text . '</td>';
-
        // Approved Comments
        $num = '<span class="approved-count">' . number_format_i18n($num_comm->approved) . '</span>';
        // Approved Comments
        $num = '<span class="approved-count">' . number_format_i18n($num_comm->approved) . '</span>';
-       $text = _nc( 'Approved|Right Now', 'Approved', $num_comm->approved );
+       $text = _nx( 'Approved', 'Approved', $num_comm->approved, 'Right Now' );
        if ( current_user_can( 'moderate_comments' ) ) {
                $num = "<a href='edit-comments.php?comment_status=approved'>$num</a>";
                $text = "<a class='approved' href='edit-comments.php?comment_status=approved'>$text</a>";
        if ( current_user_can( 'moderate_comments' ) ) {
                $num = "<a href='edit-comments.php?comment_status=approved'>$num</a>";
                $text = "<a class='approved' href='edit-comments.php?comment_status=approved'>$text</a>";
@@ -270,16 +314,6 @@ function wp_dashboard_right_now() {
 
        echo "</tr>\n\t<tr>";
 
 
        echo "</tr>\n\t<tr>";
 
-       // Categories
-       $num = number_format_i18n( $num_cats );
-       $text = _n( 'Category', 'Categories', $num_cats );
-       if ( current_user_can( 'manage_categories' ) ) {
-               $num = "<a href='categories.php'>$num</a>";
-               $text = "<a href='categories.php'>$text</a>";
-       }
-       echo '<td class="first b b-cats">' . $num . '</td>';
-       echo '<td class="t cats">' . $text . '</td>';
-
        // Pending Comments
        $num = '<span class="pending-count">' . number_format_i18n($num_comm->moderated) . '</span>';
        $text = _n( 'Pending', 'Pending', $num_comm->moderated );
        // Pending Comments
        $num = '<span class="pending-count">' . number_format_i18n($num_comm->moderated) . '</span>';
        $text = _n( 'Pending', 'Pending', $num_comm->moderated );
@@ -292,19 +326,9 @@ function wp_dashboard_right_now() {
 
        echo "</tr>\n\t<tr>";
 
 
        echo "</tr>\n\t<tr>";
 
-       // Tags
-       $num = number_format_i18n( $num_tags );
-       $text = _n( 'Tag', 'Tags', $num_tags );
-       if ( current_user_can( 'manage_categories' ) ) {
-               $num = "<a href='edit-tags.php'>$num</a>";
-               $text = "<a href='edit-tags.php'>$text</a>";
-       }
-       echo '<td class="first b b-tags">' . $num . '</td>';
-       echo '<td class="t tags">' . $text . '</td>';
-
        // Spam Comments
        $num = number_format_i18n($num_comm->spam);
        // Spam Comments
        $num = number_format_i18n($num_comm->spam);
-       $text = _n( 'Spam', 'Spam', $num_comm->spam );
+       $text = _nx( 'Spam', 'Spam', $num_comm->spam, 'comment' );
        if ( current_user_can( 'moderate_comments' ) ) {
                $num = "<a href='edit-comments.php?comment_status=spam'><span class='spam-count'>$num</span></a>";
                $text = "<a class='spam' href='edit-comments.php?comment_status=spam'>$text</a>";
        if ( current_user_can( 'moderate_comments' ) ) {
                $num = "<a href='edit-comments.php?comment_status=spam'><span class='spam-count'>$num</span></a>";
                $text = "<a class='spam' href='edit-comments.php?comment_status=spam'>$text</a>";
@@ -314,6 +338,7 @@ function wp_dashboard_right_now() {
 
        echo "</tr>";
        do_action('right_now_table_end');
 
        echo "</tr>";
        do_action('right_now_table_end');
+       do_action('right_now_discussion_table_end');
        echo "\n\t</table>\n\t</div>";
 
        echo "\n\t".'<div class="versions">';
        echo "\n\t</table>\n\t</div>";
 
        echo "\n\t".'<div class="versions">';
@@ -331,11 +356,15 @@ function wp_dashboard_right_now() {
                }
                $num = number_format_i18n( $num_widgets );
 
                }
                $num = number_format_i18n( $num_widgets );
 
-               if ( current_user_can( 'switch_themes' ) ) {
+               $switch_themes = $ct->title;
+               if ( current_user_can( 'switch_themes') ) {
                        echo '<a href="themes.php" class="button rbutton">' . __('Change Theme') . '</a>';
                        echo '<a href="themes.php" class="button rbutton">' . __('Change Theme') . '</a>';
-                       printf(_n('Theme <span class="b"><a href="themes.php">%1$s</a></span> with <span class="b"><a href="widgets.php">%2$s Widget</a></span>', 'Theme <span class="b"><a href="themes.php">%1$s</a></span> with <span class="b"><a href="widgets.php">%2$s Widgets</a></span>', $num_widgets), $ct->title, $num);
+                       $switch_themes = '<a href="themes.php">' . $switch_themes . '</a>';
+               }
+               if ( current_user_can( 'edit_theme_options' ) ) {
+                       printf(_n('Theme <span class="b">%1$s</span> with <span class="b"><a href="widgets.php">%2$s Widget</a></span>', 'Theme <span class="b">%1$s</span> with <span class="b"><a href="widgets.php">%2$s Widgets</a></span>', $num_widgets), $switch_themes, $num);
                } else {
                } else {
-                       printf(_n('Theme <span class="b">%1$s</span> with <span class="b">%2$s Widget</span>', 'Theme <span class="b">%1$s</span> with <span class="b">%2$s Widgets</span>', $num_widgets), $ct->title, $num);
+                       printf(_n('Theme <span class="b">%1$s</span> with <span class="b">%2$s Widget</span>', 'Theme <span class="b">%1$s</span> with <span class="b">%2$s Widgets</span>', $num_widgets), $switch_themes, $num);
                }
        } else {
                if ( current_user_can( 'switch_themes' ) ) {
                }
        } else {
                if ( current_user_can( 'switch_themes' ) ) {
@@ -354,18 +383,20 @@ function wp_dashboard_right_now() {
        do_action( 'activity_box_end' );
 }
 
        do_action( 'activity_box_end' );
 }
 
-function wp_dashboard_quick_press() {
+function wp_dashboard_quick_press_output() {
+       global $post_ID;
+
        $drafts = false;
        if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) && (int) $_POST['post_ID'] ) {
                $view = get_permalink( $_POST['post_ID'] );
                $edit = esc_url( get_edit_post_link( $_POST['post_ID'] ) );
                if ( 'post-quickpress-publish' == $_POST['action'] ) {
                        if ( current_user_can('publish_posts') )
        $drafts = false;
        if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) && (int) $_POST['post_ID'] ) {
                $view = get_permalink( $_POST['post_ID'] );
                $edit = esc_url( get_edit_post_link( $_POST['post_ID'] ) );
                if ( 'post-quickpress-publish' == $_POST['action'] ) {
                        if ( current_user_can('publish_posts') )
-                               printf( '<div class="message"><p>' . __( 'Post Published. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( $view ), $edit );
+                               printf( '<div class="updated"><p>' . __( 'Post published. <a href="%s">View post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( $view ), $edit );
                        else
                        else
-                               printf( '<div class="message"><p>' . __( 'Post submitted. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit );
+                               printf( '<div class="updated"><p>' . __( 'Post submitted. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit );
                } else {
                } else {
-                       printf( '<div class="message"><p>' . __( 'Draft Saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit );
+                       printf( '<div class="updated"><p>' . __( 'Draft saved. <a href="%s">Preview post</a> | <a href="%s">Edit post</a>' ) . '</p></div>', esc_url( add_query_arg( 'preview', 1, $view ) ), $edit );
                        $drafts_query = new WP_Query( array(
                                'post_type' => 'post',
                                'post_status' => 'draft',
                        $drafts_query = new WP_Query( array(
                                'post_type' => 'post',
                                'post_status' => 'draft',
@@ -378,11 +409,26 @@ function wp_dashboard_quick_press() {
                        if ( $drafts_query->posts )
                                $drafts =& $drafts_query->posts;
                }
                        if ( $drafts_query->posts )
                                $drafts =& $drafts_query->posts;
                }
-               printf('<p class="textright">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href="tools.php">' . __('Press This') . '</a>' );
+               printf('<p class="textright">' . __('You can also try %s, easy blogging from anywhere on the Web.') . '</p>', '<a href="' . esc_url( admin_url( 'tools.php' ) ) . '">' . __('Press This') . '</a>' );
                $_REQUEST = array(); // hack for get_default_post_to_edit()
        }
 
                $_REQUEST = array(); // hack for get_default_post_to_edit()
        }
 
-       $post = get_default_post_to_edit();
+       /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
+       $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
+       if ( $last_post_id ) {
+               $post = get_post( $last_post_id );
+               if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
+                       $post = get_default_post_to_edit('post', true);
+                       update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
+               } else {
+                       $post->post_title = ''; // Remove the auto draft title
+               }
+       } else {
+               $post = get_default_post_to_edit('post', true);
+               update_user_option( (int) $GLOBALS['current_user']->ID, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
+       }
+
+       $post_ID = (int) $post->ID;
 ?>
 
        <form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press">
 ?>
 
        <form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press">
@@ -411,15 +457,15 @@ function wp_dashboard_quick_press() {
 
                <p class="submit">
                        <input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" />
 
                <p class="submit">
                        <input type="hidden" name="action" id="quickpost-action" value="post-quickpress-save" />
-                       <input type="hidden" name="quickpress_post_ID" value="<?php echo (int) $post->ID; ?>" />
+                       <input type="hidden" name="quickpress_post_ID" value="<?php echo $post_ID; ?>" />
+                       <input type="hidden" name="post_type" value="post" />
                        <?php wp_nonce_field('add-post'); ?>
                        <input type="submit" name="save" id="save-post" class="button" tabindex="4" value="<?php esc_attr_e('Save Draft'); ?>" />
                        <input type="reset" value="<?php esc_attr_e( 'Reset' ); ?>" class="button" />
                        <?php wp_nonce_field('add-post'); ?>
                        <input type="submit" name="save" id="save-post" class="button" tabindex="4" value="<?php esc_attr_e('Save Draft'); ?>" />
                        <input type="reset" value="<?php esc_attr_e( 'Reset' ); ?>" class="button" />
-                       <?php if ( current_user_can('publish_posts') ) { ?>
-                       <input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php esc_attr_e('Publish'); ?>" />
-                       <?php } else { ?>
-                       <input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php esc_attr_e('Submit for Review'); ?>" />
-                       <?php } ?>
+                       <span id="publishing-action">
+                               <input type="submit" name="publish" id="publish" accesskey="p" tabindex="5" class="button-primary" value="<?php current_user_can('publish_posts') ? esc_attr_e('Publish') : esc_attr_e('Submit for Review'); ?>" />
+                               <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" />
+                       </span>
                        <br class="clear" />
                </p>
 
                        <br class="clear" />
                </p>
 
@@ -430,6 +476,10 @@ function wp_dashboard_quick_press() {
                wp_dashboard_recent_drafts( $drafts );
 }
 
                wp_dashboard_recent_drafts( $drafts );
 }
 
+function wp_dashboard_quick_press() {
+       echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
+}
+
 function wp_dashboard_recent_drafts( $drafts = false ) {
        if ( !$drafts ) {
                $drafts_query = new WP_Query( array(
 function wp_dashboard_recent_drafts( $drafts = false ) {
        if ( !$drafts ) {
                $drafts_query = new WP_Query( array(
@@ -481,12 +531,18 @@ function wp_dashboard_recent_comments() {
        $comments = array();
        $start = 0;
 
        $comments = array();
        $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;
+
        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" ) ) {
 
                foreach ( $possible as $comment ) {
        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" ) ) {
 
                foreach ( $possible as $comment ) {
-                       if ( count( $comments ) >= 5 )
+                       if ( count( $comments ) >= $total_items )
                                break;
                                break;
-                       if ( in_array( $comment->comment_approved, $allowed_states ) )
+                       if ( in_array( $comment->comment_approved, $allowed_states ) && current_user_can( 'read_post', $comment->comment_post_ID ) )
                                $comments[] = $comment;
                }
 
                                $comments[] = $comment;
                }
 
@@ -582,7 +638,10 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
                        <?php echo get_avatar( $comment, 50 ); ?>
 
                        <div class="dashboard-comment-wrap">
                        <?php echo get_avatar( $comment, 50 ); ?>
 
                        <div class="dashboard-comment-wrap">
-                       <h4 class="comment-meta"><?php printf( __( 'From %1$s on %2$s%3$s' ), '<cite class="comment-author">' . get_comment_author_link() . '</cite>', $comment_post_link.' '.$comment_link, ' <span class="approve">' . __( '[Pending]' ) . '</span>' ); ?></h4>
+                       <h4 class="comment-meta">
+                               <?php printf( /* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */__( 'From %1$s on %2$s%3$s' ),
+                                       '<cite class="comment-author">' . get_comment_author_link() . '</cite>', $comment_post_link.' '.$comment_link, ' <span class="approve">' . __( '[Pending]' ) . '</span>' ); ?>
+                       </h4>
 
                        <?php
                        else :
 
                        <?php
                        else :
@@ -611,6 +670,32 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
 <?php
 }
 
 <?php
 }
 
+/**
+ * The recent comments dashboard widget control.
+ *
+ * @since 3.0.0
+ */
+function wp_dashboard_recent_comments_control() {
+       if ( !$widget_options = get_option( 'dashboard_widget_options' ) )
+               $widget_options = array();
+
+       if ( !isset($widget_options['dashboard_recent_comments']) )
+               $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;
+               $widget_options['dashboard_recent_comments']['items'] = $number;
+               update_option( 'dashboard_widget_options', $widget_options );
+       }
+
+       $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>';
+}
+
 function wp_dashboard_incoming_links() {
        echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
 }
 function wp_dashboard_incoming_links() {
        echo '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="describe hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
 }
@@ -636,7 +721,7 @@ function wp_dashboard_incoming_links_output() {
 
        if ( !$rss->get_item_quantity() ) {
                echo '<p>' . __('This dashboard widget queries <a href="http://blogsearch.google.com/">Google Blog Search</a> so that when another blog links to your site it will show up here. It has found no incoming links&hellip; yet. It&#8217;s okay &#8212; there is no rush.') . "</p>\n";
 
        if ( !$rss->get_item_quantity() ) {
                echo '<p>' . __('This dashboard widget queries <a href="http://blogsearch.google.com/">Google Blog Search</a> so that when another blog links to your site it will show up here. It has found no incoming links&hellip; yet. It&#8217;s okay &#8212; there is no rush.') . "</p>\n";
-               $rss->__destruct(); 
+               $rss->__destruct();
                unset($rss);
                return;
        }
                unset($rss);
                return;
        }
@@ -691,7 +776,7 @@ function wp_dashboard_incoming_links_output() {
        }
 
        echo "</ul>\n";
        }
 
        echo "</ul>\n";
-       $rss->__destruct(); 
+       $rss->__destruct();
        unset($rss);
 }
 
        unset($rss);
 }
 
@@ -748,14 +833,14 @@ function wp_dashboard_secondary_output() {
                        echo '</p></div>';
                }
        } elseif ( !$rss->get_item_quantity() ) {
                        echo '</p></div>';
                }
        } elseif ( !$rss->get_item_quantity() ) {
-               $rss->__destruct(); 
+               $rss->__destruct();
                unset($rss);
                return false;
        } else {
                echo '<div class="rss-widget">';
                wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] );
                echo '</div>';
                unset($rss);
                return false;
        } else {
                echo '<div class="rss-widget">';
                wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] );
                echo '</div>';
-               $rss->__destruct(); 
+               $rss->__destruct();
                unset($rss);
        }
 }
                unset($rss);
        }
 }
@@ -839,7 +924,7 @@ function wp_dashboard_plugins_output() {
                echo "<h4>$label</h4>\n";
                echo "<h5><a href='$link'>$title</a></h5>&nbsp;<span>(<a href='$ilink' class='thickbox' title='$title'>" . __( 'Install' ) . "</a>)</span>\n";
                echo "<p>$description</p>\n";
                echo "<h4>$label</h4>\n";
                echo "<h5><a href='$link'>$title</a></h5>&nbsp;<span>(<a href='$ilink' class='thickbox' title='$title'>" . __( 'Install' ) . "</a>)</span>\n";
                echo "<p>$description</p>\n";
-               
+
                $$feed->__destruct();
                unset($$feed);
        }
                $$feed->__destruct();
                unset($$feed);
        }
@@ -938,9 +1023,9 @@ function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) {
                        if ( is_wp_error($rss) ) {
                                $widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed'));
                        } else {
                        if ( is_wp_error($rss) ) {
                                $widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed'));
                        } else {
-                               $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title()));     
+                               $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title()));
                                $rss->__destruct();
                                $rss->__destruct();
-                               unset($rss);                            
+                               unset($rss);
                        }
                }
                update_option( 'dashboard_widget_options', $widget_options );
                        }
                }
                update_option( 'dashboard_widget_options', $widget_options );