diff --git wp-admin/admin-ajax.php wp-admin/admin-ajax.php
index cef3981..e912aa8 100644
|
|
|
case 'fetch-list' : |
| 57 | 57 | $current_screen->is_network = 'false' === $current_screen->is_network ? false : true; |
| 58 | 58 | $current_screen->is_user = 'false' === $current_screen->is_user ? false : true; |
| 59 | 59 | |
| 60 | | $wp_list_table = get_list_table( $_GET['list_args']['class'] ); |
| 61 | | if ( ! $wp_list_table ) |
| 62 | | die( '0' ); |
| | 60 | if ( $current_screen->id == 'dashboard' ) { |
| | 61 | require_once( ABSPATH . 'wp-admin/includes/dashboard.php' ); |
| | 62 | |
| | 63 | ob_start(); |
| | 64 | wp_dashboard_recent_comments( true ); |
| | 65 | $rows = ob_get_clean(); |
| | 66 | |
| | 67 | $response = array( 'rows' => $rows ); |
| | 68 | die( json_encode( $response ) ); |
| | 69 | exit; |
| | 70 | } else { |
| | 71 | $wp_list_table = get_list_table( $_GET['list_args']['class'] ); |
| | 72 | if ( ! $wp_list_table ) |
| | 73 | die( '0' ); |
| 63 | 74 | |
| 64 | | $wp_list_table->ajax_response(); |
| | 75 | $wp_list_table->ajax_response(); |
| | 76 | } |
| 65 | 77 | |
| 66 | 78 | die( '0' ); |
| 67 | 79 | break; |
diff --git wp-admin/includes/dashboard.php wp-admin/includes/dashboard.php
index fc5ca47..6ba49fb 100644
|
|
|
function wp_dashboard_recent_drafts( $drafts = false ) { |
| 593 | 593 | * |
| 594 | 594 | * @since 2.5.0 |
| 595 | 595 | */ |
| 596 | | function wp_dashboard_recent_comments() { |
| | 596 | function wp_dashboard_recent_comments( $refill = false ) { |
| 597 | 597 | global $wpdb; |
| 598 | 598 | |
| 599 | 599 | if ( current_user_can('edit_posts') ) |
| … |
… |
function wp_dashboard_recent_comments() { |
| 604 | 604 | // Select all comment types and filter out spam later for better query performance. |
| 605 | 605 | $comments = array(); |
| 606 | 606 | $start = 0; |
| 607 | | |
| 608 | 607 | $widgets = get_option( 'dashboard_widget_options' ); |
| 609 | | $total_items = isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] ) |
| | 608 | $comments_shown = isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] ) |
| 610 | 609 | ? absint( $widgets['dashboard_recent_comments']['items'] ) : 5; |
| | 610 | |
| | 611 | if ( $refill ) { |
| | 612 | $total_items = 1; // only needs to fetch 1 to refill the river |
| | 613 | $offset = $comments_shown + 2; // comments being shown plus 3 in the extra list minus 1 just deleted / spammed |
| | 614 | } else { |
| | 615 | $total_items = $comments_shown + 3; // extra items for the river |
| | 616 | } |
| 611 | 617 | |
| 612 | | 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" ) ) { |
| | 618 | while ( count( $comments ) < $total_items && $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" ) ) { |
| 613 | 619 | |
| 614 | 620 | foreach ( $possible as $comment ) { |
| 615 | 621 | if ( count( $comments ) >= $total_items ) |
| 616 | 622 | break; |
| 617 | | if ( in_array( $comment->comment_approved, $allowed_states ) && current_user_can( 'read_post', $comment->comment_post_ID ) ) |
| | 623 | if ( in_array( $comment->comment_approved, $allowed_states ) && current_user_can( 'read_post', $comment->comment_post_ID ) ) { |
| | 624 | // skip if we're refilling, and this comment is already shown |
| | 625 | if ( $refill && $offset > 0 ) { |
| | 626 | $offset --; |
| | 627 | continue; |
| | 628 | } |
| | 629 | |
| 618 | 630 | $comments[] = $comment; |
| | 631 | } |
| 619 | 632 | } |
| 620 | 633 | |
| 621 | 634 | $start = $start + 50; |
| 622 | 635 | } |
| 623 | 636 | |
| 624 | 637 | if ( $comments ) : |
| | 638 | if ( $refill ) : |
| | 639 | _wp_dashboard_recent_comments_row( $comments[0] ); |
| | 640 | else : // $refill |
| 625 | 641 | ?> |
| 626 | | |
| 627 | | <div id="the-comment-list" class="list:comment"> |
| | 642 | <div id="the-comment-list" class="list:comment"> |
| 628 | 643 | <?php |
| 629 | | foreach ( $comments as $comment ) |
| 630 | | _wp_dashboard_recent_comments_row( $comment ); |
| | 644 | $i = 0; |
| | 645 | while ( $i < $comments_shown ) { |
| | 646 | _wp_dashboard_recent_comments_row( $comments[$i] ); |
| | 647 | $i++; |
| | 648 | } |
| 631 | 649 | ?> |
| 632 | 650 | |
| 633 | | </div> |
| | 651 | </div> |
| | 652 | |
| | 653 | <div id="the-extra-comment-list" class="list:comment" style="display:none"> |
| | 654 | <?php |
| | 655 | while ( $i < $total_items ) { |
| | 656 | _wp_dashboard_recent_comments_row( $comments[$i] ); |
| | 657 | $i++; |
| | 658 | } |
| | 659 | ?> |
| | 660 | </div> |
| 634 | 661 | |
| 635 | 662 | <?php |
| 636 | | if ( current_user_can('edit_posts') ) { ?> |
| 637 | | <p class="textright"><a href="edit-comments.php" class="button"><?php _e('View all'); ?></a></p> |
| | 663 | if ( current_user_can('edit_posts') ) { ?> |
| | 664 | <p class="textright"><a href="edit-comments.php" class="button"><?php _e('View all'); ?></a></p> |
| 638 | 665 | <?php } |
| 639 | 666 | |
| 640 | | wp_comment_reply( -1, false, 'dashboard', false ); |
| 641 | | wp_comment_trashnotice(); |
| 642 | | |
| 643 | | else : |
| | 667 | wp_comment_reply( -1, false, 'dashboard', false ); |
| | 668 | wp_comment_trashnotice(); |
| | 669 | endif; // $refill |
| | 670 | else :// $comments |
| 644 | 671 | ?> |
| 645 | 672 | |
| 646 | 673 | <p><?php _e( 'No comments yet.' ); ?></p> |
diff --git wp-admin/js/edit-comments.dev.js wp-admin/js/edit-comments.dev.js
index 76bcc79..27f6418 100644
|
|
|
setCommentsList = function() { |
| 215 | 215 | |
| 216 | 216 | var refillTheExtraList = function(ev) { |
| 217 | 217 | var args = $.query.get(), total_pages = listTable.get_total_pages(), per_page = $('input[name=_per_page]', '#comments-form').val(); |
| 218 | | |
| 219 | | if (args.paged > total_pages) { |
| 220 | | return; |
| 221 | | } |
| 222 | 218 | |
| 223 | | if (ev) { |
| 224 | | theExtraList.empty(); |
| 225 | | args.number = Math.min(8, per_page); // see WP_Comments_List_Table::prepare_items() @ class-wp-comments-list-table.php |
| 226 | | } else { |
| 227 | | args.number = 1; |
| 228 | | args.offset = per_page - 1; // fetch only the last item of the next page |
| | 219 | if (total_pages && args.paged > total_pages) { |
| | 220 | return; |
| 229 | 221 | } |
| 230 | 222 | |
| 231 | | args.paged ++; |
| | 223 | if (pagenow != 'dashboard') { |
| | 224 | if (ev) { |
| | 225 | theExtraList.empty(); |
| | 226 | args.number = Math.min(8, per_page); // see WP_Comments_List_Table::prepare_items() @ class-wp-comments-list-table.php |
| | 227 | } else { |
| | 228 | args.number = 1; |
| | 229 | args.offset = per_page - 1; // fetch only the last item of the next page |
| | 230 | } |
| | 231 | args.paged ++; |
| | 232 | } |
| 232 | 233 | |
| 233 | 234 | listTable.fetch_list(args, function(response) { |
| 234 | 235 | theExtraList.get(0).wpList.add( response.rows ); |