Enhanced Ecommerce Google Analytics Plugin for WooCommerce - Version 3.1.2

Version Description

  • 29/06/2021 =
    • Fixed remarketing code bug
Download this release

Release Info

Developer Tatvic
Plugin Icon 128x128 Enhanced Ecommerce Google Analytics Plugin for WooCommerce
Version 3.1.2
Comparing to
See all releases

Code changes from version 3.1.1 to 3.1.2

admin/class-.txt ADDED
@@ -0,0 +1,276 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! class_exists( 'TVC_Survey' ) ) {
3
+
4
+ class TVC_Survey {
5
+ public $api_url = '';
6
+ public $name;
7
+ public $plugin;
8
+ public function __construct( $name = '', $plugin = '' ){
9
+ $this->name = $name;
10
+ $this->plugin = $plugin;
11
+ if ( $this->is_dev_url() ) {
12
+ return;
13
+ }
14
+
15
+ add_action( 'admin_print_scripts', array( $this, 'tvc_js' ), 20 );
16
+ add_action( 'admin_print_scripts', array( $this, 'tvc_css' ) );
17
+ add_action( 'admin_footer', array( $this, 'tvc_modal' ) );
18
+ }
19
+ public function is_dev_url() {
20
+ $url = network_site_url( '/' );
21
+ $is_local_url = false;
22
+ // Trim it up
23
+ $url = strtolower( trim( $url ) );
24
+ if ( false === strpos( $url, 'http://' ) && false === strpos( $url, 'https://' ) ) {
25
+ $url = 'http://' . $url;
26
+ }
27
+ $url_parts = parse_url( $url );
28
+ $host = ! empty( $url_parts['host'] ) ? $url_parts['host'] : false;
29
+ if ( ! empty( $url ) && ! empty( $host ) ) {
30
+ if ( false !== ip2long( $host ) ) {
31
+ if ( ! filter_var( $host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) ) {
32
+ $is_local_url = true;
33
+ }
34
+ } else if ( 'localhost' === $host ) {
35
+ $is_local_url = true;
36
+ }
37
+
38
+ $tlds_to_check = array( '.dev', '.local', ':8888' );
39
+ foreach ( $tlds_to_check as $tld ) {
40
+ if ( false !== strpos( $host, $tld ) ) {
41
+ $is_local_url = true;
42
+ continue;
43
+ }
44
+
45
+ }
46
+ if ( substr_count( $host, '.' ) > 1 ) {
47
+ $subdomains_to_check = array( 'dev.', '*.staging.', 'beta.', 'test.' );
48
+ foreach ( $subdomains_to_check as $subdomain ) {
49
+ $subdomain = str_replace( '.', '(.)', $subdomain );
50
+ $subdomain = str_replace( array( '*', '(.)' ), '(.*)', $subdomain );
51
+ if ( preg_match( '/^(' . $subdomain . ')/', $host ) ) {
52
+ $is_local_url = true;
53
+ continue;
54
+ }
55
+ }
56
+ }
57
+ }
58
+ return $is_local_url;
59
+ }
60
+ public function is_plugin_page() {
61
+ $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
62
+ if ( empty( $screen ) ) {
63
+ return false;
64
+ }
65
+ return ( ! empty( $screen->id ) && in_array( $screen->id, array( 'plugins', 'plugins-network' ), true ) );
66
+ }
67
+ public function tvc_js() {
68
+
69
+ if ( ! $this->is_plugin_page() ) {
70
+ return;
71
+ }
72
+ ?>
73
+ <script type="text/javascript">
74
+ jQuery(function($){
75
+ var $deactivateLink = $('#the-list').find('[data-slug="<?php echo $this->plugin; ?>"] span.deactivate a'),
76
+ $overlay = $('#ee-survey-<?php echo $this->plugin; ?>'),
77
+ $form = $overlay.find('form'),
78
+ formOpen = false;
79
+ // Plugin listing table deactivate link.
80
+ $deactivateLink.on('click', function(event) {
81
+ event.preventDefault();
82
+ $overlay.css('display', 'table');
83
+ formOpen = true;
84
+ $form.find('.ee-survey-option:first-of-type input[type=radio]').focus();
85
+ });
86
+ // Survey radio option selected.
87
+ $form.on('change', 'input[type=radio]', function(event) {
88
+ event.preventDefault();
89
+ $form.find('input[type=text], .error').hide();
90
+ $form.find('.ee-survey-option').removeClass('selected');
91
+ $(this).closest('.ee-survey-option').addClass('selected').find('input[type=text]').show();
92
+ });
93
+ // Survey Skip & Deactivate.
94
+ $form.on('click', '.ee-survey-deactivate', function(event) {
95
+ event.preventDefault();
96
+ location.href = $deactivateLink.attr('href');
97
+ });
98
+ // Survey submit.
99
+ $form.submit(function(event) {
100
+ event.preventDefault();
101
+ if (! $form.find('input[type=radio]:checked').val()) {
102
+ $form.find('.ee-survey-footer').prepend('<span class="error"><?php echo esc_js( __( 'Please select an option', 'google-analytics-for-wordpress' ) ); ?></span>');
103
+ return;
104
+ }
105
+ var data = {
106
+ code: $form.find('.selected input[type=radio]').val(),
107
+ reason: $form.find('.selected .ee-survey-option-reason').text(),
108
+ details: $form.find('.selected input[type=text]').val(),
109
+ site: '<?php echo esc_url( home_url() ); ?>',
110
+ plugin: '<?php echo sanitize_key( $this->name ); ?>'
111
+ }
112
+ var submitSurvey = $.post('<?php echo $this->api_url; ?>', data);
113
+ submitSurvey.always(function() {
114
+ location.href = $deactivateLink.attr('href');
115
+ });
116
+ });
117
+ // Exit key closes survey when open.
118
+ $(document).keyup(function(event) {
119
+ if (27 === event.keyCode && formOpen) {
120
+ $overlay.hide();
121
+ formOpen = false;
122
+ $deactivateLink.focus();
123
+ }
124
+ });
125
+ });
126
+ </script>
127
+ <?php
128
+ }
129
+ public function tvc_css() {
130
+
131
+ if ( ! $this->is_plugin_page() ) {
132
+ return;
133
+ }
134
+ ?>
135
+ <style type="text/css">
136
+ .ee-survey-modal {
137
+ display: none;
138
+ table-layout: fixed;
139
+ position: fixed;
140
+ z-index: 9999;
141
+ width: 100%;
142
+ height: 100%;
143
+ text-align: center;
144
+ font-size: 14px;
145
+ top: 0;
146
+ left: 0;
147
+ background: rgba(0,0,0,0.8);
148
+ }
149
+ .ee-survey-wrap {
150
+ display: table-cell;
151
+ vertical-align: middle;
152
+ }
153
+ .ee-survey {
154
+ background-color: #fff;
155
+ max-width: 550px;
156
+ margin: 0 auto;
157
+ padding: 30px;
158
+ text-align: left;
159
+ }
160
+ .ee-survey .error {
161
+ display: block;
162
+ color: red;
163
+ margin: 0 0 10px 0;
164
+ }
165
+ .ee-survey-title {
166
+ display: block;
167
+ font-size: 18px;
168
+ font-weight: 700;
169
+ text-transform: uppercase;
170
+ border-bottom: 1px solid #ddd;
171
+ padding: 0 0 18px 0;
172
+ margin: 0 0 18px 0;
173
+ }
174
+ .ee-survey-title span {
175
+ color: #999;
176
+ margin-right: 10px;
177
+ }
178
+ .ee-survey-desc {
179
+ display: block;
180
+ font-weight: 600;
181
+ margin: 0 0 18px 0;
182
+ }
183
+ .ee-survey-option {
184
+ margin: 0 0 10px 0;
185
+ }
186
+ .ee-survey-option-input {
187
+ margin-right: 10px !important;
188
+ }
189
+ .ee-survey-option-details {
190
+ display: none;
191
+ width: 90%;
192
+ margin: 10px 0 0 30px;
193
+ }
194
+ .ee-survey-footer {
195
+ margin-top: 18px;
196
+ }
197
+ .ee-survey-deactivate {
198
+ float: right;
199
+ font-size: 13px;
200
+ color: #ccc;
201
+ text-decoration: none;
202
+ padding-top: 7px;
203
+ }
204
+ </style>
205
+ <?php
206
+ }
207
+ public function tvc_modal() {
208
+
209
+ if ( ! $this->is_plugin_page() ) {
210
+ return;
211
+ }
212
+
213
+ $options = array(
214
+ 1 => array(
215
+ "title" => esc_html__("No longer need the plugin","enhanced-e-commerce-for-woocommerce-store"),
216
+ ),
217
+ 2 => array(
218
+ 'title' => esc_html__("Switching to a different plugin","enhanced-e-commerce-for-woocommerce-store"),
219
+ 'details' => esc_html__( 'Please share which plugin', 'google-analytics-for-wordpress' ),
220
+ ),
221
+ 3 => array(
222
+ 'title' => esc_html__("Couldn't get the plugin to work","enhanced-e-commerce-for-woocommerce-store"),
223
+ ),
224
+ 4 => array(
225
+ 'title' => esc_html__("It's a temporary deactivation","enhanced-e-commerce-for-woocommerce-store"),
226
+ ),
227
+ 5 => array(
228
+ 'title' => esc_html__("No longer need the plugin","enhanced-e-commerce-for-woocommerce-store"),
229
+ 'details' => esc_html__( 'Please share the reason', 'google-analytics-for-wordpress' ),
230
+ ),
231
+ );
232
+ ?>
233
+ <div class="ee-survey-modal" id="ee-survey-<?php echo $this->plugin; ?>">
234
+ <div class="ee-survey-wrap">
235
+ <form class="ee-survey" method="post">
236
+ <span class="ee-survey-title"><span class="dashicons dashicons-testimonial"></span><?php echo ' ' . esc_html__( 'Quick Feedback', 'google-analytics-for-wordpress' ); ?></span>
237
+ <span class="ee-survey-desc">
238
+ <?php
239
+ // Translators: Placeholder for the plugin name.
240
+ echo sprintf( esc_html__('If you have a moment, please share why you are deactivating %s:', 'google-analytics-for-wordpress' ), $this->name );
241
+ ?>
242
+ </span>
243
+ <div class="ee-survey-options">
244
+ <?php foreach ( $options as $id => $option ) : ?>
245
+ <div class="ee-survey-option">
246
+ <label for="ee-survey-option-<?php echo $this->plugin; ?>-<?php echo $id; ?>" class="ee-survey-option-label">
247
+ <input id="ee-survey-option-<?php echo $this->plugin; ?>-<?php echo $id; ?>" class="ee-survey-option-input" type="radio" name="code" value="<?php echo $id; ?>" />
248
+ <span class="ee-survey-option-reason"><?php echo $option['title']; ?></span>
249
+ </label>
250
+ <?php if ( ! empty( $option['details'] ) ) : ?>
251
+ <input class="ee-survey-option-details" type="text" placeholder="<?php echo $option['details']; ?>" />
252
+ <?php endif; ?>
253
+ </div>
254
+ <?php endforeach; ?>
255
+ </div>
256
+ <div class="ee-survey-footer">
257
+ <button type="submit" class="ee-survey-submit button button-primary button-large">
258
+ <?php
259
+ // Translators: Adds an ampersand.
260
+ echo sprintf( esc_html__('Submit %s Deactivate', 'google-analytics-for-wordpress' ), '&amp;' );
261
+ ?>
262
+ </button>
263
+ <a href="#" class="ee-survey-deactivate">
264
+ <?php
265
+ // Translators: Adds an ampersand.
266
+ echo sprintf( esc_html__('Skip %s Deactivate', 'google-analytics-for-wordpress' ), '&amp;' );
267
+ ?>
268
+ </a>
269
+ </div>
270
+ </form>
271
+ </div>
272
+ </div>
273
+ <?php
274
+ }
275
+ }
276
+ }
admin/class-survey.php ADDED
@@ -0,0 +1,321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! class_exists( 'TVC_Survey' ) ) {
3
+
4
+ class TVC_Survey {
5
+ public $api_url = TVC_API_CALL_URL.'/customersurvey';
6
+ public $name;
7
+ public $plugin;
8
+ protected $TVC_Admin_DB_Helper;
9
+ protected $apiCustomerId;
10
+ protected $subscriptionId;
11
+ public function __construct( $name = '', $plugin = '' ){
12
+ $this->name = $name;
13
+ $this->plugin = $plugin;
14
+ if ( $this->is_dev_url() ) {
15
+ return;
16
+ }
17
+ $this->TVC_Admin_Helper = new TVC_Admin_Helper();
18
+ $this->apiCustomerId = $this->TVC_Admin_Helper->get_api_customer_id();
19
+ $this->subscriptionId = $this->TVC_Admin_Helper->get_subscriptionId();
20
+
21
+ add_action( 'admin_print_scripts', array( $this, 'tvc_js' ), 20 );
22
+ add_action( 'admin_print_scripts', array( $this, 'tvc_css' ) );
23
+ add_action( 'admin_footer', array( $this, 'tvc_modal' ) );
24
+ }
25
+ public function is_dev_url() {
26
+ $url = network_site_url( '/' );
27
+ $is_local_url = false;
28
+ // Trim it up
29
+ $url = strtolower( trim( $url ) );
30
+ if ( false === strpos( $url, 'http://' ) && false === strpos( $url, 'https://' ) ) {
31
+ $url = 'http://' . $url;
32
+ }
33
+ $url_parts = parse_url( $url );
34
+ $host = ! empty( $url_parts['host'] ) ? $url_parts['host'] : false;
35
+ if ( ! empty( $url ) && ! empty( $host ) ) {
36
+ if ( false !== ip2long( $host ) ) {
37
+ if ( ! filter_var( $host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) ) {
38
+ $is_local_url = true;
39
+ }
40
+ } else if ( 'localhost' === $host ) {
41
+ $is_local_url = true;
42
+ }
43
+
44
+ $tlds_to_check = array( '.dev', '.local', ':8888' );
45
+ foreach ( $tlds_to_check as $tld ) {
46
+ if ( false !== strpos( $host, $tld ) ) {
47
+ $is_local_url = true;
48
+ continue;
49
+ }
50
+
51
+ }
52
+ if ( substr_count( $host, '.' ) > 1 ) {
53
+ $subdomains_to_check = array( 'dev.', '*.staging.', 'beta.', 'test.' );
54
+ foreach ( $subdomains_to_check as $subdomain ) {
55
+ $subdomain = str_replace( '.', '(.)', $subdomain );
56
+ $subdomain = str_replace( array( '*', '(.)' ), '(.*)', $subdomain );
57
+ if ( preg_match( '/^(' . $subdomain . ')/', $host ) ) {
58
+ $is_local_url = true;
59
+ continue;
60
+ }
61
+ }
62
+ }
63
+ }
64
+ return $is_local_url;
65
+ }
66
+ public function is_plugin_page() {
67
+ $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
68
+ if ( empty( $screen ) ) {
69
+ return false;
70
+ }
71
+ return ( ! empty( $screen->id ) && in_array( $screen->id, array( 'plugins', 'plugins-network' ), true ) );
72
+ }
73
+ public function tvc_js() {
74
+
75
+ if ( ! $this->is_plugin_page() ) {
76
+ return;
77
+ }
78
+ ?>
79
+ <script type="text/javascript">
80
+ jQuery(function($){
81
+ var $deactivateLink = $('#the-list').find('[data-slug="<?php echo $this->plugin; ?>"] span.deactivate a'),
82
+ $overlay = $('#ee-survey-<?php echo $this->plugin; ?>'),
83
+ $form = $overlay.find('form'),
84
+ formOpen = false;
85
+ // Plugin listing table deactivate link.
86
+ $deactivateLink.on('click', function(event) {
87
+ event.preventDefault();
88
+ $overlay.css('display', 'table');
89
+ formOpen = true;
90
+ $form.find('.ee-survey-option:first-of-type input[type=radio]').focus();
91
+ });
92
+ // Survey radio option selected.
93
+ $form.on('change', 'input[type=radio]', function(event) {
94
+ event.preventDefault();
95
+ $form.find('input[type=text], .error').hide();
96
+ $form.find('.ee-survey-option').removeClass('selected');
97
+ $(this).closest('.ee-survey-option').addClass('selected').find('input[type=text]').show();
98
+ });
99
+ // Survey Skip & Deactivate.
100
+ $form.on('click', '.ee-survey-deactivate', function(event) {
101
+ event.preventDefault();
102
+ var data = {
103
+ action:'tvc_call_add_survey',
104
+ customer_id:'<?php echo $this->apiCustomerId; ?>',
105
+ subscription_id:'<?php echo $this->subscriptionId; ?>',
106
+ radio_option_val: "skip",
107
+ other_reason: "",
108
+ site_url: '<?php echo esc_url( home_url() ); ?>',
109
+ plugin_name: 'ee-woocommerce'
110
+ }
111
+ add_survey(data);
112
+ });
113
+ // Survey submit.
114
+ $form.submit(function(event) {
115
+ event.preventDefault();
116
+ if (! $form.find('input[type=radio]:checked').val()) {
117
+ $form.find('.ee-survey-footer').prepend('<span class="error"><?php echo esc_js( __( 'Please select an option', 'google-analytics-for-wordpress' ) ); ?></span>');
118
+ return;
119
+ }
120
+ var data = {
121
+ action:'tvc_call_add_survey',
122
+ customer_id:'<?php echo $this->apiCustomerId; ?>',
123
+ subscription_id:'<?php echo $this->subscriptionId; ?>',
124
+ radio_option_val: $form.find('.selected input[type=radio]').val(),
125
+ other_reason: $form.find('.selected input[type=text]').val(),
126
+ site_url: '<?php echo esc_url( home_url() ); ?>',
127
+ plugin_name: 'ee-woocommerce'
128
+ }
129
+ add_survey(data);
130
+ /*var submitSurvey = $.post('<?php echo $this->api_url; ?>', data);
131
+ submitSurvey.always(function() {
132
+ $(".ee-survey-modal").hide(100);
133
+ location.href = $deactivateLink.attr('href');
134
+ });*/
135
+ });
136
+ // Exit key closes survey when open.
137
+ $(document).keyup(function(event) {
138
+ if (27 === event.keyCode && formOpen) {
139
+ $overlay.hide();
140
+ formOpen = false;
141
+ $deactivateLink.focus();
142
+ }
143
+ });
144
+ function add_survey(data){
145
+ $.ajax({
146
+ type: "POST",
147
+ dataType: "json",
148
+ url: '<?php echo admin_url( 'admin-ajax.php' ); ?>',
149
+ data: data,
150
+ beforeSend: function(){
151
+ //$('.ee-survey-submit').html("Thanks..");
152
+ $('.ee-survey-submit').prop('disabled', true);
153
+ $('.ee-survey-deactivate').hide();
154
+ },
155
+ success: function(response){
156
+ $(".ee-survey-modal").hide();
157
+ location.href = $deactivateLink.attr('href');
158
+ }
159
+ });
160
+ }
161
+ });
162
+ </script>
163
+ <?php
164
+ }
165
+ public function tvc_css() {
166
+
167
+ if ( ! $this->is_plugin_page() ) {
168
+ return;
169
+ }
170
+ ?>
171
+ <style type="text/css">
172
+ .ee-survey-modal {
173
+ width: 100%;
174
+ height: 100%;
175
+ display: none;
176
+ table-layout: fixed;
177
+ position: fixed;
178
+ z-index: 9999;
179
+ text-align: center;
180
+ font-size: 14px;
181
+ top: 0;
182
+ left: 0;
183
+ background: rgba(0,0,0,0.8);
184
+ }
185
+ .ee-survey-wrap {
186
+ display: table-cell;
187
+ vertical-align: middle;
188
+ }
189
+ .ee-survey {
190
+ background-color: #fff;
191
+ padding: 32px;
192
+ max-width: 540px;
193
+ margin: 0 auto;
194
+ text-align: left;
195
+ border-radius: 40px;
196
+ }
197
+ .ee-survey .error {
198
+ display: block;
199
+ color: red;
200
+ margin: 0 0 10px 0;
201
+ }
202
+ .ee-survey-title {
203
+ display: block;
204
+ font-size: 18px;
205
+ font-weight: 700;
206
+ text-transform: uppercase;
207
+ border-bottom: 1px solid #ddd;
208
+ padding: 0 0 15px 0;
209
+ margin: 0 0 15px 0;
210
+ }
211
+ .ee-survey-title span {
212
+ color: #999;
213
+ margin-right: 10px;
214
+ }
215
+ .ee-survey-desc {
216
+ display: block;
217
+ font-weight: 600;
218
+ margin: 0 0 15px 0;
219
+ }
220
+ .ee-survey-option {
221
+ margin: 0 0 10px 0;
222
+ }
223
+ .ee-survey-option-input {
224
+ margin-right: 10px !important;
225
+ }
226
+ .ee-survey-option-details {
227
+ display: none;
228
+ width: 90%;
229
+ margin: 10px 0 0 30px;
230
+ }
231
+ .ee-survey-footer {
232
+ margin-top: 15px;
233
+ }
234
+ .ee-survey-deactivate {
235
+ font-size: 13px;
236
+ color: #ccc;
237
+ text-decoration: none;
238
+ margin-top: 7px;
239
+ float: right;
240
+ position: relative;
241
+ display: inline-block;
242
+ }
243
+ .ee-survey-wrap .dashicons{
244
+ font-size: 24px;
245
+ color: #3C434A;
246
+ }
247
+ </style>
248
+ <?php
249
+ }
250
+ public function tvc_modal() {
251
+
252
+ if ( ! $this->is_plugin_page() ) {
253
+ return;
254
+ }
255
+
256
+ $options = array(
257
+ 1 => array(
258
+ "title" => esc_html__("No longer need the plugin","enhanced-e-commerce-for-woocommerce-store"),
259
+ ),
260
+ 2 => array(
261
+ 'title' => esc_html__("Switching to a different plugin","enhanced-e-commerce-for-woocommerce-store"),
262
+ 'details' => esc_html__( 'Please share which plugin', 'google-analytics-for-wordpress' ),
263
+ ),
264
+ 3 => array(
265
+ 'title' => esc_html__("Couldn't get the plugin to work","enhanced-e-commerce-for-woocommerce-store"),
266
+ ),
267
+ 4 => array(
268
+ 'title' => esc_html__("It's a temporary deactivation","enhanced-e-commerce-for-woocommerce-store"),
269
+ ),
270
+ 5 => array(
271
+ 'title' => esc_html__("Other","enhanced-e-commerce-for-woocommerce-store"),
272
+ 'details' => esc_html__( 'Please share the reason', 'google-analytics-for-wordpress' ),
273
+ ),
274
+ );
275
+ ?>
276
+ <div class="ee-survey-modal" id="ee-survey-<?php echo $this->plugin; ?>">
277
+ <div class="ee-survey-wrap">
278
+ <form class="ee-survey" method="post">
279
+ <span class="ee-survey-title"><span class="dashicons dashicons-admin-customizer"></span><?php echo ' ' . esc_html__( 'Quick Feedback', 'google-analytics-for-wordpress' ); ?></span>
280
+ <span class="ee-survey-desc">
281
+ <?php
282
+ // Translators: Placeholder for the plugin name.
283
+ echo sprintf( esc_html__('If you have a moment, please share why you are deactivating %s:', 'google-analytics-for-wordpress' ), $this->name );
284
+ ?>
285
+ </span>
286
+ <div class="ee-survey-options">
287
+ <?php foreach ( $options as $id => $option ) :
288
+ //$slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $option['title']);
289
+ $slug = sanitize_title($option['title']); ?>
290
+ <div class="ee-survey-option">
291
+ <label for="ee-survey-option-<?php echo $this->plugin; ?>-<?php echo $id; ?>" class="ee-survey-option-label">
292
+ <input id="ee-survey-option-<?php echo $this->plugin; ?>-<?php echo $id; ?>" class="ee-survey-option-input" type="radio" name="code" value="<?php echo $slug; ?>" />
293
+ <span class="ee-survey-option-reason"><?php echo $option['title']; ?></span>
294
+ </label>
295
+ <?php if ( ! empty( $option['details'] ) ) : ?>
296
+ <input class="ee-survey-option-details" type="text" placeholder="<?php echo $option['details']; ?>" />
297
+ <?php endif; ?>
298
+ </div>
299
+ <?php endforeach; ?>
300
+ </div>
301
+ <div class="ee-survey-footer">
302
+ <button type="submit" class="ee-survey-submit button button-primary button-large">
303
+ <?php
304
+ // Translators: Adds an ampersand.
305
+ echo sprintf( esc_html__('Submit %s Deactivate', 'google-analytics-for-wordpress' ), '&amp;' );
306
+ ?>
307
+ </button>
308
+ <a href="#" class="ee-survey-deactivate">
309
+ <?php
310
+ // Translators: Adds an ampersand.
311
+ echo sprintf( esc_html__('Skip %s Deactivate', 'google-analytics-for-wordpress' ), '&amp;' );
312
+ ?>
313
+ </a>
314
+ </div>
315
+ </form>
316
+ </div>
317
+ </div>
318
+ <?php
319
+ }
320
+ }
321
+ }
admin/class-tvc-admin-helper.php CHANGED
@@ -156,6 +156,23 @@ Class TVC_Admin_Helper{
156
  return array("error"=>false, "message"=>"Details updated successfully.");
157
  }
