diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 82c822245a..366a4fef92 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -24,6 +24,9 @@ function wp_dashboard_setup() { /* Register Widgets and Controls */ + // Right Now + wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' ); + // Recent Comments Widget wp_add_dashboard_widget( 'dashboard_recent_comments', __( 'Recent Comments' ), 'wp_dashboard_recent_comments' ); @@ -150,6 +153,119 @@ function wp_dashboard() { /* Dashboard Widgets */ +function wp_dashboard_right_now() { + $num_posts = wp_count_posts( 'post' ); + $num_pages = wp_count_posts( 'page' ); + + $num_cats = wp_count_terms('category'); + + $num_tags = wp_count_terms('post_tag'); + + $num_comm = get_comment_count( ); + + echo '
' . __('At a Glance') . '
'; + echo '| $num | "; + echo '' . __ngettext( 'Post', 'Posts', $num_posts->publish ) . ' | '; + /* 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[] = ''.sprintf( __ngettext( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).''; + } + if ( $can_edit_posts && !empty($num_posts->draft) ) { + $post_type_texts[] = ''.sprintf( __ngettext( '%s draft', '%s drafts', $num_posts->draft ), number_format_i18n( $num_posts->draft ) ).''; + } + if ( $can_edit_posts && !empty($num_posts->future) ) { + $post_type_texts[] = ''.sprintf( __ngettext( '%s scheduled post', '%s scheduled posts', $num_posts->future ), number_format_i18n( $num_posts->future ) ).''; + } + if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) { + $pending_text = sprintf( __ngettext( 'There is %2$s post pending your review.', 'There are %2$s posts pending your review.', $num_posts->pending ), 'edit.php?post_status=pending', number_format_i18n( $num_posts->pending ) ); + } else { + $pending_text = ''; + } + */ + + // Total Comments + $num = number_format_i18n($num_comm['total_comments']); + if ( current_user_can( 'moderate_comments' ) ) + $num = "$num"; + echo "$num | "; + echo '' . __ngettext( 'Comment', 'Comments', $num_comm['total_comments'] ) . ' | '; + + echo '
| $num | "; + echo '' . __ngettext( 'Page', 'Pages', $num_pages->publish ) . ' | '; + + // Approved Comments + $num = number_format_i18n($num_comm['approved']); + if ( current_user_can( 'moderate_comments' ) ) + $num = "$num"; + echo "$num | "; + echo '' . __ngettext( 'Approved', 'Approved', $num_comm['approved'] ) . ' | '; + + echo '
| $num | "; + echo '' . __ngettext( 'Category', 'Categories', $num_cats ) . ' | '; + + // Spam Comments + $num = number_format_i18n($num_comm['spam']); + if ( current_user_can( 'moderate_comments' ) ) + $num = "$num"; + echo "$num | "; + echo '' . __ngettext( 'Spam', 'Spam', $num_comm['spam'] ) . ' | '; + + echo '
| $num | "; + echo '' . __ngettext( 'Tag', 'Tags', $num_tags ) . ' | '; + + // Pending Comments + $num = number_format_i18n($num_comm['awaiting_moderation']); + if ( current_user_can( 'moderate_comments' ) ) + $num = "$num"; + echo "$num | "; + echo '' . __ngettext( 'Pending', 'Pending', $num_comm['awaiting_moderation'] ) . ' | '; + + echo '
'; + printf(__ngettext('Theme %1$s with %2$s Widgets', 'Theme %1$s with %2$s Widgets', $num_widgets), $ct->title, $num); + if ( $can_switch_themes ) + echo '' . __('Change Theme') . ''; + echo '
'; + + update_right_now_message(); + + do_action( 'rightnow_end' ); + do_action( 'activity_box_end' ); +} + function wp_dashboard_quick_press( $dashboard, $meta_box ) { $drafts = false; if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) && isset( $_POST['action'] ) && 0 === strpos( $_POST['action'], 'post-quickpress' ) ) {