PluginProbe
Yatra – Travel Booking & Tour Operator Software / 1.0.0
Yatra – Travel Booking & Tour Operator Software v1.0.0
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 1.0.0, at includes/template-tags.php

386 lines 12.1 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 = '')
6 {
7 /* translators: used between list items, there is a space after the comma. */
8 $terms = get_the_term_list($post_id, $taxonomy, '', __(', ', 'yatra'));
9
10 if ($terms) {
11 printf(
12 /* translators: 1: SVG icon. 2: posted in label, only visible to screen readers. 3: list of categories. */
13 '<span class="cat-links"><span class="screen-reader-text">%1$s</span>%2$s</span>',
14 __('Posted in', 'yatra'),
15 $terms
16 ); // WPCS: XSS OK.
17 }
18
19 // /* translators: used between list items, there is a space after the comma. */
20 // $tags_list = get_the_tag_list('', __(', ', 'yatra'));
21 // if ($tags_list) {
22 // printf(
23 // /* translators: 1: SVG icon. 2: posted in label, only visible to screen readers. 3: list of tags. */
24 // '<span class="tags-links">%1$s<span class="screen-reader-text">%2$s </span>%3$s</span>',
25 // yatra_get_icon_svg('tag', 16),
26 // __('Tags:', 'yatra'),
27 // $tags_list
28 // ); // WPCS: XSS OK.
29 // }
30 }
31 }
32
33 if (!function_exists('yatra_entry_header')) {
34
35 function yatra_entry_header()
36 {
37 ?>
38 <header class="entry-header">
39 <?php
40 if (is_sticky() && is_home() && !is_paged()) {
41 printf('<span class="sticky-post">%s</span>', _x('Featured', 'post', 'yatra'));
42 }
43 if (is_singular()) :
44 the_title('<h1 class="entry-title">', '</h1>');
45 else :
46 the_title(sprintf('<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url(get_permalink())), '</a></h2>');
47 endif;
48 ?>
49 <div class="entry-meta">
50 <?php
51 yatra_get_taxonomy_term_lists(get_the_ID(), 'destination');
52 ?></div>
53 </header><!-- .entry-header -->
54 <?php
55 }
56 }
57
58 if (!function_exists('yatra_post_thumbnail')) {
59
60 function yatra_post_thumbnail($size = "post-thumbnail")
61 {
62 ?>
63 <figure class="post-thumbnail">
64 <a class="post-thumbnail-inner" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1">
65 <?php the_post_thumbnail($size); ?>
66 </a>
67 </figure>
68 <?php
69 }
70 }
71
72 if (!function_exists('yatra_entry_post_content')) {
73
74 function yatra_entry_post_content()
75 {
76 ?>
77 <div class="entry-content">
78 <?php
79 the_excerpt();
80 ?>
81 </div><!-- .entry-content -->
82 <?php
83 }
84 }
85
86 if (!function_exists('yatra_entry_footer')) {
87
88 function yatra_entry_footer()
89 {
90 ?>
91 <div class="entry-footer">
92 <?php
93 yatra_posted_by();
94 yatra_posted_on();
95 yatra_get_taxonomy_term_lists(get_the_ID(), 'destination'); ?>
96 </div>
97 <?php
98 }
99 }
100
101 if (!function_exists('yatra_entry_meta_for_frontend_archive')) {
102
103 function yatra_entry_meta_for_frontend_archive()
104 {
105
106 $currency = get_option('yatra_currency');
107
108 $currency_symbol = yatra_get_currency_symbols($currency);
109
110 $meta_frontend = array(
111
112 array(
113 'icon' => 'fa fa-money',
114 'text' => $currency_symbol . '{{yatra_tour_meta_tour_price}}',
115 'title' => __('Price', 'yatra')
116
117 ),
118 array(
119 'icon' => 'fa fa-clock-o',
120 'text' => '{{yatra_tour_meta_tour_duration_days}} days and {{yatra_tour_meta_tour_duration_nights}} nights',
121 'title' => __('Duration', 'yatra')
122
123 ),
124 array(
125 'icon' => 'fa fa-calendar-check-o',
126 'text' => '{{yatra_tour_meta_tour_starts_at}}',
127 'title' => __('Starting location', 'yatra')
128
129 ),
130 array(
131 'icon' => 'fa fa-calendar-check-o',
132 'text' => '{{yatra_tour_meta_tour_ends_at}}',
133 'title' => __('Ending location', 'yatra')
134
135 ),
136 array(
137 'icon' => 'fa fa-users',
138 'text' => '{{yatra_tour_meta_tour_best_season}}',
139 'title' => __('Best sessions', 'yatra')
140
141 )
142 );
143
144 return apply_filters(
145 'yatra_entry_meta_frontend',
146 $meta_frontend
147 );
148
149 }
150 }
151
152
153 if (!function_exists('yatra_entry_meta_for_frontend_single_tab')) {
154
155 function yatra_entry_meta_for_frontend_single_tab($key = '')
156 {
157
158 $post_id = get_the_id();
159
160 if (empty($key)) {
161 return;
162 }
163 $currency = get_option('yatra_currency');
164
165 $country = get_post_meta($post_id, 'yatra_tour_meta_tour_country', true);
166
167 $country_array = array_values(yatra_get_countries($country));
168
169 $country_text = implode(',', $country_array);
170
171 $currency_symbol = yatra_get_currency_symbols($currency);
172
173 $meta_frontend_for_tabs = array(
174
175 'overview' => array(
176 array(
177 'icon' => 'fa fa-money',
178 'text' => $currency_symbol . '{{yatra_tour_meta_tour_price}}',
179 'title' => __('Tour Price', 'yatra')
180 ),
181 array(
182 'icon' => 'fa fa-money',
183 'text' => $country_text,
184 'title' => __('Country', 'yatra')
185 ),
186 array(
187 'icon' => 'fa fa-money',
188 'text' => '{{yatra_tour_meta_tour_max_altitude}}',
189 'title' => __('Max altitude', 'yatra')
190 ),
191 array(
192 'icon' => 'fa fa-clock-o',
193 'text' => 'Duration: {{yatra_tour_meta_tour_duration_days}} days and {{yatra_tour_meta_tour_duration_nights}} nights',
194 'title' => 'Trip Code'
195 ),
196 array(
197 'icon' => 'fa fa-calendar-check-o',
198 'text' => '{{yatra_tour_meta_tour_starts_at}}',
199 'title' => __('Starts at', 'yatra')
200 ),
201 array(
202 'icon' => 'fa fa-calendar-check-o',
203 'text' => '{{yatra_tour_meta_tour_ends_at}}',
204 'title' => __('Ends at', 'yatra')
205 ),
206 array(
207 'icon' => 'fa fa-users',
208 'text' => '{{yatra_tour_meta_tour_best_season}}',
209 'title' => __('Best sessions', 'yatra')
210 ), array(
211 'icon' => 'fa fa-users',
212 'text' => '{{yatra_tour_meta_tour_route}}',
213 'title' => __('Tour Route', 'yatra')
214 )
215 ), 'itinerary' => array(
216 array(
217 'icon' => 'fa fa-users',
218 'text' => '{{yatra_itineray_detail}}',
219 'title' => __('Tour Route', 'yatra')
220 )
221 ), 'cost_info' => array(
222 array(
223 'icon' => 'fa fa-users',
224 'text' => '{{yatra_cost_included}}',
225 'title' => __('Cost Included', 'yatra'),
226 'id' => 'cost_included'
227 ), array(
228 'icon' => 'fa fa-users',
229 'text' => '{{yatra_cost_excluded}}',
230 'title' => __('Cost Excluded', 'yatra'),
231 'id' => 'cost_excluded'
232 )
233 ), 'tour_facts' => array(
234 array(
235 'icon' => 'fa fa-users',
236 'text' => '{{yatra_facts_detail}}',
237 'title' => __('Tour Route', 'yatra')
238 )
239 )
240 );
241
242 if (!isset($meta_frontend_for_tabs[$key])) {
243
244 return;
245 }
246 $meta_frontend_for_tabs = apply_filters(
247
248 'yatra_entry_meta_frontend_single_tab',
249
250 $meta_frontend_for_tabs
251 );
252
253 $meta_frontend = $meta_frontend_for_tabs[$key];
254
255 $list = array();
256
257 foreach ($meta_frontend as $value) {
258
259 $icon = isset($value['icon']) ? $value['icon'] : '';
260
261 $text = isset($value['text']) ? $value['text'] : '';
262
263 $title = isset($value['title']) ? $value['title'] : '';
264
265 preg_match_all("~\{\{\s*(.*?)\s*\}\}~", $text, $matches);
266
267 $matches = isset($matches[1]) ? $matches[1] : array();
268
269 foreach ($matches as $match) {
270
271 $text_id = sanitize_text_field($match);
272
273 $text_option = get_post_meta($post_id, $text_id, true);
274
275 $text = str_replace('{{' . $match . '}}', $text_option, $text);
276 }
277
278 $list_array =
279
280 array(
281 'icon' => $icon,
282 'text' => $text,
283 'title' => $title,
284 'id' => isset($value['id']) ? $value['id'] : ''
285 );
286 $list[] = $list_array;
287 }
288
289 return $list;
290 }
291 }
292
293
294 if (!function_exists('yatra_entry_meta_attributes')) {
295
296 function yatra_entry_meta_attributes()
297 {
298 $post_id = get_the_id();
299
300 $meta_frontend = yatra_entry_meta_for_frontend_archive();
301
302 $list = '';
303
304 foreach ($meta_frontend as $value) {
305
306 $icon = isset($value['icon']) ? $value['icon'] : '';
307
308 $text = isset($value['text']) ? $value['text'] : '';
309
310 $title = isset($value['title']) ? $value['title'] : '';
311
312 preg_match_all("~\{\{\s*(.*?)\s*\}\}~", $text, $matches);
313
314 $matches = isset($matches[1]) ? $matches[1] : array();
315
316 foreach ($matches as $match) {
317
318 $text_id = sanitize_text_field($match);
319
320 $text_option = get_post_meta($post_id, $text_id, true);
321
322 $text = str_replace('{{' . $match . '}}', $text_option, $text);
323 }
324
325 $list .= '<li><i class="' . esc_attr($icon) . '"></i>&nbsp;<strong>' . esc_html($title) . ': </strong>' . esc_html($text) . '</li>';
326 }
327
328 echo '<ul>';
329
330 echo $list;
331
332 echo '</ul>';
333
334 }
335 }
336
337 if (!function_exists('yatra_frontend_tabs_config')) {
338
339 function yatra_frontend_tabs_config()
340 {
341 $frontend_tabs_config = array(
342
343 'overview' => __('Overview', 'yatra'),
344 'itinerary' => __('Itinerary', 'yatra'),
345 'cost_info' => __('Cost Info', 'yatra'),
346 'tour_facts' => __('Tour Facts', 'yatra'),
347 );
348 return apply_filters('frontend_tabs_configurations', $frontend_tabs_config);
349 }
350 }
351
352
353 if (!function_exists('yatra_frontend_tabs')) {
354
355 function yatra_frontend_tabs()
356 {
357
358 $frontend_tabs_config = yatra_frontend_tabs_config();
359
360 ?>
361 <div class="yatra-tabs">
362
363 <ul>
364 <?php foreach ($frontend_tabs_config as $tab_key => $tab) { ?>
365 <li><a href="#<?php echo esc_attr($tab_key); ?>"><?php echo esc_html($tab); ?></a></li>
366 <?php } ?>
367 </ul>
368 <?php
369 $loop_index = 0;
370 foreach ($frontend_tabs_config as $tab_content_key => $tab_content) { ?>
371 <section id="<?php echo esc_attr($tab_content_key); ?>"
372 class="yatra-tab-content" <?php if ($loop_index > 0) { ?> aria-hidden="true" <?php } ?>>
373 <div class="tab-inner">
374 <?php
375 do_action('yatra_frontend_tab_content_' . $tab_content_key, $tab_content)
376 ?>
377 </div>
378 </section>
379 <?php
380 $loop_index++;
381 } ?>
382
383 </div>
384 <?php
385 }
386 }