158
  /*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  * import GMC products in DB
160
  */
161
  public function import_gmc_products_sync_in_db($next_page_token = null){
@@ -355,6 +372,13 @@ Class TVC_Admin_Helper{
355
  }
356
  }
357
 
 
 
 
 
 
 
 
358
  //tvc_customer = >google_ads_id
359
  public function get_currentCustomerId(){
360
  if(!empty($this->currentCustomerId)){
@@ -383,12 +407,6 @@ Class TVC_Admin_Helper{
383
  return $this->user_currency_symbol;
384
  }
385
  }
386
-
387
- public function add_tvc_log($log_string){
388
- $log = "User: ".date("F j, Y, g:i a").PHP_EOL." Attempt: ".$log_string;
389
- //Save string to log, use FILE_APPEND to append.
390
- file_put_contents('log_tvc.log', $log, FILE_APPEND);
391
- }
392
 
393
  public function add_spinner_html(){
394
  $spinner_gif = ENHANCAD_PLUGIN_URL . '/admin/images/ajax-loader.gif';
@@ -995,4 +1013,22 @@ Class TVC_Admin_Helper{
995
  return false;
996
  }
997
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
998
  }
156
  return array("error"=>false, "message"=>"Details updated successfully.");
157
  }
158
  /*
159
+ * update remarketing snippets
160
+ */
161
+ public function update_remarketing_snippets(){
162
+ $customer_id = $this->get_currentCustomerId();
163
+ if($customer_id != ""){
164
+ $rs = $this->customApiObj->get_remarketing_snippets($customer_id);
165
+ $remarketing_snippets=array();
166
+ if(property_exists($rs,"error") && $rs->error == false){
167
+ if(property_exists($rs,"data") && $rs->data != "") {
168
+ $remarketing_snippets["snippets"]=base64_encode($rs->data->snippets);
169
+ $remarketing_snippets["id"]=$rs->data->id;
170
+ }
171
+ }
172
+ update_option("ee_remarketing_snippets", serialize($remarketing_snippets));
173
+ }
174
+ }
175
+ /*
176
  * import GMC products in DB
177
  */
