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
|
<?php /** * WPKlaviyo Helper Class. * * @package WooCommerceKlaviyo * @version 2.0.0 */
/** * WPKlaviyo Helper Class */ class WPKlaviyo {
/** * Determines whether a Klaviyo account is integrated based on presence of public API key. * * @param string $public_api_key Public API key of integrated Klaviyo account. * @return bool */ public static function is_connected( $public_api_key = '' ) { if ( trim( $public_api_key ) != '' ) { return true; } else { $klaviyo_settings = get_option( 'klaviyo_settings' ); if ( isset( $klaviyo_settings['klaviyo_public_api_key'] ) && trim( $klaviyo_settings['klaviyo_public_api_key'] ) != '' ) { return true; }
return false; } }
/** * Constructor */ public function __construct() { global $klaviyowp_analytics;
if ( ! is_admin() ) { $klaviyowp_analytics = new WPKlaviyoAnalytics( WCK()->options->get_klaviyo_option( 'klaviyo_public_api_key' ) ); }
// Display config message. $klaviyowp_message = new WPKlaviyoNotification(); add_action( 'admin_notices', array( &$klaviyowp_message, 'config_warning' ) );
add_action( 'widgets_init', function () { register_widget( 'Klaviyo_EmailSignUp_Widget' ); // Only display Built-in Signup Form widget if klaviyo.js is checked in settings. if ( WCK()->options->get_klaviyo_option( 'klaviyo_popup' ) ) { register_widget( 'Klaviyo_EmbedEmailSignUp_Widget' ); } } ); }
/** * Add default settings. * * @deprecated * @return void */ public function add_defaults() { $klaviyo_settings = get_option( 'klaviyo_settings' );
if ( ( 'true' != $klaviyo_settings['installed'] ) || ! is_array( $klaviyo_settings ) ) { $klaviyo_settings = array( 'installed' => 'true', 'klaviyo_public_api_key' => '', 'klaviyo_newsletter_list_id' => '', 'klaviyo_newsletter_text' => '', ); update_option( 'klaviyo_settings', $klaviyo_settings ); } }
/** * Format text. * * @deprecated * @param string $content Context to be formatted. * @param boolean $br Contains a break element. * @return mixed */ public function format_text( $content, $br = true ) { return $content; } }
|