PluginProbe
Yatra – Travel Booking & Tour Operator Software / 2.2.10
Yatra – Travel Booking & Tour Operator Software v2.2.10
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 / functions.php

functions.php in Yatra – Travel Booking & Tour Operator Software 2.2.10, at includes/functions.php

1,486 lines 44.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined('ABSPATH') || exit;
3
4 // Load Helpers
5
6 include_once YATRA_ABSPATH . 'includes/yatra-pricing-functions.php';
7 include_once YATRA_ABSPATH . 'includes/yatra-deprecated-functions.php';
8 include_once YATRA_ABSPATH . 'includes/yatra-html-functions.php';
9 include_once YATRA_ABSPATH . 'includes/helpers/yatra-country-helper.php';
10 include_once YATRA_ABSPATH . 'includes/helpers/yatra-currency-helper.php';
11 include_once YATRA_ABSPATH . 'includes/helpers/yatra-font-helper.php';
12 include_once YATRA_ABSPATH . 'includes/template-tags.php';
13 include_once YATRA_ABSPATH . 'includes/yatra-destination-functions.php';
14 include_once YATRA_ABSPATH . 'includes/yatra-activity-functions.php';
15 include_once YATRA_ABSPATH . 'includes/yatra-misc-functions.php';
16 include_once YATRA_ABSPATH . 'includes/yatra-formatting-functions.php';
17
18
19 if (!function_exists('yatra_tour_tabs')) {
20 function yatra_tour_tabs()
21 {
22 $tour_tabs_array = array(
23 'options' => array(
24 'title' => __('Options', 'yatra'),
25 'icon' => '',
26 ),
27 'itinerary' => array(
28 'title' => __('Itinerary', 'yatra'),
29 'icon' => '',
30 ),
31 'cost_info' => array(
32 'title' => __('Cost Info', 'yatra'),
33 'icon' => '',
34 ),
35 'facts' => array(
36 'title' => __('Facts', 'yatra'),
37 'icon' => '',
38 ),
39 'faq' => array(
40 'title' => __('FAQ', 'yatra'),
41 'icon' => '',
42 ),
43 );
44
45 return apply_filters('yatra_tour_tabs', $tour_tabs_array);
46 }
47 }
48
49 if (!function_exists('yatra_tour_metabox_tabs')) {
50
51 function yatra_tour_metabox_tabs()
52 {
53 $metabox_tabs = array(
54
55 'general' => array(
56 'title' => esc_html__('General', 'yatra'),
57 'is_active' => true,
58 'settings' => yatra_tour_general_configurations()
59 ),
60 'duration' => array(
61 'title' => esc_html__('Date & Durations', 'yatra'),
62 'settings' => yatra_tour_duration_configurations()
63 ),
64 'pricing' => array(
65 'title' => esc_html__('Pricing', 'yatra'),
66 'settings' => yatra_tour_pricing_configurations()
67 ),
68
69 'attributes' => array(
70 'title' => esc_html__('Attributes', 'yatra'),
71 'settings' => yatra_tour_attributes()
72 ),
73 'tour_tabs' => array(
74 'title' => esc_html__('Tour Tabs', 'yatra'),
75 'settings' => yatra_tour_tab_configurations()
76 ),
77 );
78
79 return apply_filters('yatra_tour_metabox_tabs', $metabox_tabs);
80 }
81 }
82
83
84 if (!function_exists('yatra_set_session')) {
85
86 function yatra_set_session($key = '', $value = '')
87 {
88 yatra()->session->set($key, $value);
89
90 return true;
91
92 }
93 }
94
95 if (!function_exists('yatra_get_session')) {
96
97 function yatra_get_session($key = '')
98 {
99 $session = yatra()->session->get($key);
100
101 if (is_array($session)) {
102
103 return $session;
104 }
105 return [];
106 }
107 }
108
109 if (!function_exists('yatra_clear_session')) {
110
111 function yatra_clear_session($key = '')
112 {
113 yatra()->session->set($key, '');
114
115 return true;
116
117 }
118 }
119
120 if (!function_exists('yatra_get_template')) {
121
122 function yatra_get_template($template_name, $args = array(), $template_path = '', $default_path = '')
123 {
124 $cache_key = sanitize_key(implode('-', array('template', $template_name, $template_path, $default_path)));
125 $template = (string)wp_cache_get($cache_key, 'yatra');
126
127 if (!$template) {
128 $template = yatra_locate_template($template_name, $template_path, $default_path);
129 wp_cache_set($cache_key, $template, 'yatra');
130 }
131 // Allow 3rd party plugin filter template file from their plugin.
132 $filter_template = apply_filters('yatra_get_template', $template, $template_name, $args, $template_path, $default_path);
133
134 if ($filter_template !== $template) {
135 if (!file_exists($filter_template)) {
136 /* translators: %s template */
137 _doing_it_wrong(__FUNCTION__, sprintf(__('%s does not exist.', 'yatra'), '<code>' . $template . '</code>'), '1.0.1');
138 return;
139 }
140 $template = $filter_template;
141 }
142
143 $action_args = array(
144 'template_name' => $template_name,
145 'template_path' => $template_path,
146 'located' => $template,
147 'args' => $args,
148 );
149
150 if (!empty($args) && is_array($args)) {
151 if (isset($args['action_args'])) {
152 _doing_it_wrong(
153 __FUNCTION__,
154 __('action_args should not be overwritten when calling yatra_get_template.', 'yatra'),
155 '1.0.0'
156 );
157 unset($args['action_args']);
158 }
159 extract($args); // @codingStandardsIgnoreLine
160 }
161
162 do_action('yatra_before_template_part', $action_args['template_name'], $action_args['template_path'], $action_args['located'], $action_args['args']);
163
164 include $action_args['located'];
165
166 do_action('yatra_after_template_part', $action_args['template_name'], $action_args['template_path'], $action_args['located'], $action_args['args']);
167 }
168 }
169
170 if (!function_exists('yatra_locate_template')) {
171 function yatra_locate_template($template_name, $template_path = '', $default_path = '')
172 {
173 if (!$template_path) {
174 $template_path = yatra()->template_path();
175 }
176
177 if (!$default_path) {
178 $default_path = yatra()->plugin_template_path();
179 }
180
181 // Look within passed path within the theme - this is priority.
182 $template = locate_template(
183 array(
184 trailingslashit($template_path) . $template_name,
185 $template_name,
186 )
187 );
188
189 // Get default template/.
190 if (!$template) {
191 $template = $default_path . $template_name;
192 }
193 // Return what we found.
194 return apply_filters('yatra_locate_template', $template, $template_name, $template_path);
195 }
196 }
197
198 if (!function_exists('yatra_single_tour_tabs')) {
199
200 function yatra_single_tour_tabs()
201 {
202 global $post;
203
204
205 }
206 }
207
208 if (!function_exists('yatra_get_checkout_page')) {
209
210 function yatra_get_checkout_page($get_permalink = false)
211 {
212
213 $page_id = absint(get_option('yatra_checkout_page'));
214
215 if ($page_id < 1) {
216
217 global $wpdb;
218
219 $page_id = $wpdb->get_var('SELECT ID FROM ' . $wpdb->prefix . 'posts WHERE post_content LIKE "%[yatra_checkout]%" AND post_parent = 0');
220 }
221
222 $page_permalink = get_permalink($page_id);
223
224 if ($get_permalink) {
225
226 return $page_permalink;
227 }
228
229 return $page_id;
230
231
232 }
233 }
234
235
236 if (!function_exists('yatra_get_cart_page')) {
237
238 function yatra_get_cart_page($get_permalink = false)
239 {
240 $page_id = absint(get_option('yatra_cart_page'));
241
242 if ($page_id < 1) {
243
244 global $wpdb;
245
246 $page_id = $wpdb->get_var('SELECT ID FROM ' . $wpdb->prefix . 'posts WHERE post_content LIKE "%[yatra_cart]%" AND post_parent = 0');
247 }
248
249 $page_permalink = get_permalink($page_id);
250
251 if ($get_permalink) {
252
253 return $page_permalink;
254 }
255
256 return $page_id;
257
258
259 }
260 }
261
262 if (!function_exists('yatra_get_booking_statuses')) {
263
264 function yatra_get_booking_statuses($status_key = '')
265 {
266 $statuses = apply_filters(
267 'yatra_booking_statuses', array(
268 'yatra-pending' => __('Pending', 'yatra'),
269 'yatra-processing' => __('Processing', 'yatra'),
270 'yatra-on-hold' => __('On Hold', 'yatra'),
271 'yatra-completed' => __('Completed', 'yatra'),
272 'yatra-cancelled' => __('Cancelled', 'yatra'),
273 'yatra-failed' => __('Failed', 'yatra'),
274 )
275 );
276
277 if (empty($status_key)) {
278
279 return $statuses;
280 }
281 if (isset($statuses[$status_key])) {
282 return $statuses[$status_key];
283 }
284 return $statuses;
285
286 }
287 }
288
289 if (!function_exists('yatra_the_posts_navigation')) :
290 /**
291 * Documentation for function.
292 */
293 function yatra_the_posts_navigation()
294 {
295 the_post_navigation(array(
296 'prev_text' => '<span class="screen-reader-text">' . esc_html__('Previous Post', 'yatra') . '</span><span class="nav-title">%title</span>',
297 'next_text' => '<span class="screen-reader-text">' . esc_html__('Next Post', 'yatra') . '</span><span class="nav-title">%title</span>',
298 ));
299 }
300 endif;
301
302 if (!function_exists('yatra_get_template_part')) {
303
304 function yatra_get_template_part($slug, $name = '')
305 {
306 $path = "{$slug}.php";
307
308 if ('' !== $name) {
309
310 $path = "{$slug}-{$name}.php";
311 }
312 $template = yatra_locate_template($path, false, false);
313
314 require $template;
315
316 }
317
318 }
319 if (!function_exists('yatra_posted_by')) :
320 /**
321 * Prints HTML with meta information about theme author.
322 */
323 function yatra_posted_by()
324 {
325 printf(
326 /* translators: 1: SVG icon. 2: post author, only visible to screen readers. 3: author link. */
327 '<span class="byline"><span class="screen-reader-text">%1$s</span><span class="author vcard"><a class="url fn n" href="%2$s">%3$s</a></span></span>',
328 __('Posted by', 'yatra'),
329 esc_url(get_author_posts_url(get_the_author_meta('ID'))),
330 esc_html(get_the_author())
331 );
332 }
333 endif;
334
335 if (!function_exists('yatra_posted_on')) :
336 /**
337 * Prints HTML with meta information for the current post-date/time.
338 */
339 function yatra_posted_on()
340 {
341 $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
342 if (get_the_time('U') !== get_the_modified_time('U')) {
343 //$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
344 }
345
346 $time_string = sprintf(
347 $time_string,
348 esc_attr(get_the_date(DATE_W3C)),
349 esc_html(get_the_date()),
350 esc_attr(get_the_modified_date(DATE_W3C)),
351 esc_html(get_the_modified_date())
352 );
353
354 printf(
355 '<span class="posted-on"><a href="%1$s" rel="bookmark">%2$s</a></span>',
356 esc_url(get_permalink()),
357 $time_string
358 );
359 }
360 endif;
361
362 /**
363 * Get permalink settings
364 *
365 * @return array
366 * @since 1.0.0
367 */
368 function yatra_get_permalink_structure()
369 {
370
371 $permalinks = wp_parse_args(
372 (array)get_option('yatra_permalinks', array()),
373 array(
374 'yatra_tour_base' => 'tour',
375 'yatra_destination_base' => 'destination',
376 'yatra_activity_base' => 'activity',
377 'yatra_attributes_base' => 'attributes',
378 )
379 );
380
381 // Ensure rewrite slugs are set.
382 $permalinks['yatra_tour_base'] = untrailingslashit(empty($permalinks['yatra_tour_base']) ? 'tour' : $permalinks['yatra_tour_base']);
383 $permalinks['yatra_destination_base'] = untrailingslashit(empty($permalinks['yatra_destination_base']) ? 'destination' : $permalinks['yatra_destination_base']);
384 $permalinks['yatra_activity_base'] = untrailingslashit(empty($permalinks['yatra_activity_base']) ? 'activity' : $permalinks['yatra_activity_base']);
385 return $permalinks;
386 }
387
388 if (!function_exists('yatra_get_tour_price')) {
389
390 function yatra_get_tour_price($tour_id, $number_of_people, $selected_date)
391 {
392 $tour_options = new Yatra_Tour_Options($tour_id, $selected_date, $selected_date, $number_of_people);
393
394 $tourData = $tour_options->getTourData();
395
396 $todayDataSettings = $tour_options->getTodayData($selected_date);
397
398 if ($todayDataSettings instanceof Yatra_Tour_Dates) {
399
400 $todayData = (boolean)$todayDataSettings->isActive() ? $todayDataSettings : $tourData;
401
402 } else {
403
404 $todayData = $tourData;
405 }
406
407 $pricing = $todayData->getPricing();
408
409 $tour_total_price = 0;
410
411 if ($pricing instanceof Yatra_Tour_Pricing) {
412
413 $tour_total_price += $pricing->getFinalPrice();
414
415 } else {
416
417 foreach ($pricing as $pricing_item) {
418
419 $tour_total_price += $pricing_item->getFinalPrice();
420 }
421
422 }
423 return $tour_total_price;
424 }
425
426 }
427
428 if (!function_exists('yatra_get_final_tour_price')) {
429
430 function yatra_get_final_tour_price($tour_id, $number_of_people, $selected_date)
431 {
432
433 $final_pricing = yatra_get_tour_price($tour_id, $number_of_people, $selected_date);
434
435 return apply_filters('yatra_tour_booking_final_price', floatval($final_pricing), $tour_id, $number_of_people, $selected_date);
436 }
437 }
438
439
440 if (!function_exists('yatra_get_booking_final_price')) {
441
442 function yatra_get_booking_final_price($booking_parameters = array(), $net_pricing = false)
443 {
444 $total_booking_price = 0;
445
446 foreach ($booking_parameters as $parameter) {
447
448 $total_booking_price = $total_booking_price + floatval(yatra_get_final_tour_price($parameter['tour_id'], $parameter['number_of_person'], $parameter['selected_date']));
449
450 }
451 return apply_filters('yatra_booking_final_price', $total_booking_price, $booking_parameters, $net_pricing);
452 }
453 }
454
455
456 if (!function_exists('yatra_update_booking_status')) {
457
458 function yatra_update_booking_status($booking_id = 0, $status = 'yatra-pending')
459 {
460 $yatra_booking_statuses = yatra_get_booking_statuses();
461
462 if ($booking_id < 1 || !isset($yatra_booking_statuses[$status])) {
463
464 return false;
465 }
466
467 do_action('yatra_before_booking_status_change', array(
468 'booking_id' => $booking_id,
469 'status' => $status
470 ));
471
472 $booking_array = array();
473 $booking_array['ID'] = $booking_id;
474 $booking_array['post_status'] = $status;
475
476 // Update the post into the database
477 wp_update_post($booking_array);
478
479 do_action('yatra_after_booking_status_change', array(
480 'booking_id' => $booking_id,
481 'status' => $status
482 ));
483
484 return true;
485 }
486 }
487
488
489 if (!function_exists('yatra_global_smart_tags')) {
490
491 function yatra_global_smart_tags()
492 {
493 return apply_filters(
494 'yatra_global_smart_tags',
495 array(
496 'home_url' => get_home_url(),
497 'blog_info' => get_bloginfo(),
498 )
499 );
500 }
501 }
502
503 if (!function_exists('yatra_enquiry_form_smart_tags')) {
504 function yatra_enquiry_form_smart_tags($enquiry_id = 0)
505 {
506 $smart_tags = array(
507 'enquiry_fullname' => '',
508 'enquiry_tour_name' => '',
509 'enquiry_email' => '',
510 'enquiry_country' => '',
511 'enquiry_phone_number' => '',
512 'enquiry_number_of_adults' => '',
513 'enquiry_number_of_childs' => '',
514 'enquiry_message' => '',
515 'enquiry_subject' => '',
516 'enquiry_date' => '',
517 );
518
519 $where = array(
520 'id' => absint($enquiry_id)
521 );
522 $enquiry = Yatra_Core_DB::get_data(Yatra_Tables::TOUR_ENQUIRIES, array(), $where);
523 if (isset($enquiry[0])) {
524 $enquiry_item = $enquiry[0];
525
526 $country = $enquiry_item->country ? yatra_get_countries($enquiry_item->country) : '';
527 $tour_title = isset($enquiry_item->tour_id) && absint($enquiry_item->tour_id) > 0 ? get_the_title($enquiry_item->tour_id) : '';
528 $smart_tags = array(
529 'enquiry_fullname' => $enquiry_item->fullname ?? '',
530 'enquiry_tour_name' => $tour_title,
531 'enquiry_email' => $enquiry_item->email ?? '',
532 'enquiry_country' => !is_array($country) ? $country : '',
533 'enquiry_phone_number' => $enquiry_item->phone_number ?? '',
534 'enquiry_number_of_adults' => $enquiry_item->number_of_adults ?? '',
535 'enquiry_number_of_childs' => $enquiry_item->number_of_childs ?? '',
536 'enquiry_message' => $enquiry_item->message ?? '',
537 'enquiry_subject' => $enquiry_item->subject ?? '',
538 'enquiry_date' => $enquiry_item->created_at ?? '',
539 );
540 }
541
542 $smart_tags = apply_filters(
543 'yatra_enquiry_form_smart_tags',
544 $smart_tags
545 );
546
547 $yatra_global_smart_tags = yatra_global_smart_tags();
548
549 return array_merge($yatra_global_smart_tags, $smart_tags);
550
551 }
552 }
553 if (!function_exists('yatra_booking_smart_tags')) {
554
555 function yatra_booking_smart_tags($booking_id = 0)
556 {
557 $smart_tags['booking_code'] = '';
558
559 $smart_tags['booking_status'] = '';
560
561 $smart_tags['total_number_of_persons'] = '';
562
563 $tour_lists = array();
564
565 $total_number_of_persons = 0;
566
567 if ($booking_id > 0) {
568
569 $booking_post = get_post($booking_id);
570
571 $booking_status = $booking_post->post_status ?? '';
572
573 $booking = new Yatra_Tour_Booking($booking_id);
574
575 $booking_details = $booking->get_all_booking_details($booking_id);
576
577 $all_post_statuses = yatra_get_booking_statuses();
578
579 $booking_meta_params = $booking_details->yatra_booking_meta_params ?? array();
580
581 $booking_meta = $booking_details->yatra_booking_meta ?? array();
582
583 $smart_tags['booking_code'] = $booking_meta_params['booking_code'] ?? '';
584
585 $smart_tags['booking_status'] = $all_post_statuses[$booking_status] ?? '';
586
587 $smart_tags['net_booking_price'] = yatra_get_price(yatra_get_current_currency_symbol($booking->get_currency_code()), $booking->get_total(true));
588
589 $smart_tags['gross_booking_price'] = yatra_get_price(yatra_get_current_currency_symbol($booking->get_currency_code()), $booking->get_total());
590
591 $smart_tags['discount'] = yatra_get_price(yatra_get_current_currency_symbol($booking->get_currency_code()), $booking->get_discount_amount());
592
593 foreach ($booking_meta as $tour_id => $meta) {
594
595 $booked_date = $meta['yatra_selected_date'] ?? '';
596
597 $number_of_person = $meta['number_of_person'] ?? '';
598
599 $total_tour_price = $meta['total_tour_price'] ?? '';
600
601 $number_of_person = is_array($number_of_person) ? array_sum($number_of_person) : $number_of_person;
602
603 $total_number_of_persons += absint($number_of_person);
604
605 $tour_list = array();
606
607 $tour_list['tour_name'] = '<a href="' . get_permalink($tour_id) . '" target="_blank">' . $meta['yatra_tour_name'] . '</a>';
608
609 $tour_list['tour_date'] = $booked_date;
610
611 $tour_list['number_of_person'] = $number_of_person;
612
613 $tour_list['total_tour_price'] = yatra_get_price(yatra_get_current_currency_symbol($booking->get_currency_code()), $total_tour_price);
614
615 array_push($tour_lists, $tour_list);
616 }
617
618 }
619
620 $smart_tags['tour_lists'] = $tour_lists;
621
622 $smart_tags['booking_tours_count'] = count($tour_lists);
623
624 $smart_tags['total_number_of_persons'] = $total_number_of_persons;
625
626 return apply_filters(
627 'yatra_booking_smart_tags', $smart_tags,
628 ['booking_id' => $booking_id]
629 );
630 }
631 }
632
633 if (!function_exists('yatra_customer_smart_tags')) {
634
635 function yatra_customer_smart_tags($booking_id = 0)
636 {
637 $smart_tags['customer_name'] = '';
638
639 $smart_tags['customer_email'] = '';
640
641 if ($booking_id > 0) {
642
643 $booking_meta_params = get_post_meta($booking_id, 'yatra_booking_meta_params', true);
644
645 $customer_info = isset($booking_meta_params ['yatra_tour_customer_info']) ? $booking_meta_params ['yatra_tour_customer_info'] : array();
646
647 $smart_tags['customer_name'] = isset($customer_info['fullname']) ? $customer_info['fullname'] : '';
648
649 $smart_tags['customer_email'] = isset($customer_info['email']) ? $customer_info['email'] : '';
650
651 $smart_tags['customer_phone_number'] = isset($customer_info['phone_number']) ? $customer_info['phone_number'] : '';
652
653 $country_index = isset($customer_info['country']) ? $customer_info['country'] : '';
654
655 $country = $country_index !== '' ? yatra_get_countries($country_index) : '';
656
657 $smart_tags['customer_country'] = $country;
658 }
659
660 return apply_filters(
661 'yatra_customer_smart_tags', $smart_tags,
662 ['booking_id' => $booking_id]
663 );
664 }
665 }
666 if (!function_exists('yatra_get_date')) {
667
668 function yatra_get_date($date_only = false, $datetime = '')
669 {
670 $date_format = 'Y-m-d';
671
672 $time_format = 'Y-m-d H:i:s';
673
674 if ($date_only) {
675 return $datetime == '' ? date($date_format) : date($date_format, strtotime($datetime));
676 }
677 return $datetime == '' ? date($time_format) : date($time_format, strtotime($datetime));
678 }
679 }
680
681 function yatra_get_string_between(&$string_content, $startDelimiter, $endDelimiter)
682 {
683 $contents = array();
684 $startDelimiterLength = strlen($startDelimiter);
685 $endDelimiterLength = strlen($endDelimiter);
686 $startFrom = $contentStart = $contentEnd = 0;
687 while (false !== ($contentStart = strpos($string_content, $startDelimiter, $startFrom))) {
688 $contentStart += $startDelimiterLength;
689 $contentEnd = strpos($string_content, $endDelimiter, $contentStart);
690 if (false === $contentEnd) {
691 break;
692 }
693 $loop_index = count($contents) < 1 ? 1 : count($contents);
694 $substr = substr($string_content, $contentStart, $contentEnd - $contentStart);
695 $substr_index = 'yatra_content_loop_' . $loop_index;
696 $contents[$substr_index] = $substr;
697 $string_content = substr_replace($string_content, '{{' . 'yatra_content_loop_' . $loop_index . '}}', $contentStart, ($contentEnd - $contentStart));
698 $contentEnd = strpos($string_content, $endDelimiter, $contentStart);
699 $startFrom = $contentEnd + $endDelimiterLength;
700 }
701
702 return $contents;
703 }
704
705 if (!function_exists('yatra_maybe_parse_smart_tags')) {
706
707 function yatra_maybe_parse_smart_tags($all_smart_tags = array(), $content = '')
708 {
709
710 //For Back Compatibility
711 $content = str_replace("{{tour_lists}}", "{{tour_lists_loop_start}}{{tour_name}}{{tour_lists_loop_end}}", $content);
712
713 $looped_content = yatra_get_string_between($content, '{{tour_lists_loop_start}}', '{{tour_lists_loop_end}}');
714
715
716 foreach ($all_smart_tags as $tag => $tag_value) {
717
718 $content = yatra_parse_smart_tag_item($tag, $tag_value, $content);
719
720 $looped_content = yatra_parse_smart_tag_item($tag, $tag_value, $looped_content);
721
722 }
723 $parsed_looped_content = array();
724
725 foreach ($looped_content as $loop_id => $loop_content) {
726
727 $tour_list_smart_tags = $all_smart_tags['tour_lists'] ? $all_smart_tags['tour_lists'] : array();
728
729 foreach ($tour_list_smart_tags as $tour_list_item) {
730
731 $loop_content = $looped_content[$loop_id];
732
733 foreach ($tour_list_item as $tag_item => $tag_item_value) {
734
735 $loop_content = yatra_parse_smart_tag_item($tag_item, $tag_item_value, $loop_content);
736
737 }
738
739 $parsed_looped_content[$loop_id] = isset($parsed_looped_content[$loop_id]) ? $parsed_looped_content[$loop_id] . $loop_content : $loop_content;
740 }
741 }
742
743 foreach ($parsed_looped_content as $parsed_loop_id => $parsed_loop_content) {
744
745 $content = str_replace('{{tour_lists_loop_start}}{{' . $parsed_loop_id . '}}{{tour_lists_loop_end}}', $parsed_loop_content, $content);
746 }
747
748 return $content;
749 }
750 }
751 if (!function_exists('yatra_parse_smart_tag_item')) {
752
753 function yatra_parse_smart_tag_item($tag, $tag_value, $content)
754 {
755 $smart_tag = "{{" . $tag . "}}";
756
757 if (!is_array($tag_value)) {
758
759 $content = str_replace($smart_tag, $tag_value, $content);
760
761 } else {
762
763 foreach ($tag_value as $new_tag_id => $new_tag_value) {
764
765 $new_tag_id_string = count(array_filter(array_keys($tag_value), 'is_string')) === 0 ? $tag : ($tag . '.' . $new_tag_id);
766
767 $content = yatra_parse_smart_tag_item($new_tag_id_string, $new_tag_value, $content);
768
769 }
770 }
771 return $content;
772 }
773 }
774
775 if (!function_exists('yatra_all_smart_tags')) {
776
777 function yatra_all_smart_tags($booking_id = 0)
778 {
779 $yatra_global_smart_tags = yatra_global_smart_tags();
780
781 $yatra_booking_smart_tags = yatra_booking_smart_tags($booking_id);
782
783 $yatra_customer_smart_tags = yatra_customer_smart_tags($booking_id);
784
785 $all_tags = array_merge($yatra_global_smart_tags, $yatra_booking_smart_tags, $yatra_customer_smart_tags);
786
787 return apply_filters('yatra_all_smart_tags', $all_tags, ['booking_id' => $booking_id]);
788 }
789 }
790
791
792 /**
793 * Get data if set, otherwise return a default value or null. Prevents notices when data is not set.
794 *
795 * @param mixed $var Variable.
796 * @param string $default Default value.
797 * @return mixed
798 * @since
799 */
800 if (!function_exists(('yatra_get_var'))) {
801 function yatra_get_var(&$var, $default = null)
802 {
803 return isset($var) ? $var : $default;
804 }
805 }
806
807 if (!function_exists('is_yatra_error')) {
808
809 function is_yatra_error($thing)
810 {
811 return ($thing instanceof WP_Error);
812 }
813
814
815 }
816
817 if (!function_exists('yatra_logout_url')) {
818
819 function yatra_logout_url()
820 {
821
822 return wp_logout_url(get_permalink());
823
824 }
825
826
827 }
828
829 if (!function_exists('yatra_get_my_account_page')) {
830
831 function yatra_get_my_account_page($get_permalink = false)
832 {
833 $page_id = absint(get_option('yatra_my_account_page'));
834
835 if ($page_id < 1) {
836
837 global $wpdb;
838
839 $page_id = $wpdb->get_var('SELECT ID FROM ' . $wpdb->prefix . 'posts WHERE post_content LIKE "%[yatra_my_account]%" AND post_parent = 0');
840 }
841
842 $page_permalink = get_permalink($page_id);
843
844 if ($get_permalink) {
845
846 return $page_permalink;
847 }
848
849 return $page_id;
850
851
852 }
853 }
854
855 if (!function_exists('yatra_enable_guest_checkout')) {
856
857 function yatra_enable_guest_checkout()
858 {
859 if ('yes' === get_option('yatra_enable_guest_checkout', 'yes')) {
860
861 return true;
862 }
863 return false;
864
865 }
866 }
867
868 if (!function_exists('yatra_payment_gateway_fields')) {
869
870 function yatra_payment_gateway_fields()
871 {
872 $yatra_get_active_payment_gateways = (yatra_get_active_payment_gateways());
873
874 $yatra_get_payment_gateways = yatra_get_payment_gateways();
875
876 if (count($yatra_get_active_payment_gateways) > 0) {
877
878 echo '<h2 class="yatra-payment-gateway-title">' . __('Payment Gateways', 'yatra') . '</h2>';
879
880 echo '<ul class="yatra-payment-gateway">';
881
882 $selected_gateway_id = $yatra_get_payment_gateways[0]['id'] ?? '';
883
884 $selected_gateway = yatra()->helper->input('yatra-payment-gateway');
885
886 $selected_gateway = $selected_gateway === '' ? $selected_gateway_id : $selected_gateway;
887
888 foreach ($yatra_get_payment_gateways as $gateway) {
889
890 $gateway_id = isset($gateway['id']) ? $gateway['id'] : '';
891
892 if (in_array($gateway_id, $yatra_get_active_payment_gateways)) {
893
894 echo '<li>';
895
896 echo '<label for="yatra-payment-gateway-' . esc_attr($gateway_id) . '">';
897
898 echo '<input type="radio" id="yatra-payment-gateway-' . esc_attr($gateway_id) . '" name="yatra-payment-gateway" value="' . esc_attr($gateway_id) . '" ' . checked($gateway_id, $selected_gateway, false) . '/>';
899
900 echo '&nbsp;<span>' . $gateway['frontend_title'] . '</span>';
901
902 echo '</label>';
903
904 echo '<div class="yatra-payment-gateway-field-wrap yatra-payment-gateway-field-' . $gateway_id . ' yatra-hide">';
905
906 do_action('yatra_payment_gateway_field_' . $gateway_id);
907
908 echo '</div>';
909
910 echo '</li>';
911 }
912
913 }
914 echo '</ul>';
915 }
916 }
917 }
918
919 if (!function_exists('yatra_tour_has_attributes')) {
920
921 function yatra_tour_has_attributes($post_id = null)
922 {
923 $post_id = is_null($post_id) ? get_the_ID() : $post_id;
924
925 $tour_meta_custom_attributes = get_post_meta($post_id, 'tour_meta_custom_attributes', true);
926
927 $tour_meta_custom_attributes = !$tour_meta_custom_attributes ? array() : $tour_meta_custom_attributes;
928
929 if (count($tour_meta_custom_attributes) > 0) {
930
931 return true;
932 }
933 return false;
934 }
935 }
936
937
938 if (!function_exists('yatra_maybeintempty')) {
939 function yatra_maybeintempty($var)
940 {
941 if ($var == '') {
942 return '';
943 }
944 return absint($var);
945 }
946 }
947
948 if (!function_exists('yatra_maybe_json_decode')) {
949 function yatra_maybe_json_decode($var, $assoc = true)
950 {
951 if ($var == '') {
952 return array();
953 }
954 if (is_array($var)) {
955
956 return $var;
957 }
958 return json_decode($var, $assoc);
959 }
960 }
961
962
963 if (!function_exists('yatra_tour_tabs_additional_types')) {
964 function yatra_tour_tabs_additional_types()
965 {
966 return apply_filters('yatra_tour_tabs_additional_types', ["text"]);
967 }
968 }
969
970
971 if (!function_exists('yatra_frontend_tour_tabs_ordering')) {
972
973 function yatra_frontend_tour_tabs_ordering($type = 'array', $post_ID = null)
974 {
975 $ordering_string = '';
976
977 if (!is_null($post_ID)) {
978
979 $ordering_string = get_post_meta($post_ID, 'yatra_tour_meta_tour_tabs_ordering', true);
980 }
981 if (!$ordering_string) {
982
983 $ordering_string_array = array_keys(yatra_frontend_tabs_available_options());
984
985 $ordering_string = implode(',', $ordering_string_array);
986 }
987
988 if (!$ordering_string) {
989
990 $tour_tab_configs = yatra_tour_tab_default_configurations();
991
992 $config_keys = array_keys($tour_tab_configs);
993
994 $ordering_string = implode(',', $config_keys);
995 }
996 return $type === 'array' ? explode(',', $ordering_string) : $ordering_string;
997
998 }
999 }
1000
1001
1002 if (!function_exists('yatra_has_tab_visible')) {
1003
1004 function yatra_has_tab_visible($tab_key, $post_id = null): bool
1005 {
1006 $post_id = is_null($post_id) ? get_the_ID() : $post_id;
1007
1008 $visibility_key = sanitize_text_field(($tab_key . '_visibility'));
1009
1010 $visibility = get_post_meta($post_id, $visibility_key, true);
1011
1012 if ($visibility == '' || is_null($visibility)) {
1013
1014 $available_tabs = yatra_frontend_tabs_available_options();
1015
1016 $tab = $available_tabs[$tab_key] ?? array();
1017
1018 $visibility = isset($tab['visibility']) && (boolean)$tab['visibility'];
1019 }
1020
1021
1022 return $visibility;
1023
1024 }
1025 }
1026
1027 if (!function_exists('yatra_frontend_tabs_available_options')) {
1028
1029 function yatra_frontend_tabs_available_options($post_id = null)
1030 {
1031 $all_valid_available_tabs = get_option('yatra_frontend_tabs_available_options', array());
1032
1033 $tour_tab_configs = yatra_tour_tab_default_configurations();
1034
1035 $all_valid_available_tabs_keys = !(is_array($all_valid_available_tabs)) ? array() : array_keys($all_valid_available_tabs);
1036
1037 $yatra_tour_tabs_additional_types = yatra_tour_tabs_additional_types();
1038
1039 foreach ($tour_tab_configs as $config_key => $config) {
1040
1041 $visibility = true;
1042
1043 if (isset($config['options'])) {
1044
1045
1046 $visibility = isset($config['options'][$config_key . '_visibility']) && isset($config['options'][$config_key . '_visibility']['default']) && (boolean)$config['options'][$config_key . '_visibility']['default'];
1047
1048 unset($config['options']);
1049 }
1050
1051 if (!in_array($config_key, $all_valid_available_tabs_keys)) {
1052
1053 $all_valid_available_tabs[$config_key] = $config;
1054
1055 $all_valid_available_tabs[$config_key]['type'] = $config_key;
1056
1057 $all_valid_available_tabs[$config_key]['visibility'] = $visibility;
1058
1059 }
1060 };
1061 foreach ($all_valid_available_tabs as $tab_index => $tab) {
1062
1063 $type = $tab['type'] ?? $tab_index;
1064
1065 if (!isset($tour_tab_configs[$type])) {
1066
1067 if (!in_array($type, $yatra_tour_tabs_additional_types)) {
1068
1069 unset($all_valid_available_tabs[$tab_index]);
1070 }
1071
1072 }
1073 }
1074
1075
1076 return $all_valid_available_tabs;
1077
1078 }
1079 }
1080 if (!function_exists('yatra_tour_availability')) {
1081
1082 function yatra_tour_meta_availability_date_ranges($tour_id)
1083 {
1084
1085 $availability = get_post_meta($tour_id, 'yatra_tour_meta_availability_date_ranges', true);
1086
1087 return yatra_maybe_json_decode($availability);
1088 }
1089 }
1090
1091 if (!function_exists('yatra_is_date_overlap')) {
1092
1093 function yatra_is_date_overlap($start_one, $end_one, $start_two, $end_two)
1094 {
1095
1096 if ($start_one <= $end_two && $end_one >= $start_two) { //If the dates overlap
1097 return min($end_one, $end_two)->diff(max($start_two, $start_one))->days + 1; //return how many days overlap
1098 }
1099
1100 return 0; //Return 0 if there is no overlap
1101 }
1102 }
1103
1104 if (!function_exists('yatra_is_date_overlapped')) {
1105 function yatra_is_date_range_overlap($date_ranges, $input_range)
1106 {
1107 $start = new DateTime($input_range['start']);
1108
1109 $end = new DateTime($input_range['end']);
1110
1111 $overlaped_ranges = array();
1112
1113 foreach ($date_ranges as $range) {
1114
1115 $range_start = new DateTime($range['start']);
1116
1117 $range_end = new DateTime($range['end']);
1118
1119 $status = yatra_is_date_overlap($start, $end, $range_start, $range_end);
1120
1121 if ($status) {
1122
1123 $overlaped_ranges[] = $range;
1124 }
1125
1126 }
1127
1128 return $overlaped_ranges;
1129 }
1130
1131
1132 }
1133 if (!function_exists('yatra_get_unique_date_ranges')) { // Get ranges with not overlapped each other
1134 function yatra_get_unique_date_ranges($date_ranges)
1135 {
1136 $unique_ranges = array();
1137
1138 foreach ($date_ranges as $range_index => $range) {
1139
1140 $new_ranges = $date_ranges;
1141
1142 unset($new_ranges[$range_index]);
1143
1144 if (!yatra_is_date_range_overlap($new_ranges, $range)) {
1145 $unique_ranges[] = $range;
1146 }
1147
1148 }
1149 return $unique_ranges;
1150
1151
1152 }
1153
1154
1155 }
1156 if (!function_exists('yatra_parse_args')) {
1157
1158 function yatra_parse_args($args, $defaults = array(), $limited_to_defaults = false)
1159 {
1160 $defaults = is_array($defaults) ? $defaults: array();
1161
1162 $parsed = wp_parse_args($args, $defaults);
1163
1164 if (!$limited_to_defaults) {
1165 return $parsed;
1166 }
1167 $final_parsed = array();
1168
1169 foreach ($defaults as $array_key => $array_value) {
1170
1171 $final_parsed[$array_key] = isset($parsed[$array_key]) ? $parsed[$array_key] : $defaults[$array_key];
1172 }
1173
1174
1175 return $final_parsed;
1176 }
1177 }
1178
1179 if (!function_exists('yatra_get_pricing_type')) {
1180
1181 function yatra_get_pricing_type($tourID)
1182 {
1183 $multiple_pricing = get_post_meta($tourID, 'yatra_multiple_pricing', true);
1184
1185 if (is_array($multiple_pricing)) {
1186
1187 if (count($multiple_pricing) > 0) {
1188
1189 return 'multi';
1190 }
1191 }
1192 return 'single';
1193 }
1194 }
1195
1196 if (!function_exists('yatra_get_tour_base_multiple_pricing')) {
1197
1198 function yatra_get_tour_base_multiple_pricing($tourID, $override_overridable_fields_from_base = false)
1199 {
1200 $multiple_pricing = get_post_meta($tourID, 'yatra_multiple_pricing', true);
1201
1202 if (is_array($multiple_pricing)) {
1203
1204 if ($override_overridable_fields_from_base) {
1205
1206 $base_pricing = yatra_get_tour_base_single_pricing($tourID);
1207
1208 foreach ($multiple_pricing as $pricing_id => $pricing) {
1209 $multiple_pricing[$pricing_id]['group_size'] = $pricing['pricing_per'] === '' ? $base_pricing['group_size'] : $pricing['group_size'];
1210 $multiple_pricing[$pricing_id]['pricing_per'] = $pricing['pricing_per'] === '' ? $base_pricing['pricing_per'] : $pricing['pricing_per'];
1211 $multiple_pricing[$pricing_id]['minimum_pax'] = $pricing['minimum_pax'] === '' ? $base_pricing['minimum_pax'] : $pricing['minimum_pax'];
1212 $multiple_pricing[$pricing_id]['maximum_pax'] = $pricing['maximum_pax'] === '' ? $base_pricing['maximum_pax'] : $pricing['maximum_pax'];
1213
1214 }
1215
1216 }
1217 return $multiple_pricing;
1218 }
1219 return array();
1220 }
1221 }
1222
1223 if (!function_exists('yatra_get_tour_base_single_pricing')) {
1224
1225 function yatra_get_tour_base_single_pricing($tourID, $pricing_key = null)
1226 {
1227 $pricing = array();
1228 $pricing['regular_price'] = get_post_meta($tourID, 'yatra_tour_meta_regular_price', true);
1229 $pricing['sales_price'] = get_post_meta($tourID, 'yatra_tour_meta_sales_price', true);
1230 $pricing['pricing_label'] = sanitize_text_field(get_post_meta($tourID, 'yatra_tour_meta_pricing_label', true));
1231 $pricing['pricing_label'] = $pricing['pricing_label'] ? $pricing['pricing_label'] : __('Guest', 'yatra');
1232 $pricing['pricing_description'] = sanitize_text_field(get_post_meta($tourID, 'yatra_tour_meta_pricing_description', true));
1233 $pricing['pricing_per'] = get_post_meta($tourID, 'yatra_tour_meta_price_per', true);
1234 $pricing['group_size'] = get_post_meta($tourID, 'yatra_tour_meta_group_size', true);
1235 $pricing['minimum_pax'] = get_post_meta($tourID, 'yatra_tour_minimum_pax', true);
1236 $pricing['maximum_pax'] = get_post_meta($tourID, 'yatra_tour_maximum_pax', true);
1237 if (!is_null($pricing_key)) {
1238
1239 if (isset($pricing[$pricing_key])) {
1240
1241 return $pricing[$pricing_key];
1242 }
1243 }
1244 return $pricing;
1245 }
1246 }
1247
1248 function yatra_get_current_month_start_and_end_date($year = null, $month = null, $week_start_from = 0)
1249 {
1250 $year = is_null($year) ? date('Y') : $year;
1251
1252 $month = is_null($month) ? date('m') : $month;
1253
1254 $first_day = 1;
1255
1256 $week_start_from = absint($week_start_from);
1257
1258 $month_start = $year . '-' . $month . '-' . $first_day;
1259
1260 $first_day_of_week = absint(date('w', strtotime($month_start)));
1261
1262 $modified_date = new DateTime($month_start);
1263
1264 while ($first_day_of_week !== $week_start_from) {
1265
1266 $modified_date->modify('-1 day');
1267
1268 $first_day_of_week = absint(date('w', strtotime($modified_date->format('Y-m-d'))));
1269
1270 }
1271 $start_date_string = $modified_date->format('Y-m-d');
1272
1273 $modified_date->modify('+41 day');
1274
1275 $end_date_string = $modified_date->format('Y-m-d');
1276
1277 return [
1278 'start' => $start_date_string,
1279 'end' => $end_date_string
1280 ];
1281
1282 }
1283
1284
1285 if (!function_exists('yatra_get_visitor_ip_address')) {
1286
1287 function yatra_get_visitor_ip_address()
1288 {
1289
1290 if (getenv('HTTP_CLIENT_IP')) {
1291 $ip_address = getenv('HTTP_CLIENT_IP');
1292 } else if (getenv('HTTP_X_FORWARDED_FOR')) {
1293 $ip_address = getenv('HTTP_X_FORWARDED_FOR');
1294 } else if (getenv('HTTP_X_FORWARDED')) {
1295 $ip_address = getenv('HTTP_X_FORWARDED');
1296 } else if (getenv('HTTP_FORWARDED_FOR')) {
1297 $ip_address = getenv('HTTP_FORWARDED_FOR');
1298 } else if (getenv('HTTP_FORWARDED')) {
1299 $ip_address = getenv('HTTP_FORWARDED');
1300 } else if (getenv('REMOTE_ADDR')) {
1301 $ip_address = getenv('REMOTE_ADDR');
1302 } else {
1303 $ip_address = 'UNKNOWN';
1304 }
1305 if (apply_filters('yatra_track_visitor_ip_address', true)) {
1306
1307 return $ip_address;
1308 }
1309 return 'TRACKING_DISABLED';
1310 }
1311 }
1312 if (!function_exists('yatra_is_tour_page')) {
1313 function yatra_is_tour_page()
1314 {
1315 if (is_singular('tour')) {
1316 return true;
1317 }
1318 return false;
1319 }
1320 }
1321
1322 if (!function_exists('yatra_is_archive_page')) {
1323
1324 function yatra_is_archive_page()
1325 {
1326 if (is_tax('destination')) {
1327 return true;
1328 }
1329 if (is_tax('activity')) {
1330 return true;
1331 }
1332 if (is_post_type_archive('tour')) {
1333 return true;
1334 }
1335 return false;
1336 }
1337 }
1338
1339 if (!function_exists('yatra_is_search_page')) {
1340
1341 function yatra_is_search_page()
1342 {
1343 global $wp_query;
1344
1345 if (is_post_type_archive('tour') && $wp_query->is_search) {
1346
1347 return true;
1348 }
1349 return false;
1350 }
1351 }
1352 function yatra_get_logger()
1353 {
1354 static $logger = null;
1355
1356 $class = apply_filters('yatra_logging_class', 'Yatra_Logger');
1357
1358 if (null !== $logger && is_string($class) && is_a($logger, $class)) {
1359 return $logger;
1360 }
1361
1362 $implements = class_implements($class);
1363
1364 if (is_array($implements) && in_array('Yatra_Interface_Logger', $implements, true)) {
1365 $logger = is_object($class) ? $class : new $class();
1366 } else {
1367 _doing_it_wrong(
1368 __FUNCTION__,
1369 sprintf(
1370 /* translators: 1: class name 2: yatra_logging_class 3: Yatra_Interface_Logger */
1371 __('The class %1$s provided by %2$s filter must implement %3$s.', 'yatra'),
1372 '<code>' . esc_html(is_object($class) ? get_class($class) : $class) . '</code>',
1373 '<code>yatra_logging_class</code>',
1374 '<code>Yatra_Interface_Logger</code>'
1375 ),
1376 '3.0'
1377 );
1378
1379 $logger = is_a($logger, 'Yatra_Logger') ? $logger : new Yatra_Logger();
1380 }
1381
1382 return $logger;
1383 }
1384
1385 function yatra_enqueue_js($code)
1386 {
1387 global $yatra_queued_js;
1388
1389 if (empty($yatra_queued_js)) {
1390 $yatra_queued_js = '';
1391 }
1392
1393 $yatra_queued_js .= "\n" . $code . "\n";
1394 }
1395
1396 function yatra_print_js()
1397 {
1398 global $yatra_queued_js;
1399
1400 if (!empty($yatra_queued_js)) {
1401 // Sanitize.
1402 $yatra_queued_js = wp_check_invalid_utf8($yatra_queued_js);
1403 $yatra_queued_js = preg_replace('/&#(x)?0*(?(1)27|39);?/i', "'", $yatra_queued_js);
1404 $yatra_queued_js = str_replace("\r", '', $yatra_queued_js);
1405
1406 $js = "<!-- Yatra JavaScript -->\n<script type=\"text/javascript\">\njQuery(function($) { $yatra_queued_js });\n</script>\n";
1407
1408 echo apply_filters('yatra_queued_js', $js); //
1409
1410 unset($yatra_queued_js);
1411 }
1412 }
1413
1414 if (!function_exists('yatra_terms_and_conditions_pass')) {
1415
1416 function yatra_terms_and_conditions_pass($show_terms_option_id)
1417 {
1418 $show_terms_option_id = sanitize_text_field($show_terms_option_id);
1419
1420 $agree_terms = get_option($show_terms_option_id, 'no');
1421
1422 if ($agree_terms === 'yes') {
1423
1424 $agreed_by_user_value = isset($_POST['yatra_agree_to_terms_and_conditions']) ? absint($_POST['yatra_agree_to_terms_and_conditions']) : 0;
1425
1426 if ($agreed_by_user_value === 1) {
1427
1428 return true;
1429 }
1430 return false;
1431 }
1432 return true;
1433 }
1434 }
1435
1436 if (!function_exists('yatra_privacy_policy_pass')) {
1437
1438 function yatra_privacy_policy_pass($show_privacy_policy_option_id)
1439 {
1440 $show_privacy_policy_option_id = sanitize_text_field($show_privacy_policy_option_id);
1441
1442 $agree_privacy = get_option($show_privacy_policy_option_id, 'no');
1443
1444 if ($agree_privacy === 'yes') {
1445
1446 $agreed_by_user_value = isset($_POST['yatra_agree_to_privacy_policy']) ? absint($_POST['yatra_agree_to_privacy_policy']) : 0;
1447
1448 if ($agreed_by_user_value === 1) {
1449
1450 return true;
1451 }
1452 return false;
1453 }
1454 return true;
1455 }
1456 }
1457
1458
1459 if (!function_exists('yatra_is_checkout')) {
1460
1461 function yatra_is_checkout()
1462 {
1463 global $wp_query;
1464
1465 $is_object_set = isset($wp_query->queried_object);
1466 $is_object_id_set = isset($wp_query->queried_object_id);
1467 $is_checkout = is_page(get_option('yatra_checkout_page'));
1468
1469 if (!$is_object_set) {
1470 unset($wp_query->queried_object);
1471 } else if (is_singular()) {
1472 $content = $wp_query->queried_object->post_content;
1473 }
1474
1475 if (!$is_object_id_set) {
1476 unset($wp_query->queried_object_id);
1477 }
1478
1479 // If we know this isn't the primary checkout page, check other methods.
1480 if (!$is_checkout && isset($content) && has_shortcode($content, 'yatra_checkout')) {
1481 $is_checkout = true;
1482 }
1483
1484 return apply_filters('yatra_is_checkout', $is_checkout);
1485 }
1486 }