178
  public function import_gmc_products_sync_in_db($next_page_token = null){
372
  }
373
  }
374
 
375
+ public function get_api_customer_id(){
376
+ $google_detail = $this->get_ee_options_data();
377
+ if(isset($google_detail['setting'])){
378
+ $googleDetail = (array) $google_detail['setting'];
379
+ return ((isset($googleDetail['customer_id']))?$googleDetail['customer_id']:"");
380
+ }
381
+ }
382
  //tvc_customer = >google_ads_id
383
  public function get_currentCustomerId(){
384
  if(!empty($this->currentCustomerId)){
407
  return $this->user_currency_symbol;
408
  }
409
  }
 
 
 
 
 
 
410
 
411
  public function add_spinner_html(){
412
  $spinner_gif = ENHANCAD_PLUGIN_URL . '/admin/images/ajax-loader.gif';
1013
  return false;
1014
  }
1015
  }
1016
+ /*
1017
+ * get user plan id
1018
+ */
1019
+ public function get_plan_id(){
1020
+ if(!empty($this->plan_id)){
1021
+ return $this->plan_id;
1022
+ }else{
1023
+ $plan_id = 1;
1024
+ if(isset($google_detail['setting'])){
1025
+ $googleDetail = $google_detail['setting'];
1026
+ if(isset($googleDetail->plan_id) && !in_array($googleDetail->plan_id, array("1"))){
1027
+ $plan_id = $googleDetail->plan_id;
1028
+ }
1029
+ }
1030
+ return $this->plan_id = $plan_id;
1031
+ }
1032
+ }
1033
+
1034
  }
