diff --git wp-admin/admin-ajax.php wp-admin/admin-ajax.php
index d2a8d4d..e3caf71 100644
|
|
|
if ( ! is_user_logged_in() ) { |
| 50 | 50 | |
| 51 | 51 | if ( isset( $_GET['action'] ) ) : |
| 52 | 52 | switch ( $action = $_GET['action'] ) : |
| | 53 | case 'recent-comments-refill' : |
| | 54 | check_ajax_referer( 'recent-comments-refill' ); |
| | 55 | |
| | 56 | // comment river for Dashboard Recent Comment |
| | 57 | require_once( ABSPATH . 'wp-admin/includes/dashboard.php' ); |
| | 58 | |
| | 59 | ob_start(); |
| | 60 | wp_dashboard_recent_comments( true ); |
| | 61 | $rows = ob_get_clean(); |
| | 62 | |
| | 63 | $response = array( 'rows' => $rows ); |
| | 64 | die( json_encode( $response ) ); |
| | 65 | exit; |
| 53 | 66 | case 'fetch-list' : |
| 54 | 67 | |
| 55 | 68 | $list_class = $_GET['list_args']['class']; |
| … |
… |
case 'fetch-list' : |
| 66 | 79 | $wp_list_table = _get_list_table( $list_class ); |
| 67 | 80 | if ( ! $wp_list_table ) |
| 68 | 81 | die( '0' ); |
| 69 | | |
| | 82 | |
| 70 | 83 | if ( ! $wp_list_table->ajax_user_can() ) |
| 71 | 84 | die( '-1' ); |
| 72 | 85 | |
diff --git wp-admin/includes/dashboard.php wp-admin/includes/dashboard.php
index 8f937f3..456d3e6 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 && $i < count( $comments ) ) { |
| | 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 && $i < count( $comments ) ) { |
| | 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 |
| | 671 | if ( $refill ) |
| | 672 | return FALSE; |
| 644 | 673 | ?> |
| 645 | | |
| 646 | | <p><?php _e( 'No comments yet.' ); ?></p> |
| 647 | | |
| | 674 | <p><?php _e( 'No comments yet.' ); ?></p> |
| 648 | 675 | <?php |
| 649 | 676 | endif; // $comments; |
| 650 | 677 | } |
diff --git wp-admin/index.php wp-admin/index.php
index 748141e..ac3149a 100644
|
|
|
require_once(ABSPATH . 'wp-admin/includes/dashboard.php'); |
| 15 | 15 | wp_dashboard_setup(); |
| 16 | 16 | |
| 17 | 17 | wp_enqueue_script( 'dashboard' ); |
| | 18 | wp_localize_script( 'dashboard', 'recentCommentsWidget', array( 'nonce' => wp_create_nonce( 'recent-comments-refill' ) ) ); |
| 18 | 19 | wp_enqueue_script( 'plugin-install' ); |
| 19 | 20 | wp_enqueue_script( 'media-upload' ); |
| 20 | 21 | wp_admin_css( 'dashboard' ); |
diff --git wp-admin/js/edit-comments.dev.js wp-admin/js/edit-comments.dev.js
index fbadeba..e178048 100644
|
|
|
setCommentsList = function() { |
| 217 | 217 | |
| 218 | 218 | var refillTheExtraList = function(ev) { |
| 219 | 219 | // var args = $.query.get(), total_pages = listTable.get_total_pages(), per_page = $('input[name=_per_page]', '#comments-form').val(), r; |
| 220 | | var args = $.query.get(), total_pages = $('.total-pages').text(), per_page = $('input[name=_per_page]', '#comments-form').val(), r; |
| 221 | | |
| 222 | | if (! args.paged) |
| 223 | | args.paged = 1; |
| 224 | | |
| 225 | | if (args.paged > total_pages) { |
| 226 | | return; |
| 227 | | } |
| | 220 | var args, total_pages = $('.total-pages').text(), per_page = $('input[name=_per_page]', '#comments-form').val(), r; |
| 228 | 221 | |
| 229 | | if (ev) { |
| 230 | | theExtraList.empty(); |
| 231 | | args.number = Math.min(8, per_page); // see WP_Comments_List_Table::prepare_items() @ class-wp-comments-list-table.php |
| | 222 | if (pagenow == 'dashboard') { |
| | 223 | args = { |
| | 224 | action : 'recent-comments-refill', |
| | 225 | _ajax_nonce : recentCommentsWidget.nonce |
| | 226 | }; |
| 232 | 227 | } else { |
| 233 | | args.number = 1; |
| 234 | | args.offset = Math.min(8, per_page) - 1; // fetch only the next item on the extra list |
| | 228 | args = $.query.get(); |
| | 229 | if (! args.paged) |
| | 230 | args.paged = 1; |
| | 231 | |
| | 232 | if (total_pages && args.paged > total_pages) |
| | 233 | return; |
| | 234 | |
| | 235 | if (ev) { |
| | 236 | theExtraList.empty(); |
| | 237 | args.number = Math.min(8, per_page); // see WP_Comments_List_Table::prepare_items() @ class-wp-comments-list-table.php |
| | 238 | } else { |
| | 239 | args.number = 1; |
| | 240 | args.offset = Math.min(8, per_page) - 1; // fetch only the next item on the extra list |
| | 241 | } |
| | 242 | |
| | 243 | args.paged ++; |
| | 244 | args.no_placeholder = true; |
| | 245 | |
| | 246 | // $.query.get() needs some correction to be sent into an ajax request |
| | 247 | if ( true === args.comment_type ) |
| | 248 | args.comment_type = ''; |
| | 249 | |
| | 250 | args = $.extend(args, { |
| | 251 | 'action': 'fetch-list', |
| | 252 | 'list_args': list_args, |
| | 253 | '_ajax_fetch_list_nonce': $('#_ajax_fetch_list_nonce').val() |
| | 254 | }); |
| 235 | 255 | } |
| 236 | 256 | |
| 237 | | args.no_placeholder = true; |
| 238 | | |
| 239 | | args.paged ++; |
| 240 | | |
| 241 | | // $.query.get() needs some correction to be sent into an ajax request |
| 242 | | if ( true === args.comment_type ) |
| 243 | | args.comment_type = ''; |
| 244 | | |
| 245 | | args = $.extend(args, { |
| 246 | | 'action': 'fetch-list', |
| 247 | | 'list_args': list_args, |
| 248 | | '_ajax_fetch_list_nonce': $('#_ajax_fetch_list_nonce').val() |
| 249 | | }); |
| 250 | | |
| 251 | 257 | $.ajax({ |
| 252 | 258 | url: ajaxurl, |
| 253 | 259 | global: false, |