| @@ -19,22 +19,12 @@ | ||
| 19 | 19 | * Load activities via AJAX for pagination |
| 20 | 20 | */ |
| 21 | 21 | public function loadActivities(): void |
| 22 | 22 | { |
| 23 | - // Debug: Log AJAX request | |
| 24 | - if (defined('WP_DEBUG') && WP_DEBUG) { | |
| 25 | - error_log('Yatra Activity AJAX - Request received: ' . print_r($_POST, true)); | |
| 26 | - $atts = $_POST['atts'] ?? []; | |
| 27 | - error_log('Yatra Activity AJAX - per_page parameter: ' . ($atts['per_page'] ?? 'NOT SET')); | |
| 28 | - error_log('Yatra Activity AJAX - page parameter: ' . ($_POST['page'] ?? 'NOT SET')); | |
| 29 | - } | |
| 30 | - | |
| 23 | + | |
| 31 | 24 | // Verify nonce |
| 32 | 25 | if (!wp_verify_nonce($_POST['nonce'] ?? '', 'yatra_activity_shortcode_nonce')) { |
| 33 | - if (defined('WP_DEBUG') && WP_DEBUG) { | |
| 34 | - error_log('Yatra Activity AJAX - Security check failed'); | |
| 35 | - } | |
| 36 | - wp_die(esc_html__('Security check failed', 'yatra'), '', ['response' => 403]); | |
| 26 | + wp_die(esc_html__('Security check failed', 'yatra'), '', ['response' => 403]); | |
| 37 | 27 | } |
| 38 | 28 | |
| 39 | 29 | // Parse shortcode attributes |
| 40 | 30 | $atts = $_POST['atts'] ?? []; |
| @@ -61,30 +51,10 @@ | ||
| 61 | 51 | $current_page = $activities_data['current_page'] ?? 1; |
| 62 | 52 | $total_found = $activities_data['total_found'] ?? 0; |
| 63 | 53 | $columns = (int) $atts['columns']; |
| 64 | 54 | $column_class = 'yatra-activity-grid-' . min(max($columns, 1), 4); |
| 65 | - | |
| 66 | - // Debug: Log AJAX data with comprehensive pagination info | |
| 67 | - if (defined('WP_DEBUG') && WP_DEBUG) { | |
| 68 | - error_log('=== YATRA ACTIVITY AJAX DEBUG ==='); | |
| 69 | - error_log('Yatra Activity AJAX - Requested page: ' . $page); | |
| 70 | - error_log('Yatra Activity AJAX - Activities count: ' . count($activities_data['activities'] ?? [])); | |
| 71 | - error_log('Yatra Activity AJAX - Total found: ' . $total_found); | |
| 72 | - error_log('Yatra Activity AJAX - Max pages: ' . $max_pages); | |
| 73 | - error_log('Yatra Activity AJAX - Current page: ' . $current_page); | |
| 74 | - error_log('Yatra Activity AJAX - Attributes received: ' . print_r($atts, true)); | |
| 75 | - | |
| 76 | - // Log each activity being returned | |
| 77 | - $activities_list = $activities_data['activities'] ?? []; | |
| 78 | - if (!empty($activities_list)) { | |
| 79 | - error_log('Activities being returned for page ' . $current_page . ':'); | |
| 80 | - foreach ($activities_list as $index => $activity) { | |
| 81 | - error_log(' ' . ($index + 1) . '. ' . ($activity['term']->name ?? 'NO NAME') . ' (ID: ' . ($activity['term']->id ?? 'NO ID') . ')'); | |
| 82 | - } | |
| 83 | - } | |
| 84 | - error_log('=== END ACTIVITY AJAX DEBUG ==='); | |
| 85 | - } | |
| 86 | 55 | |
| 56 | + | |
| 87 | 57 | // Load the template content with variables in scope |
| 88 | 58 | ob_start(); |
| 89 | 59 | // Extract variables to make them available in template (matching trip shortcode pattern) |
| 90 | 60 | $activities = $activities_data['activities'] ?? []; |
| @@ -104,13 +74,9 @@ | ||
| 104 | 74 | 'total_found' => $activities_data['total_found'] ?? 0 |
| 105 | 75 | ]); |
| 106 | 76 | |
| 107 | 77 | } catch (\Exception $e) { |
| 108 | - // Log error for debugging | |
| 109 | - if (defined('WP_DEBUG') && WP_DEBUG) { | |
| 110 | - error_log('Yatra ActivityShortcode AJAX Error: ' . $e->getMessage()); | |
| 111 | - error_log('Yatra ActivityShortcode AJAX Trace: ' . $e->getTraceAsString()); | |
| 112 | - } | |
| 78 | + | |
| 113 | 79 | |
| 114 | 80 | wp_send_json_error([ |
| 115 | 81 | 'message' => (defined('WP_DEBUG') && WP_DEBUG) |
| 116 | 82 | ? 'Error loading activities: ' . $e->getMessage() |