WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/21/2008 05:56:48 PM (12 years ago)
Author:
ryan
Message:

Right Now modules. Very rough, needs styling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/dashboard.php

    r9223 r9265  
    2424
    2525    /* Register Widgets and Controls */
     26
     27    // Right Now
     28    wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' );
    2629
    2730    // Recent Comments Widget
     
    150153
    151154/* Dashboard Widgets */
     155
     156function wp_dashboard_right_now() {
     157    $num_posts = wp_count_posts( 'post' );
     158    $num_pages = wp_count_posts( 'page' );
     159
     160    $num_cats  = wp_count_terms('category');
     161
     162    $num_tags = wp_count_terms('post_tag');
     163
     164    $num_comm = get_comment_count( );
     165
     166    echo '<p>' . __('At a Glance') . '</p>';
     167    echo '<table>';
     168    echo '<tr>';
     169
     170    // Posts
     171    $num = number_format_i18n( $num_posts->publish );
     172    if ( current_user_can( 'edit_posts' ) )
     173        $num = "<a href='edit.php'>$num</a>";
     174    echo "<td>$num</td>";
     175    echo '<td>' . __ngettext( 'Post', 'Posts', $num_posts->publish ) . '</td>';
     176    /* TODO: Show status breakdown on hover
     177    if ( $can_edit_pages && !empty($num_pages->publish) ) { // how many pages is not exposed in feeds.  Don't show if !current_user_can
     178        $post_type_texts[] = '<a href="edit-pages.php">'.sprintf( __ngettext( '%s page', '%s pages', $num_pages->publish ), number_format_i18n( $num_pages->publish ) ).'</a>';
     179    }
     180    if ( $can_edit_posts && !empty($num_posts->draft) ) {
     181        $post_type_texts[] = '<a href="edit.php?post_status=draft">'.sprintf( __ngettext( '%s draft', '%s drafts', $num_posts->draft ), number_format_i18n( $num_posts->draft ) ).'</a>';
     182    }
     183    if ( $can_edit_posts && !empty($num_posts->future) ) {
     184        $post_type_texts[] = '<a href="edit.php?post_status=future">'.sprintf( __ngettext( '%s scheduled post', '%s scheduled posts', $num_posts->future ), number_format_i18n( $num_posts->future ) ).'</a>';
     185    }
     186    if ( current_user_can('publish_posts') && !empty($num_posts->pending) ) {
     187        $pending_text = sprintf( __ngettext( 'There is <a href="%1$s">%2$s post</a> pending your review.', 'There are <a href="%1$s">%2$s posts</a> pending your review.', $num_posts->pending ), 'edit.php?post_status=pending', number_format_i18n( $num_posts->pending ) );
     188    } else {
     189        $pending_text = '';
     190    }
     191    */
     192
     193    // Total Comments
     194    $num = number_format_i18n($num_comm['total_comments']);
     195    if ( current_user_can( 'moderate_comments' ) )
     196        $num = "<a href='edit-comments.php'>$num</a>";
     197    echo "<td>$num</td>";
     198    echo '<td>' . __ngettext( 'Comment', 'Comments', $num_comm['total_comments'] ) . '</td>';
     199
     200    echo '</tr><tr>';
     201
     202    // Pages
     203    $num = number_format_i18n( $num_pages->publish );
     204    if ( current_user_can( 'edit_pages' ) )
     205        $num = "<a href='edit-pages.php'>$num</a>";
     206    echo "<td>$num</td>";
     207    echo '<td>' . __ngettext( 'Page', 'Pages', $num_pages->publish ) . '</td>';
     208
     209    // Approved Comments
     210    $num = number_format_i18n($num_comm['approved']);
     211    if ( current_user_can( 'moderate_comments' ) )
     212        $num = "<a href='edit-comments.php?comment_status=approved'>$num</a>";
     213    echo "<td>$num</td>";
     214    echo '<td>' . __ngettext( 'Approved', 'Approved', $num_comm['approved'] ) . '</td>';
     215
     216    echo '</tr><tr>';
     217
     218    // Categories
     219    $num = number_format_i18n( $num_cats );
     220    if ( current_user_can( 'manage_categories' ) )
     221        $num = "<a href='categories.php'>$num</a>";
     222    echo "<td>$num</td>";
     223    echo '<td>' . __ngettext( 'Category', 'Categories', $num_cats ) . '</td>';
     224
     225    // Spam Comments
     226    $num = number_format_i18n($num_comm['spam']);
     227    if ( current_user_can( 'moderate_comments' ) )
     228        $num = "<a href='edit-comments.php?comment_status=spam'>$num</a>";
     229    echo "<td>$num</td>";
     230    echo '<td>' . __ngettext( 'Spam', 'Spam', $num_comm['spam'] ) . '</td>';
     231
     232    echo '</tr><tr>';
     233
     234    // Tags
     235    $num = number_format_i18n( $num_tags );
     236    if ( current_user_can( 'manage_categories' ) )
     237        $num = "<a href='edit-tags.php'>$num</a>";
     238    echo "<td>$num</td>";
     239    echo '<td>' . __ngettext( 'Tag', 'Tags', $num_tags ) . '</td>';
     240
     241    // Pending Comments
     242    $num = number_format_i18n($num_comm['awaiting_moderation']);
     243    if ( current_user_can( 'moderate_comments' ) )
     244        $num = "<a href='edit-comments.php?comment_status=moderated'>$num</a>";
     245    echo "<td>$num</td>";
     246    echo '<td>' . __ngettext( 'Pending', 'Pending', $num_comm['awaiting_moderation'] ) . '</td>';
     247
     248    echo '</tr></table>';   
     249
     250    $ct = current_theme_info();
     251    $sidebars_widgets = wp_get_sidebars_widgets();
     252    $num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev, $curr', 'return $prev+count($curr);' ), 0 );
     253    $num = number_format_i18n( $num_widgets );
     254    if ( $can_switch_themes = current_user_can( 'switch_themes' ) )
     255        $num = "<a href='widgets.php'>$num</a>";
     256
     257    echo '<p>';
     258    printf(__ngettext('Theme %1$s with %2$s Widgets', 'Theme %1$s with %2$s Widgets', $num_widgets), $ct->title, $num);
     259    if ( $can_switch_themes )
     260        echo '<a href="themes.php" class="rbutton">' . __('Change Theme') . '</a>';
     261    echo '</p>';
     262
     263    update_right_now_message();
     264
     265    do_action( 'rightnow_end' );
     266    do_action( 'activity_box_end' );
     267}
    152268
    153269function wp_dashboard_quick_press( $dashboard, $meta_box ) {
Note: See TracChangeset for help on using the changeset viewer.