admin/partials/general-fields.php CHANGED
@@ -100,6 +100,7 @@ if (isset($_GET['connect']) && isset($_GET['subscription_id'])) {
100
  Enhanced_Ecommerce_Google_Settings::add_update_settings('ee_options');
101
  //save data in DB
102
  $TVC_Admin_Helper->set_update_api_to_db($googleDetail, false);
 
103
  if(isset($googleDetail->google_merchant_center_id) || isset($googleDetail->google_ads_id) ){
104
  if( $googleDetail->google_merchant_center_id != "" && $googleDetail->google_ads_id != ""){
105
  wp_redirect("admin.php?page=enhanced-ecommerce-google-analytics-admin-display&tab=sync_product_page&welcome_msg=true");
100
  Enhanced_Ecommerce_Google_Settings::add_update_settings('ee_options');
101
  //save data in DB
102
  $TVC_Admin_Helper->set_update_api_to_db($googleDetail, false);
103
+ $TVC_Admin_Helper->update_remarketing_snippets();
104
  if(isset($googleDetail->google_merchant_center_id) || isset($googleDetail->google_ads_id) ){
105
  if( $googleDetail->google_merchant_center_id != "" && $googleDetail->google_ads_id != ""){
106
  wp_redirect("admin.php?page=enhanced-ecommerce-google-analytics-admin-display&tab=sync_product_page&welcome_msg=true");
enhanced-ecommerce-google-analytics.php CHANGED
@@ -16,7 +16,7 @@
16
  * Plugin Name: Enhanced E-commerce for Woocommerce store
17
  * Plugin URI: https://www.tatvic.com/tatvic-labs/woocommerce-extension/
18
  * Description: Automates eCommerce tracking in Google Analytics, dynamic remarkting in Google Ads, and provides complete Google Shopping features.
19
- * Version: 3.1.1
20
  * Author: Tatvic
21
  * Author URI: www.tatvic.com
22
  * License: GPL-2.0+
@@ -38,7 +38,7 @@ if ( ! defined( 'WPINC' ) ) {
38
  * Start at version 1.0.0 and use SemVer - https://semver.org
39
  * Rename this for your plugin and update it as you release new versions.
40
  */
41
- define( 'PLUGIN_TVC_VERSION', '3.1.1' );
42
  $fullName = plugin_basename( __FILE__ );
43
  $dir = str_replace('/enhanced-ecommerce-google-analytics.php','',$fullName);
44
  if ( ! defined( 'ENHANCAD_PLUGIN_NAME' ) ) {
16
  * Plugin Name: Enhanced E-commerce for Woocommerce store
17
  * Plugin URI: https://www.tatvic.com/tatvic-labs/woocommerce-extension/
18
  * Description: Automates eCommerce tracking in Google Analytics, dynamic remarkting in Google Ads, and provides complete Google Shopping features.
19
+ * Version: 3.1.2
20
  * Author: Tatvic
21
  * Author URI: www.tatvic.com
22
  * License: GPL-2.0+
38
  * Start at version 1.0.0 and use SemVer - https://semver.org
39
  * Rename this for your plugin and update it as you release new versions.
40
  */
41
+ define( 'PLUGIN_TVC_VERSION', '3.1.2' );
42
  $fullName = plugin_basename( __FILE__ );
43
  $dir = str_replace('/enhanced-ecommerce-google-analytics.php','',$fullName);
44
  if ( ! defined( 'ENHANCAD_PLUGIN_NAME' ) ) {
includes/class-enhanced-ecommerce-google-analytics.php CHANGED
@@ -125,6 +125,7 @@ class Enhanced_Ecommerce_Google_Analytics {
125
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-enhanced-ecommerce-google-analytics-settings.php';
126
 
127
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-tvc-admin-auto-product-sync-helper.php';
 
128
 
129
 
130
  /**
@@ -132,7 +133,13 @@ class Enhanced_Ecommerce_Google_Analytics {
132
  * side of the site.
133
  */
134
 
135
- require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-enhanced-ecommerce-google-analytics-public.php';
 
 
 
 
 
 
136
  $this->loader = new Enhanced_Ecommerce_Google_Analytics_Loader();
137
 
138
  }
@@ -166,6 +173,9 @@ class Enhanced_Ecommerce_Google_Analytics {
166
  $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
167
  $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
168
  $this->loader->add_action( 'admin_notices', $plugin_admin, 'tvc_admin_notice' );
 
 
 
169
 
170
  }
171
 
@@ -178,6 +188,7 @@ class Enhanced_Ecommerce_Google_Analytics {
178
  */
179
  private function define_public_hooks() {
180
  $plugin_public = new Enhanced_Ecommerce_Google_Analytics_Public( $this->get_plugin_name(), $this->get_version() );
 
181
  $this->loader->add_action("wp_head", $plugin_public, "ee_settings");
182
  $this->loader->add_action("wp_head", $plugin_public, "add_google_site_verification_tag",1);
183
 
125
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-enhanced-ecommerce-google-analytics-settings.php';
126
 
127
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-tvc-admin-auto-product-sync-helper.php';
128
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-survey.php';
129
 
130
 
131
  /**
133
  * side of the site.
134
  */
135
 
136
+ $TVC_Admin_Helper = new TVC_Admin_Helper();
137
+ $plan_id = $TVC_Admin_Helper->get_plan_id();
138
+ if($plan_id == 1){
139
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-enhanced-ecommerce-google-analytics-public.php';
140
+ }else{
141
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-enhanced-ecommerce-google-analytics-public.php';
142
+ }
143
  $this->loader = new Enhanced_Ecommerce_Google_Analytics_Loader();
144
 
145
  }
173
  $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
174
  $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
175
  $this->loader->add_action( 'admin_notices', $plugin_admin, 'tvc_admin_notice' );
176
+ if ( is_admin() ) {
177
+ new TVC_Survey( "Enhanced ecommerce google analytics plugin for woocommerce", ENHANCAD_PLUGIN_NAME );
178
+ }
179
 
180
  }
181
 
188
  */
189
  private function define_public_hooks() {
190
  $plugin_public = new Enhanced_Ecommerce_Google_Analytics_Public( $this->get_plugin_name(), $this->get_version() );
191
+ $this->loader->add_action("wp_head", $plugin_public, "enqueue_scripts");
192
  $this->loader->add_action("wp_head", $plugin_public, "ee_settings");
193
  $this->loader->add_action("wp_head", $plugin_public, "add_google_site_verification_tag",1);
194
 
includes/data/class-tvc-ajax-file.php CHANGED
@@ -36,6 +36,19 @@ class TVC_Ajax_File extends TVC_Ajax_Calls {
36
  add_action('wp_ajax_tvc_call_notice_dismiss', array($this, 'tvc_call_notice_dismiss'));
37
  add_action('wp_ajax_tvc_call_notification_dismiss', array($this, 'tvc_call_notification_dismiss'));
38
  add_action('wp_ajax_tvc_call_active_licence', array($this, 'tvc_call_active_licence'));
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  }
40
  //active licence key
41
  public function tvc_call_active_licence(){
@@ -704,6 +717,8 @@ class TVC_Ajax_File extends TVC_Ajax_Calls {
704
  ),
705
  'body' => wp_json_encode($data)
706
  );
 
 
707
 
708
  $request = wp_remote_post($url, $args);
709
 
36
  add_action('wp_ajax_tvc_call_notice_dismiss', array($this, 'tvc_call_notice_dismiss'));
37
  add_action('wp_ajax_tvc_call_notification_dismiss', array($this, 'tvc_call_notification_dismiss'));
38
  add_action('wp_ajax_tvc_call_active_licence', array($this, 'tvc_call_active_licence'));
39
+ add_action('wp_ajax_tvc_call_add_survey', array($this, 'tvc_call_add_survey'));
40
+ }
41
+
42
+ public function tvc_call_add_survey(){
43
+ if ( is_admin() ) {
44
+ if(!class_exists('CustomApi')){
45
+ include(ENHANCAD_PLUGIN_DIR . 'includes/setup/CustomApi.php');
46
+ }
47
+ $customObj = new CustomApi();
48
+ unset($_POST['action']);
49
+ echo json_encode($customObj->add_survey_of_deactivate_plugin($_POST));
50
+ exit;
51
+ }
52
  }
53
  //active licence key
54
  public function tvc_call_active_licence(){
717
  ),
718
  'body' => wp_json_encode($data)
719
  );
720
+
721
+
722
 
723
  $request = wp_remote_post($url, $args);
724
 
includes/setup/CustomApi.php CHANGED
@@ -213,6 +213,38 @@ class CustomApi{
213
  return $e->getMessage();
214
  }
215
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  public function active_licence_Key($licence_key, $subscription_id) {
217
  try {
218
  $header = array(
@@ -263,6 +295,53 @@ class CustomApi{
263
  return $e->getMessage();
264
  }
265
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  public function verifyLicenceKey($licence_key, $subscription_id) {
267
  try {
268
  echo $url = $this->apiDomain . '/licence/verify-key';
213
  return $e->getMessage();
214
  }
215
  }
216
+ public function add_survey_of_deactivate_plugin($data) {
217
+ try {
218
+ $header = array(
219
+ "Authorization: Bearer MTIzNA==",
220
+ "content-type: application/json"
221
+ );
222
+ $curl_url = $this->apiDomain . "/customersurvey";
223
+ $postData = json_encode($data);
224
+ $ch = curl_init();
225
+ curl_setopt_array($ch, array(
226
+ CURLOPT_URL => esc_url($curl_url),
227
+ CURLOPT_RETURNTRANSFER => true,
228
+ CURLOPT_TIMEOUT => 1000,
229
+ CURLOPT_HTTPHEADER => $header,
230
+ CURLOPT_POSTFIELDS => $postData
231
+ ));
232
+ $response = curl_exec($ch);
233
+ $response = json_decode($response);
234
+ $return = new \stdClass();
235
+ if (isset($response->error) && $response->error == '') {
236
+ $return->error = false;
237
+ $return->message = $response->message;
238
+ return $return;
239
+ } else {
240
+ $return->error = false;
241
+ $return->message = $response->message;
242
+ return $return;
243
+ }
244
+ } catch (Exception $e) {
245
+ return $e->getMessage();
246
+ }
247
+ }
248
  public function active_licence_Key($licence_key, $subscription_id) {
249
  try {
250
  $header = array(
295
  return $e->getMessage();
296
  }
297
  }
298
+ public function get_remarketing_snippets($customer_id) {
299
+ try {
300
+ $header = array(
301
+ "Authorization: Bearer MTIzNA==",
302
+ "content-type: application/json"
303
+ );
304
+ $curl_url = $this->apiDomain . "/google-ads/remarketing-snippets";
305
+ $postData = [
306
+ 'customer_id' => $customer_id
307
+ ];
308
+ $postData = json_encode($postData);
309
+ $ch = curl_init();
310
+ curl_setopt_array($ch, array(
311
+ CURLOPT_URL => esc_url($curl_url),
312
+ CURLOPT_RETURNTRANSFER => true,
313
+ CURLOPT_TIMEOUT => 1000,
314
+ CURLOPT_HTTPHEADER => $header,
315
+ CURLOPT_POSTFIELDS => $postData
316
+ ));
317
+ $response = curl_exec($ch);
318
+ $response = json_decode($response);
319
+ $return = new \stdClass();
320
+ if (isset($response->error) && $response->error == '') {
321
+ $return->error = false;
322
+ $return->data = $response->data;
323
+ $return->message = $response->message;
324
+ return $return;
325
+ } else {
326
+ if (isset($response->data)) {
327
+ $return->error = false;
328
+ $return->data = $response->data;
329
+ $return->message = $response->message;
330
+ } else {
331
+ $return->error = true;
332
+ $return->data = [];
333
+ if(isset($response->errors->key[0])){
334
+ $return->message = $response->errors->key[0];
335
+ }else{
336
+ $return->message = "";
337
+ }
338
+ }
339
+ return $return;
340
+ }
341
+ } catch (Exception $e) {
342
+ return $e->getMessage();
343
+ }
344
+ }
345
  public function verifyLicenceKey($licence_key, $subscription_id) {
346
  try {
347
  echo $url = $this->apiDomain . '/licence/verify-key';
public/class-enhanced-ecommerce-google-analytics-public-pro.php ADDED
@@ -0,0 +1,1736 @@