/** * Process a batch of comments via AJAX - EXACTLY LIKE WORKING SINGLE FILE */ public function process_queue_batch() { // Add debugging output to browser console echo ''; // Check basic requirements if (!is_user_logged_in() || !current_user_can('manage_options')) { echo ''; wp_send_json_error('Insufficient permissions'); return; } // Check nonce if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ab_process_queue')) { echo ''; wp_send_json_error('Security check failed'); return; } echo ''; // If just getting count if (isset($_POST['get_count'])) { echo ''; $count = wp_count_comments(); $pending_count = isset($count->moderated) ? $count->moderated : 0; wp_send_json_success(array( 'total' => intval($pending_count) )); return; } echo ''; $batch_size = isset($_POST['batch_size']) ? intval($_POST['batch_size']) : 25; $batch_size = max(1, min(100, $batch_size)); // Get pending comments $comments = get_comments(array( 'status' => 'hold', 'number' => $batch_size, 'orderby' => 'comment_date', 'order' => 'ASC' )); echo ''; $processed = 0; $spam_found = 0; $details = array(); foreach ($comments as $comment) { $processed++; $comment_id = $comment->comment_ID; echo ''; // Convert WP_Comment to array format for verification $comment_data = array