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 / functions.php

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

371 lines 10.6 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/helpers/yatra-country-helper.php';
7 include_once YATRA_ABSPATH . 'includes/helpers/yatra-currency-helper.php';
8 include_once YATRA_ABSPATH . 'includes/template-tags.php';
9
10
11 if (!function_exists('yatra_tour_tabs')) {
12 function yatra_tour_tabs()
13 {
14 $tour_tabs_array = array(
15 'overview' => array(
16 'title' => __('Overview', 'yatra'),
17 'icon' => '',
18 ),
19 'itinerary' => array(
20 'title' => __('Itinerary', 'yatra'),
21 'icon' => '',
22 ),
23 'cost_info' => array(
24 'title' => __('Cost Info', 'yatra'),
25 'icon' => '',
26 ),
27 'facts' => array(
28 'title' => __('Facts', 'yatra'),
29 'icon' => '',
30 ),
31 'faq' => array(
32 'title' => __('FAQ', 'yatra'),
33 'icon' => '',
34 ),
35 );
36
37 return apply_filters('yatra_tour_tabs', $tour_tabs_array);
38 }
39 }
40
41 if (!function_exists('yatra_tour_metabox_tabs')) {
42 function yatra_tour_metabox_tabs()
43 {
44 $metabox_tabs = array(
45
46 'tour-overview' => __('Overview', 'yatra'),
47 'tour-itinerary' => __('Itinerary', 'yatra'),
48 'tour-cost' => __('Cost Info', 'yatra'),
49 'tour-facts' => __('Tour Facts', 'yatra'),
50 );
51
52 return apply_filters('yatra_tour_metabox_tabs', $metabox_tabs);
53 }
54 }
55
56
57 if (!function_exists('yatra_set_session')) {
58
59 function yatra_set_session($key = '', $value = '')
60 {
61 if (!session_id()) {
62 session_start();
63 }
64
65 $yatra_session_id = "yatra_session";
66
67 if (!empty($key) && !empty($value)) {
68
69 $_SESSION[$yatra_session_id][$key] = $value;
70
71 return true;
72 }
73 return false;
74
75 }
76 }
77
78 if (!function_exists('yatra_get_session')) {
79
80 function yatra_get_session($key = '')
81 {
82
83 $yatra_session_id = "yatra_session";
84
85 if (!empty($key)) {
86
87 if (isset($_SESSION[$yatra_session_id][$key])) {
88
89 return $_SESSION[$yatra_session_id][$key];
90 }
91
92 }
93 if (isset($_SESSION[$yatra_session_id])) {
94
95 return $_SESSION[$yatra_session_id];
96 }
97
98 return array();
99
100 }
101 }
102
103 if (!function_exists('yatra_clear_session')) {
104
105 function yatra_clear_session($key = '')
106 {
107 if (!session_id()) {
108 session_start();
109 }
110
111 $yatra_session_id = "yatra_session";
112
113 if (!empty($key)) {
114
115 if (isset($_SESSION[$yatra_session_id][$key])) {
116
117 unset($_SESSION[$yatra_session_id][$key]);
118
119 return true;
120 }
121
122 }
123 if (isset($_SESSION[$yatra_session_id])) {
124
125 unset($_SESSION[$yatra_session_id]);
126
127 return true;
128 }
129
130 return false;
131
132 }
133 }
134
135 if (!function_exists('yatra_get_template')) {
136
137 function yatra_get_template($template_name, $args = array(), $template_path = '', $default_path = '')
138 {
139 $cache_key = sanitize_key(implode('-', array('template', $template_name, $template_path, $default_path)));
140 $template = (string)wp_cache_get($cache_key, 'yatra');
141
142 if (!$template) {
143 $template = yatra_locate_template($template_name, $template_path, $default_path);
144 wp_cache_set($cache_key, $template, 'yatra');
145 }
146 // Allow 3rd party plugin filter template file from their plugin.
147 $filter_template = apply_filters('yatra_get_template', $template, $template_name, $args, $template_path, $default_path);
148
149 if ($filter_template !== $template) {
150 if (!file_exists($filter_template)) {
151 /* translators: %s template */
152 _doing_it_wrong(__FUNCTION__, sprintf(__('%s does not exist.', 'yatra'), '<code>' . $template . '</code>'), '1.0.1');
153 return;
154 }
155 $template = $filter_template;
156 }
157
158 $action_args = array(
159 'template_name' => $template_name,
160 'template_path' => $template_path,
161 'located' => $template,
162 'args' => $args,
163 );
164
165 if (!empty($args) && is_array($args)) {
166 if (isset($args['action_args'])) {
167 _doing_it_wrong(
168 __FUNCTION__,
169 __('action_args should not be overwritten when calling yatra_get_template.', 'yatra'),
170 '1.0.0'
171 );
172 unset($args['action_args']);
173 }
174 extract($args); // @codingStandardsIgnoreLine
175 }
176
177 do_action('yatra_before_template_part', $action_args['template_name'], $action_args['template_path'], $action_args['located'], $action_args['args']);
178
179 include $action_args['located'];
180
181 do_action('yatra_after_template_part', $action_args['template_name'], $action_args['template_path'], $action_args['located'], $action_args['args']);
182 }
183 }
184
185 if (!function_exists('yatra_locate_template')) {
186 function yatra_locate_template($template_name, $template_path = '', $default_path = '')
187 {
188 if (!$template_path) {
189 $template_path = yatra_instance()->template_path();
190 }
191
192 if (!$default_path) {
193 $default_path = yatra_instance()->plugin_template_path();
194 }
195
196 // Look within passed path within the theme - this is priority.
197 $template = locate_template(
198 array(
199 trailingslashit($template_path) . $template_name,
200 $template_name,
201 )
202 );
203
204 // Get default template/.
205 if (!$template) {
206 $template = $default_path . $template_name;
207 }
208 // Return what we found.
209 return apply_filters('yatra_locate_template', $template, $template_name, $template_path);
210 }
211 }
212
213 if (!function_exists('yatra_single_tour_tabs')) {
214
215 function yatra_single_tour_tabs()
216 {
217 global $post;
218
219
220 }
221 }
222
223 if (!function_exists('yatra_get_checkout_page')) {
224
225 function yatra_get_checkout_page($get_permalink = false)
226 {
227
228 $page_id = absint(get_option('yatra_checkout_page'));
229
230 if ($page_id < 1) {
231
232 global $wpdb;
233
234 $page_id = $wpdb->get_var('SELECT ID FROM ' . $wpdb->prefix . 'posts WHERE post_content LIKE "%[yatra_checkout]%" AND post_parent = 0');
235 }
236
237 $page_permalink = get_permalink($page_id);
238
239 if ($get_permalink) {
240
241 return $page_permalink;
242 }
243
244 return $page_id;
245
246
247 }
248 }
249
250 if (!function_exists('yatra_get_booking_statuses')) {
251
252 function yatra_get_booking_statuses()
253 {
254 return apply_filters(
255 'yatra_booking_statuses', array(
256 'yatra-pending' => __('Pending', 'yatra' ),
257 'yatra-processing' => __('Processing', 'yatra' ),
258 'yatra-on-hold' => __('On Hold', 'yatra' ),
259 'yatra-completed' => __('Completed', 'yatra' ),
260 'yatra-cancelled' => __('Cancelled', 'yatra' )
261 )
262 );
263
264 }
265 }
266
267 if (!function_exists('yatra_the_posts_navigation')) :
268 /**
269 * Documentation for function.
270 */
271 function yatra_the_posts_navigation()
272 {
273 the_post_navigation(array(
274 'prev_text' => '<span class="screen-reader-text">' . esc_html__('Previous Post', 'yatra') . '</span><span class="nav-title">%title</span>',
275 'next_text' => '<span class="screen-reader-text">' . esc_html__('Next Post', 'yatra') . '</span><span class="nav-title">%title</span>',
276 ));
277 }
278 endif;
279
280 if (!function_exists('yatra_get_template_part')) {
281
282 function yatra_get_template_part($slug, $name = '')
283 {
284 $path = "{$slug}.php";
285
286 if ('' !== $name) {
287
288 $path = "{$slug}-{$name}.php";
289 }
290 $template = yatra_locate_template($path, false, false);
291
292 require $template;
293
294 }
295
296 }
297 if (!function_exists('yatra_posted_by')) :
298 /**
299 * Prints HTML with meta information about theme author.
300 */
301 function yatra_posted_by()
302 {
303 printf(
304 /* translators: 1: SVG icon. 2: post author, only visible to screen readers. 3: author link. */
305 '<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>',
306 __('Posted by', 'yatra'),
307 esc_url(get_author_posts_url(get_the_author_meta('ID'))),
308 esc_html(get_the_author())
309 );
310 }
311 endif;
312
313 if (!function_exists('yatra_posted_on')) :
314 /**
315 * Prints HTML with meta information for the current post-date/time.
316 */
317 function yatra_posted_on()
318 {
319 $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
320 if (get_the_time('U') !== get_the_modified_time('U')) {
321 $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
322 }
323
324 $time_string = sprintf(
325 $time_string,
326 esc_attr(get_the_date(DATE_W3C)),
327 esc_html(get_the_date()),
328 esc_attr(get_the_modified_date(DATE_W3C)),
329 esc_html(get_the_modified_date())
330 );
331
332 printf(
333 '<span class="posted-on"><a href="%1$s" rel="bookmark">%2$s</a></span>',
334 esc_url(get_permalink()),
335 $time_string
336 );
337 }
338 endif;
339
340 if (!function_exists('yatra_entry_meta')) {
341
342 function yatra_entry_meta()
343 {
344 ?>
345 <div class="entry-meta">
346 <?php yatra_posted_by(); ?>
347 <?php yatra_posted_on(); ?>
348 <?php
349 // Edit post link.
350 edit_post_link(
351 sprintf(
352 wp_kses(
353 /* translators: %s: Name of current post. Only visible to screen readers. */
354 __('Edit <span class="screen-reader-text">%s</span>', 'yatra'),
355 array(
356 'span' => array(
357 'class' => array(),
358 ),
359 )
360 ),
361 get_the_title()
362 ),
363 '<span class="edit-link">',
364 '</span>'
365 );
366 ?>
367 </div><!-- .meta-info -->
368 <?php
369 }
370
371 }