-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeme-functions.php
746 lines (678 loc) · 23.4 KB
/
theme-functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
<?php
/***************************************************************************
* Theme Functions
* ----------------------------------------------------------------------
* DO NOT EDIT THIS FILE
* ----------------------------------------------------------------------
*
* Copyright (C) Themify
* http://themify.me
*
* To add custom PHP functions to the theme, create a new 'custom-functions.php' file in the theme folder.
* They will be added to the theme automatically.
*
***************************************************************************/
/////// Actions ////////
// Setup post, page and additional post types if they exist
add_action( 'after_setup_theme', 'themify_theme_init_types' );
// Build custom panels for post, page and additional post types
add_action( 'init', 'themify_theme_create_custom_panels', 11 );
// Enqueue scripts and styles required by theme
add_action( 'wp_enqueue_scripts', 'themify_theme_enqueue_scripts', 11 );
// Browser compatibility
add_action( 'wp_head', 'themify_ie_enhancements' );
add_action( 'wp_head', 'themify_viewport_tag' );
add_action( 'wp_head', 'themify_ie_standards_compliant');
// Register custom menu
add_action( 'init', 'themify_register_custom_nav');
// Register sidebars
add_action( 'widgets_init', 'themify_theme_register_sidebars' );
/////// Filters ////////
if ( themify_is_transition_active() ) {
// Apply some transition setup
add_filter( 'themify_builder_create_animation_selectors', 'themify_transition_setup' );
// Extend builder inview animation
add_filter( 'themify_builder_animation_inview_selectors', 'themify_extend_animation_selectors' );
}
/**
* Enqueue Stylesheets and Scripts
* @since 1.0.0
*/
function themify_theme_enqueue_scripts() {
global $wp_query, $themify;
// Get theme version for Themify theme scripts and styles
$theme_version = wp_get_theme()->display('Version');
///////////////////
//Enqueue styles
///////////////////
// Themify base styling
wp_enqueue_style( 'theme-style', get_stylesheet_uri(), array(), $theme_version);
if ( themify_is_woocommerce_active() ) {
//Themify shop stylesheet
wp_enqueue_style( 'themify-shop', THEME_URI . '/shop.css');
}
// Themify Media Queries CSS
wp_enqueue_style( 'themify-media-queries', THEME_URI . '/media-queries.css', array(), $theme_version);
// Google Web Fonts embedding
wp_enqueue_style( 'google-fonts', themify_https_esc('http://fonts.googleapis.com/css'). '?family=Raleway:300,400&subset=latin,latin-ext');
///////////////////
//Enqueue scripts
///////////////////
//isotope, used to re-arrange blocks
wp_enqueue_script( 'isotope', THEME_URI . '/js/jquery.isotope.js', array('jquery'), false, true );
//creates infinite scroll
wp_enqueue_script( 'infinitescroll', THEME_URI . '/js/jquery.infinitescroll.min.js', array('jquery'), false, true );
//Slider script
wp_enqueue_script( 'jquery-slider', THEME_URI . '/js/jquery.slider.js', array('jquery'), false, true );
// Nice scroll plugin - Load only in desktop
if ( ! themify_theme_is_mobile() ) {
wp_enqueue_script( 'theme-scroll', THEME_URI . '/js/jquery.scroll.js', array('jquery'), $theme_version, true );
}
// Check transition Effect
if ( themify_is_transition_active() ) {
$bufferPx = apply_filters( 'infinite_scroll_bufferPx', 40 );
$transitionEffect = true;
} else {
$bufferPx = apply_filters( 'infinite_scroll_bufferPx', 500 );
$transitionEffect = false;
}
// Slide mobile navigation menu
wp_enqueue_script( 'off-canvas', THEME_URI . '/js/off-canvas.js', array( 'jquery' ), $theme_version, true );
//auto height iframe plugin
wp_enqueue_script( 'auto-height-iframe', THEME_URI . '/js/jquery.iframe-auto-height.js', array('jquery'), false, true );
// Themify custom lightbox
wp_enqueue_script( 'themibox', THEME_URI . '/js/themibox.js', array('jquery'), $theme_version, true );
// Themify internal scripts
wp_enqueue_script( 'theme-script', THEME_URI . '/js/themify.script.js', array('jquery', 'jquery-effects-core'), $theme_version, true );
// Themify Gallery
wp_enqueue_script( 'themify-gallery', THEMIFY_URI . '/js/themify.gallery.js', array('jquery'), false, true );
// Get auto infinite scroll setting
$autoinfinite = '';
if ( ! themify_get( 'setting-autoinfinite' ) ) {
$autoinfinite = 'auto';
}
// Slider Variables
$data = themify_get_data();
if ( ! isset( $data['setting-feature_box_speed'] ) ) {
$speed = '4000';
} else {
$speed = $data['setting-feature_box_speed'];
}
if ( ! isset( $data['setting-feature_box_effect'] ) ) {
$effect = 'slide';
} else {
$effect = $data['setting-feature_box_effect'];
}
if ( ! isset( $data['setting-feature_box_auto'] ) || '0' == $data['setting-feature_box_auto'] ) {
$slideshowSpeed = 'false';
} else {
$slideshowSpeed = $data['setting-feature_box_auto'];
}
// Inject variable values in gallery script
wp_localize_script( 'theme-script', 'themifyScript', apply_filters('themify_script_vars', array(
// Themify Lightbox/Fullscreen Gallery Parameters
'lightbox' => themify_lightbox_vars_init(),
'lightboxContext' => apply_filters('themify_lightbox_context', '#pagewrap'),
'isTouch' => themify_is_touch()? 'true': 'false',
// Fixed Header Parameter
'fixedHeader' => themify_check('setting-fixed_header_disabled')? '': 'fixed-header',
// Infinite Scroll Parameters
'loadingImg' => THEME_URI . '/images/loading.gif',
'maxPages' => $wp_query->max_num_pages,
'autoInfinite' => $autoinfinite,
'bufferPx' => $bufferPx,
// Slider Parameters
'animation' => $effect,
'animationDuration' => $speed,
'slideshow' => 0,
'slideshowSpeed' => $slideshowSpeed,
// FlyIn Animation
'transitionEffect' => $transitionEffect,
// Header Parallax
'headerParallax' => themify_check('setting-parallax_scrolling_disabled')? false : true,
// Screen size at which horizontal menu is moved into side panel
'smallScreen' => '900',
// Resize refresh rate
'resizeRefresh' => '250',
// Masonry Layout Option
'masonryLayout' => themify_check( 'setting-shop_masonry_disabled' )? '': 'masonry-layout',
)));
if ( themify_is_woocommerce_active() ) {
// Themify shop script
wp_enqueue_script( 'theme-shop', THEME_URI . '/js/themify.shop.js', array('jquery'), false, true );
// Inject variable values in themify.shop.js
// Can be filtered hooking to themify_shop_js_vars
wp_localize_script( 'theme-shop', 'themifyShop', apply_filters(
'themify_shop_js_vars',
array(
'themibox' => array(
'close' => '<a href="#" class="close-lightbox"><i class="icon-flatshop-close"></i></a>',
),
'nonce' => wp_create_nonce( 'themify-ecommerce-nonce' ),
'cartUrl' => WC()->cart->get_cart_url()
)
)
);
}
// WordPress internal script to move the comment box to the right place when replying to a user
if ( is_single() || is_page() ) wp_enqueue_script( 'comment-reply' );
}
/**
* Apply some transition effect
* @param array $setup
* @return array
*/
function themify_transition_setup( $setup ) {
$effect = themify_check('setting-transition_effect_fadein') ? 'fade-in' : 'fly-in';
$products_fly_in = array(
'body.list-post .products .image-left .product-image' => 'fly-in-left',
'body.list-post .products .image-right .product-image' => 'fly-in-right',
'body.list-post .products .image-left .summary' => 'fly-in-right',
'body.list-post .products .image-right .summary' => 'fly-in-left',
'body.list-post .products .image-center .product-image' => 'fly-in-bottom',
'body.list-post .products .image-center .summary' => 'fly-in-bottom'
);
$setup = array(
'selectors' => array(
'.shortcode.col4-3', '.shortcode.col4-2', '.shortcode.col4-1',
'.shortcode.col3-2', '.shortcode.col3-1', '.shortcode.col2-1',
'.loops-wrapper.grid4', '.loops-wrapper.grid3', '.loops-wrapper.grid2', '.loops-wrapper.grid2-thumb'
),
'specificSelectors' => array(
'.grid2 .products .product' => 'fade-in-up',
'.grid3 .products .product' => 'fade-in-up',
'.grid4 .products .product' => 'fade-in-up',
'.loops-wrapper.list-post > .post' => 'fade-in-up'
),
'effect' => $effect
);
if ( 'fade-in' == $effect ) {
$new_fade_in = array();
foreach( $products_fly_in as $selector => $val ) {
$new_fade_in[ $selector ] = $effect;
}
$setup['specificSelectors'] = array_merge( $setup['specificSelectors'], $new_fade_in );
} else {
$setup['specificSelectors'] = array_merge( $setup['specificSelectors'], $products_fly_in );
}
return $setup;
}
/**
* Extend animation selector on inview
* @param string $selector
* @return string
*/
function themify_extend_animation_selectors( $selector ) {
$extends = array(
'.products .product.fade-in-up',
'.list-post > .post.fade-in-up',
'.fly-in-left', '.fly-in-right', '.fly-in-bottom',
'.product-image.fade-in', '.summary.fade-in',
'.shortcode.col4-3', '.shortcode.col4-2', '.shortcode.col4-1',
'.shortcode.col3-2', '.shortcode.col3-1', '.shortcode.col2-1',
);
$selector = array_merge( $selector, $extends );
return $selector;
}
/**
* Check whether element transition effect is ON or Off
* @return boolean
*/
function themify_is_transition_active() {
// check if mobile exclude disabled OR disabled all transition
if ( ( themify_check('setting-transition_effect_mobile_exclude') && themify_is_touch() )
|| themify_check('setting-transition_effect_all_disabled') ) {
return false;
} else {
return true;
}
}
/**
* Add JavaScript files if IE version is lower than 9
* @since 1.0.0
*/
function themify_ie_enhancements() {
echo "\n".'
<!-- media-queries.js -->
<!--[if lt IE 9]>
<script src="' . THEME_URI . '/js/respond.js"></script>
<![endif]-->
<!-- html5.js -->
<!--[if lt IE 9]>
<script src="'.themify_https_esc('http://html5shim.googlecode.com/svn/trunk/html5.js').'"></script>
<![endif]-->
'."\n";
}
/**
* Add viewport tag for responsive layouts
* @since 1.0.0
*/
function themify_viewport_tag() {
echo "\n".'<meta name="viewport" content="width=width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">'."\n";
}
/**
* Make IE behave like a standards-compliant browser
* @since 1.0.0
*/
function themify_ie_standards_compliant() {
echo "\n".'
<!--[if lt IE 9]>
<script src="'.themify_https_esc('http://s3.amazonaws.com/nwapi/nwmatcher/nwmatcher-1.2.5-min.js').'"></script>
<script type="text/javascript" src="'.themify_https_esc('http://cdnjs.cloudflare.com/ajax/libs/selectivizr/1.0.2/selectivizr-min.js').'"></script>
<![endif]-->
'."\n";
}
/***************************************************************************
* Custom Write Panels
***************************************************************************/
///////////////////////////////////////////
// Load Post, Page and Custom Post Types
///////////////////////////////////////////
if ( ! function_exists( 'themify_theme_init_types' ) ) {
/**
* Load custom routines for post, page and custom post types.
*
* @since 1.0.7
*/
function themify_theme_init_types() {
// Load required files for post, page and custom post types where it applies
foreach( array( 'post', 'page', 'slider', 'product' ) as $cpt ) {
require_once "admin/post-type-$cpt.php";
}
}
}
///////////////////////////////////////
// Build Write Panels
///////////////////////////////////////
if ( ! function_exists( 'themify_theme_create_custom_panels' ) ) {
/**
* Initialize custom panel with its definitions
* Custom panel definitions are located in admin/post-type-TYPE.php
*
* @since 1.2.9
*/
function themify_theme_create_custom_panels() {
themify_build_write_panels( apply_filters('themify_theme_meta_boxes',
array(
array(
'name' => __('Post Options', 'themify'), // Name displayed in box
'id' => 'post-options', // Panel ID used for tabs
'options' => themify_theme_post_meta_box(), // Field options
'pages' => 'post' // Pages to show write panel
),
array(
'name' => __('Page Options', 'themify'),
'id' => 'page-options',
'options' => themify_theme_page_meta_box(),
'pages' => 'page'
),
array(
'name' => __('Query Posts', 'themify'),
'id' => 'query-posts',
'options' => themify_theme_query_post_meta_box(),
'pages' => 'page'
),
array(
'name' => __('Query Products', 'themify'),
'id' => 'query-products',
'options' => themify_theme_query_product_meta_box(),
'pages' => 'page'
),
array(
'name' => __('Slider Options', 'themify'),
'id' => 'slider-options',
'options' => themify_theme_slider_meta_box(),
'pages' => 'slider'
),
array(
'name' => __('Slider Style', 'themify'),
'id' => 'slider-style',
'options' => themify_theme_slider_style_meta_box(),
'pages' => 'slider'
),
array(
'name' => __('Product Options', 'themify'),
'id' => 'product-options',
'options' => themify_theme_product_meta_box(),
'pages' => 'product'
)
)
));
}
}
/***************************************************************************
* Custom Functions
***************************************************************************/
///////////////////////////////////////
// Enable WordPress feature image
///////////////////////////////////////
add_theme_support( 'post-thumbnails' );
remove_post_type_support( 'page', 'thumbnail' );
if ( ! function_exists( 'themify_register_custom_nav' ) ) {
/**
* Register Custom Menu Function
* @since 1.0.0
*/
function themify_register_custom_nav() {
register_nav_menus( array(
'main-nav' => __( 'Main Navigation', 'themify' ),
'horizontal-menu' => __( 'Horizontal Menu', 'themify' ),
));
}
}
if ( ! function_exists( 'themify_default_main_nav' ) ) {
/**
* Default Main Nav Function
* @since 1.0.0
*/
function themify_default_main_nav() {
echo '<ul id="main-nav" class="main-nav clearfix">';
wp_list_pages('title_li=');
echo '</ul>';
}
}
if ( ! function_exists( 'themify_theme_register_sidebars' ) ) {
/**
* Register sidebars
* @since 1.0.0
*/
function themify_theme_register_sidebars() {
$sidebars = array(
array(
'name' => __('Sidebar', 'themify'),
'id' => 'sidebar-main',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widgettitle">',
'after_title' => '</h4>',
),
array(
'name' => __('Social Widget - Header', 'themify'),
'id' => 'social-widget',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<strong class="widgettitle">',
'after_title' => '</strong>',
),
array(
'name' => __('Social Widget - Footer', 'themify'),
'id' => 'social-widget-footer',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<strong class="widgettitle">',
'after_title' => '</strong>',
)
);
foreach( $sidebars as $sidebar ) {
register_sidebar( $sidebar );
}
// Footer Sidebars
themify_register_grouped_widgets();
}
}
if ( ! function_exists( 'themify_theme_custom_post_css' ) ) {
/**
* Outputs custom post CSS at the end of a post
* @since 1.0.0
*/
function themify_theme_custom_post_css() {
global $themify;
$css = array();
$rules = array();
$style = '';
if ( ! isset( $themify->google_fonts ) ) {
$themify->google_fonts = '';
}
$post_id = get_the_ID();
$post_type = get_post_type( $post_id );
switch( $post_type ) {
case 'product':
$id = '.post-' . $post_id;
$product_id = '#product-' . $post_id;
if ( is_singular( 'product' ) ) {
$id .= ' .product-single-top';
$pid = '.single ' . $id;
$product_id = '.single ' . $product_id;
}
else {
$pid = $id;
if ( 'list-post' != $themify->post_layout )
$id .= ' .product-bg';
else
$id = '.list-post ' . $id;
}
$rules = array(
$id => array(
array( 'prop' => 'background-color',
'key' => 'background_color'
),
array( 'prop' => 'background-image',
'key' => 'background_image'
),
array( 'prop' => 'background-repeat',
'key' => 'background_repeat'
),
array( 'prop' => 'background-position',
'key' => array('background_position_x', 'background_position_y')
)
),
"$pid h3, $pid h3 a, $pid .product_title, $pid .product_title a, $pid .woocommerce-breadcrumb a, $pid .star-rating" => array(
array( 'prop' => 'color',
'key' => 'title_font_color'
)
),
"$id .summary .price" => array(
array( 'prop' => 'color',
'key' => 'price_font_color'
)
),
"$pid" => array(
array( 'prop' => 'color',
'key' => 'description_font_color'
)
),
"$id .product-description a, $id .product_meta a, $id .quantity .plus, $id .quantity .minus" => array(
array( 'prop' => 'color',
'key' => 'link_font_color'
)
),
"$pid .button.outline" => array(
array( 'prop' => 'color',
'key' => 'link_font_color',
'important' => true
),
array( 'prop' => 'border-color',
'key' => 'link_font_color'
)
),
"$pid .single_add_to_cart_button, $pid .theme_add_to_cart_button, $pid .added_to_cart.button, $pid .quantity input.qty, $product_id .variations select" => array(
array( 'prop' => 'color',
'key' => 'button_font_color'
),
array( 'prop' => 'background-color',
'key' => 'button_background_color'
),
array( 'prop' => 'border-color',
'key' => 'button_background_color'
),
),
);
break;
case 'slider':
$id = '.slider-post.post-' . $post_id;
$rules = array(
$id => array(
array( 'prop' => 'background-color',
'key' => 'background_color'
)
),
"$id .slide-post-title, $id .slide-post-title a" => array(
array( 'prop' => 'color',
'key' => 'title_font_color'
),
array( 'prop' => 'font-size',
'key' => array('title_font_size', 'title_font_size_unit')
),
array( 'prop' => 'font-family',
'key' => 'title_font_family'
),
),
"$id .slide-excerpt" => array(
array( 'prop' => 'color',
'key' => 'text_font_color'
)
),
"$id a" => array(
array( 'prop' => 'color',
'key' => 'link_font_color'
)
),
);
break;
}
foreach ( $rules as $selector => $property ) {
foreach ( $property as $val ) {
$prop = $val['prop'];
$key = $val['key'];
if ( is_array( $key ) ) {
if ( 'fullcover' == themify_get( $key[0] ) ) {
continue;
}
if ( $prop == 'font-size' && themify_check( $key[0] ) ){
$css[$selector][$prop] = $prop .': '. themify_get( $key[0] ) . themify_get($key[1]);
}
if ( $prop == 'background-position' && themify_check( $key[0] ) ) {
$css[$selector][$prop] = $prop .': '. themify_get($key[0]) . ' ' . themify_get($key[1]);
}
} elseif ( themify_check( $key ) && 'default' != themify_get( $key ) ) {
if ( 'fullcover' == themify_get( $key ) ) {
continue;
}
if ( $prop == 'color' || stripos($prop, 'color')) {
$css[$selector][$prop] = $prop .': #'.themify_get( $key );
}
elseif ( $prop == 'background-image' ) {
$css[$selector][$prop] = $prop .': url('.themify_get($key).')';
}
elseif ( $prop == 'font-family' ) {
$font = themify_get( $key );
$css[$selector][$prop] = $prop .': '. $font;
if ( ! in_array( $font, themify_get_web_safe_font_list( true ) ) ) {
$themify->google_fonts .= str_replace(' ', '+', $font.'|');
}
}
else {
$css[$selector][$prop] = $prop .': '. themify_get( $key );
}
}
if ( isset( $val['important'] ) && $val['important'] && isset( $css[$selector] ) && isset( $css[$selector][$prop] ) ) {
$css[$selector][$prop] .= ' !important';
}
}
if ( ! empty( $css[$selector] ) ) {
$style .= "$selector {\n\t" . implode( ";\n\t", $css[$selector] ) . "\n}\n";
}
}
if ( '' != $style ) {
echo "\n<!-- $post_type-$post_id Style -->\n<style>\n$style</style>\n<!-- End $post_type-$post_id Style -->\n";
}
}
}
if ( ! function_exists( 'themify_theme_enqueue_google_fonts' ) ) {
/**
* Enqueue Google Fonts
* @since 1.0.0
*/
function themify_theme_enqueue_google_fonts() {
global $themify;
if ( ! isset( $themify->google_fonts ) || '' == $themify->google_fonts ) return;
$themify->google_fonts = substr( $themify->google_fonts, 0, -1 );
wp_enqueue_style( 'entry-styling-google-fonts', themify_https_esc( 'http://fonts.googleapis.com/css' ). '?family='.$themify->google_fonts );
}
add_action( 'wp_footer', 'themify_theme_enqueue_google_fonts' );
}
if ( ! function_exists( 'themify_theme_comment' ) ) {
/**
* Custom Theme Comment
* @param object $comment Current comment.
* @param array $args Parameters for comment reply link.
* @param int $depth Maximum comment nesting depth.
*/
function themify_theme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li id="comment-<?php comment_ID() ?>" <?php comment_class(); ?>>
<p class="comment-author">
<?php printf('%s <cite>%s</cite>', get_avatar($comment,$size='48'), get_comment_author_link()); ?>
<small class="comment-time">
<?php comment_date( apply_filters('themify_comment_date', '') ); ?> @
<?php comment_time( apply_filters('themify_comment_time', '') ); ?>
<?php edit_comment_link( __('Edit', 'themify'),' [',']'); ?>
</small>
</p>
<div class="commententry">
<?php if ($comment->comment_approved == '0') : ?>
<p><em><?php _e('Your comment is awaiting moderation.', 'themify') ?></em></p>
<?php endif; ?>
<?php comment_text(); ?>
</div>
<p class="reply">
<?php comment_reply_link(array_merge( $args, array('add_below' => 'comment', 'depth' => $depth, 'reply_text' => __( '<i class="fa fa-mail-reply icon-mail-reply"></i>', 'themify' ), 'max_depth' => $args['max_depth']))) ?>
</p>
<?php
}
}
/*************************************************************
* Product Lightbox
*************************************************************/
/**
* Template redirect function
**/
function themify_do_theme_redirect( $url ) {
global $post, $wp_query;
if ( have_posts() ) {
include( $url );
die();
} else {
$wp_query->is_404 = true;
}
}
/**
* Single post lightbox
**/
function themify_single_post_lightbox() {
global $wp;
// locate template single page in lightbox
if ( is_single() && isset( $_GET['post_in_lightbox'] ) && 1 == $_GET['post_in_lightbox'] ) {
// remove admin bar inside iframe
add_filter( 'show_admin_bar', '__return_false' );
$templatefilename = 'single-lightbox.php';
$return_template = locate_template( $templatefilename );
themify_do_theme_redirect($return_template);
}
}
add_action( 'template_redirect', 'themify_single_post_lightbox', 10 );
/**
* Register any extra string for translation with external plugin
* @param $strings
* @return array
*/
function themify_theme_register_strings( $strings ) {
$strings[] = 'setting-store_info_address';
return $strings;
}
add_filter( 'themify_wpml_registered_strings', 'themify_theme_register_strings' );
if( ! function_exists( 'themify_theme_is_mobile' ) ) :
function themify_theme_is_mobile() {
if ( function_exists( 'themify_is_touch' ) ) {
$isPhone = themify_is_touch( 'phone' );
} else {
if ( ! class_exists( 'Themify_Mobile_Detect' ) ) {
require_once THEMIFY_DIR . '/class-themify-mobile-detect.php';
}
$detect = new Themify_Mobile_Detect;
$isPhone = $detect->isMobile() && !$detect->isTablet();
}
return $isPhone;
}
endif;
?>