PluginProbe
Yatra – Travel Booking & Tour Operator Software / 2.1.16
Yatra – Travel Booking & Tour Operator Software v2.1.16
3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 2.0.11 All 82 releases
yatra / includes / template-tags.php

template-tags.php in Yatra – Travel Booking & Tour Operator Software 2.1.16, at includes/template-tags.php

1,246 lines 45.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined('ABSPATH') || exit;
4 if (!function_exists('yatra_get_taxonomy_term_lists')) {
5 function yatra_get_taxonomy_term_lists($post_id, $taxonomy = '', $return = false, $icon = '')
6 {
7 ob_start();
8 /* translators: used between list items, there is a space after the comma. */
9 $terms = get_the_term_list($post_id, $taxonomy, '', __(',&nbsp;', 'yatra'));
10
11 $icon_html = $icon !== '' ? '<i class="yatra-icon ' . esc_attr($icon) . '"></i> ' : '';
12
13 if ($terms) {
14 printf(
15 /* translators: 1: Taxonomy name 2: SVG icon. 3: posted in label, only visible to screen readers.*/
16 '<span class="yatra-cat-links %1$s-links"><span class="screen-reader-text">%2$s</span>%3$s%4$s</span>',
17 ($taxonomy),
18 ucwords($taxonomy),
19 $icon_html,
20 $terms
21 ); // WPCS: XSS OK.
22 }
23 $content = ob_get_clean();
24 if ($return) {
25 return $content;
26 }
27 echo $content;
28 }
29 }
30
31 if (!function_exists('yatra_entry_header')) {
32
33 function yatra_entry_header()
34 {
35 ?>
36 <header class="yatra-tour-header">
37 <?php
38 if (is_sticky() && is_home() && !is_paged()) {
39 printf('<span class="sticky-post">%s</span>', _x('Featured', 'post', 'yatra'));
40 }
41 if (is_singular()) :
42 the_title('<h1 class="yatra-tour-title">', '</h1>');
43 else :
44 the_title(sprintf('<h2 class="yatra-tour-title"><a href="%s" rel="bookmark">', esc_url(get_permalink())), '</a></h2>');
45 endif;
46 ?>
47 </header><!-- .yatra-tour-header -->
48 <?php
49 }
50 }
51
52 if (!function_exists('yatra_tour_thumbnail')) {
53
54 function yatra_tour_thumbnail($size = "post-thumbnail")
55 {
56 ?>
57 <figure class="tour-thumbnail">
58 <?php if (!is_singular('tour')){ ?>
59 <a class="tour-thumbnail-inner" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
60 <?php }
61 the_post_thumbnail($size);
62 if (!is_singular('tour')){
63 ?>
64 </a>
65 <?php } ?>
66 </figure>
67 <?php
68 }
69 }
70
71 if (!function_exists('yatra_entry_post_content')) {
72
73 function yatra_entry_post_content()
74 {
75 ?>
76 <div class="yatra-tour-content">
77 <?php
78 the_excerpt();
79 ?>
80 </div><!-- .yatra-tour-content -->
81 <?php
82 }
83 }
84
85
86 if (!function_exists('yatra_get_current_currency_symbol')) {
87
88 function yatra_get_current_currency_symbol($currency = '')
89 {
90 $currency = $currency === '' ? yatra_get_current_currency() : $currency;
91
92 $symbol_type = get_option('yatra_currency_symbol_type', 'symbol');
93
94 if ($symbol_type === 'code') {
95
96 return $currency;
97
98 }
99 return yatra_get_currency_symbol($currency);
100 }
101 }
102
103 if (!function_exists('yatra_get_current_currency')) {
104
105 function yatra_get_current_currency()
106 {
107 return get_option('yatra_currency', 'USD');
108 }
109 }
110
111 if (!function_exists('yatra_entry_meta_for_frontend_archive')) {
112
113 function yatra_entry_meta_for_frontend_archive($post_id)
114 {
115
116 $currency_symbol = yatra_get_current_currency_symbol();
117
118 $regular_yatra_tour_meta_regular_price = get_post_meta($post_id, 'yatra_tour_meta_regular_price', true);
119
120 $yatra_tour_meta_sales_price = get_post_meta($post_id, 'yatra_tour_meta_sales_price', true);
121
122 $yatra_tour_meta_tour_country = get_post_meta($post_id, 'yatra_tour_meta_tour_country', true);
123
124 $yatra_tour_meta_regular_price_string = $currency_symbol . $regular_yatra_tour_meta_regular_price;
125
126 $meta_frontend = array(
127 array(
128 'icon' => 'fa fa-users',
129 'text' => '{{yatra_tour_maximum_number_of_traveller}}',
130
131 ),
132 array(
133 'icon' => 'fa fa-chair',
134 'text' => '{{yatra_tour_minimum_pax}}',
135
136 )
137
138 );
139 if (!empty($yatra_tour_meta_tour_country)) {
140
141 $country_string = '';
142
143
144 foreach ($yatra_tour_meta_tour_country as $country_item) {
145
146 $country = yatra_get_countries($country_item);
147
148
149 $country_string .= $country . ', ';
150 }
151 $country_string = trim($country_string, ', ');
152
153 $meta_frontend[] =
154 array(
155 'icon' => 'fa fa-globe',
156 'text' => $country_string,
157
158 );
159
160 }
161
162 return apply_filters(
163 'yatra_entry_meta_frontend',
164 $meta_frontend
165 );
166
167 }
168 }
169
170 if (!function_exists('yatra_entry_meta_options')) {
171
172 function yatra_entry_meta_options($post_id = 0)
173 {
174 $post_id = $post_id > 0 ? $post_id : get_the_id();
175
176 $yatra_tour_meta_tour_days = get_post_meta($post_id, 'yatra_tour_meta_tour_duration_days', true);
177
178 $yatra_tour_meta_tour_nights = get_post_meta($post_id, 'yatra_tour_meta_tour_duration_nights', true);
179
180 $duration_string = '';
181
182 if ($yatra_tour_meta_tour_days != '') {
183
184 $duration_string .= $yatra_tour_meta_tour_days . ' ' . __("Days", 'yatra');
185
186 }
187 if ($yatra_tour_meta_tour_nights != '') {
188
189 $duration_string .= ' ' . $yatra_tour_meta_tour_nights . ' ' . __("Nights", 'yatra');
190
191 }
192 if ($yatra_tour_meta_tour_nights == '' && $yatra_tour_meta_tour_days == '') {
193
194 $duration_string = __('N/A', 'yatra');
195
196 }
197
198 echo '<div class="yatra-tour-meta">';
199
200 yatra_get_taxonomy_term_lists($post_id, 'activity', false, 'fa fa-universal-access');
201
202 yatra_get_taxonomy_term_lists($post_id, 'destination', false, 'fas fa-map-marker-alt');
203
204 echo '<span class="yatra-tour-duration"><i class="yatra-icon fa fa-clock"></i>' . esc_html($duration_string) . '</span>';
205
206 do_action('yatra_after_tour_meta', $post_id);
207
208 echo '</div>';
209
210 }
211 }
212 if (!function_exists('yatra_tour_tab_configurations')) {
213
214 function yatra_tour_tab_configurations($config_key = null)
215 {
216 $all_tab_configs = yatra_tour_tab_default_configurations();
217
218 $available_tabs = yatra_frontend_tabs_available_options();
219
220 $final_available_tabs = array();
221
222 $yatra_tour_tabs_additional_types = yatra_tour_tabs_additional_types();
223
224 foreach ($available_tabs as $tab_index => $tab) {
225
226 $type = $tab['type'] ?? $tab_index;
227
228 if (isset($all_tab_configs[$type])) {
229
230 $final_available_tabs[$type] = $all_tab_configs[$type];
231
232 $final_available_tabs[$type]['label'] = $tab['label'] ?? '';
233
234 $final_available_tabs[$type]['options'][$type . '_label']['default'] = $tab['label'] ?? '';
235
236 $final_available_tabs[$type]['options'][$type . '_visibility']['default'] = $tab['visibility'] && boolval($tab['visibility']);
237
238 $final_available_tabs[$type]['icon'] = $tab['icon'] ?? '';
239
240
241 } else {
242
243
244 if (in_array("text", $yatra_tour_tabs_additional_types)) {
245
246 $final_available_tabs[$tab_index] = array(
247 'label' => $tab['label'] ?? '',
248 'icon' => $tab['icon'] ?? '',
249 'type' => $type,
250 'options' =>
251 array(
252 $tab_index . '_visibility' => array(
253 'name' => $tab_index . '_visibility',
254 'title' => '',
255 'type' => 'hidden',
256 'default' => $tab['visibility'] && boolval($tab['visibility']),
257 ),
258 $tab_index . '_label' => array(
259 'name' => $tab_index . '_label',
260 'title' => __('Label Text', 'yatra'),
261 'type' => 'text',
262 'default' => $tab['label'] ?? '',
263 ),
264 $tab_index . '_content' => array(
265 'name' => $tab_index . '_content',
266 'title' => __('Content', 'yatra'),
267 'type' => 'textarea',
268 'editor' => true
269 )
270 ),
271
272 );
273 }
274
275 }
276
277 }
278
279 if (!is_null($config_key)) {
280
281 if (isset($final_available_tabs[$config_key])) {
282
283 return $final_available_tabs[$config_key];
284 }
285 }
286
287 return $final_available_tabs;
288
289
290 }
291 }
292
293 if (!function_exists('yatra_tour_tab_default_configurations')) {
294
295 function yatra_tour_tab_default_configurations()
296 {
297
298 $tab_config = array(
299 'overview' => array(
300 'label' => __('Overview', 'yatra'),
301 'icon' => 'fas fa-atom',
302 'options' =>
303 array(
304 'overview_visibility' => array(
305 'name' => 'overview_visibility',
306 'title' => '',
307 'type' => 'hidden',
308 'default' => true,
309 ),
310 'overview_label' => array(
311 'name' => 'overview_label',
312 'title' => __('Label Text', 'yatra'),
313 'type' => 'text',
314 'default' => __('Overview', 'yatra'),
315 ),
316 'overview_description' => array(
317 'name' => 'overview_description',
318 'title' => __('Overview Description', 'yatra'),
319 'type' => 'textarea',
320 'editor' => true
321 )
322 ),
323
324 ),
325 'itinerary' => array(
326 'label' => __('Itinerary', 'yatra'),
327 'icon' => 'fas fa-gopuram',
328 'options' =>
329 array(
330 'itinerary_visibility' => array(
331 'name' => 'itinerary_visibility',
332 'title' => '',
333 'type' => 'hidden',
334 'default' => true,
335 ),
336 'itinerary_label' => array(
337 'name' => 'itinerary_label',
338 'title' => __('Label', 'yatra'),
339 'type' => 'text',
340 'default' => __('Itinerary', 'yatra'),
341
342 ),
343 'itinerary_repeator' => array(
344 'name' => 'itinerary_repeator',
345 'type' => 'repeator',
346 'options' => array(
347 array(
348 'itinerary_heading' => array(
349 'name' => 'itinerary_heading',
350 'title' => __('Heading', 'yatra'),
351 'type' => 'text',
352 'default' => __('Day {index} ', 'yatra'),
353 'class' => 'mb-repeator-heading-input',
354 ),
355 'itinerary_title' => array(
356 'name' => 'itinerary_title',
357 'title' => __('Title', 'yatra'),
358 'type' => 'text',
359 ),
360 'itinerary_details' => array(
361 'name' => 'itinerary_details',
362 'title' => __('Details', 'yatra'),
363 'type' => 'textarea',
364 'editor' => true
365 )
366 )
367 )
368 )
369
370 )
371 ),
372 'cost_info' => array(
373 'label' => __('Cost Info', 'yatra'),
374 'icon' => 'fa fa-dollar-sign',
375 'options' =>
376 array(
377 'cost_info_visibility' => array(
378 'name' => 'cost_info_visibility',
379 'title' => '',
380 'type' => 'hidden',
381 'default' => true,
382 ),
383 'cost_info_label' => array(
384 'name' => 'cost_info_label',
385 'title' => __('Label', 'yatra'),
386 'type' => 'text',
387 'default' => __('Cost Info', 'yatra'),
388 ),
389 'cost_info_price_includes_title' => array(
390 'name' => 'cost_info_price_includes_title',
391 'title' => __('Price includes title', 'yatra'),
392 'type' => 'text',
393 'default' => __('Price includes', 'yatra'),
394 ),
395 'cost_info_price_includes_description' => array(
396 'name' => 'cost_info_price_includes_description',
397 'title' => __('Price include description', 'yatra'),
398 'type' => 'textarea',
399 'description' => __('Type enter to show in new list.', 'yatra'),
400 'editor' => true
401 ),
402 'cost_info_price_excludes_title' => array(
403 'name' => 'cost_info_price_excludes_title',
404 'title' => __('Price excludes title', 'yatra'),
405 'type' => 'text',
406 'default' => __('Price excludes', 'yatra'),
407 ),
408 'cost_info_price_excludes_description' => array(
409 'name' => 'cost_info_price_excludes_description',
410 'title' => __('Price excludes description', 'yatra'),
411 'type' => 'textarea',
412 'description' => __('Type enter to show in new list.', 'yatra'),
413 'editor' => true
414 )
415 ),
416 ),
417 'faq' => array(
418 'label' => __('FAQ', 'yatra'),
419 'icon' => 'fas fa-comment-dots',
420 'options' =>
421 array(
422 'faq_visibility' => array(
423 'name' => 'faq_visibility',
424 'title' => '',
425 'type' => 'hidden',
426 'default' => true,
427 ),
428 'faq_label' => array(
429 'name' => 'faq_label',
430 'title' => __('Label', 'yatra'),
431 'type' => 'text',
432 'default' => __('FAQ', 'yatra'),
433
434 ),
435 'faq_repeator' => array(
436 'name' => 'faq_repeator',
437 'type' => 'repeator',
438 'options' => array(
439 array(
440 'faq_heading' => array(
441 'name' => 'faq_heading',
442 'title' => __('FAQ Heading', 'yatra'),
443 'type' => 'text',
444 'default' => __('FAQ {index} ', 'yatra'),
445 'class' => 'mb-repeator-heading-input'
446 ),
447 'faq_description' => array(
448 'name' => 'faq_description',
449 'title' => __('Description', 'yatra'),
450 'type' => 'textarea',
451 'editor' => true
452 )
453 )
454 )
455 )
456
457 )
458
459 ),
460 'map' => array(
461 'label' => __('Map', 'yatra'),
462 'icon' => 'fas fa-directions',
463 'options' =>
464 array(
465 'map_visibility' => array(
466 'name' => 'map_visibility',
467 'title' => '',
468 'type' => 'hidden',
469 'default' => true,
470 ),
471 'map_label' => array(
472 'name' => 'map_label',
473 'title' => __('Label', 'yatra'),
474 'type' => 'text',
475 'default' => __('Map', 'yatra'),
476
477 ),
478 'yatra_tour_meta_map_content' => array(
479 'name' => 'yatra_tour_meta_map_content',
480 'title' => __('Map Content', 'yatra'),
481 'type' => 'textarea',
482 'editor' => true,
483 'allow-html' => true
484 )
485 ),
486 ),
487 'gallery' => array(
488 'label' => __('Gallery', 'yatra'),
489 'icon' => 'fas fa-images',
490 'options' =>
491 array(
492 'gallery_visibility' => array(
493 'name' => 'gallery_visibility',
494 'title' => '',
495 'type' => 'hidden',
496 'default' => true,
497 ),
498 'gallery_label' => array(
499 'name' => 'gallery_label',
500 'title' => __('Label', 'yatra'),
501 'type' => 'text',
502 'default' => __('Gallery', 'yatra'),
503
504 ),
505 'yatra_tour_meta_gallery' => array(
506 'name' => 'yatra_tour_meta_gallery',
507 'title' => __('Gallery', 'yatra'),
508 'type' => 'gallery',
509 )
510 ),
511 ),
512 );
513
514 return apply_filters('yatra_tour_tab_configurations', $tab_config);
515
516 }
517 }
518
519
520 if (!function_exists('yatra_tour_attribute_type_options')) {
521
522 function yatra_tour_attribute_type_options()
523 {
524
525 $tour_attributes = array(
526
527 'text_field' => array(
528 'label' => __('Text Field', 'yatra'),
529 'options' =>
530 array(
531 'content' => array(
532 'name' => 'content',
533 'title' => __('Content', 'yatra'),
534 'placeholder' => __('Default value for text field.', 'yatra'),
535 'description' => __('Default value for text field.', 'yatra'),
536 'type' => 'text',
537
538
539 )
540 ),
541 ),
542 'number_field' => array(
543 'label' => __('Number Field', 'yatra'),
544 'options' =>
545 array(
546
547 'content' => array(
548 'name' => 'content',
549 'title' => __('Default value for number field.', 'yatra'),
550 'placeholder' => __('Default value for number field.', 'yatra'),
551 'description' => __('Default value for number field.', 'yatra'),
552 'type' => 'number',
553 )
554 ),
555 ),
556 'textarea_field' => array(
557 'label' => __('Textarea Field', 'yatra'),
558 'options' =>
559 array(
560
561 'content' => array(
562 'name' => 'content',
563 'title' => __('Default value for textarea field.', 'yatra'),
564 'placeholder' => __('Default value for textarea field.', 'yatra'),
565 'description' => __('Default value for textarea field.', 'yatra'),
566 'type' => 'textarea',
567
568 )
569 ),
570 ),
571 'shortcode_field' => array(
572 'label' => __('Shortcode Field', 'yatra'),
573 'options' =>
574 array(
575 'shortcode' => array(
576 'name' => 'shortcode',
577 'title' => __('Shortcode', 'yatra'),
578 'placeholder' => __('Default value for shortcode field.', 'yatra'),
579 'description' => __('Default value for shortcode field.', 'yatra'),
580 'type' => 'shortcode',
581
582
583 )
584 ),
585 ),
586 /* 'dropdown_field' => array(
587 'label' => __('Dropdown Field', 'yatra'),
588 'options' =>
589 array(
590 'content' => array(
591 'name' => 'content',
592 'title' => __('Default value for select(drop-down) field. Enter drop-down values separated by commas.', 'yatra'),
593 'placeholder' => __('Default value for select(drop-down) field. Enter drop-down values separated by commas.', 'yatra'),
594 'description' => __('Default value for select(drop-down) field. Enter drop-down values separated by commas.', 'yatra'),
595 'type' => 'textarea',
596
597
598
599 )
600 ),
601 )*/
602 );
603 return apply_filters('yatra_tour_attribute_type_options', $tour_attributes);
604 }
605 }
606
607
608 if (!function_exists('yatra_tour_attributes_list')) {
609 function yatra_tour_attributes_list()
610 {
611 $terms = get_terms(array(
612 'taxonomy' => 'attributes',
613 'hide_empty' => false
614
615 ));
616
617 $fields = array();
618
619 $number_of_tour_attributes = apply_filters('number_of_tour_attributes', 5);
620
621 foreach ($terms as $term_key => $term_value) {
622 if (isset($term_value->term_id)) {
623 $fields[$term_value->term_id] = $term_value->name;
624 if (count($fields) === $number_of_tour_attributes && $number_of_tour_attributes !== -1) {
625 break;
626 }
627 }
628 }
629
630 return $fields;
631
632 }
633 }
634 if (!function_exists('yatra_tour_attributes')) {
635 function yatra_tour_attributes()
636 {
637 $tour_attributes = array(
638 array(
639 'name' => 'tour_attributes',
640 'title' => sprintf(__('Tour Attributes', 'yatra')),
641 'type' => 'select',
642 'options' => yatra_tour_attributes_list(),
643 ),
644 array(
645 'name' => 'add_tour_attribute',
646 'type' => 'button',
647 'default' => sprintf(__('Add New', 'yatra')),
648
649 )
650 );
651 return apply_filters('yatra_tour_attribute_configurations', $tour_attributes);
652 }
653 }
654
655
656 if (!function_exists('yatra_tour_general_configurations')) {
657
658 function yatra_tour_general_configurations()
659 {
660
661 $countries = yatra_get_countries();
662
663 $tour_options = array(
664
665 'yatra_tour_meta_tour_external_url' => array(
666 'name' => 'yatra_tour_meta_tour_external_url',
667 'title' => esc_html__('External tour URL', 'yatra'),
668 'type' => 'text',
669 'description' => esc_html__('Enter the external URL to the tour package. ', 'yatra'),
670
671 'visibility_condition' => array(
672 'yatra_tour_meta_tour_type' => 'external',
673 )
674 //'wrap_class' => 'yatra-right',
675 //'row_end' => true,
676
677 ),
678 'yatra_tour_meta_tour_external_button_text' => array(
679 'name' => 'yatra_tour_meta_tour_external_button_text',
680 'title' => esc_html__('Button text', 'yatra'),
681 'type' => 'text',
682 'description' => esc_html__('This text will be shown on the button linking to the external tour package ', 'yatra'),
683 'visibility_condition' => array(
684 'yatra_tour_meta_tour_type' => 'external',
685 )
686 //'wrap_class' => 'yatra-right',
687 //'row_end' => true,
688
689 ),
690 'yatra_tour_meta_tour_featured' => array(
691 'name' => 'yatra_tour_meta_tour_featured',
692 'title' => esc_html__('Feature this tour', 'yatra'),
693 'type' => 'switch',
694 'description' => esc_html__('This option let you enable/disable feature option for this tour package. ', 'yatra'),
695
696 //'wrap_class' => 'yatra-right',
697 //'row_end' => true,
698
699 ),
700 'yatra_tour_meta_tour_country' => array(
701 'name' => 'yatra_tour_meta_tour_country',
702 'title' => esc_html__('Country', 'yatra'),
703 'type' => 'select',
704 //'wrap_class' => 'yatra-left',
705 'extra_attributes' => array(
706 'placeholder' => __('Country', 'yatra'),
707 ),
708 'options' => $countries,
709 'default' => 'NP',
710 'is_multiple' => true,
711 'select2' => true,
712 //'row_start' => true,
713
714 ),
715
716
717 'yatra_tour_minimum_pax' => array(
718 'name' => 'yatra_tour_minimum_pax',
719 'title' => esc_html__('Minimum People (Pax)', 'yatra'),
720 'description' => esc_html__('Minimum number of people per booking. Leave it blank to ignore minimum limit per booking.', 'yatra'),
721 'type' => 'number',
722 // 'wrap_class' => 'yatra-left',
723 'extra_attributes' => array(
724 'placeholder' => __('Minimum number of people per booking', 'yatra'),
725 ),
726
727 ),
728 'yatra_tour_maximum_pax' => array(
729 'name' => 'yatra_tour_maximum_pax',
730 'title' => esc_html__('Maximum People (Pax)', 'yatra'),
731 'description' => esc_html__('Maximum number of people per booking. Leave it blank to ignore maximum limit per booking.', 'yatra'),
732 'type' => 'number',
733 // 'wrap_class' => 'yatra-left',
734 'extra_attributes' => array(
735 'placeholder' => __('Maximum number of people per booking', 'yatra'),
736 ),
737
738 ),
739
740
741 'yatra_tour_maximum_number_of_traveller' => array(
742 'name' => 'yatra_tour_maximum_number_of_traveller',
743 'title' => esc_html__('Maximum number of traveller', 'yatra'),
744 'description' => esc_html__('Maximum number of traveller', 'yatra'),
745 'type' => 'number',
746 // 'wrap_class' => 'yatra-left',
747 'extra_attributes' => array(
748 'placeholder' => __('Maximum number of traveller for this tour package.', 'yatra'),
749 )
750
751 ),
752
753 'yatra_tour_meta_tour_tabs_ordering' => array(
754 'name' => 'yatra_tour_meta_tour_tabs_ordering',
755 'type' => 'hidden',
756 'default' => yatra_frontend_tour_tabs_ordering('string')
757 ),
758
759 'yatra_tour_meta_tour_admin_active_tab' => array(
760 'name' => 'yatra_tour_meta_tour_admin_active_tab',
761 'type' => 'hidden',
762 'default' => 'general'
763
764 ),
765 'yatra_tour_meta_tour_admin_subtab_active_tab' => array(
766 'name' => 'yatra_tour_meta_tour_admin_subtab_active_tab',
767 'type' => 'hidden',
768 'default' => 'overview'
769 ),
770 );
771 return apply_filters('yatra_tour_general_configurations', $tour_options);
772 }
773 }
774
775 if (!function_exists('yatra_tour_duration_configurations')) {
776
777 function yatra_tour_duration_configurations()
778 {
779
780 $tour_options = array(
781
782 'yatra_tour_meta_tour_fixed_departure' => array(
783 'name' => 'yatra_tour_meta_tour_fixed_departure',
784 'title' => esc_html__('Fixed Departure', 'yatra'),
785 'type' => 'switch',
786 'description' => esc_html__('This option let you enable/disable fix depdeparture option for this tour package. ', 'yatra'),
787
788 //'wrap_class' => 'yatra-right',
789 //'row_end' => true,
790
791 ),
792
793 'yatra_tour_meta_availability_date_ranges' => array(
794 'name' => 'yatra_tour_meta_availability_date_ranges',
795 'title' => esc_html__('Tour Availability Date Ranges', 'yatra'),
796 'description' => esc_html__('You can choose date range slot for this tour availability. Do not add any date range slot to show this tour on all dates.', 'yatra'),
797 'type' => 'date_range',
798 'visibility_condition' => array(
799 'yatra_tour_meta_tour_fixed_departure' => true,
800 )
801 //'row_start' => true,
802
803 ),
804 'yatra_tour_meta_tour_duration_days' => array(
805 'name' => 'yatra_tour_meta_tour_duration_days',
806 'title' => esc_html__('Tour Duration Days', 'yatra'),
807 'description' => esc_html__('Total duration days for this tour', 'yatra'),
808 'type' => 'number',
809 // 'wrap_class' => 'yatra-left',
810 'extra_attributes' => array(
811 'placeholder' => __('Number of days', 'yatra'),
812 ),
813
814
815 //'row_start' => true,
816
817 ),
818 'yatra_tour_meta_tour_duration_nights' => array(
819 'name' => 'yatra_tour_meta_tour_duration_nights',
820 'title' => esc_html__('Tour Duration Nights', 'yatra'),
821 'type' => 'number',
822 //'wrap_class' => 'yatra-right',
823 'extra_attributes' => array(
824 'placeholder' => __('Number of nights', 'yatra'),
825 ),
826 ///'row_end' => true,
827
828 ),
829
830
831 );
832 return apply_filters('yatra_tour_duration_configurations', $tour_options);
833 }
834 }
835
836 if (!function_exists('yatra_tour_pricing_configurations')) {
837
838 function yatra_tour_pricing_configurations()
839 {
840 $currency = yatra_get_current_currency();
841
842 $currency_symbols = yatra_get_currency_symbol($currency);
843
844 $tour_options = array(
845 'yatra_tour_meta_price_per' => array(
846 'name' => 'yatra_tour_meta_price_per',
847 'title' => __('Price Per', 'yatra'),
848 'type' => 'select',
849 //'wrap_class' => 'yatra-left',
850 //'row_start' => true,
851 'options' => array(
852 'person' => __('Person', 'yatra'),
853 'group' => __('Group', 'yatra')
854 ),
855
856 ), 'yatra_tour_meta_group_size' => array(
857 'name' => 'yatra_tour_meta_group_size',
858 'title' => __('Group Size', 'yatra'),
859 'type' => 'number',
860 //'wrap_class' => 'yatra-right',
861 'extra_attributes' => array(
862 'placeholder' => __('Group Size', 'yatra'),
863 ),
864 'visibility_condition' => array(
865 'yatra_tour_meta_price_per' => 'group'
866 ),
867 // 'row_end' => true,
868 ),
869 'yatra_tour_meta_regular_price' => array(
870 'name' => 'yatra_tour_meta_regular_price',
871 'title' => sprintf(__('Tour Price- Regular (%s)', 'yatra'), $currency_symbols),
872 'type' => 'number',
873 //'wrap_class' => 'yatra-left',
874 'extra_attributes' => array(
875 'placeholder' => sprintf(__('Tour Price - Regular (%s)', 'yatra'), $currency_symbols),
876 ),
877 //'row_start' => true,
878 ),
879 'yatra_tour_meta_sales_price' => array(
880 'name' => 'yatra_tour_meta_sales_price',
881 'title' => sprintf(__('Tour Price- Sales Price (%s)', 'yatra'), $currency_symbols),
882 'type' => 'number',
883 //'wrap_class' => 'yatra-right',
884 'extra_attributes' => array(
885 'placeholder' => sprintf(__('Tour Price - Sales Price (%s). Leave it empty if you do not want to show sales price.', 'yatra'), $currency_symbols),
886 ),
887 //'row_end' => true,
888 ),
889 'yatra_tour_meta_pricing_label' => array(
890 'name' => 'yatra_tour_meta_pricing_label',
891 'title' => __('Pricing Label', 'yatra'),
892 'type' => 'text',
893 'default' => __('Guest', 'yatra'),
894 'extra_attributes' => array(
895 'placeholder' => __('Pricing Label', 'yatra'),
896 ),
897 //'row_end' => true,
898 ),
899 'yatra_tour_meta_pricing_description' => array(
900 'name' => 'yatra_tour_meta_pricing_description',
901 'title' => __('Pricing Description', 'yatra'),
902 'type' => 'text',
903 //'wrap_class' => 'yatra-right',
904 'extra_attributes' => array(
905 'placeholder' => __('Pricing Description', 'yatra'),
906 ),
907 //'row_end' => true,
908 )
909 );
910 return apply_filters('yatra_tour_pricing_configurations', $tour_options);
911 }
912 }
913
914
915 if (!function_exists('yatra_frontend_tabs_config')) {
916
917 function yatra_frontend_tabs_config()
918 {
919
920 $post_id = get_the_ID();
921
922 $yatra_tour_meta_tour_tabs_ordering_array = yatra_frontend_tour_tabs_ordering('array', $post_id);
923
924 $configs = yatra_tour_tab_configurations();
925
926 $config_array_keys = array_keys($configs);
927
928 $array_diff = array_diff($config_array_keys, $yatra_tour_meta_tour_tabs_ordering_array);
929
930 $final_ordered_config_keys = $yatra_tour_meta_tour_tabs_ordering_array;
931
932 if (count($array_diff) > 0) {
933
934 $final_ordered_config_keys = array_merge($yatra_tour_meta_tour_tabs_ordering_array, $array_diff);
935 }
936
937 $frontend_tabs_config = array();
938
939 foreach ($final_ordered_config_keys as $config) {
940
941 if (isset($configs[$config])) {
942
943 if (yatra_has_tab_visible($config, $post_id)) {
944
945 $setting = $configs[$config];
946
947 $label = get_post_meta($post_id, $config . '_label', true);
948
949 $label = empty($label) ? $setting['label'] : $label;
950
951 $frontend_tabs_config [$config] = $label;
952 }
953
954 }
955 }
956
957
958 return apply_filters('frontend_tabs_configurations', $frontend_tabs_config);
959 }
960 }
961
962
963 if (!function_exists('yatra_frontend_tabs')) {
964
965 function yatra_frontend_tabs()
966 {
967 global $post;
968
969 $frontend_tabs_config = yatra_frontend_tabs_config();
970
971 $yatra_tour_tab_configurations = yatra_tour_tab_configurations();
972
973 $yatra_setting_layouts_single_tour_tab_layout = get_option('yatra_setting_layouts_single_tour_tab_layout', '');
974
975 $layout_class = 'yatra-tabs';
976
977 $layout_class .= $yatra_setting_layouts_single_tour_tab_layout === 'heading_and_content' ? ' heading-and-content' : ' yatra-single-tour-tabs ';
978
979 echo '<div class="' . esc_attr($layout_class) . '" id="yatra-tour-tabs">';
980
981 if ($yatra_setting_layouts_single_tour_tab_layout === 'heading_and_content') {
982
983 foreach ($frontend_tabs_config as $tab_content_key => $tab_content_title) {
984
985 echo '<div class="yatra-tab-item ' . esc_attr($tab_content_key) . '">';
986
987 $config = $yatra_tour_tab_configurations[$tab_content_key] ?? '';
988
989 $icon = '';
990
991 if (isset($config['icon']) && '' != $config['icon']) {
992 $icon = '<span class="tab-icon ' . esc_attr($yatra_tour_tab_configurations[$tab_content_key]['icon']) . '"></span> ';
993 }
994
995 echo '<div class="yatra-tab-content">';
996
997 do_action('yatra_frontend_tab_content_' . $tab_content_key, $tab_content_title, array(
998 'post' => $post,
999 'tab_content_key' => $tab_content_key,
1000 'icon' => $icon
1001 ));
1002 echo '</div>';
1003
1004 echo '</div>';
1005 }
1006 } else {
1007
1008 ?>
1009 <ul class="yatra-tab-wrap">
1010 <?php foreach ($frontend_tabs_config as $tab_key => $tab) {
1011
1012 ?>
1013 <li class="item"><a
1014 href="#<?php echo esc_attr($tab_key); ?>"><?php if (isset($yatra_tour_tab_configurations[$tab_key]) && isset($yatra_tour_tab_configurations[$tab_key]['icon'])) {
1015 echo !empty($yatra_tour_tab_configurations[$tab_key]['icon']) ? '<span class="yatra-icon ' . esc_attr($yatra_tour_tab_configurations[$tab_key]['icon']) . '"></span>' : '';
1016 }
1017 echo esc_html($tab); ?></a></li>
1018 <?php } ?>
1019 </ul>
1020 <?php
1021 $loop_index = 0;
1022
1023 foreach ($frontend_tabs_config as $tab_content_key => $tab_content_title) {
1024
1025 $config = $yatra_tour_tab_configurations[$tab_content_key] ?? '';
1026
1027 $icon = '';
1028
1029 if (isset($config['icon']) && '' != $config['icon']) {
1030 $icon = '<span class="tab-icon ' . esc_attr($yatra_tour_tab_configurations[$tab_content_key]['icon']) . '"></span> ';
1031 }
1032 if ($loop_index > 0) {
1033 $toggle_icon = '<span class="tab-icon yatra-toggle-icon fa fa-angle-down"></span> ';
1034 } else {
1035 $toggle_icon = '<span class="tab-icon yatra-toggle-icon fa fa-angle-up"></span> ';
1036 }
1037
1038 $title_text = '<span class="title-text">' . esc_html($tab_content_title) . '</span> ';
1039 ?>
1040 <h3 class="yatra-responsive-tab-title"
1041 data-id="<?php echo esc_attr($tab_content_key) ?>"><?php echo $icon . ' ' . $title_text . ' ' . $toggle_icon ?></h3>
1042 <section id="<?php echo esc_attr($tab_content_key); ?>"
1043 class="yatra-tab-content" <?php if ($loop_index > 0) { ?> aria-hidden="true" <?php } ?>>
1044 <div class="tab-inner">
1045 <?php
1046
1047 do_action('yatra_frontend_tab_content_' . $tab_content_key, $tab_content_title, array(
1048 'post' => $post,
1049 'tab_content_key' => $tab_content_key,
1050 'icon' => ''
1051 ))
1052 ?>
1053 </div>
1054 </section>
1055 <?php
1056 $loop_index++;
1057 } ?>
1058
1059
1060 <?php
1061 }
1062 echo ' </div>';
1063 }
1064 }
1065
1066 if (!function_exists('yatra_tour_custom_attributes')) {
1067 function yatra_tour_custom_attributes()
1068 {
1069 $all_args = array();
1070 $post_id = get_the_ID();
1071 $tour_meta_custom_attributes = get_post_meta($post_id, 'tour_meta_custom_attributes', true);
1072 if (count($tour_meta_custom_attributes) > 0) {
1073 $yatra_tour_attribute_type_options = yatra_tour_attribute_type_options();
1074 foreach ($tour_meta_custom_attributes as $term_id => $content) {
1075 $term = get_term($term_id);
1076 $field_key = get_term_meta($term_id, 'attribute_field_type', true);
1077 $icon = get_term_meta($term_id, 'icon', true);
1078 $icon = '' === ($icon) ? 'fa fa-hashtag' : $icon;
1079 $field = $yatra_tour_attribute_type_options[$field_key] ?? array();
1080 $field_option = $field['options'] ?? array();
1081 if (isset($term->name)) {
1082 foreach ($content as $content_key => $content_value) {
1083
1084 $type = isset($field_option[$content_key]['type']) ? $field_option[$content_key]['type'] : '';
1085
1086 if ($type != '') {
1087 $type_index = in_array($type, array('text', 'number')) ? 'text_number' : '';
1088 $type_index = in_array($type, array('shortcode', 'textarea')) ? 'textarea_shortcode' : $type_index;
1089
1090 $all_args[$type_index][] = array(
1091 'title' => $term->name,
1092 'content' => $content_value,
1093 'type' => $type,
1094 'icon' => $icon
1095
1096 );
1097 }
1098
1099 }
1100 }
1101 }
1102 }
1103 return $all_args;
1104 }
1105 }
1106
1107 if (!function_exists('yatra_tour_custom_attributes_template')) {
1108
1109
1110 function yatra_tour_custom_attributes_template()
1111 {
1112 $all_args = yatra_tour_custom_attributes();
1113
1114
1115 if (count($all_args) > 0) {
1116
1117 foreach ($all_args as $arg_type => $arg_item) {
1118
1119 foreach ($arg_item as $item_index => $item) {
1120
1121 $type = $item['type'];
1122
1123 switch ($arg_type) {
1124 case "text_number":
1125
1126 if ($item_index === 0) {
1127 echo '<div class="yatra-tour-additional-text-number">';
1128 }
1129
1130 if (($item_index + 1) % 4 === 1) {
1131
1132 echo '<div class="yatra-flex-row">';
1133 }
1134 yatra_get_template("tour/attributes-{$type}.php", $item);
1135
1136
1137 if (count($arg_item) === ($item_index + 1) || (($item_index + 1) % 4 === 0)) {
1138
1139 echo '</div>';
1140
1141 }
1142
1143 if (count($arg_item) === ($item_index + 1)) {
1144
1145
1146 echo '</div>';
1147 }
1148 break;
1149 case "textarea_shortcode":
1150 yatra_get_template("tour/attributes-{$type}.php", $item);
1151 break;
1152
1153
1154 }
1155
1156
1157 }
1158 }
1159
1160 }
1161
1162
1163 /*if (count($short_code_args) > 0) {
1164
1165 echo '<div class="yatra-tour-additional-info-shortcode">';
1166
1167 foreach ($short_code_args as $shortcode_content) {
1168 yatra_get_template("tour/attributes-shortcode.php", $shortcode_content);
1169 }
1170 echo '</div>';
1171
1172 }*/
1173
1174 }
1175 }
1176 if (!function_exists('yatra_tour_additional_info')) {
1177 function yatra_tour_additional_info()
1178 {
1179 $post_id = get_the_ID();
1180 $yatra_tour_meta_price_per = get_post_meta($post_id, 'yatra_tour_meta_price_per', true);
1181 $yatra_tour_meta_group_size = get_post_meta($post_id, 'yatra_tour_meta_group_size', true);
1182 $yatra_tour_meta_regular_price = get_post_meta($post_id, 'yatra_tour_meta_regular_price', true);
1183 $yatra_tour_meta_sales_price = get_post_meta($post_id, 'yatra_tour_meta_sales_price', true);
1184 $yatra_tour_meta_tour_duration_days = get_post_meta($post_id, 'yatra_tour_meta_tour_duration_days', true);
1185 $yatra_tour_meta_tour_duration_nights = get_post_meta($post_id, 'yatra_tour_meta_tour_duration_nights', true);
1186 $yatra_tour_meta_tour_country = get_post_meta($post_id, 'yatra_tour_meta_tour_country', true);
1187 $yatra_tour_maximum_number_of_traveller = get_post_meta($post_id, 'yatra_tour_maximum_number_of_traveller', true);
1188 $yatra_tour_minimum_pax = get_post_meta($post_id, 'yatra_tour_minimum_pax', true);
1189
1190
1191 $currency = yatra_get_current_currency();
1192
1193 $currency_symbol = yatra_get_currency_symbol($currency);
1194
1195 $country_string = '';
1196
1197 if (!empty($yatra_tour_meta_tour_country)) {
1198
1199 foreach ($yatra_tour_meta_tour_country as $country_item) {
1200
1201 $country = yatra_get_countries($country_item);
1202
1203 $country_string .= $country . ', ';
1204 }
1205 $country_string = trim($country_string, ', ');
1206
1207 $meta_frontend[] =
1208 array(
1209 'icon' => 'fa fa-map',
1210 'text' => $country_string,
1211 'title' => __('Country', 'yatra')
1212
1213 );
1214
1215 }
1216 $price_string = $currency_symbol . absint($yatra_tour_meta_regular_price);
1217 if ($yatra_tour_meta_sales_price > 0) {
1218
1219 $price_string = '<del>' . $price_string . '</del> &nbsp;' . $currency_symbol . $yatra_tour_meta_sales_price;
1220 }
1221
1222 $tour_duration_string = '';
1223
1224 if ('' != $yatra_tour_meta_tour_duration_days) {
1225
1226 $tour_duration_string = absint($yatra_tour_meta_tour_duration_days) . ' ' . __('Days', 'yatra');
1227 }
1228 if ('' != $yatra_tour_meta_tour_duration_nights) {
1229
1230 $tour_duration_string .= ' ' . absint($yatra_tour_meta_tour_duration_nights) . ' ' . __('Nights', 'yatra');
1231 }
1232
1233 $additional_info = array(
1234 'pricing_per' => ucwords($yatra_tour_meta_price_per),
1235 'group_size' => $yatra_tour_meta_group_size,
1236 'price' => $price_string,
1237 'tour_duration' => $tour_duration_string,
1238 'country' => $country_string,
1239 'max_travellers' => $yatra_tour_maximum_number_of_traveller,
1240 'min_pax' => $yatra_tour_minimum_pax
1241 );
1242 return $additional_info;
1243
1244 }
1245 }
1246