PluginProbe
Themify Builder / trunk
Themify Builder vtrunk
7.8.1 7.8.0 7.7.9 7.7.8 7.7.7 7.7.6 7.7.5 7.7.4 7.7.3 7.7.2 trunk 7.6.0 7.6.1 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.8 7.6.9 7.7.0 7.7.1
themify-builder / themify / themify-template-tags.php

themify-template-tags.php in Themify Builder trunk, at themify/themify-template-tags.php

2,163 lines 82.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Custom template tags used in template files
4 *
5 * @package Themify
6 */
7 if (!function_exists('themify_logo_image')) :
8
9 /**
10 * Returns logo image.
11 * Available filters:
12 * 'themify_'.$location.'_logo_tag': filter the HTML tag used to wrap the text or image.
13 * 'themify_logo_home_url': filter the home URL linked.
14 * 'themify_'.$location.'_logo_html': filter the final HTML output to page.
15 * @param string $location Logo location used as key to get theme setting values
16 * @param string $cssid ID attribute for the logo tag.
17 * @return string logo markup
18 */
19 function themify_logo_image(string $location = 'site_logo',string $cssid = 'site-logo'):string {
20 global $themify_customizer;
21 if ($location === 'site_logo') {
22 Themify_Enqueue_Assets::loadThemeStyleModule('site-logo');
23 }
24 $logo_tag = tag_escape( apply_filters('themify_' . $location . '_logo_tag', 'div') );
25 $logo_is_image = themify_get('setting-' . $location, false, true) === 'image' && themify_check('setting-' . $location . '_image_value', true);
26 $logo_mod = $logo_is_image === true ? get_theme_mod($cssid . '_image') : false;
27
28 $html = '<' . $logo_tag . ' id="' . esc_attr($cssid) . '">';
29 $type = '';
30 if ($logo_is_image === true && empty($logo_mod)) {
31 $site_name = esc_html(get_bloginfo('name'));
32 $html .= '<a href="' . esc_url(apply_filters('themify_logo_home_url', themify_home_url())) . '" title="' . esc_attr($site_name) . '">';
33
34 $html .= themify_get_image(
35 array(
36 'src' => themify_get('setting-' . $location . '_image_value', '', true),
37 'preload' => Themify_Enqueue_Assets::$isFooter === false,
38 'w' => themify_get('setting-' . $location . '_width', '', true),
39 'h' => themify_get('setting-' . $location . '_height', '', true),
40 'alt' => $site_name,
41 'lazy_load' => Themify_Enqueue_Assets::$isFooter === false,
42 'attr' => Themify_Enqueue_Assets::$isFooter === false ? array('fetchpriority' => 'high') : null,
43 'class' => 'site-logo-image'
44 ));
45 $html .= is_customize_preview() ? '<span style="display: none;">' . $site_name . '</span>' : '';
46
47 $html .= '</a>';
48 } else {
49 $type = 'customizer';
50 $html .= $themify_customizer->site_logo($cssid);
51 }
52
53 $html .= '</' . $logo_tag . '>';
54
55 return apply_filters('themify_' . $location . '_logo_html', $html, $location, $logo_tag, $type);
56 }
57
58 endif;
59
60 if (!function_exists('themify_site_description')) :
61
62 /**
63 * Returns site description markup.
64 *
65 * @since 1.3.2
66 *
67 * @return string
68 */
69 function themify_site_description() {
70 global $themify_customizer;
71 $output = $themify_customizer->site_description();
72 if ( ! empty( $output ) ) {
73 Themify_Enqueue_Assets::loadThemeStyleModule('site-description');
74 $output = '<div id="site-description" class="site-description">' . $output . '</div>';
75 }
76
77 /**
78 * Filters description markup before it's returned.
79 *
80 * @param string $output
81 */
82 return apply_filters('themify_site_description', $output);
83 }
84
85 endif;
86
87 if (!function_exists('themify_zoom_icon')) :
88
89 /**
90 * Returns zoom icon markup for lightboxed featured image
91 *
92 * @param bool $echo
93 *
94 * @return mixed|void
95 */
96 function themify_zoom_icon(bool $echo = true) {
97 $zoom = apply_filters('themify_zoom_icon', themify_check('lightbox_icon') ? '<span class="zoom">' . themify_get_icon('search', 'ti', false, false, array('aria-label' => __('Zoom', 'themify'))) . '</span>' : '');
98 if ($echo !== true) {
99 return $zoom;
100 }
101 echo $zoom;
102 }
103
104 endif;
105
106 if (!function_exists('themify_register_grouped_widgets')) :
107
108 /**
109 * Registers footer sidebars.
110 *
111 * @param array $columns Sets of sidebars that can be created.
112 * @param array $widget_attr General markup for widgets.
113 * @param string $widgets_key
114 * @param string $default_set
115 */
116 function themify_register_grouped_widgets($columns = array(), $widget_attr = array(), $widgets_key = 'setting-footer_widgets', $default_set = 'footerwidget-3col') {
117 if (empty($columns)) {
118 $columns = array(
119 'footerwidget-4col' => 4,
120 'footerwidget-3col' => 3,
121 'footerwidget-2col' => 2,
122 'footerwidget-1col' => 1,
123 'none' => 0
124 );
125 }
126 $option = themify_get($widgets_key, $default_set, true);
127 if (isset($columns[$option])) {
128 if (empty($widget_attr)) {
129 $widget_attr = array(
130 'sidebar_name' => __('Footer Widget', 'themify'),
131 'sidebar_id' => 'footer-widget',
132 'before_widget' => '<div id="%1$s" class="widget %2$s">',
133 'after_widget' => '</div>',
134 'before_title' => '<h4 class="widgettitle">',
135 'after_title' => '</h4>',
136 );
137 }
138 for ($x = 1; $x <= $columns[$option]; ++$x) {
139 register_sidebar(array(
140 'name' => $widget_attr['sidebar_name'] . ' ' . $x,
141 'id' => $widget_attr['sidebar_id'] . '-' . $x,
142 'before_widget' => $widget_attr['before_widget'],
143 'after_widget' => $widget_attr['after_widget'],
144 'before_title' => $widget_attr['before_title'],
145 'after_title' => $widget_attr['after_title']
146 ));
147 }
148 }
149 }
150
151 endif;
152
153 if (!function_exists('themify_the_footer_text')) :
154
155 /**
156 * Outputs footer text
157 *
158 * @param string $area Footer text area
159 * @param bool $wrap Class to add to block
160 * @param string $block The block of text this is
161 * @param string $date_fmt Date format for year shown
162 * @param bool $echo Whether to echo or return the markup
163 *
164 * @return mixed|string|void
165 * @internal param string $key The footer text to show. Default: left
166 */
167 function themify_the_footer_text($area = 'left', $wrap = true, $block = '', $date_fmt = 'Y', $echo = true) {
168 if (themify_check('setting-footer_text_' . $area . '_hide', true)) {
169 return;
170 }
171 // Prepare variables
172 if ('' == $block) {
173 if ('left' === $area) {
174 $block = 'one';
175 } elseif ('right' === $area) {
176 $block = 'two';
177 }
178 }
179 $text_block = '';
180 if ('one' === $block) {
181 $text_block = '&copy; <a href="' . esc_url(home_url()) . '">' . esc_html(get_bloginfo('name')) . '</a> ' . date($date_fmt);
182 } elseif ('two' === $block) {
183 $text_block = __('Powered by <a href="http://wordpress.org">WordPress</a> &bull; <a href="https://themify.me">Themify WordPress Themes</a>', 'themify');
184 }
185 $key = 'setting-footer_text_' . $area;
186 $text = themify_get($key, '', true);
187 // Get definitive text to display, parse through WPML if available
188 if ('' != $text) {
189 if (function_exists('icl_t')) {
190 $text = icl_t('Themify', $key, $text);
191 }
192 } else {
193 $text = $text_block;
194 }
195 // Start markup
196 $html = apply_filters('themify_footer_text' . $block, $text);
197 if (true === $wrap) {
198 $html = '<div class="' . esc_attr($block) . '">' . $html . '</div>';
199 } elseif (!is_bool($wrap)) {
200 $html = '<div class="' . esc_attr($wrap) . '">' . $html . '</div>';
201 }
202 $html = apply_filters('themify_the_footer_text_' . $area, $html);
203
204 $html = str_replace('%year%', wp_date('Y'), $html);
205
206 if ($echo)
207 echo $html;
208 return $html;
209 }
210
211 endif;
212
213 if (!function_exists('themify_get_author_link')) :
214
215 /**
216 * Builds the markup for the entry author with microdata information.
217 * @return string
218 * @since 1.7.4
219 */
220 function themify_get_author_link():string {
221 return '<span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '" rel="author">' . get_the_author() . '</a></span>';
222 }
223
224 endif;
225
226 if (!function_exists('themify_pagenav')) :
227
228 /**
229 * Echoes Pagination
230 *
231 * @param string $before
232 * @param string $after
233 * @param bool $query
234 */
235 function themify_pagenav($before = '', $after = '', $query = false) {
236 echo themify_get_pagenav($before, $after, $query);
237 }
238
239 endif;
240
241 if (!function_exists('themify_get_pagenav')) {
242
243 /**
244 * Returns Pagination
245 * @param string $before Markup to show before pagination links
246 * @param string $after Markup to show after pagination links
247 * @param object $query WordPress query object to use
248 * @param original_offset number of posts configured to skip over
249 * @return string
250 * @since 1.2.4
251 */
252 function themify_get_pagenav($args = '',?string $after = '', $query = false,int $max_page = 0,int $paged = 0):string {
253 /* old syntax, first parameter is string $before */
254 $before = is_array($args) ? '' : $args;
255
256 $args = wp_parse_args($args, [
257 'before' => $before,
258 'after' => $after,
259 'query' => $query,
260 'max_page' => $max_page,
261 'paged' => $paged,
262 'container_class' => '',
263 ]);
264
265 $key = false;
266 if ($args['max_page'] === 0) {
267 if (empty($args['query'])) {
268 global $wp_query;
269 $args['query'] = $wp_query;
270 }
271 $args['max_page'] = (int) $args['query']->max_num_pages;
272 } elseif (!empty($args['query']) && is_string($args['query'])) {
273 $key = $args['query'];
274 }
275 if ($args['max_page'] > 1) {
276 $request_url=$_SERVER['REQUEST_URI'];
277 if($key!==false){
278 $result=[];
279 parse_str($key,$result);
280 $request_url= remove_query_arg(array_keys($result),$request_url);
281 unset($result);
282 }
283 if ($args['paged'] === 0) {
284 $args['paged'] = get_query_var('paged', 1);
285 if (empty($args['paged'])) {
286 $args['paged'] = get_query_var('page', 1);
287 }
288 }
289 $args['paged'] = (int) $args['paged'];
290 $args['paged'] = $args['paged'] < 1 ? 1 : $args['paged'];
291 $pages_to_show = apply_filters('themify_filter_pages_to_show', 4);
292 $pages_to_show_minus_1 = $pages_to_show - 1;
293 $half_page_start = floor($pages_to_show_minus_1 / 2);
294 $half_page_end = ceil($pages_to_show_minus_1 / 2);
295 $start_page = (int) ($args['paged'] - $half_page_start);
296 if ($start_page <= 0) {
297 $start_page = 1;
298 }
299 $end_page = (int) ($args['paged'] + $half_page_end);
300 if (($end_page - $start_page) !== $pages_to_show_minus_1) {
301 $end_page = (int) ($start_page + $pages_to_show_minus_1);
302 }
303 if ($end_page > $args['max_page']) {
304 $start_page = (int) ($args['max_page'] - $pages_to_show_minus_1);
305 $end_page = (int) $args['max_page'];
306 }
307 $prefetch = '';
308 if (Themify_Enqueue_Assets::$themeVersion !== null) {
309 Themify_Enqueue_Assets::loadThemeStyleModule('pagenav');
310 }
311 $out = $args['before'] . '<div class="pagenav tf_clear tf_box tf_textr tf_clearfix ' . $args['container_class'] . '">';
312 if ($start_page <= 0) {
313 $start_page = 1;
314 } elseif ($start_page >= 2 && $pages_to_show < $args['max_page']) {
315 $first_page_text = '&laquo;';
316 $link = $key !== false ? add_query_arg(array($key => 1),$request_url) : get_pagenum_link();
317 $out .= '<a href="' . $link . '" title="' . $first_page_text . '" class="number firstp">&laquo;</a>';
318 }
319 if ($args['paged'] > 1 && $pages_to_show < $args['max_page']) {
320
321 $link = $key !== false ? add_query_arg(array($key => ($args['paged'] - 1)),$request_url) : get_pagenum_link($args['paged'] - 1);
322 $prefetch = '<link rel="prefetch" as="document" href="' . esc_url( $link ) . '"/>';
323 $attr = apply_filters('previous_posts_link_attributes', '');
324 $out .= '<a href="' . esc_url( $link ) . '" ' . $attr . ' class="number prevp">&lsaquo;</a>';
325 }
326
327 for ($i = $start_page; $i <= $end_page; ++$i) {
328 if ($i === $args['paged']) {
329 $out .= ' <span class="number current">' . $i . '</span>';
330 } else {
331 $link = $key !== false ? add_query_arg(array($key => $i),$request_url) : get_pagenum_link($i);
332 $out .= ' <a href="' . esc_url( $link ) . '" class="number">' . $i . '</a>';
333 }
334 }
335 if (($args['paged'] + 1) < $args['max_page'] && $pages_to_show < $args['max_page']) {
336 $link = $key !== false ? add_query_arg(array($key => ($args['paged'] + 1),$request_url)) : get_pagenum_link($args['paged'] + 1);
337 $prefetch .= '<link rel="prefetch" as="document" href="' . $link . '"/>';
338 $attr = apply_filters('next_posts_link_attributes', '');
339 $out .= '<a href="' . esc_url( $link ) . '" ' . $attr . ' class="number nextp">&rsaquo;</a>';
340 }
341 if ($end_page < $args['max_page']) {
342 $last_page_text = '&raquo;';
343 $link = $key !== false ? add_query_arg(array($key => $args['max_page']),$request_url) : get_pagenum_link($args['max_page']);
344 $out .= '<a href="' . esc_url( $link ) . '" title="' . $last_page_text . '" class="number lastp">&raquo;</a>';
345 }
346 $out .= '</div>' . $args['after'];
347 return $prefetch . $out;
348 }
349 return '';
350 }
351
352 }
353
354 if (!function_exists('themify_has_post_video')) {
355
356 /**
357 * Check if current post has featured video
358 * Must be used inside the loop
359 *
360 * @since 2.7.3
361 */
362 function themify_has_post_video():bool {
363 return themify_check('video_url');
364 }
365
366 }
367
368 if (!function_exists('themify_area_design')) {
369
370 /**
371 * Checks the area design setting and returns 'none' or a design option.
372 *
373 * @since 2.1.3
374 *
375 * @param string $key Main prefix for setting and field.
376 * @param array $args
377 *
378 * @return mixed
379 */
380 function themify_area_design(string $key = 'header',array $args = array()) {
381 if (!isset($args['setting'])) {
382 $args['setting'] = 'setting-' . $key . '_design';
383 }
384 if (!isset($args['field']) && !( is_singular() || themify_is_shop() )) {
385 $args['field'] = $args['setting'];
386 }
387 if (!isset($args['field'])) {
388 $args['field'] = $key . '_design';
389 }
390 if (!isset($args['default'])) {
391 $args['default'] = $key . '-horizontal';
392 }
393 if (!isset($args['values'])) {
394 $args['values'] = array('header-horizontal', 'header-block', 'none');
395 }
396 $design = themify_get_both($args['field'], $args['setting'], $args['default']);
397 if ($design !== 'default' && !in_array($design, $args['values'], true)) {
398 $design = 'default';
399 }
400 return $design;
401 }
402
403 }
404
405 /**
406 * Returns current active theme skin name, false if no skin is active
407 *
408 * @return string|bool
409 */
410 function themify_get_skin() {
411 static $skin = null;
412
413 if ($skin === null) {
414 $value = themify_get('skin', 'default', true);
415 /* backward compatibility, "skin" used to be saved as a URL */
416 if (filter_var($value, FILTER_VALIDATE_URL)) {
417 $parsed_skin = parse_url($value, PHP_URL_PATH);
418 if ( $parsed_skin !== null ) {
419 $value = basename(dirname($parsed_skin));
420 }
421 }
422
423 if ('default' !== $value && is_file(get_template_directory() . "/skins/{$value}/style.css")) {
424 $skin = $value;
425 } else {
426 $skin = false;
427 }
428 }
429
430 return $skin;
431 }
432
433 /**
434 * Enqueues the chosen skin, if there was one selected and custom_style.css if it exists
435 * 1. themify-skin
436 * 2. custom-style
437 * 3. fontawesome - added 1.7.8
438 * @since 1.7.4
439 */
440 function themify_enqueue_framework_assets() {
441 // Skin stylesheet
442 do_action('themify_before_skin_css');
443 if ($skin = themify_get_skin()) {
444 $url = THEME_URI . '/skins/' . $skin;
445 $dir = THEME_DIR . '/skins/' . $skin;
446 themify_enque_style('themify-skin', $url . '/style.css', null, THEMIFY_VERSION);
447 if (is_file($dir . '/media//mobile-menu.css')) {
448 Themify_Enqueue_Assets::addMobileMenuCss('mobile-menu-' . $skin, $url . '/media/mobile-menu.css');
449 }
450 if (is_rtl() && is_file($dir . '/rtl.min.css')) {
451 themify_enque_style('themify-skin-rtl', $url . '/rtl.min.css', null, THEMIFY_VERSION);
452 }
453 }
454 do_action('themify_after_skin_css');
455 }
456
457 if (!function_exists('themify_get_term_description')) {
458
459 /**
460 * Returns term description
461 * @return string
462 * @since 1.5.6
463 */
464 function themify_get_term_description():string {
465 $term_description = term_description();
466 $output = !empty($term_description) ? '<div class="category-description">' . $term_description . '</div>' : '';
467 return apply_filters('themify_get_term_description', $output);
468 }
469
470 }
471
472 if (!function_exists('themify_permalink_attr')) {
473
474 /**
475 * Returns escaped URL for post
476 * @return string
477 * @since 1.3.5
478 */
479 function themify_permalink_attr($args = array(), $echo = true) {
480 global $themify;
481 $cl = '';
482 $rel = '';
483 $isLightbox = false;
484 if (!is_array($args)) {
485 $args = array();
486 }
487 if (isset($_GET['post_in_lightbox'])) {
488 $link = get_permalink();
489 } else {
490 $link = themify_get('external_link', '');
491 if ($link === '') {
492 $isIframe = false;
493 if (isset($args['use_video_link']) && $args['use_video_link'] === true) {
494 $link = themify_get('video_url', '');
495 }
496 if ($link === '') {
497 $link = themify_get('lightbox_link', '');
498 if ($link === '') {
499 $link = themify_get('link_url', '');
500 if ($link === '' && (!isset($args['no_permalink']) || $args['no_permalink'] === false)) {
501 $link = get_permalink();
502 }
503 $isLightbox = ( isset($args['is_lightbox']) && $args['is_lightbox'] === true )
504 || $themify->lightboxed_permalink === true
505 || (!is_single() && themify_check('setting-open_inline', true) );
506 } else {
507 $isLightbox = true;
508 $cl = 'themify_lightbox';
509 }
510 } else {
511 $isLightbox = $isIframe = true;
512 }
513 if ($isLightbox === true && (!isset($args['disable_lightbox']) || $args['disable_lightbox'] === false) && $cl !== 'themify_lightbox') {
514 $queryArgs = array('post_in_lightbox' => 1);
515 $cl = 'themify_lightbox';
516 if ($isIframe === true || themify_check('iframe_url')) {
517 $queryArgs['iframe'] = 1;
518 }
519 $link = add_query_arg($queryArgs, $link);
520 }
521 } elseif (!isset($args['new_tab']) || $args['new_tab'] === true) {
522 $rel = true;
523 }
524 }
525 $link = apply_filters('themify_get_permalink', $link);
526 if (!empty($args['link_class']) && $args['link_class'] !== $cl) {
527 if ($isLightbox === false) {
528 $args['link_class'] = str_replace('themify_lightbox', '', $args['link_class']);
529 }
530 if ($cl !== '' && stripos($args['link_class'], $cl) !== false) {
531 $cl = $args['link_class'];
532 } else {
533 $cl .= ' ' . $args['link_class'];
534 }
535 }
536 $rel = $rel === true && $isLightbox === false ? 'target="_blank" rel="noopener"' : '';
537 $result = array(
538 'href' => esc_url( $link ),
539 'cl' => esc_attr( trim( $cl ) ),
540 'r' => $rel,
541 'l' => $isLightbox
542 );
543
544 if ($echo === false) {
545 return $result;
546 }
547 echo 'href="' . $result['href'] . '"';
548 if ($result['cl'] !== '') {
549 echo ' class="' . $result['cl'] . '"';
550 }
551 if ($result['r'] !== '') {
552 echo ' ' . $result['r'];
553 }
554 }
555
556 }
557
558 if (!function_exists('themify_theme_feed_link')) {
559
560 /**
561 * Returns the feed link, usually RSS
562 * @param string $setting
563 * @param bool $echo
564 * @return mixed|void
565 * @since 1.5.2
566 */
567 function themify_theme_feed_link($setting = 'setting-custom_feed_url', $echo = true) {
568 $out = themify_get($setting, '', true);
569 if ($out === '') {
570 $out = get_bloginfo('rss2_url');
571 }
572 $out = esc_url(apply_filters('themify_theme_feed_link', $out));
573 if ($echo) {
574 echo $out;
575 }
576 return $out;
577 }
578
579 }
580
581 if (!function_exists('themify_theme_feed')) {
582
583 /**
584 * Returns the feed html
585 * @param array $args
586 * @return void
587 * @since 1.5.2
588 */
589 function themify_theme_feed($args = array()) {
590 $key = isset($args['key']) ? $args['key'] : 'setting-exclude_rss';
591 if (!themify_check($key, true)) {
592 $key = isset($args['feed_key']) ? $args['feed_key'] : 'setting-custom_feed_url';
593 $text = isset($args['text']) ? $args['text'] : __('RSS', 'themify');
594 ?>
595 <div class="rss<?php if (isset($args['class'])): ?> <?php echo $args['class'] ?><?php endif; ?>"><a<?php if (isset($args['link_class'])): ?> class="<?php echo $args['link_class'] ?>"<?php endif; ?> href="<?php themify_theme_feed_link($key) ?>"><?php if (isset($args['icon'])): ?><?php echo themify_get_icon($args['icon'], false, false, false, array('aria-label' => __('RSS', 'themify'))) ?><?php endif; ?><?php echo!empty($text) ? $text : '<span class="screen-reader-text">' . __('RSS', 'themify') . '</span>'; ?></a></div>
596 <?php
597 }
598 }
599
600 }
601 if (!function_exists('themify_is_query_page')) {
602
603 /**
604 * Checks if current page is a query category page
605 * @return bool
606 * @since 1.3.8
607 */
608 function themify_is_query_page():bool {
609 static $is = NULL;
610 if ($is === null) {
611 global $themify;
612 $is = isset($themify->query_category) && '' !== $themify->query_category;
613 }
614
615 return $is;
616 }
617
618 }
619
620 if (!function_exists('themify_post_media')) {
621
622 /**
623 * Display post video or the featured image
624 *
625 * @since 2.7.7
626 */
627 function themify_post_media(array $args = array()) {
628 global $themify;
629 if ( $themify->hide_image !== 'yes' && ! post_password_required() ) {
630 $isImage = 'yes' !== $themify->unlink_image || isset($_GET['post_in_lightbox']) || (isset($args['unlink']) && false === $args['unlink']);
631 if (isset($args['image'])) {
632 $post_image = $args['image'];
633 } else {
634 $post_image = isset($args['use_video_link']) && $args['use_video_link'] === true ? '' : themify_post_video(false, false);
635 //check if there is a video url in the custom field
636 if ($post_image === '') {
637 $params = array('w' => $themify->width, 'h' => $themify->height);
638 if (isset($args['lazy_load'])) {
639 $params['lazy_load'] = $args['lazy_load'];
640 }
641 if (isset($args['preload'])) {
642 $params['preload'] = $args['preload'];
643 }
644 if (isset($args['prefetch'])) {
645 $params['prefetch'] = $args['prefetch'];
646 }
647 if (isset($args['alt'])) {
648 $params['alt'] = $args['alt'];
649 }
650 if (isset($args['title'])) {
651 $params['title'] = $args['title'];
652 }
653 if (isset($args['image_class'])) {
654 $params['image_class'] = $args['image_class'];
655 }
656 $post_image = themify_get_image($params);
657 unset($params);
658 if ($post_image === '' && isset($args['use_video_link']) && $args['use_video_link'] === true) {
659 $post_image = themify_fetch_video_image(themify_get('video_url'));
660 }
661 } else {
662 $isImage = false;
663 }
664 }
665 if ($isImage === true) {
666 $link_attr = themify_permalink_attr($args, false);
667 }
668 if (isset($args['before'])) {
669 echo $args['before'];
670 }
671 if ($post_image !== '') {
672 if (!isset($args['no_hook'])) {
673 themify_before_post_image(); // Hook
674 }
675 ?>
676 <figure class="<?php echo isset($args['class']) ? $args['class'] : 'post-image tf_clearfix' ?><?php if ($isImage === false): ?> is_video<?php endif; ?>">
677 <?php
678 if (isset($args['before_image'])) {
679 echo $args['before_image'];
680 }
681 ?>
682 <?php if ($isImage === true): ?>
683 <a href="<?php echo esc_url( $link_attr['href'] ) ?>"<?php if ($link_attr['cl'] !== ''): ?> class="<?php echo esc_attr( $link_attr['cl'] ) ?>"<?php endif; ?><?php if ($link_attr['r'] !== ''): ?> <?php echo $link_attr['r'] ?><?php endif; ?>>
684 <?php endif; ?>
685 <?php echo $post_image; ?>
686 <?php if ($isImage === true): ?>
687 <?php if ($link_attr['l'] === true): ?>
688 <?php themify_zoom_icon(); ?>
689 <?php endif; ?>
690 </a>
691 <?php endif; ?>
692 <?php
693 if (isset($args['after_image'])) {
694 echo $args['after_image'];
695 }
696 ?>
697 </figure>
698 <?php
699 if (!isset($args['no_hook'])) {
700 themify_after_post_image(); // Hook
701 }
702 }
703 if (isset($args['after'])) {
704 echo $args['after'];
705 }
706 }
707 }
708
709 function themify_fetch_video_image(?string $video_url,bool $url_only = false):string {
710 if (empty($video_url)) {
711 return '';
712 }
713 $image_url = $title = '';
714 if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $video_url, $match)) {
715 $video_id = $match[1];
716 $image_url = 'http://img.youtube.com/vi/' . $video_id . '/hqdefault.jpg';
717 $title = get_the_title();
718 } elseif (false !== stripos($video_url, 'vimeo')) {
719 $video_url = trim($video_url);
720 $key = 'tf_vimeo_' . $video_url;
721 $data = Themify_Storage::get($key);
722 if (!$data) {
723 $request = wp_safe_remote_get( 'https://vimeo.com/api/oembed.json?url=' . rawurlencode( $video_url ), array( 'timeout' => 5, 'redirection' => 3 ) );
724 $response_body = wp_remote_retrieve_body($request);
725 if ('' != $response_body) {
726 $vimeo = json_decode($response_body);
727 $image_url = $vimeo->thumbnail_url;
728 $title = str_replace('"', "'", $vimeo->title);
729 Themify_Storage::set($key, array('t' => $title, 'u' => $image_url), MONTH_IN_SECONDS);
730 }
731 } else {
732 $data = json_decode($data, true);
733 $image_url = $data['u'];
734 $title = $data['t'];
735 }
736 }
737 if ($url_only === true) {
738 return $image_url;
739 }
740 global $themify;
741 $title = esc_attr($title);
742 return '<img alt="' . $title . '" title="' . $title . '" src="' . themify_https_esc($image_url) . '" width="' . $themify->width . '">';
743 }
744
745 }
746 if (!function_exists('themify_get_featured_image_link')) {//deprecated from 2020.06.02
747
748 function themify_get_featured_image_link() {
749
750 }
751
752 }
753
754 if (!function_exists('themify_post_content')) {
755
756 function themify_post_content(bool $showedit = true) {
757
758 global $themify;
759 $iseditable = false && Themify_Builder::$frontedit_active === true && $themify->display_content !== 'none'; //temprorary disable
760 $more_text = themify_get('setting-default_more_text', __('More &rarr;', 'themify'), true);
761 if (function_exists('icl_t')) {
762 $more_text = icl_t('Themify', 'setting-default_more_text', $more_text);
763 }
764 ?>
765 <div class="entry-content<?php if ($iseditable === true && $themify->display_content === 'content'): ?> tb_editor_enable<?php endif; ?>"<?php if ($iseditable === true): ?> data-type="<?php echo $themify->display_content ?>" contenteditable="false"<?php endif; ?>>
766
767 <?php if ('excerpt' === $themify->display_content && (!is_attachment() || isset($themify->post_module_hook))) : ?>
768
769 <?php
770 themify_before_post_content();
771 the_excerpt();
772 themify_after_post_content();
773 ?>
774
775 <?php if (themify_check('setting-excerpt_more', true) && (!is_single() || isset($themify->post_module_hook))) : ?>
776
777 <div class="more-link-wrap"><a href="<?php $link = themify_permalink_attr(array(), false);
778 echo esc_url( $link['href'] ); ?>" class="more-link"><?php echo wp_kses_post( $more_text ); ?></a></div>
779
780 <?php endif; ?>
781
782 <?php elseif ($themify->display_content !== 'none'): ?>
783 <?php
784 if (!is_single()) {
785 global $more;
786 $more = 0; //enable more link
787 }
788 ?>
789 <?php
790 themify_before_post_content();
791 the_content($more_text);
792 themify_after_post_content();
793 ?>
794
795 <?php endif; //display content ?>
796
797 </div><!-- /.entry-content -->
798 <?php
799 // show edit link for single post pages only
800 if ( $showedit === true && is_singular() && get_the_ID() === get_queried_object_id() ) {
801 themify_edit_link( '[' . __('Edit', 'themify') . ']' );
802 }
803 }
804
805 }
806
807
808
809 if (!function_exists('themify_post_title_tag')) {
810
811 /**
812 * Get the HTML tag to be used for post titles
813 *
814 * @since 2.7.7
815 * @return string
816 */
817 function themify_post_title_tag():string {
818 global $themify;
819 $tag = !empty($themify->themify_post_title_tag) ? $themify->themify_post_title_tag : ((empty($themify->is_shortcode) && empty($themify->is_builder_loop) && is_singular()) ? 'h1' : 'h2');
820
821 return apply_filters('themify_post_title_tag', $tag);
822 }
823
824 }
825
826 if (!function_exists('themify_post_title')) {
827
828 /**
829 * Template tag to display the post title
830 *
831 * uses themify_parse_args to filter the $args
832 */
833 function themify_post_title($args = array()) {
834 global $themify;
835 if ($themify->hide_title !== 'yes' || (isset($args['show_title']) && $args['show_title'] === true)) {
836 $posfix = !empty($themify->post_module_hook) ? '_module' : '';
837 $html = '';
838 if (!isset($args['unlink'])) {
839 $args['unlink'] = isset($_GET['post_in_lightbox']) ? false : (isset($themify->unlink_title) && $themify->unlink_title === 'yes');
840 }
841 if (!isset($args['tag'])) {
842 $args['tag'] = themify_post_title_tag();
843 }
844 if (!isset($args['class'])) {
845 $args['class'] = 'post-title entry-title';
846 }
847 $args = apply_filters('themify_post_title_args', $args);
848 if (!isset($args['no_hook'])) {
849 ob_start();
850 themify_before_post_title($posfix); // Hook
851 $html = ob_get_clean();
852 }
853 $html .= '<' . $args['tag'];
854 if ($args['class'] !== '') {
855 $html .= ' class="' . $args['class'] . '"';
856 }
857 if (false && Themify_Builder::$frontedit_active === true && $args['unlink'] === true) {//temprorary disable
858 $html .= ' contenteditable="false" data-type="title"';
859 }
860 $html .= '>';
861 if (isset($args['before_title'])) {
862 $html .= $args['before_title'];
863 }
864 if ($args['unlink'] !== true) {
865 $link = themify_permalink_attr($args, false);
866 $html .= '<a href="' . esc_url( $link['href'] ) . '"';
867 if ($link['cl'] !== '') {
868 $html .= ' class="' . esc_attr( $link['cl'] ) . '" ';
869 }
870 if ($link['r'] !== '') {
871 $html .= $link['r'];
872 }
873 if (false && Themify_Builder::$frontedit_active === true) {//temprorary disable
874 $html .= ' contenteditable="false" data-type="title"';
875 }
876 $html .= '>';
877 }
878 $html .= isset($args['title']) ? $args['title'] : the_title('', '', false);
879 if ($args['unlink'] !== true) {
880 if ($link['l'] === true && isset($args['zoom']) && $args['zoom'] === true) {
881 $html .= themify_zoom_icon(false);
882 }
883 $html .= '</a>';
884 }
885 if (isset($args['after_title'])) {
886 $html .= $args['after_title'];
887 }
888 $html .= '</' . $args['tag'] . '>';
889 if (isset($args['before'])) {
890
891 $html = $args['before'] . $html;
892 }
893 if (isset($args['after'])) {
894 $html = $html . $args['after'];
895 }
896
897 if (!isset($args['no_hook'])) {
898 ob_start();
899 themify_after_post_title($posfix); // Hook
900 $html .= ob_get_clean();
901 }
902
903 $html = apply_filters('themify_post_title_html', $html, $args);
904 if (isset($args['echo']) && $args['echo'] !== true) {
905 return $html;
906 }
907 echo $html;
908 }
909 }
910
911 }
912
913
914 if (!function_exists('themify_comments_popup_link')) {
915
916 /**
917 * Generate the popup comment link
918 *
919 * @since 2.9.9
920 */
921 function themify_comments_popup_link(array $args = array()) {
922 global $themify;
923 if ($themify->hide_meta !== 'yes' && (!isset($themify->hide_meta_comment) || $themify->hide_meta_comment !== 'yes' ) && comments_open()) {
924 $post_type = get_post_type();
925 if (( $post_type === 'post' && themify_check('setting-comments_posts', true) ) || ( $post_type === 'portfolio' && !themify_check('setting-portfolio_comments', true) )) {
926 return;
927 }
928 } else {
929 return;
930 }
931 $args = array_merge(array(
932 'zero' => __('0', 'themify'),
933 'one' => __('1', 'themify'),
934 'more' => __('%', 'themify'),
935 'class' => 'post-comment',
936 'icon' => '',
937 ), $args);
938 ?>
939 <span class="<?php echo $args['class']; ?>">
940 <?php
941 comments_popup_link($args['zero'], $args['one'], $args['more']);
942 if ($args['icon'] !== '') {
943 echo themify_get_icon($args['icon']);
944 }
945 ?>
946 </span>
947 <?php
948 }
949
950 }
951
952 if (!function_exists('themify_author_bio')) {
953
954 /**
955 * Display author biography, used in author archive pages
956 *
957 * @since 3.0.8
958 */
959 function themify_author_bio() {
960 global $author, $author_name;
961
962 $curauth = ( isset($_GET['author_name']) ) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
963 $author_url = $curauth->user_url;
964 ?>
965 <div class="author-bio tf_clearfix">
966 <p class="author-avatar"><?php echo get_avatar($curauth->user_email, 200); ?></p>
967 <h2 class="author-name">
968 <?php printf(__('About <span>%s</span>', 'themify'), $curauth->display_name); ?></span>
969 </h2>
970 <?php if ($author_url != '') : ?>
971 <p class="author-url">
972 <a href="<?php echo esc_attr($author_url); ?>"><?php echo esc_html($author_url); ?></a>
973 </p>
974 <?php endif; //author url ?>
975 <div class="author-description">
976 <?php echo $curauth->user_description; ?>
977 </div><!-- /.author-description -->
978 </div><!-- /.author bio -->
979
980 <h2 class="author-posts-by"><?php printf(__('Posts by %s %s', 'themify'), $curauth->first_name, $curauth->last_name); ?>:</h2>
981 <?php
982 }
983
984 }
985
986 if (!function_exists('themify_loop_get_context')) {
987
988 /**
989 * Get current context, where the template file is being rendered in.
990 * Used mainly in loop.php template file, since this template file can be called to render inside itself
991 *
992 * @return string|NULL
993 * @since 3.1.1
994 */
995 function themify_loop_get_context($type = 'post') {
996 global $themify;
997
998 if (!empty($themify->is_shortcode)) {
999 return 'shortcode';
1000 }
1001 if (!empty($themify->is_builder_loop)) {
1002 return 'builder';
1003 }
1004 if (is_singular($type)) {
1005 return 'single';
1006 }
1007 }
1008
1009 }
1010
1011 if (!function_exists('themify_loop_is_singular')) {
1012
1013 /**
1014 * Check if current context is "single post page" and not inside a shortcode or Builder module
1015 * Note: this may return false even if is_singular( $type ) returns true, using this function context matters.
1016 *
1017 * @return bool
1018 * @since 3.1.1
1019 */
1020 function themify_loop_is_singular($type = 'post'):bool {
1021 return 'single' === themify_loop_get_context($type);
1022 }
1023
1024 }
1025
1026 if (!function_exists('themify_open_link')) {
1027
1028 /**
1029 * Create the opening <a> tag, links to the permalink by default
1030 *
1031 * @return string
1032 */
1033 function themify_open_link(array $args = array()) {
1034 $args = wp_parse_args($args, array(
1035 'no_permalink' => false, // if there is no lightbox link, don't return a link
1036 'class' => '', // additional classes to attach to link
1037 'echo' => false,
1038 'link' => '',
1039 'lightbox' => false,
1040 ));
1041 $attr = array(
1042 'class' => $args['class']
1043 );
1044 $link = $args['link'];
1045 if (empty($link)) {
1046 if (themify_get('external_link') != '') {
1047 $link = esc_url(themify_get('external_link'));
1048 } elseif (themify_get('lightbox_link') != '') {
1049 $link = esc_url(themify_get('lightbox_link'));
1050 $args['lightbox'] = true;
1051 } elseif (themify_check('link_url')) {
1052 $link = themify_get('link_url');
1053 } elseif ($args['no_permalink']) {
1054 $link = '';
1055 } else {
1056 $link = get_permalink();
1057 if (current_theme_supports('themify-post-in-lightbox')) {
1058 if (!is_single() && '' != themify_get('setting-open_inline')) {
1059 $args['lightbox'] = true;
1060 }
1061 if (themify_is_query_page()) {
1062 if ('no' === themify_get('post_in_lightbox')) {
1063 $link = get_permalink();
1064 } else {
1065 $args['lightbox'] = true;
1066 }
1067 }
1068 if ($args['lightbox'] === true) {
1069 $link = add_query_arg(array('post_in_lightbox' => 1), get_permalink());
1070 }
1071 }
1072 }
1073 }
1074 $attr['href'] = $link;
1075 if ($args['lightbox'] === true) {
1076 $attr['class'] .= ' themify_lightbox';
1077 }
1078
1079 $link = sprintf('<a%s>', themify_get_element_attributes($attr));
1080
1081 if ($args['echo'])
1082 echo $link;
1083
1084 return $link;
1085 }
1086
1087 }
1088
1089 if (!function_exists('themify_get_categories_as_classes')) {
1090
1091 /**
1092 * Returns a CSS-formatted string of categories assigned to current post
1093 *
1094 * @return string
1095 */
1096 function themify_get_categories_as_classes($post_id):string {
1097 $categories = wp_get_post_categories($post_id);
1098 $class = '';
1099 foreach ($categories as $cat)
1100 $class .= ' cat-' . $cat;
1101
1102 return $class;
1103 }
1104
1105 }
1106
1107 if (!function_exists('themify_the_terms')) {
1108
1109 /**
1110 * Retrieve a post's terms as a list with specified format.
1111 * Based on get_the_term_list()
1112 *
1113 * @since 3.4.7
1114 *
1115 * @param int $id Post ID.
1116 * @param string $taxonomy Taxonomy name.
1117 * @param string $before Optional. Before list.
1118 * @param string $sep Optional. Separate items using this.
1119 * @param string $after Optional. After list.
1120 * @return false|void False on WordPress error.
1121 */
1122 function themify_the_terms($id, $taxonomy, $before = '', $sep = '', $after = '') {
1123 $terms = get_the_terms($id, $taxonomy);
1124
1125 if (is_wp_error($terms) || empty($terms)) {
1126 return $terms;
1127 }
1128
1129
1130 $links = array();
1131
1132 foreach ($terms as $term) {
1133 $link = get_term_link($term, $taxonomy);
1134 if (is_wp_error($link)) {
1135 return $link;
1136 }
1137 $links[] = '<a href="' . esc_url($link) . '" rel="tag" class="term-' . $term->slug . '">' . $term->name . '</a>';
1138 }
1139
1140 /**
1141 * Filters the term links for a given taxonomy.
1142 *
1143 * The dynamic portion of the filter name, `$taxonomy`, refers
1144 * to the taxonomy slug.
1145 *
1146 * @param array $links An array of term links.
1147 */
1148 $term_links = apply_filters("term_links-{$taxonomy}", $links);
1149
1150 $term_links = $before . implode($sep, $term_links) . $after;
1151 /**
1152 * Filters the list of terms to display.
1153 *
1154 * @param array $term_list List of terms to display.
1155 * @param string $taxonomy The taxonomy name.
1156 * @param string $before String to use before the terms.
1157 * @param string $sep String to use between the terms.
1158 * @param string $after String to use after the terms.
1159 */
1160 echo apply_filters('the_terms', $term_links, $taxonomy, $before, $sep, $after);
1161 }
1162
1163 }
1164
1165
1166 if (!function_exists('themify_meta_taxonomies')) :
1167
1168 function themify_meta_taxonomies($taxonomy = '', $sep = '', $before = '', $after = '') {
1169 global $themify;
1170 if ($themify->hide_meta !== 'yes' && (!isset($themify->hide_meta_category) || $themify->hide_meta_category !== 'yes')) {
1171 if ($taxonomy === '') {
1172 $taxonomy = get_post_type();
1173 if ($taxonomy === 'post') {
1174 $taxonomy = 'category';
1175 } elseif ($taxonomy === 'product') {
1176 $taxonomy = 'product_cat';
1177 } else {
1178 $taxonomy .= '-category';
1179 }
1180 }
1181 if ($sep === '') {
1182 $sep = ', ';
1183 }
1184 if ($before === '') {
1185 $before = '<span class="post-category">';
1186 }
1187 if ($after === '') {
1188 $after = '</span>';
1189 }
1190 themify_the_terms(get_the_ID(), $taxonomy, $before, $sep, $after);
1191 }
1192 }
1193
1194 endif;
1195
1196 if (!function_exists('themify_page_description')) :
1197
1198 /**
1199 * Display page description depending on context
1200 *
1201 * @since 4.2.2
1202 * @return string
1203 */
1204 function themify_page_description() {
1205 if (is_author()) {
1206 themify_author_bio();
1207 } elseif (is_category() || is_tag() || is_tax()) {
1208 echo themify_get_term_description();
1209 }
1210 }
1211
1212 endif;
1213
1214 if (!function_exists('themify_get_title')) {
1215
1216 /**
1217 * Display page title depending on context
1218 *
1219 * @since 4.2.2
1220 * @return string
1221 */
1222 function themify_get_title(array $args = array()) {
1223
1224 $title = '';
1225
1226 if (themify_is_page() && !is_404()) {
1227 $title = get_the_title();
1228 } elseif (is_search()) {
1229 $title = '<span class="page_title_prefix">' . __('Search Results for: ', 'themify') . '</span><em>' . get_search_query() . '</em>';
1230 } elseif (is_category() || is_tag() || is_tax()) {
1231 $title = single_cat_title('', false);
1232 } elseif (is_author()) {
1233 $title = get_the_author();
1234 } elseif (is_date()) {
1235 $useLabel = isset($args['use_date_labels']) && $args['use_date_labels'] === true;
1236 $label = '';
1237 if (is_year()) {
1238 $title = get_the_date( _x('Y', 'yearly archives date format', 'themify') );
1239 if ($useLabel === true || isset($args['label_year'])) {
1240 $label = isset($args['label_year']) ? $args['label_year'] : __('Yearly Archives: %s', 'themify');
1241 }
1242 } elseif (is_month()) {
1243 $title = get_the_date(_x('F Y', 'monthly archives date format', 'themify'));
1244 if ($useLabel === true || isset($args['label_month'])) {
1245 $label = isset($args['label_month']) ? $args['label_month'] : __('Monthly Archives: %s', 'themify');
1246 }
1247 } else {
1248 $title = get_the_date(_x('F j, Y', 'daily archives date format', 'themify'));
1249 if ($useLabel === true || isset($args['day'])) {
1250 $label = isset($args['label_day']) ? $args['label_day'] : __('Daily Archives: %s', 'themify');
1251 }
1252 }
1253 if ($label !== '') {
1254 $title = sprintf($label, $title);
1255 }
1256 } elseif (is_post_type_archive()) {
1257 $title = post_type_archive_title('', false);
1258 } elseif (is_404()) {
1259 $title = __('404', 'themify');
1260 }
1261
1262 if (!empty($title)) {
1263 $args = themify_parse_args($args, array(
1264 'tag' => 'h1',
1265 'class' => 'page-title',
1266 'before' => '',
1267 'after' => '',
1268 'before_title' => '',
1269 'after_title' => '',
1270 ), 'page_title');
1271 $title = "{$args['before']} <{$args['tag']} itemprop=\"name\" class=\"{$args['class']}\">{$args['before_title']}{$title}{$args['after_title']} </{$args['tag']}>{$args['after']}";
1272 }
1273 return $title;
1274 }
1275
1276 }
1277 if (!function_exists('themify_page_output')) :
1278
1279 function themify_page_output($args = array()) {
1280
1281 $args = themify_parse_args($args, array(
1282 'disable' => false, // whether page output should be disabled entirely
1283 ), 'page_output');
1284
1285 if ($args['disable'] !== false) {
1286 themify_content_start();
1287 themify_content_end();
1288 return;
1289 }
1290
1291 themify_content_start(); // hook
1292 if ((!isset($args['hide_page_content']) || $args['hide_page_content'] === false)) {
1293 themify_page_content($args);
1294 }
1295 if (!is_404() && (!isset($args['hide_loop']) || $args['hide_loop'] === false)) {
1296 global $themify;
1297 $isPage = themify_is_page();
1298 if ($isPage === false || $themify->query_category !== '') {
1299 if ($isPage === true) {
1300 $themify->page_id = get_the_ID();
1301 }
1302 if ($isPage === true && $themify->query_category !== '' && themify_get('section_categories') === 'yes') {
1303 if (!isset($args['hide_filter']) || $args['hide_filter'] === false) {
1304 themify_masonry_filter();
1305 }
1306 get_template_part('includes/category-section');
1307 } else {
1308 // Query posts action based on global $themify options
1309 do_action('themify_custom_query_posts', (isset($args['query_args']) ? $args['query_args'] : array()));
1310 if (have_posts()) {
1311 if ((!isset($args['hide_filter']) || $args['hide_filter'] === false) && themify_masonry_filter()) {
1312 $args['loop_class'] = !isset($args['loop_class']) ? array() : $args['loop_class'];
1313 $args['loop_class'][] = 'masonry';
1314 }
1315 if ($themify->query_category !== '' && current_user_can('edit_post', $themify->page_id)) {
1316 $post_type = $themify->query_post_type && $themify->query_post_type !== 'page' ? $themify->query_post_type : 'post';
1317 $tabSlug = $post_type === 'post' || $post_type === 'product' ? $post_type . 's' : $post_type;
1318 ?>
1319 <a class="tf_query_edit_link" href="<?php echo get_edit_post_link($themify->page_id) ?>#query-<?php echo $tabSlug ?>t"><?php echo sprintf(__('Edit Query %s', 'themify'), ucfirst($post_type . 's')) ?></a>
1320 <?php
1321 }
1322 themify_loop_output($args);
1323 } elseif (is_search() || ($isPage === true && $themify->query_category !== '')) {
1324 echo '<p>', __('Sorry, nothing found.', 'themify'), '</p>';
1325 }
1326 }
1327 //Reset query posts if it exist
1328 do_action('themify_reset_query');
1329 if ($isPage === true) {
1330 unset($themify->page_id);
1331 }
1332 }
1333 }
1334 themify_content_end();
1335 }
1336
1337 endif;
1338
1339 if (!function_exists('themify_masonry_filter')) {
1340
1341 function themify_masonry_filter($args = array()) {
1342 global $themify;
1343 if (isset($themify) && ((isset($themify->post_layout) && 'slider' === $themify->post_layout) || empty($themify->post_filter) || $themify->post_filter === 'no')) {
1344 return false;
1345 }
1346 elseif (empty($args)) {
1347 $args['query_category'] = $themify->query_category;
1348 if (isset($themify->query_taxonomy)) {
1349 $args['query_taxonomy'] = $themify->query_taxonomy;
1350 }
1351 }
1352 themify_get_template('includes/filter', '', $args);
1353 return true;
1354 }
1355
1356 }
1357
1358 function themify_set_loop_args(array $class, $post_type, $layout, $type = 'main'):array {
1359 $post_type = '' === $post_type ? 'post' : $post_type;
1360 $class = apply_filters('themify_loops_wrapper_class', $class, $post_type, $layout, $type);
1361 array_unshift($class, 'loops-wrapper');
1362 $_args = array(
1363 'id' => 'loops-wrapper',
1364 'class' => $class
1365 );
1366 if (Themify_Builder::$frontedit_active === false) {
1367 $_args['data-lazy'] = 1;
1368 }
1369 $container_props = apply_filters('themify_container_props', $_args, $post_type, $layout, $type);
1370 unset($_args);
1371 global $woocommerce_loop;
1372 if ($type !== 'main' || ($post_type === 'product' && ( ( isset($woocommerce_loop['name']) && in_array( $woocommerce_loop['name'], [ 'up-sells', 'cross-sells', 'related' ], true ) ) || wc_get_loop_prop('is_shortcode')))) {
1373 unset($container_props['id']);
1374 $index = array_search('masonry', $container_props['class'], true);
1375 if ($index !== false) {
1376 unset($container_props['class'][$index]);
1377 }
1378 $index = array_search('infinite', $container_props['class'], true);
1379 if ($index !== false) {
1380 unset($container_props['class'][$index]);
1381 }
1382 $index = array_search('no-gutter', $container_props['class'], true);
1383 if ($index !== false) {
1384 unset($container_props['class'][$index]);
1385 }
1386 unset($container_props['data-layout'], $container_props['data-gutter']);
1387 }
1388 $container_props['class'][] = 'tf_clear tf_clearfix';
1389 $container_props['class'] = implode(' ', $container_props['class']);
1390 return $container_props;
1391 }
1392
1393 if (!function_exists('themify_loop_output')) {
1394
1395 function themify_loop_output(array $args = array()) {
1396 global $themify;
1397 $post_type = '';
1398 if ($themify->query_category !== '') {
1399 if ($themify->query_post_type !== 'post' && $themify->query_post_type !== 'page') {
1400 $post_type = $themify->query_post_type;
1401 }
1402 } elseif (is_tax() || is_post_type_archive()) {
1403 if (is_post_type_archive('portfolio') || is_tax('portfolio-category')) {
1404 $post_type = 'portfolio';
1405 } else {
1406 if (is_post_type_archive()) {
1407 if (!themify_is_shop()) {
1408 $post_type = get_query_var('post_type');
1409 if (is_array($post_type)) {
1410 $post_type = reset($post_type);
1411 }
1412 } else {
1413 $post_type = 'product';
1414 }
1415 } elseif (is_tax()) {
1416 $post_type = get_post_type();
1417 }
1418 }
1419 }
1420 if ($post_type === 'product') {
1421 themify_product_loop_output($args);
1422 return;
1423 }
1424 $class = isset($args['loop_class']) ? $args['loop_class'] : array();
1425 if ($post_type !== '' && $post_type !== 'category' && $post_type !== 'post_tag') {
1426 $class[] = $post_type;
1427 } else {
1428 $post_type = '';
1429 }
1430 $templates = array(); //we need array ,because get_post_type() can be different(e.g multiple post types attached to taxonomy
1431 $slug = isset($args['loop_template']) ? $args['loop_template'] : 'includes/loop';
1432 do_action('themify_before_loop_output');
1433 ?>
1434 <div <?php echo themify_get_element_attributes(themify_set_loop_args($class, $post_type, $themify->post_layout)); ?>>
1435 <?php while (have_posts()) : the_post(); ?>
1436 <?php
1437 $post_type = get_post_type();
1438 do_action("get_template_part_{$slug}", $slug, $post_type);
1439 if (!isset($templates[$post_type])) {
1440 $templates[$post_type] = locate_template(array(
1441 $slug . '-' . $post_type . '.php',
1442 $slug . '.php'
1443 ), false);
1444 }
1445 if ($templates[$post_type] !== '') {
1446 require $templates[$post_type];
1447 }
1448 do_action('get_template_part', $slug, $post_type, array());
1449 ?>
1450 <?php endwhile; ?>
1451 </div>
1452 <?php
1453 $templates = null;
1454 if ($themify->page_navigation !== 'yes' || !themify_is_page()) {
1455 get_template_part('includes/pagination');
1456 }
1457 do_action('themify_after_loop_output');
1458 }
1459
1460 }
1461
1462 function themify_product_loop_output(array $args = array()) {
1463 global $wp_query, $woocommerce_loop;
1464 $woocommerce_loop = array_merge($args, array(
1465 'is_search' => $wp_query->is_search(),
1466 'is_filtered' => is_filtered(),
1467 'total' => $wp_query->found_posts,
1468 'total_pages' => $wp_query->max_num_pages,
1469 'per_page' => $wp_query->get('posts_per_page'),
1470 'current_page' => max(1, $wp_query->get('paged', 1)),
1471 ));
1472 if (wc_get_loop_prop('total')) {
1473 echo '<div class="woocommerce">';
1474 do_action('woocommerce_before_shop_loop');
1475 woocommerce_product_loop_start();
1476 while (have_posts()) {
1477 the_post();
1478 do_action('woocommerce_shop_loop');
1479
1480 wc_get_template_part('content', 'product');
1481 }
1482 woocommerce_product_loop_end();
1483 do_action('woocommerce_after_shop_loop');
1484 echo '</div>';
1485 }
1486 $woocommerce_loop = null;
1487 }
1488
1489 if (!function_exists('themify_404_page_content')) {
1490
1491 function themify_404_page_content() {
1492 ?>
1493 <p><?php _e('Page not found.', 'themify'); ?></p>
1494 <?php if (current_user_can('administrator')): ?>
1495 <p><?php _e('@admin Learn how to create a <a href="https://themify.me/docs/custom-404" target="_blank">custom 404 page</a>.', 'themify'); ?></p>
1496 <?php
1497 endif;
1498 }
1499
1500 }
1501
1502 if (!function_exists('themify_page_title')) {
1503
1504 function themify_page_title(array $args = array()) {
1505 global $themify;
1506 do_action('themify_before_page_title');
1507 if (isset($themify->page_title) && $themify->page_title !== 'yes') {
1508 ?>
1509 <!-- page-title -->
1510 <time datetime="<?php the_time('o-m-d'); ?>"></time>
1511 <?php
1512 echo themify_get_title($args);
1513 }
1514 do_action('themify_after_page_title');
1515 }
1516
1517 }
1518
1519 if (!function_exists('themify_page_image')) {
1520
1521 function themify_page_image() {
1522 global $themify;
1523
1524 do_action('themify_before_page_image');
1525
1526 if (has_post_thumbnail()) {
1527 if (!isset($themify->hide_page_image) || $themify->hide_page_image !== 'yes') {
1528 ?>
1529 <figure class="post-image">
1530
1531 <?php
1532 echo themify_get_image(array(
1533 'w' => isset($themify->image_page_single_width) ? $themify->image_page_single_width : $themify->width,
1534 'h' => isset($themify->image_page_single_height) ? $themify->image_page_single_height : $themify->height,
1535 ));
1536 ?>
1537
1538 </figure>
1539 <?php
1540 }
1541 }
1542
1543 do_action('themify_after_page_image');
1544 }
1545
1546 }
1547
1548 if (!function_exists('themify_page_content')) {
1549
1550 function themify_page_content(array $args = array()) {
1551 if (is_404()) {
1552 if (!isset($args['hide_title']) || $args['hide_title'] === false) {
1553 echo themify_get_title($args);
1554 }
1555 if (!isset($args['hide_desc']) || $args['hide_desc'] === false) {
1556 themify_404_page_content();
1557 }
1558 } elseif (themify_is_page()) {
1559 if (have_posts()) {
1560 the_post();
1561 do_action('themify_before_page_content');
1562 ?>
1563 <div id="page-<?php the_ID(); ?>" class="type-page">
1564 <?php
1565 if (!isset($args['hide_title']) || $args['hide_title'] === false) {
1566 themify_page_title($args);
1567 }
1568 if (!isset($args['hide_page_entry']) || $args['hide_page_entry'] === false) {
1569 themify_page_entry_content();
1570 }
1571 ?>
1572 </div>
1573 <!-- /.type-page -->
1574 <?php
1575 do_action('themify_after_page_content');
1576 }
1577 } else {
1578 if (!isset($args['hide_title']) || $args['hide_title'] === false) {
1579 echo themify_get_title($args);
1580 }
1581 if (!isset($args['hide_desc']) || $args['hide_desc'] === false) {
1582 themify_page_description();
1583 }
1584 }
1585 }
1586
1587 }
1588
1589 if (!function_exists('themify_page_entry_content')) {
1590
1591 function themify_page_entry_content() {
1592 global $themify;
1593 do_action('themify_before_entry_content');
1594 ?>
1595 <div class="page-content entry-content">
1596 <?php
1597 themify_page_image();
1598 the_content();
1599 wp_link_pages(array('before' => '<p class="post-pagination tf_block"><strong>' . __('Pages:', 'themify') . '</strong> ', 'after' => '</p>', 'next_or_number' => 'number'));
1600 themify_edit_link( '[' . __('Edit', 'themify') . ']' );
1601 if ($themify->query_category === '' && !themify_check('setting-comments_pages', true)) {
1602 comments_template();
1603 }
1604 ?>
1605 <!-- /comments -->
1606 </div>
1607 <!-- /.post-content -->
1608 <?php
1609 do_action('themify_after_entry_content');
1610 }
1611
1612 }
1613
1614 function themify_is_page():bool {
1615 static $is = null;
1616 if ($is === null) {
1617 global $themify;
1618 $is = (isset($themify->isPage) && $themify->isPage === true) || is_page();
1619 }
1620 return $is;
1621 }
1622
1623 if (!function_exists('themify_comment_list')) {
1624
1625 /**
1626 * Themify Comment
1627 *
1628 * @since 1.0.0
1629 *
1630 * @param object $comment Current comment.
1631 * @param array $args Parameters for comment reply link.
1632 * @param int $depth Maximum comment nesting depth.
1633 */
1634 function themify_comment_list($comment, $args, $depth) {
1635 $GLOBALS['comment'] = $comment;
1636 static $size = null;
1637 static $date = null;
1638 static $time = null;
1639 if ($size === null) {
1640 $size = apply_filters('themify_comment_avatar_size', 48);
1641 $date = apply_filters('themify_comment_date', '');
1642 $time = apply_filters('themify_comment_time', '');
1643 }
1644 ?>
1645 <li id="comment-<?php comment_ID() ?>" <?php comment_class(); ?>>
1646 <p class="comment-author">
1647 <?php echo get_avatar($comment, $size); ?>
1648 <cite><?php echo themify_get_icon('bookmark', 'fa', false, false, array('aria-label' => __('Bookmark', 'themify'))); ?><?php echo get_comment_author_link(); ?></cite>
1649 <br/>
1650 <small class="comment-time">
1651 <?php comment_date($date); ?>
1652 @
1653 <?php
1654 comment_time($time);
1655 edit_comment_link(__('Edit', 'themify'), ' [', ']');
1656 ?>
1657 </small>
1658 </p>
1659 <div class="commententry">
1660 <?php if ($comment->comment_approved == '0') : ?>
1661 <p><em><?php _e('Your comment is awaiting moderation.', 'themify') ?></em></p>
1662 <?php endif; ?>
1663 <?php comment_text(); ?>
1664 </div>
1665 <p class="reply">
1666 <?php comment_reply_link(array_merge($args, array('add_below' => 'comment', 'depth' => $depth, 'reply_text' => __('Reply', 'themify'), 'max_depth' => $args['max_depth']))) ?>
1667 </p>
1668 <?php
1669 }
1670
1671 }
1672
1673 if (!function_exists('themify_comments')) {
1674
1675 function themify_comments() {
1676 $post_type = get_post_type();
1677 if (($post_type === 'post' && themify_check('setting-comments_posts', true)) || ($post_type === 'portfolio' && !themify_check('setting-portfolio_comments', true))) {
1678 return;
1679 }
1680 themify_comment_before(); //hook
1681 $hasComment = have_comments();
1682 $commentOpen = comments_open();
1683 ?>
1684 <?php if ($hasComment === true || $commentOpen === true) : ?>
1685
1686 <div id="comments" class="commentwrap tf_clearfix">
1687
1688 <?php themify_comment_start(); //hook ?>
1689
1690 <?php if ($hasComment === true): ?>
1691 <?php if (post_password_required()) : ?>
1692 <p class="nopassword"><?php _e('This post is password protected. Enter the password to view any comments.', 'themify'); ?></p>
1693 <?php else: ?>
1694 <?php
1695 $callback = function_exists('themify_theme_comment') ? 'themify_theme_comment' : 'themify_comment_list';
1696
1697 $total = get_comment_pages_count();
1698 $pagination = $total > 1 ? paginate_comments_links(array('prev_text' => '', 'next_text' => '', 'echo' => false, 'total' => $total)) : false;
1699 ?>
1700 <h4 class="comment-title"><?php comments_number(__('No Comments', 'themify'), __('1 Comment', 'themify'), __('% Comments', 'themify')); ?></h4>
1701
1702 <?php if ($pagination !== false) : ?>
1703 <nav class="pagenav top tf_clearfix">
1704 <?php echo $pagination ?>
1705 </nav>
1706 <!-- /.pagenav -->
1707 <?php endif; ?>
1708
1709 <ol class="commentlist">
1710 <?php wp_list_comments('callback=' . $callback); ?>
1711 </ol>
1712
1713 <?php if ($pagination !== false) : ?>
1714 <nav class="pagenav bottom tf_clearfix">
1715 <?php echo $pagination ?>
1716 </nav>
1717 <!-- /.pagenav -->
1718 <?php endif; ?>
1719
1720 <?php endif; ?>
1721 <?php endif; ?>
1722 <?php
1723 if ($commentOpen === true) {
1724 comment_form();
1725 }
1726 if (themify_is_themify_theme() && Themify_Enqueue_Assets::has_theme_support_css('comments')) {
1727 Themify_Enqueue_Assets::loadThemeStyleModule('comments');
1728 }
1729 themify_comment_end(); //hook
1730 ?>
1731 </div>
1732 <!-- /.commentwrap -->
1733 <?php endif; ?>
1734
1735 <?php
1736 themify_comment_after(); //hook
1737 }
1738
1739 }
1740
1741 if (!function_exists('themify_single_comments_template')) {
1742
1743 function themify_comments_template() {
1744 $post_type = get_post_type();
1745 if (($post_type === 'post' && themify_check('setting-comments_posts', true)) || ($post_type === 'portfolio' && !themify_check('setting-portfolio_comments', true))) {
1746 return;
1747 }
1748 if ( post_password_required() ) {
1749 return;
1750 }
1751 comments_template();
1752 }
1753
1754 }
1755
1756 /**
1757 * Parses the arguments given as category to see if they are category IDs or slugs and returns a proper tax_query
1758 * @param $category
1759 * @param $taxonomy
1760 * @return array
1761 */
1762 function themify_parse_category_args($category, $taxonomy):array {
1763 $tax_query = array();
1764 if ('all' !== $category && $category != '0') {
1765 $terms = explode(',', $category);
1766 $ids_in = $ids_not_in = $slugs_in = $slugs_not_in = array();
1767 $isAnd = 0;
1768 foreach ($terms as $c) {
1769 $c = trim($c);
1770 if ($c) {
1771 if ('-' !== $c[0]) {
1772 if (is_numeric($c)) {
1773 $ids_in[] = (int) $c;
1774 ++$isAnd;
1775 } else {
1776 $slugs_in[] = $c;
1777 ++$isAnd;
1778 }
1779 } elseif (is_numeric($c)) {
1780 $ids_not_in[] = $c * (-1);
1781 ++$isAnd;
1782 } else {
1783 $slugs_not_in[] = ltrim($c, '-'); // remove the minus sign (first character)
1784 ++$isAnd;
1785 }
1786 }
1787 }
1788 if ($isAnd > 1) {
1789 $tax_query = array(
1790 'relation' => 'AND'
1791 );
1792 }
1793 $terms = $isAnd = null;
1794 if (!empty($ids_in)) {
1795 $tax_query[] = array(
1796 'taxonomy' => $taxonomy,
1797 'field' => 'id',
1798 'terms' => $ids_in
1799 );
1800 }
1801 if (!empty($ids_not_in)) {
1802 $tax_query[] = array(
1803 'taxonomy' => $taxonomy,
1804 'field' => 'id',
1805 'terms' => $ids_not_in,
1806 'operator' => 'NOT IN'
1807 );
1808 }
1809 if (!empty($slugs_in)) {
1810 $tax_query[] = array(
1811 'taxonomy' => $taxonomy,
1812 'field' => 'slug',
1813 'terms' => $slugs_in
1814 );
1815 }
1816 if (!empty($slugs_not_in)) {
1817 $tax_query[] = array(
1818 'taxonomy' => $taxonomy,
1819 'field' => 'slug',
1820 'terms' => $slugs_not_in,
1821 'operator' => 'NOT IN'
1822 );
1823 }
1824 }
1825 return $tax_query;
1826 }
1827
1828 /**
1829 * Get Theme Sidebar
1830 * @param void
1831 * @return void
1832 */
1833 if (!function_exists('themify_get_sidebar')) {
1834
1835 function themify_get_sidebar() {
1836 global $themify;
1837 $page_id = themify_is_shop() ? wc_get_page_id( 'shop' ) : get_the_ID();
1838 if ($themify->layout !== 'sidebar-none' && !isset($_GET['post_in_lightbox']) && !post_password_required($page_id)) {
1839 if (is_file(Themify_Enqueue_Assets::$THEME_CSS_MODULES_DIR . 'sidebar.css')) {
1840 Themify_Enqueue_Assets::loadThemeStyleModule('sidebar');
1841 }
1842 get_sidebar();
1843 }
1844 }
1845
1846 }
1847
1848
1849 if (!function_exists('themify_menu_nav')) :
1850
1851 /**
1852 * Display main navigation menu
1853 *
1854 * @param $args array customize the arguments sent to wp_nav_menu
1855 * @return string|null output of the wp_nav_menu if $args['echo'] == false, otherwise null
1856 */
1857 function themify_menu_nav($args = array(), $reinit = false) {
1858
1859 $args = themify_parse_args($args, array(
1860 'theme_location' => 'main-nav',
1861 'fallback_cb' => 'themify_default_main_nav',
1862 'container' => '',
1863 'menu' => '',
1864 'menu_id' => 'main-nav',
1865 'menu_class' => 'main-nav tf_clearfix tf_box'
1866 ));
1867 if(isset($args['walker']) && is_string($args['walker'])){
1868 if($args['walker']==='Themify_Mega_Menu_Walker' && !class_exists('Themify_Mega_Menu_Walker',false)){
1869 require THEMIFY_DIR . '/megamenu/class-mega-menu.php';
1870 }
1871 $args['walker']=new $args['walker']();
1872 }
1873 $cacheDisable = $reinit === true || themify_is_dev_mode() || TFCache::get_cache_plugins('any') || themify_check('setting-cache-menu', true) || themify_check('setting-cache-html', true) || defined('POLYLANG_VERSION');
1874 $isEcho = !isset($args['echo']) || $args['echo'] === true;
1875 $menu = null;
1876 if ($args['menu_id'] === 'main-nav' && empty($args['menu']) && themify_is_themify_theme() && (is_singular() || themify_is_shop())) {
1877 $menu = themify_get('custom_menu');
1878 if (!empty($menu)) {
1879 $args['menu'] = $menu;
1880 }
1881 }
1882 if ($cacheDisable === false) {
1883 $transient_key = 'tf_menu_' . $args['theme_location'];
1884 if (!$menu) {
1885 if (empty($args['menu'])) {
1886 $locations = get_nav_menu_locations();
1887 if (!empty($locations) && isset($locations[$args['theme_location']])) {
1888 $menu = wp_get_nav_menu_object($locations[$args['theme_location']]);
1889 if (isset($menu, $menu->term_id)) {
1890 $menu = $menu->term_id;
1891 }
1892 }
1893 $locations = null;
1894 } else {
1895 $menu = wp_get_nav_menu_object($args['menu']);
1896 if (isset($menu, $menu->term_id)) {
1897 $menu = $menu->term_id;
1898 }
1899 }
1900 }
1901 global $wp_filter;
1902 if ($menu && isset($wp_filter['wp_get_nav_menu_items'], $wp_filter['wp_get_nav_menu_items']->callbacks) && class_exists('WPML_LS_Render',false)) {
1903 /* disable WPML_LS_Render::wp_get_nav_menu_items_filter(), located in wpml/classes/language-switcher/class-wpml-ls-render.php */
1904
1905 $wpml_ls_render = null;
1906 foreach ($wp_filter['wp_get_nav_menu_items']->callbacks[10] as $i => $filter) {
1907 if (is_array($filter['function']) && is_a($filter['function'][0], 'WPML_LS_Render')) {
1908 $wpml_ls_render = $filter;
1909 unset($wp_filter['wp_get_nav_menu_items']->callbacks[10][$i]);
1910 break;
1911 }
1912 }
1913 /* render the LS menu items */
1914 if ($wpml_ls_render !== null) {
1915 $dummy = new stdClass(); /* dummy element, added to check where LS menu items should be displayed */
1916 $dummy->menu_order = null;
1917 $ls_menu_items = $wpml_ls_render['function'][0]->wp_get_nav_menu_items_filter(array($dummy), wp_get_nav_menu_object($menu));
1918 $ls_dummy_position = array_search($dummy, $ls_menu_items);
1919 unset($ls_menu_items[$ls_dummy_position]);
1920 _wp_menu_item_classes_by_context($ls_menu_items);
1921 $args = wp_parse_args($args, array(
1922 'before' => '',
1923 'after' => '',
1924 'link_before' => '',
1925 'link_after' => '',
1926 ));
1927 $ls_output = walk_nav_menu_tree($ls_menu_items, 0, (object) $args);
1928 }
1929 }
1930
1931 if (defined('ICL_LANGUAGE_CODE')) {
1932 $transient_key .= '_' . ICL_LANGUAGE_CODE;
1933 }
1934 if (!empty($menu)) {
1935 $transient_key .= '_' . $menu;
1936 $menu = null;
1937 }
1938 $args = apply_filters('wp_nav_menu_args', $args);
1939 $transient_key .= '_' . json_encode($args);
1940 $transient = Themify_Storage::get($transient_key, 'tf_menu_');
1941
1942 //current page selection
1943 if ($transient !== false && $transient !== '') {
1944 if ( class_exists( 'Themify_Mega_Menu_Walker' ,false) && strpos( $transient, 'has-mega', 10 ) !== false ) {
1945 Themify_Mega_Menu_Walker::preloadCssJs();
1946 }
1947 global $wp_query;
1948 $queried_object = $wp_query->get_queried_object();
1949 if (!empty($queried_object)) {
1950 if (themify_is_shop()) {
1951 $object_id = themify_shop_pageId();
1952 $type = 'page';
1953 } else {
1954 $object_id = (int) $wp_query->queried_object_id;
1955 $type = !empty($queried_object->taxonomy) ? $queried_object->taxonomy : (!empty($queried_object->post_type) ? $queried_object->post_type : '');
1956 }
1957 if ($type !== '') {
1958 $transient = str_replace(array('current-menu-item', 'current-menu-parent', 'current_page_item', 'current-menu-parent', 'current_page_parent', 'current_page_ancestor', 'current-menu-ancestor'), '', $transient);
1959
1960 $replace = 'current-menu-item menu-item-' . $type . '-' . $object_id;
1961 if ($type === 'page') {
1962 $replace .= ' current_page_item';
1963 }
1964
1965 $transient = str_replace('menu-item-' . $type . '-' . $object_id . ' ', $replace . ' ', $transient);
1966 $transient = themify_set_current_menu_nav($transient, $type, $object_id);
1967 }
1968 }
1969
1970 if (!empty($transient) && strpos($transient, 'tf_fa', 10) !== false) {
1971 preg_match_all('/tf_fa\s(.+?)[\"\s]/m', $transient, $match);
1972 if (!empty($match[1])) {
1973 foreach ($match[1] as $m) {//generate svg
1974 $m = explode('-', str_replace('tf-', '', explode(' ', trim($m))[0]));
1975 $prefix = false;
1976
1977 if ($m[0] === 'fas' || $m[0] === 'far' || $m[0] === 'fab') {
1978 $pre = $m[0];
1979 unset($m[0]);
1980 $m = $pre . ' ' . implode('-', $m);
1981 $prefix = 'fa';
1982 } else {
1983 if ($m[0] === 'fontello' || $m[0] === 'la') {
1984 $prefix = $m[0];
1985 }
1986 $m = implode('-', $m);
1987 }
1988 themify_get_icon($m, $prefix);
1989 }
1990 }
1991 }
1992 }
1993 } else {
1994 $transient = false;
1995 }
1996 if ($transient === false) {
1997 $args['echo'] = false;
1998 // Render the menu
1999 add_filter('nav_menu_css_class', 'themify_class_to_nav_menu', 100, 2);
2000 if (empty($args['walker'])) {
2001 add_filter('nav_menu_item_args', 'themify_menu_child_arrow', 100, 2);
2002 add_filter('nav_menu_link_attributes', 'themify_menu_filter_href', 100, 1);
2003 }
2004 $menu = (string) wp_nav_menu($args, 'menu_nav');
2005 unset($args);
2006 /*
2007 if ($menu) {
2008 $menu = themify_make_lazy($menu, false);
2009 }
2010 *
2011 */
2012 if ($cacheDisable === false) {
2013 Themify_Storage::set($transient_key, !$menu ? '' : $menu, MONTH_IN_SECONDS, 'tf_menu_');
2014 }
2015 remove_filter('nav_menu_css_class', 'themify_class_to_nav_menu', 100);
2016 remove_filter('nav_menu_item_args', 'themify_menu_child_arrow', 100);
2017 remove_filter('nav_menu_link_attributes', 'themify_menu_filter_href', 100);
2018 } else {
2019 $menu = (string) $transient;
2020 }
2021
2022 if (isset($ls_output)) {
2023 if ($ls_dummy_position === 0) {
2024 $menu = themify_str_replace_last('</ul>', $ls_output . '</ul>', $menu); /* append as the very last item in the menu */
2025 } else {
2026 $menu = themify_str_replace_first('<li', $ls_output . '<li', $menu); /* prepend the LS to before the very first menu item */
2027 }
2028 $wp_filter['wp_get_nav_menu_items']->callbacks[10][] = $wpml_ls_render;
2029 }
2030
2031 if ( str_contains( $menu, '<!--themify_widget_menu' ) ) {
2032 $menu = preg_replace_callback( '/<!--themify_widget_menu (.+?) -->/', function( $matches ) {
2033 if ( $matches[1] ) {
2034 list( $menu_widget, $item_id ) = explode( ' ', $matches[1] );
2035 return Themify_Widgets_Menu::get_instance()->render_widget(
2036 $menu_widget,
2037 Themify_Widgets_Menu::get_instance()->get_widget_options( $item_id ),
2038 array(
2039 'widget_id' => $item_id // widget_id is required, some widgets use it
2040 )
2041 );
2042 }
2043 }, $menu );
2044 }
2045
2046 if ($isEcho === false) {
2047 return $menu;
2048 }
2049 echo $menu;
2050 }
2051
2052 endif;
2053
2054 function themify_set_current_menu_nav($text, $type, $object_id) {
2055 //parent id
2056 preg_match('/menu-' . $type . '-' . $object_id . '-parent-(\d+)/i', $text, $match);
2057
2058 if (!empty($match[1])) {
2059 $pid = (int) $match[1];
2060 $menuId = get_post_meta($pid, '_menu_item_object_id', true);
2061 if ($menuId) {
2062 $object = get_post_meta($pid, '_menu_item_object', true);
2063 if ($object === 'taxonomy') {
2064 $type = get_post_meta($pid, '_menu_item_type', true);
2065 } else {
2066 $type = $object;
2067 }
2068 $replace = 'current-menu-ancestor current-menu-parent menu-item-' . $type . '-' . $menuId;
2069 if ($object === 'page') {
2070 $replace .= ' current_page_parent current_page_ancestor';
2071 }
2072 $text = str_replace('menu-item-' . $type . '-' . $menuId . ' ', $replace . ' ', $text);
2073 if ($menuId != $object_id) {
2074 $text = themify_set_current_menu_nav($text, $type, $menuId);
2075 }
2076 }
2077 }
2078
2079 return $text;
2080 }
2081
2082 function themify_class_to_nav_menu($classes, $item) {
2083 if (!isset($item->object_id)) {
2084 return $classes;
2085 }
2086
2087 array_unshift($classes, 'menu-item-' . $item->object . '-' . $item->object_id); //need to be first, to have space between classes
2088 if ($item->menu_item_parent != 0) {
2089 $classes[] = 'menu-' . $item->object . '-' . $item->object_id . '-parent-' . $item->menu_item_parent;
2090 }
2091 // Clean up active menu item from the links with hashtag
2092 $hash = strpos($item->url, '#');
2093 if ($hash !== false && $hash !== 0) {
2094 $key = array_search('current-menu-item', $classes);
2095 if (false !== $key) {
2096 unset($classes[$key]);
2097 }
2098 $key = array_search('current_page_item', $classes);
2099 if (false !== $key) {
2100 unset($classes[$key]);
2101 }
2102 }
2103 return $classes;
2104 }
2105
2106 function themify_menu_filter_href(array $atts):array {
2107 if ($atts['href'] === '#') {
2108 $atts['href'] = '';
2109 $atts['role'] = 'button';
2110 $atts['tabindex'] = '0';
2111 }
2112 return $atts;
2113 }
2114
2115 function themify_menu_child_arrow($args, $item) {
2116 $args->link_after = in_array('menu-item-has-children', $item->classes, true) ? '<span class="child-arrow closed" tabindex="-1"></span>' : '';
2117 return $args;
2118 }
2119
2120 if (!function_exists('themify_default_main_nav')) {
2121
2122 /**
2123 * Default Main Nav Function
2124 * @since 1.0.0
2125 */
2126 function themify_default_main_nav($args = []) {
2127 $fallback_args = isset($args['fallback_args']) ? $args['fallback_args'] : [];
2128 $args = themify_parse_args($fallback_args, [
2129 'title_li' => '',
2130 ]);
2131
2132 echo '<ul id="main-nav" class="main-nav tf_clearfix tf_box">';
2133 wp_list_pages($args);
2134 echo '</ul>';
2135 }
2136
2137 }
2138
2139 if (!function_exists('themify_theme_menu_nav')) {
2140
2141 function themify_theme_menu_nav($args = array()) {//deprecated from 2020.06.02,instead of use themify_menu_nav
2142 themify_menu_nav($args);
2143 }
2144
2145 }
2146
2147 /**
2148 * Validates $string to only contain HTML links
2149 *
2150 * Shortcut to wp_kses
2151 *
2152 * @since 4.5.7
2153 * @return string
2154 */
2155 function themify_kses_link(string $string):string {
2156 return wp_kses($string, array(
2157 'a' => array(
2158 'href' => array(),
2159 'title' => array()
2160 ))
2161 );
2162 }
2163