403]); } $atts = $_POST['atts'] ?? []; if (!is_array($atts)) { $atts = []; } $page = (int) ($_POST['page'] ?? 1); $atts['current_page'] = $page; try { $shortcode = new \Yatra\Shortcodes\TripCategoryShortcode(); $data = $shortcode->getCategories($atts); $categories = $data['categories'] ?? []; $max_pages = $data['max_pages'] ?? 1; $current_page = $data['current_page'] ?? 1; $total_found = $data['total_found'] ?? 0; $columns = (int) ($atts['columns'] ?? 3); $column_class = 'yatra-destination-grid-' . min(max($columns, 1), 6); ob_start(); include YATRA_PLUGIN_PATH . 'templates/shortcodes/trip-category.php'; $html = ob_get_clean(); wp_send_json_success([ 'html' => $html, 'current_page' => $current_page, 'max_pages' => $max_pages, 'total_found' => $total_found, ]); } catch (\Exception $e) { wp_send_json_error([ 'message' => (defined('WP_DEBUG') && WP_DEBUG) ? 'Error loading categories: ' . $e->getMessage() : __('Unable to load categories. Please try again.', 'yatra'), ]); } } }