| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Yatra\Shortcodes; |
| 6 |
|
| 7 |
/** |
| 8 |
* Trip Shortcode |
| 9 |
* |
| 10 |
* Displays trips with various filtering options using trip-listing-card.php template |
| 11 |
*/ |
| 12 |
class TripShortcode extends BaseShortcode |
| 13 |
{ |
| 14 |
public function __construct() |
| 15 |
{ |
| 16 |
parent::__construct('yatra_tour', [ |
| 17 |
'order' => 'asc', |
| 18 |
'featured' => '0', |
| 19 |
'featured_priority' => '', |
| 20 |
'per_page' => '10', |
| 21 |
'category' => '', |
| 22 |
'destination' => '', |
| 23 |
'activity' => '', |
| 24 |
'difficulty' => '', |
| 25 |
'price_min' => '', |
| 26 |
'price_max' => '', |
| 27 |
'duration_min' => '', |
| 28 |
'duration_max' => '', |
| 29 |
'search' => '', |
| 30 |
'columns' => '3', |
| 31 |
'show_pagination' => 'yes', |
| 32 |
'title' => 'Our Trips' |
| 33 |
]); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Register the shortcode |
| 38 |
*/ |
| 39 |
public function register(): void |
| 40 |
{ |
| 41 |
// Register both shortcode tags |
| 42 |
add_shortcode('yatra_tour', [$this, 'render']); |
| 43 |
add_shortcode('yatra_trip', [$this, 'render']); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Render the trip shortcode content |
| 48 |
*/ |
| 49 |
protected function renderContent(array $atts): string |
| 50 |
{ |
| 51 |
// Use the shared BlockDataService method |
| 52 |
return \Yatra\Services\BlockDataService::renderTrip($atts); |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Get trips using Yatra's service |
| 57 |
*/ |
| 58 |
public function getTrips(array $atts): array |
| 59 |
{ |
| 60 |
return \Yatra\Services\BlockDataService::getTripListingForShortcode($atts); |
| 61 |
} |
| 62 |
|
| 63 |
} |
| 64 |
|