Version Description
- New: Facebook pixel
- Tweak: Adjust db and bump up to version 3
- Tweak: Introduced Pixel_Manager and restructured Google Ads class
Download this release
Release Info
Developer | alekv |
Plugin | Pixel Manager for WooCommerce – Track Google Analytics, Google Ads, Facebook and more |
Version | 1.7.13 |
Comparing to | |
See all releases |
Code changes from version 1.6.17 to 1.7.13
- admin/class-admin.php +0 -831
- classes/admin/class-admin.php +1086 -0
- classes/admin/class-ask-for-rating.php +155 -0
- {includes → classes/admin}/index.php +0 -0
- classes/class-db-upgrade.php +138 -0
- classes/index.php +1 -0
- {includes → classes/pixels}/class-cookie-consent-management.php +13 -9
- classes/pixels/class-facebook.php +98 -0
- classes/pixels/class-google.php +342 -0
- classes/pixels/class-pixel-manager.php +121 -0
- classes/pixels/class-pixel.php +102 -0
- classes/pixels/index.php +1 -0
- css/admin.css +40 -0
- css/index.php +1 -0
- freemius/includes/fs-core-functions.php +12 -12
- freemius/package.json +1 -1
- includes/class-ask-for-rating.php +0 -105
- includes/class-db-upgrade.php +0 -62
- includes/class-gtag.php +0 -37
- includes/class-pixel.php +0 -218
- js/admin-helpers.js +0 -9
- js/admin/ask-for-rating.js +38 -0
- js/admin/helpers.js +20 -0
- js/admin/index.php +1 -0
- js/{admin-tabs.js → admin/tabs.js} +0 -0
- js/index.php +1 -0
- js/public/index.php +1 -0
- languages/woocommerce-google-adwords-conversion-tracking-tag-de_DE.mo +0 -0
- languages/woocommerce-google-adwords-conversion-tracking-tag-de_DE.po +0 -93
- languages/woocommerce-google-adwords-conversion-tracking-tag-sr_RS.mo +0 -0
- languages/woocommerce-google-adwords-conversion-tracking-tag-sr_RS.po +0 -96
- languages/woocommerce-google-adwords-conversion-tracking-tag.pot +219 -51
- lib/autoload.php +81 -0
- lib/index.php +1 -0
- readme.txt +114 -19
- uninstall.php +0 -23
- wgact.php +229 -187
admin/class-admin.php
DELETED
@@ -1,831 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// TODO move script for copying debug info into a proper .js enqueued file, or switch tabs to JavaScript switching and always save all settings at the same time
|
4 |
-
// TODO debug info list of active payment gateways
|
5 |
-
|
6 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
-
exit; // Exit if accessed directly
|
8 |
-
}
|
9 |
-
|
10 |
-
class WgactAdmin {
|
11 |
-
|
12 |
-
public $ip;
|
13 |
-
protected $text_domain;
|
14 |
-
protected $options;
|
15 |
-
protected $plugin_hook;
|
16 |
-
|
17 |
-
public function init() {
|
18 |
-
|
19 |
-
$this->plugin_hook = 'woocommerce_page_wgact';
|
20 |
-
|
21 |
-
$this->options = get_option( 'wgact_plugin_options' );
|
22 |
-
|
23 |
-
add_action( 'admin_enqueue_scripts', [$this,'wgact_admin_scripts'] );
|
24 |
-
|
25 |
-
// add the admin options page
|
26 |
-
add_action( 'admin_menu', [ $this, 'wgact_plugin_admin_add_page' ], 99 );
|
27 |
-
|
28 |
-
// install a settings page in the admin console
|
29 |
-
add_action( 'admin_init', [ $this, 'wgact_plugin_admin_init' ] );
|
30 |
-
|
31 |
-
// Load textdomain
|
32 |
-
add_action( 'init', [ $this, 'load_plugin_textdomain' ] );
|
33 |
-
}
|
34 |
-
|
35 |
-
public function wgact_admin_scripts($hook)
|
36 |
-
{
|
37 |
-
if ( $this->plugin_hook != $hook ) {
|
38 |
-
return;
|
39 |
-
}
|
40 |
-
wp_enqueue_script( 'admin-helpers', plugin_dir_url( __DIR__ ) . 'js/admin-helpers.js', array(), WGACT_CURRENT_VERSION, true );
|
41 |
-
wp_enqueue_script( 'admin-tabs', plugin_dir_url( __DIR__ ) . 'js/admin-tabs.js', array(), WGACT_CURRENT_VERSION, true );
|
42 |
-
|
43 |
-
wp_enqueue_style( 'admin-css', plugin_dir_url( __DIR__ ) . 'css/admin.css', array(), WGACT_CURRENT_VERSION );
|
44 |
-
}
|
45 |
-
|
46 |
-
// Load text domain function
|
47 |
-
public function load_plugin_textdomain() {
|
48 |
-
load_plugin_textdomain( 'woocommerce-google-adwords-conversion-tracking-tag', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
49 |
-
}
|
50 |
-
|
51 |
-
// add the admin options page
|
52 |
-
public function wgact_plugin_admin_add_page() {
|
53 |
-
//add_options_page('WGACT Plugin Page', 'WGACT Plugin Menu', 'manage_options', 'wgact', array($this, 'wgact_plugin_options_page'));
|
54 |
-
add_submenu_page(
|
55 |
-
'woocommerce',
|
56 |
-
esc_html__( 'Google Ads Conversion Tracking', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
57 |
-
esc_html__( 'Google Ads Conversion Tracking', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
58 |
-
'manage_options',
|
59 |
-
'wgact',
|
60 |
-
[ $this, 'wgact_plugin_options_page' ]
|
61 |
-
);
|
62 |
-
}
|
63 |
-
|
64 |
-
// add the admin settings and such
|
65 |
-
public function wgact_plugin_admin_init() {
|
66 |
-
|
67 |
-
register_setting(
|
68 |
-
'wgact_plugin_options_group',
|
69 |
-
'wgact_plugin_options',
|
70 |
-
[ $this, 'wgact_options_validate' ]
|
71 |
-
);
|
72 |
-
|
73 |
-
$this->add_section_main();
|
74 |
-
$this->add_section_advanced();
|
75 |
-
$this->add_section_beta();
|
76 |
-
$this->add_section_support();
|
77 |
-
$this->add_section_author();
|
78 |
-
}
|
79 |
-
|
80 |
-
public function add_section_main() {
|
81 |
-
|
82 |
-
$section_ids = [
|
83 |
-
'title' => 'Main',
|
84 |
-
'slug' => 'main',
|
85 |
-
'settings_name' => 'wgact_plugin_main_section',
|
86 |
-
];
|
87 |
-
|
88 |
-
$this->output_section_data_field( $section_ids );
|
89 |
-
|
90 |
-
add_settings_section(
|
91 |
-
$section_ids['settings_name'],
|
92 |
-
esc_html__( $section_ids['title'], 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
93 |
-
[ $this, 'wgact_plugin_section_main_description' ],
|
94 |
-
'wgact_plugin_options_page'
|
95 |
-
);
|
96 |
-
|
97 |
-
$this->add_section_main_subsection_google_ads($section_ids);
|
98 |
-
// $this->add_section_main_subsection_facebook($section_ids);
|
99 |
-
}
|
100 |
-
|
101 |
-
public function add_section_main_subsection_google_ads($section_ids){
|
102 |
-
|
103 |
-
$sub_section_ids = [
|
104 |
-
'title' => 'Google Ads',
|
105 |
-
'slug' => 'google-ads'
|
106 |
-
];
|
107 |
-
|
108 |
-
add_settings_field(
|
109 |
-
'wgact_plugin_subsection_' . $sub_section_ids['slug'] . '_opening_div',
|
110 |
-
esc_html__(
|
111 |
-
$sub_section_ids['title'],
|
112 |
-
'woocommerce-google-adwords-conversion-tracking-tag'
|
113 |
-
),
|
114 |
-
function() use ($section_ids, $sub_section_ids) {
|
115 |
-
$this->wgact_subsection_generic_opening_div_html($section_ids, $sub_section_ids);
|
116 |
-
},
|
117 |
-
'wgact_plugin_options_page',
|
118 |
-
$section_ids['settings_name']
|
119 |
-
);
|
120 |
-
|
121 |
-
// add the field for the conversion id
|
122 |
-
add_settings_field(
|
123 |
-
'wgact_plugin_conversion_id',
|
124 |
-
esc_html__(
|
125 |
-
'Conversion ID',
|
126 |
-
'woocommerce-google-adwords-conversion-tracking-tag'
|
127 |
-
),
|
128 |
-
[ $this, 'wgact_plugin_setting_conversion_id' ],
|
129 |
-
'wgact_plugin_options_page',
|
130 |
-
$section_ids['settings_name']
|
131 |
-
);
|
132 |
-
|
133 |
-
// add the field for the conversion label
|
134 |
-
add_settings_field(
|
135 |
-
'wgact_plugin_conversion_label',
|
136 |
-
esc_html__(
|
137 |
-
'Conversion Label',
|
138 |
-
'woocommerce-google-adwords-conversion-tracking-tag'
|
139 |
-
),
|
140 |
-
[ $this, 'wgact_plugin_setting_conversion_label' ],
|
141 |
-
'wgact_plugin_options_page',
|
142 |
-
$section_ids['settings_name']
|
143 |
-
);
|
144 |
-
}
|
145 |
-
|
146 |
-
public function add_section_main_subsection_facebook($section_ids){
|
147 |
-
|
148 |
-
$sub_section_ids = [
|
149 |
-
'title' => 'Facebook',
|
150 |
-
'slug' => 'facebook'
|
151 |
-
];
|
152 |
-
|
153 |
-
add_settings_field(
|
154 |
-
'wgact_plugin_subsection_' . $sub_section_ids['slug'] . '_opening_div',
|
155 |
-
esc_html__(
|
156 |
-
$sub_section_ids['title'],
|
157 |
-
'woocommerce-google-adwords-conversion-tracking-tag'
|
158 |
-
),
|
159 |
-
function() use ($section_ids, $sub_section_ids) {
|
160 |
-
$this->wgact_subsection_generic_opening_div_html($section_ids, $sub_section_ids);
|
161 |
-
},
|
162 |
-
'wgact_plugin_options_page',
|
163 |
-
$section_ids['settings_name']
|
164 |
-
);
|
165 |
-
|
166 |
-
// add the field for the conversion label
|
167 |
-
add_settings_field(
|
168 |
-
'wgact_plugin_facebook_id',
|
169 |
-
esc_html__(
|
170 |
-
'Facebook ID',
|
171 |
-
'woocommerce-google-adwords-conversion-tracking-tag'
|
172 |
-
),
|
173 |
-
[ $this, 'wgact_plugin_setting_conversion_label' ],
|
174 |
-
'wgact_plugin_options_page',
|
175 |
-
$section_ids['settings_name']
|
176 |
-
);
|
177 |
-
|
178 |
-
}
|
179 |
-
|
180 |
-
public function add_section_advanced() {
|
181 |
-
|
182 |
-
$section_ids = [
|
183 |
-
'title' => 'Advanced',
|
184 |
-
'slug' => 'advanced',
|
185 |
-
'settings_name' => 'wgact_plugin_advanced_section',
|
186 |
-
];
|
187 |
-
|
188 |
-
add_settings_section(
|
189 |
-
$section_ids['settings_name'],
|
190 |
-
esc_html__(
|
191 |
-
$section_ids['title'],
|
192 |
-
'woocommerce-google-adwords-conversion-tracking-tag'
|
193 |
-
),
|
194 |
-
[ $this, 'wgact_plugin_section_advanced_description' ],
|
195 |
-
'wgact_plugin_options_page'
|
196 |
-
);
|
197 |
-
|
198 |
-
$this->output_section_data_field( $section_ids );
|
199 |
-
|
200 |
-
$this->add_section_advanced_subsection_order_logic($section_ids);
|
201 |
-
$this->add_section_advanced_subsection_gtag($section_ids);
|
202 |
-
}
|
203 |
-
|
204 |
-
public function add_section_advanced_subsection_order_logic($section_ids){
|
205 |
-
|
206 |
-
$sub_section_ids = [
|
207 |
-
'title' => 'Order Logic',
|
208 |
-
'slug' => 'order-logic'
|
209 |
-
];
|
210 |
-
|
211 |
-
add_settings_field(
|
212 |
-
'wgact_plugin_subsection_' . $sub_section_ids['slug'] . '_opening_div',
|
213 |
-
esc_html__(
|
214 |
-
$sub_section_ids['title'],
|
215 |
-
'woocommerce-google-adwords-conversion-tracking-tag'
|
216 |
-
),
|
217 |
-
function() use ($section_ids, $sub_section_ids) {
|
218 |
-
$this->wgact_subsection_generic_opening_div_html($section_ids, $sub_section_ids);
|
219 |
-
},
|
220 |
-
'wgact_plugin_options_page',
|
221 |
-
$section_ids['settings_name']
|
222 |
-
);
|
223 |
-
|
224 |
-
// add fields for the order total logic
|
225 |
-
add_settings_field(
|
226 |
-
'wgact_plugin_order_total_logic',
|
227 |
-
esc_html__(
|
228 |
-
'Order Total Logic',
|
229 |
-
'woocommerce-google-adwords-conversion-tracking-tag'
|
230 |
-
),
|
231 |
-
[ $this, 'wgact_plugin_setting_order_total_logic' ],
|
232 |
-
'wgact_plugin_options_page',
|
233 |
-
$section_ids['settings_name']
|
234 |
-
);
|
235 |
-
|
236 |
-
}
|
237 |
-
|
238 |
-
public function add_section_advanced_subsection_gtag($section_ids){
|
239 |
-
|
240 |
-
$sub_section_ids = [
|
241 |
-
'title' => 'Gtag',
|
242 |
-
'slug' => 'gtag'
|
243 |
-
];
|
244 |
-
|
245 |
-
add_settings_field(
|
246 |
-
'wgact_plugin_subsection_' . $sub_section_ids['slug'] . '_opening_div',
|
247 |
-
esc_html__(
|
248 |
-
$sub_section_ids['title'],
|
249 |
-
'woocommerce-google-adwords-conversion-tracking-tag'
|
250 |
-
),
|
251 |
-
function() use ($section_ids, $sub_section_ids) {
|
252 |
-
$this->wgact_subsection_generic_opening_div_html($section_ids, $sub_section_ids);
|
253 |
-
},
|
254 |
-
'wgact_plugin_options_page',
|
255 |
-
$section_ids['settings_name']
|
256 |
-
);
|
257 |
-
|
258 |
-
// add fields for the gtag insertion
|
259 |
-
add_settings_field(
|
260 |
-
'wgact_plugin_gtag',
|
261 |
-
esc_html__(
|
262 |
-
'gtag Deactivation',
|
263 |
-
'woocommerce-google-adwords-conversion-tracking-tag'
|
264 |
-
),
|
265 |
-
[ $this, 'wgact_plugin_setting_gtag_deactivation' ],
|
266 |
-
'wgact_plugin_options_page',
|
267 |
-
$section_ids['settings_name']
|
268 |
-
);
|
269 |
-
}
|
270 |
-
|
271 |
-
public function add_section_beta() {
|
272 |
-
|
273 |
-
$section_ids = [
|
274 |
-
'title' => 'Beta',
|
275 |
-
'slug' => 'beta',
|
276 |
-
'settings_name' => 'wgact_plugin_beta_section',
|
277 |
-
];
|
278 |
-
|
279 |
-
$this->output_section_data_field( $section_ids );
|
280 |
-
|
281 |
-
// add new section for cart data
|
282 |
-
add_settings_section(
|
283 |
-
'wgact_plugin_beta_section',
|
284 |
-
esc_html__(
|
285 |
-
'Beta',
|
286 |
-
'woocommerce-google-adwords-conversion-tracking-tag'
|
287 |
-
),
|
288 |
-
[ $this, 'wgact_plugin_section_add_cart_data_description' ],
|
289 |
-
'wgact_plugin_options_page'
|
290 |
-
);
|
291 |
-
|
292 |
-
// add fields for cart data
|
293 |
-
add_settings_field(
|
294 |
-
'wgact_plugin_add_cart_data',
|
295 |
-
esc_html__(
|
296 |
-
'Activation',
|
297 |
-
'woocommerce-google-adwords-conversion-tracking-tag'
|
298 |
-
),
|
299 |
-
[ $this, 'wgact_plugin_setting_add_cart_data' ],
|
300 |
-
'wgact_plugin_options_page',
|
301 |
-
'wgact_plugin_beta_section'
|
302 |
-
);
|
303 |
-
|
304 |
-
// add the field for the aw_merchant_id
|
305 |
-
add_settings_field(
|
306 |
-
'wgact_plugin_aw_merchant_id',
|
307 |
-
esc_html__(
|
308 |
-
'aw_merchant_id',
|
309 |
-
'woocommerce-google-adwords-conversion-tracking-tag'
|
310 |
-
),
|
311 |
-
[ $this, 'wgact_plugin_setting_aw_merchant_id' ],
|
312 |
-
'wgact_plugin_options_page',
|
313 |
-
'wgact_plugin_beta_section'
|
314 |
-
);
|
315 |
-
|
316 |
-
// add the field for the aw_feed_country
|
317 |
-
add_settings_field(
|
318 |
-
'wgact_plugin_aw_feed_country',
|
319 |
-
esc_html__(
|
320 |
-
'aw_feed_country',
|
321 |
-
'woocommerce-google-adwords-conversion-tracking-tag'
|
322 |
-
),
|
323 |
-
[ $this, 'wgact_plugin_setting_aw_feed_country' ],
|
324 |
-
'wgact_plugin_options_page',
|
325 |
-
'wgact_plugin_beta_section'
|
326 |
-
);
|
327 |
-
|
328 |
-
// add the field for the aw_feed_language
|
329 |
-
add_settings_field(
|
330 |
-
'wgact_plugin_aw_feed_language',
|
331 |
-
esc_html__(
|
332 |
-
'aw_feed_language',
|
333 |
-
'woocommerce-google-adwords-conversion-tracking-tag'
|
334 |
-
),
|
335 |
-
[ $this, 'wgact_plugin_setting_aw_feed_language' ],
|
336 |
-
'wgact_plugin_options_page',
|
337 |
-
'wgact_plugin_beta_section'
|
338 |
-
);
|
339 |
-
|
340 |
-
// add fields for the product identifier
|
341 |
-
add_settings_field(
|
342 |
-
'wgact_plugin_option_product_identifier',
|
343 |
-
esc_html__(
|
344 |
-
'Product Identifier',
|
345 |
-
'woocommerce-google-adwords-conversion-tracking-tag'
|
346 |
-
),
|
347 |
-
[ $this, 'wgact_plugin_option_product_identifier' ],
|
348 |
-
'wgact_plugin_options_page',
|
349 |
-
'wgact_plugin_beta_section'
|
350 |
-
);
|
351 |
-
}
|
352 |
-
|
353 |
-
public function add_section_support() {
|
354 |
-
|
355 |
-
$section_ids = [
|
356 |
-
'title' => 'Support',
|
357 |
-
'slug' => 'support',
|
358 |
-
'settings_name' => 'wgact_plugin_support_section',
|
359 |
-
];
|
360 |
-
|
361 |
-
$this->output_section_data_field( $section_ids );
|
362 |
-
|
363 |
-
add_settings_section(
|
364 |
-
'wgact_plugin_support_section',
|
365 |
-
esc_html__( 'Support', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
366 |
-
[ $this, 'wgact_plugin_section_support_description' ],
|
367 |
-
'wgact_plugin_options_page'
|
368 |
-
);
|
369 |
-
}
|
370 |
-
|
371 |
-
public function add_section_author(){
|
372 |
-
|
373 |
-
$section_ids = [
|
374 |
-
'title' => 'Author',
|
375 |
-
'slug' => 'author',
|
376 |
-
'settings_name' => 'wgact_plugin_author_section',
|
377 |
-
];
|
378 |
-
|
379 |
-
$this->output_section_data_field( $section_ids );
|
380 |
-
|
381 |
-
add_settings_section(
|
382 |
-
'wgact_plugin_author_section',
|
383 |
-
esc_html__( 'Author', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
384 |
-
[ $this, 'wgact_plugin_section_author_description' ],
|
385 |
-
'wgact_plugin_options_page'
|
386 |
-
);
|
387 |
-
}
|
388 |
-
|
389 |
-
protected function output_section_data_field( array $section_ids ): void {
|
390 |
-
add_settings_field(
|
391 |
-
'wgact_plugin_section_' . $section_ids['slug'] . '_opening_div',
|
392 |
-
'',
|
393 |
-
function () use ( $section_ids ) {
|
394 |
-
$this->wgact_section_generic_opening_div_html( $section_ids );
|
395 |
-
},
|
396 |
-
'wgact_plugin_options_page',
|
397 |
-
$section_ids['settings_name']
|
398 |
-
);
|
399 |
-
}
|
400 |
-
|
401 |
-
public function wgact_section_generic_opening_div_html($section_ids) {
|
402 |
-
echo '<div class="section" data-section-title="' . $section_ids['title'] . '" data-section-slug="' . $section_ids['slug'] . '"></div>';
|
403 |
-
}
|
404 |
-
|
405 |
-
public function wgact_subsection_generic_opening_div_html($section_ids, $sub_section_ids) {
|
406 |
-
echo '<div class="subsection" data-section-slug="' . $section_ids['slug'] . '" data-subsection-title="' . $sub_section_ids['title'] . '" data-subsection-slug="' . $sub_section_ids['slug'] . '"></div>';
|
407 |
-
}
|
408 |
-
|
409 |
-
// display the admin options page
|
410 |
-
public function wgact_plugin_options_page() {
|
411 |
-
?>
|
412 |
-
|
413 |
-
<div style="width:980px; float: left; margin: 5px">
|
414 |
-
<div style="float:left; margin: 5px; margin-right:20px; width:750px">
|
415 |
-
|
416 |
-
<?php settings_errors(); ?>
|
417 |
-
|
418 |
-
<h2 class="nav-tab-wrapper">
|
419 |
-
</h2>
|
420 |
-
|
421 |
-
<form id="wgact_settings_form" action="options.php" method="post">
|
422 |
-
|
423 |
-
<?php
|
424 |
-
|
425 |
-
settings_fields( 'wgact_plugin_options_group' );
|
426 |
-
do_settings_sections( 'wgact_plugin_options_page' );
|
427 |
-
submit_button();
|
428 |
-
?>
|
429 |
-
|
430 |
-
</form>
|
431 |
-
|
432 |
-
<div style="background: #0073aa; padding: 10px; font-weight: bold; color: white; margin-bottom: 20px; border-radius: 2px">
|
433 |
-
<span>
|
434 |
-
<?php esc_html_e( 'Profit Driven Marketing by Wolf+Bär', 'woocommerce-google-adwords-conversion-tracking-tag' ) ?>
|
435 |
-
</span>
|
436 |
-
<span style="float: right;">
|
437 |
-
<a href="https://wolfundbaer.ch/"
|
438 |
-
target="_blank" style="color: white">
|
439 |
-
<?php esc_html_e( 'Visit us here: https://wolfundbaer.ch', 'woocommerce-google-adwords-conversion-tracking-tag' ) ?>
|
440 |
-
</a>
|
441 |
-
</span>
|
442 |
-
</div>
|
443 |
-
</div>
|
444 |
-
<div style="float: left; margin: 5px">
|
445 |
-
<a href="https://wordpress.org/plugins/woocommerce-google-dynamic-retargeting-tag/" target="_blank">
|
446 |
-
<img src="<?php echo( plugins_url( '../images/wgdr-icon-256x256.png', __FILE__ ) ) ?>" width="150px"
|
447 |
-
height="150px">
|
448 |
-
</a>
|
449 |
-
</div>
|
450 |
-
<div style="float: left; margin: 5px">
|
451 |
-
<a href="https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-tag/"
|
452 |
-
target="_blank">
|
453 |
-
<img src="<?php echo( plugins_url( '../images/wgact-icon-256x256.png', __FILE__ ) ) ?>"
|
454 |
-
width="150px"
|
455 |
-
height="150px">
|
456 |
-
</a>
|
457 |
-
</div>
|
458 |
-
</div>
|
459 |
-
<?php
|
460 |
-
}
|
461 |
-
|
462 |
-
// descriptions
|
463 |
-
|
464 |
-
public function wgact_plugin_section_main_description() {
|
465 |
-
// do nothing
|
466 |
-
}
|
467 |
-
|
468 |
-
public function wgact_plugin_section_advanced_description() {
|
469 |
-
// do nothing
|
470 |
-
}
|
471 |
-
|
472 |
-
public function wgact_plugin_section_add_cart_data_description() {
|
473 |
-
echo '<div id="beta-description" style="margin-top:20px">';
|
474 |
-
|
475 |
-
esc_html_e( 'Find out more about this new feature: ', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
476 |
-
echo '<a href="https://support.google.com/google-ads/answer/9028254" target="_blank">https://support.google.com/google-ads/answer/9028254</a><br>';
|
477 |
-
esc_html_e( 'At the moment we are testing this feature. It might go into a PRO version of this plugin in the future.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
478 |
-
echo '</div>';
|
479 |
-
}
|
480 |
-
|
481 |
-
public function wgact_plugin_section_support_description() {
|
482 |
-
?>
|
483 |
-
<div style="margin-top:20px">
|
484 |
-
<?php esc_html_e( 'Use the following two resources for support: ', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?>
|
485 |
-
</div>
|
486 |
-
<div style="margin-bottom: 30px;">
|
487 |
-
<ul>
|
488 |
-
|
489 |
-
<li>
|
490 |
-
<?php esc_html_e( 'Post a support request in the WordPress support forum here: ', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?>
|
491 |
-
<a href="https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag/"
|
492 |
-
target="_blank">https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag/</a>
|
493 |
-
</li>
|
494 |
-
<li>
|
495 |
-
<?php esc_html_e( 'Or send us an email to the following address: ', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?>
|
496 |
-
<a href="mailto:support@wolfundbaer.ch" target="_blank">support@wolfundbaer.ch</a>
|
497 |
-
</li>
|
498 |
-
</ul>
|
499 |
-
</div>
|
500 |
-
<div class=" woocommerce-message">
|
501 |
-
|
502 |
-
<div>
|
503 |
-
<textarea id="debug-info-textarea" class="" style="color:dimgrey;resize: none;" cols="100%" rows="30"
|
504 |
-
readonly><?php echo $this->get_debug_info() ?></textarea>
|
505 |
-
<button id="debug-info-button" type="button"><?php esc_html_e('copy to clipboard', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?></button>
|
506 |
-
</div>
|
507 |
-
|
508 |
-
</div>
|
509 |
-
|
510 |
-
<?php
|
511 |
-
}
|
512 |
-
|
513 |
-
public function wgact_plugin_section_author_description() {
|
514 |
-
?>
|
515 |
-
<div style="margin-top:20px;margin-bottom: 30px">
|
516 |
-
<?php esc_html_e( 'More details about the developer of this plugin: ', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?>
|
517 |
-
</div>
|
518 |
-
<div style="margin-bottom: 30px;">
|
519 |
-
<div><?php esc_html_e( 'Developer: Wolf+Bär Agency', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?></div>
|
520 |
-
<div><?php esc_html_e( 'Website: ', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?><a href="https://wolfundbaer.ch" target="_blank">https://wolfundbaer.ch</a></div>
|
521 |
-
|
522 |
-
</div>
|
523 |
-
<?php
|
524 |
-
}
|
525 |
-
|
526 |
-
public function get_debug_info(): string {
|
527 |
-
global $woocommerce, $wp_version, $current_user;
|
528 |
-
|
529 |
-
$html = '### Debugging Information ###' . PHP_EOL . PHP_EOL;
|
530 |
-
|
531 |
-
$html .= '## System Environment ##' . PHP_EOL . PHP_EOL;
|
532 |
-
|
533 |
-
$html .= 'This plugin\'s version: ' . WGACT_CURRENT_VERSION . PHP_EOL;
|
534 |
-
|
535 |
-
$html .= PHP_EOL;
|
536 |
-
|
537 |
-
$html .= 'WordPress version: ' . $wp_version . PHP_EOL;
|
538 |
-
$html .= 'WooCommerce version: ' . $woocommerce->version . PHP_EOL;
|
539 |
-
$html .= 'PHP version: ' . phpversion() . PHP_EOL;
|
540 |
-
|
541 |
-
$html .= PHP_EOL;
|
542 |
-
|
543 |
-
$multisite_enabled = is_multisite() ? 'yes' : 'no';
|
544 |
-
$html .= 'Multisite enabled: ' . $multisite_enabled . PHP_EOL;
|
545 |
-
|
546 |
-
$wp_debug = 'no';
|
547 |
-
if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) {
|
548 |
-
$wp_debug = 'yes';
|
549 |
-
}
|
550 |
-
|
551 |
-
$html .= 'WordPress debug mode enabled: ' . $wp_debug . PHP_EOL;
|
552 |
-
|
553 |
-
wp_get_current_user();
|
554 |
-
$html .= 'Logged in user login name: ' . $current_user->user_login . PHP_EOL;
|
555 |
-
$html .= 'Logged in user display name: ' . $current_user->display_name . PHP_EOL;
|
556 |
-
|
557 |
-
$html .= PHP_EOL . '## WooCommerce ##' . PHP_EOL . PHP_EOL;
|
558 |
-
|
559 |
-
$html .= 'Default currency: ' . get_woocommerce_currency() . PHP_EOL;
|
560 |
-
$html .= 'Shop URL: ' . get_home_url() . PHP_EOL;
|
561 |
-
$html .= 'Cart URL: ' . wc_get_cart_url() . PHP_EOL;
|
562 |
-
$html .= 'Checkout URL: ' . wc_get_checkout_url() . PHP_EOL;
|
563 |
-
|
564 |
-
$last_order_id = $this->get_last_order_id();
|
565 |
-
// echo('last order: ' . $last_order_id . PHP_EOL);
|
566 |
-
$last_order = new WC_Order( wc_get_order( $last_order_id ) );
|
567 |
-
$html .= 'Last order URL: ' . $last_order->get_checkout_order_received_url() . PHP_EOL;
|
568 |
-
|
569 |
-
|
570 |
-
$html .= PHP_EOL . '## Theme ##' . PHP_EOL . PHP_EOL;
|
571 |
-
|
572 |
-
$is_child_theme = is_child_theme() ? 'yes' : 'no';
|
573 |
-
$html .= 'Is child theme: ' . $is_child_theme . PHP_EOL;
|
574 |
-
$theme_support = current_theme_supports( 'woocommerce' ) ? 'yes' : 'no';
|
575 |
-
$html .= 'WooCommerce support: ' . $theme_support . PHP_EOL;
|
576 |
-
|
577 |
-
$html .= PHP_EOL;
|
578 |
-
|
579 |
-
$style_parent_theme = wp_get_theme( get_template() );
|
580 |
-
$style_parent_theme_author = $style_parent_theme->get( 'Author' );
|
581 |
-
|
582 |
-
$theme_description_prefix = is_child_theme() ? 'Child theme ' : 'Theme ';
|
583 |
-
|
584 |
-
$html .= $theme_description_prefix . 'Name: ' . wp_get_theme()->get( 'Name' ) . PHP_EOL;
|
585 |
-
$html .= $theme_description_prefix . 'ThemeURI: ' . wp_get_theme()->get( 'ThemeURI' ) . PHP_EOL;
|
586 |
-
$html .= $theme_description_prefix . 'Author: ' . wp_get_theme()->get( 'Author' ) . PHP_EOL;
|
587 |
-
$html .= $theme_description_prefix . 'AuthorURI: ' . wp_get_theme()->get( 'AuthorURI' ) . PHP_EOL;
|
588 |
-
$html .= $theme_description_prefix . 'Version: ' . wp_get_theme()->get( 'Version' ) . PHP_EOL;
|
589 |
-
$html .= $theme_description_prefix . 'Template: ' . wp_get_theme()->get( 'Template' ) . PHP_EOL;
|
590 |
-
$html .= $theme_description_prefix . 'Status: ' . wp_get_theme()->get( 'Status' ) . PHP_EOL;
|
591 |
-
$html .= $theme_description_prefix . 'TextDomain: ' . wp_get_theme()->get( 'TextDomain' ) . PHP_EOL;
|
592 |
-
$html .= $theme_description_prefix . 'DomainPath: ' . wp_get_theme()->get( 'DomainPath' ) . PHP_EOL;
|
593 |
-
|
594 |
-
$html .= PHP_EOL;
|
595 |
-
|
596 |
-
if ( is_child_theme() ) {
|
597 |
-
$html .= 'Parent theme Name: ' . wp_get_theme()->parent()->get( 'Name' ) . PHP_EOL;
|
598 |
-
$html .= 'Parent theme ThemeURI: ' . wp_get_theme()->parent()->get( 'ThemeURI' ) . PHP_EOL;
|
599 |
-
$html .= 'Parent theme Author: ' . wp_get_theme()->parent()->get( 'Author' ) . PHP_EOL;
|
600 |
-
$html .= 'Parent theme AuthorURI: ' . wp_get_theme()->parent()->get( 'AuthorURI' ) . PHP_EOL;
|
601 |
-
$html .= 'Parent theme Version: ' . wp_get_theme()->parent()->get( 'Version' ) . PHP_EOL;
|
602 |
-
$html .= 'Parent theme Template: ' . wp_get_theme()->parent()->get( 'Template' ) . PHP_EOL;
|
603 |
-
$html .= 'Parent theme Status: ' . wp_get_theme()->parent()->get( 'Status' ) . PHP_EOL;
|
604 |
-
$html .= 'Parent theme TextDomain: ' . wp_get_theme()->parent()->get( 'TextDomain' ) . PHP_EOL;
|
605 |
-
$html .= 'Parent theme DomainPath: ' . wp_get_theme()->parent()->get( 'DomainPath' ) . PHP_EOL;
|
606 |
-
}
|
607 |
-
|
608 |
-
// TODO maybe add all active plugins
|
609 |
-
|
610 |
-
$html .= PHP_EOL . PHP_EOL . '### End of Information ###';
|
611 |
-
|
612 |
-
return $html;
|
613 |
-
}
|
614 |
-
|
615 |
-
public function get_last_order_id() {
|
616 |
-
global $wpdb;
|
617 |
-
$statuses = array_keys( wc_get_order_statuses() );
|
618 |
-
$statuses = implode( "','", $statuses );
|
619 |
-
|
620 |
-
// Getting last Order ID (max value)
|
621 |
-
$results = $wpdb->get_col( "
|
622 |
-
SELECT MAX(ID) FROM {$wpdb->prefix}posts
|
623 |
-
WHERE post_type LIKE 'shop_order'
|
624 |
-
AND post_status IN ('$statuses')
|
625 |
-
" );
|
626 |
-
|
627 |
-
return reset( $results );
|
628 |
-
}
|
629 |
-
|
630 |
-
public function wgact_plugin_setting_conversion_id() {
|
631 |
-
echo "<input id='wgact_plugin_conversion_id' name='wgact_plugin_options[conversion_id]' size='40' type='text' value='{$this->options['conversion_id']}' />";
|
632 |
-
echo '<br><br>';
|
633 |
-
esc_html_e( 'The conversion ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
634 |
-
echo ' <i>123456789</i>';
|
635 |
-
echo '<p>';
|
636 |
-
esc_html_e( 'Watch a video that explains how to find the conversion ID: ', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
637 |
-
echo '<a href="https://www.youtube.com/watch?v=p9gY3JSrNHU" target="_blank">https://www.youtube.com/watch?v=p9gY3JSrNHU</a>';
|
638 |
-
}
|
639 |
-
|
640 |
-
public function wgact_plugin_setting_conversion_label() {
|
641 |
-
echo "<input id='wgact_plugin_conversion_label' name='wgact_plugin_options[conversion_label]' size='40' type='text' value='{$this->options['conversion_label']}' />";
|
642 |
-
echo '<br><br>';
|
643 |
-
esc_html_e( 'The conversion Label looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
644 |
-
echo ' <i>Xt19CO3axGAX0vg6X3gM</i>';
|
645 |
-
echo '<p>';
|
646 |
-
esc_html_e( 'Watch a video that explains how to find the conversion ID: ', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
647 |
-
echo '<a href="https://www.youtube.com/watch?v=p9gY3JSrNHU" target="_blank">https://www.youtube.com/watch?v=p9gY3JSrNHU</a>';
|
648 |
-
}
|
649 |
-
|
650 |
-
public function wgact_plugin_setting_order_total_logic() {
|
651 |
-
?>
|
652 |
-
<input type='radio' id='wgact_plugin_option_product_identifier_0' name='wgact_plugin_options[order_total_logic]'
|
653 |
-
value='0' <?php echo( checked( 0, $this->options['order_total_logic'], false ) ) ?> ><?php esc_html_e( 'Use order_subtotal: Doesn\'t include tax and shipping (default)', 'woocommerce-google-adwords-conversion-tracking-tag' ) ?>
|
654 |
-
<br>
|
655 |
-
<input type='radio' id='wgact_plugin_option_product_identifier_1' name='wgact_plugin_options[order_total_logic]'
|
656 |
-
value='1' <?php echo( checked( 1, $this->options['order_total_logic'], false ) ) ?> ><?php esc_html_e( 'Use order_total: Includes tax and shipping', 'woocommerce-google-adwords-conversion-tracking-tag' ) ?>
|
657 |
-
<br><br>
|
658 |
-
<?php esc_html_e( 'This is the order total amount reported back to Google Ads', 'woocommerce-google-adwords-conversion-tracking-tag' ) ?>
|
659 |
-
<?php
|
660 |
-
}
|
661 |
-
|
662 |
-
public function wgact_plugin_setting_gtag_deactivation() {
|
663 |
-
?>
|
664 |
-
<input type='checkbox' id='wgact_plugin_option_gtag_deactivation' name='wgact_plugin_options[gtag_deactivation]'
|
665 |
-
value='1' <?php checked( $this->options['gtag_deactivation'] ); ?> />
|
666 |
-
<?php esc_html_e( 'Disable gtag.js insertion if another plugin is inserting it already.', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
667 |
-
}
|
668 |
-
|
669 |
-
public function wgact_plugin_setting_add_cart_data() {
|
670 |
-
?>
|
671 |
-
<input type='checkbox' id='wgact_plugin_add_cart_data' name='wgact_plugin_options[add_cart_data]' size='40'
|
672 |
-
value='1' <?php echo( checked( 1, $this->options['add_cart_data'], true ) ) ?> >
|
673 |
-
<?php
|
674 |
-
esc_html_e( 'Add the cart data to the conversion event', 'woocommerce-google-adwords-conversion-tracking-tag' );
|
675 |
-
}
|
676 |
-
|
677 |
-
public function wgact_plugin_setting_aw_merchant_id() {
|
678 |
-
echo "<input type='text' id='wgact_plugin_aw_merchant_id' name='wgact_plugin_options[aw_merchant_id]' size='40' value='{$this->options['aw_merchant_id']}' />";
|
679 |
-
echo '<br><br>';
|
680 |
-
esc_html_e('Enter the ID of your Google Merchant Center account.', 'woocommerce-google-adwords-conversion-tracking-tag');
|
681 |
-
}
|
682 |
-
|
683 |
-
public function wgact_plugin_setting_aw_feed_country() {
|
684 |
-
|
685 |
-
?><b><?php echo $this->get_visitor_country() ?></b><?php
|
686 |
-
// echo '<br>' . 'get_external_ip_address: ' . WC_Geolocation::get_external_ip_address();
|
687 |
-
// echo '<br>' . 'get_ip_address: ' . WC_Geolocation::get_ip_address();
|
688 |
-
// echo '<p>' . 'geolocate_ip: ' . '<br>';
|
689 |
-
// echo print_r(WC_Geolocation::geolocate_ip());
|
690 |
-
// echo '<p>' . 'WC_Geolocation::geolocate_ip(WC_Geolocation::get_external_ip_address()): ' . '<br>';
|
691 |
-
// echo print_r(WC_Geolocation::geolocate_ip(WC_Geolocation::get_external_ip_address()));
|
692 |
-
?>
|
693 |
-
<div style="margin-top:10px">
|
694 |
-
<?php
|
695 |
-
esc_html_e('Currently the plugin automatically detects the location of the visitor for this setting. In most, if not all, cases this will work fine. Please let us know if you have a use case where you need another output:', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?>
|
696 |
-
<a href="mailto:support@wolfundbaer.ch">support@wolfundbaer.ch</a>
|
697 |
-
</div>
|
698 |
-
<?php
|
699 |
-
}
|
700 |
-
|
701 |
-
// dupe in pixel
|
702 |
-
public function get_visitor_country() {
|
703 |
-
|
704 |
-
if ( $this->isLocalhost() ) {
|
705 |
-
// error_log('check external ip');
|
706 |
-
$this->ip = WC_Geolocation::get_external_ip_address();
|
707 |
-
} else {
|
708 |
-
// error_log('check regular ip');
|
709 |
-
$this->ip = WC_Geolocation::get_ip_address();
|
710 |
-
}
|
711 |
-
|
712 |
-
$location = WC_Geolocation::geolocate_ip( $this->ip );
|
713 |
-
|
714 |
-
// error_log ('ip: ' . $this->>$ip);
|
715 |
-
// error_log ('country: ' . $location['country']);
|
716 |
-
return $location['country'];
|
717 |
-
}
|
718 |
-
|
719 |
-
// dupe in pixel
|
720 |
-
public function isLocalhost() {
|
721 |
-
return in_array( $_SERVER['REMOTE_ADDR'], [ '127.0.0.1', '::1' ] );
|
722 |
-
}
|
723 |
-
|
724 |
-
public function wgact_plugin_setting_aw_feed_language() {
|
725 |
-
?><b><?php echo $this->get_gmc_language() ?></b>
|
726 |
-
<div style="margin-top:10px">
|
727 |
-
<?php esc_html_e('The plugin will use the WordPress default language for this setting. If the shop uses translations, in theory we could also use the visitors locale. But, if that language is not set up in the Google Merchant Center we might run into issues. If you need more options here let us know:', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?>
|
728 |
-
<a href=\"mailto:support@wolfundbaer.ch\">support@wolfundbaer.ch</a>
|
729 |
-
</div>
|
730 |
-
<?php
|
731 |
-
}
|
732 |
-
|
733 |
-
// dupe in pixel
|
734 |
-
public function get_gmc_language() {
|
735 |
-
return strtoupper( substr( get_locale(), 0, 2 ) );
|
736 |
-
}
|
737 |
-
|
738 |
-
public function wgact_plugin_option_product_identifier() {
|
739 |
-
?>
|
740 |
-
<input type='radio' id='wgact_plugin_option_product_identifier_0'
|
741 |
-
name='wgact_plugin_options[product_identifier]'
|
742 |
-
value='0' <?php echo( checked( 0, $this->options['product_identifier'], false ) ) ?>/><?php esc_html_e( 'post id (default)', 'woocommerce-google-adwords-conversion-tracking-tag' ) ?>
|
743 |
-
<br>
|
744 |
-
|
745 |
-
<input type='radio' id='wgact_plugin_option_product_identifier_1'
|
746 |
-
name='wgact_plugin_options[product_identifier]'
|
747 |
-
value='1' <?php echo( checked( 1, $this->options['product_identifier'], false ) ) ?>/><?php esc_html_e( 'post id with woocommerce_gpf_ prefix *', 'woocommerce-google-adwords-conversion-tracking-tag' ) ?>
|
748 |
-
<br>
|
749 |
-
|
750 |
-
<input type='radio' id='wgact_plugin_option_product_identifier_1'
|
751 |
-
name='wgact_plugin_options[product_identifier]'
|
752 |
-
value='2' <?php echo( checked( 2, $this->options['product_identifier'], false ) ) ?>/><?php esc_html_e( 'SKU', 'woocommerce-google-adwords-conversion-tracking-tag' ) ?>
|
753 |
-
<br><br>
|
754 |
-
|
755 |
-
<?php esc_html_e( 'Choose a product identifier.', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?>
|
756 |
-
<br><br>
|
757 |
-
<?php esc_html_e( '* This is for users of the WooCommerce Google Product Feed Plugin', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?>
|
758 |
-
<a href="https://woocommerce.com/products/google-product-feed/" target="_blank">WooCommerce Google Product Feed Plugin</a>
|
759 |
-
|
760 |
-
|
761 |
-
<?php
|
762 |
-
}
|
763 |
-
|
764 |
-
// validate the options
|
765 |
-
public function wgact_options_validate( $input ) {
|
766 |
-
|
767 |
-
// error_log('input');
|
768 |
-
// error_log(print_r($input, true));
|
769 |
-
|
770 |
-
// validate ['conversion_id']
|
771 |
-
if ( isset( $input['conversion_id'] ) ) {
|
772 |
-
if ( ! $this->is_conversion_id( $input['conversion_id'] ) ) {
|
773 |
-
$input['conversion_id'] = isset( $this->options['conversion_id'] ) ? $this->options['conversion_id'] : '';
|
774 |
-
add_settings_error( 'wgact_plugin_options', 'invalid-conversion-id', 'You have entered an invalid conversion id.' );
|
775 |
-
}
|
776 |
-
}
|
777 |
-
|
778 |
-
// validate ['conversion_label']
|
779 |
-
if ( isset( $input['conversion_label'] ) ) {
|
780 |
-
if ( ! $this->is_conversion_label( $input['conversion_label'] ) ) {
|
781 |
-
$input['conversion_label'] = isset( $this->options['conversion_label'] ) ? $this->options['conversion_label'] : '';
|
782 |
-
add_settings_error( 'wgact_plugin_options', 'invalid-conversion-label', 'You have entered an invalid conversion label.' );
|
783 |
-
}
|
784 |
-
}
|
785 |
-
|
786 |
-
|
787 |
-
// merging with the existing options
|
788 |
-
// and overwriting old values
|
789 |
-
|
790 |
-
// since disabling a checkbox doesn't send a value,
|
791 |
-
// we need to set one to overwrite the old value
|
792 |
-
|
793 |
-
// list of all checkbox keys
|
794 |
-
// $checkbox_keys = [ 'add_cart_data', 'gtag_deactivation' ];
|
795 |
-
//
|
796 |
-
// foreach ( $checkbox_keys as $checkbox_key ) {
|
797 |
-
// if ( ! isset( $input[ $checkbox_key ] ) ) {
|
798 |
-
// $input[ $checkbox_key ] = 0;
|
799 |
-
// }
|
800 |
-
// }
|
801 |
-
//
|
802 |
-
// $input = array_merge( $this->options, $input );
|
803 |
-
|
804 |
-
return $input;
|
805 |
-
}
|
806 |
-
|
807 |
-
public function is_conversion_id( $string ) {
|
808 |
-
|
809 |
-
$re = '/^\d{8,11}$/m';
|
810 |
-
|
811 |
-
return $this->validate_with_regex( $re, $string );
|
812 |
-
}
|
813 |
-
|
814 |
-
public function is_conversion_label( $string ) {
|
815 |
-
|
816 |
-
$re = '/^[-a-zA-Z_0-9]{17,20}$/m';
|
817 |
-
|
818 |
-
return $this->validate_with_regex( $re, $string );
|
819 |
-
}
|
820 |
-
|
821 |
-
protected function validate_with_regex( string $re, $string ): bool {
|
822 |
-
preg_match_all( $re, $string, $matches, PREG_SET_ORDER, 0 );
|
823 |
-
|
824 |
-
if ( isset( $matches[0] ) ) {
|
825 |
-
return true;
|
826 |
-
} else {
|
827 |
-
return false;
|
828 |
-
}
|
829 |
-
}
|
830 |
-
|
831 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/admin/class-admin.php
ADDED
@@ -0,0 +1,1086 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// TODO move script for copying debug info into a proper .js enqueued file, or switch tabs to JavaScript switching and always save all settings at the same time
|
4 |
+
// TODO debug info list of active payment gateways
|
5 |
+
|
6 |
+
namespace WGACT\Classes\Admin;
|
7 |
+
|
8 |
+
use WC_Geolocation;
|
9 |
+
use WC_Order;
|
10 |
+
|
11 |
+
if (!defined('ABSPATH')) {
|
12 |
+
exit; // Exit if accessed directly
|
13 |
+
}
|
14 |
+
|
15 |
+
class Admin
|
16 |
+
{
|
17 |
+
|
18 |
+
public $ip;
|
19 |
+
protected $text_domain;
|
20 |
+
protected $options;
|
21 |
+
protected $plugin_hook;
|
22 |
+
protected $documentation_host;
|
23 |
+
|
24 |
+
public function __construct()
|
25 |
+
{
|
26 |
+
|
27 |
+
$this->plugin_hook = 'woocommerce_page_wgact';
|
28 |
+
$this->documentation_host = 'docs.wolfundbaer.ch';
|
29 |
+
|
30 |
+
$this->options = get_option('wgact_plugin_options');
|
31 |
+
|
32 |
+
add_action('admin_enqueue_scripts', [$this, 'wgact_admin_scripts']);
|
33 |
+
|
34 |
+
// add the admin options page
|
35 |
+
add_action('admin_menu', [$this, 'wgact_plugin_admin_add_page'], 99);
|
36 |
+
|
37 |
+
// install a settings page in the admin console
|
38 |
+
add_action('admin_init', [$this, 'wgact_plugin_admin_init']);
|
39 |
+
|
40 |
+
// Load textdomain
|
41 |
+
add_action('init', [$this, 'load_plugin_textdomain']);
|
42 |
+
}
|
43 |
+
|
44 |
+
public function wgact_admin_scripts($hook)
|
45 |
+
{
|
46 |
+
if ($this->plugin_hook != $hook) {
|
47 |
+
return;
|
48 |
+
}
|
49 |
+
wp_enqueue_script('admin-helpers', plugin_dir_url(__DIR__) . '../js/admin/helpers.js', array(), WGACT_CURRENT_VERSION, true);
|
50 |
+
wp_enqueue_script('admin-tabs', plugin_dir_url(__DIR__) . '../js/admin/tabs.js', array(), WGACT_CURRENT_VERSION, true);
|
51 |
+
|
52 |
+
wp_enqueue_style('admin-css', plugin_dir_url(__DIR__) . '../css/admin.css', array(), WGACT_CURRENT_VERSION);
|
53 |
+
}
|
54 |
+
|
55 |
+
// Load text domain function
|
56 |
+
public function load_plugin_textdomain()
|
57 |
+
{
|
58 |
+
load_plugin_textdomain('woocommerce-google-adwords-conversion-tracking-tag', false, dirname(plugin_basename(__FILE__)) . '/languages/');
|
59 |
+
}
|
60 |
+
|
61 |
+
// add the admin options page
|
62 |
+
public function wgact_plugin_admin_add_page()
|
63 |
+
{
|
64 |
+
//add_options_page('WGACT Plugin Page', 'WGACT Plugin Menu', 'manage_options', 'wgact', array($this, 'wgact_plugin_options_page'));
|
65 |
+
add_submenu_page(
|
66 |
+
'woocommerce',
|
67 |
+
esc_html__('Google Ads Conversion Tracking', 'woocommerce-google-adwords-conversion-tracking-tag'),
|
68 |
+
esc_html__('Google Ads Conversion Tracking', 'woocommerce-google-adwords-conversion-tracking-tag'),
|
69 |
+
'manage_options',
|
70 |
+
'wgact',
|
71 |
+
[$this, 'wgact_plugin_options_page']
|
72 |
+
);
|
73 |
+
}
|
74 |
+
|
75 |
+
// add the admin settings and such
|
76 |
+
public function wgact_plugin_admin_init()
|
77 |
+
{
|
78 |
+
|
79 |
+
register_setting(
|
80 |
+
'wgact_plugin_options_group',
|
81 |
+
'wgact_plugin_options',
|
82 |
+
[$this, 'wgact_options_validate']
|
83 |
+
);
|
84 |
+
|
85 |
+
$this->add_section_main();
|
86 |
+
$this->add_section_advanced();
|
87 |
+
$this->add_section_beta();
|
88 |
+
$this->add_section_support();
|
89 |
+
$this->add_section_author();
|
90 |
+
}
|
91 |
+
|
92 |
+
public function add_section_main()
|
93 |
+
{
|
94 |
+
|
95 |
+
$section_ids = [
|
96 |
+
'title' => 'Main',
|
97 |
+
'slug' => 'main',
|
98 |
+
'settings_name' => 'wgact_plugin_main_section',
|
99 |
+
];
|
100 |
+
|
101 |
+
$this->output_section_data_field($section_ids);
|
102 |
+
|
103 |
+
add_settings_section(
|
104 |
+
$section_ids['settings_name'],
|
105 |
+
esc_html__($section_ids['title'], 'woocommerce-google-adwords-conversion-tracking-tag'),
|
106 |
+
[$this, 'wgact_plugin_section_main_description'],
|
107 |
+
'wgact_plugin_options_page'
|
108 |
+
);
|
109 |
+
|
110 |
+
$this->add_section_main_subsection_google_ads($section_ids);
|
111 |
+
$this->add_section_main_subsection_facebook($section_ids);
|
112 |
+
}
|
113 |
+
|
114 |
+
public function add_section_main_subsection_google_ads($section_ids)
|
115 |
+
{
|
116 |
+
|
117 |
+
$sub_section_ids = [
|
118 |
+
'title' => 'Google Ads',
|
119 |
+
'slug' => 'google-ads'
|
120 |
+
];
|
121 |
+
|
122 |
+
add_settings_field(
|
123 |
+
'wgact_plugin_subsection_' . $sub_section_ids['slug'] . '_opening_div',
|
124 |
+
esc_html__(
|
125 |
+
$sub_section_ids['title'],
|
126 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
127 |
+
),
|
128 |
+
function () use ($section_ids, $sub_section_ids) {
|
129 |
+
$this->wgact_subsection_generic_opening_div_html($section_ids, $sub_section_ids);
|
130 |
+
},
|
131 |
+
'wgact_plugin_options_page',
|
132 |
+
$section_ids['settings_name']
|
133 |
+
);
|
134 |
+
|
135 |
+
// add the field for the conversion id
|
136 |
+
add_settings_field(
|
137 |
+
'wgact_plugin_conversion_id',
|
138 |
+
esc_html__(
|
139 |
+
'Conversion ID',
|
140 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
141 |
+
),
|
142 |
+
[$this, 'wgact_plugin_setting_conversion_id'],
|
143 |
+
'wgact_plugin_options_page',
|
144 |
+
$section_ids['settings_name']
|
145 |
+
);
|
146 |
+
|
147 |
+
// add the field for the conversion label
|
148 |
+
add_settings_field(
|
149 |
+
'wgact_plugin_conversion_label',
|
150 |
+
esc_html__(
|
151 |
+
'Conversion Label',
|
152 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
153 |
+
),
|
154 |
+
[$this, 'wgact_plugin_setting_conversion_label'],
|
155 |
+
'wgact_plugin_options_page',
|
156 |
+
$section_ids['settings_name']
|
157 |
+
);
|
158 |
+
}
|
159 |
+
|
160 |
+
public function add_section_main_subsection_facebook($section_ids)
|
161 |
+
{
|
162 |
+
|
163 |
+
$sub_section_ids = [
|
164 |
+
'title' => 'Facebook',
|
165 |
+
'slug' => 'facebook'
|
166 |
+
];
|
167 |
+
|
168 |
+
add_settings_field(
|
169 |
+
'wgact_plugin_subsection_' . $sub_section_ids['slug'] . '_opening_div',
|
170 |
+
esc_html__(
|
171 |
+
$sub_section_ids['title'],
|
172 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
173 |
+
),
|
174 |
+
function () use ($section_ids, $sub_section_ids) {
|
175 |
+
$this->wgact_subsection_generic_opening_div_html($section_ids, $sub_section_ids);
|
176 |
+
},
|
177 |
+
'wgact_plugin_options_page',
|
178 |
+
$section_ids['settings_name']
|
179 |
+
);
|
180 |
+
|
181 |
+
// add the field for the conversion label
|
182 |
+
add_settings_field(
|
183 |
+
'wgact_plugin_facebook_id',
|
184 |
+
esc_html__(
|
185 |
+
'Facebook pixel ID',
|
186 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
187 |
+
),
|
188 |
+
[$this, 'wgact_plugin_setting_facebook_pixel_id'],
|
189 |
+
'wgact_plugin_options_page',
|
190 |
+
$section_ids['settings_name']
|
191 |
+
);
|
192 |
+
|
193 |
+
}
|
194 |
+
|
195 |
+
public function add_section_advanced()
|
196 |
+
{
|
197 |
+
|
198 |
+
$section_ids = [
|
199 |
+
'title' => 'Advanced',
|
200 |
+
'slug' => 'advanced',
|
201 |
+
'settings_name' => 'wgact_plugin_advanced_section',
|
202 |
+
];
|
203 |
+
|
204 |
+
add_settings_section(
|
205 |
+
$section_ids['settings_name'],
|
206 |
+
esc_html__(
|
207 |
+
$section_ids['title'],
|
208 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
209 |
+
),
|
210 |
+
[$this, 'wgact_plugin_section_advanced_description'],
|
211 |
+
'wgact_plugin_options_page'
|
212 |
+
);
|
213 |
+
|
214 |
+
$this->output_section_data_field($section_ids);
|
215 |
+
|
216 |
+
$this->add_section_advanced_subsection_order_logic($section_ids);
|
217 |
+
$this->add_section_advanced_subsection_gtag($section_ids);
|
218 |
+
}
|
219 |
+
|
220 |
+
public function add_section_advanced_subsection_order_logic($section_ids)
|
221 |
+
{
|
222 |
+
|
223 |
+
$sub_section_ids = [
|
224 |
+
'title' => 'Order Logic',
|
225 |
+
'slug' => 'order-logic'
|
226 |
+
];
|
227 |
+
|
228 |
+
add_settings_field(
|
229 |
+
'wgact_plugin_subsection_' . $sub_section_ids['slug'] . '_opening_div',
|
230 |
+
esc_html__(
|
231 |
+
$sub_section_ids['title'],
|
232 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
233 |
+
),
|
234 |
+
function () use ($section_ids, $sub_section_ids) {
|
235 |
+
$this->wgact_subsection_generic_opening_div_html($section_ids, $sub_section_ids);
|
236 |
+
},
|
237 |
+
'wgact_plugin_options_page',
|
238 |
+
$section_ids['settings_name']
|
239 |
+
);
|
240 |
+
|
241 |
+
// add fields for the order total logic
|
242 |
+
add_settings_field(
|
243 |
+
'wgact_plugin_order_total_logic',
|
244 |
+
esc_html__(
|
245 |
+
'Order Total Logic',
|
246 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
247 |
+
),
|
248 |
+
[$this, 'wgact_plugin_setting_order_total_logic'],
|
249 |
+
'wgact_plugin_options_page',
|
250 |
+
$section_ids['settings_name']
|
251 |
+
);
|
252 |
+
}
|
253 |
+
|
254 |
+
public function add_section_advanced_subsection_gtag($section_ids)
|
255 |
+
{
|
256 |
+
|
257 |
+
$sub_section_ids = [
|
258 |
+
'title' => 'Gtag',
|
259 |
+
'slug' => 'gtag'
|
260 |
+
];
|
261 |
+
|
262 |
+
add_settings_field(
|
263 |
+
'wgact_plugin_subsection_' . $sub_section_ids['slug'] . '_opening_div',
|
264 |
+
esc_html__(
|
265 |
+
$sub_section_ids['title'],
|
266 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
267 |
+
),
|
268 |
+
function () use ($section_ids, $sub_section_ids) {
|
269 |
+
$this->wgact_subsection_generic_opening_div_html($section_ids, $sub_section_ids);
|
270 |
+
},
|
271 |
+
'wgact_plugin_options_page',
|
272 |
+
$section_ids['settings_name']
|
273 |
+
);
|
274 |
+
|
275 |
+
// add fields for the gtag insertion
|
276 |
+
add_settings_field(
|
277 |
+
'wgact_plugin_gtag',
|
278 |
+
esc_html__(
|
279 |
+
'gtag Deactivation',
|
280 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
281 |
+
),
|
282 |
+
[$this, 'wgact_plugin_setting_gtag_deactivation'],
|
283 |
+
'wgact_plugin_options_page',
|
284 |
+
$section_ids['settings_name']
|
285 |
+
);
|
286 |
+
}
|
287 |
+
|
288 |
+
public function add_section_beta()
|
289 |
+
{
|
290 |
+
|
291 |
+
$section_ids = [
|
292 |
+
'title' => 'Beta',
|
293 |
+
'slug' => 'beta',
|
294 |
+
'settings_name' => 'wgact_plugin_beta_section',
|
295 |
+
];
|
296 |
+
|
297 |
+
$this->output_section_data_field($section_ids);
|
298 |
+
|
299 |
+
// add new section for cart data
|
300 |
+
add_settings_section(
|
301 |
+
'wgact_plugin_beta_section',
|
302 |
+
esc_html__(
|
303 |
+
'Beta',
|
304 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
305 |
+
),
|
306 |
+
[$this, 'wgact_plugin_section_add_cart_data_description'],
|
307 |
+
'wgact_plugin_options_page'
|
308 |
+
);
|
309 |
+
|
310 |
+
// add fields for cart data
|
311 |
+
add_settings_field(
|
312 |
+
'wgact_plugin_add_cart_data',
|
313 |
+
esc_html__(
|
314 |
+
'Activation',
|
315 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
316 |
+
),
|
317 |
+
[$this, 'wgact_plugin_setting_add_cart_data'],
|
318 |
+
'wgact_plugin_options_page',
|
319 |
+
'wgact_plugin_beta_section'
|
320 |
+
);
|
321 |
+
|
322 |
+
// add the field for the aw_merchant_id
|
323 |
+
add_settings_field(
|
324 |
+
'wgact_plugin_aw_merchant_id',
|
325 |
+
esc_html__(
|
326 |
+
'aw_merchant_id',
|
327 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
328 |
+
),
|
329 |
+
[$this, 'wgact_plugin_setting_aw_merchant_id'],
|
330 |
+
'wgact_plugin_options_page',
|
331 |
+
'wgact_plugin_beta_section'
|
332 |
+
);
|
333 |
+
|
334 |
+
// add the field for the aw_feed_country
|
335 |
+
add_settings_field(
|
336 |
+
'wgact_plugin_aw_feed_country',
|
337 |
+
esc_html__(
|
338 |
+
'aw_feed_country',
|
339 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
340 |
+
),
|
341 |
+
[$this, 'wgact_plugin_setting_aw_feed_country'],
|
342 |
+
'wgact_plugin_options_page',
|
343 |
+
'wgact_plugin_beta_section'
|
344 |
+
);
|
345 |
+
|
346 |
+
// add the field for the aw_feed_language
|
347 |
+
add_settings_field(
|
348 |
+
'wgact_plugin_aw_feed_language',
|
349 |
+
esc_html__(
|
350 |
+
'aw_feed_language',
|
351 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
352 |
+
),
|
353 |
+
[$this, 'wgact_plugin_setting_aw_feed_language'],
|
354 |
+
'wgact_plugin_options_page',
|
355 |
+
'wgact_plugin_beta_section'
|
356 |
+
);
|
357 |
+
|
358 |
+
// add fields for the product identifier
|
359 |
+
add_settings_field(
|
360 |
+
'wgact_plugin_option_product_identifier',
|
361 |
+
esc_html__(
|
362 |
+
'Product Identifier',
|
363 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
364 |
+
),
|
365 |
+
[$this, 'wgact_plugin_option_product_identifier'],
|
366 |
+
'wgact_plugin_options_page',
|
367 |
+
'wgact_plugin_beta_section'
|
368 |
+
);
|
369 |
+
|
370 |
+
// add fields for dynamic remarketing
|
371 |
+
add_settings_field(
|
372 |
+
'wgact_plugin_option_dynamic_remarketing',
|
373 |
+
esc_html__(
|
374 |
+
'Dynamic Remarketing',
|
375 |
+
'woocommerce-google-adwords-conversion-tracking-tag'
|
376 |
+
),
|
377 |
+
[$this, 'wgact_plugin_option_dynamic_remarketing'],
|
378 |
+
'wgact_plugin_options_page',
|
379 |
+
'wgact_plugin_beta_section'
|
380 |
+
);
|
381 |
+
}
|
382 |
+
|
383 |
+
public function add_section_support()
|
384 |
+
{
|
385 |
+
|
386 |
+
$section_ids = [
|
387 |
+
'title' => 'Support',
|
388 |
+
'slug' => 'support',
|
389 |
+
'settings_name' => 'wgact_plugin_support_section',
|
390 |
+
];
|
391 |
+
|
392 |
+
$this->output_section_data_field($section_ids);
|
393 |
+
|
394 |
+
add_settings_section(
|
395 |
+
'wgact_plugin_support_section',
|
396 |
+
esc_html__('Support', 'woocommerce-google-adwords-conversion-tracking-tag'),
|
397 |
+
[$this, 'wgact_plugin_section_support_description'],
|
398 |
+
'wgact_plugin_options_page'
|
399 |
+
);
|
400 |
+
}
|
401 |
+
|
402 |
+
public function add_section_author()
|
403 |
+
{
|
404 |
+
|
405 |
+
$section_ids = [
|
406 |
+
'title' => 'Author',
|
407 |
+
'slug' => 'author',
|
408 |
+
'settings_name' => 'wgact_plugin_author_section',
|
409 |
+
];
|
410 |
+
|
411 |
+
$this->output_section_data_field($section_ids);
|
412 |
+
|
413 |
+
add_settings_section(
|
414 |
+
'wgact_plugin_author_section',
|
415 |
+
esc_html__('Author', 'woocommerce-google-adwords-conversion-tracking-tag'),
|
416 |
+
[$this, 'wgact_plugin_section_author_description'],
|
417 |
+
'wgact_plugin_options_page'
|
418 |
+
);
|
419 |
+
}
|
420 |
+
|
421 |
+
protected function output_section_data_field(array $section_ids)
|
422 |
+
{
|
423 |
+
add_settings_field(
|
424 |
+
'wgact_plugin_section_' . $section_ids['slug'] . '_opening_div',
|
425 |
+
'',
|
426 |
+
function () use ($section_ids) {
|
427 |
+
$this->wgact_section_generic_opening_div_html($section_ids);
|
428 |
+
},
|
429 |
+
'wgact_plugin_options_page',
|
430 |
+
$section_ids['settings_name']
|
431 |
+
);
|
432 |
+
}
|
433 |
+
|
434 |
+
public function wgact_section_generic_opening_div_html($section_ids)
|
435 |
+
{
|
436 |
+
echo '<div class="section" data-section-title="' . $section_ids['title'] . '" data-section-slug="' . $section_ids['slug'] . '"></div>';
|
437 |
+
}
|
438 |
+
|
439 |
+
public function wgact_subsection_generic_opening_div_html($section_ids, $sub_section_ids)
|
440 |
+
{
|
441 |
+
echo '<div class="subsection" data-section-slug="' . $section_ids['slug'] . '" data-subsection-title="' . $sub_section_ids['title'] . '" data-subsection-slug="' . $sub_section_ids['slug'] . '"></div>';
|
442 |
+
}
|
443 |
+
|
444 |
+
// display the admin options page
|
445 |
+
public function wgact_plugin_options_page()
|
446 |
+
{
|
447 |
+
?>
|
448 |
+
<div id="script-blocker-notice" class="notice notice-error"
|
449 |
+
style="width:90%; float: left; margin: 5px; font-weight: bold">
|
450 |
+
<p>
|
451 |
+
<?php esc_html_e('It looks like you are using some sort of ad or script blocker which is blocking the script and CSS files of this plugin.
|
452 |
+
In order for the plugin to work properly you need to disable the script blocker.', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
453 |
+
</p>
|
454 |
+
<p>
|
455 |
+
<a href="https://docs.wolfundbaer.ch/wgact/#/script-blockers" target="_blank">
|
456 |
+
<?php esc_html_e('Learn more', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
457 |
+
</a>
|
458 |
+
</p>
|
459 |
+
|
460 |
+
|
461 |
+
</div>
|
462 |
+
<div style="width:90%; float: left; margin: 5px">
|
463 |
+
<?php settings_errors(); ?>
|
464 |
+
|
465 |
+
<h2 class="nav-tab-wrapper">
|
466 |
+
</h2>
|
467 |
+
|
468 |
+
<form id="wgact_settings_form" action="options.php" method="post">
|
469 |
+
|
470 |
+
<?php
|
471 |
+
|
472 |
+
settings_fields('wgact_plugin_options_group');
|
473 |
+
do_settings_sections('wgact_plugin_options_page');
|
474 |
+
submit_button();
|
475 |
+
?>
|
476 |
+
|
477 |
+
</form>
|
478 |
+
|
479 |
+
<div class="developer-banner">
|
480 |
+
<div>
|
481 |
+
<span>
|
482 |
+
<?php
|
483 |
+
/* translators: 'Wolf+Bär' needs to always stay the same*/
|
484 |
+
esc_html_e('Profit Driven Marketing by Wolf+Bär', 'woocommerce-google-adwords-conversion-tracking-tag');
|
485 |
+
?>
|
486 |
+
</span>
|
487 |
+
<span style="float: right; padding-left: 20px">
|
488 |
+
<?php esc_html_e('Visit us here:', 'woocommerce-google-adwords-conversion-tracking-tag') ?>
|
489 |
+
<a href="https://wolfundbaer.ch/<?php echo $this->get_link_locale() ?>/?utm_source=plugin&utm_medium=banner&utm_campaign=wgact_plugin"
|
490 |
+
target="_blank">https://wolfundbaer.ch
|
491 |
+
</a>
|
492 |
+
</span>
|
493 |
+
</div>
|
494 |
+
</div>
|
495 |
+
</div>
|
496 |
+
<?php
|
497 |
+
}
|
498 |
+
|
499 |
+
private function get_link_locale(): string
|
500 |
+
{
|
501 |
+
|
502 |
+
if (substr(get_user_locale(), 0, 2) === 'de') {
|
503 |
+
return 'de';
|
504 |
+
} else {
|
505 |
+
return 'en';
|
506 |
+
}
|
507 |
+
}
|
508 |
+
|
509 |
+
/*
|
510 |
+
* descriptions
|
511 |
+
*/
|
512 |
+
|
513 |
+
public function wgact_plugin_section_main_description()
|
514 |
+
{
|
515 |
+
// do nothing
|
516 |
+
}
|
517 |
+
|
518 |
+
public function wgact_plugin_section_advanced_description()
|
519 |
+
{
|
520 |
+
// do nothing
|
521 |
+
}
|
522 |
+
|
523 |
+
public function wgact_plugin_section_add_cart_data_description()
|
524 |
+
{
|
525 |
+
echo '<div id="beta-description" style="margin-top:20px">';
|
526 |
+
|
527 |
+
esc_html_e('Find out more about this new feature: ', 'woocommerce-google-adwords-conversion-tracking-tag');
|
528 |
+
echo '<a href="https://support.google.com/google-ads/answer/9028254" target="_blank">https://support.google.com/google-ads/answer/9028254</a><br>';
|
529 |
+
esc_html_e('At the moment we are testing this feature. It might go into a PRO version of this plugin in the future.', 'woocommerce-google-adwords-conversion-tracking-tag');
|
530 |
+
echo '</div>';
|
531 |
+
}
|
532 |
+
|
533 |
+
public function wgact_plugin_section_support_description()
|
534 |
+
{
|
535 |
+
?>
|
536 |
+
<div style="margin-top:20px">
|
537 |
+
<?php esc_html_e('Use the following two resources for support: ', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
538 |
+
</div>
|
539 |
+
<div style="margin-bottom: 30px;">
|
540 |
+
<ul>
|
541 |
+
|
542 |
+
<li>
|
543 |
+
<?php esc_html_e('Post a support request in the WordPress support forum here: ', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
544 |
+
<a href="https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag/"
|
545 |
+
target="_blank">
|
546 |
+
<?php esc_html_e('Support forum', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
547 |
+
</a>
|
548 |
+
</li>
|
549 |
+
<li>
|
550 |
+
<?php esc_html_e('Or send us an email to the following address: ', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
551 |
+
<a href="mailto:support@wolfundbaer.ch" target="_blank">support@wolfundbaer.ch</a>
|
552 |
+
</li>
|
553 |
+
</ul>
|
554 |
+
</div>
|
555 |
+
<div class=" woocommerce-message">
|
556 |
+
|
557 |
+
<div>
|
558 |
+
<textarea id="debug-info-textarea" class=""
|
559 |
+
style="display:block; margin-bottom: 10px; width: 100%;resize: none;color:dimgrey;"
|
560 |
+
cols="100%" rows="30"
|
561 |
+
readonly>
|
562 |
+
<?php echo $this->get_debug_info() ?>
|
563 |
+
</textarea>
|
564 |
+
<button id="debug-info-button"
|
565 |
+
type="button"><?php esc_html_e('copy to clipboard', 'woocommerce-google-adwords-conversion-tracking-tag'); ?></button>
|
566 |
+
</div>
|
567 |
+
|
568 |
+
</div>
|
569 |
+
|
570 |
+
<?php
|
571 |
+
}
|
572 |
+
|
573 |
+
public function wgact_plugin_section_author_description()
|
574 |
+
{
|
575 |
+
?>
|
576 |
+
<div style="margin-top:20px;margin-bottom: 30px">
|
577 |
+
<?php esc_html_e('More details about the developer of this plugin: ', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
578 |
+
</div>
|
579 |
+
<div style="margin-bottom: 30px;">
|
580 |
+
<div><?php
|
581 |
+
/* translators: 'Wolf+Bär' needs to always stay the same, while 'Agency' can be translated */
|
582 |
+
esc_html_e('Developer: Wolf+Bär Agency', 'woocommerce-google-adwords-conversion-tracking-tag');
|
583 |
+
?></div>
|
584 |
+
<div>
|
585 |
+
<?php esc_html_e('Website: ', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
586 |
+
<a href="https://wolfundbaer.ch/<?php echo $this->get_link_locale() ?>/?utm_source=plugin&utm_medium=banner&utm_campaign=wgact_plugin"
|
587 |
+
target="_blank">https://wolfundbaer.ch</a>
|
588 |
+
|
589 |
+
</div>
|
590 |
+
|
591 |
+
</div>
|
592 |
+
<?php
|
593 |
+
}
|
594 |
+
|
595 |
+
public function get_debug_info(): string
|
596 |
+
{
|
597 |
+
global $woocommerce, $wp_version, $current_user;
|
598 |
+
|
599 |
+
$html = '### Debugging Information ###' . PHP_EOL . PHP_EOL;
|
600 |
+
|
601 |
+
$html .= '## System Environment ##' . PHP_EOL . PHP_EOL;
|
602 |
+
|
603 |
+
$html .= 'This plugin\'s version: ' . WGACT_CURRENT_VERSION . PHP_EOL;
|
604 |
+
|
605 |
+
$html .= PHP_EOL;
|
606 |
+
|
607 |
+
$html .= 'WordPress version: ' . $wp_version . PHP_EOL;
|
608 |
+
$html .= 'WooCommerce version: ' . $woocommerce->version . PHP_EOL;
|
609 |
+
$html .= 'PHP version: ' . phpversion() . PHP_EOL;
|
610 |
+
|
611 |
+
$html .= PHP_EOL;
|
612 |
+
|
613 |
+
$multisite_enabled = is_multisite() ? 'yes' : 'no';
|
614 |
+
$html .= 'Multisite enabled: ' . $multisite_enabled . PHP_EOL;
|
615 |
+
|
616 |
+
$wp_debug = 'no';
|
617 |
+
if (defined('WP_DEBUG') && true === WP_DEBUG) {
|
618 |
+
$wp_debug = 'yes';
|
619 |
+
}
|
620 |
+
|
621 |
+
$html .= 'WordPress debug mode enabled: ' . $wp_debug . PHP_EOL;
|
622 |
+
|
623 |
+
wp_get_current_user();
|
624 |
+
$html .= 'Logged in user login name: ' . $current_user->user_login . PHP_EOL;
|
625 |
+
$html .= 'Logged in user display name: ' . $current_user->display_name . PHP_EOL;
|
626 |
+
|
627 |
+
$html .= PHP_EOL . '## WooCommerce ##' . PHP_EOL . PHP_EOL;
|
628 |
+
|
629 |
+
$html .= 'Default currency: ' . get_woocommerce_currency() . PHP_EOL;
|
630 |
+
$html .= 'Shop URL: ' . get_home_url() . PHP_EOL;
|
631 |
+
$html .= 'Cart URL: ' . wc_get_cart_url() . PHP_EOL;
|
632 |
+
$html .= 'Checkout URL: ' . wc_get_checkout_url() . PHP_EOL;
|
633 |
+
|
634 |
+
$last_order_id = $this->get_last_order_id();
|
635 |
+
// echo('last order: ' . $last_order_id . PHP_EOL);
|
636 |
+
$last_order = new WC_Order(wc_get_order($last_order_id));
|
637 |
+
$html .= 'Last order URL: ' . $last_order->get_checkout_order_received_url() . PHP_EOL;
|
638 |
+
|
639 |
+
|
640 |
+
$html .= PHP_EOL . '## Theme ##' . PHP_EOL . PHP_EOL;
|
641 |
+
|
642 |
+
$is_child_theme = is_child_theme() ? 'yes' : 'no';
|
643 |
+
$html .= 'Is child theme: ' . $is_child_theme . PHP_EOL;
|
644 |
+
$theme_support = current_theme_supports('woocommerce') ? 'yes' : 'no';
|
645 |
+
$html .= 'WooCommerce support: ' . $theme_support . PHP_EOL;
|
646 |
+
|
647 |
+
$html .= PHP_EOL;
|
648 |
+
|
649 |
+
// using the double check prevents problems with some themes that have not implemented
|
650 |
+
// the child state correctly
|
651 |
+
// https://wordpress.org/support/topic/debug-error-33/
|
652 |
+
$theme_description_prefix = (is_child_theme() && wp_get_theme()->parent()) ? 'Child theme ' : 'Theme ';
|
653 |
+
|
654 |
+
$html .= $theme_description_prefix . 'Name: ' . wp_get_theme()->get('Name') . PHP_EOL;
|
655 |
+
$html .= $theme_description_prefix . 'ThemeURI: ' . wp_get_theme()->get('ThemeURI') . PHP_EOL;
|
656 |
+
$html .= $theme_description_prefix . 'Author: ' . wp_get_theme()->get('Author') . PHP_EOL;
|
657 |
+
$html .= $theme_description_prefix . 'AuthorURI: ' . wp_get_theme()->get('AuthorURI') . PHP_EOL;
|
658 |
+
$html .= $theme_description_prefix . 'Version: ' . wp_get_theme()->get('Version') . PHP_EOL;
|
659 |
+
$html .= $theme_description_prefix . 'Template: ' . wp_get_theme()->get('Template') . PHP_EOL;
|
660 |
+
$html .= $theme_description_prefix . 'Status: ' . wp_get_theme()->get('Status') . PHP_EOL;
|
661 |
+
$html .= $theme_description_prefix . 'TextDomain: ' . wp_get_theme()->get('TextDomain') . PHP_EOL;
|
662 |
+
$html .= $theme_description_prefix . 'DomainPath: ' . wp_get_theme()->get('DomainPath') . PHP_EOL;
|
663 |
+
|
664 |
+
$html .= PHP_EOL;
|
665 |
+
|
666 |
+
// using the double check prevents problems with some themes that have not implemented
|
667 |
+
// the child state correctly
|
668 |
+
if (is_child_theme() && wp_get_theme()->parent()) {
|
669 |
+
$html .= 'Parent theme Name: ' . wp_get_theme()->parent()->get('Name') . PHP_EOL;
|
670 |
+
$html .= 'Parent theme ThemeURI: ' . wp_get_theme()->parent()->get('ThemeURI') . PHP_EOL;
|
671 |
+
$html .= 'Parent theme Author: ' . wp_get_theme()->parent()->get('Author') . PHP_EOL;
|
672 |
+
$html .= 'Parent theme AuthorURI: ' . wp_get_theme()->parent()->get('AuthorURI') . PHP_EOL;
|
673 |
+
$html .= 'Parent theme Version: ' . wp_get_theme()->parent()->get('Version') . PHP_EOL;
|
674 |
+
$html .= 'Parent theme Template: ' . wp_get_theme()->parent()->get('Template') . PHP_EOL;
|
675 |
+
$html .= 'Parent theme Status: ' . wp_get_theme()->parent()->get('Status') . PHP_EOL;
|
676 |
+
$html .= 'Parent theme TextDomain: ' . wp_get_theme()->parent()->get('TextDomain') . PHP_EOL;
|
677 |
+
$html .= 'Parent theme DomainPath: ' . wp_get_theme()->parent()->get('DomainPath') . PHP_EOL;
|
678 |
+
}
|
679 |
+
|
680 |
+
// TODO maybe add all active plugins
|
681 |
+
|
682 |
+
$html .= PHP_EOL;
|
683 |
+
|
684 |
+
$html .= PHP_EOL . '## freemius ##' . PHP_EOL . PHP_EOL;
|
685 |
+
|
686 |
+
$html .= 'api.freemius.com : ' . $this->try_connect_to_server('api.freemius.com') . PHP_EOL;
|
687 |
+
$html .= 'wp.freemius.com : ' . $this->try_connect_to_server('wp.freemius.com') . PHP_EOL;
|
688 |
+
|
689 |
+
// $html .= PHP_EOL . '## misc ##' . PHP_EOL . PHP_EOL;
|
690 |
+
|
691 |
+
// $html .= 'Script blocker detected:';
|
692 |
+
|
693 |
+
$html .= PHP_EOL . PHP_EOL . '### End of Information ###';
|
694 |
+
|
695 |
+
return $html;
|
696 |
+
}
|
697 |
+
|
698 |
+
protected function try_connect_to_server($server): string
|
699 |
+
{
|
700 |
+
if ($socket = @ fsockopen($server, 80)) {
|
701 |
+
@fclose($socket);
|
702 |
+
return 'online';
|
703 |
+
} else {
|
704 |
+
return 'offline';
|
705 |
+
}
|
706 |
+
}
|
707 |
+
|
708 |
+
public function get_last_order_id()
|
709 |
+
{
|
710 |
+
global $wpdb;
|
711 |
+
$statuses = array_keys(wc_get_order_statuses());
|
712 |
+
$statuses = implode("','", $statuses);
|
713 |
+
|
714 |
+
// Getting last Order ID (max value)
|
715 |
+
$results = $wpdb->get_col("
|
716 |
+
SELECT MAX(ID) FROM {$wpdb->prefix}posts
|
717 |
+
WHERE post_type LIKE 'shop_order'
|
718 |
+
AND post_status IN ('$statuses')
|
719 |
+
");
|
720 |
+
|
721 |
+
return reset($results);
|
722 |
+
}
|
723 |
+
|
724 |
+
public function wgact_plugin_setting_conversion_id()
|
725 |
+
{
|
726 |
+
echo "<input id='wgact_plugin_conversion_id' name='wgact_plugin_options[google][ads][conversion_id]' size='40' type='text' value='{$this->options['google']['ads']['conversion_id']}' />";
|
727 |
+
echo $this->get_documentation_html('/wgact/#/plugin-configuration?id=configure-the-plugin');
|
728 |
+
echo '<br><br>';
|
729 |
+
esc_html_e('The conversion ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag');
|
730 |
+
echo ' <i>123456789</i>';
|
731 |
+
}
|
732 |
+
|
733 |
+
public function wgact_plugin_setting_conversion_label()
|
734 |
+
{
|
735 |
+
echo "<input id='wgact_plugin_conversion_label' name='wgact_plugin_options[google][ads][conversion_label]' size='40' type='text' value='{$this->options['google']['ads']['conversion_label']}' />";
|
736 |
+
echo $this->get_documentation_html('/wgact/#/plugin-configuration?id=configure-the-plugin');
|
737 |
+
echo '<br><br>';
|
738 |
+
esc_html_e('The conversion Label looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag');
|
739 |
+
echo ' <i>Xt19CO3axGAX0vg6X3gM</i>';
|
740 |
+
}
|
741 |
+
|
742 |
+
public function wgact_plugin_setting_facebook_pixel_id()
|
743 |
+
{
|
744 |
+
echo "<input id='wgact_plugin_facebook_pixel_id' name='wgact_plugin_options[facebook][pixel_id]' size='40' type='text' value='{$this->options['facebook']['pixel_id']}' />";
|
745 |
+
echo $this->get_documentation_html('/wgact/#/facebook');
|
746 |
+
echo '<br><br>';
|
747 |
+
esc_html_e('The Facebook pixel ID looks similar to this:', 'woocommerce-google-adwords-conversion-tracking-tag');
|
748 |
+
echo ' <i>765432112345678</i>';
|
749 |
+
}
|
750 |
+
|
751 |
+
public function wgact_plugin_setting_order_total_logic()
|
752 |
+
{
|
753 |
+
?>
|
754 |
+
<input type='radio' id='wgact_plugin_option_product_identifier_0' name='wgact_plugin_options[shop][order_total_logic]'
|
755 |
+
value='0' <?php echo(checked(0, $this->options['shop']['order_total_logic'], false)) ?> ><?php esc_html_e('Use order_subtotal: Doesn\'t include tax and shipping (default)', 'woocommerce-google-adwords-conversion-tracking-tag') ?>
|
756 |
+
<br>
|
757 |
+
<input type='radio' id='wgact_plugin_option_product_identifier_1' name='wgact_plugin_options[shop][order_total_logic]'
|
758 |
+
value='1' <?php echo(checked(1, $this->options['shop']['order_total_logic'], false)) ?> ><?php esc_html_e('Use order_total: Includes tax and shipping', 'woocommerce-google-adwords-conversion-tracking-tag') ?>
|
759 |
+
<br><br>
|
760 |
+
<?php esc_html_e('This is the order total amount reported back to Google Ads', 'woocommerce-google-adwords-conversion-tracking-tag') ?>
|
761 |
+
<?php
|
762 |
+
}
|
763 |
+
|
764 |
+
protected function get_documentation_html($path): string
|
765 |
+
{
|
766 |
+
|
767 |
+
$html = '<a style="text-decoration: none" href="//' . $this->documentation_host . $path . '" target="_blank">';
|
768 |
+
$html .= '<span style="margin-left: 10px; vertical-align: middle" class="dashicons dashicons-info-outline tooltip"><span class="tooltiptext">';
|
769 |
+
$html .= esc_html__('open the documentation', 'woocommerce-google-adwords-conversion-tracking-tag');
|
770 |
+
$html .= '</span></span></a>';
|
771 |
+
|
772 |
+
return $html;
|
773 |
+
}
|
774 |
+
|
775 |
+
public function wgact_plugin_setting_gtag_deactivation()
|
776 |
+
{
|
777 |
+
// adding the hidden input is a hack to make WordPress save the option with the value zero,
|
778 |
+
// instead of not saving it and remove that array key entirely
|
779 |
+
// https://stackoverflow.com/a/1992745/4688612
|
780 |
+
?>
|
781 |
+
<input type='hidden' value='0' name='wgact_plugin_options[google][gtag][deactivation]''>
|
782 |
+
<input type='checkbox' id='wgact_plugin_option_gtag_deactivation'
|
783 |
+
name='wgact_plugin_options[google][gtag][deactivation]'
|
784 |
+
value='1' <?php checked($this->options['google']['gtag']['deactivation']); ?> />
|
785 |
+
<?php esc_html_e('Disable gtag.js insertion if another plugin is inserting it already.', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
786 |
+
<br>
|
787 |
+
<p>
|
788 |
+
<span class="dashicons dashicons-info"></span>
|
789 |
+
<?php esc_html_e('Only do this, if the other plugin does insert the gtag above this pixel. If not, keep the gtag active.', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
790 |
+
</p>
|
791 |
+
<?php
|
792 |
+
}
|
793 |
+
|
794 |
+
public function wgact_plugin_setting_add_cart_data()
|
795 |
+
{
|
796 |
+
// adding the hidden input is a hack to make WordPress save the option with the value zero,
|
797 |
+
// instead of not saving it and remove that array key entirely
|
798 |
+
// https://stackoverflow.com/a/1992745/4688612
|
799 |
+
?>
|
800 |
+
<input type='hidden' value='0' name='wgact_plugin_options[google][ads][add_cart_data]'>
|
801 |
+
<input type='checkbox' id='wgact_plugin_option_gads_add_cart_data'
|
802 |
+
name='wgact_plugin_options[google][ads][add_cart_data]'
|
803 |
+
value='1' <?php checked($this->options['google']['ads']['add_cart_data']); ?> />
|
804 |
+
<?php esc_html_e('Add the cart data to the conversion event', 'woocommerce-google-adwords-conversion-tracking-tag');
|
805 |
+
}
|
806 |
+
|
807 |
+
public function wgact_plugin_option_dynamic_remarketing()
|
808 |
+
{
|
809 |
+
|
810 |
+
// adding the hidden input is a hack to make WordPress save the option with the value zero,
|
811 |
+
// instead of not saving it and remove that array key entirely
|
812 |
+
// https://stackoverflow.com/a/1992745/4688612
|
813 |
+
?>
|
814 |
+
<input type='hidden' value='0' name='wgact_plugin_options[google][ads][dynamic_remarketing]'>
|
815 |
+
<input type='checkbox' id='wgact_plugin_option_gads_dynamic_remarketing'
|
816 |
+
name='wgact_plugin_options[google][ads][dynamic_remarketing]'
|
817 |
+
value='1' <?php checked($this->options['google']['ads']['dynamic_remarketing']); ?> />
|
818 |
+
|
819 |
+
<?php esc_html_e('Enable dynamic remarketing audience collection', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
820 |
+
<?php echo $this->get_documentation_html('/wgact/#/dynamic-remarketing'); ?>
|
821 |
+
<p><span class="dashicons dashicons-info"></span>
|
822 |
+
<?php esc_html_e('You need to choose the correct product identifier setting in order to match the product identifiers in the Google Merchant Center or your Google Ads business feed.', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
823 |
+
</p>
|
824 |
+
|
825 |
+
<?php
|
826 |
+
}
|
827 |
+
|
828 |
+
|
829 |
+
public function wgact_plugin_setting_aw_merchant_id()
|
830 |
+
{
|
831 |
+
echo "<input type='text' id='wgact_plugin_aw_merchant_id' name='wgact_plugin_options[google][ads][aw_merchant_id]' size='40' value='{$this->options['google']['ads']['aw_merchant_id']}' />";
|
832 |
+
echo '<br><br>';
|
833 |
+
esc_html_e('Enter the ID of your Google Merchant Center account.', 'woocommerce-google-adwords-conversion-tracking-tag');
|
834 |
+
}
|
835 |
+
|
836 |
+
public function wgact_plugin_setting_aw_feed_country()
|
837 |
+
{
|
838 |
+
|
839 |
+
?><b><?php echo $this->get_visitor_country() ?></b><?php
|
840 |
+
// echo '<br>' . 'get_external_ip_address: ' . WC_Geolocation::get_external_ip_address();
|
841 |
+
// echo '<br>' . 'get_ip_address: ' . WC_Geolocation::get_ip_address();
|
842 |
+
// echo '<p>' . 'geolocate_ip: ' . '<br>';
|
843 |
+
// echo print_r(WC_Geolocation::geolocate_ip());
|
844 |
+
// echo '<p>' . 'WC_Geolocation::geolocate_ip(WC_Geolocation::get_external_ip_address()): ' . '<br>';
|
845 |
+
// echo print_r(WC_Geolocation::geolocate_ip(WC_Geolocation::get_external_ip_address()));
|
846 |
+
?>
|
847 |
+
<div style="margin-top:10px">
|
848 |
+
<?php
|
849 |
+
esc_html_e('Currently the plugin automatically detects the location of the visitor for this setting. In most, if not all, cases this will work fine. Please let us know if you have a use case where you need another output:', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
850 |
+
<a href="mailto:support@wolfundbaer.ch">support@wolfundbaer.ch</a>
|
851 |
+
</div>
|
852 |
+
<?php
|
853 |
+
}
|
854 |
+
|
855 |
+
// dupe in pixel
|
856 |
+
public function get_visitor_country()
|
857 |
+
{
|
858 |
+
|
859 |
+
if ($this->isLocalhost()) {
|
860 |
+
// error_log('check external ip');
|
861 |
+
$this->ip = WC_Geolocation::get_external_ip_address();
|
862 |
+
} else {
|
863 |
+
// error_log('check regular ip');
|
864 |
+
$this->ip = WC_Geolocation::get_ip_address();
|
865 |
+
}
|
866 |
+
|
867 |
+
$location = WC_Geolocation::geolocate_ip($this->ip);
|
868 |
+
|
869 |
+
// error_log ('ip: ' . $this->>$ip);
|
870 |
+
// error_log ('country: ' . $location['country']);
|
871 |
+
return $location['country'];
|
872 |
+
}
|
873 |
+
|
874 |
+
// dupe in pixel
|
875 |
+
public function isLocalhost(): bool
|
876 |
+
{
|
877 |
+
return in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']);
|
878 |
+
}
|
879 |
+
|
880 |
+
public function wgact_plugin_setting_aw_feed_language()
|
881 |
+
{
|
882 |
+
?><b><?php echo $this->get_gmc_language() ?></b>
|
883 |
+
<div style="margin-top:10px">
|
884 |
+
<?php esc_html_e('The plugin will use the WordPress default language for this setting. If the shop uses translations, in theory we could also use the visitors locale. But, if that language is not set up in the Google Merchant Center we might run into issues. If you need more options here let us know:', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
885 |
+
<a href=\"mailto:support@wolfundbaer.ch\">support@wolfundbaer.ch</a>
|
886 |
+
</div>
|
887 |
+
<?php
|
888 |
+
}
|
889 |
+
|
890 |
+
// dupe in pixel
|
891 |
+
public function get_gmc_language(): string
|
892 |
+
{
|
893 |
+
return strtoupper(substr(get_locale(), 0, 2));
|
894 |
+
}
|
895 |
+
|
896 |
+
public function wgact_plugin_option_product_identifier()
|
897 |
+
{
|
898 |
+
?>
|
899 |
+
<input type='radio' id='wgact_plugin_option_product_identifier_0'
|
900 |
+
name='wgact_plugin_options[google][ads][product_identifier]'
|
901 |
+
value='0' <?php echo(checked(0, $this->options['google']['ads']['product_identifier'], false)) ?>/><?php esc_html_e('post id (default)', 'woocommerce-google-adwords-conversion-tracking-tag') ?>
|
902 |
+
<br>
|
903 |
+
|
904 |
+
<input type='radio' id='wgact_plugin_option_product_identifier_1'
|
905 |
+
name='wgact_plugin_options[google][ads][product_identifier]'
|
906 |
+
value='1' <?php echo(checked(1, $this->options['google']['ads']['product_identifier'], false)) ?>/><?php esc_html_e('post id with woocommerce_gpf_ prefix *', 'woocommerce-google-adwords-conversion-tracking-tag') ?>
|
907 |
+
<br>
|
908 |
+
|
909 |
+
<input type='radio' id='wgact_plugin_option_product_identifier_1'
|
910 |
+
name='wgact_plugin_options[google][ads][product_identifier]'
|
911 |
+
value='2' <?php echo(checked(2, $this->options['google']['ads']['product_identifier'], false)) ?>/><?php esc_html_e('SKU', 'woocommerce-google-adwords-conversion-tracking-tag') ?>
|
912 |
+
<br><br>
|
913 |
+
|
914 |
+
<?php esc_html_e('Choose a product identifier.', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
915 |
+
<br><br>
|
916 |
+
<?php esc_html_e('* This is for users of the WooCommerce Google Product Feed Plugin', 'woocommerce-google-adwords-conversion-tracking-tag'); ?>
|
917 |
+
<a href="https://woocommerce.com/products/google-product-feed/" target="_blank">WooCommerce Google Product Feed
|
918 |
+
Plugin</a>
|
919 |
+
|
920 |
+
|
921 |
+
<?php
|
922 |
+
}
|
923 |
+
|
924 |
+
// validate the options
|
925 |
+
public function wgact_options_validate($input): array
|
926 |
+
{
|
927 |
+
|
928 |
+
// validate ['google]['gds']['conversion_id']
|
929 |
+
if (isset($input['google']['ads']['conversion_id'])) {
|
930 |
+
if (!$this->is_gads_conversion_id($input['google']['ads']['conversion_id'])) {
|
931 |
+
$input['google']['ads']['conversion_id'] = isset($this->options['google']['ads']['conversion_id']) ? $this->options['google']['ads']['conversion_id'] : '';
|
932 |
+
add_settings_error('wgact_plugin_options', 'invalid-conversion-id', esc_html__('You have entered an invalid conversion ID. It only contains 8 to 10 digits.', 'woocommerce-google-adwords-conversion-tracking-tag'));
|
933 |
+
}
|
934 |
+
}
|
935 |
+
|
936 |
+
// validate ['google]['gds']['conversion_label']
|
937 |
+
if (isset($input['google']['ads']['conversion_label'])) {
|
938 |
+
if (!$this->is_gads_conversion_label($input['google']['ads']['conversion_label'])) {
|
939 |
+
$input['google']['ads']['conversion_label'] = isset($this->options['google']['ads']['conversion_label']) ? $this->options['google']['ads']['conversion_label'] : '';
|
940 |
+
add_settings_error('wgact_plugin_options', 'invalid-conversion-label', esc_html__('You have entered an invalid conversion label.', 'woocommerce-google-adwords-conversion-tracking-tag'));
|
941 |
+
}
|
942 |
+
}
|
943 |
+
|
944 |
+
// validate ['google]['gds']['aw_merchant_id']
|
945 |
+
if (isset($input['google']['ads']['aw_merchant_id'])) {
|
946 |
+
if (!$this->is_gads_aw_merchant_id($input['google']['ads']['aw_merchant_id'])) {
|
947 |
+
$input['google']['ads']['aw_merchant_id'] = isset($this->options['google']['ads']['aw_merchant_id']) ? $this->options['google']['ads']['aw_merchant_id'] : '';
|
948 |
+
add_settings_error('wgact_plugin_options', 'invalid-aw-merchant-id', esc_html__('You have entered an invalid merchant ID. It only contains 8 to 10 digits.', 'woocommerce-google-adwords-conversion-tracking-tag'));
|
949 |
+
}
|
950 |
+
}
|
951 |
+
|
952 |
+
// validate ['facebook']['pixel_id']
|
953 |
+
if (isset($input['facebook']['pixel_id'])) {
|
954 |
+
if (!$this->is_facebook_pixel_id($input['facebook']['pixel_id'])) {
|
955 |
+
$input['facebook']['pixel_id'] = isset($this->options['facebook']['pixel_id']) ? $this->options['facebook']['pixel_id'] : '';
|
956 |
+
add_settings_error('wgact_plugin_options', 'invalid-facebook-pixel-id', esc_html__('You have entered an invalid Facebook pixel ID. It only contains 14 to 16 digits.', 'woocommerce-google-adwords-conversion-tracking-tag'));
|
957 |
+
}
|
958 |
+
}
|
959 |
+
|
960 |
+
// merging with the existing options
|
961 |
+
// and overwriting old values
|
962 |
+
|
963 |
+
// since disabling a checkbox doesn't send a value,
|
964 |
+
// we need to set one to overwrite the old value
|
965 |
+
|
966 |
+
$input = array_replace_recursive($this->non_form_keys(), $input);
|
967 |
+
|
968 |
+
$input = $this->merge_options($this->options, $input);
|
969 |
+
|
970 |
+
// error_log('input merged');
|
971 |
+
// error_log(print_r($input, true));
|
972 |
+
|
973 |
+
return $input;
|
974 |
+
}
|
975 |
+
|
976 |
+
// Recursively go through the array and merge (overwrite old values with new ones
|
977 |
+
// if a value is missing in the input array, set it to value zero in the options array
|
978 |
+
// Omit key like 'db_version' since they would be overwritten with zero.
|
979 |
+
protected function merge_options($array_existing, $array_input): array
|
980 |
+
{
|
981 |
+
$array_output = [];
|
982 |
+
|
983 |
+
foreach ($array_existing as $key => $value) {
|
984 |
+
if (array_key_exists($key, $array_input)) {
|
985 |
+
if (is_array($value)) {
|
986 |
+
$array_output[$key] = $this->merge_options($value, $array_input[$key]);
|
987 |
+
} else {
|
988 |
+
$array_output[$key] = $array_input[$key];
|
989 |
+
}
|
990 |
+
} else {
|
991 |
+
if (is_array($value)) {
|
992 |
+
$array_output[$key] = $this->set_array_value_to_zero($value);
|
993 |
+
} else {
|
994 |
+
$array_output[$key] = 0;
|
995 |
+
}
|
996 |
+
}
|
997 |
+
}
|
998 |
+
|
999 |
+
return $array_output;
|
1000 |
+
}
|
1001 |
+
|
1002 |
+
protected function non_form_keys(): array
|
1003 |
+
{
|
1004 |
+
return [
|
1005 |
+
'db_version' => $this->options['db_version'],
|
1006 |
+
'google' => [
|
1007 |
+
'ads' => [
|
1008 |
+
'google_business_vertical' => $this->options['google']['ads']['google_business_vertical'],
|
1009 |
+
],
|
1010 |
+
]
|
1011 |
+
];
|
1012 |
+
}
|
1013 |
+
|
1014 |
+
function set_array_value_to_zero($array)
|
1015 |
+
{
|
1016 |
+
|
1017 |
+
array_walk_recursive(
|
1018 |
+
$array,
|
1019 |
+
function (&$leafnode) {
|
1020 |
+
$leafnode = 0;
|
1021 |
+
}
|
1022 |
+
);
|
1023 |
+
|
1024 |
+
return $array;
|
1025 |
+
}
|
1026 |
+
|
1027 |
+
public function is_gads_conversion_id($string): bool
|
1028 |
+
{
|
1029 |
+
|
1030 |
+
if (empty($string)) {
|
1031 |
+
return true;
|
1032 |
+
}
|
1033 |
+
|
1034 |
+
$re = '/^\d{8,11}$/m';
|
1035 |
+
|
1036 |
+
return $this->validate_with_regex($re, $string);
|
1037 |
+
}
|
1038 |
+
|
1039 |
+
protected function is_gads_conversion_label($string): bool
|
1040 |
+
{
|
1041 |
+
|
1042 |
+
if (empty($string)) {
|
1043 |
+
return true;
|
1044 |
+
}
|
1045 |
+
|
1046 |
+
$re = '/^[-a-zA-Z_0-9]{17,20}$/m';
|
1047 |
+
|
1048 |
+
return $this->validate_with_regex($re, $string);
|
1049 |
+
}
|
1050 |
+
|
1051 |
+
protected function is_gads_aw_merchant_id($string): bool
|
1052 |
+
{
|
1053 |
+
|
1054 |
+
if (empty($string)) {
|
1055 |
+
return true;
|
1056 |
+
}
|
1057 |
+
|
1058 |
+
$re = '/^\d{8,10}$/m';
|
1059 |
+
|
1060 |
+
return $this->validate_with_regex($re, $string);
|
1061 |
+
}
|
1062 |
+
|
1063 |
+
protected function is_facebook_pixel_id($string): bool
|
1064 |
+
{
|
1065 |
+
|
1066 |
+
if (empty($string)) {
|
1067 |
+
return true;
|
1068 |
+
}
|
1069 |
+
|
1070 |
+
$re = '/^\d{14,16}$/m';
|
1071 |
+
|
1072 |
+
return $this->validate_with_regex($re, $string);
|
1073 |
+
}
|
1074 |
+
|
1075 |
+
protected function validate_with_regex(string $re, $string): bool
|
1076 |
+
{
|
1077 |
+
preg_match_all($re, $string, $matches, PREG_SET_ORDER, 0);
|
1078 |
+
|
1079 |
+
if (isset($matches[0])) {
|
1080 |
+
return true;
|
1081 |
+
} else {
|
1082 |
+
return false;
|
1083 |
+
}
|
1084 |
+
}
|
1085 |
+
|
1086 |
+
}
|
classes/admin/class-ask-for-rating.php
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WGACT\Classes\Admin;
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
6 |
+
exit; // Exit if accessed directly
|
7 |
+
}
|
8 |
+
|
9 |
+
class Ask_For_Rating {
|
10 |
+
|
11 |
+
private $option_name = WGACT_DB_RATINGS;
|
12 |
+
private $conversions_count;
|
13 |
+
|
14 |
+
public function __construct() {
|
15 |
+
|
16 |
+
// $options = get_option($this->option_name);
|
17 |
+
// $options['conversions_count'] = 8;
|
18 |
+
// $options['rating_threshold'] = 10;
|
19 |
+
// unset($options['conversion_count']);
|
20 |
+
// $options['rating_done'] = false;
|
21 |
+
// update_option($this->option_name,$options);
|
22 |
+
|
23 |
+
// ask for a rating in a plugin notice
|
24 |
+
add_action( 'admin_enqueue_scripts', [$this,'wgact_rating_script'] );
|
25 |
+
add_action( 'wp_ajax_wgact_dismissed_notice_handler', [$this, 'ajax_rating_notice_handler'] );
|
26 |
+
add_action( 'admin_notices', [$this, 'ask_for_rating_notices_if_not_asked_before'] );
|
27 |
+
}
|
28 |
+
|
29 |
+
public function wgact_rating_script(){
|
30 |
+
|
31 |
+
wp_enqueue_script(
|
32 |
+
'ask-for-rating', // Handle
|
33 |
+
plugin_dir_url( __DIR__ ) . '../js/admin/ask-for-rating.js',
|
34 |
+
[ 'jquery' ],
|
35 |
+
WGACT_CURRENT_VERSION,
|
36 |
+
true
|
37 |
+
);
|
38 |
+
|
39 |
+
// wp_localize_script(
|
40 |
+
// 'ask-for-rating', // Handle
|
41 |
+
// 'ask-for-rating_ajax_object', // Object name
|
42 |
+
// [
|
43 |
+
// 'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
44 |
+
// 'ajaxnonce' => wp_create_nonce( 'ask-for-rating_security_nonce' )
|
45 |
+
// ]
|
46 |
+
// );
|
47 |
+
}
|
48 |
+
|
49 |
+
// server side php ajax handler for the admin rating notice
|
50 |
+
public function ajax_rating_notice_handler() {
|
51 |
+
|
52 |
+
$set = $_POST['set'];
|
53 |
+
|
54 |
+
$options = get_option($this->option_name);
|
55 |
+
|
56 |
+
if ( 'rating_done' === $set ){
|
57 |
+
|
58 |
+
// error_log('saving rating done');
|
59 |
+
$options['rating_done'] = true;
|
60 |
+
update_option($this->option_name, $options);
|
61 |
+
|
62 |
+
} elseif ('later' === $set) {
|
63 |
+
|
64 |
+
// error_log('saving later');
|
65 |
+
$options['rating_threshold'] = $this->get_next_threshold($options['conversions_count']);
|
66 |
+
update_option($this->option_name, $options);
|
67 |
+
}
|
68 |
+
|
69 |
+
wp_die(); // this is required to terminate immediately and return a proper response
|
70 |
+
}
|
71 |
+
|
72 |
+
public function ask_for_rating_notices_if_not_asked_before() {
|
73 |
+
|
74 |
+
$wgact_ratings = get_option($this->option_name);
|
75 |
+
|
76 |
+
if ( isset( $wgact_ratings['conversions_count'] ) ) {
|
77 |
+
|
78 |
+
$this->conversions_count = $wgact_ratings['conversions_count'];
|
79 |
+
// error_log('conversion count: ' . $wgact_ratings['conversions_count'] );
|
80 |
+
|
81 |
+
// if(false === $wgact_ratings['rating_done'] && $this->conversions_count > $wgact_ratings['rating_threshold'] ){
|
82 |
+
if((false === $wgact_ratings['rating_done'] && $this->conversions_count > $wgact_ratings['rating_threshold']) || ( defined( 'WGACT_ALWAYS_AKS_FOR_RATING' ) && true === WGACT_ALWAYS_AKS_FOR_RATING )){
|
83 |
+
|
84 |
+
$this->ask_for_rating_notices($this->conversions_count);
|
85 |
+
}
|
86 |
+
} else {
|
87 |
+
|
88 |
+
// set default settings for wgact_ratings
|
89 |
+
update_option($this->option_name, $this->get_default_settings());
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
private function get_next_threshold($conversions_count){
|
94 |
+
|
95 |
+
return $conversions_count * 10;
|
96 |
+
}
|
97 |
+
|
98 |
+
|
99 |
+
private function get_default_settings(): array {
|
100 |
+
|
101 |
+
return [
|
102 |
+
'conversions_count' => 1,
|
103 |
+
'rating_threshold' => 10,
|
104 |
+
'rating_done' => false,
|
105 |
+
];
|
106 |
+
}
|
107 |
+
|
108 |
+
// show an admin notice to ask for a plugin rating
|
109 |
+
public function ask_for_rating_notices($conversions_count) {
|
110 |
+
|
111 |
+
?>
|
112 |
+
<div class="notice notice-success wgact-rating-success-notice" style="display: none">
|
113 |
+
<div style="color:#02830b;font-weight: bold">
|
114 |
+
|
115 |
+
<span>
|
116 |
+
<?php
|
117 |
+
printf(
|
118 |
+
/* translators: %d: the amount of purchase conversions that have been measured */
|
119 |
+
esc_html__( 'Hey, I noticed that you tracked more than %d purchase conversions with the Google Ads Conversion Tracking plugin - that\'s awesome! Could you please do me a BIG favour and give it a 5-star rating on WordPress? Just to help us spread the word and boost our motivation.', 'woocommerce-google-adwords-conversion-tracking-tag' ),
|
120 |
+
$conversions_count
|
121 |
+
);
|
122 |
+
?>
|
123 |
+
|
124 |
+
</span>
|
125 |
+
<br>
|
126 |
+
<span>- Aleksandar</span>
|
127 |
+
</div>
|
128 |
+
<div style="font-weight: bold;">
|
129 |
+
|
130 |
+
<ul style="list-style-type: disc ;padding-left:20px">
|
131 |
+
<li>
|
132 |
+
<a id="rate-it" href="#">
|
133 |
+
<?php esc_html_e( 'Ok, you deserve it', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?>
|
134 |
+
</a>
|
135 |
+
</li>
|
136 |
+
<li>
|
137 |
+
<a id="maybe-later" href="#">
|
138 |
+
<?php esc_html_e( 'Nope, maybe later', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?>
|
139 |
+
</a>
|
140 |
+
</li>
|
141 |
+
<li>
|
142 |
+
<a id="already-did" href="#">
|
143 |
+
<?php esc_html_e( 'I already did', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?>
|
144 |
+
</a>
|
145 |
+
</li>
|
146 |
+
</ul>
|
147 |
+
</div>
|
148 |
+
|
149 |
+
|
150 |
+
</div>
|
151 |
+
<?php
|
152 |
+
|
153 |
+
}
|
154 |
+
|
155 |
+
}
|
{includes → classes/admin}/index.php
RENAMED
File without changes
|
classes/class-db-upgrade.php
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* DB upgrade function
|
4 |
+
*/
|
5 |
+
|
6 |
+
namespace WGACT\Classes;
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit; // Exit if accessed directly
|
10 |
+
}
|
11 |
+
|
12 |
+
class Db_Upgrade {
|
13 |
+
|
14 |
+
protected $options_backup_name = 'wgact_options_backup';
|
15 |
+
|
16 |
+
public function run_options_db_upgrade() {
|
17 |
+
|
18 |
+
$mysql_db_version = $this->get_mysql_db_version();
|
19 |
+
|
20 |
+
// determine version and run version specific upgrade function
|
21 |
+
// check if options db version zero by looking if the old entries are still there.
|
22 |
+
if ( '0.0' === $mysql_db_version ) {
|
23 |
+
$this->up_from_zero_to_1();
|
24 |
+
}
|
25 |
+
|
26 |
+
if ( version_compare(2, $mysql_db_version, '>' ) ){
|
27 |
+
$this->up_from_1_to_2();
|
28 |
+
}
|
29 |
+
|
30 |
+
if ( version_compare(3, $mysql_db_version, '>' ) ){
|
31 |
+
$this->up_from_2_to_3();
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
protected function up_from_2_to_3(){
|
36 |
+
$options_old = get_option(WGACT_DB_OPTIONS_NAME);
|
37 |
+
|
38 |
+
$this->backup_options($options_old, '2');
|
39 |
+
|
40 |
+
$options_new = $options_old;
|
41 |
+
|
42 |
+
$options_new['shop']['order_total_logic'] = $options_old['gads']['order_total_logic'];
|
43 |
+
|
44 |
+
$options_new['google']['ads'] = $options_old['gads'];
|
45 |
+
$options_new['google']['gtag'] = $options_old['gtag'];
|
46 |
+
|
47 |
+
|
48 |
+
unset($options_new['google']['ads']['order_total_logic']);
|
49 |
+
unset($options_new['gads']);
|
50 |
+
unset($options_new['gtag']);
|
51 |
+
unset($options_new['google']['ads']['google_business_vertical']);
|
52 |
+
|
53 |
+
$options_new['google']['ads']['google_business_vertical'] = 0;
|
54 |
+
|
55 |
+
$options_new['db_version'] = '3';
|
56 |
+
|
57 |
+
update_option(WGACT_DB_OPTIONS_NAME, $options_new);
|
58 |
+
}
|
59 |
+
|
60 |
+
protected function up_from_1_to_2(){
|
61 |
+
$options_old = get_option(WGACT_DB_OPTIONS_NAME);
|
62 |
+
|
63 |
+
$this->backup_options($options_old, '1');
|
64 |
+
|
65 |
+
$options_new = [
|
66 |
+
'gads' => [
|
67 |
+
'conversion_id' => $options_old['conversion_id'],
|
68 |
+
'conversion_label' => $options_old['conversion_label'],
|
69 |
+
'order_total_logic' => $options_old['order_total_logic'],
|
70 |
+
'add_cart_data' => $options_old['add_cart_data'],
|
71 |
+
'aw_merchant_id' => $options_old['aw_merchant_id'],
|
72 |
+
'product_identifier' => $options_old['product_identifier'],
|
73 |
+
],
|
74 |
+
'gtag' => [
|
75 |
+
'deactivation' => $options_old['gtag_deactivation'],
|
76 |
+
],
|
77 |
+
'db_version' => '2',
|
78 |
+
];
|
79 |
+
|
80 |
+
update_option(WGACT_DB_OPTIONS_NAME, $options_new);
|
81 |
+
}
|
82 |
+
|
83 |
+
protected function get_mysql_db_version(): string {
|
84 |
+
|
85 |
+
$options = get_option(WGACT_DB_OPTIONS_NAME);
|
86 |
+
|
87 |
+
// error_log(print_r($options,true));
|
88 |
+
|
89 |
+
if ( ( get_option( 'wgact_plugin_options_1' ) ) || ( get_option( 'wgact_plugin_options_2' ) ) ) {
|
90 |
+
return '0';
|
91 |
+
} elseif (array_key_exists('conversion_id', $options)) {
|
92 |
+
return '1';
|
93 |
+
} else {
|
94 |
+
return $options['db_version'];
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
public function up_from_zero_to_1() {
|
99 |
+
|
100 |
+
$option_name_old_1 = 'wgact_plugin_options_1';
|
101 |
+
$option_name_old_2 = 'wgact_plugin_options_2';
|
102 |
+
|
103 |
+
// db version place options into new array
|
104 |
+
$options = [
|
105 |
+
'conversion_id' => $this->get_option_value_v1( $option_name_old_1 ),
|
106 |
+
'conversion_label' => $this->get_option_value_v1( $option_name_old_2 ),
|
107 |
+
];
|
108 |
+
|
109 |
+
// store new option array into the options table
|
110 |
+
update_option( WGACT_DB_OPTIONS_NAME, $options );
|
111 |
+
|
112 |
+
// delete old options
|
113 |
+
// only on single site
|
114 |
+
// we will run the multisite deletion only during uninstall
|
115 |
+
delete_option( $option_name_old_1 );
|
116 |
+
delete_option( $option_name_old_2 );
|
117 |
+
}
|
118 |
+
|
119 |
+
protected function get_option_value_v1( string $option_name ): string {
|
120 |
+
if ( ! get_option( $option_name ) ) {
|
121 |
+
$option_value = "";
|
122 |
+
} else {
|
123 |
+
$option = get_option( $option_name );
|
124 |
+
$option_value = $option['text_string'];
|
125 |
+
}
|
126 |
+
|
127 |
+
return $option_value;
|
128 |
+
}
|
129 |
+
|
130 |
+
protected function backup_options($options, $version){
|
131 |
+
|
132 |
+
$options_backup = get_option($this->options_backup_name);
|
133 |
+
|
134 |
+
$options_backup[$version] = $options;
|
135 |
+
|
136 |
+
update_option( $this->options_backup_name, $options_backup );
|
137 |
+
}
|
138 |
+
}
|
classes/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
{includes → classes/pixels}/class-cookie-consent-management.php
RENAMED
@@ -6,20 +6,24 @@
|
|
6 |
*/
|
7 |
|
8 |
// TODO implement CCM https://wordpress.org/plugins/uk-cookie-consent/ (200k) -> doesn't allow cookies to be disabled
|
9 |
-
// TODO
|
10 |
-
// TODO
|
11 |
-
// TODO
|
12 |
-
// TODO
|
13 |
-
// TODO
|
14 |
-
// TODO
|
15 |
-
// TODO
|
|
|
|
|
16 |
|
17 |
|
|
|
|
|
18 |
if ( ! defined( 'ABSPATH' ) ) {
|
19 |
exit; // Exit if accessed directly
|
20 |
}
|
21 |
|
22 |
-
class
|
23 |
|
24 |
public $pluginPrefix;
|
25 |
|
@@ -96,7 +100,7 @@ class WgactCookieConsentManagement {
|
|
96 |
// https://wordpress.org/plugins/cookie-law-info/
|
97 |
public function is_cookie_law_info_cookie_prevention_active() {
|
98 |
|
99 |
-
$cookieConsentManagementcookie = $this->getCookie( '
|
100 |
|
101 |
if ( $cookieConsentManagementcookie == 'no' ) {
|
102 |
return true;
|
6 |
*/
|
7 |
|
8 |
// TODO implement CCM https://wordpress.org/plugins/uk-cookie-consent/ (200k) -> doesn't allow cookies to be disabled
|
9 |
+
// TODO implement CCM https://wordpress.org/plugins/auto-terms-of-service-and-privacy-policy/ (100k)
|
10 |
+
// TODO implement CCM https://wordpress.org/plugins/complianz-gdpr/ (100k)
|
11 |
+
// TODO implement CCM https://wordpress.org/plugins/eu-cookie-law/ (100k) -> doesn't set a non tracking cookie. bad programming overall
|
12 |
+
// TODO implement CCM https://wordpress.org/plugins/gdpr-cookie-compliance/ (100k)
|
13 |
+
// TODO implement CCM https://wordpress.org/plugins/cookiebot/ (60k) -> no cookie or filter based third party tracking opt out
|
14 |
+
// TODO implement CCM https://wordpress.org/plugins/gdpr/ (30k) -> not possible to implement since users can choose their own cookie names
|
15 |
+
// TODO implement CCM https://wordpress.org/plugins/wf-cookie-consent/ (20k)
|
16 |
+
// TODO implement CCM https://wordpress.org/plugins/responsive-cookie-consent/ (3k)
|
17 |
+
// TODO implement CCM https://wordpress.org/plugins/surbma-gdpr-proof-google-analytics/ (1k)
|
18 |
|
19 |
|
20 |
+
namespace WGACT\Classes\Pixels;
|
21 |
+
|
22 |
if ( ! defined( 'ABSPATH' ) ) {
|
23 |
exit; // Exit if accessed directly
|
24 |
}
|
25 |
|
26 |
+
class Cookie_Consent_Management {
|
27 |
|
28 |
public $pluginPrefix;
|
29 |
|
100 |
// https://wordpress.org/plugins/cookie-law-info/
|
101 |
public function is_cookie_law_info_cookie_prevention_active() {
|
102 |
|
103 |
+
$cookieConsentManagementcookie = $this->getCookie( 'cookielawinfo-checkbox-non-necessary' );
|
104 |
|
105 |
if ( $cookieConsentManagementcookie == 'no' ) {
|
106 |
return true;
|
classes/pixels/class-facebook.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WGACT\Classes\Pixels;
|
4 |
+
|
5 |
+
if (!defined('ABSPATH')) {
|
6 |
+
exit; // Exit if accessed directly
|
7 |
+
}
|
8 |
+
|
9 |
+
class Facebook extends Pixel
|
10 |
+
{
|
11 |
+
public function inject_everywhere()
|
12 |
+
{
|
13 |
+
|
14 |
+
// @formatter:off
|
15 |
+
?>
|
16 |
+
|
17 |
+
<!-- Facebook Pixel Code -->
|
18 |
+
<script>
|
19 |
+
!function(f,b,e,v,n,t,s)
|
20 |
+
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
|
21 |
+
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
|
22 |
+
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
|
23 |
+
n.queue=[];t=b.createElement(e);t.async=!0;
|
24 |
+
t.src=v;s=b.getElementsByTagName(e)[0];
|
25 |
+
s.parentNode.insertBefore(t,s)}(window, document,'script',
|
26 |
+
'https://connect.facebook.net/en_US/fbevents.js');
|
27 |
+
fbq('init', '<?php echo $this->options_obj->facebook->pixel_id ?>');
|
28 |
+
fbq('track', 'PageView');
|
29 |
+
</script>
|
30 |
+
<noscript><img height="1" width="1" style="display:none"
|
31 |
+
src="https://www.facebook.com/tr?id=<?php echo $this->options_obj->facebook->pixel_id ?>&ev=PageView&noscript=1"
|
32 |
+
/></noscript>
|
33 |
+
<!-- End Facebook Pixel Code -->
|
34 |
+
<?php
|
35 |
+
// @formatter:on
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
public function inject_search()
|
40 |
+
{
|
41 |
+
?>
|
42 |
+
|
43 |
+
<script>
|
44 |
+
fbq('track', 'Search');
|
45 |
+
</script>
|
46 |
+
<?php
|
47 |
+
}
|
48 |
+
|
49 |
+
public function inject_product($product_id, $product)
|
50 |
+
{
|
51 |
+
?>
|
52 |
+
|
53 |
+
<script>
|
54 |
+
fbq('track', 'ViewContent', {
|
55 |
+
'content_type' : 'product',
|
56 |
+
'content_name' : '<?php echo $product->get_name() ?>',
|
57 |
+
'content_category': <?php echo json_encode($this->get_product_category($product_id)) ?>,
|
58 |
+
'content_ids' : '<?php echo $product_id ?>',
|
59 |
+
'currency' : '<?php echo $this->options_obj->shop->currency ?>',
|
60 |
+
'value' : <?php echo (float)$product->get_price() . PHP_EOL ?>
|
61 |
+
});
|
62 |
+
</script>
|
63 |
+
<?php
|
64 |
+
}
|
65 |
+
|
66 |
+
public function inject_cart($cart, $cart_total)
|
67 |
+
{
|
68 |
+
?>
|
69 |
+
<script>
|
70 |
+
fbq('track', 'AddToCart', {
|
71 |
+
'content_name': 'Shopping Cart',
|
72 |
+
'content_type': 'product',
|
73 |
+
'content_ids' : <?php echo json_encode($this->get_cart_ids($cart)) ?>,
|
74 |
+
'currency' : '<?php echo $this->options_obj->shop->currency ?>',
|
75 |
+
'value' : <?php echo $cart_total . PHP_EOL ?>
|
76 |
+
});
|
77 |
+
</script>
|
78 |
+
<?php
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
public function inject_order_received_page($order, $order_total, $order_item_ids)
|
83 |
+
{
|
84 |
+
?>
|
85 |
+
|
86 |
+
<script>
|
87 |
+
fbq('track', 'Purchase', {
|
88 |
+
'content_type': 'product',
|
89 |
+
'content_ids' : <?php echo json_encode($order_item_ids) ?>,
|
90 |
+
'currency' : '<?php echo $this->options_obj->shop->currency ?>',
|
91 |
+
'value' : <?php echo $order_total . PHP_EOL ?>
|
92 |
+
});
|
93 |
+
</script>
|
94 |
+
|
95 |
+
<?php
|
96 |
+
}
|
97 |
+
|
98 |
+
}
|
classes/pixels/class-google.php
ADDED
@@ -0,0 +1,342 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WGACT\Classes\Pixels;
|
4 |
+
|
5 |
+
if (!defined('ABSPATH')) {
|
6 |
+
exit; // Exit if accessed directly
|
7 |
+
}
|
8 |
+
|
9 |
+
class Google extends Pixel
|
10 |
+
{
|
11 |
+
public function inject_product_category()
|
12 |
+
{
|
13 |
+
global $wp_query;
|
14 |
+
|
15 |
+
if (true == $this->dynamic_remarketing) {
|
16 |
+
?>
|
17 |
+
|
18 |
+
<script type="text/javascript">
|
19 |
+
<?php echo $this->gtag_config() ?>
|
20 |
+
|
21 |
+
gtag('event', 'view_item_list', {
|
22 |
+
'send_to': 'AW-<?php echo esc_html($this->conversion_id) ?>',
|
23 |
+
'items' : <?php echo json_encode($this->get_products_from_wp_query($wp_query)) . PHP_EOL ?>
|
24 |
+
});
|
25 |
+
</script>
|
26 |
+
<?php
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
public function inject_search()
|
31 |
+
{
|
32 |
+
global $wp_query;
|
33 |
+
|
34 |
+
if (true == $this->dynamic_remarketing) {
|
35 |
+
?>
|
36 |
+
|
37 |
+
<script type="text/javascript">
|
38 |
+
<?php echo $this->gtag_config() ?>
|
39 |
+
|
40 |
+
gtag('event', 'view_search_results',
|
41 |
+
{
|
42 |
+
'send_to': 'AW-<?php echo esc_html($this->conversion_id) ?>',
|
43 |
+
'items' : <?php echo json_encode($this->get_products_from_wp_query($wp_query)) . PHP_EOL ?>
|
44 |
+
});
|
45 |
+
</script>
|
46 |
+
<?php
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
public function inject_product($product_id, $product)
|
51 |
+
{
|
52 |
+
if (true == $this->dynamic_remarketing) {
|
53 |
+
|
54 |
+
$product_details = $this->get_gads_formatted_product_details_from_product_id($product_id);
|
55 |
+
?>
|
56 |
+
|
57 |
+
<script type="text/javascript">
|
58 |
+
<?php echo $this->gtag_config() ?>
|
59 |
+
|
60 |
+
gtag('event', 'view_item', {
|
61 |
+
'send_to': 'AW-<?php echo esc_html($this->conversion_id) ?>',
|
62 |
+
'value' : <?php echo $product_details['price'] ?>,
|
63 |
+
'items' : [<?php echo(json_encode($product_details)) ?>]
|
64 |
+
});
|
65 |
+
</script>
|
66 |
+
<?php
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
public function inject_cart($cart, $cart_total)
|
71 |
+
{
|
72 |
+
|
73 |
+
if (true == $this->dynamic_remarketing) {
|
74 |
+
|
75 |
+
?>
|
76 |
+
|
77 |
+
<script type="text/javascript">
|
78 |
+
<?php echo $this->gtag_config() ?>
|
79 |
+
|
80 |
+
gtag('event', 'add_to_cart', {
|
81 |
+
'send_to': 'AW-<?php echo esc_html($this->conversion_id) ?>',
|
82 |
+
'value' : <?php echo $cart_total ?>,
|
83 |
+
'items' : <?php echo (json_encode($this->get_gads_formatted_cart_items($cart))) . PHP_EOL ?>
|
84 |
+
});
|
85 |
+
</script>
|
86 |
+
<?php
|
87 |
+
}
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
public function inject_order_received_page($order, $order_total)
|
92 |
+
{
|
93 |
+
|
94 |
+
|
95 |
+
// use the right function to get the currency depending on the WooCommerce version
|
96 |
+
$order_currency = $this->woocommerce_3_and_above() ? $order->get_currency() : $order->get_order_currency();
|
97 |
+
|
98 |
+
// filter to adjust the order value
|
99 |
+
$order_total_filtered = apply_filters('wgact_conversion_value_filter', $order_total, $order);
|
100 |
+
|
101 |
+
$ratings = get_option(WGACT_DB_RATINGS);
|
102 |
+
$ratings['conversions_count'] = $ratings['conversions_count'] + 1;
|
103 |
+
update_option(WGACT_DB_RATINGS, $ratings);
|
104 |
+
|
105 |
+
?>
|
106 |
+
|
107 |
+
<!-- Global site tag (gtag.js) - Google Ads: <?php echo esc_html($this->conversion_id) ?> -->
|
108 |
+
<?php
|
109 |
+
|
110 |
+
// Only run conversion script if the payment has not failed. (has_status('completed') is too restrictive)
|
111 |
+
// Also don't run the pixel if an admin or shop manager is logged in.
|
112 |
+
if (!$order->has_status('failed') && !current_user_can('edit_others_pages') && $this->add_cart_data == 0) {
|
113 |
+
// if ( ! $order->has_status( 'failed' ) ) {
|
114 |
+
?>
|
115 |
+
|
116 |
+
<!-- Event tag for WooCommerce Checkout conversion page -->
|
117 |
+
<script>
|
118 |
+
<?php echo $this->gtag_config() ?>
|
119 |
+
|
120 |
+
gtag('event', 'conversion', {
|
121 |
+
'send_to' : 'AW-<?php echo esc_html($this->conversion_id) ?>/<?php echo esc_html($this->conversion_label) ?>',
|
122 |
+
'value' : <?php echo $order_total_filtered; ?>,
|
123 |
+
'currency' : '<?php echo $order_currency; ?>',
|
124 |
+
'transaction_id': '<?php echo $order->get_order_number(); ?>',
|
125 |
+
});
|
126 |
+
</script>
|
127 |
+
|
128 |
+
<?php echo $this->get_dyn_remarketing_purchase_script($order, $order_total) ?>
|
129 |
+
|
130 |
+
<?php
|
131 |
+
|
132 |
+
} else if (!$order->has_status('failed') && !current_user_can('edit_others_pages') && $this->add_cart_data == 1) {
|
133 |
+
?>
|
134 |
+
|
135 |
+
<!-- Event tag for WooCommerce Checkout conversion page -->
|
136 |
+
<script>
|
137 |
+
<?php echo $this->gtag_config() ?>
|
138 |
+
|
139 |
+
gtag('event', 'purchase', {
|
140 |
+
'send_to' : 'AW-<?php echo esc_html($this->conversion_id) ?>/<?php echo esc_html($this->conversion_label) ?>',
|
141 |
+
'transaction_id' : '<?php echo $order->get_order_number(); ?>',
|
142 |
+
'value' : <?php echo $order_total_filtered; ?>,
|
143 |
+
'currency' : '<?php echo $order_currency; ?>',
|
144 |
+
'discount' : <?php echo $order->get_total_discount(); ?>,
|
145 |
+
'aw_merchant_id' : '<?php echo $this->aw_merchant_id ?>',
|
146 |
+
'aw_feed_country' : '<?php echo $this->get_visitor_country(); ?>',
|
147 |
+
'aw_feed_language': '<?php echo $this->get_gmc_language(); ?>',
|
148 |
+
'items' : <?php echo json_encode($this->get_gads_formatted_order_items($order)) . PHP_EOL ?>
|
149 |
+
});
|
150 |
+
|
151 |
+
<?php // echo $this->get_dyn_remarketing_purchase_script($order, $order_total) ?>
|
152 |
+
|
153 |
+
</script>
|
154 |
+
<?php
|
155 |
+
|
156 |
+
} else {
|
157 |
+
|
158 |
+
?>
|
159 |
+
|
160 |
+
<!-- The Google Ads pixel has not been inserted. Possible reasons: -->
|
161 |
+
<!-- You are logged into WooCommerce as admin or shop manager. -->
|
162 |
+
<!-- The order payment has failed. -->
|
163 |
+
<!-- The pixel has already been fired. To prevent double counting the pixel is not being fired again. -->
|
164 |
+
|
165 |
+
<?php
|
166 |
+
} // end if order status
|
167 |
+
|
168 |
+
?>
|
169 |
+
|
170 |
+
<!-- END Google Code for Sales (Google Ads) Conversion Page -->
|
171 |
+
<?php
|
172 |
+
|
173 |
+
}
|
174 |
+
|
175 |
+
public function inject_everywhere()
|
176 |
+
{
|
177 |
+
if (!$this->options_obj->google->gtag->deactivation) {
|
178 |
+
?>
|
179 |
+
|
180 |
+
<!-- Global site tag (gtag.js) - Google Ads: <?php echo esc_html($this->conversion_id) ?> -->
|
181 |
+
<script async
|
182 |
+
src="https://www.googletagmanager.com/gtag/js?id=AW-<?php echo esc_html($this->conversion_id) ?>"></script>
|
183 |
+
<script>
|
184 |
+
window.dataLayer = window.dataLayer || [];
|
185 |
+
|
186 |
+
function gtag() {
|
187 |
+
dataLayer.push(arguments);
|
188 |
+
}
|
189 |
+
|
190 |
+
gtag('js', new Date());
|
191 |
+
|
192 |
+
gtag('config', 'AW-<?php echo esc_html($this->conversion_id) ?>');
|
193 |
+
</script>
|
194 |
+
|
195 |
+
<?php
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
protected function woocommerce_3_and_above(): bool
|
200 |
+
{
|
201 |
+
global $woocommerce;
|
202 |
+
if (version_compare($woocommerce->version, 3.0, ">=")) {
|
203 |
+
return true;
|
204 |
+
} else {
|
205 |
+
return false;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
|
210 |
+
protected function get_gmc_language(): string
|
211 |
+
{
|
212 |
+
return strtoupper(substr(get_locale(), 0, 2));
|
213 |
+
}
|
214 |
+
|
215 |
+
protected function get_gads_formatted_order_items($order)
|
216 |
+
{
|
217 |
+
$order_items = $order->get_items();
|
218 |
+
$order_items_array = [];
|
219 |
+
|
220 |
+
foreach ((array)$order_items as $item) {
|
221 |
+
|
222 |
+
$product = wc_get_product($item['product_id']);
|
223 |
+
|
224 |
+
$item_details_array = [];
|
225 |
+
|
226 |
+
$item_details_array['id'] = $this->get_compiled_product_id($item['product_id'], $product->get_sku());
|
227 |
+
$item_details_array['quantity'] = (int)$item['quantity'];
|
228 |
+
$item_details_array['price'] = (int)$product->get_price();
|
229 |
+
$item_details_array['google_business_vertical'] = $this->google_business_vertical;
|
230 |
+
|
231 |
+
|
232 |
+
array_push($order_items_array, $item_details_array);
|
233 |
+
}
|
234 |
+
|
235 |
+
// apply filter to the $order_items_array array
|
236 |
+
$order_items_array = apply_filters('wgact_filter', $order_items_array, 'order_items_array');
|
237 |
+
|
238 |
+
return $order_items_array;
|
239 |
+
}
|
240 |
+
|
241 |
+
protected function get_compiled_product_id($product_id, $product_sku): string
|
242 |
+
{
|
243 |
+
// depending on setting use product IDs or SKUs
|
244 |
+
if (0 == $this->product_identifier) {
|
245 |
+
return (string)$product_id;
|
246 |
+
} else if (1 == $this->product_identifier) {
|
247 |
+
return (string)'woocommerce_gpf_' . $product_id;
|
248 |
+
} else {
|
249 |
+
return (string)$product_sku;
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
// get products from wp_query
|
254 |
+
protected function get_products_from_wp_query($wp_query): array
|
255 |
+
{
|
256 |
+
$items = [];
|
257 |
+
|
258 |
+
$posts = $wp_query->posts;
|
259 |
+
|
260 |
+
foreach ($posts as $key => $post) {
|
261 |
+
|
262 |
+
if ($post->post_type == 'product') {
|
263 |
+
|
264 |
+
$item_details = [];
|
265 |
+
|
266 |
+
$product = wc_get_product($post->ID);
|
267 |
+
$item_details['id'] = $this->get_compiled_product_id($post->ID, $product->get_sku());
|
268 |
+
$item_details['google_business_vertical'] = $this->google_business_vertical;
|
269 |
+
|
270 |
+
array_push($items, $item_details);
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
return $items;
|
275 |
+
}
|
276 |
+
|
277 |
+
protected function gtag_config(): string
|
278 |
+
{
|
279 |
+
if ($this->gtag_deactivation == true) {
|
280 |
+
return "gtag('config', 'AW-" . $this->conversion_id . "');" . PHP_EOL;
|
281 |
+
} else {
|
282 |
+
return '';
|
283 |
+
}
|
284 |
+
}
|
285 |
+
|
286 |
+
protected function get_gads_formatted_product_details_from_product_id($product_id): array
|
287 |
+
{
|
288 |
+
$product = wc_get_product($product_id);
|
289 |
+
|
290 |
+
$product_details['id'] = $this->get_compiled_product_id(get_the_ID(), $product->get_sku());
|
291 |
+
$product_details['category'] = $this->get_product_category($product_id);
|
292 |
+
// $product_details['list_position'] = 1;
|
293 |
+
$product_details['quantity'] = 1;
|
294 |
+
$product_details['price'] = (float)$product->get_price();
|
295 |
+
$product_details['google_business_vertical'] = $this->google_business_vertical;
|
296 |
+
|
297 |
+
return $product_details;
|
298 |
+
}
|
299 |
+
|
300 |
+
// get an array with all cart product ids
|
301 |
+
protected function get_gads_formatted_cart_items($cart)
|
302 |
+
{
|
303 |
+
// error_log(print_r($cart, true));
|
304 |
+
// initiate product identifier array
|
305 |
+
$cart_items = [];
|
306 |
+
$item_details = [];
|
307 |
+
|
308 |
+
// go through the array and get all product identifiers
|
309 |
+
foreach ((array)$cart as $item) {
|
310 |
+
|
311 |
+
$product = wc_get_product($item['product_id']);
|
312 |
+
|
313 |
+
$item_details['id'] = $this->get_compiled_product_id($item['product_id'], $product->get_sku());
|
314 |
+
$item_details['quantity'] = (int)$item['quantity'];
|
315 |
+
$item_details['price'] = (int)$product->get_price();
|
316 |
+
$item_details['google_business_vertical'] = $this->google_business_vertical;
|
317 |
+
|
318 |
+
array_push($cart_items, $item_details);
|
319 |
+
}
|
320 |
+
|
321 |
+
// apply filter to the $cartprods_items array
|
322 |
+
$cart_items = apply_filters('wgact_filter', $cart_items, 'cart_items');
|
323 |
+
|
324 |
+
return $cart_items;
|
325 |
+
}
|
326 |
+
|
327 |
+
protected function get_dyn_remarketing_purchase_script($order, $order_total)
|
328 |
+
{
|
329 |
+
if (true == $this->dynamic_remarketing) {
|
330 |
+
?>
|
331 |
+
|
332 |
+
<script>
|
333 |
+
gtag('event', 'purchase', {
|
334 |
+
'send_to': 'AW-<?php echo esc_html($this->conversion_id) ?>',
|
335 |
+
'value' : <?php echo $order_total; ?>,
|
336 |
+
'items' : <?php echo (json_encode($this->get_gads_formatted_order_items($order))) . PHP_EOL ?>
|
337 |
+
});
|
338 |
+
</script>
|
339 |
+
<?php
|
340 |
+
}
|
341 |
+
}
|
342 |
+
}
|
classes/pixels/class-pixel-manager.php
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WGACT\Classes\Pixels;
|
4 |
+
|
5 |
+
use WC_Order;
|
6 |
+
|
7 |
+
if (!defined('ABSPATH')) {
|
8 |
+
exit; // Exit if accessed directly
|
9 |
+
}
|
10 |
+
|
11 |
+
class Pixel_Manager
|
12 |
+
{
|
13 |
+
protected $options;
|
14 |
+
protected $options_obj;
|
15 |
+
protected $cart;
|
16 |
+
protected $facebook_active;
|
17 |
+
|
18 |
+
public function __construct($options)
|
19 |
+
{
|
20 |
+
$this->options = $options;
|
21 |
+
$this->options_obj = json_decode(json_encode($this->options));
|
22 |
+
|
23 |
+
$this->options_obj->shop->currency = new \stdClass();
|
24 |
+
$this->options_obj->shop->currency = get_woocommerce_currency();
|
25 |
+
|
26 |
+
$this->facebook_active = !empty($this->options_obj->facebook->pixel_id);
|
27 |
+
|
28 |
+
add_action('wp_head', function () {
|
29 |
+
$this->inject_head_pixels();
|
30 |
+
});
|
31 |
+
}
|
32 |
+
|
33 |
+
public function inject_head_pixels()
|
34 |
+
{
|
35 |
+
global $woocommerce;
|
36 |
+
|
37 |
+
$cart = $woocommerce->cart->get_cart();
|
38 |
+
$cart_total = WC()->cart->get_cart_contents_total();
|
39 |
+
|
40 |
+
|
41 |
+
$this->inject_noptimize_opening_tag();
|
42 |
+
|
43 |
+
(new Google($this->options, $this->options_obj))->inject_everywhere();
|
44 |
+
if ($this->facebook_active) (new Facebook($this->options, $this->options_obj))->inject_everywhere();
|
45 |
+
|
46 |
+
|
47 |
+
if (is_product_category()) {
|
48 |
+
|
49 |
+
(new Google($this->options, $this->options_obj))->inject_product_category();
|
50 |
+
|
51 |
+
} elseif (is_search()) {
|
52 |
+
|
53 |
+
(new Google($this->options, $this->options_obj))->inject_search();
|
54 |
+
if ($this->facebook_active) (new Facebook($this->options, $this->options_obj))->inject_search();
|
55 |
+
|
56 |
+
} elseif (is_product() && (!isset($_POST['add-to-cart']))) {
|
57 |
+
|
58 |
+
$product_id = get_the_ID();
|
59 |
+
$product = wc_get_product($product_id);
|
60 |
+
|
61 |
+
if (is_bool($product)) {
|
62 |
+
// error_log( 'WooCommerce detects the page ID ' . $product_id . ' as product, but when invoked by wc_get_product( ' . $product_id . ' ) it returns no product object' );
|
63 |
+
return;
|
64 |
+
}
|
65 |
+
|
66 |
+
(new Google($this->options, $this->options_obj))->inject_product($product_id, $product);
|
67 |
+
if ($this->facebook_active) (new Facebook($this->options, $this->options_obj))->inject_product($product_id, $product);
|
68 |
+
|
69 |
+
} elseif (is_cart()) {
|
70 |
+
|
71 |
+
(new Google($this->options, $this->options_obj))->inject_cart($cart, $cart_total);
|
72 |
+
if ($this->facebook_active) (new Facebook($this->options, $this->options_obj))->inject_cart($cart, $cart_total);
|
73 |
+
|
74 |
+
} elseif (is_order_received_page()) {
|
75 |
+
|
76 |
+
// get order from URL and evaluate order total
|
77 |
+
$order_key = $_GET['key'];
|
78 |
+
$order = new WC_Order(wc_get_order_id_by_order_key($order_key));
|
79 |
+
|
80 |
+
$order_total = 0 == $this->options_obj->shop->order_total_logic ? $order->get_subtotal() - $order->get_total_discount() : $order->get_total();
|
81 |
+
|
82 |
+
$order_item_ids = $this->get_order_item_ids($order);
|
83 |
+
|
84 |
+
(new Google($this->options, $this->options_obj))->inject_order_received_page($order, $order_total, $order_item_ids);
|
85 |
+
if ($this->facebook_active) (new Facebook($this->options, $this->options_obj))->inject_order_received_page($order, $order_total, $order_item_ids);
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
$this->inject_noptimize_closing_tag();
|
91 |
+
}
|
92 |
+
|
93 |
+
private function inject_noptimize_opening_tag()
|
94 |
+
{
|
95 |
+
?>
|
96 |
+
<!--noptimize--><?php
|
97 |
+
}
|
98 |
+
|
99 |
+
private function inject_noptimize_closing_tag()
|
100 |
+
{
|
101 |
+
?>
|
102 |
+
<!--/noptimize-->
|
103 |
+
<?php
|
104 |
+
}
|
105 |
+
|
106 |
+
protected function get_order_item_ids($order)
|
107 |
+
{
|
108 |
+
$order_items = $order->get_items();
|
109 |
+
$order_items_array = [];
|
110 |
+
|
111 |
+
foreach ((array)$order_items as $item) {
|
112 |
+
array_push($order_items_array, (string)$item['product_id']);
|
113 |
+
}
|
114 |
+
|
115 |
+
// apply filter to the $order_items_array array
|
116 |
+
$order_items_array = apply_filters('wgact_filter', $order_items_array, 'order_items_array');
|
117 |
+
|
118 |
+
return $order_items_array;
|
119 |
+
}
|
120 |
+
|
121 |
+
}
|
classes/pixels/class-pixel.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WGACT\Classes\Pixels;
|
4 |
+
|
5 |
+
use WC_Geolocation;
|
6 |
+
|
7 |
+
if (!defined('ABSPATH')) {
|
8 |
+
exit; // Exit if accessed directly
|
9 |
+
}
|
10 |
+
|
11 |
+
class Pixel
|
12 |
+
{
|
13 |
+
protected $add_cart_data;
|
14 |
+
protected $aw_merchant_id;
|
15 |
+
protected $conversion_id;
|
16 |
+
protected $conversion_label;
|
17 |
+
protected $dynamic_remarketing;
|
18 |
+
protected $google_business_vertical;
|
19 |
+
protected $gtag_deactivation;
|
20 |
+
protected $ip;
|
21 |
+
protected $order_total_logic;
|
22 |
+
protected $product_identifier;
|
23 |
+
protected $options;
|
24 |
+
protected $options_obj;
|
25 |
+
|
26 |
+
public function __construct($options, $options_obj)
|
27 |
+
{
|
28 |
+
$this->options = $options;
|
29 |
+
$this->options_obj = $options_obj;
|
30 |
+
|
31 |
+
$this->order_total_logic = $this->options['shop']['order_total_logic'];
|
32 |
+
$this->add_cart_data = $this->options['google']['ads']['add_cart_data'];
|
33 |
+
$this->aw_merchant_id = $this->options['google']['ads']['aw_merchant_id'];
|
34 |
+
$this->conversion_id = $this->options['google']['ads']['conversion_id'];
|
35 |
+
$this->conversion_label = $this->options['google']['ads']['conversion_label'];
|
36 |
+
$this->dynamic_remarketing = $this->options['google']['ads']['dynamic_remarketing'];
|
37 |
+
$this->product_identifier = $this->options['google']['ads']['product_identifier'];
|
38 |
+
$this->google_business_vertical = $this->get_google_business_vertical($this->options['google']['ads']['google_business_vertical']);
|
39 |
+
$this->gtag_deactivation = $this->options['google']['gtag']['deactivation'];
|
40 |
+
}
|
41 |
+
|
42 |
+
protected function get_google_business_vertical($id): string
|
43 |
+
{
|
44 |
+
$verticals = [
|
45 |
+
0 => 'retail',
|
46 |
+
];
|
47 |
+
|
48 |
+
return $verticals[$id];
|
49 |
+
}
|
50 |
+
|
51 |
+
// get an array with all product categories
|
52 |
+
protected function get_product_category($product_id): array
|
53 |
+
{
|
54 |
+
$prod_cats = get_the_terms($product_id, 'product_cat');
|
55 |
+
$prod_cats_output = [];
|
56 |
+
|
57 |
+
// only continue with the loop if one or more product categories have been set for the product
|
58 |
+
if (!empty($prod_cats)) {
|
59 |
+
foreach ((array)$prod_cats as $key) {
|
60 |
+
array_push($prod_cats_output, $key->name);
|
61 |
+
}
|
62 |
+
|
63 |
+
// apply filter to the $prod_cats_output array
|
64 |
+
$prod_cats_output = apply_filters('wgact_filter', $prod_cats_output, 'prod_cats_output');
|
65 |
+
}
|
66 |
+
|
67 |
+
return $prod_cats_output;
|
68 |
+
}
|
69 |
+
|
70 |
+
// get an array with all cart product ids
|
71 |
+
protected function get_cart_ids($cart): array
|
72 |
+
{
|
73 |
+
// error_log(print_r($cart, true));
|
74 |
+
// initiate product identifier array
|
75 |
+
$cart_items = [];
|
76 |
+
|
77 |
+
// go through the array and get all product identifiers
|
78 |
+
foreach ((array)$cart as $item) {
|
79 |
+
array_push($cart_items, (string)$item['product_id']);
|
80 |
+
}
|
81 |
+
|
82 |
+
return $cart_items;
|
83 |
+
}
|
84 |
+
|
85 |
+
protected function get_visitor_country()
|
86 |
+
{
|
87 |
+
if ($this->isLocalhost()) {
|
88 |
+
$this->ip = WC_Geolocation::get_external_ip_address();
|
89 |
+
} else {
|
90 |
+
$this->ip = WC_Geolocation::get_ip_address();
|
91 |
+
}
|
92 |
+
|
93 |
+
$location = WC_Geolocation::geolocate_ip($this->ip);
|
94 |
+
|
95 |
+
return $location['country'];
|
96 |
+
}
|
97 |
+
|
98 |
+
protected function isLocalhost(): bool
|
99 |
+
{
|
100 |
+
return in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']);
|
101 |
+
}
|
102 |
+
}
|
classes/pixels/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
css/admin.css
CHANGED
@@ -16,4 +16,44 @@
|
|
16 |
padding: 0 5px 0 5px;
|
17 |
color: black;
|
18 |
font-weight: normal;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
16 |
padding: 0 5px 0 5px;
|
17 |
color: black;
|
18 |
font-weight: normal;
|
19 |
+
}
|
20 |
+
|
21 |
+
.tooltip {
|
22 |
+
position: relative;
|
23 |
+
display: inline-block;
|
24 |
+
}
|
25 |
+
|
26 |
+
.tooltip .tooltiptext {
|
27 |
+
visibility: hidden;
|
28 |
+
/* width: 120px; */
|
29 |
+
background-color: #0073aa;
|
30 |
+
color: #fff;
|
31 |
+
text-align: center;
|
32 |
+
border-radius: 6px;
|
33 |
+
padding: 5px 5px 5px 5px;
|
34 |
+
position: absolute;
|
35 |
+
z-index: 1;
|
36 |
+
top: -5px;
|
37 |
+
left: 105%;
|
38 |
+
font-family: apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
|
39 |
+
margin-left: 10px;
|
40 |
+
font-size: 16px;
|
41 |
+
}
|
42 |
+
|
43 |
+
.tooltip:hover .tooltiptext {
|
44 |
+
visibility: visible;
|
45 |
+
}
|
46 |
+
|
47 |
+
.developer-banner {
|
48 |
+
background: #f3f5f6;
|
49 |
+
color: #0071a1;
|
50 |
+
padding: 0px 10px;
|
51 |
+
margin-bottom: 20px;
|
52 |
+
border-radius: 3px;
|
53 |
+
border-style: solid;
|
54 |
+
border-width: 1px;
|
55 |
+
min-height: 30px;
|
56 |
+
display: flex;
|
57 |
+
flex-direction: column;
|
58 |
+
justify-content: center;
|
59 |
}
|
css/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
freemius/includes/fs-core-functions.php
CHANGED
@@ -114,27 +114,27 @@
|
|
114 |
if ( ! function_exists( 'fs_enqueue_local_style' ) ) {
|
115 |
function fs_enqueue_local_style( $handle, $path, $deps = array(), $ver = false, $media = 'all' ) {
|
116 |
|
117 |
-
|
118 |
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
|
123 |
-
|
124 |
}
|
125 |
}
|
126 |
|
127 |
if ( ! function_exists( 'fs_enqueue_local_script' ) ) {
|
128 |
function fs_enqueue_local_script( $handle, $path, $deps = array(), $ver = false, $in_footer = 'all' ) {
|
129 |
-
|
130 |
|
131 |
-
|
132 |
|
133 |
wp_enqueue_script( $handle, plugin_dir_url( '' ) . 'woocommerce-google-adwords-conversion-tracking-tag' . '/freemius/assets/js/'. $path, $deps, $ver, $in_footer );
|
134 |
-
|
135 |
-
|
136 |
|
137 |
-
|
138 |
}
|
139 |
}
|
140 |
|
@@ -852,7 +852,7 @@
|
|
852 |
* @global $fs_text_overrides
|
853 |
*/
|
854 |
function _fs_text_x_inline( $text, $context, $key = '', $slug = 'freemius' ) {
|
855 |
-
|
856 |
|
857 |
// Avoid misleading Theme Check warning.
|
858 |
$fn = 'translate_with_gettext_context';
|
@@ -1012,7 +1012,7 @@
|
|
1012 |
* @global $fs_text_overrides
|
1013 |
*/
|
1014 |
function _fs_text_inline( $text, $key = '', $slug = 'freemius' ) {
|
1015 |
-
|
1016 |
|
1017 |
// Avoid misleading Theme Check warning.
|
1018 |
$fn = 'translate';
|
114 |
if ( ! function_exists( 'fs_enqueue_local_style' ) ) {
|
115 |
function fs_enqueue_local_style( $handle, $path, $deps = array(), $ver = false, $media = 'all' ) {
|
116 |
|
117 |
+
if ( defined( 'WP_FS__SYMLINKS' ) && true === WP_FS__SYMLINKS ) {
|
118 |
|
119 |
+
wp_enqueue_style( $handle, plugin_dir_url( '' ) . 'woocommerce-google-adwords-conversion-tracking-tag' . '/freemius/assets/css'. $path, $deps, $ver, $media );
|
120 |
+
} else {
|
121 |
+
wp_enqueue_style( $handle, fs_asset_url( WP_FS__DIR_CSS . '/' . trim( $path, '/' ) ), $deps, $ver, $media );
|
122 |
|
123 |
+
}
|
124 |
}
|
125 |
}
|
126 |
|
127 |
if ( ! function_exists( 'fs_enqueue_local_script' ) ) {
|
128 |
function fs_enqueue_local_script( $handle, $path, $deps = array(), $ver = false, $in_footer = 'all' ) {
|
129 |
+
if ( defined( 'WP_FS__SYMLINKS' ) && true === WP_FS__SYMLINKS ) {
|
130 |
|
131 |
+
error_log('FS_WP__DIR');
|
132 |
|
133 |
wp_enqueue_script( $handle, plugin_dir_url( '' ) . 'woocommerce-google-adwords-conversion-tracking-tag' . '/freemius/assets/js/'. $path, $deps, $ver, $in_footer );
|
134 |
+
} else {
|
135 |
+
wp_enqueue_script( $handle, fs_asset_url( WP_FS__DIR_JS . '/' . trim( $path, '/' ) ), $deps, $ver, $in_footer );
|
136 |
|
137 |
+
}
|
138 |
}
|
139 |
}
|
140 |
|
852 |
* @global $fs_text_overrides
|
853 |
*/
|
854 |
function _fs_text_x_inline( $text, $context, $key = '', $slug = 'freemius' ) {
|
855 |
+
list( $text, $text_domain ) = fs_text_and_domain( $text, $key, $slug );
|
856 |
|
857 |
// Avoid misleading Theme Check warning.
|
858 |
$fn = 'translate_with_gettext_context';
|
1012 |
* @global $fs_text_overrides
|
1013 |
*/
|
1014 |
function _fs_text_inline( $text, $key = '', $slug = 'freemius' ) {
|
1015 |
+
list( $text, $text_domain ) = fs_text_and_domain( $text, $key, $slug );
|
1016 |
|
1017 |
// Avoid misleading Theme Check warning.
|
1018 |
$fn = 'translate';
|
freemius/package.json
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
"author": "Freemius, Inc.",
|
5 |
"license": "GPL-3.0",
|
6 |
"homepage": "https://freemius.com",
|
7 |
-
"version": "2.4.
|
8 |
"main": "gulpfile.js",
|
9 |
"dependencies": {},
|
10 |
"scripts": {
|
4 |
"author": "Freemius, Inc.",
|
5 |
"license": "GPL-3.0",
|
6 |
"homepage": "https://freemius.com",
|
7 |
+
"version": "2.4.1",
|
8 |
"main": "gulpfile.js",
|
9 |
"dependencies": {},
|
10 |
"scripts": {
|
includes/class-ask-for-rating.php
DELETED
@@ -1,105 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit; // Exit if accessed directly
|
5 |
-
}
|
6 |
-
|
7 |
-
class WgactAskForRating {
|
8 |
-
|
9 |
-
public function init() {
|
10 |
-
|
11 |
-
// ask for a rating in a plugin notice
|
12 |
-
add_action( 'admin_head', [$this, 'ask_for_rating_js'] );
|
13 |
-
add_action( 'wp_ajax_wgact_dismissed_notice_handler', [$this, 'ajax_rating_notice_handler'] );
|
14 |
-
add_action( 'admin_notices', [$this, 'ask_for_rating_notices_if_not_asked_before'] );
|
15 |
-
|
16 |
-
}
|
17 |
-
|
18 |
-
// client side ajax js handler for the admin rating notice
|
19 |
-
public function ask_for_rating_js() {
|
20 |
-
|
21 |
-
?>
|
22 |
-
<script type="text/javascript">
|
23 |
-
jQuery(document).on('click', '.notice-success.wgact-rating-success-notice, wgact-rating-link, .wgact-rating-support', function ($) {
|
24 |
-
|
25 |
-
var data = {
|
26 |
-
'action': 'wgact_dismissed_notice_handler',
|
27 |
-
};
|
28 |
-
|
29 |
-
jQuery.post(ajaxurl, data);
|
30 |
-
jQuery('.wgact-rating-success-notice').remove();
|
31 |
-
|
32 |
-
});
|
33 |
-
</script> <?php
|
34 |
-
|
35 |
-
}
|
36 |
-
|
37 |
-
// server side php ajax handler for the admin rating notice
|
38 |
-
public function ajax_rating_notice_handler() {
|
39 |
-
|
40 |
-
// prepare the data that needs to be written into the user meta
|
41 |
-
$wgdr_admin_notice_user_meta = array(
|
42 |
-
'date-dismissed' => date( 'Y-m-d' ),
|
43 |
-
);
|
44 |
-
|
45 |
-
// update the user meta
|
46 |
-
update_user_meta( get_current_user_id(), 'wgact_admin_notice_user_meta', $wgdr_admin_notice_user_meta );
|
47 |
-
|
48 |
-
wp_die(); // this is required to terminate immediately and return a proper response
|
49 |
-
}
|
50 |
-
|
51 |
-
// only ask for rating if not asked before or longer than a year
|
52 |
-
public function ask_for_rating_notices_if_not_asked_before() {
|
53 |
-
|
54 |
-
// get user meta data for this plugin
|
55 |
-
$user_meta = get_user_meta( get_current_user_id(), 'wgact_admin_notice_user_meta' );
|
56 |
-
|
57 |
-
// check if there is already a saved value in the user meta
|
58 |
-
if ( isset( $user_meta[0]['date-dismissed'] ) ) {
|
59 |
-
|
60 |
-
$date_1 = date_create( $user_meta[0]['date-dismissed'] );
|
61 |
-
$date_2 = date_create( date( 'Y-m-d' ) );
|
62 |
-
|
63 |
-
// calculate day difference between the dates
|
64 |
-
$interval = date_diff( $date_1, $date_2 );
|
65 |
-
|
66 |
-
// check if the date difference is more than 360 days
|
67 |
-
if ( 360 < $interval->format( '%a' ) ) {
|
68 |
-
$this->ask_for_rating_notices();
|
69 |
-
}
|
70 |
-
|
71 |
-
} else {
|
72 |
-
|
73 |
-
$this->ask_for_rating_notices();
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
// show an admin notice to ask for a plugin rating
|
78 |
-
public function ask_for_rating_notices() {
|
79 |
-
|
80 |
-
$current_user = wp_get_current_user();
|
81 |
-
|
82 |
-
?>
|
83 |
-
<div class="notice notice-success is-dismissible wgact-rating-success-notice">
|
84 |
-
<p>
|
85 |
-
<span><?php esc_html_e( 'Hi ', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?></span>
|
86 |
-
<span><?php echo( $current_user->user_firstname ? $current_user->user_firstname : $current_user->nickname ); ?></span>
|
87 |
-
<span><?php esc_html_e( '! ', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?></span>
|
88 |
-
<span><?php esc_html_e( 'You\'ve been using the WGACT Google Ads Conversion Tracking Plugin for a while now. If you like the plugin please support our development by leaving a ★★★★★ rating: ', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?></span>
|
89 |
-
<span class="wgact-rating-link">
|
90 |
-
<a href="https://wordpress.org/support/view/plugin-reviews/woocommerce-google-adwords-conversion-tracking-tag?rate=5#postform"
|
91 |
-
target="_blank"><?php esc_html_e( 'Rate it!', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?></a>
|
92 |
-
</span>
|
93 |
-
</p>
|
94 |
-
<p>
|
95 |
-
<span><?php esc_html_e( 'Or else, please leave us a support question in the forum. We\'ll be happy to assist you: ', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?></span>
|
96 |
-
<span class="wgact-rating-support">
|
97 |
-
<a href="https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag"
|
98 |
-
target="_blank"><?php esc_html_e( 'Get support', 'woocommerce-google-adwords-conversion-tracking-tag' ); ?></a>
|
99 |
-
</span>
|
100 |
-
</p>
|
101 |
-
</div>
|
102 |
-
<?php
|
103 |
-
|
104 |
-
}
|
105 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-db-upgrade.php
DELETED
@@ -1,62 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* DB upgrade function
|
4 |
-
*/
|
5 |
-
|
6 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
-
exit; // Exit if accessed directly
|
8 |
-
}
|
9 |
-
|
10 |
-
class WgactDbUpgrade {
|
11 |
-
|
12 |
-
protected $options_db_name = 'wgact_plugin_options';
|
13 |
-
|
14 |
-
public function run_options_db_upgrade() {
|
15 |
-
|
16 |
-
// determine version and run version specific upgrade function
|
17 |
-
// check if options db version zero by looking if the old entries are still there.
|
18 |
-
if ( ( get_option( 'wgact_plugin_options_1' ) ) or ( get_option( 'wgact_plugin_options_2' ) ) ) {
|
19 |
-
// error_log( 'current db version is zero ' );
|
20 |
-
$this->upgrade_options_db_from_zero_to_1_point_zero();
|
21 |
-
}
|
22 |
-
}
|
23 |
-
|
24 |
-
public function upgrade_options_db_from_zero_to_1_point_zero() {
|
25 |
-
|
26 |
-
$option_name_1 = 'wgact_plugin_options_1';
|
27 |
-
$option_name_2 = 'wgact_plugin_options_2';
|
28 |
-
|
29 |
-
// get current options
|
30 |
-
// get option 1
|
31 |
-
if ( ! ( get_option( $option_name_1 ) ) ) {
|
32 |
-
$option_value_1 = "";
|
33 |
-
} else {
|
34 |
-
$option_value_1_array = get_option( $option_name_1 );
|
35 |
-
$option_value_1 = $option_value_1_array['text_string'];
|
36 |
-
}
|
37 |
-
|
38 |
-
// get option 2
|
39 |
-
if ( ! ( get_option( $option_name_2 ) ) ) {
|
40 |
-
$option_value_2 = "";
|
41 |
-
} else {
|
42 |
-
$option_value_2_array = get_option( $option_name_2 );
|
43 |
-
$option_value_2 = $option_value_2_array['text_string'];
|
44 |
-
}
|
45 |
-
|
46 |
-
// db version place options into new array
|
47 |
-
$options_array = array(
|
48 |
-
'conversion_id' => $option_value_1,
|
49 |
-
'conversion_label' => $option_value_2,
|
50 |
-
);
|
51 |
-
|
52 |
-
// store new option array into the options table
|
53 |
-
update_option( $this->options_db_name, $options_array );
|
54 |
-
|
55 |
-
// delete old options
|
56 |
-
// only on single site
|
57 |
-
// we will run the multisite deletion only during uninstall
|
58 |
-
delete_option( $option_name_1 );
|
59 |
-
delete_option( $option_name_2 );
|
60 |
-
|
61 |
-
}
|
62 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-gtag.php
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit; // Exit if accessed directly
|
5 |
-
}
|
6 |
-
|
7 |
-
class WgactGtag {
|
8 |
-
|
9 |
-
public $conversion_id;
|
10 |
-
|
11 |
-
public function set_conversion_id ($conversion_id) {
|
12 |
-
$this->conversion_id = $conversion_id;
|
13 |
-
}
|
14 |
-
|
15 |
-
public function inject () {
|
16 |
-
?>
|
17 |
-
|
18 |
-
<!--noptimize-->
|
19 |
-
<!-- Global site tag (gtag.js) - Google Ads: <?php echo esc_html( $this->conversion_id ) ?> -->
|
20 |
-
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-<?php echo esc_html( $this->conversion_id ) ?>"></script>
|
21 |
-
<script>
|
22 |
-
window.dataLayer = window.dataLayer || [];
|
23 |
-
|
24 |
-
function gtag() {
|
25 |
-
dataLayer.push(arguments);
|
26 |
-
}
|
27 |
-
|
28 |
-
gtag('js', new Date());
|
29 |
-
|
30 |
-
gtag('config', 'AW-<?php echo esc_html( $this->conversion_id ) ?>');
|
31 |
-
</script>
|
32 |
-
<!--/noptimize-->
|
33 |
-
|
34 |
-
<?php
|
35 |
-
|
36 |
-
}
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-pixel.php
DELETED
@@ -1,218 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit; // Exit if accessed directly
|
5 |
-
}
|
6 |
-
|
7 |
-
class WgactPixel {
|
8 |
-
|
9 |
-
public $conversion_id;
|
10 |
-
public $conversion_label;
|
11 |
-
public $add_cart_data;
|
12 |
-
public $product_identifier;
|
13 |
-
public $gtag_deactivation;
|
14 |
-
public $ip;
|
15 |
-
|
16 |
-
public function GoogleAdsTag() {
|
17 |
-
|
18 |
-
$this->conversion_id = $this->get_conversion_id();
|
19 |
-
$this->conversion_label = $this->get_conversion_label();
|
20 |
-
$this->add_cart_data = $this->get_add_cart_data();
|
21 |
-
$this->product_identifier = $this->get_product_identifier();
|
22 |
-
$this->gtag_deactivation = $this->get_gtag_deactivation();
|
23 |
-
|
24 |
-
if($this->gtag_deactivation == 0) {
|
25 |
-
|
26 |
-
$wgact_gtag = new WgactGtag();
|
27 |
-
$wgact_gtag->set_conversion_id($this->get_conversion_id());
|
28 |
-
$wgact_gtag->inject();
|
29 |
-
}
|
30 |
-
|
31 |
-
if ( is_order_received_page() ) {
|
32 |
-
|
33 |
-
// get order from URL and evaluate order total
|
34 |
-
$order_key = $_GET['key'];
|
35 |
-
$order = new WC_Order( wc_get_order_id_by_order_key( $order_key ) );
|
36 |
-
|
37 |
-
$options = get_option( 'wgact_plugin_options' );
|
38 |
-
$order_total_setting = $options['order_total_logic'];
|
39 |
-
$order_total = 0 == $order_total_setting ? $order->get_subtotal() - $order->get_total_discount(): $order->get_total();
|
40 |
-
|
41 |
-
// use the right function to get the currency depending on the WooCommerce version
|
42 |
-
$order_currency = $this->woocommerce_3_and_above() ? $order->get_currency() : $order->get_order_currency();
|
43 |
-
|
44 |
-
// filter to adjust the order value
|
45 |
-
$order_total_filtered = apply_filters( 'wgact_conversion_value_filter', $order_total, $order );
|
46 |
-
|
47 |
-
?>
|
48 |
-
|
49 |
-
<!--noptimize-->
|
50 |
-
<!-- Global site tag (gtag.js) - Google Ads: <?php echo esc_html( $this->conversion_id ) ?> -->
|
51 |
-
<?php
|
52 |
-
|
53 |
-
// Only run conversion script if the payment has not failed. (has_status('completed') is too restrictive)
|
54 |
-
// Also don't run the pixel if an admin or shop manager is logged in.
|
55 |
-
if ( ! $order->has_status( 'failed' ) && ! current_user_can( 'edit_others_pages' ) && $this->add_cart_data == 0 ) {
|
56 |
-
// if ( ! $order->has_status( 'failed' ) ) {
|
57 |
-
?>
|
58 |
-
|
59 |
-
<!-- Event tag for WooCommerce Checkout conversion page -->
|
60 |
-
<script>
|
61 |
-
gtag('event', 'conversion', {
|
62 |
-
'send_to': 'AW-<?php echo esc_html( $this->conversion_id ) ?>/<?php echo esc_html( $this->conversion_label ) ?>',
|
63 |
-
'value': <?php echo $order_total_filtered; ?>,
|
64 |
-
'currency': '<?php echo $order_currency; ?>',
|
65 |
-
'transaction_id': '<?php echo $order->get_order_number(); ?>',
|
66 |
-
});
|
67 |
-
</script>
|
68 |
-
<?php
|
69 |
-
|
70 |
-
} elseif ( ! $order->has_status( 'failed' ) && ! current_user_can( 'edit_others_pages' ) && $this->add_cart_data == 1 ){
|
71 |
-
?>
|
72 |
-
|
73 |
-
<!-- Event tag for WooCommerce Checkout conversion page -->
|
74 |
-
<script>
|
75 |
-
gtag('event', 'purchase', {
|
76 |
-
'send_to': 'AW-<?php echo esc_html( $this->conversion_id ) ?>/<?php echo esc_html( $this->conversion_label ) ?>',
|
77 |
-
'transaction_id': '<?php echo $order->get_order_number(); ?>',
|
78 |
-
'value': <?php echo $order_total_filtered; ?>,
|
79 |
-
'currency': '<?php echo $order_currency; ?>',
|
80 |
-
'discount': <?php echo $order->get_total_discount(); ?>,
|
81 |
-
'aw_merchant_id': '<?php echo $options['aw_merchant_id']; ?>',
|
82 |
-
'aw_feed_country': '<?php echo $this->get_visitor_country(); ?>',
|
83 |
-
'aw_feed_language': '<?php echo $this->get_gmc_language(); ?>',
|
84 |
-
'items': <?php echo json_encode( $this->get_order_items($order) ); ?>
|
85 |
-
});
|
86 |
-
</script>
|
87 |
-
<?php
|
88 |
-
|
89 |
-
} else {
|
90 |
-
|
91 |
-
?>
|
92 |
-
|
93 |
-
<!-- The Google Ads pixel has not been inserted. Possible reasons: -->
|
94 |
-
<!-- You are logged into WooCommerce as admin or shop manager. -->
|
95 |
-
<!-- The order payment has failed. -->
|
96 |
-
<!-- The pixel has already been fired. To prevent double counting the pixel is not being fired again. -->
|
97 |
-
|
98 |
-
<?php
|
99 |
-
} // end if order status
|
100 |
-
|
101 |
-
?>
|
102 |
-
|
103 |
-
<!-- END Google Code for Sales (Google Ads) Conversion Page -->
|
104 |
-
<!--/noptimize-->
|
105 |
-
<?php
|
106 |
-
}
|
107 |
-
}
|
108 |
-
|
109 |
-
public function get_conversion_id() {
|
110 |
-
$opt = get_option( 'wgact_plugin_options' );
|
111 |
-
|
112 |
-
return $opt['conversion_id'];
|
113 |
-
}
|
114 |
-
|
115 |
-
public function get_conversion_label() {
|
116 |
-
$opt = get_option( 'wgact_plugin_options' );
|
117 |
-
|
118 |
-
return $opt['conversion_label'];
|
119 |
-
}
|
120 |
-
|
121 |
-
public function get_add_cart_data() {
|
122 |
-
$opt = get_option( 'wgact_plugin_options' );
|
123 |
-
|
124 |
-
if ($opt == ''){
|
125 |
-
return 0;
|
126 |
-
} else {
|
127 |
-
return $opt['add_cart_data'];
|
128 |
-
}
|
129 |
-
}
|
130 |
-
|
131 |
-
public function get_product_identifier() {
|
132 |
-
$opt = get_option( 'wgact_plugin_options' );
|
133 |
-
|
134 |
-
return $opt['product_identifier'];
|
135 |
-
}
|
136 |
-
|
137 |
-
public function woocommerce_3_and_above(){
|
138 |
-
global $woocommerce;
|
139 |
-
if( version_compare( $woocommerce->version, 3.0, ">=" ) ) {
|
140 |
-
return true;
|
141 |
-
} else {
|
142 |
-
return false;
|
143 |
-
}
|
144 |
-
}
|
145 |
-
|
146 |
-
public function get_visitor_country(){
|
147 |
-
|
148 |
-
if ( $this->isLocalhost() ){
|
149 |
-
// error_log('check external ip');
|
150 |
-
$this->ip = WC_Geolocation::get_external_ip_address();
|
151 |
-
} else {
|
152 |
-
// error_log('check regular ip');
|
153 |
-
$this->ip = WC_Geolocation::get_ip_address();
|
154 |
-
}
|
155 |
-
|
156 |
-
$location = WC_Geolocation::geolocate_ip($this->ip);
|
157 |
-
|
158 |
-
// error_log ('ip: ' . $this->ip);
|
159 |
-
// error_log ('country: ' . $location['country']);
|
160 |
-
return $location['country'];
|
161 |
-
}
|
162 |
-
|
163 |
-
public function isLocalhost() {
|
164 |
-
return in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']);
|
165 |
-
}
|
166 |
-
|
167 |
-
public function get_gmc_language(){
|
168 |
-
return strtoupper(substr( get_locale(), 0, 2 ));
|
169 |
-
}
|
170 |
-
|
171 |
-
public function get_order_items($order){
|
172 |
-
|
173 |
-
$order_items = $order->get_items();
|
174 |
-
$order_items_array = array();
|
175 |
-
|
176 |
-
foreach ( (array) $order_items as $item ) {
|
177 |
-
|
178 |
-
$product = wc_get_product( $item['product_id'] );
|
179 |
-
|
180 |
-
$item_details_array = array();
|
181 |
-
|
182 |
-
// depending on setting use product IDs or SKUs
|
183 |
-
if ( 0 == $this->product_identifier ) {
|
184 |
-
|
185 |
-
$item_details_array['id'] = (string)$item['product_id'];
|
186 |
-
|
187 |
-
} elseif ( 1 == $this->product_identifier ) {
|
188 |
-
|
189 |
-
$item_details_array['id'] = 'woocommerce_gpf_' . $item['product_id'];
|
190 |
-
|
191 |
-
} else {
|
192 |
-
|
193 |
-
// fill the array with all product SKUs
|
194 |
-
$item_details_array['id'] = (string)$product->get_sku();
|
195 |
-
|
196 |
-
}
|
197 |
-
|
198 |
-
$item_details_array['quantity'] = (int)$item['quantity'];
|
199 |
-
$item_details_array['price'] = (int)$product->get_price();
|
200 |
-
|
201 |
-
array_push($order_items_array, $item_details_array);
|
202 |
-
|
203 |
-
}
|
204 |
-
|
205 |
-
// apply filter to the $order_items_array array
|
206 |
-
$order_items_array = apply_filters( 'wgdr_filter', $order_items_array, 'order_items_array' );
|
207 |
-
|
208 |
-
return $order_items_array;
|
209 |
-
|
210 |
-
}
|
211 |
-
|
212 |
-
public function get_gtag_deactivation() {
|
213 |
-
$opt = get_option( 'wgact_plugin_options' );
|
214 |
-
|
215 |
-
return $opt['gtag_deactivation'];
|
216 |
-
}
|
217 |
-
|
218 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/admin-helpers.js
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
|
2 |
-
// copy debug info textarea
|
3 |
-
(function(){
|
4 |
-
jQuery("#debug-info-button").click(function () {
|
5 |
-
jQuery("#debug-info-textarea").select();
|
6 |
-
document.execCommand('copy');
|
7 |
-
});
|
8 |
-
})();
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/admin/ask-for-rating.js
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function (){
|
2 |
+
|
3 |
+
jQuery('.wgact-rating-success-notice').show();
|
4 |
+
|
5 |
+
// go and rate it or already done
|
6 |
+
jQuery(document).on('click', '#rate-it', function (e) {
|
7 |
+
process_click(e, 'rating_done');
|
8 |
+
|
9 |
+
let win = window.open('https://wordpress.org/support/view/plugin-reviews/woocommerce-google-adwords-conversion-tracking-tag?rate=5#postform', '_blank');
|
10 |
+
win.focus();
|
11 |
+
});
|
12 |
+
|
13 |
+
jQuery(document).on('click', '#already-did', function (e) {
|
14 |
+
process_click(e, 'rating_done');
|
15 |
+
});
|
16 |
+
|
17 |
+
// maybe rate later
|
18 |
+
jQuery(document).on('click', '#maybe-later', function (e) {
|
19 |
+
process_click(e, 'later');
|
20 |
+
});
|
21 |
+
|
22 |
+
function process_click(e, set){
|
23 |
+
|
24 |
+
e.preventDefault();
|
25 |
+
|
26 |
+
let data = {
|
27 |
+
'action': 'wgact_dismissed_notice_handler',
|
28 |
+
'set': set
|
29 |
+
};
|
30 |
+
|
31 |
+
jQuery.post(ajaxurl, data, function(response) {
|
32 |
+
// console.log('Got this from the server: ' + response);
|
33 |
+
// console.log('update rating done');
|
34 |
+
});
|
35 |
+
jQuery('.wgact-rating-success-notice').remove();
|
36 |
+
}
|
37 |
+
|
38 |
+
})();
|
js/admin/helpers.js
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function(){
|
2 |
+
|
3 |
+
// run immediately
|
4 |
+
// might not work if html parsing is not as fast
|
5 |
+
jQuery('#script-blocker-notice').hide();
|
6 |
+
|
7 |
+
// run one mre time after html parsing has been done
|
8 |
+
// in case the first run was not successful
|
9 |
+
jQuery('document').ready(function(){
|
10 |
+
jQuery('#script-blocker-notice').hide();
|
11 |
+
});
|
12 |
+
|
13 |
+
// copy debug info textarea
|
14 |
+
jQuery("#debug-info-button").click(function () {
|
15 |
+
jQuery("#debug-info-textarea").select();
|
16 |
+
document.execCommand('copy');
|
17 |
+
});
|
18 |
+
|
19 |
+
})();
|
20 |
+
|
js/admin/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
js/{admin-tabs.js → admin/tabs.js}
RENAMED
File without changes
|
js/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
js/public/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
languages/woocommerce-google-adwords-conversion-tracking-tag-de_DE.mo
DELETED
Binary file
|
languages/woocommerce-google-adwords-conversion-tracking-tag-de_DE.po
DELETED
@@ -1,93 +0,0 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version: WooCommerce Google AdWords conversion tracking tag\n"
|
4 |
-
"POT-Creation-Date: 2015-07-02 06:51+0200\n"
|
5 |
-
"PO-Revision-Date: 2015-07-02 06:53+0200\n"
|
6 |
-
"Last-Translator: \n"
|
7 |
-
"Language-Team: \n"
|
8 |
-
"Language: de_DE\n"
|
9 |
-
"MIME-Version: 1.0\n"
|
10 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
-
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"X-Generator: Poedit 1.8.2\n"
|
13 |
-
"X-Poedit-Basepath: ..\n"
|
14 |
-
"X-Poedit-WPHeader: wgact.php\n"
|
15 |
-
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
16 |
-
"X-Poedit-SourceCharset: UTF-8\n"
|
17 |
-
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
|
18 |
-
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
|
19 |
-
"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
20 |
-
"X-Poedit-SearchPath-0: .\n"
|
21 |
-
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
22 |
-
|
23 |
-
#: wgact.php:76
|
24 |
-
msgid "Settings"
|
25 |
-
msgstr "Einstellungen"
|
26 |
-
|
27 |
-
#: wgact.php:83
|
28 |
-
msgid "AdWords Conversion Tracking"
|
29 |
-
msgstr "AdWords Konversions-Messung"
|
30 |
-
|
31 |
-
#: wgact.php:100
|
32 |
-
msgid "AdWords Conversion Tracking Settings"
|
33 |
-
msgstr "AdWords Konversions-Messung Einstellungen"
|
34 |
-
|
35 |
-
#: wgact.php:109
|
36 |
-
msgid "Save Changes"
|
37 |
-
msgstr "Änderungen speichern"
|
38 |
-
|
39 |
-
#: wgact.php:121
|
40 |
-
msgid "Donation"
|
41 |
-
msgstr "Spenden"
|
42 |
-
|
43 |
-
#: wgact.php:126
|
44 |
-
msgid "This plugin was developed by"
|
45 |
-
msgstr "Dieses Plugin wurde entwickelt von"
|
46 |
-
|
47 |
-
#: wgact.php:126
|
48 |
-
msgid "Buy me a beer if you like the plugin."
|
49 |
-
msgstr "Kauf mir ein Bier, wenn du das Plugin magst."
|
50 |
-
|
51 |
-
#: wgact.php:127
|
52 |
-
msgid ""
|
53 |
-
"If you want me to continue developing the plugin buy me a few more beers. "
|
54 |
-
"Although, I probably will continue to develop the plugin anyway. It would be "
|
55 |
-
"just much more fun if I had a few beers to celebrate my milestones."
|
56 |
-
msgstr ""
|
57 |
-
"Falls Du möchtest, dass ich das Plugin weiterentwickle kauf mir noch mehr "
|
58 |
-
"Bier. Allerdings werde ich das Plugin so oder so weiterentwickeln. Es wär "
|
59 |
-
"nur schön wenn jeden Meilenstein mit ein paar Bier feiern könnte."
|
60 |
-
|
61 |
-
#: wgact.php:151
|
62 |
-
msgid "Main Settings"
|
63 |
-
msgstr "Haupt-Einstellungen"
|
64 |
-
|
65 |
-
#: wgact.php:152
|
66 |
-
msgid "Conversion ID"
|
67 |
-
msgstr "Konversions ID"
|
68 |
-
|
69 |
-
#: wgact.php:153
|
70 |
-
msgid "Conversion Label"
|
71 |
-
msgstr "Konversions Label"
|
72 |
-
|
73 |
-
#. Plugin Name of the plugin/theme
|
74 |
-
msgid "WooCommerce Google AdWords conversion tracking tag"
|
75 |
-
msgstr ""
|
76 |
-
|
77 |
-
#. Plugin URI of the plugin/theme
|
78 |
-
msgid ""
|
79 |
-
"https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-"
|
80 |
-
"tag/"
|
81 |
-
msgstr ""
|
82 |
-
|
83 |
-
#. Description of the plugin/theme
|
84 |
-
msgid "Google AdWords dynamic conversion value tracking for WooCommerce."
|
85 |
-
msgstr ""
|
86 |
-
|
87 |
-
#. Author of the plugin/theme
|
88 |
-
msgid "Wolf & Bär GmbH"
|
89 |
-
msgstr ""
|
90 |
-
|
91 |
-
#. Author URI of the plugin/theme
|
92 |
-
msgid "http://www.wolfundbaer.ch"
|
93 |
-
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/woocommerce-google-adwords-conversion-tracking-tag-sr_RS.mo
DELETED
Binary file
|
languages/woocommerce-google-adwords-conversion-tracking-tag-sr_RS.po
DELETED
@@ -1,96 +0,0 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version: WooCommerce Google AdWords conversion tracking tag\n"
|
4 |
-
"POT-Creation-Date: 2015-07-02 06:54+0200\n"
|
5 |
-
"PO-Revision-Date: 2015-07-06 09:31+0100\n"
|
6 |
-
"Last-Translator: Borisa Djuraskovic <borisad@webhostinghub.com>\n"
|
7 |
-
"Language-Team: \n"
|
8 |
-
"MIME-Version: 1.0\n"
|
9 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
-
"Content-Transfer-Encoding: 8bit\n"
|
11 |
-
"X-Generator: Poedit 1.7.4\n"
|
12 |
-
"X-Poedit-Basepath: ..\n"
|
13 |
-
"X-Poedit-WPHeader: wgact.php\n"
|
14 |
-
"X-Poedit-SourceCharset: UTF-8\n"
|
15 |
-
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
|
16 |
-
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
|
17 |
-
"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
18 |
-
"Language: sr_RS\n"
|
19 |
-
"X-Poedit-SearchPath-0: .\n"
|
20 |
-
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
21 |
-
|
22 |
-
#: wgact.php:76
|
23 |
-
msgid "Settings"
|
24 |
-
msgstr "Podešavanja"
|
25 |
-
|
26 |
-
#: wgact.php:83
|
27 |
-
msgid "AdWords Conversion Tracking"
|
28 |
-
msgstr "Trakiranje AdWords konverzije"
|
29 |
-
|
30 |
-
#: wgact.php:100
|
31 |
-
msgid "AdWords Conversion Tracking Settings"
|
32 |
-
msgstr "Podešavanja za trakiranje AdWords konverzije"
|
33 |
-
|
34 |
-
#: wgact.php:109
|
35 |
-
msgid "Save Changes"
|
36 |
-
msgstr "Sačuvajte izmene"
|
37 |
-
|
38 |
-
#: wgact.php:121
|
39 |
-
msgid "Donation"
|
40 |
-
msgstr "Donacija"
|
41 |
-
|
42 |
-
#: wgact.php:126
|
43 |
-
msgid "This plugin was developed by"
|
44 |
-
msgstr "Ovaj plugin je razvijen od strane"
|
45 |
-
|
46 |
-
#: wgact.php:126
|
47 |
-
msgid "Buy me a beer if you like the plugin."
|
48 |
-
msgstr "Platite mi pivo ako ti se dopada plugin"
|
49 |
-
|
50 |
-
#: wgact.php:127
|
51 |
-
msgid ""
|
52 |
-
"If you want me to continue developing the plugin buy me a few more beers. "
|
53 |
-
"Although, I probably will continue to develop the plugin anyway. It would be "
|
54 |
-
"just much more fun if I had a few beers to celebrate my milestones."
|
55 |
-
msgstr ""
|
56 |
-
"Ukoliko želite da nastavim da razvijam plugin, platite mi još nekoliko piva. "
|
57 |
-
"Mada ću ja verovatno nastaviti da razvijam plugin u svakom slučaju. Samo bi "
|
58 |
-
"bilo mnogo zabavnije kada bih imao nekoliko piva da proslavim moje "
|
59 |
-
"prekretnice. "
|
60 |
-
|
61 |
-
#: wgact.php:151
|
62 |
-
msgid "Main Settings"
|
63 |
-
msgstr "Glavna podešavanja"
|
64 |
-
|
65 |
-
#: wgact.php:152
|
66 |
-
msgid "Conversion ID"
|
67 |
-
msgstr "ID konverzije"
|
68 |
-
|
69 |
-
#: wgact.php:153
|
70 |
-
msgid "Conversion Label"
|
71 |
-
msgstr "Oznaka konverzije"
|
72 |
-
|
73 |
-
#. Plugin Name of the plugin/theme
|
74 |
-
msgid "WooCommerce Google AdWords conversion tracking tag"
|
75 |
-
msgstr "Tag za trakiranje WooCommerce Google AdWords konverzije"
|
76 |
-
|
77 |
-
#. Plugin URI of the plugin/theme
|
78 |
-
msgid ""
|
79 |
-
"https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-"
|
80 |
-
"tag/"
|
81 |
-
msgstr ""
|
82 |
-
"https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-"
|
83 |
-
"tag/"
|
84 |
-
|
85 |
-
#. Description of the plugin/theme
|
86 |
-
msgid "Google AdWords dynamic conversion value tracking for WooCommerce."
|
87 |
-
msgstr ""
|
88 |
-
"Trakiranje vrednosti dinamičke konverzije Google AdWords-a za WooCommerce."
|
89 |
-
|
90 |
-
#. Author of the plugin/theme
|
91 |
-
msgid "Wolf & Bär GmbH"
|
92 |
-
msgstr "Wolf & Bär GmbH"
|
93 |
-
|
94 |
-
#. Author URI of the plugin/theme
|
95 |
-
msgid "http://www.wolfundbaer.ch"
|
96 |
-
msgstr "http://www.wolfundbaer.ch"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/woocommerce-google-adwords-conversion-tracking-tag.pot
CHANGED
@@ -1,89 +1,257 @@
|
|
1 |
-
|
|
|
2 |
msgid ""
|
3 |
msgstr ""
|
4 |
-
"Project-Id-Version: WooCommerce Google
|
5 |
-
"
|
6 |
-
"
|
7 |
-
"
|
8 |
-
"Language-Team: \n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"
|
13 |
-
"
|
14 |
-
"X-
|
15 |
-
"X-
|
16 |
-
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
|
17 |
-
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
|
18 |
-
"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
19 |
-
"X-Poedit-SearchPath-0: .\n"
|
20 |
-
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
21 |
|
22 |
-
|
23 |
-
msgid "
|
24 |
msgstr ""
|
25 |
|
26 |
-
|
27 |
-
msgid "
|
28 |
msgstr ""
|
29 |
|
30 |
-
|
31 |
-
msgid "
|
32 |
msgstr ""
|
33 |
|
34 |
-
|
35 |
-
msgid "
|
36 |
msgstr ""
|
37 |
|
38 |
-
|
39 |
-
msgid "
|
40 |
msgstr ""
|
41 |
|
42 |
-
#:
|
43 |
-
|
|
|
44 |
msgstr ""
|
45 |
|
46 |
-
#:
|
47 |
-
msgid "
|
48 |
msgstr ""
|
49 |
|
50 |
-
#:
|
51 |
-
msgid ""
|
52 |
-
"If you want me to continue developing the plugin buy me a few more beers. "
|
53 |
-
"Although, I probably will continue to develop the plugin anyway. It would be "
|
54 |
-
"just much more fun if I had a few beers to celebrate my milestones."
|
55 |
msgstr ""
|
56 |
|
57 |
-
#:
|
58 |
-
msgid "
|
59 |
msgstr ""
|
60 |
|
61 |
-
#:
|
62 |
-
msgid "
|
63 |
msgstr ""
|
64 |
|
65 |
-
#:
|
66 |
-
msgid "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
msgstr ""
|
68 |
|
69 |
-
|
70 |
-
msgid "
|
71 |
msgstr ""
|
72 |
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
msgid ""
|
75 |
-
"
|
76 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
msgstr ""
|
78 |
|
79 |
-
|
80 |
-
msgid "
|
81 |
msgstr ""
|
82 |
|
83 |
-
|
84 |
-
msgid "
|
85 |
msgstr ""
|
86 |
|
87 |
-
|
88 |
-
msgid "
|
89 |
msgstr ""
|
1 |
+
# Copyright (C) 2021 Wolf+Bär Agency
|
2 |
+
# This file is distributed under the same license as the WooCommerce Google Ads Conversion Tracking plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: WooCommerce Google Ads Conversion Tracking 1.7.8\n"
|
6 |
+
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/trunk\n"
|
7 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
|
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"POT-Creation-Date: 2021-01-15T05:37:25+00:00\n"
|
13 |
+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
+
"X-Generator: WP-CLI 2.4.0\n"
|
15 |
+
"X-Domain: woocommerce-google-adwords-conversion-tracking-tag\n"
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
#. Plugin Name of the plugin
|
18 |
+
msgid "WooCommerce Google Ads Conversion Tracking"
|
19 |
msgstr ""
|
20 |
|
21 |
+
#. Plugin URI of the plugin
|
22 |
+
msgid "https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-tag/"
|
23 |
msgstr ""
|
24 |
|
25 |
+
#. Description of the plugin
|
26 |
+
msgid "Google Ads dynamic conversion value tracking for WooCommerce."
|
27 |
msgstr ""
|
28 |
|
29 |
+
#. Author of the plugin
|
30 |
+
msgid "Wolf+Bär Agency"
|
31 |
msgstr ""
|
32 |
|
33 |
+
#. Author URI of the plugin
|
34 |
+
msgid "https://wolfundbaer.ch"
|
35 |
msgstr ""
|
36 |
|
37 |
+
#: classes/admin/class-admin.php:64
|
38 |
+
#: classes/admin/class-admin.php:65
|
39 |
+
msgid "Google Ads Conversion Tracking"
|
40 |
msgstr ""
|
41 |
|
42 |
+
#: classes/admin/class-admin.php:132
|
43 |
+
msgid "Conversion ID"
|
44 |
msgstr ""
|
45 |
|
46 |
+
#: classes/admin/class-admin.php:144
|
47 |
+
msgid "Conversion Label"
|
|
|
|
|
|
|
48 |
msgstr ""
|
49 |
|
50 |
+
#: classes/admin/class-admin.php:177
|
51 |
+
msgid "Facebook ID"
|
52 |
msgstr ""
|
53 |
|
54 |
+
#: classes/admin/class-admin.php:235
|
55 |
+
msgid "Order Total Logic"
|
56 |
msgstr ""
|
57 |
|
58 |
+
#: classes/admin/class-admin.php:268
|
59 |
+
msgid "gtag Deactivation"
|
60 |
+
msgstr ""
|
61 |
+
|
62 |
+
#: classes/admin/class-admin.php:291
|
63 |
+
msgid "Beta"
|
64 |
+
msgstr ""
|
65 |
+
|
66 |
+
#: classes/admin/class-admin.php:302
|
67 |
+
msgid "Activation"
|
68 |
msgstr ""
|
69 |
|
70 |
+
#: classes/admin/class-admin.php:314
|
71 |
+
msgid "aw_merchant_id"
|
72 |
msgstr ""
|
73 |
|
74 |
+
#: classes/admin/class-admin.php:326
|
75 |
+
msgid "aw_feed_country"
|
76 |
+
msgstr ""
|
77 |
+
|
78 |
+
#: classes/admin/class-admin.php:338
|
79 |
+
msgid "aw_feed_language"
|
80 |
+
msgstr ""
|
81 |
+
|
82 |
+
#: classes/admin/class-admin.php:350
|
83 |
+
msgid "Product Identifier"
|
84 |
+
msgstr ""
|
85 |
+
|
86 |
+
#: classes/admin/class-admin.php:362
|
87 |
+
msgid "Dynamic Remarketing"
|
88 |
+
msgstr ""
|
89 |
+
|
90 |
+
#: classes/admin/class-admin.php:384
|
91 |
+
msgid "Support"
|
92 |
+
msgstr ""
|
93 |
+
|
94 |
+
#: classes/admin/class-admin.php:402
|
95 |
+
msgid "Author"
|
96 |
+
msgstr ""
|
97 |
+
|
98 |
+
#: classes/admin/class-admin.php:433
|
99 |
msgid ""
|
100 |
+
"It looks like you are using some sort of ad or script blocker which is blocking the script and CSS files of this plugin.\n"
|
101 |
+
" In order for the plugin to work properly you need to disable the script blocker."
|
102 |
+
msgstr ""
|
103 |
+
|
104 |
+
#: classes/admin/class-admin.php:438
|
105 |
+
msgid "Learn more"
|
106 |
+
msgstr ""
|
107 |
+
|
108 |
+
#. translators: 'Wolf+Bär' needs to always stay the same
|
109 |
+
#: classes/admin/class-admin.php:466
|
110 |
+
msgid "Profit Driven Marketing by Wolf+Bär"
|
111 |
+
msgstr ""
|
112 |
+
|
113 |
+
#: classes/admin/class-admin.php:470
|
114 |
+
msgid "Visit us here:"
|
115 |
+
msgstr ""
|
116 |
+
|
117 |
+
#: classes/admin/class-admin.php:504
|
118 |
+
msgid "Find out more about this new feature: "
|
119 |
+
msgstr ""
|
120 |
+
|
121 |
+
#: classes/admin/class-admin.php:506
|
122 |
+
msgid "At the moment we are testing this feature. It might go into a PRO version of this plugin in the future."
|
123 |
+
msgstr ""
|
124 |
+
|
125 |
+
#: classes/admin/class-admin.php:513
|
126 |
+
msgid "Use the following two resources for support: "
|
127 |
+
msgstr ""
|
128 |
+
|
129 |
+
#: classes/admin/class-admin.php:519
|
130 |
+
msgid "Post a support request in the WordPress support forum here: "
|
131 |
+
msgstr ""
|
132 |
+
|
133 |
+
#: classes/admin/class-admin.php:522
|
134 |
+
msgid "Support forum"
|
135 |
+
msgstr ""
|
136 |
+
|
137 |
+
#: classes/admin/class-admin.php:526
|
138 |
+
msgid "Or send us an email to the following address: "
|
139 |
+
msgstr ""
|
140 |
+
|
141 |
+
#: classes/admin/class-admin.php:536
|
142 |
+
msgid "copy to clipboard"
|
143 |
+
msgstr ""
|
144 |
+
|
145 |
+
#: classes/admin/class-admin.php:547
|
146 |
+
msgid "More details about the developer of this plugin: "
|
147 |
+
msgstr ""
|
148 |
+
|
149 |
+
#. translators: 'Wolf+Bär' needs to always stay the same, while 'Agency' can be translated
|
150 |
+
#: classes/admin/class-admin.php:552
|
151 |
+
msgid "Developer: Wolf+Bär Agency"
|
152 |
+
msgstr ""
|
153 |
+
|
154 |
+
#: classes/admin/class-admin.php:555
|
155 |
+
msgid "Website: "
|
156 |
+
msgstr ""
|
157 |
+
|
158 |
+
#: classes/admin/class-admin.php:695
|
159 |
+
msgid "The conversion ID looks similar to this:"
|
160 |
+
msgstr ""
|
161 |
+
|
162 |
+
#: classes/admin/class-admin.php:703
|
163 |
+
msgid "The conversion Label looks similar to this:"
|
164 |
+
msgstr ""
|
165 |
+
|
166 |
+
#: classes/admin/class-admin.php:710
|
167 |
+
msgid "Use order_subtotal: Doesn't include tax and shipping (default)"
|
168 |
+
msgstr ""
|
169 |
+
|
170 |
+
#: classes/admin/class-admin.php:713
|
171 |
+
msgid "Use order_total: Includes tax and shipping"
|
172 |
+
msgstr ""
|
173 |
+
|
174 |
+
#: classes/admin/class-admin.php:715
|
175 |
+
msgid "This is the order total amount reported back to Google Ads"
|
176 |
+
msgstr ""
|
177 |
+
|
178 |
+
#: classes/admin/class-admin.php:723
|
179 |
+
msgid "open the documentation"
|
180 |
+
msgstr ""
|
181 |
+
|
182 |
+
#: classes/admin/class-admin.php:738
|
183 |
+
msgid "Disable gtag.js insertion if another plugin is inserting it already."
|
184 |
+
msgstr ""
|
185 |
+
|
186 |
+
#: classes/admin/class-admin.php:750
|
187 |
+
msgid "Add the cart data to the conversion event"
|
188 |
+
msgstr ""
|
189 |
+
|
190 |
+
#: classes/admin/class-admin.php:763
|
191 |
+
msgid "Enable dynamic remarketing audience collection"
|
192 |
+
msgstr ""
|
193 |
+
|
194 |
+
#: classes/admin/class-admin.php:766
|
195 |
+
msgid "You need to choose the correct product identifier setting in order to match the product identifiers in the Google Merchant Center or your Google Ads business feed."
|
196 |
+
msgstr ""
|
197 |
+
|
198 |
+
#: classes/admin/class-admin.php:776
|
199 |
+
msgid "Enter the ID of your Google Merchant Center account."
|
200 |
+
msgstr ""
|
201 |
+
|
202 |
+
#: classes/admin/class-admin.php:791
|
203 |
+
msgid "Currently the plugin automatically detects the location of the visitor for this setting. In most, if not all, cases this will work fine. Please let us know if you have a use case where you need another output:"
|
204 |
+
msgstr ""
|
205 |
+
|
206 |
+
#: classes/admin/class-admin.php:823
|
207 |
+
msgid "The plugin will use the WordPress default language for this setting. If the shop uses translations, in theory we could also use the visitors locale. But, if that language is not set up in the Google Merchant Center we might run into issues. If you need more options here let us know:"
|
208 |
+
msgstr ""
|
209 |
+
|
210 |
+
#: classes/admin/class-admin.php:838
|
211 |
+
msgid "post id (default)"
|
212 |
+
msgstr ""
|
213 |
+
|
214 |
+
#: classes/admin/class-admin.php:843
|
215 |
+
msgid "post id with woocommerce_gpf_ prefix *"
|
216 |
+
msgstr ""
|
217 |
+
|
218 |
+
#: classes/admin/class-admin.php:848
|
219 |
+
msgid "SKU"
|
220 |
+
msgstr ""
|
221 |
+
|
222 |
+
#: classes/admin/class-admin.php:851
|
223 |
+
msgid "Choose a product identifier."
|
224 |
+
msgstr ""
|
225 |
+
|
226 |
+
#: classes/admin/class-admin.php:853
|
227 |
+
msgid "* This is for users of the WooCommerce Google Product Feed Plugin"
|
228 |
+
msgstr ""
|
229 |
+
|
230 |
+
#: classes/admin/class-admin.php:867
|
231 |
+
msgid "You have entered an invalid conversion id. It only contains 8 to 10 digits."
|
232 |
+
msgstr ""
|
233 |
+
|
234 |
+
#: classes/admin/class-admin.php:875
|
235 |
+
msgid "You have entered an invalid conversion label."
|
236 |
+
msgstr ""
|
237 |
+
|
238 |
+
#: classes/admin/class-admin.php:883
|
239 |
+
msgid "You have entered an invalid merchant id. It only contains 8 to 10 digits."
|
240 |
+
msgstr ""
|
241 |
+
|
242 |
+
#. translators: %d: the amount of purchase conversions that have been measured
|
243 |
+
#: classes/admin/class-ask-for-rating.php:119
|
244 |
+
msgid "Hey, I noticed that you tracked more than %d purchase conversions with the Google Ads Conversion Tracking plugin - that's awesome! Could you please do me a BIG favour and give it a 5-star rating on WordPress? Just to help us spread the word and boost our motivation."
|
245 |
msgstr ""
|
246 |
|
247 |
+
#: classes/admin/class-ask-for-rating.php:133
|
248 |
+
msgid "Ok, you deserve it"
|
249 |
msgstr ""
|
250 |
|
251 |
+
#: classes/admin/class-ask-for-rating.php:138
|
252 |
+
msgid "Nope, maybe later"
|
253 |
msgstr ""
|
254 |
|
255 |
+
#: classes/admin/class-ask-for-rating.php:143
|
256 |
+
msgid "I already did"
|
257 |
msgstr ""
|
lib/autoload.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// https://github.com/tommcfarlin/simple-autoloader-for-wordpress/
|
4 |
+
// class names need to be
|
5 |
+
// class-something.php
|
6 |
+
// not
|
7 |
+
// class-some-thing.php
|
8 |
+
// namespaces must reflect the folder structure exactly
|
9 |
+
spl_autoload_register(function( $filename ) {
|
10 |
+
|
11 |
+
// if (strpos($filename, 'WGACT') !== false) {
|
12 |
+
// error_log('filename: ' . $filename);
|
13 |
+
//
|
14 |
+
// }
|
15 |
+
|
16 |
+
// First, separate the components of the incoming file.
|
17 |
+
$file_path = explode( '\\', $filename );
|
18 |
+
|
19 |
+
/**
|
20 |
+
* - The first index will always be the namespace since it's part of the plugin.
|
21 |
+
* - All but the last index will be the path to the file.
|
22 |
+
* - The final index will be the filename. If it doesn't begin with 'I' then it's a class.
|
23 |
+
*/
|
24 |
+
|
25 |
+
// Get the last index of the array. This is the class we're loading.
|
26 |
+
$file_name = '';
|
27 |
+
if ( isset( $file_path[ count( $file_path ) - 1 ] ) ) {
|
28 |
+
|
29 |
+
$file_name = strtolower(
|
30 |
+
$file_path[ count( $file_path ) - 1 ]
|
31 |
+
);
|
32 |
+
|
33 |
+
$file_name = str_ireplace( '_', '-', $file_name );
|
34 |
+
$file_name_parts = explode( '-', $file_name );
|
35 |
+
|
36 |
+
// Interface support: handle both Interface_Foo or Foo_Interface.
|
37 |
+
$index = array_search( 'interface', $file_name_parts );
|
38 |
+
|
39 |
+
if ( false !== $index ) {
|
40 |
+
// Remove the 'interface' part.
|
41 |
+
unset( $file_name_parts[ $index ] );
|
42 |
+
|
43 |
+
// Rebuild the file name.
|
44 |
+
$file_name = implode( '-', $file_name_parts );
|
45 |
+
|
46 |
+
$file_name = "interface-{$file_name}.php";
|
47 |
+
} else {
|
48 |
+
$file_name = "class-$file_name.php";
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Find the fully qualified path to the class file by iterating through the $file_path array.
|
54 |
+
* We ignore the first index since it's always the top-level package. The last index is always
|
55 |
+
* the file so we append that at the end.
|
56 |
+
*/
|
57 |
+
$fully_qualified_path = trailingslashit(
|
58 |
+
dirname(
|
59 |
+
dirname( __FILE__ )
|
60 |
+
)
|
61 |
+
);
|
62 |
+
|
63 |
+
for ( $i = 1; $i < count( $file_path ) - 1; $i++ ) {
|
64 |
+
|
65 |
+
$dir = strtolower( $file_path[ $i ] );
|
66 |
+
$fully_qualified_path .= trailingslashit( $dir );
|
67 |
+
}
|
68 |
+
$fully_qualified_path .= $file_name;
|
69 |
+
|
70 |
+
// if (strpos($filename, 'WGACT') !== false) {
|
71 |
+
// error_log('fully qualified path: ' . $fully_qualified_path);
|
72 |
+
//
|
73 |
+
// }
|
74 |
+
|
75 |
+
|
76 |
+
|
77 |
+
// Now include the file.
|
78 |
+
if ( stream_resolve_include_path($fully_qualified_path) ) {
|
79 |
+
include_once $fully_qualified_path;
|
80 |
+
}
|
81 |
+
});
|
lib/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
readme.txt
CHANGED
@@ -1,31 +1,27 @@
|
|
1 |
=== Plugin Name ===
|
2 |
-
Contributors: alekv
|
3 |
-
Tags: woocommerce, google ads,
|
4 |
Requires at least: 3.7
|
5 |
Tested up to: 5.6
|
6 |
-
|
|
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
-
Track the
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
-
This plugin <strong>tracks the value of WooCommerce orders in Google Ads</strong>.
|
15 |
|
16 |
-
With this you can optimize all your Google Ads campaigns to achieve maximum efficiency.
|
17 |
|
18 |
<strong>Highlights</strong>
|
19 |
|
20 |
* Precise measurement by preventing duplicate reporting effectively, excluding admins and shop managers from tracking, and not counting failed payments.
|
21 |
-
*
|
22 |
* Implements the new Google Add Cart Data functionality. More info about the new feature: [add cart data to the conversion](https://support.google.com/google-ads/answer/9028254)
|
23 |
* Support for various cookie consent management systems
|
24 |
-
* [Cookie Notice](https://wordpress.org/plugins/cookie-notice/)
|
25 |
-
* [Cookie Law Info](https://wordpress.org/plugins/cookie-law-info/)
|
26 |
-
* [GDPR Cookie Compliance](https://wordpress.org/plugins/gdpr-cookie-compliance/)
|
27 |
-
* [Borlabs Cookie](https://borlabs.io/borlabs-cookie/) (from version 2.1.0)
|
28 |
-
[Borlabs Cookie Setup](https://wolfundbaer.ch/en/blog/our-marketing-plugins-now-support-borlabs-cookie/)
|
29 |
|
30 |
<strong>Documentation</strong>
|
31 |
|
@@ -35,7 +31,7 @@ Link to the full documentation of the plugin: [Open the documentation](https://d
|
|
35 |
|
36 |
The plugin uses data from several Cookie Consent Management plugins to manage approvals and disapprovals for injection of marketing pixels.
|
37 |
|
38 |
-
It works with the following Cookie Consent Management plugins:
|
39 |
|
40 |
* [Cookie Notice](https://wordpress.org/plugins/cookie-notice/)
|
41 |
* [Cookie Law Info](https://wordpress.org/plugins/cookie-law-info/)
|
@@ -43,7 +39,7 @@ It works with the following Cookie Consent Management plugins:
|
|
43 |
* [Borlabs Cookie](https://borlabs.io/borlabs-cookie/) (from version 2.1.0)
|
44 |
[Borlabs Cookie Setup](https://wolfundbaer.ch/en/blog/our-marketing-plugins-now-support-borlabs-cookie/)
|
45 |
|
46 |
-
It is also possible for developers of Cookie Consent Management plugins to deactivate
|
47 |
|
48 |
`add_filter( 'wgact_cookie_prevention', '__return_true' );`
|
49 |
|
@@ -66,11 +62,12 @@ Yes. Head over to this link: [Documentation](https://docs.wolfundbaer.ch/wgact/#
|
|
66 |
|
67 |
= How do I check if the plugin is working properly? =
|
68 |
|
69 |
-
1.
|
70 |
-
2.
|
71 |
-
3.
|
72 |
-
4.
|
73 |
-
5.
|
|
|
74 |
|
75 |
With the Google Tag Assistant you will also be able to see the tag fired on the thankyou page.
|
76 |
|
@@ -89,16 +86,114 @@ Here is a non-exhaustive list of causes that might interfere with the plugin cod
|
|
89 |
* Minification plugins try to minify the JavaScript code of the plugin. Not all minification plugins do this good enough and can cause problems. Turn off the JavaScript minification and try again.
|
90 |
* Caching could also cause problems if caching is set too aggressively. Generally don't ever enable HTML caching on a WooCommerce shop, as it can cause troubles with plugins that generate dynamic output.
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
= Where can I report a bug or suggest improvements? =
|
93 |
|
94 |
Please post your problem in the WGACT Support forum: http://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag
|
95 |
You can send the link to the front page of your shop too if you think it would be of help.
|
96 |
|
97 |
== Screenshots ==
|
|
|
98 |
1. Settings page
|
99 |
|
100 |
== Changelog ==
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
= 1.6.17 =
|
103 |
|
104 |
* Tweak: Reactivate freemius
|
1 |
=== Plugin Name ===
|
2 |
+
Contributors: alekv, wolfbaer, woopt
|
3 |
+
Tags: woocommerce, google ads, conversion tracking, dynamic retargeting, remarketing , adwords
|
4 |
Requires at least: 3.7
|
5 |
Tested up to: 5.6
|
6 |
+
Requires PHP: 7.2
|
7 |
+
Stable tag: 1.7.13
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
+
Track the order value and create dynamic remarketing lists in Google Ads from WooCommerce
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
This plugin <strong>tracks the value of WooCommerce orders and collects data for dynamic remarketing lists in Google Ads</strong>.
|
16 |
|
17 |
+
With this data you can optimize all your Google Ads campaigns to achieve maximum efficiency.
|
18 |
|
19 |
<strong>Highlights</strong>
|
20 |
|
21 |
* Precise measurement by preventing duplicate reporting effectively, excluding admins and shop managers from tracking, and not counting failed payments.
|
22 |
+
* Collects dynamic remarketing audiences for dynamic retargeting: [Google Ads Dynamic Remarketing](https://support.google.com/google-ads/answer/3124536)
|
23 |
* Implements the new Google Add Cart Data functionality. More info about the new feature: [add cart data to the conversion](https://support.google.com/google-ads/answer/9028254)
|
24 |
* Support for various cookie consent management systems
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
<strong>Documentation</strong>
|
27 |
|
31 |
|
32 |
The plugin uses data from several Cookie Consent Management plugins to manage approvals and disapprovals for injection of marketing pixels.
|
33 |
|
34 |
+
It works with the following Cookie Consent Management plugins out of the box:
|
35 |
|
36 |
* [Cookie Notice](https://wordpress.org/plugins/cookie-notice/)
|
37 |
* [Cookie Law Info](https://wordpress.org/plugins/cookie-law-info/)
|
39 |
* [Borlabs Cookie](https://borlabs.io/borlabs-cookie/) (from version 2.1.0)
|
40 |
[Borlabs Cookie Setup](https://wolfundbaer.ch/en/blog/our-marketing-plugins-now-support-borlabs-cookie/)
|
41 |
|
42 |
+
It is also possible for developers of Cookie Consent Management plugins to deactivate the pixel injection with a filter:
|
43 |
|
44 |
`add_filter( 'wgact_cookie_prevention', '__return_true' );`
|
45 |
|
62 |
|
63 |
= How do I check if the plugin is working properly? =
|
64 |
|
65 |
+
1. Turn off any kind of caching and / or minification plugins.
|
66 |
+
2. Log out of the shop.
|
67 |
+
3. Turn off any kind of ad or script blocker in your browser.
|
68 |
+
4. Search for one of your keywords and click on one of your ads.
|
69 |
+
5. Purchase an item from your shop.
|
70 |
+
6. Wait up to 48 hours until the conversion shows up in Google Ads. (usually takes only a few hours)
|
71 |
|
72 |
With the Google Tag Assistant you will also be able to see the tag fired on the thankyou page.
|
73 |
|
86 |
* Minification plugins try to minify the JavaScript code of the plugin. Not all minification plugins do this good enough and can cause problems. Turn off the JavaScript minification and try again.
|
87 |
* Caching could also cause problems if caching is set too aggressively. Generally don't ever enable HTML caching on a WooCommerce shop, as it can cause troubles with plugins that generate dynamic output.
|
88 |
|
89 |
+
= I see issues in the backend of my shop. Admin pages get rendered weird, and popups don't go away when I click to close them. How can I fix this? =
|
90 |
+
|
91 |
+
You probably have some script or ad blocker activated. Deactivate it and the issues should go away. Usually you can disable the blocker for just that particular site (your WooCommerce back end).
|
92 |
+
|
93 |
+
Our plugin injects tracking pixels on the front end of WooCommerce shops. As a consequence scripts of our plugin have been added to some privacy filter lists. The idea is to prevent the scripts running if a shop visitor has some ad blocker enabled and wants to visit the front end of the shop. This is totally ok for visitors of the front end of the shop. But, it becomes an issue for admins of the shop who have a blocker activated in their browser and visit the backend of the shop.
|
94 |
+
|
95 |
+
Unfortunately there is no way for us to generally approve our scripts in all blockers for the WooCommerce back end.
|
96 |
+
|
97 |
+
Therefore we recommend admins of the shop to exclude their own shop from the blocker in their browser.
|
98 |
+
|
99 |
= Where can I report a bug or suggest improvements? =
|
100 |
|
101 |
Please post your problem in the WGACT Support forum: http://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag
|
102 |
You can send the link to the front page of your shop too if you think it would be of help.
|
103 |
|
104 |
== Screenshots ==
|
105 |
+
|
106 |
1. Settings page
|
107 |
|
108 |
== Changelog ==
|
109 |
|
110 |
+
= 1.7.13 =
|
111 |
+
|
112 |
+
* New: Facebook pixel
|
113 |
+
* Tweak: Adjust db and bump up to version 3
|
114 |
+
* Tweak: Introduced Pixel_Manager and restructured Google Ads class
|
115 |
+
|
116 |
+
= 1.7.12 =
|
117 |
+
|
118 |
+
* Fix: Removed namespace for main class because it was conflicting with freemius in some cases
|
119 |
+
|
120 |
+
= 1.7.11 =
|
121 |
+
|
122 |
+
* Fix: Directory name fix
|
123 |
+
* New: Warning message if an ad- or script-blocker is active
|
124 |
+
* Tweak: Improved one of the db saving functions
|
125 |
+
* Tweak: Start using namespaces
|
126 |
+
|
127 |
+
|
128 |
+
= 1.7.10 =
|
129 |
+
|
130 |
+
* Fix: child theme detection
|
131 |
+
|
132 |
+
= 1.7.9 =
|
133 |
+
|
134 |
+
* Fix: Roll back to 1.7.7 since namespace don't work everywhere
|
135 |
+
* Fix: child theme detection
|
136 |
+
|
137 |
+
= 1.7.8 =
|
138 |
+
|
139 |
+
* New: Warning message if an ad- or script-blocker is active
|
140 |
+
* Tweak: Improved one of the db saving functions
|
141 |
+
* Tweak: Start using namespaces
|
142 |
+
|
143 |
+
= 1.7.7 =
|
144 |
+
|
145 |
+
* Fix: Don't show the rating popup if an admin uses a script blocker
|
146 |
+
|
147 |
+
= 1.7.6 =
|
148 |
+
|
149 |
+
* Fix: Improved check if dynamic remarketing settings already has been set before checking for it.
|
150 |
+
* Fix: Saving to the database threw sometimes warnings that have been fixed.
|
151 |
+
* Tweak: Styling changes
|
152 |
+
|
153 |
+
= 1.7.5 =
|
154 |
+
|
155 |
+
* New: Added checks for freemius servers
|
156 |
+
* New: Dynamic remarketing pixels
|
157 |
+
* New: Deactivation trigger for the WGDR plugin if dynamic remarketing is enabled
|
158 |
+
* Fix: Adjusted the cookie name for Cookie Law Info
|
159 |
+
* Fix: Improved detection if WooCommerce is active on multisite
|
160 |
+
* Fix: Fixed default setting for conversion_id
|
161 |
+
* Tweak: Added back rating testing code
|
162 |
+
* Tweak: Adjusted some links
|
163 |
+
* Tweak: Code style cleanups
|
164 |
+
|
165 |
+
= 1.7.4 =
|
166 |
+
|
167 |
+
* Fix: Fixed the ask for rating constant
|
168 |
+
|
169 |
+
= 1.7.3 =
|
170 |
+
|
171 |
+
* Fix: Don't open the rating page if user clicks on already done
|
172 |
+
* Tweak: Backward compatibility to PHP 7.0
|
173 |
+
|
174 |
+
= 1.7.2 =
|
175 |
+
|
176 |
+
* Fix: Fixed a printf syntax error that caused issues on some installations
|
177 |
+
|
178 |
+
= 1.7.1 =
|
179 |
+
|
180 |
+
* Tweak: Removed deletion of settings on uninstall in order to preserve the settings
|
181 |
+
|
182 |
+
= 1.7.0 =
|
183 |
+
|
184 |
+
* New: Added German translations
|
185 |
+
* Fix: Reversed some code in freemius to make it compatible with older versions of PHP (< PHP 7.2)
|
186 |
+
* Fix: Fixed the uninstall hook for it to work with freemius
|
187 |
+
* Tweak: Added some comments for translators
|
188 |
+
* Tweak: Removed old language packs
|
189 |
+
* Tweak: Add gtag config if gtag insertion is disabled
|
190 |
+
* Tweak: Rating request improved
|
191 |
+
* Tweak: Removed plugin ads
|
192 |
+
* Tweak: Added documentation
|
193 |
+
* Tweak: Updated db scheme
|
194 |
+
* Tweak: Merge new default options recursively
|
195 |
+
* Tweak: On save merge new and old options recursively, set missing checkbox options to zero, omit db_version
|
196 |
+
|
197 |
= 1.6.17 =
|
198 |
|
199 |
* Tweak: Reactivate freemius
|
uninstall.php
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Uninstall routine for the WGACT plugin
|
4 |
-
*/
|
5 |
-
|
6 |
-
// If uninstall is not called from WordPress, exit
|
7 |
-
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
8 |
-
exit();
|
9 |
-
}
|
10 |
-
|
11 |
-
$option_name_1 = 'wgact_plugin_options_1';
|
12 |
-
$option_name_2 = 'wgact_plugin_options_2';
|
13 |
-
$option_name_3 = 'wgact_plugin_options';
|
14 |
-
|
15 |
-
|
16 |
-
delete_option( $option_name_1 );
|
17 |
-
delete_option( $option_name_2 );
|
18 |
-
delete_option( $option_name_3 );
|
19 |
-
|
20 |
-
// For site options in Multisite
|
21 |
-
delete_site_option( $option_name_1 );
|
22 |
-
delete_site_option( $option_name_2 );
|
23 |
-
delete_site_option( $option_name_3 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wgact.php
CHANGED
@@ -5,210 +5,252 @@
|
|
5 |
* Author: Wolf+Bär Agency
|
6 |
* Plugin URI: https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-tag/
|
7 |
* Author URI: https://wolfundbaer.ch
|
8 |
-
* Version: 1.
|
9 |
* License: GPLv2 or later
|
10 |
* Text Domain: woocommerce-google-adwords-conversion-tracking-tag
|
11 |
* WC requires at least: 2.6
|
12 |
-
* WC tested up to: 4.
|
13 |
**/
|
14 |
|
15 |
-
// TODO in case Google starts to use alphabetic characters in the conversion ID, output the conversion ID with ''
|
16 |
// TODO give users choice to use content or footer based code insertion
|
17 |
-
// TODO only run if WooCommerce is active
|
18 |
// TODO make this class a singleton
|
19 |
// TODO don't run if minimum versions of PHP, WordPress and WooCommerce are not met, and issue a warning notification
|
20 |
-
// TODO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
|
23 |
if (!defined('ABSPATH')) {
|
24 |
-
|
25 |
}
|
26 |
|
27 |
-
if (
|
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 |
-
public function __construct()
|
81 |
-
{
|
82 |
-
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
|
83 |
-
|
84 |
-
if ( is_admin() ) {
|
85 |
-
$plugin_data = get_file_data( __FILE__, [ 'Version' => 'Version' ], false );
|
86 |
-
$plugin_version = $plugin_data['Version'];
|
87 |
-
define( 'WGACT_CURRENT_VERSION', $plugin_version );
|
88 |
-
}
|
89 |
-
|
90 |
-
// preparing the DB check and upgrade routine
|
91 |
-
require_once plugin_dir_path( __FILE__ ) . 'includes/class-db-upgrade.php';
|
92 |
-
|
93 |
-
// running the DB updater
|
94 |
-
( new WgactDbUpgrade )->run_options_db_upgrade();
|
95 |
-
|
96 |
-
// $this->runCookieConsentManagement();
|
97 |
-
|
98 |
-
// run the following function after_setup_theme in order to allow
|
99 |
-
// the cookie_prevention filter to be used in functions.php
|
100 |
-
// https://stackoverflow.com/a/19279650
|
101 |
-
add_action( 'after_setup_theme', [ $this, 'runCookieConsentManagement' ] );
|
102 |
-
}
|
103 |
-
}
|
104 |
-
|
105 |
-
public function runCookieConsentManagement()
|
106 |
-
{
|
107 |
-
|
108 |
-
require_once plugin_dir_path(__FILE__) . 'includes/class-cookie-consent-management.php';
|
109 |
-
|
110 |
-
// load the cookie consent management functions
|
111 |
-
$cookie_consent = new WgactCookieConsentManagement();
|
112 |
-
$cookie_consent->setPluginPrefix(self::PLUGIN_PREFIX);
|
113 |
-
|
114 |
-
// check if third party cookie prevention has been requested
|
115 |
-
// if not, run the plugin
|
116 |
-
if ($cookie_consent->is_cookie_prevention_active() == false) {
|
117 |
-
|
118 |
-
// startup main plugin functions
|
119 |
-
$this->init();
|
120 |
-
|
121 |
-
} else {
|
122 |
-
// error_log('third party cookie prevention active');
|
123 |
-
}
|
124 |
-
}
|
125 |
-
|
126 |
-
// startup all functions
|
127 |
-
public function init()
|
128 |
-
{
|
129 |
-
|
130 |
-
// load the options
|
131 |
-
$this->wgact_options_init();
|
132 |
|
133 |
-
require_once plugin_dir_path(__FILE__) . 'includes/class-ask-for-rating.php';
|
134 |
-
require_once plugin_dir_path(__FILE__) . 'includes/class-gtag.php';
|
135 |
-
require_once plugin_dir_path(__FILE__) . 'includes/class-pixel.php';
|
136 |
-
require_once plugin_dir_path(__FILE__) . 'admin/class-admin.php';
|
137 |
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
// ask visitor for rating
|
142 |
-
(new WgactAskForRating)->init();
|
143 |
-
|
144 |
-
// add the Google Ads tag to the thankyou part of the page within the body tags
|
145 |
-
add_action('wp_head', function(){
|
146 |
-
(new WgactPixel)->GoogleAdsTag();
|
147 |
-
});
|
148 |
-
|
149 |
-
// add a settings link on the plugins page
|
150 |
-
add_filter('plugin_action_links_' . plugin_basename(__FILE__), [$this, 'wgact_settings_link']);
|
151 |
-
}
|
152 |
-
|
153 |
-
// initialise the options
|
154 |
-
private function wgact_options_init()
|
155 |
-
{
|
156 |
-
|
157 |
-
// set options equal to defaults
|
158 |
-
global $wgact_plugin_options;
|
159 |
-
$wgact_plugin_options = get_option('wgact_plugin_options');
|
160 |
-
|
161 |
-
if (false === $wgact_plugin_options) {
|
162 |
-
|
163 |
-
$wgact_plugin_options = $this->wgact_get_default_options();
|
164 |
-
update_option('wgact_plugin_options', $wgact_plugin_options);
|
165 |
-
|
166 |
-
} else { // Check if each single option has been set. If not, set them. That is necessary when new options are introduced.
|
167 |
-
|
168 |
-
// get default plugins options
|
169 |
-
$wgact_default_plugin_options = $this->wgact_get_default_options();
|
170 |
-
|
171 |
-
// go through all default options an find out if the key has been set in the current options already
|
172 |
-
foreach ($wgact_default_plugin_options as $key => $value) {
|
173 |
-
|
174 |
-
// Test if the key has been set in the options already
|
175 |
-
if (!array_key_exists($key, $wgact_plugin_options)) {
|
176 |
-
|
177 |
-
// set the default key and value in the options table
|
178 |
-
$wgact_plugin_options[$key] = $value;
|
179 |
-
|
180 |
-
// update the options table with the new key
|
181 |
-
update_option('wgact_plugin_options', $wgact_plugin_options);
|
182 |
-
|
183 |
-
}
|
184 |
-
}
|
185 |
-
}
|
186 |
-
}
|
187 |
-
|
188 |
-
// get the default options
|
189 |
-
private function wgact_get_default_options()
|
190 |
-
{
|
191 |
-
// default options settings
|
192 |
-
$options = [
|
193 |
-
'conversion_id' => '',
|
194 |
-
'conversion_label' => '',
|
195 |
-
'order_total_logic' => 0,
|
196 |
-
'gtag_deactivation' => 0,
|
197 |
-
'add_cart_data' => 0,
|
198 |
-
'aw_merchant_id' => '',
|
199 |
-
'product_identifier' => 0,
|
200 |
-
];
|
201 |
-
|
202 |
-
return $options;
|
203 |
-
}
|
204 |
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
$
|
210 |
-
|
211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
}
|
213 |
|
214 |
-
|
5 |
* Author: Wolf+Bär Agency
|
6 |
* Plugin URI: https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-tag/
|
7 |
* Author URI: https://wolfundbaer.ch
|
8 |
+
* Version: 1.7.13
|
9 |
* License: GPLv2 or later
|
10 |
* Text Domain: woocommerce-google-adwords-conversion-tracking-tag
|
11 |
* WC requires at least: 2.6
|
12 |
+
* WC tested up to: 4.9
|
13 |
**/
|
14 |
|
|
|
15 |
// TODO give users choice to use content or footer based code insertion
|
|
|
16 |
// TODO make this class a singleton
|
17 |
// TODO don't run if minimum versions of PHP, WordPress and WooCommerce are not met, and issue a warning notification
|
18 |
+
// TODO export settings function
|
19 |
+
// TODO add option checkbox on uninstall and ask if user wants to delete options from db
|
20 |
+
// TODO ask inverse cookie approval. Only of cookies have been allowed, fire the pixels.
|
21 |
+
// TODO force init gtag if it was deactivated but not initialized in the correct sequence on the website
|
22 |
+
// TODO remove google_business_vertical cleanup
|
23 |
+
|
24 |
+
|
25 |
+
use WGACT\Classes\Admin\Admin;
|
26 |
+
use WGACT\Classes\Admin\Ask_For_Rating;
|
27 |
+
use WGACT\Classes\Db_Upgrade;
|
28 |
+
use WGACT\Classes\Pixels\Cookie_Consent_Management;
|
29 |
+
use WGACT\Classes\Pixels\Google;
|
30 |
+
use WGACT\Classes\Pixels\Pixel_Manager;
|
31 |
|
32 |
|
33 |
if (!defined('ABSPATH')) {
|
34 |
+
exit; // Exit if accessed directly
|
35 |
}
|
36 |
|
37 |
+
if (!function_exists('wga_fs')) {
|
38 |
+
// Create a helper function for easy SDK access.
|
39 |
+
function wga_fs()
|
40 |
+
{
|
41 |
+
global $wga_fs;
|
42 |
+
|
43 |
+
if (!isset($wga_fs)) {
|
44 |
+
// Include Freemius SDK.
|
45 |
+
require_once dirname(__FILE__) . '/freemius/start.php';
|
46 |
+
|
47 |
+
$wga_fs = fs_dynamic_init([
|
48 |
+
'id' => '7498',
|
49 |
+
'slug' => 'woocommerce-google-adwords-conversion-tracking-tag',
|
50 |
+
'premium_slug' => 'wgact-premium',
|
51 |
+
'type' => 'plugin',
|
52 |
+
'public_key' => 'pk_d4182c5e1dc92c6032e59abbfdb91',
|
53 |
+
'is_premium' => false,
|
54 |
+
'has_addons' => false,
|
55 |
+
'has_paid_plans' => false,
|
56 |
+
'menu' => [
|
57 |
+
'slug' => 'wgact',
|
58 |
+
'override_exact' => true,
|
59 |
+
'account' => false,
|
60 |
+
'contact' => false,
|
61 |
+
'support' => false,
|
62 |
+
'parent' => [
|
63 |
+
'slug' => 'woocommerce',
|
64 |
+
],
|
65 |
+
],
|
66 |
+
]);
|
67 |
+
}
|
68 |
+
|
69 |
+
return $wga_fs;
|
70 |
+
}
|
71 |
+
|
72 |
+
// Init Freemius.
|
73 |
+
wga_fs();
|
74 |
+
// Signal that SDK was initiated.
|
75 |
+
do_action('wga_fs_loaded');
|
76 |
+
|
77 |
+
function wga_fs_settings_url()
|
78 |
+
{
|
79 |
+
return admin_url('admin.php?page=wgact§ion=main&subsection=google-ads');
|
80 |
+
}
|
81 |
+
|
82 |
+
wga_fs()->add_filter('connect_url', 'wga_fs_settings_url');
|
83 |
+
wga_fs()->add_filter('after_skip_url', 'wga_fs_settings_url');
|
84 |
+
wga_fs()->add_filter('after_connect_url', 'wga_fs_settings_url');
|
85 |
+
wga_fs()->add_filter('after_pending_connect_url', 'wga_fs_settings_url');
|
86 |
}
|
87 |
|
88 |
+
define('WGACT_PLUGIN_PREFIX', 'wgact_');
|
89 |
+
define('WGACT_DB_VERSION', '3');
|
90 |
+
define('WGACT_DB_OPTIONS_NAME', 'wgact_plugin_options');
|
91 |
+
define('WGACT_DB_RATINGS', 'wgact_ratings');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
|
|
|
|
|
|
|
|
93 |
|
94 |
+
class WGACT
|
95 |
+
{
|
96 |
+
protected $options;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
+
public function __construct()
|
99 |
+
{
|
100 |
+
|
101 |
+
// $options = get_option(WGACT_DB_OPTIONS_NAME);
|
102 |
+
// error_log(print_r($options, true));
|
103 |
+
// $options['gads']['google_business_vertical'] = 'retail';
|
104 |
+
// $options['google_business_vertical'] = 'XX';
|
105 |
+
|
106 |
+
// $options['woopt'] = [];
|
107 |
+
// $options['woopt']['existing'] = true;
|
108 |
+
// $options['db_version'] = '2';
|
109 |
+
// unset($options['2']);
|
110 |
+
// update_option(WGACT_DB_OPTIONS_NAME, $options);
|
111 |
+
|
112 |
+
// $options = get_option('wgact_options_backup');
|
113 |
+
// error_log(print_r($options, true));
|
114 |
+
|
115 |
+
|
116 |
+
// check if WooCommerce is running
|
117 |
+
// currently this is the most reliable test for single and multisite setups
|
118 |
+
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
119 |
+
if (is_plugin_active('woocommerce/woocommerce.php')) {
|
120 |
+
|
121 |
+
// autoloader
|
122 |
+
require_once 'lib/autoload.php';
|
123 |
+
|
124 |
+
if (is_admin()) {
|
125 |
+
$plugin_data = get_file_data(__FILE__, ['Version' => 'Version'], false);
|
126 |
+
$plugin_version = $plugin_data['Version'];
|
127 |
+
define('WGACT_CURRENT_VERSION', $plugin_version);
|
128 |
+
}
|
129 |
+
|
130 |
+
// running the DB updater
|
131 |
+
if (get_option(WGACT_DB_OPTIONS_NAME)) {
|
132 |
+
(new Db_Upgrade)->run_options_db_upgrade();
|
133 |
+
}
|
134 |
+
|
135 |
+
// load the options
|
136 |
+
$this->wgact_options_init();
|
137 |
+
if (isset($this->options['gads']['dynamic_remarketing']) && $this->options['gads']['dynamic_remarketing']) {
|
138 |
+
add_filter('wgdr_third_party_cookie_prevention', '__return_true');
|
139 |
+
}
|
140 |
+
|
141 |
+
$this->init();
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
// startup all functions
|
146 |
+
public function init()
|
147 |
+
{
|
148 |
+
// display admin views
|
149 |
+
new Admin();
|
150 |
+
|
151 |
+
// ask visitor for rating
|
152 |
+
new Ask_For_Rating();
|
153 |
+
|
154 |
+
// add a settings link on the plugins page
|
155 |
+
add_filter('plugin_action_links_' . plugin_basename(__FILE__), [$this, 'wgact_settings_link']);
|
156 |
+
|
157 |
+
// inject pixels into front end
|
158 |
+
// in order to time it correctly so that the prevention filter works we need to use the after_setup_theme action
|
159 |
+
// https://stackoverflow.com/a/19279650
|
160 |
+
add_action('after_setup_theme', [$this, 'inject_pixels']);
|
161 |
+
}
|
162 |
+
|
163 |
+
public function inject_pixels()
|
164 |
+
{
|
165 |
+
// check if cookie prevention has been activated
|
166 |
+
|
167 |
+
// load the cookie consent management functions
|
168 |
+
$cookie_consent = new Cookie_Consent_Management();
|
169 |
+
$cookie_consent->setPluginPrefix(WGACT_PLUGIN_PREFIX);
|
170 |
+
|
171 |
+
if ($cookie_consent->is_cookie_prevention_active() == false) {
|
172 |
+
|
173 |
+
// inject pixels
|
174 |
+
new Pixel_Manager($this->options);
|
175 |
+
}
|
176 |
+
}
|
177 |
+
|
178 |
+
// initialise the options
|
179 |
+
private function wgact_options_init()
|
180 |
+
{
|
181 |
+
// set options equal to defaults
|
182 |
+
// global $wgact_plugin_options;
|
183 |
+
$this->options = get_option(WGACT_DB_OPTIONS_NAME);
|
184 |
+
|
185 |
+
if (false === $this->options) { // of no options have been set yet, initiate default options
|
186 |
+
|
187 |
+
update_option(WGACT_DB_OPTIONS_NAME, $this->wgact_get_default_options());
|
188 |
+
|
189 |
+
} else { // Check if each single option has been set. If not, set them. That is necessary when new options are introduced.
|
190 |
+
|
191 |
+
// cleanup the db of this setting
|
192 |
+
// remove by end of 2021 latest
|
193 |
+
if (array_key_exists('google_business_vertical', $this->options)) {
|
194 |
+
unset($this->options['google_business_vertical']);
|
195 |
+
}
|
196 |
+
|
197 |
+
// add new default options to the options db array
|
198 |
+
update_option(WGACT_DB_OPTIONS_NAME, $this->update_with_defaults($this->options, $this->wgact_get_default_options()));
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
protected function update_with_defaults($array_input, $array_default)
|
203 |
+
{
|
204 |
+
foreach ($array_default as $key => $value) {
|
205 |
+
if (array_key_exists($key, $array_input)) {
|
206 |
+
if (is_array($value)) {
|
207 |
+
$array_input[$key] = $this->update_with_defaults($array_input[$key], $value);
|
208 |
+
}
|
209 |
+
} else {
|
210 |
+
$array_input[$key] = $value;
|
211 |
+
}
|
212 |
+
}
|
213 |
+
|
214 |
+
return $array_input;
|
215 |
+
}
|
216 |
+
|
217 |
+
// get the default options
|
218 |
+
private function wgact_get_default_options(): array
|
219 |
+
{
|
220 |
+
// default options settings
|
221 |
+
return [
|
222 |
+
'google' => [
|
223 |
+
'ads' => [
|
224 |
+
'conversion_id' => '',
|
225 |
+
'conversion_label' => '',
|
226 |
+
'add_cart_data' => 0,
|
227 |
+
'aw_merchant_id' => '',
|
228 |
+
'product_identifier' => 0,
|
229 |
+
'google_business_vertical' => 0,
|
230 |
+
'dynamic_remarketing' => 0
|
231 |
+
],
|
232 |
+
'gtag' => [
|
233 |
+
'deactivation' => 0,
|
234 |
+
],
|
235 |
+
],
|
236 |
+
'facebook' => [
|
237 |
+
'pixel_id' => '767038516805171'
|
238 |
+
],
|
239 |
+
'shop' => [
|
240 |
+
'order_total_logic' => 0,
|
241 |
+
],
|
242 |
+
'db_version' => WGACT_DB_VERSION,
|
243 |
+
];
|
244 |
+
}
|
245 |
+
|
246 |
+
// adds a link on the plugins page for the wgdr settings
|
247 |
+
// ! Can't be required. Must be in the main plugin file.
|
248 |
+
public function wgact_settings_link($links)
|
249 |
+
{
|
250 |
+
$links[] = '<a href="' . admin_url('admin.php?page=wgact') . '">Settings</a>';
|
251 |
+
|
252 |
+
return $links;
|
253 |
+
}
|
254 |
}
|
255 |
|
256 |
+
new WGACT();
|