Plugin Directory

Changeset 786069


Ignore:
Timestamp:
10/10/2013 07:41:40 PM (12 years ago)
Author:
lessbloat
Message:

Super rough pass at fleshing out the rest of the activity widget - still needs a fair amount of code refactoring and CSS love.

Location:
dashboard/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • dashboard/trunk/activity.php

    r780696 r786069  
    55function add_activity_dashboard_widget() {
    66    add_meta_box( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_activity', 'dashboard', 'normal', 'high' );
    7     remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
    87}
    98
     
    1312    echo '<div id="activity-widget">';
    1413
    15     dash_publishing_soon();
    16     //dash_comments();
     14    dash_show_published_posts( array(
     15        'display' => 2,
     16        'max' => 5,
     17        'status' => 'future',
     18        'title' => __( 'Publishing Soon' ),
     19        'id' => 'future-posts',
     20    ) );
     21    dash_show_published_posts( array(
     22        'display' => 2,
     23        'max' => 5,
     24        'status' => 'publish',
     25        'title' => __( 'Recently Published' ),
     26        'id' => 'published-posts',
     27    ) );
     28    dash_comments();
    1729
    1830    echo '</div>';
     
    2032}
    2133
    22 // show `Publishing Soon` section
    23 function dash_publishing_soon( $display = 2, $max = 5 ) {
     34// Generates `Publishing Soon` and `Recently Published` sections
     35function dash_show_published_posts( $args ) {
    2436
    25     $future_posts = new WP_Query(array(
     37    $posts = new WP_Query(array(
    2638        'post_type' => 'post',
    27         'post_status' => 'future',
     39        'post_status' => $args['status'],
    2840        'orderby' => 'date',
    2941        'order' => 'ASC',
    30         'posts_per_page' => intval( $max )
     42        'posts_per_page' => intval( $args['max'] )
    3143    ));
    3244
    33     if ( $future_posts->have_posts() ) {
     45    if ( $posts->have_posts() ) {
    3446
    35         echo '<div id="future-posts">';
    36         echo '<strong>' . __( 'Publishing Soon' ) . '</strong>';
     47        echo '<div id="' . $args['id'] . '" class="activity-block">';
     48        echo $args['title'];
    3749
    38         if ( $future_posts->post_count > $display ) {
    39             echo '<small class="show-more"><a href="#">' . sprintf( __( 'See %s more&hellip;'), $future_posts->post_count - intval( $display ) ) . '</a></small>';
     50        if ( $posts->post_count > $args['display'] ) {
     51            echo '<small class="show-more"><a href="#">' . sprintf( __( 'See %s more&hellip;'), $posts->post_count - intval( $args['display'] ) ) . '</a></small>';
    4052        }
    4153
     
    4355
    4456        $i = 0;
    45         while ( $future_posts->have_posts() ) {
    46             $future_posts->the_post();
     57        while ( $posts->have_posts() ) {
     58            $posts->the_post();
    4759            printf(
    4860                '<li%s><span>%s, %s</span> <a href="%s">%s</a></li>',
    49                 ( $i >= intval ( $display ) ? ' class="hidden"' : '' ),
     61                ( $i >= intval ( $args['display'] ) ? ' class="hidden"' : '' ),
    5062                dash_relative_date( get_the_time( 'U' ) ),
    5163                get_the_time(),
     
    6678
    6779// show `Comments` section
    68 function dash_comments( $display = 5 ) {
     80function dash_comments( $total_items = 5 ) {
     81    global $wpdb;
    6982
    70     $comments = new WP_Comment_Query(array(
    71         'status' => '',
    72         'number' => intval( $display )
    73     ));
     83    // Select all comment types and filter out spam later for better query performance.
     84    $comments = array();
     85    $start = 0;
    7486
    75     echo '<div id="latest-comments">';
    76     echo '<strong>' . __( 'Comments' ) . '</strong>';
     87    $comments_query = array( 'number' => $total_items * 5, 'offset' => 0 );
     88    if ( ! current_user_can( 'edit_posts' ) )
     89        $comments_query['status'] = 'approve';
    7790
    78     echo '</ul>';
     91    while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) {
     92        foreach ( $possible as $comment ) {
     93            if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) )
     94                continue;
     95            $comments[] = $comment;
     96            if ( count( $comments ) == $total_items )
     97                break 2;
     98        }
     99        $comments_query['offset'] += $comments_query['number'];
     100        $comments_query['number'] = $total_items * 10;
     101    }
     102   
     103    echo '<div id="latest-comments" class="activity-block">';
     104    _e( 'Comments' );
     105
     106    if ( $comments ) {
     107        echo '<div id="the-comment-list" data-wp-lists="list:comment">';
     108        foreach ( $comments as $comment )
     109            _wp_dashboard_recent_comments_row( $comment );
     110        echo '</div>';
     111
     112        if ( current_user_can('edit_posts') )
     113            _get_list_table('WP_Comments_List_Table')->views();
     114
     115        wp_comment_reply( -1, false, 'dashboard', false );
     116        wp_comment_trashnotice();
     117    } else {
     118        echo '<p>' . __( 'No comments yet.' ) . '</p>';
     119    }
     120   
    79121    echo '</div>';
    80122
  • dashboard/trunk/css/activity.css

    r780696 r786069  
    1 #future-posts .show-more {
     1#dashboard_activity .inside {
     2    padding: 0;
     3    margin: 0;
     4}
     5
     6#future-posts .show-more,
     7#published-posts .show-more {
    28    float: right;
    39}
    410
    5 #future-posts ul {
     11#future-posts ul,
     12#published-posts ul {
    613    clear: both;
    714}
    815
    9 #future-posts ul span {
     16#future-posts li,
     17#published-posts li {
     18    overflow: hidden;
     19}
     20
     21#future-posts ul span,
     22#published-posts ul span {
    1023    color: #aaa;
     24    float: left;
     25    margin-right: 8px;
     26    min-width: 150px;
    1127}
     28
     29.activity-block {
     30    border-bottom: 1px solid #eee;
     31    overflow: hidden;
     32    padding: 12px 12px 0;
     33}
     34
     35.activity-block:last-child {
     36    border-bottom: none;
     37    padding-bottom: 10px;
     38}
     39
     40.activity-block .subsubsub li {
     41    color: #ddd;
     42}
     43
     44#the-comment-list .comment {
     45    border-left: 4px solid #fff;
     46}
     47
     48#the-comment-list .unapproved {
     49    background: none;
     50    border-left: 4px solid #f4f290;
     51}
     52
     53#the-comment-list .alternate,
     54#the-comment-list .alt {
     55    background: none;
     56}
  • dashboard/trunk/dashboard-override.php

    r785524 r786069  
    1919remove_meta_box( 'dashboard_primary', 'dashboard', 'side' );
    2020remove_meta_box( 'dashboard_secondary', 'dashboard', 'side' );
     21// Remove Recent Comments
     22remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
    2123 
    2224wp_enqueue_script( 'dashboard' );
  • dashboard/trunk/js/dash-rwd.js

    r785996 r786069  
    1515    });
    1616});
     17
    1718jQuery(window).resize( _.debounce( function(){
    1819    updateColumnCount();
    1920}, 50) );
     21
    2022function updateColumnCount() {
    2123    var cols = 1,
Note: See TracChangeset for help on using the changeset viewer.