|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* Jetpack_Google_Analytics_Options provides a single interface to module options |
|
6
|
|
|
* |
|
7
|
|
|
* @author allendav |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Bail if accessed directly |
|
12
|
|
|
*/ |
|
13
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
|
14
|
|
|
exit; |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
class Jetpack_Google_Analytics_Options { |
|
18
|
|
|
public static function get_option( $option_name, $default = false ) { |
|
19
|
|
|
$o = get_option( 'jetpack_wga' ); |
|
20
|
|
|
return isset( $o[ $option_name ] ) ? $o[ $option_name ] : $default; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public static function get_tracking_code() { |
|
24
|
|
|
return self::get_option( 'code', '' ); |
|
|
|
|
|
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public static function has_tracking_code() { |
|
28
|
|
|
$code = self::get_tracking_code(); |
|
29
|
|
|
return ! empty( $code ); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
// Options used by both legacy and universal analytics |
|
33
|
|
|
public static function anonymize_ip_is_enabled() { |
|
34
|
|
|
return self::get_option( 'anonymize_ip' ); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
// eCommerce options used by both legacy and universal analytics |
|
38
|
|
|
public static function track_purchases_is_enabled() { |
|
39
|
|
|
return self::get_option( 'ec_track_purchases' ); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public static function track_add_to_cart_is_enabled() { |
|
43
|
|
|
return self::get_option( 'ec_track_add_to_cart' ); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
// Enhanced eCommerce options |
|
47
|
|
|
public static function enhanced_ecommerce_tracking_is_enabled() { |
|
48
|
|
|
return self::get_option( 'enh_ec_tracking' ); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public static function track_remove_from_cart_is_enabled() { |
|
52
|
|
|
return self::get_option( 'enh_ec_track_remove_from_cart' ); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public static function track_product_impressions_is_enabled() { |
|
56
|
|
|
return self::get_option( 'enh_ec_track_prod_impression' ); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public static function track_product_clicks_is_enabled() { |
|
60
|
|
|
return self::get_option( 'enh_ec_track_prod_click' ); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public static function track_product_detail_view_is_enabled() { |
|
64
|
|
|
return self::get_option( 'enh_ec_track_prod_detail_view' ); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public static function track_checkout_started_is_enabled() { |
|
68
|
|
|
return self::get_option( 'enh_ec_track_checkout_started' ); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public static function debug_dump() { |
|
72
|
|
|
$messages = array( 'Jetpack_Google_Analytics_Options' ); |
|
73
|
|
|
$tracking_code = self::has_tracking_code() ? self::get_tracking_code() : '(empty)'; |
|
74
|
|
|
array_push( $messages, "get_tracking_code: $tracking_code" ); |
|
75
|
|
|
|
|
76
|
|
|
$flags = array( |
|
77
|
|
|
'anonymize_ip_is_enabled', |
|
78
|
|
|
'track_purchases_is_enabled', |
|
79
|
|
|
'track_add_to_cart_is_enabled', |
|
80
|
|
|
'enhanced_ecommerce_tracking_is_enabled', |
|
81
|
|
|
'track_remove_from_cart_is_enabled', |
|
82
|
|
|
'track_product_impressions_is_enabled', |
|
83
|
|
|
'track_product_clicks_is_enabled', |
|
84
|
|
|
'track_product_detail_view_is_enabled', |
|
85
|
|
|
'track_checkout_started_is_enabled', |
|
86
|
|
|
); |
|
87
|
|
|
|
|
88
|
|
|
foreach( $flags as $flag ) { |
|
89
|
|
|
$value = call_user_func( 'Jetpack_Google_Analytics_Options::' . $flag ) ? 'true' : 'false'; |
|
90
|
|
|
array_push( $messages, "$flag: $value" ); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
return $messages; |
|
94
|
|
|
} |
|
95
|
|
|
} |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: