Changeset 786069
- Timestamp:
- 10/10/2013 07:41:40 PM (12 years ago)
- Location:
- dashboard/trunk
- Files:
-
- 4 edited
-
activity.php (modified) (5 diffs)
-
css/activity.css (modified) (1 diff)
-
dashboard-override.php (modified) (1 diff)
-
js/dash-rwd.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
dashboard/trunk/activity.php
r780696 r786069 5 5 function add_activity_dashboard_widget() { 6 6 add_meta_box( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_activity', 'dashboard', 'normal', 'high' ); 7 remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );8 7 } 9 8 … … 13 12 echo '<div id="activity-widget">'; 14 13 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(); 17 29 18 30 echo '</div>'; … … 20 32 } 21 33 22 // show `Publishing Soon` section23 function dash_ publishing_soon( $display = 2, $max = 5) {34 // Generates `Publishing Soon` and `Recently Published` sections 35 function dash_show_published_posts( $args ) { 24 36 25 $ future_posts = new WP_Query(array(37 $posts = new WP_Query(array( 26 38 'post_type' => 'post', 27 'post_status' => 'future',39 'post_status' => $args['status'], 28 40 'orderby' => 'date', 29 41 'order' => 'ASC', 30 'posts_per_page' => intval( $ max)42 'posts_per_page' => intval( $args['max'] ) 31 43 )); 32 44 33 if ( $ future_posts->have_posts() ) {45 if ( $posts->have_posts() ) { 34 46 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']; 37 49 38 if ( $ future_posts->post_count > $display) {39 echo '<small class="show-more"><a href="#">' . sprintf( __( 'See %s more…'), $ 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…'), $posts->post_count - intval( $args['display'] ) ) . '</a></small>'; 40 52 } 41 53 … … 43 55 44 56 $i = 0; 45 while ( $ future_posts->have_posts() ) {46 $ future_posts->the_post();57 while ( $posts->have_posts() ) { 58 $posts->the_post(); 47 59 printf( 48 60 '<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"' : '' ), 50 62 dash_relative_date( get_the_time( 'U' ) ), 51 63 get_the_time(), … … 66 78 67 79 // show `Comments` section 68 function dash_comments( $display = 5 ) { 80 function dash_comments( $total_items = 5 ) { 81 global $wpdb; 69 82 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; 74 86 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'; 77 90 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 79 121 echo '</div>'; 80 122 -
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 { 2 8 float: right; 3 9 } 4 10 5 #future-posts ul { 11 #future-posts ul, 12 #published-posts ul { 6 13 clear: both; 7 14 } 8 15 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 { 10 23 color: #aaa; 24 float: left; 25 margin-right: 8px; 26 min-width: 150px; 11 27 } 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 19 19 remove_meta_box( 'dashboard_primary', 'dashboard', 'side' ); 20 20 remove_meta_box( 'dashboard_secondary', 'dashboard', 'side' ); 21 // Remove Recent Comments 22 remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' ); 21 23 22 24 wp_enqueue_script( 'dashboard' ); -
dashboard/trunk/js/dash-rwd.js
r785996 r786069 15 15 }); 16 16 }); 17 17 18 jQuery(window).resize( _.debounce( function(){ 18 19 updateColumnCount(); 19 20 }, 50) ); 21 20 22 function updateColumnCount() { 21 23 var cols = 1,
Note: See TracChangeset
for help on using the changeset viewer.