die('1'); } $position = isset($_POST['position']) && (int) $_POST['position'] ? (int) $_POST['position'] : '-1'; // automatically approve parent comment if (!empty($_POST['approve_parent'])) { $parent = get_comment($comment_parent); if ($parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID) { if (nxt_set_comment_status($parent->comment_ID, 'approve')) { $comment_auto_approved = true; } } } ob_start(); if ('dashboard' == $_REQUEST['mode']) { require_once ABSPATH . 'nxt-admin/includes/dashboard.php'; _nxt_dashboard_recent_comments_row($comment); } else { if ('single' == $_REQUEST['mode']) { $nxt_list_table = _get_list_table('nxt_Post_Comments_List_Table'); } else { $nxt_list_table = _get_list_table('nxt_Comments_List_Table'); } $nxt_list_table->single_row($comment); } $comment_list_item = ob_get_contents(); ob_end_clean(); $response = array('what' => 'comment', 'id' => $comment->comment_ID, 'data' => $comment_list_item, 'position' => $position); if ($comment_auto_approved) { $response['supplemental'] = array('parent_approved' => $parent->comment_ID); } $x = new nxt_Ajax_Response();
/** * Display recent comments dashboard widget content. * * @since 2.5.0 */ function nxt_dashboard_recent_comments() { global $nxtdb; if (current_user_can('edit_posts')) { $allowed_states = array('0', '1'); } else { $allowed_states = array('1'); } // Select all comment types and filter out spam later for better query performance. $comments = array(); $start = 0; $widgets = get_option('dashboard_widget_options'); $total_items = isset($widgets['dashboard_recent_comments']) && isset($widgets['dashboard_recent_comments']['items']) ? absint($widgets['dashboard_recent_comments']['items']) : 5; while (count($comments) < $total_items && ($possible = $nxtdb->get_results("SELECT * FROM {$nxtdb->comments} c LEFT JOIN {$nxtdb->posts} p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT {$start}, 50"))) { foreach ($possible as $comment) { if (count($comments) >= $total_items) { break; } if (in_array($comment->comment_approved, $allowed_states) && current_user_can('read_post', $comment->comment_post_ID)) { $comments[] = $comment; } } $start = $start + 50; } if ($comments) { ?> <div id="the-comment-list" class="list:comment"> <?php foreach ($comments as $comment) { _nxt_dashboard_recent_comments_row($comment); } ?> </div> <?php if (current_user_can('edit_posts')) { ?> <?php _get_list_table('nxt_Comments_List_Table')->views(); } nxt_comment_reply(-1, false, 'dashboard', false); nxt_comment_trashnotice(); } else { ?> <p><?php _e('No comments yet.'); ?> </p> <?php } // $comments; }