-
Notifications
You must be signed in to change notification settings - Fork 11
/
functions.php
8507 lines (7468 loc) · 330 KB
/
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
if ( ! isset( $content_width ) ) $content_width = 1080;
function et_setup_theme() {
global $themename, $shortname, $et_store_options_in_one_row, $default_colorscheme;
$themename = 'Divi';
$shortname = 'divi';
$et_store_options_in_one_row = true;
$default_colorscheme = "Default";
$template_directory = get_template_directory();
$theme_version = et_get_theme_version();
define( 'ET_CORE_VERSION', $theme_version );
require_once( $template_directory . '/core/init.php' );
et_core_setup( get_template_directory_uri() );
require_once( $template_directory . '/epanel/custom_functions.php' );
require_once( $template_directory . '/includes/functions/choices.php' );
require_once( $template_directory . '/includes/functions/sanitization.php' );
require_once( $template_directory . '/includes/functions/sidebars.php' );
load_theme_textdomain( 'Divi', $template_directory . '/lang' );
require_once( $template_directory . '/epanel/core_functions.php' );
require_once( $template_directory . '/post_thumbnails_divi.php' );
include( $template_directory . '/includes/widgets.php' );
register_nav_menus( array(
'primary-menu' => esc_html__( 'Primary Menu', 'Divi' ),
'secondary-menu' => esc_html__( 'Secondary Menu', 'Divi' ),
'footer-menu' => esc_html__( 'Footer Menu', 'Divi' ),
) );
// don't display the empty title bar if the widget title is not set
remove_filter( 'widget_title', 'et_widget_force_title' );
remove_filter( 'body_class', 'et_add_fullwidth_body_class' );
add_action( 'wp_enqueue_scripts', 'et_add_responsive_shortcodes_css', 11 );
// Declare theme supports
add_theme_support( 'title-tag' );
add_theme_support( 'post-formats', array(
'video', 'audio', 'quote', 'gallery', 'link'
) );
add_theme_support( 'woocommerce' );
remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
add_action( 'woocommerce_before_main_content', 'et_divi_output_content_wrapper', 10 );
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
add_action( 'woocommerce_after_main_content', 'et_divi_output_content_wrapper_end', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
// deactivate page templates and custom import functions
remove_action( 'init', 'et_activate_features' );
remove_action('admin_menu', 'et_add_epanel');
// Load editor styling
add_editor_style( 'css/editor-style.css' );
}
add_action( 'after_setup_theme', 'et_setup_theme' );
function et_theme_epanel_reminder(){
global $shortname, $themename;
$documentation_url = 'http://www.elegantthemes.com/gallery/divi/readme.html';
$documentation_option_name = $shortname . '_2_4_documentation_message';
if ( false === et_get_option( $shortname . '_logo' ) && false === et_get_option( $documentation_option_name ) ) {
$message = sprintf(
et_get_safe_localization( __( 'Welcome to Divi! Before diving in to your new theme, please visit the <a style="color: #fff; font-weight: bold;" href="%1$s" target="_blank">Divi Documentation</a> page for access to dozens of in-depth tutorials.', $themename ) ),
esc_url( $documentation_url )
);
printf(
'<div class="notice is-dismissible" style="background-color: #6C2EB9; color: #fff; border-left: none;">
<p>%1$s</p>
</div>',
$message
);
et_update_option( $documentation_option_name, 'triggered' );
}
}
add_action( 'admin_init', 'et_theme_epanel_reminder' );
if ( ! function_exists( 'et_divi_fonts_url' ) ) :
function et_divi_fonts_url() {
$fonts_url = '';
/* 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.
*/
$open_sans = _x( 'on', 'Open Sans font: on or off', 'Divi' );
if ( 'off' !== $open_sans ) {
$font_families = array();
if ( 'off' !== $open_sans )
$font_families[] = 'Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800';
$protocol = is_ssl() ? 'https' : 'http';
$query_args = array(
'family' => implode( '%7C', $font_families ),
'subset' => 'latin,latin-ext',
);
$fonts_url = add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" );
}
return $fonts_url;
}
endif;
function et_divi_load_fonts() {
$fonts_url = et_divi_fonts_url();
if ( ! empty( $fonts_url ) )
wp_enqueue_style( 'divi-fonts', esc_url_raw( $fonts_url ), array(), null );
}
add_action( 'wp_enqueue_scripts', 'et_divi_load_fonts' );
function et_add_home_link( $args ) {
// add Home link to the custom menu WP-Admin page
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'et_add_home_link' );
function et_divi_load_scripts_styles(){
global $wp_styles;
$template_dir = get_template_directory_uri();
$theme_version = et_get_theme_version();
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
$dependencies_array = array( 'jquery', 'et-jquery-touch-mobile' );
// load 'jquery-effects-core' if SlideIn/Fullscreen header used or if customizer opened
if ( is_customize_preview() || 'slide' === et_get_option( 'header_style', 'left' ) || 'fullscreen' === et_get_option( 'header_style', 'left' ) ) {
$dependencies_array[] = 'jquery-effects-core';
}
wp_enqueue_script( 'et-jquery-touch-mobile', $template_dir . '/includes/builder/scripts/jquery.mobile.custom.min.js', array( 'jquery' ), $theme_version, true );
wp_enqueue_script( 'divi-custom-script', $template_dir . '/js/custom.js', $dependencies_array , $theme_version, true );
if ( 'on' === et_get_option( 'divi_smooth_scroll', false ) ) {
wp_enqueue_script( 'smooth-scroll', $template_dir . '/js/smoothscroll.js', array( 'jquery' ), $theme_version, true );
}
$et_gf_enqueue_fonts = array();
$et_gf_heading_font = sanitize_text_field( et_get_option( 'heading_font', 'none' ) );
$et_gf_body_font = sanitize_text_field( et_get_option( 'body_font', 'none' ) );
$et_gf_button_font = sanitize_text_field( et_get_option( 'all_buttons_font', 'none' ) );
$et_gf_primary_nav_font = sanitize_text_field( et_get_option( 'primary_nav_font', 'none' ) );
$et_gf_secondary_nav_font = sanitize_text_field( et_get_option( 'secondary_nav_font', 'none' ) );
$et_gf_slide_nav_font = sanitize_text_field( et_get_option( 'slide_nav_font', 'none' ) );
$site_domain = get_locale();
$et_one_font_languages = et_get_one_font_languages();
if ( 'none' != $et_gf_heading_font ) $et_gf_enqueue_fonts[] = $et_gf_heading_font;
if ( 'none' != $et_gf_body_font ) $et_gf_enqueue_fonts[] = $et_gf_body_font;
if ( 'none' != $et_gf_button_font ) $et_gf_enqueue_fonts[] = $et_gf_button_font;
if ( 'none' != $et_gf_primary_nav_font ) $et_gf_enqueue_fonts[] = $et_gf_primary_nav_font;
if ( 'none' != $et_gf_secondary_nav_font ) $et_gf_enqueue_fonts[] = $et_gf_secondary_nav_font;
if ( 'none' != $et_gf_slide_nav_font ) $et_gf_enqueue_fonts[] = $et_gf_slide_nav_font;
if ( isset( $et_one_font_languages[$site_domain] ) ) {
$et_gf_font_name_slug = strtolower( str_replace( ' ', '-', $et_one_font_languages[$site_domain]['language_name'] ) );
wp_enqueue_style( 'et-gf-' . $et_gf_font_name_slug, $et_one_font_languages[$site_domain]['google_font_url'], array(), null );
} else if ( ! empty( $et_gf_enqueue_fonts ) ) {
foreach ( $et_gf_enqueue_fonts as $single_font ) {
et_builder_enqueue_font( $single_font );
}
}
/*
* Loads the main stylesheet.
*/
wp_enqueue_style( 'divi-style', get_stylesheet_uri(), array(), $theme_version );
}
add_action( 'wp_enqueue_scripts', 'et_divi_load_scripts_styles' );
function et_add_mobile_navigation(){
if ( is_customize_preview() || ( 'slide' !== et_get_option( 'header_style', 'left' ) && 'fullscreen' !== et_get_option( 'header_style', 'left' ) ) ) {
printf(
'<div id="et_mobile_nav_menu">
<div class="mobile_nav closed">
<span class="select_page">%1$s</span>
<span class="mobile_menu_bar mobile_menu_bar_toggle"></span>
</div>
</div>',
esc_html__( 'Select Page', 'Divi' )
);
}
}
add_action( 'et_header_top', 'et_add_mobile_navigation' );
function et_add_viewport_meta(){
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />';
}
add_action( 'wp_head', 'et_add_viewport_meta' );
function et_maybe_add_scroll_to_anchor_fix() {
$add_scroll_to_anchor_fix = et_get_option( 'divi_scroll_to_anchor_fix' );
if ( 'on' === $add_scroll_to_anchor_fix ) {
echo '<script>
document.addEventListener( "DOMContentLoaded", function( event ) {
window.et_location_hash = window.location.hash;
if ( "" !== window.et_location_hash ) {
// Prevent jump to anchor - Firefox
window.scrollTo( 0, 0 );
var et_anchor_element = document.getElementById( window.et_location_hash.substring( 1 ) );
window.et_location_hash_style = et_anchor_element.style.display;
// Prevent jump to anchor - Other Browsers
et_anchor_element.style.display = "none";
}
} );
</script>';
}
}
add_action( 'wp_head', 'et_maybe_add_scroll_to_anchor_fix', 9 );
function et_remove_additional_stylesheet( $stylesheet ){
global $default_colorscheme;
return $default_colorscheme;
}
add_filter( 'et_get_additional_color_scheme', 'et_remove_additional_stylesheet' );
if ( ! function_exists( 'et_list_pings' ) ) :
function et_list_pings($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li id="comment-<?php comment_ID(); ?>"><?php comment_author_link(); ?> - <?php comment_excerpt(); ?>
<?php }
endif;
if ( ! function_exists( 'et_get_theme_version' ) ) :
function et_get_theme_version() {
$theme_info = wp_get_theme();
if ( is_child_theme() ) {
$theme_info = wp_get_theme( $theme_info->parent_theme );
}
$theme_version = $theme_info->display( 'Version' );
return $theme_version;
}
endif;
function et_add_post_meta_box() {
// Add Page settings meta box only if it's not disabled for current user
if ( et_pb_is_allowed( 'page_options' ) ) {
add_meta_box( 'et_settings_meta_box', esc_html__( 'Divi Page Settings', 'Divi' ), 'et_single_settings_meta_box', 'page', 'side', 'high' );
}
add_meta_box( 'et_settings_meta_box', esc_html__( 'Divi Post Settings', 'Divi' ), 'et_single_settings_meta_box', 'post', 'side', 'high' );
add_meta_box( 'et_settings_meta_box', esc_html__( 'Divi Product Settings', 'Divi' ), 'et_single_settings_meta_box', 'product', 'side', 'high' );
add_meta_box( 'et_settings_meta_box', esc_html__( 'Divi Project Settings', 'Divi' ), 'et_single_settings_meta_box', 'project', 'side', 'high' );
}
add_action( 'add_meta_boxes', 'et_add_post_meta_box' );
if ( ! function_exists( 'et_pb_portfolio_meta_box' ) ) :
function et_pb_portfolio_meta_box() { ?>
<div class="et_project_meta">
<strong class="et_project_meta_title"><?php echo esc_html__( 'Skills', 'Divi' ); ?></strong>
<p><?php echo get_the_term_list( get_the_ID(), 'project_tag', '', ', ' ); ?></p>
<strong class="et_project_meta_title"><?php echo esc_html__( 'Posted on', 'Divi' ); ?></strong>
<p><?php echo get_the_date(); ?></p>
</div>
<?php }
endif;
if ( ! function_exists( 'et_single_settings_meta_box' ) ) :
function et_single_settings_meta_box( $post ) {
$post_id = get_the_ID();
wp_nonce_field( basename( __FILE__ ), 'et_settings_nonce' );
$page_layout = get_post_meta( $post_id, '_et_pb_page_layout', true );
$side_nav = get_post_meta( $post_id, '_et_pb_side_nav', true );
$project_nav = get_post_meta( $post_id, '_et_pb_project_nav', true );
$post_hide_nav = get_post_meta( $post_id, '_et_pb_post_hide_nav', true );
$post_hide_nav = $post_hide_nav && 'off' === $post_hide_nav ? 'default' : $post_hide_nav;
$show_title = get_post_meta( $post_id, '_et_pb_show_title', true );
$page_layouts = array(
'et_right_sidebar' => esc_html__( 'Right Sidebar', 'Divi' ),
'et_left_sidebar' => esc_html__( 'Left Sidebar', 'Divi' ),
'et_full_width_page' => esc_html__( 'Full Width', 'Divi' ),
);
$layouts = array(
'light' => esc_html__( 'Light', 'Divi' ),
'dark' => esc_html__( 'Dark', 'Divi' ),
);
$post_bg_color = ( $bg_color = get_post_meta( $post_id, '_et_post_bg_color', true ) ) && '' !== $bg_color
? $bg_color
: '#ffffff';
$post_use_bg_color = get_post_meta( $post_id, '_et_post_use_bg_color', true )
? true
: false;
$post_bg_layout = ( $layout = get_post_meta( $post_id, '_et_post_bg_layout', true ) ) && '' !== $layout
? $layout
: 'light'; ?>
<p class="et_pb_page_settings et_pb_page_layout_settings">
<label for="et_pb_page_layout" style="display: block; font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Page Layout', 'Divi' ); ?>: </label>
<select id="et_pb_page_layout" name="et_pb_page_layout">
<?php
foreach ( $page_layouts as $layout_value => $layout_name ) {
printf( '<option value="%2$s"%3$s>%1$s</option>',
esc_html( $layout_name ),
esc_attr( $layout_value ),
selected( $layout_value, $page_layout, false )
);
} ?>
</select>
</p>
<p class="et_pb_page_settings et_pb_side_nav_settings" style="display: none;">
<label for="et_pb_side_nav" style="display: block; font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Dot Navigation', 'Divi' ); ?>: </label>
<select id="et_pb_side_nav" name="et_pb_side_nav">
<option value="off" <?php selected( 'off', $side_nav ); ?>><?php esc_html_e( 'Off', 'Divi' ); ?></option>
<option value="on" <?php selected( 'on', $side_nav ); ?>><?php esc_html_e( 'On', 'Divi' ); ?></option>
</select>
</p>
<p class="et_pb_page_settings">
<label for="et_pb_post_hide_nav" style="display: block; font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Hide Nav Before Scroll', 'Divi' ); ?>: </label>
<select id="et_pb_post_hide_nav" name="et_pb_post_hide_nav">
<option value="default" <?php selected( 'default', $post_hide_nav ); ?>><?php esc_html_e( 'Default', 'Divi' ); ?></option>
<option value="no" <?php selected( 'no', $post_hide_nav ); ?>><?php esc_html_e( 'Off', 'Divi' ); ?></option>
<option value="on" <?php selected( 'on', $post_hide_nav ); ?>><?php esc_html_e( 'On', 'Divi' ); ?></option>
</select>
</p>
<?php if ( 'post' === $post->post_type ) : ?>
<p class="et_pb_page_settings et_pb_single_title" style="display: none;">
<label for="et_single_title" style="display: block; font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Post Title', 'Divi' ); ?>: </label>
<select id="et_single_title" name="et_single_title">
<option value="on" <?php selected( 'on', $show_title ); ?>><?php esc_html_e( 'Show', 'Divi' ); ?></option>
<option value="off" <?php selected( 'off', $show_title ); ?>><?php esc_html_e( 'Hide', 'Divi' ); ?></option>
</select>
</p>
<p class="et_divi_quote_settings et_divi_audio_settings et_divi_link_settings et_divi_format_setting et_pb_page_settings">
<label for="et_post_use_bg_color" style="display: block; font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Use Background Color', 'Divi' ); ?></label>
<input name="et_post_use_bg_color" type="checkbox" id="et_post_use_bg_color" <?php checked( $post_use_bg_color ); ?> />
</p>
<p class="et_post_bg_color_setting et_divi_format_setting et_pb_page_settings">
<input id="et_post_bg_color" name="et_post_bg_color" class="color-picker-hex" type="text" maxlength="7" placeholder="<?php esc_attr_e( 'Hex Value', 'Divi' ); ?>" value="<?php echo esc_attr( $post_bg_color ); ?>" data-default-color="#ffffff" />
</p>
<p class="et_divi_quote_settings et_divi_audio_settings et_divi_link_settings et_divi_format_setting">
<label for="et_post_bg_layout" style="font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Text Color', 'Divi' ); ?>: </label>
<select id="et_post_bg_layout" name="et_post_bg_layout">
<?php
foreach ( $layouts as $layout_name => $layout_title )
printf( '<option value="%s"%s>%s</option>',
esc_attr( $layout_name ),
selected( $layout_name, $post_bg_layout, false ),
esc_html( $layout_title )
);
?>
</select>
</p>
<?php endif;
if ( 'project' === $post->post_type ) : ?>
<p class="et_pb_page_settings et_pb_project_nav" style="display: none;">
<label for="et_project_nav" style="display: block; font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Project Navigation', 'Divi' ); ?>: </label>
<select id="et_project_nav" name="et_project_nav">
<option value="off" <?php selected( 'off', $project_nav ); ?>><?php esc_html_e( 'Hide', 'Divi' ); ?></option>
<option value="on" <?php selected( 'on', $project_nav ); ?>><?php esc_html_e( 'Show', 'Divi' ); ?></option>
</select>
</p>
<?php endif;
}
endif;
function et_divi_post_settings_save_details( $post_id, $post ){
global $pagenow;
if ( 'post.php' != $pagenow ) return $post_id;
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return $post_id;
$post_type = get_post_type_object( $post->post_type );
if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) )
return $post_id;
if ( ! isset( $_POST['et_settings_nonce'] ) || ! wp_verify_nonce( $_POST['et_settings_nonce'], basename( __FILE__ ) ) )
return $post_id;
if ( isset( $_POST['et_post_use_bg_color'] ) )
update_post_meta( $post_id, '_et_post_use_bg_color', true );
else
delete_post_meta( $post_id, '_et_post_use_bg_color' );
if ( isset( $_POST['et_post_bg_color'] ) )
update_post_meta( $post_id, '_et_post_bg_color', sanitize_text_field( $_POST['et_post_bg_color'] ) );
else
delete_post_meta( $post_id, '_et_post_bg_color' );
if ( isset( $_POST['et_post_bg_layout'] ) )
update_post_meta( $post_id, '_et_post_bg_layout', sanitize_text_field( $_POST['et_post_bg_layout'] ) );
else
delete_post_meta( $post_id, '_et_post_bg_layout' );
if ( isset( $_POST['et_single_title'] ) )
update_post_meta( $post_id, '_et_pb_show_title', sanitize_text_field( $_POST['et_single_title'] ) );
else
delete_post_meta( $post_id, '_et_pb_show_title' );
if ( isset( $_POST['et_pb_post_hide_nav'] ) )
update_post_meta( $post_id, '_et_pb_post_hide_nav', sanitize_text_field( $_POST['et_pb_post_hide_nav'] ) );
else
delete_post_meta( $post_id, '_et_pb_post_hide_nav' );
if ( isset( $_POST['et_project_nav'] ) )
update_post_meta( $post_id, '_et_pb_project_nav', sanitize_text_field( $_POST['et_project_nav'] ) );
else
delete_post_meta( $post_id, '_et_pb_project_nav' );
if ( isset( $_POST['et_pb_page_layout'] ) ) {
update_post_meta( $post_id, '_et_pb_page_layout', sanitize_text_field( $_POST['et_pb_page_layout'] ) );
} else {
delete_post_meta( $post_id, '_et_pb_page_layout' );
}
if ( isset( $_POST['et_pb_side_nav'] ) ) {
update_post_meta( $post_id, '_et_pb_side_nav', sanitize_text_field( $_POST['et_pb_side_nav'] ) );
} else {
delete_post_meta( $post_id, '_et_pb_side_nav' );
}
}
add_action( 'save_post', 'et_divi_post_settings_save_details', 10, 2 );
if ( ! function_exists( 'et_get_one_font_languages' ) ) :
function et_get_one_font_languages() {
$one_font_languages = array(
'he_IL' => array(
'language_name' => 'Hebrew',
'google_font_url' => '//fonts.googleapis.com/earlyaccess/alefhebrew.css',
'font_family' => "'Alef Hebrew', serif",
),
'ja' => array(
'language_name' => 'Japanese',
'google_font_url' => '//fonts.googleapis.com/earlyaccess/notosansjapanese.css',
'font_family' => "'Noto Sans Japanese', serif",
),
'ko_KR' => array(
'language_name' => 'Korean',
'google_font_url' => '//fonts.googleapis.com/earlyaccess/hanna.css',
'font_family' => "'Hanna', serif",
),
'ar' => array(
'language_name' => 'Arabic',
'google_font_url' => '//fonts.googleapis.com/earlyaccess/lateef.css',
'font_family' => "'Lateef', serif",
),
'th' => array(
'language_name' => 'Thai',
'google_font_url' => '//fonts.googleapis.com/earlyaccess/notosansthai.css',
'font_family' => "'Noto Sans Thai', serif",
),
'ms_MY' => array(
'language_name' => 'Malay',
'google_font_url' => '//fonts.googleapis.com/earlyaccess/notosansmalayalam.css',
'font_family' => "'Noto Sans Malayalam', serif",
),
'zh_CN' => array(
'language_name' => 'Chinese',
'google_font_url' => '//fonts.googleapis.com/earlyaccess/cwtexfangsong.css',
'font_family' => "'cwTeXFangSong', serif",
),
);
return $one_font_languages;
}
endif;
function et_divi_customize_register( $wp_customize ) {
$wp_customize->remove_section( 'title_tagline' );
$wp_customize->remove_section( 'background_image' );
$wp_customize->remove_section( 'colors' );
$wp_customize->register_control_type( 'ET_Divi_Customize_Color_Alpha_Control' );
wp_register_script( 'wp-color-picker-alpha', get_template_directory_uri() . '/includes/builder/scripts/ext/wp-color-picker-alpha.min.js', array( 'jquery', 'wp-color-picker' ) );
$option_set_name = 'et_customizer_option_set';
$option_set_allowed_values = apply_filters( 'et_customizer_option_set_allowed_values', array( 'module', 'theme' ) );
$customizer_option_set = '';
/**
* Set a transient,
* if 'et_customizer_option_set' query parameter is set to one of the allowed values
*/
if ( isset( $_GET[ $option_set_name ] ) && in_array( $_GET[ $option_set_name ], $option_set_allowed_values ) ) {
$customizer_option_set = $_GET[ $option_set_name ];
set_transient( 'et_divi_customizer_option_set', $customizer_option_set, DAY_IN_SECONDS );
}
if ( '' === $customizer_option_set && ( $et_customizer_option_set_value = get_transient( 'et_divi_customizer_option_set' ) ) ) {
$customizer_option_set = $et_customizer_option_set_value;
}
et_builder_init_global_settings();
if ( isset( $customizer_option_set ) && 'module' === $customizer_option_set ) {
// display wp error screen if module customizer disabled for current user
if ( ! et_pb_is_allowed( 'module_customizer' ) ) {
wp_die( esc_html__( "you don't have sufficient permissions to access this page", 'Divi' ) );
}
$removed_default_sections = array( 'nav', 'static_front_page' );
foreach ( $removed_default_sections as $default_section ) {
$wp_customize->remove_section( $default_section );
}
et_divi_customizer_module_settings( $wp_customize );
} else {
// display wp error screen if theme customizer disabled for current user
if ( ! et_pb_is_allowed( 'theme_customizer' ) ) {
wp_die( esc_html__( "you don't have sufficient permissions to access this page", 'Divi' ) );
}
et_divi_customizer_theme_settings( $wp_customize );
}
}
add_action( 'customize_register', 'et_divi_customize_register' );
if ( ! function_exists( 'et_divi_customizer_theme_settings' ) ) :
function et_divi_customizer_theme_settings( $wp_customize ) {
$site_domain = get_locale();
$google_fonts = et_builder_get_fonts( array(
'prepend_standard_fonts' => false,
) );
$et_domain_fonts = array(
'ru_RU' => 'cyrillic',
'uk' => 'cyrillic',
'bg_BG' => 'cyrillic',
'vi' => 'vietnamese',
'el' => 'greek',
);
$et_one_font_languages = et_get_one_font_languages();
$font_choices = array();
$font_choices['none'] = array(
'label' => 'Default Theme Font'
);
foreach ( $google_fonts as $google_font_name => $google_font_properties ) {
if ( '' !== $site_domain && isset( $et_domain_fonts[$site_domain] ) && false === strpos( $google_font_properties['character_set'], $et_domain_fonts[$site_domain] ) ) {
continue;
}
$font_choices[ $google_font_name ] = array(
'label' => $google_font_name,
'data' => array(
'parent_font' => isset( $google_font_properties['parent_font'] ) ? $google_font_properties['parent_font'] : '',
'parent_styles' => isset( $google_font_properties['parent_font'] ) && isset( $google_fonts[$google_font_properties['parent_font']]['styles'] ) ? $google_fonts[$google_font_properties['parent_font']]['styles'] : $google_font_properties['styles'],
'current_styles' => isset( $google_font_properties['parent_font'] ) && isset( $google_fonts[$google_font_properties['parent_font']]['styles'] ) && isset( $google_font_properties['styles'] ) ? $google_font_properties['styles'] : '',
'parent_subset' => isset( $google_font_properties['parent_font'] ) && isset( $google_fonts[$google_font_properties['parent_font']]['character_set'] ) ? $google_fonts[$google_font_properties['parent_font']]['character_set'] : '',
'standard' => isset( $google_font_properties['standard'] ) && $google_font_properties['standard'] ? 'on' : 'off',
)
);
}
$wp_customize->add_panel( 'et_divi_general_settings' , array(
'title' => esc_html__( 'General Settings', 'Divi' ),
'priority' => 1,
) );
$wp_customize->add_section( 'title_tagline', array(
'title' => esc_html__( 'Site Identity', 'Divi' ),
'panel' => 'et_divi_general_settings',
) );
$wp_customize->add_section( 'et_divi_general_layout' , array(
'title' => esc_html__( 'Layout Settings', 'Divi' ),
'panel' => 'et_divi_general_settings',
) );
$wp_customize->add_section( 'et_divi_general_typography' , array(
'title' => esc_html__( 'Typography', 'Divi' ),
'panel' => 'et_divi_general_settings',
) );
$wp_customize->add_panel( 'et_divi_mobile' , array(
'title' => esc_html__( 'Mobile Styles', 'Divi' ),
'priority' => 6,
) );
$wp_customize->add_section( 'et_divi_mobile_tablet' , array(
'title' => esc_html__( 'Tablet', 'Divi' ),
'panel' => 'et_divi_mobile',
) );
$wp_customize->add_section( 'et_divi_mobile_phone' , array(
'title' => esc_html__( 'Phone', 'Divi' ),
'panel' => 'et_divi_mobile',
) );
$wp_customize->add_section( 'et_divi_mobile_menu' , array(
'title' => esc_html__( 'Mobile Menu', 'Divi' ),
'panel' => 'et_divi_mobile',
) );
$wp_customize->add_section( 'et_divi_general_background' , array(
'title' => esc_html__( 'Background', 'Divi' ),
'panel' => 'et_divi_general_settings',
) );
$wp_customize->add_panel( 'et_divi_header_panel', array(
'title' => esc_html__( 'Header & Navigation', 'Divi' ),
'priority' => 2,
) );
$wp_customize->add_section( 'et_divi_header_layout' , array(
'title' => esc_html__( 'Header Format', 'Divi' ),
'panel' => 'et_divi_header_panel',
) );
$wp_customize->add_section( 'et_divi_header_primary' , array(
'title' => esc_html__( 'Primary Menu Bar', 'Divi' ),
'panel' => 'et_divi_header_panel',
) );
$wp_customize->add_section( 'et_divi_header_secondary' , array(
'title' => esc_html__( 'Secondary Menu Bar', 'Divi' ),
'panel' => 'et_divi_header_panel',
) );
$wp_customize->add_section( 'et_divi_header_slide' , array(
'title' => esc_html__( 'Slide In & Fullscreen Header Settings', 'Divi' ),
'panel' => 'et_divi_header_panel',
) );
$wp_customize->add_section( 'et_divi_header_fixed' , array(
'title' => esc_html__( 'Fixed Navigation Settings', 'Divi' ),
'panel' => 'et_divi_header_panel',
) );
$wp_customize->add_section( 'et_divi_header_information' , array(
'title' => esc_html__( 'Header Elements', 'Divi' ),
'panel' => 'et_divi_header_panel',
) );
$wp_customize->add_panel( 'et_divi_footer_panel' , array(
'title' => esc_html__( 'Footer', 'Divi' ),
'priority' => 3,
) );
$wp_customize->add_section( 'et_divi_footer_layout' , array(
'title' => esc_html__( 'Layout', 'Divi' ),
'panel' => 'et_divi_footer_panel',
) );
$wp_customize->add_section( 'et_divi_footer_widgets' , array(
'title' => esc_html__( 'Widgets', 'Divi' ),
'panel' => 'et_divi_footer_panel',
) );
$wp_customize->add_section( 'et_divi_footer_elements' , array(
'title' => esc_html__( 'Footer Elements', 'Divi' ),
'panel' => 'et_divi_footer_panel',
) );
$wp_customize->add_section( 'et_divi_footer_menu' , array(
'title' => esc_html__( 'Footer Menu', 'Divi' ),
'panel' => 'et_divi_footer_panel',
) );
$wp_customize->add_section( 'et_divi_bottom_bar' , array(
'title' => esc_html__( 'Bottom Bar', 'Divi' ),
'panel' => 'et_divi_footer_panel',
) );
$wp_customize->add_section( 'et_color_schemes' , array(
'title' => esc_html__( 'Color Schemes', 'Divi' ),
'priority' => 7,
'description' => esc_html__( 'Note: Color settings set above should be applied to the Default color scheme.', 'Divi' ),
) );
$wp_customize->add_panel( 'et_divi_buttons_settings' , array(
'title' => esc_html__( 'Buttons', 'Divi' ),
'priority' => 4,
) );
$wp_customize->add_section( 'et_divi_buttons' , array(
'title' => esc_html__( 'Buttons Style', 'Divi' ),
'panel' => 'et_divi_buttons_settings',
) );
$wp_customize->add_section( 'et_divi_buttons_hover' , array(
'title' => esc_html__( 'Buttons Hover Style', 'Divi' ),
'panel' => 'et_divi_buttons_settings',
) );
$wp_customize->add_panel( 'et_divi_blog_settings' , array(
'title' => esc_html__( 'Blog', 'Divi' ),
'priority' => 5,
) );
$wp_customize->add_section( 'et_divi_blog_post' , array(
'title' => esc_html__( 'Post', 'Divi' ),
'panel' => 'et_divi_blog_settings',
) );
$wp_customize->add_setting( 'et_divi[post_meta_font_size]', array(
'default' => '14',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'absint',
) );
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->add_control( new ET_Divi_Range_Option ( $wp_customize, 'et_divi[post_meta_font_size]', array(
'label' => esc_html__( 'Meta Text Size', 'Divi' ),
'section' => 'et_divi_blog_post',
'type' => 'range',
'input_attrs' => array(
'min' => 10,
'max' => 32,
'step' => 1
),
) ) );
$wp_customize->add_setting( 'et_divi[post_meta_height]', array(
'default' => '1',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'et_sanitize_float_number',
) );
$wp_customize->add_control( new ET_Divi_Range_Option ( $wp_customize, 'et_divi[post_meta_height]', array(
'label' => esc_html__( 'Meta Line Height', 'Divi' ),
'section' => 'et_divi_blog_post',
'type' => 'range',
'input_attrs' => array(
'min' => .8,
'max' => 3,
'step' => .1
),
) ) );
$wp_customize->add_setting( 'et_divi[post_meta_spacing]', array(
'default' => '0',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'absint',
) );
$wp_customize->add_control( new ET_Divi_Range_Option ( $wp_customize, 'et_divi[post_meta_spacing]', array(
'label' => esc_html__( 'Meta Letter Spacing', 'Divi' ),
'section' => 'et_divi_blog_post',
'type' => 'range',
'input_attrs' => array(
'min' => -2,
'max' => 10,
'step' => 1
),
) ) );
$wp_customize->add_setting( 'et_divi[post_meta_style]', array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'et_sanitize_font_style',
) );
$wp_customize->add_control( new ET_Divi_Font_Style_Option ( $wp_customize, 'et_divi[post_meta_style]', array(
'label' => esc_html__( 'Meta Font Style', 'Divi' ),
'section' => 'et_divi_blog_post',
'type' => 'font_style',
'choices' => et_divi_font_style_choices(),
) ) );
$wp_customize->add_setting( 'et_divi[post_header_font_size]', array(
'default' => '30',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'absint',
) );
$wp_customize->add_control( new ET_Divi_Range_Option ( $wp_customize, 'et_divi[post_header_font_size]', array(
'label' => esc_html__( 'Header Text Size', 'Divi' ),
'section' => 'et_divi_blog_post',
'type' => 'range',
'input_attrs' => array(
'min' => 10,
'max' => 72,
'step' => 1
),
) ) );
$wp_customize->add_setting( 'et_divi[post_header_height]', array(
'default' => '1',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'et_sanitize_float_number',
) );
$wp_customize->add_control( new ET_Divi_Range_Option ( $wp_customize, 'et_divi[post_header_height]', array(
'label' => esc_html__( 'Header Line Height', 'Divi' ),
'section' => 'et_divi_blog_post',
'type' => 'range',
'input_attrs' => array(
'min' => 0.8,
'max' => 3,
'step' => 0.1
),
) ) );
$wp_customize->add_setting( 'et_divi[post_header_spacing]', array(
'default' => '0',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'et_sanitize_int_number',
) );
$wp_customize->add_control( new ET_Divi_Range_Option ( $wp_customize, 'et_divi[post_header_spacing]', array(
'label' => esc_html__( 'Header Letter Spacing', 'Divi' ),
'section' => 'et_divi_blog_post',
'type' => 'range',
'input_attrs' => array(
'min' => -2,
'max' => 10,
'step' => 1
),
) ) );
$wp_customize->add_setting( 'et_divi[post_header_style]', array(
'default' => '',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'et_sanitize_font_style',
) );
$wp_customize->add_control( new ET_Divi_Font_Style_Option ( $wp_customize, 'et_divi[post_header_style]', array(
'label' => esc_html__( 'Header Font Style', 'Divi' ),
'section' => 'et_divi_blog_post',
'type' => 'font_style',
'choices' => et_divi_font_style_choices(),
) ) );
$wp_customize->add_setting( 'et_divi[boxed_layout]', array(
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'wp_validate_boolean',
) );
$wp_customize->add_control( 'et_divi[boxed_layout]', array(
'label' => esc_html__( 'Enable Boxed Layout', 'Divi' ),
'section' => 'et_divi_general_layout',
'type' => 'checkbox',
) );
$wp_customize->add_setting( 'et_divi[content_width]', array(
'default' => '1080',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'absint',
) );
$wp_customize->add_control( new ET_Divi_Range_Option ( $wp_customize, 'et_divi[content_width]', array(
'label' => esc_html__( 'Website Content Width', 'Divi' ),
'section' => 'et_divi_general_layout',
'type' => 'range',
'input_attrs' => array(
'min' => 960,
'max' => 1920,
'step' => 1
),
) ) );
$wp_customize->add_setting( 'et_divi[gutter_width]', array(
'default' => '3',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'absint',
) );
$wp_customize->add_control( new ET_Divi_Range_Option ( $wp_customize, 'et_divi[gutter_width]', array(
'label' => esc_html__( 'Website Gutter Width', 'Divi' ),
'section' => 'et_divi_general_layout',
'type' => 'range',
'input_attrs' => array(
'min' => 1,
'max' => 4,
'step' => 1
),
) ) );
$wp_customize->add_setting( 'et_divi[use_sidebar_width]', array(
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'wp_validate_boolean',
) );
$wp_customize->add_control( 'et_divi[use_sidebar_width]', array(
'label' => esc_html__( 'Use Custom Sidebar Width', 'Divi' ),
'section' => 'et_divi_general_layout',
'type' => 'checkbox',
) );
$wp_customize->add_setting( 'et_divi[sidebar_width]', array(
'default' => '21',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'absint',
) );
$wp_customize->add_control( new ET_Divi_Range_Option ( $wp_customize, 'et_divi[sidebar_width]', array(
'label' => esc_html__( 'Sidebar Width', 'Divi' ),
'section' => 'et_divi_general_layout',
'type' => 'range',
'input_attrs' => array(
'min' => 19,
'max' => 33,
'step' => 1,
),
) ) );
$wp_customize->add_setting( 'et_divi[section_padding]', array(
'default' => '4',
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'absint',
) );
$wp_customize->add_control( new ET_Divi_Range_Option ( $wp_customize, 'et_divi[section_padding]', array(
'label' => esc_html__( 'Section Height', 'Divi' ),
'section' => 'et_divi_general_layout',
'type' => 'range',
'input_attrs' => array(
'min' => 0,
'max' => 10,
'step' => 1
),
) ) );
$wp_customize->add_setting( 'et_divi[phone_section_height]', array(
'default' => et_get_option( 'tablet_section_height', '50' ),