-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme-functions.php
3137 lines (2823 loc) · 111 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
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/***************************************************************************
* Theme Functions
* ----------------------------------------------------------------------
* DO NOT EDIT THIS FILE
* ----------------------------------------------------------------------
*
* Copyright (C) Themify
* https://themify.me
*
* To add custom PHP functions to the theme, create a child theme (https://themify.me/docs/child-theme) and add it to the child theme functions.php file.
* They will be added to the theme automatically.
*
***************************************************************************/
/////// Actions ////////
// Init post, page and additional post types if they exist
add_action( 'after_setup_theme', 'themify_theme_init_types' );
if (!defined('DOING_AJAX')) {
// Enqueue scripts and styles required by theme
add_action( 'wp_enqueue_scripts', 'themify_theme_enqueue_scripts', 11 );
add_filter('themify_main_script_vars','themify_add_minify_vars',10,1);
add_filter( 'themify_google_fonts', 'themify_theme_google_fonts' );
}
// Browser compatibility
add_action( 'wp_head', 'themify_viewport_tag' );
// Register custom menu
add_action( 'init', 'themify_register_custom_nav');
// Register sidebars
add_action( 'widgets_init', 'themify_theme_register_sidebars' );
// Add additional sidebar
add_action( 'themify_content_after', 'themify_theme_add_sidebar_alt' );
// CPT Sidebars
add_filter( 'themify_post_type_theme_sidebars', 'themify_CPT_sidebar_option', 10, 2 );
// Exclude CPT for sidebar
add_filter( 'themify_exclude_CPT_for_sidebar', 'themify_CPT_exclude_sidebar' );
/////// Filters ////////
add_filter( 'themify_parallax_header', 'themify_disable_parallax_header_on_mobile' );
// Set class on body tag according to layout width
add_filter( 'body_class', 'themify_theme_body_class', 99 );
// Add loading animation
add_action( 'themify_body_start', 'themify_theme_add_section_loader' );
// WooCommerce
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 10 );
add_action( 'woocommerce_after_shop_loop', 'themify_theme_shop_pagination', 10 );
/**
* Enqueue Stylesheets and Scripts
* @since 1.0.0
*/
function themify_theme_enqueue_scripts() {
global $themify;
// Get theme version for Themify theme scripts and styles
$theme_version = wp_get_theme()->display( 'Version' );
$is_fullpage_scroll = themify_theme_is_fullpage_scroll();
$font = themify_area_design( 'font', array(
'default' => '',
'values' => wp_list_pluck( themify_theme_font_design_options(), 'value' ),
) );
$color = themify_area_design( 'color', array(
'default' => '',
'values' => wp_list_pluck( themify_theme_color_design_options(), 'value' ),
) );
$header = themify_theme_get_header_design();
$design_preset_dependency = array( 'theme-style' );
if( themify_is_theme_skin() ) {
$design_preset_dependency[] = 'themify-skin';
}
///////////////////
//Enqueue styles
///////////////////
// Themify base styling
wp_enqueue_style( 'theme-style', themify_enque( THEME_URI . '/style.css' ), array(), $theme_version);
// Themify Media Queries CSS
wp_enqueue_style( 'themify-media-queries', themify_enque(THEME_URI . '/media-queries.css'), array(), $theme_version);
if( themify_is_using_custom_setting( 'font_design' ) || themify_is_using_custom_setting( 'color_design' ) ) {
if( $GLOBALS['themify_customizer']->test_stylesheet() ) {
$design_preset_dependency[] = 'themify-customize';
}
}
if( themify_is_woocommerce_active() ) {
wp_enqueue_style( 'themify-woocommerce', themify_enque(THEME_URI . '/styles/woocommerce.css') );
$design_preset_dependency[] = 'themify-woocommerce';
}
if( $font != '' && $font != 'default' ) {
wp_enqueue_style( 'ultra-font', themify_enque(THEME_URI . '/styles/' . $font . '.css'), $design_preset_dependency );
}
if( $header != '' && $header != 'default' && $header != 'header-none' && $header != 'header-block' ) {
wp_enqueue_style( 'ultra-header', themify_enque(THEME_URI . '/styles/' . $header . '.css'), $design_preset_dependency );
}
if( $color != '' && $color != 'default' ) {
wp_enqueue_style( 'ultra-color', themify_enque(THEME_URI . '/styles/' . $color . '.css'), $design_preset_dependency );
}
// Themify child base styling
if( is_child_theme() ) {
wp_enqueue_style( 'theme-style-child', themify_enque( get_stylesheet_uri() ), array(), $theme_version );
}
///////////////////
//Enqueue scripts
///////////////////
wp_enqueue_script( 'imagesloaded');
if ( $themify->post_layout_type === 'slider' && is_single() ) {
wp_enqueue_script( 'themify-carousel-js' );
}
if ( $is_fullpage_scroll ){
wp_enqueue_style( 'themify-section-scroll', themify_enque(THEME_URI . '/styles/section-scroll.css'), array(), $theme_version);
}
if ( $is_fullpage_scroll && (class_exists('Themify_Builder_Model') && !Themify_Builder_Model::is_front_builder_activate())) {
wp_enqueue_style( 'themify-splitscroll', themify_enque(THEME_URI . '/styles/splitscroll.css'), array(), $theme_version);
wp_enqueue_script( 'themify-fullpage-slimscroll', THEME_URI . '/js/jquery.slimscroll.min.js', array( 'jquery', 'jquery-effects-core' ), $theme_version, true );
wp_enqueue_script( 'themify-fullpage-scrollhorizontal', THEME_URI . '/js/fullpage.scrollHorizontally.min.js', array( 'jquery', 'jquery-effects-core' ), $theme_version, true );
wp_enqueue_script( 'themify-fullpage-scrolloverflow', THEME_URI . '/js/scrolloverflow.min.js', array( 'jquery', 'jquery-effects-core' ), null, true );
if( 'on' !== themify_get('section_scrolling_parallax') ) {
wp_enqueue_script( 'themify-fullpage-parallax-scrolling', THEME_URI . '/js/fullpage.parallax.min.js', array( 'jquery', 'jquery-effects-core' ), $theme_version, true );
}
}
// Slide mobile navigation menu
wp_enqueue_script( 'slide-nav', themify_enque(THEMIFY_URI . '/js/themify.sidemenu.js'), array( 'jquery' ), $theme_version, true );
if ( ( is_home() || is_archive() || themify_is_query_page() || is_search() ) && 'slider' !== $themify->post_layout ) {
// Infinite scroll
wp_enqueue_script( 'infinitescroll', THEME_URI . '/js/jquery.infinitescroll.min.js', array('jquery'), false, true );
}
// Carousel
if ( 'slider' === $themify->post_layout ) {
wp_enqueue_script('themify-carousel-js');
}
// Themify internal scripts
wp_enqueue_script( 'theme-script', themify_enque(THEME_URI . '/js/themify.script.js'), array('jquery'), $theme_version, true );
global $wp_query;
// Prepare JS variables
$themify_script_vars = array(
'themeURI' => THEME_URI,
'lightbox' => themify_lightbox_vars_init(),
'lightboxContext' => apply_filters('themify_lightbox_context', '#pagewrap'),
'fixedHeader' => themify_theme_fixed_header(),
'sticky_header'=>themify_theme_sticky_logo(),
'ajax_nonce' => wp_create_nonce('ajax_nonce'),
'ajax_url' => admin_url( 'admin-ajax.php' ),
// Screen size at which horizontal menu is moved into side panel
'smallScreen' => '760',
// Resize refresh rate
'resizeRefresh' => '250',
'parallaxHeader' => apply_filters( 'themify_parallax_header', true ),
// Infinite Scroll
'loadingImg' => THEME_URI . '/images/loading.gif',
'maxPages' => $wp_query->max_num_pages,
'currentPage' => get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1,
'pageLoaderEffect' => page_loader_status(),
'autoInfinite' => themify_check( 'setting-autoinfinite' ) ? 'no': 'auto',
'bufferPx' => 50,
'infiniteURL' => themify_check( 'setting-infinite-url' ) ? 1 : 0,
'scrollToNewOnLoad' => 'scroll',
'resetFilterOnLoad' => 'reset',
'fullPageScroll' => $is_fullpage_scroll,
'shop_masonry'=> themify_is_woocommerce_active() && themify_get('setting-product_disable_masonry')!=='no'?'yes':'no',
// auto tiles
'tiledata' => array(
'grids' => array(
"post" => themify_is_touch('phone')?false:themify_set_tiles_template(),
"mobile" => array("AA", "..")
),
'default_grid' => 'post',
'small_screen_grid' => 'mobile',
'breakpoint' => 800,
'padding' => 5,
'full_width' => false,
'animate_init' => false,
'animate_resize' => true,
'animate_template' => false
),
'responsiveBreakpoints' => array(
'tablet_landscape' => themify_get('setting-customizer_responsive_design_tablet_landscape', false, true),
'tablet' => themify_get('setting-customizer_responsive_design_tablet', false, true),
'mobile' => themify_get('setting-customizer_responsive_design_mobile', false, true)
)
);
// Pass variable values to JavaScript
wp_localize_script( 'theme-script', 'themifyScript', apply_filters('themify_script_vars', $themify_script_vars ) );
// Collect page variables or use defaults
$page_id = get_queried_object_id();
if($page_id != null) {
$slider_play = get_post_meta( $page_id, 'background_auto', true ) ? get_post_meta( $page_id, 'background_auto', true ) : (themify_check('setting-footer_slider_auto') ? themify_get('setting-footer_slider_auto') : 'yes');
$slider_autoplay = get_post_meta( $page_id, 'background_autotimeout', true ) ? get_post_meta( $page_id, 'background_autotimeout', true ) : (themify_check('setting-footer_slider_autotimeout') ? themify_get('setting-footer_slider_autotimeout') : 5);
$slider_speed = get_post_meta( $page_id, 'background_speed', true ) ? get_post_meta( $page_id, 'background_speed', true ) : (themify_check('setting-footer_slider_speed') ? themify_get('setting-footer_slider_speed') : 500);
$slider_wrap = get_post_meta( $page_id, 'background_wrap', true ) ? get_post_meta( $page_id, 'background_wrap', true ) : 'yes';
$slider_background_mode = get_post_meta( $page_id, 'background_mode', true ) ? get_post_meta( $page_id, 'background_mode', true ) : 'cover';
$slider_background_position = get_post_meta( $page_id, 'background_position', true ) ? get_post_meta( $page_id, 'background_position', true ) : 'center-center';
} else {
$slider_play = 'yes';
$slider_autoplay = 5;
$slider_speed = 500;
$slider_wrap = 'yes';
$slider_background_mode = 'cover';
$slider_background_position = 'center-center';
}
// Header gallery
wp_register_script( 'header-slider', themify_enque(THEME_URI . '/js/themify.header-slider.js'), array( 'jquery' ), false, true );
//Inject variable values in gallery script
wp_localize_script( 'header-slider', 'themifyVars', array(
'play' => $slider_play,
'autoplay' => $slider_autoplay,
'speed' => $slider_speed,
'wrap' => $slider_wrap,
'backgroundMode' => $slider_background_mode,
'backgroundPosition' => $slider_background_position
)
);
// 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' );
}
function themify_add_minify_vars($vars){
$vars['minify']['js']['themify-tiles'] = themify_enque(THEME_URI.'/js/themify-tiles.js',true);
return $vars;
}
/**
* Load Google fonts used by the theme
*
* @return array
*/
function themify_theme_google_fonts( $fonts ) {
$font = themify_area_design( 'font', array(
'default' => '',
'values' => wp_list_pluck( themify_theme_font_design_options(), 'value' ),
) );
/* translators: If there are characters in your language that are not supported by Open Sans, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'themify' ) ) {
$fonts['open-sans'] = 'Open+Sans:400italic,600italic,700italic,400,300,600,700';
}
if( $font == 'theme-font-slab' || $font == 'theme-font-slab-sans' ) {
/* translators: If there are characters in your language that are not supported by Roboto Slab, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Roboto Slab font: on or off', 'themify' ) ) {
$fonts['roboto-slab'] = 'Roboto+Slab:300,700,400';
}
}
if( $font == 'theme-font-serif' || $font == 'theme-font-slab-sans' ) {
/* translators: If there are characters in your language that are not supported by Sorts Mill Goudy, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Sorts Mill Goudy font: on or off', 'themify' ) ) {
$fonts['sorts-mill-goudy'] = 'Sorts+Mill+Goudy:400,400italic';
}
}
return apply_filters( 'themify_theme_google_fonts', $fonts );
}
function themify_is_using_custom_setting( $name ) {
global $post;
if( is_object( $post ) && ( is_singular() || is_single() || is_page() ) && get_post_meta( $post->ID, $name, true ) != '' ) {
if( get_post_meta( $post->ID, $name, true ) != 'default' ) {
return true;
}
}
return false;
}
if (is_admin()) {
add_action('admin_enqueue_scripts', 'themify_admin_script_style');
function themify_admin_script_style() {
wp_enqueue_script('themify-admin-script', themify_enque(THEME_URI . '/admin/js/admin-script.js'));
}
}
//Remove class has-post-thumbnail when hide_image is yes
add_filter('post_class','themify_hide_feature_image',10,1);
function themify_hide_feature_image($classes){
global $themify;
if($themify->hide_image==='yes' && ($index=array_search('has-post-thumbnail', $classes))!==false){
unset($classes[$index]);
}
return $classes;
}
/**
* Check whether fullpage scrolling is enabled
*
* @return bool
* @since 1.5.4
*/
function themify_theme_is_fullpage_scroll() {
static $is_fullpage_scroll = null;
if($is_fullpage_scroll===null){
$is_fullpage_scroll = ( themify_is_touch( 'phone' ) && 'on' !== themify_get( 'section_scrolling_mobile' ) ) || is_search() ? false : 'yes' === themify_get( 'section_full_scrolling' ); // disable fullpage scroll on mobile
$is_fullpage_scroll = apply_filters( 'themify_theme_is_fullpage_scroll', $is_fullpage_scroll );
}
return $is_fullpage_scroll;
}
/**
* Logic for fixed header. Checks, if it applies, custom fields first and then theme settings.
*
* @since 1.0.0
*
* @return string
*/
function themify_theme_fixed_header() {
static $fixed = NULL;
if(is_null($fixed)){
$header = themify_area_design( 'header', array(
'values' => wp_list_pluck( themify_theme_header_design_options(), 'value' ), ) );
if ( in_array( $header, array( 'header-leftpane', 'header-minbar', 'boxed-content', 'none', 'header-rightpane' ) ) ) {
$fixed = '';
return $fixed;
}
if ( is_singular( array( 'post', 'page', 'portfolio' ) ) ) {
$fixed_header_field = themify_get( 'fixed_header' );
if ( 'yes' == $fixed_header_field ) {
$fixed = 'fixed-header';
return $fixed;
} elseif ( 'no' == $fixed_header_field ) {
$fixed = '';
return $fixed;
}
}
$fixed = themify_check( 'setting-fixed_header_disabled' ) ? '' : 'fixed-header';
}
return $fixed;
}
/**
* Disable Parallax header on mobile devices
* @param bool $bool
* @return bool
*/
function themify_disable_parallax_header_on_mobile( $bool ) {
if ( themify_is_touch() ) $bool = false;
return $bool;
}
/**
* Add viewport tag for responsive layouts
* @since 1.0.0
*/
function themify_viewport_tag() {
echo "\n".'<meta name="viewport" content="width=device-width, initial-scale=1">'."\n";
}
/* Custom Write Panels
/***************************************************************************/
///////////////////////////////////////
// Build Write Panels
///////////////////////////////////////
if ( ! function_exists( 'themify_theme_init_types' ) ) {
/**
* Initialize custom panel with its definitions
* Custom panel definitions are located in admin/post-type-TYPE.php
* @since 1.0.0
*/
function themify_theme_init_types() {
// Load required files for post, page and custom post types where it applies
foreach ( array( 'post', 'page', 'portfolio' ) as $type ) {
require_once( "admin/post-type-$type.php" );
}
}
}
function themify_theme_setup_metaboxes( $meta_boxes, $post_type ) {
if( ! in_array( $post_type, array( 'post', 'page', 'portfolio', 'product' ) ) ) {
return $meta_boxes;
}
/**
* Navigation menus used in page custom panel to specify a custom menu for the page.
* @since 1.0.0
* @var array
*/
$nav_menus = array( array( 'name' => '', 'value' => '', 'selected' => true ) );
foreach ( get_terms( 'nav_menu' ) as $menu ) {
$nav_menus[] = array( 'name' => $menu->name, 'value' => $menu->slug );
}
/**
* Options for header design
* @since 1.0.0
* @var array
*/
$header_design_options = themify_theme_header_design_options();
/**
* Options for footer design
* @since 1.0.0
* @var array
*/
$footer_design_options = themify_theme_footer_design_options();
/**
* Options for font design
* @since 1.0.0
* @var array
*/
$font_design_options = themify_theme_font_design_options();
/**
* Options for color design
* @since 1.0.0
* @var array
*/
$color_design_options = themify_theme_color_design_options();
$entry_id = isset( $_GET['post'] ) ? $_GET['post'] : null;
$background_slider = false;
if ( $entry_id ) {
$background_slider = ( get_post_meta( $entry_id, 'header_wrap', true ) == '' && get_post_meta( $entry_id, 'background_gallery', true ) != '' );
$background_mode = get_post_meta( $entry_id,'background_mode', true );
}
if ( ! isset( $background_mode ) || ! $background_mode ) {
$background_mode = 'fullcover';
}
if( $post_type == 'post' ) {
$theme_metaboxes = array(
array(
'name' => __( 'Post Options', 'themify' ),
'id' => 'post-options',
'options' => themify_theme_post_meta_box( array(
'nav_menus' => $nav_menus,
) ),
'pages' => 'post'
),
array(
'name' => __( 'Page Appearance', 'themify' ),
'id' => 'post-theme-design',
'options' => themify_theme_page_theme_design_meta_box( array(
'header_design_options' => $header_design_options,
'footer_design_options' => $footer_design_options,
'font_design_options' => $font_design_options,
'color_design_options' => $color_design_options,
'background_slider' => $background_slider,
'background_mode' => $background_mode,
) ),
'pages' => 'post'
),
);
} elseif( $post_type == 'page' ) {
$theme_metaboxes = array(
array(
'name' => __( 'Page Options', 'themify' ),
'id' => 'page-options',
'options' => themify_theme_page_meta_box( array(
'nav_menus' => $nav_menus,
'header_design_options' => $header_design_options,
'footer_design_options' => $footer_design_options,
'font_design_options' => $font_design_options,
'color_design_options' => $color_design_options,
) ),
'pages' => 'page'
),
array(
'name' => __( 'Page Appearance', 'themify' ),
'id' => 'page-theme-design',
'options' => themify_theme_page_theme_design_meta_box( array(
'header_design_options' => $header_design_options,
'footer_design_options' => $footer_design_options,
'font_design_options' => $font_design_options,
'color_design_options' => $color_design_options,
'background_slider' => $background_slider,
'background_mode' => $background_mode,
) ),
'pages' => 'page'
),
array(
'name' => __( 'Query Posts', 'themify' ),
'id' => 'query-posts',
'options' => themify_theme_query_post_meta_box(),
'pages' => 'page',
'display_callback' => 'themify_wc_shop_admin_check',
),
);
if( post_type_exists( 'portfolio' ) ) {
$theme_metaboxes[] = array(
'name' => __( 'Query Portfolios', 'themify' ),
'id' => 'query-portfolio',
'options' => themify_theme_query_portfolio_meta_box(),
'pages' => 'page'
);
}
} elseif( $post_type == 'portfolio' ) {
$theme_metaboxes = array(
array(
'name' => __( 'Portfolio Options', 'themify' ),
'id' => 'portfolio-options',
'options' => themify_theme_portfolio_meta_box( array(
'nav_menus' => $nav_menus,
'header_design_options' => $header_design_options,
'footer_design_options' => $footer_design_options,
'font_design_options' => $font_design_options,
'color_design_options' => $color_design_options,
) ),
'pages' => 'portfolio'
),
array(
'name' => __( 'Page Appearance', 'themify' ),
'id' => 'portfolio-theme-design',
'options' => themify_theme_page_theme_design_meta_box( array(
'header_design_options' => $header_design_options,
'footer_design_options' => $footer_design_options,
'font_design_options' => $font_design_options,
'color_design_options' => $color_design_options,
'background_slider' => $background_slider,
'background_mode' => $background_mode,
) ),
'pages' => 'portfolio'
),
);
} elseif( $post_type == 'product' ) {
$theme_metaboxes = array(
array(
'name' => __( 'Page Appearance', 'themify' ),
'id' => 'product-theme-design',
'options' => themify_theme_page_theme_design_meta_box( array(
'header_design_options' => $header_design_options,
'footer_design_options' => $footer_design_options,
'font_design_options' => $font_design_options,
'color_design_options' => $color_design_options,
'background_slider' => $background_slider,
'background_mode' => $background_mode,
) ),
'pages' => 'product'
),
);
}
return isset( $theme_metaboxes ) ? array_merge( $theme_metaboxes, $meta_boxes ) : $meta_boxes;
}
add_filter( 'themify_metabox/fields/themify-meta-boxes', 'themify_theme_setup_metaboxes', 10, 2 );
/* Custom Functions
/***************************************************************************/
///////////////////////////////////////
// Enable WordPress feature image
///////////////////////////////////////
add_theme_support( 'post-thumbnails' );
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' ),
'footer-nav' => __( 'Footer Navigation', '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' => __('Sidebar Narrow', 'themify'),
'id' => 'sidebar-alt',
'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', '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' => __( 'Footer Social Widget', 'themify' ),
'id' => 'footer-social-widget',
'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 );
}
// Header Sidebars
themify_register_grouped_widgets( array(
'headerwidget-4col' => 4,
'headerwidget-3col' => 3,
'headerwidget-2col' => 2,
'headerwidget-1col' => 1,
'none' => 0
), array(
'sidebar_name' => __( 'Header Widget', 'themify' ),
'sidebar_id' => 'header-widget',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widgettitle">',
'after_title' => '</h4>',
), 'setting-header_widgets', 'headerwidget-3col' );
// Footer Sidebars
themify_register_grouped_widgets();
}
}
if( ! function_exists('themify_theme_add_sidebar_alt') ) {
/**
* Includes second sidebar
* @since 1.0.0
*/
function themify_theme_add_sidebar_alt() {
global $themify;
if( 'sidebar2' == $themify->layout || 'sidebar2 content-left' == $themify->layout || 'sidebar2 content-right' == $themify->layout ): ?>
<?php get_template_part( 'includes/sidebar-alt'); ?>
<?php endif;
}
}
if( ! function_exists('themify_CPT_sidebar_option') ) {
/**
* Includes second sidebar
* @since 2.0.1
*/
function themify_CPT_sidebar_option($option, $default = true) {
$option = array();
if ($default) {
$option[] = array('value' => 'default', 'img' => 'images/layout-icons/default.png', 'selected' => true, 'title' => __('Default', 'themify'));
}
array_push($option,
array('value' => 'sidebar1', 'img' => 'images/layout-icons/sidebar1.png', 'selected' => true, 'title' => __('Sidebar Right', 'themify')),
array('value' => 'sidebar1 sidebar-left', 'img' => 'images/layout-icons/sidebar1-left.png', 'title' => __('Sidebar Left', 'themify')),
array('value' => 'sidebar2', 'img' => 'images/layout-icons/sidebar2.png', 'title' => __('Left and Right', 'themify')),
array('value' => 'sidebar2 content-left', 'img' => 'images/layout-icons/sidebar2-content-left.png', 'title' => __('2 Right Sidebars', 'themify')),
array('value' => 'sidebar2 content-right', 'img' => 'images/layout-icons/sidebar2-content-right.png', 'title' => __('2 Left Sidebars', 'themify')),
array('value' => 'sidebar-none', 'img' => 'images/layout-icons/sidebar-none.png', 'title' => __('No Sidebar', 'themify'))
);
return $option;
}
}
if( ! function_exists('themify_CPT_exclude_sidebar') ) {
/**
* Includes second sidebar
* @since 2.0.1
*/
function themify_CPT_exclude_sidebar($CPT = array()) {
$ultra = array('portfolio');
if(empty($CPT)){
$CPT = array('post', 'page', 'attachment', 'tbuilder_layout', 'tbuilder_layout_part', 'section');
}
if(themify_is_woocommerce_active()){
$ultra[] = 'product';
}
$CPT = array_merge($CPT, $ultra);
return $CPT;
}
}
if ( ! function_exists( 'themify_theme_comment' ) ) {
/**
* Custom Theme Comment
*
* @since 1.0.0
*
* @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() ?>">
<p class="comment-author">
<?php echo get_avatar( $comment, $size = '48' ); ?>
<cite <?php comment_class(); ?>><span <?php comment_class(); ?>><?php echo get_comment_author_link(); ?></span></cite>
<br/>
<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' => __( 'Reply', 'themify' ), 'max_depth' => $args['max_depth']))) ?>
</p>
<?php
}
}
if ( ! function_exists( 'themify_theme_has_submenu' ) ) {
/**
* Sets custom class if menu item has a submenu.
*
* @since 1.0.0
*
* @param array $sorted_menu_items The menu items to filter.
*
* @return array The filtered menu items.
*/
function themify_theme_has_submenu( $sorted_menu_items ) {
$last_top = 0;
foreach ( $sorted_menu_items as $key => $obj ) {
if ( 0 == $obj->menu_item_parent ) {
$last_top = $key;
} else {
$sorted_menu_items[$last_top]->classes['has-sub-menu'] = 'has-sub-menu';
}
}
return $sorted_menu_items;
}
add_filter( 'wp_nav_menu_objects', 'themify_theme_has_submenu', 10 );
}
if ( ! function_exists( 'themify_allow_menu_highlight' ) ) {
/**
* Enable menu link highlight.
*
* @since 1.9.9
*
* @param boolean $allow.
*
* @return boolean.
*/
function themify_allow_menu_highlight( $allow ) {
return true;
}
add_filter( 'themify_menu_highlight_link', 'themify_allow_menu_highlight', 10 );
}
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;
if (
( is_singular() && ( in_array( get_post_type(), array( 'post', 'page', 'portfolio', 'product' ) ) ) )
|| ( themify_is_shop() )
) {
$post_id = get_the_ID();
$queried_id = get_queried_object_id();
if( ! empty( $post_id ) && ! empty( $queried_id ) && $post_id !== $queried_id ) {
global $post;
$old_post = $post;
$post = get_post( $queried_id ) ? get_post( $queried_id ) : $post;
}
if ( is_page() ) {
$entry_id = '.page-id-' . $post_id;
$archive_entry_id = '.page-' . $post_id;
} elseif ( themify_is_shop() ) {
$entry_id = '.woocommerce-page';
$archive_entry_id = '.post-' . $post_id;
} else {
$entry_id = '.postid-' . $post_id;
$archive_entry_id = '.post-' . $post_id;
}
$headerwrap = $entry_id . ' #headerwrap';
$site_logo = $entry_id . ' #site-logo';
$site_description = $entry_id . ' #site-description';
$main_nav = $entry_id . ' #main-nav';
$header_widget = $entry_id . ' .header-widget';
$social_widget = $entry_id . ' .social-widget';
$header_search = $entry_id . ' #searchform-wrap';
$css = array();
$style = '';
$rules = array();
$header_type = themify_get( 'header_wrap' );
if ( 'transparent' != $header_type ) {
$rules = array(
"$entry_id #site-logo span:after, $entry_id #headerwrap #searchform, $entry_id #main-nav .current_page_item a, $entry_id #main-nav .current-menu-item a" => array(
array(
'prop' => 'border-color',
'key' => 'headerwrap_text_color'
),
),
);
if ( 'solid' === $header_type || !$header_type || 'video' === $header_type ) {
$rules[$headerwrap] = array(
array(
'prop' => 'background-color',
'key' => 'background_color'
),
array(
'prop' => 'background-image',
'key' => 'background_image'
),
array(
'prop' => 'background-repeat',
'key' => 'background_repeat',
'dependson' => array(
'prop' => 'background-image',
'key' => 'background_image'
),
),
);
}
}
$custom_color = themify_theme_get( 'color_scheme_mode', 'color-presets' ) == 'color-custom';
$custom_font = themify_theme_get( 'typography_mode' ) == 'typography-custom';
if ( ( is_singular() || themify_is_shop() ) && ($custom_color || $custom_font) ) {
if($custom_font){
$rules = array_merge( $rules, array(
'.skin-styles' => array(
array(
'prop' => 'font-family',
'key' => 'body_font'
),
array(
'prop' => 'color',
'key' => 'body_text_color'
),
),
'.skin-styles .post-meta, .skin-styles #site-description, .skin-styles .post-date .year, .skin-styles .post-date .month, .skin-styles .post-date .day, .skin-styles .loops-wrapper .entry-content' => array(
array(
'prop' => 'font-family',
'key' => 'body_font'
),
),
));
// No space between .skin-styles and $main_nav because the latter has the body classes prepended.
$rules[".skin-styles a, .skin-styles .post-nav .arrow"] = array(
array(
'prop' => 'color',
'key' => 'body_link_color'
),
);
$rules['.skin-styles h1, .skin-styles h2, .skin-styles h3, .skin-styles h4, .skin-styles h5, .skin-styles h6'] = array(
array(
'prop' => 'color',
'key' => 'heading_color'
),
array(
'prop' => 'font-family',
'key' => 'heading_font'
),
);
}
if($custom_color){
// Accent Background Color
$rules['.skin-styles #headerwrap,.skin-styles #footerwrap,.skin-styles input[type=reset],.skin-styles input[type=submit],.skin-styles button,.skin-styles #respond #cancel-comment-reply-link,.skin-styles .commentlist .comment-reply-link,.skin-styles.footer-horizontal-left .back-top .arrow-up a,.skin-styles.footer-horizontal-right .back-top .arrow-up a,.skin-styles.footer-left-col .back-top .arrow-up a,.skin-styles.footer-right-col .back-top .arrow-up a,.skin-styles.woocommerce #content input.button,.skin-styles.woocommerce #respond input#submit,.skin-styles.woocommerce a.button,.skin-styles.woocommerce button.button,.skin-styles.woocommerce input.button,.skin-styles.woocommerce-page #content input.button,.skin-styles.woocommerce-page #respond input#submit,.skin-styles.woocommerce-page a.button,.skin-styles.woocommerce-page button.button,.skin-styles.woocommerce-page input.button,.skin-styles.woocommerce #content input.button.alt,.skin-styles.woocommerce #respond input#submit.alt,.skin-styles.woocommerce a.button.alt,.skin-styles.woocommerce button.button.alt,.skin-styles.woocommerce input.button.alt,.skin-styles.woocommerce-page #content input.button.alt,.skin-styles.woocommerce-page #respond input#submit.alt,.skin-styles.woocommerce-page a.button.alt,.skin-styles.woocommerce-page button.button.alt,.skin-styles.woocommerce-page input.button.alt,.skin-styles.woocommerce ul.products li.product .add_to_cart_button,.skin-styles.woocommerce-page ul.products li.product .add_to_cart_button,.skin-styles.woocommerce ul.products li.product .button[data-product_id],.skin-styles.woocommerce-page ul.products li.product .button[data-product_id],.skin-styles.woocommerce span.onsale,.skin-styles.woocommerce-page span.onsale,.skin-styles.woocommerce ul.products li.product .onsale,.skin-styles.woocommerce-page ul.products li.product .onsale,.skin-styles.woocommerce-checkout #payment div.payment_box,.skin-styles.woocommerce #content nav.woocommerce-pagination ul li a:focus,.skin-styles.woocommerce #content nav.woocommerce-pagination ul li a:hover,.skin-styles.woocommerce #content nav.woocommerce-pagination ul li span.current,.skin-styles.woocommerce nav.woocommerce-pagination ul li a:focus,.skin-styles.woocommerce nav.woocommerce-pagination ul li a:hover,.skin-styles.woocommerce nav.woocommerce-pagination ul li span.current,.skin-styles.woocommerce-page #content nav.woocommerce-pagination ul li a:focus,.skin-styles.woocommerce-page #content nav.woocommerce-pagination ul li a:hover,.skin-styles.woocommerce-page #content nav.woocommerce-pagination ul li span.current,.skin-styles.woocommerce-page nav.woocommerce-pagination ul li a:focus,.skin-styles.woocommerce-page nav.woocommerce-pagination ul li a:hover,.skin-styles.woocommerce-page nav.woocommerce-pagination ul li span.current,.skin-styles.woocommerce #content table.cart a.remove:hover,.skin-styles.woocommerce table.cart a.remove:hover,.skin-styles.woocommerce-page #content table.cart a.remove:hover,.skin-styles.woocommerce-page table.cart a.remove:hover'] = array(
array(
'prop' => 'background-color',
'key' => 'scheme_background'
),
);
// Accent Font Color
$rules['.skin-styles #headerwrap,.skin-styles #footerwrap,.footer-widgets .widgettitle,.skin-styles #site-description,.skin-styles input[type=reset],.skin-styles input[type=submit],.skin-styles button,.skin-styles #respond #cancel-comment-reply-link,.skin-styles .commentlist .comment-reply-link,.skin-styles .post-title a,.skin-styles #main-nav > li > a,.skin-styles #main-nav > .current_page_item > a,.skin-styles #main-nav > .current-menu-item > a,.skin-styles #main-nav > li > a:hover,.skin-styles.footer-horizontal-left .back-top .arrow-up a,.skin-styles.footer-horizontal-right .back-top .arrow-up a,.skin-styles.footer-left-col .back-top .arrow-up a,.skin-styles.footer-right-col .back-top .arrow-up a,.skin-styles.woocommerce #content input.button,.skin-styles.woocommerce #respond input#submit,.skin-styles.woocommerce a.button,.skin-styles.woocommerce button.button,.skin-styles.woocommerce input.button,.skin-styles.woocommerce-page #content input.button,.skin-styles.woocommerce-page #respond input#submit,.skin-styles.woocommerce-page a.button,.skin-styles.woocommerce-page button.button,.skin-styles.woocommerce-page input.button,.skin-styles.woocommerce #content input.button.alt,.skin-styles.woocommerce #respond input#submit.alt,.skin-styles.woocommerce a.button.alt,.skin-styles.woocommerce button.button.alt,.skin-styles.woocommerce input.button.alt,.skin-styles.woocommerce-page #content input.button.alt,.skin-styles.woocommerce-page #respond input#submit.alt,.skin-styles.woocommerce-page a.button.alt,.skin-styles.woocommerce-page button.button.alt,.skin-styles.woocommerce-page input.button.alt,.skin-styles.woocommerce ul.products li.product .add_to_cart_button,.skin-styles.woocommerce-page ul.products li.product .add_to_cart_button,.skin-styles.woocommerce ul.products li.product .button[data-product_id],.skin-styles.woocommerce-page ul.products li.product .button[data-product_id],.skin-styles.woocommerce span.onsale,.skin-styles.woocommerce-page span.onsale,.skin-styles.woocommerce ul.products li.product .onsale,.skin-styles.woocommerce-page ul.products li.product .onsale,.skin-styles.woocommerce-checkout #payment div.payment_box,.skin-styles.woocommerce #content nav.woocommerce-pagination ul li a:focus,.skin-styles.woocommerce #content nav.woocommerce-pagination ul li a:hover,.skin-styles.woocommerce #content nav.woocommerce-pagination ul li span.current,.skin-styles.woocommerce nav.woocommerce-pagination ul li a:focus,.skin-styles.woocommerce nav.woocommerce-pagination ul li a:hover,.skin-styles.woocommerce nav.woocommerce-pagination ul li span.current,.skin-styles.woocommerce-page #content nav.woocommerce-pagination ul li a:focus,.skin-styles.woocommerce-page #content nav.woocommerce-pagination ul li a:hover,.skin-styles.woocommerce-page #content nav.woocommerce-pagination ul li span.current,.skin-styles.woocommerce-page nav.woocommerce-pagination ul li a:focus,.skin-styles.woocommerce-page nav.woocommerce-pagination ul li a:hover,.skin-styles.woocommerce-page nav.woocommerce-pagination ul li span.current,.skin-styles.woocommerce #content table.cart a.remove:hover,.skin-styles.woocommerce table.cart a.remove:hover,.skin-styles.woocommerce-page #content table.cart a.remove:hover,.skin-styles.woocommerce-page table.cart a.remove:hover'] = array(
array(
'prop' => 'color',
'key' => 'scheme_color'
),
);
// Accent Link Color
$rules['.skin-styles #headerwrap a, .skin-styles #footerwrap a, .skin-styles .sidemenu a, .skin-styles .post-nav .arrow, .skin-styles .widget .social-links a, .skin-styles .widget .social-links a:hover, .skin-styles .footer-nav li a'] = array(
array(
'prop' => 'color',
'key' => 'scheme_link'
),
);
$rules['.skin-styles.woocommerce .woocommerce-error,.skin-styles.woocommerce .woocommerce-info,.skin-styles.woocommerce .woocommerce-message,.skin-styles.woocommerce-page .woocommerce-error,.skin-styles.woocommerce-page .woocommerce-info,.skin-styles.woocommerce-page .woocommerce-message'] = array(
array(
'prop' => 'border-top-color',
'key' => 'scheme_background'
),
);
$rules['.skin-styles.woocommerce-checkout #payment div.payment_box:after'] = array(
array(
'prop' => 'border-bottom-color',
'key' => 'scheme_background'
),
);
$rules['.skin-styles .post-title a:hover'] = array(
array(
'prop' => 'color',
'key' => 'scheme_background'
),
);
}
}
// Body background color, image and image repeat is not influenced by presets.
$body_bg_color_image = array(
array(
'prop' => 'background-color',
'key' => 'body_background_color'
),
array(
'prop' => 'background-image',
'key' => 'body_background_image'
),
array(
'prop' => 'background-repeat',
'key' => 'body_background_repeat',
'dependson' => array(
'prop' => 'background-image',
'key' => 'body_background_image'
),
),
);
if ( isset( $rules['.skin-styles'] ) ) {
// If there is some preset styling, merge body background color and image
$rules['.skin-styles'] = array_merge( $rules['.skin-styles'], $body_bg_color_image);
} else {
// Otherwise create the key and assign body background color and image
$rules['.skin-styles'] = $body_bg_color_image;
}
$rules["$headerwrap, $site_logo, $site_description"] = array(