functions.php
3.53 KB
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
<?php
if ( ! function_exists( 'et_get_safe_localization' ) ) :
function et_get_safe_localization( $string ) {
return apply_filters( 'et_get_safe_localization', wp_kses( $string, et_get_allowed_localization_html_elements() ) );
}
endif;
if ( ! function_exists( 'et_allow_ampersand' ) ) :
/**
* Convert & into &
* Escaped ampersand by wp_kses() which is used by et_get_safe_localization()
* can be a troublesome in some cases, ie.: outputted string is sent as email
* @param string original string
* @return string modified string
*/
function et_allow_ampersand( $string ) {
return str_replace('&', '&', $string);
}
endif;
if ( ! function_exists( 'et_get_allowed_localization_html_elements' ) ) :
function et_get_allowed_localization_html_elements() {
$whitelisted_attributes = array(
'id' => array(),
'class' => array(),
'style' => array(),
);
$whitelisted_attributes = apply_filters( 'et_allowed_localization_html_attributes', $whitelisted_attributes );
$elements = array(
'a' => array(
'href' => array(),
'title' => array(),
'target' => array(),
'rel' => array(),
),
'b' => array(),
'br' => array(),
'em' => array(),
'p' => array(),
'span' => array(),
'div' => array(),
'strong' => array(),
);
$elements = apply_filters( 'et_allowed_localization_html_elements', $elements );
foreach ( $elements as $tag => $attributes ) {
$elements[ $tag ] = array_merge( $attributes, $whitelisted_attributes );
}
return $elements;
}
endif;
if ( ! function_exists( 'et_core_get_main_fonts' ) ) :
function et_core_get_main_fonts() {
global $wp_version;
if ( version_compare( $wp_version, '4.6', '<' ) ) {
return '';
}
$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;
if ( ! function_exists( 'et_core_load_main_fonts' ) ) :
function et_core_load_main_fonts() {
$fonts_url = et_core_get_main_fonts();
if ( empty( $fonts_url ) ) {
return;
}
wp_enqueue_style( 'et-core-main-fonts', esc_url_raw( $fonts_url ), array(), null );
}
endif;
if ( ! function_exists( 'et_core_browser_body_class' ) ) :
function et_core_browser_body_class( $classes ) {
global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
if( $is_lynx ) $classes[] = 'lynx';
elseif( $is_gecko ) $classes[] = 'gecko';
elseif( $is_opera ) $classes[] = 'opera';
elseif( $is_NS4 ) $classes[] = 'ns4';
elseif( $is_safari ) $classes[] = 'safari';
elseif( $is_chrome ) $classes[] = 'chrome';
elseif( $is_IE ) $classes[] = 'ie';
else $classes[] = 'unknown';
if( $is_iphone ) $classes[] = 'iphone';
return $classes;
}
endif;
add_filter( 'body_class', 'et_core_browser_body_class' );
if ( ! function_exists( 'et_force_edge_compatibility_mode' ) ) :
function et_force_edge_compatibility_mode() {
echo '<meta http-equiv="X-UA-Compatible" content="IE=edge">';
}
endif;
add_action( 'et_head_meta', 'et_force_edge_compatibility_mode' );