wp-google-analytics-options.php
3.26 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
128
129
130
131
132
133
134
135
136
137
138
139
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileNames
/**
* Jetpack_Google_Analytics_Options provides a single interface to module options
*
* @author allendav
*/
/**
* Bail if accessed directly
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Jetpack_Google_Analytics_Options main class.
*/
class Jetpack_Google_Analytics_Options {
/**
* Get the Google Analytics tracking ID.
*
* @param string $option_name Nested 'jetpack_wga' option value to retrieve.
* @param mixed $default Default value if $option is not set.
* @return mixed Option value or `$default`.
*/
public static function get_option( $option_name, $default = false ) {
$o = get_option( 'jetpack_wga' );
return isset( $o[ $option_name ] ) ? $o[ $option_name ] : $default;
}
/**
* Get the analytics tracking code.
*
* @return string
*/
public static function get_tracking_code() {
return self::get_option( 'code', '' );
}
/**
* Check if the tracking code is set.
*
* @return bool
*/
public static function has_tracking_code() {
$code = self::get_tracking_code();
return ! empty( $code );
}
/**
* Get the 'anonymize_ip' option used by both legacy and universal analytics.
*
* @return bool
*/
public static function anonymize_ip_is_enabled() {
return (bool) self::get_option( 'anonymize_ip' );
}
/**
* Get the 'honor_dnt' option used by both legacy and universal analytics.
*
* @return bool
*/
public static function honor_dnt_is_enabled() {
return (bool) static::get_option( 'honor_dnt' );
}
/**
* Get the 'ec_track_purchases' eCommerce option used by both legacy and universal analytics
*
* @return bool
*/
public static function track_purchases_is_enabled() {
return (bool) self::get_option( 'ec_track_purchases' );
}
/**
* Get the 'ec_track_add_to_cart' analytics option.
*
* @return bool
*/
public static function track_add_to_cart_is_enabled() {
return (bool) self::get_option( 'ec_track_add_to_cart' );
}
/**
* Get the 'enh_ec_tracking' analytics option.
*
* @return bool
*/
public static function enhanced_ecommerce_tracking_is_enabled() {
return (bool) self::get_option( 'enh_ec_tracking' );
}
/**
* Get the 'enh_ec_track_remove_from_cart' analytics option.
*
* @return bool
*/
public static function track_remove_from_cart_is_enabled() {
return (bool) self::get_option( 'enh_ec_track_remove_from_cart' );
}
/**
* Get the 'enh_ec_track_prod_impression' analytics option.
*
* @return bool
*/
public static function track_product_impressions_is_enabled() {
return (bool) self::get_option( 'enh_ec_track_prod_impression' );
}
/**
* Get the 'enh_ec_track_prod_click' analytics option.
*
* @return bool
*/
public static function track_product_clicks_is_enabled() {
return (bool) self::get_option( 'enh_ec_track_prod_click' );
}
/**
* Get the 'enh_ec_track_prod_detail_view' analytics option.
*
* @return bool
*/
public static function track_product_detail_view_is_enabled() {
return (bool) self::get_option( 'enh_ec_track_prod_detail_view' );
}
/**
* Get the 'enh_ec_track_checkout_started' analytics option.
*
* @return bool
*/
public static function track_checkout_started_is_enabled() {
return (bool) self::get_option( 'enh_ec_track_checkout_started' );
}
}