WooCommerce Google Analytics Integration - Version 1.4.4

Version Description

  • 20/03/2018 =
  • Fix - WC30 compatibility error when using deprecated get_product_from_item method.
  • Fix - Check object before using methods to prevent errors.
  • Fix - Variations not reporting category in cart tracking.
  • Add - Filter woocommerce_ga_disable_tracking added to disable tracking.
  • Tweak - Rebuilt languages pot file.
Download this release

Release Info

Developer bor0
Plugin Icon 128x128 WooCommerce Google Analytics Integration
Version 1.4.4
Comparing to
See all releases

Code changes from version 1.4.3 to 1.4.4

Gruntfile.js CHANGED
@@ -1,4 +1,4 @@
1
- /* jshint node:true */
2
module.exports = function( grunt ) {
3
'use strict';
4
@@ -9,9 +9,23 @@ module.exports = function( grunt ) {
9
10
// Setting folder templates
11
dirs: {
12
js: 'assets/js'
13
},
14
15
// Minify .js files.
16
uglify: {
17
options: {
@@ -34,6 +48,10 @@ module.exports = function( grunt ) {
34
35
// Watch changes for assets
36
watch: {
37
js: {
38
files: [
39
'<%= dirs.js %>/*js',
@@ -43,23 +61,50 @@ module.exports = function( grunt ) {
43
}
44
},
45
46
// Generate POT files.
47
makepot: {
48
dist: {
49
options: {
50
- type: 'wp-plugin',
51
- potHeaders: {
52
- 'report-msgid-bugs-to': 'https://wordpress.org/support/plugin/woocommerce-google-analytics-integration',
53
- 'language-team': 'LANGUAGE <EMAIL@ADDRESS>'
54
- }
55
}
56
}
57
},
58
59
// Check textdomain errors.
60
checktextdomain: {
61
- options: {
62
- text_domain: '<%= pkg.name %>',
63
keywords: [
64
'__:1,2d',
65
'_e:1,2d',
@@ -78,24 +123,44 @@ module.exports = function( grunt ) {
78
]
79
},
80
files: {
81
- src: [
82
- '**/*.php', // Include all files
83
- '!node_modules/**' // Exclude node_modules/
84
],
85
expand: true
86
}
87
- }
88
});
89
90
// Load NPM tasks to be used here
91
grunt.loadNpmTasks( 'grunt-wp-i18n' );
92
grunt.loadNpmTasks( 'grunt-checktextdomain' );
93
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
94
grunt.loadNpmTasks( 'grunt-contrib-watch' );
95
96
// Register tasks
97
grunt.registerTask( 'default', [
98
'uglify'
99
- ] );
100
101
};
1
+ /*jshint node:true */
2
module.exports = function( grunt ) {
3
'use strict';
4
9
10
// Setting folder templates
11
dirs: {
12
+ css: 'assets/css',
13
+ fonts: 'assets/fonts',
14
+ images: 'assets/images',
15
js: 'assets/js'
16
},
17
18
+ // Minify all .css files.
19
+ cssmin: {
20
+ minify: {
21
+ expand: true,
22
+ cwd: '<%= dirs.css %>/',
23
+ src: ['*.css'],
24
+ dest: '<%= dirs.css %>/',
25
+ ext: '.css'
26
+ }
27
+ },
28
+
29
// Minify .js files.
30
uglify: {
31
options: {
48
49
// Watch changes for assets
50
watch: {
51
+ less: {
52
+ files: ['<%= dirs.css %>/*.less'],
53
+ tasks: ['less', 'cssmin'],
54
+ },
55
js: {
56
files: [
57
'<%= dirs.js %>/*js',
61
}
62
},
63
64
+ // Shell scripts
65
+ shell: {
66
+ options: {
67
+ stdout: true,
68
+ stderr: true
69
+ },
70
+ txpull: {
71
+ command: [
72
+ 'tx pull -a -f', // Transifex download .po files
73
+ ].join( '&&' )
74
+ },
75
+ txpush: {
76
+ command: [
77
+ 'tx push -s' // Transifex - send .pot file
78
+ ].join( '&&' )
79
+ }
80
+ },
81
+
82
// Generate POT files.
83
makepot: {
84
+ options: {
85
+ type: 'wp-plugin',
86
+ domainPath: 'languages',
87
+ potHeaders: {
88
+ 'report-msgid-bugs-to': 'https://github.com/woocommerce/woocommerce-google-analytics-integration/issues',
89
+ 'language-team': 'LANGUAGE <EMAIL@ADDRESS>'
90
+ }
91
+ },
92
dist: {
93
options: {
94
+ potFilename: 'woocommerce-google-analytics-integration.pot',
95
+ exclude: [
96
+ 'apigen/.*',
97
+ 'tests/.*',
98
+ 'tmp/.*'
99
+ ]
100
}
101
}
102
},
103
104
// Check textdomain errors.
105
checktextdomain: {
106
+ options:{
107
+ text_domain: 'woocommerce-google-analytics-integration',
108
keywords: [
109
'__:1,2d',
110
'_e:1,2d',
123
]
124
},
125
files: {
126
+ src: [
127
+ '**/*.php', // Include all files
128
+ '!apigen/**', // Exclude apigen/
129
+ '!node_modules/**', // Exclude node_modules/
130
+ '!tests/**', // Exclude tests/
131
+ '!vendor/**', // Exclude vendor/
132
+ '!tmp/**' // Exclude tmp/
133
],
134
expand: true
135
}
136
+ },
137
});
138
139
// Load NPM tasks to be used here
140
+ grunt.loadNpmTasks( 'grunt-shell' );
141
+ grunt.loadNpmTasks( 'grunt-phpcs' );
142
+ grunt.loadNpmTasks( 'grunt-rtlcss' );
143
+ grunt.loadNpmTasks( 'grunt-postcss' );
144
grunt.loadNpmTasks( 'grunt-wp-i18n' );
145
grunt.loadNpmTasks( 'grunt-checktextdomain' );
146
grunt.loadNpmTasks( 'grunt-contrib-uglify' );
147
+ grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
148
+ grunt.loadNpmTasks( 'grunt-contrib-concat' );
149
grunt.loadNpmTasks( 'grunt-contrib-watch' );
150
+ grunt.loadNpmTasks( 'grunt-contrib-clean' );
151
152
// Register tasks
153
grunt.registerTask( 'default', [
154
+ 'js',
155
+ 'i18n'
156
+ ]);
157
+
158
+ grunt.registerTask( 'js', [
159
'uglify'
160
+ ]);
161
162
+ grunt.registerTask( 'i18n', [
163
+ 'checktextdomain',
164
+ 'makepot'
165
+ ]);
166
};
assets/js/admin-enhanced-settings.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(a){var b=a(".enhanced-setting").parent().parent().parent().parent(),c=a("#woocommerce_google_analytics_ga_enhanced_ecommerce_tracking_enabled").parent().parent().parent().parent();!1===a("#woocommerce_google_analytics_ga_enhanced_ecommerce_tracking_enabled").is(":checked")&&b.hide(),!1===a("#woocommerce_google_analytics_ga_use_universal_analytics").is(":checked")&&(b.hide(),c.hide()),a("#woocommerce_google_analytics_ga_enhanced_ecommerce_tracking_enabled").on("click",function(){!1===a("#woocommerce_google_analytics_ga_enhanced_ecommerce_tracking_enabled").is(":checked")?b.hide():b.show()}),a("#woocommerce_google_analytics_ga_use_universal_analytics").on("click",function(){!1===a("#woocommerce_google_analytics_ga_use_universal_analytics").is(":checked")?(b.hide(),c.hide()):(!0===a("#woocommerce_google_analytics_ga_enhanced_ecommerce_tracking_enabled").is(":checked")&&b.show(),c.show())})});
1
+ jQuery(document).ready(function(e){var c=e(".enhanced-setting").parent().parent().parent().parent(),a=e("#woocommerce_google_analytics_ga_enhanced_ecommerce_tracking_enabled").parent().parent().parent().parent();!1===e("#woocommerce_google_analytics_ga_enhanced_ecommerce_tracking_enabled").is(":checked")&&c.hide(),!1===e("#woocommerce_google_analytics_ga_use_universal_analytics").is(":checked")&&(c.hide(),a.hide()),e("#woocommerce_google_analytics_ga_enhanced_ecommerce_tracking_enabled").on("click",function(){!1===e("#woocommerce_google_analytics_ga_enhanced_ecommerce_tracking_enabled").is(":checked")?c.hide():c.show()}),e("#woocommerce_google_analytics_ga_use_universal_analytics").on("click",function(){!1===e("#woocommerce_google_analytics_ga_use_universal_analytics").is(":checked")?(c.hide(),a.hide()):(!0===e("#woocommerce_google_analytics_ga_enhanced_ecommerce_tracking_enabled").is(":checked")&&c.show(),a.show())})});
includes/class-wc-google-analytics-info-banner.php CHANGED
@@ -51,15 +51,15 @@ class WC_Google_Analytics_Info_Banner {
51
return;
52
}
53
54
- $integration_url = esc_url( admin_url('admin.php?page=wc-settings&tab=integration&section=google_analytics' ) );
55
$dismiss_url = $this->dismiss_url();
56
57
$heading = __( 'Google Analytics &amp; WooCommerce', 'woocommerce-google-analytics-integration' );
58
- $configure = sprintf( __( '<a href="%s">Connect WooCommerce to Google Analytics</a> to finish setting up this integration.' ), $integration_url );
59
60
// Display the message..
61
echo '<div class="updated fade"><p><strong>' . $heading . '</strong> ';
62
- echo '<a href="' . esc_url( $dismiss_url ). '" title="' . __( 'Dismiss this notice.', 'woocommerce-google-analytics-integration' ) . '"> ' . __( '(Dismiss)', 'woocommerce-google-analytics-integration' ) . '</a>';
63
echo '<p>' . $configure . "</p></div>\n";
64
}
65
51
return;
52
}
53
54
+ $integration_url = esc_url( admin_url( 'admin.php?page=wc-settings&tab=integration&section=google_analytics' ) );
55
$dismiss_url = $this->dismiss_url();
56
57
$heading = __( 'Google Analytics &amp; WooCommerce', 'woocommerce-google-analytics-integration' );
58
+ $configure = sprintf( __( '<a href="%s">Connect WooCommerce to Google Analytics</a> to finish setting up this integration.', 'woocommerce-google-analytics-integration' ), $integration_url );
59
60
// Display the message..
61
echo '<div class="updated fade"><p><strong>' . $heading . '</strong> ';
62
+ echo '<a href="' . esc_url( $dismiss_url ) . '" title="' . __( 'Dismiss this notice.', 'woocommerce-google-analytics-integration' ) . '"> ' . __( '(Dismiss)', 'woocommerce-google-analytics-integration' ) . '</a>';
63
echo '<p>' . $configure . "</p></div>\n";
64
}
65
includes/class-wc-google-analytics-js.php CHANGED
@@ -372,7 +372,7 @@ class WC_Google_Analytics_JS {
372
* @param array $item The item to add to a transaction/order
373
*/
374
function add_item_classic( $order, $item ) {
375
- $_product = $order->get_product_from_item( $item );
376
377
$code = "_gaq.push(['_addItem',";
378
$code .= "'" . esc_js( $order->get_order_number() ) . "',";
@@ -392,7 +392,7 @@ class WC_Google_Analytics_JS {
392
* @param array $item The item to add to a transaction/order
393
*/
394
function add_item_universal( $order, $item ) {
395
- $_product = $order->get_product_from_item( $item );
396
397
$code = "" . self::tracker_var() . "('ecommerce:addItem', {";
398
$code .= "'id': '" . esc_js( $order->get_order_number() ) . "',";
@@ -412,12 +412,18 @@ class WC_Google_Analytics_JS {
412
* @param array $item The item to add to a transaction/order
413
*/
414
function add_item_enhanced( $order, $item ) {
415
- $_product = $order->get_product_from_item( $item );
416
417
$code = "" . self::tracker_var() . "( 'ec:addProduct', {";
418
$code .= "'id': '" . esc_js( $_product->get_sku() ? $_product->get_sku() : $_product->get_id() ) . "',";
419
$code .= "'name': '" . esc_js( $item['name'] ) . "',";
420
$code .= "'category': " . self::product_get_category_line( $_product );
421
$code .= "'price': '" . esc_js( $order->get_item_total( $item ) ) . "',";
422
$code .= "'quantity': '" . esc_js( $item['qty'] ) . "'";
423
$code .= "});";
@@ -431,21 +437,40 @@ class WC_Google_Analytics_JS {
431
* @return string Line of JSON
432
*/
433
private static function product_get_category_line( $_product ) {
434
$variation_data = version_compare( WC_VERSION, '3.0', '<' ) ? $_product->variation_data : ( $_product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $_product->get_id() ) : '' );
435
if ( is_array( $variation_data ) && ! empty( $variation_data ) ) {
436
- $code = "'" . esc_js( wc_get_formatted_variation( $variation_data, true ) ) . "',";
437
- } else {
438
- $out = array();
439
- $categories = get_the_terms( $_product->get_id(), 'product_cat' );
440
- if ( $categories ) {
441
- foreach ( $categories as $category ) {
442
- $out[] = $category->name;
443
- }
444
}
445
- $code = "'" . esc_js( join( "/", $out ) ) . "',";
446
}
447
448
- return $code;
449
}
450
451
/**
@@ -495,11 +520,17 @@ class WC_Google_Analytics_JS {
495
496
foreach ( $cart as $cart_item_key => $cart_item ) {
497
$product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
498
$code .= "" . self::tracker_var() . "( 'ec:addProduct', {
499
'id': '" . esc_js( $product->get_sku() ? $product->get_sku() : ( '#' . $product->get_id() ) ) . "',
500
'name': '" . esc_js( $product->get_title() ) . "',
501
- 'category': " . self::product_get_category_line( $product ) . "
502
- 'price': '" . esc_js( $product->get_price() ) . "',
503
'quantity': '" . esc_js( $cart_item['quantity'] ) . "'
504
} );";
505
}
372
* @param array $item The item to add to a transaction/order
373
*/
374
function add_item_classic( $order, $item ) {
375
+ $_product = version_compare( WC_VERSION, '3.0', '<' ) ? $order->get_product_from_item( $item ) : $item->get_product();
376
377
$code = "_gaq.push(['_addItem',";
378
$code .= "'" . esc_js( $order->get_order_number() ) . "',";
392
* @param array $item The item to add to a transaction/order
393
*/
394
function add_item_universal( $order, $item ) {
395
+ $_product = version_compare( WC_VERSION, '3.0', '<' ) ? $order->get_product_from_item( $item ) : $item->get_product();
396
397
$code = "" . self::tracker_var() . "('ecommerce:addItem', {";
398
$code .= "'id': '" . esc_js( $order->get_order_number() ) . "',";
412
* @param array $item The item to add to a transaction/order
413
*/
414
function add_item_enhanced( $order, $item ) {
415
+ $_product = version_compare( WC_VERSION, '3.0', '<' ) ? $order->get_product_from_item( $item ) : $item->get_product();
416
+ $variant = self::product_get_variant_line( $_product );
417
418
$code = "" . self::tracker_var() . "( 'ec:addProduct', {";
419
$code .= "'id': '" . esc_js( $_product->get_sku() ? $_product->get_sku() : $_product->get_id() ) . "',";
420
$code .= "'name': '" . esc_js( $item['name'] ) . "',";
421
$code .= "'category': " . self::product_get_category_line( $_product );
422
+
423
+ if ( '' !== $variant ) {
424
+ $code .= "'variant': " . $variant;
425
+ }
426
+
427
$code .= "'price': '" . esc_js( $order->get_item_total( $item ) ) . "',";
428
$code .= "'quantity': '" . esc_js( $item['qty'] ) . "'";
429
$code .= "});";
437
* @return string Line of JSON
438
*/
439
private static function product_get_category_line( $_product ) {
440
+
441
+ $out = array();
442
$variation_data = version_compare( WC_VERSION, '3.0', '<' ) ? $_product->variation_data : ( $_product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $_product->get_id() ) : '' );
443
+ $categories = get_the_terms( $_product->get_id(), 'product_cat' );
444
+
445
if ( is_array( $variation_data ) && ! empty( $variation_data ) ) {
446
+ $parent_product = wc_get_product( version_compare( WC_VERSION, '3.0', '<' ) ? $_product->parent->id : $_product->get_parent_id() );
447
+ $categories = get_the_terms( $parent_product->get_id(), 'product_cat' );
448
+ }
449
+
450
+ if ( $categories ) {
451
+ foreach ( $categories as $category ) {
452
+ $out[] = $category->name;
453
}
454
}
455
456
+ return "'" . esc_js( join( "/", $out ) ) . "',";
457
+ }
458
+
459
+ /**
460
+ * Returns a 'variant' JSON line based on $product
461
+ * @param object $product Product to pull info for
462
+ * @return string Line of JSON
463
+ */
464
+ private static function product_get_variant_line( $_product ) {
465
+
466
+ $out = '';
467
+ $variation_data = version_compare( WC_VERSION, '3.0', '<' ) ? $_product->variation_data : ( $_product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $_product->get_id() ) : '' );
468
+
469
+ if ( is_array( $variation_data ) && ! empty( $variation_data ) ) {
470
+ $out = "'" . esc_js( wc_get_formatted_variation( $variation_data, true ) ) . "',";
471
+ }
472
+
473
+ return $out;
474
}
475
476
/**
520
521
foreach ( $cart as $cart_item_key => $cart_item ) {
522
$product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
523
+ $variant = self::product_get_variant_line( $product );
524
$code .= "" . self::tracker_var() . "( 'ec:addProduct', {
525
'id': '" . esc_js( $product->get_sku() ? $product->get_sku() : ( '#' . $product->get_id() ) ) . "',
526
'name': '" . esc_js( $product->get_title() ) . "',
527
+ 'category': " . self::product_get_category_line( $product );
528
+
529
+ if ( '' !== $variant ) {
530
+ $code .= "'variant': " . $variant;
531
+ }
532
+
533
+ $code .= "'price': '" . esc_js( $product->get_price() ) . "',
534
'quantity': '" . esc_js( $cart_item['quantity'] ) . "'
535
} );";
536
}
includes/class-wc-google-analytics.php CHANGED
@@ -281,7 +281,7 @@ class WC_Google_Analytics extends WC_Integration {
281
global $wp;
282
$display_ecommerce_tracking = false;
283
284
- if ( is_admin() || current_user_can( 'manage_options' ) || ! $this->ga_id ) {
285
return;
286
}
287
@@ -345,7 +345,7 @@ class WC_Google_Analytics extends WC_Integration {
345
* @return bool True if tracking for a certain setting is disabled
346
*/
347
private function disable_tracking( $type ) {
348
- if ( is_admin() || current_user_can( 'manage_options' ) || ( ! $this->ga_id ) || 'no' === $type ) {
349
return true;
350
}
351
}
@@ -410,8 +410,17 @@ class WC_Google_Analytics extends WC_Integration {
410
return $url;
411
}
412
413
$item = WC()->cart->get_cart_item( $key );
414
$product = $item['data'];
415
$url = str_replace( 'href=', 'data-product_id="' . esc_attr( $product->get_id() ) . '" data-product_sku="' . esc_attr( $product->get_sku() ) . '" href=', $url );
416
return $url;
417
}
281
global $wp;
282
$display_ecommerce_tracking = false;
283
284
+ if ( $this->disable_tracking( 'all' ) ) {
285
return;
286
}
287
345
* @return bool True if tracking for a certain setting is disabled
346
*/
347
private function disable_tracking( $type ) {
348
+ if ( is_admin() || current_user_can( 'manage_options' ) || ( ! $this->ga_id ) || 'no' === $type || apply_filters( 'woocommerce_ga_disable_tracking', false, $type ) ) {
349
return true;
350
}
351
}
410
return $url;
411
}
412
413
+ if ( ! is_object( WC()->cart ) ) {
414
+ return $url;
415
+ }
416
+
417
$item = WC()->cart->get_cart_item( $key );
418
$product = $item['data'];
419
+
420
+ if ( ! is_object( $product ) ) {
421
+ return $url;
422
+ }
423
+
424
$url = str_replace( 'href=', 'data-product_id="' . esc_attr( $product->get_id() ) . '" data-product_sku="' . esc_attr( $product->get_sku() ) . '" href=', $url );
425
return $url;
426
}
languages/woocommerce-google-analytics-integration.pot CHANGED
@@ -1,19 +1,37 @@
1
- # Copyright (C) 2014 WooThemes
2
# This file is distributed under the GPLv2 or later.
3
msgid ""
4
msgstr ""
5
- "Project-Id-Version: WooCommerce Google Analytics Integration 1.4.0\n"
6
"Report-Msgid-Bugs-To: "
7
- "https://wordpress.org/support/plugin/woocommerce-google-analytics-"
8
- "integration\n"
9
- "POT-Creation-Date: 2014-11-11 21:09:47+00:00\n"
10
"MIME-Version: 1.0\n"
11
"Content-Type: text/plain; charset=utf-8\n"
12
"Content-Transfer-Encoding: 8bit\n"
13
- "PO-Revision-Date: 2014-MO-DA HO:MI+ZONE\n"
14
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
15
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
16
- "X-Generator: grunt-wp-i18n 0.4.9\n"
17
18
#: includes/class-wc-google-analytics.php:23
19
msgid "Google Analytics"
@@ -25,87 +43,188 @@ msgid ""
25
"detailed statistics about the visitors to a website."
26
msgstr ""
27
28
- #: includes/class-wc-google-analytics.php:63
29
msgid "Google Analytics ID"
30
msgstr ""
31
32
- #: includes/class-wc-google-analytics.php:64
33
msgid ""
34
- "Log into your google analytics account to find your ID. e.g. "
35
"<code>UA-XXXXX-X</code>"
36
msgstr ""
37
38
- #: includes/class-wc-google-analytics.php:69
39
msgid "Set Domain Name"
40
msgstr ""
41
42
- #: includes/class-wc-google-analytics.php:70
43
msgid ""
44
"(Optional) Sets the <code>_setDomainName</code> variable. <a "
45
"href=\"%s\">See here for more information</a>."
46
msgstr ""
47
48
- #: includes/class-wc-google-analytics.php:75
49
- msgid "Tracking code"
50
msgstr ""
51
52
- #: includes/class-wc-google-analytics.php:76
53
msgid ""
54
- "Add tracking code to your site. You don't need to enable this if using a "
55
- "3rd party analytics plugin."
56
msgstr ""
57
58
- #: includes/class-wc-google-analytics.php:82
59
msgid ""
60
- "Set the Google Analytics code to support Display Advertising. <a "
61
- "href=\"https://support.google.com/analytics/answer/2700409\" "
62
- "target=\"_blank\">Read more about Display Advertising</a>."
63
msgstr ""
64
65
- #: includes/class-wc-google-analytics.php:88
66
- msgid "Use Universal Analytics instead of Classic Google Analytics"
67
msgstr ""
68
69
- #: includes/class-wc-google-analytics.php:94
70
msgid ""
71
- "Anonymize IP addresses. Setting this option is mandatory in certain "
72
- "countries due to national privacy laws. <a "
73
- "href=\"https://support.google.com/analytics/answer/2763052\" "
74
- "target=\"_blank\">Read more about IP Anonymization</a>."
75
msgstr ""
76
77
- #: includes/class-wc-google-analytics.php:100
78
- msgid "Add eCommerce tracking code to the thankyou page"
79
msgstr ""
80
81
- #: includes/class-wc-google-analytics.php:106
82
- msgid "Add event tracking code for add to cart actions"
83
msgstr ""
84
85
- #: includes/class-wc-google-analytics.php:178
86
- #: includes/class-wc-google-analytics.php:276
87
- msgid "Guest"
88
msgstr ""
89
90
- #: includes/class-wc-google-analytics.php:478
91
- #: includes/class-wc-google-analytics.php:499
92
msgid "Products"
93
msgstr ""
94
95
- #: includes/class-wc-google-analytics.php:479
96
- #: includes/class-wc-google-analytics.php:500
97
msgid "Add to Cart"
98
msgstr ""
99
100
- #: includes/class-wc-google-analytics.php:480
101
- msgid "SKU:"
102
msgstr ""
103
104
- #: woocommerce-google-analytics-integration.php:89
105
msgid "WooCommerce Google Analytics depends on the last version of %s to work!"
106
msgstr ""
107
108
- #: woocommerce-google-analytics-integration.php:89
109
msgid "WooCommerce"
110
msgstr ""
111
@@ -123,10 +242,6 @@ msgid ""
123
"pages."
124
msgstr ""
125
126
- #. Author of the plugin/theme
127
- msgid "WooThemes"
128
- msgstr ""
129
-
130
#. Author URI of the plugin/theme
131
- msgid "http://woothemes.com"
132
msgstr ""
1
+ # Copyright (C) 2018 WooCommerce
2
# This file is distributed under the GPLv2 or later.
3
msgid ""
4
msgstr ""
5
+ "Project-Id-Version: WooCommerce Google Analytics Integration 1.4.4\n"
6
"Report-Msgid-Bugs-To: "
7
+ "https://github.com/woocommerce/woocommerce-google-analytics-integration/"
8
+ "issues\n"
9
+ "POT-Creation-Date: 2018-03-20 14:42:08+00:00\n"
10
"MIME-Version: 1.0\n"
11
"Content-Type: text/plain; charset=utf-8\n"
12
"Content-Transfer-Encoding: 8bit\n"
13
+ "PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n"
14
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
15
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
16
+ "X-Generator: grunt-wp-i18n1.0.2\n"
17
+
18
+ #: includes/class-wc-google-analytics-info-banner.php:57
19
+ msgid "Google Analytics &amp; WooCommerce"
20
+ msgstr ""
21
+
22
+ #: includes/class-wc-google-analytics-info-banner.php:58
23
+ msgid ""
24
+ "<a href=\"%s\">Connect WooCommerce to Google Analytics</a> to finish "
25
+ "setting up this integration."
26
+ msgstr ""
27
+
28
+ #: includes/class-wc-google-analytics-info-banner.php:62
29
+ msgid "Dismiss this notice."
30
+ msgstr ""
31
+
32
+ #: includes/class-wc-google-analytics-info-banner.php:62
33
+ msgid "(Dismiss)"
34
+ msgstr ""
35
36
#: includes/class-wc-google-analytics.php:23
37
msgid "Google Analytics"
43
"detailed statistics about the visitors to a website."
44
msgstr ""
45
46
+ #: includes/class-wc-google-analytics.php:104
47
msgid "Google Analytics ID"
48
msgstr ""
49
50
+ #: includes/class-wc-google-analytics.php:105
51
msgid ""
52
+ "Log into your Google Analytics account to find your ID. e.g. "
53
"<code>UA-XXXXX-X</code>"
54
msgstr ""
55
56
+ #: includes/class-wc-google-analytics.php:111
57
msgid "Set Domain Name"
58
msgstr ""
59
60
+ #: includes/class-wc-google-analytics.php:112
61
msgid ""
62
"(Optional) Sets the <code>_setDomainName</code> variable. <a "
63
"href=\"%s\">See here for more information</a>."
64
msgstr ""
65
66
+ #: includes/class-wc-google-analytics.php:117
67
+ msgid "Tracking Options"
68
+ msgstr ""
69
+
70
+ #: includes/class-wc-google-analytics.php:118
71
+ msgid "Enable Standard Tracking"
72
+ msgstr ""
73
+
74
+ #: includes/class-wc-google-analytics.php:119
75
+ msgid ""
76
+ "This tracks session data such as demographics, system, etc. You don't need "
77
+ "to enable this if you are using a 3rd party Google analytics plugin."
78
+ msgstr ""
79
+
80
+ #: includes/class-wc-google-analytics.php:125
81
+ msgid "\"Display Advertising\" Support"
82
msgstr ""
83
84
+ #: includes/class-wc-google-analytics.php:126
85
msgid ""
86
+ "Set the Google Analytics code to support Display Advertising. %sRead more "
87
+ "about Display Advertising%s."
88
+ msgstr ""
89
+
90
+ #: includes/class-wc-google-analytics.php:132
91
+ msgid "Use Enhanced Link Attribution"
92
msgstr ""
93
94
+ #: includes/class-wc-google-analytics.php:133
95
msgid ""
96
+ "Set the Google Analytics code to support Enhanced Link Attribution. %sRead "
97
+ "more about Enhanced Link Attribution%s."
98
msgstr ""
99
100
+ #: includes/class-wc-google-analytics.php:139
101
+ msgid "Enable Universal Analytics"
102
msgstr ""
103
104
+ #: includes/class-wc-google-analytics.php:140
105
msgid ""
106
+ "Uses Universal Analytics instead of Classic Google Analytics. If you have "
107
+ "<strong>not</strong> previously used Google Analytics on this site, check "
108
+ "this box. Otherwise, %sfollow step 1 of the Universal Analytics upgrade "
109
+ "guide.%s Enabling this setting will take care of step 2. %sRead more about "
110
+ "Universal Analytics%s. Universal Analytics must be enabled to enable "
111
+ "enhanced eCommerce."
112
+ msgstr ""
113
+
114
+ #: includes/class-wc-google-analytics.php:146
115
+ msgid "Anonymize IP addresses."
116
msgstr ""
117
118
+ #: includes/class-wc-google-analytics.php:147
119
+ msgid ""
120
+ "Enabling this option is mandatory in certain countries due to national "
121
+ "privacy laws. %sRead more about IP Anonymization%s."
122
msgstr ""
123
124
+ #: includes/class-wc-google-analytics.php:153
125
+ msgid "Track 404 (Not found) Errors."
126
msgstr ""
127
128
+ #: includes/class-wc-google-analytics.php:154
129
+ msgid ""
130
+ "Enable this to find broken or dead links. An \"Event\" with category "
131
+ "\"Error\" and action \"404 Not Found\" will be created in Google Analytics "
132
+ "for each incoming pageview to a non-existing page. By setting up a \"Custom "
133
+ "Goal\" for these events within Google Analytics you can find out where "
134
+ "broken links originated from (the referrer). %sRead how to set up a goal%s."
135
msgstr ""
136
137
+ #: includes/class-wc-google-analytics.php:160
138
+ msgid "Purchase Transactions"
139
+ msgstr ""
140
+
141
+ #: includes/class-wc-google-analytics.php:161
142
+ msgid ""
143
+ "This requires a payment gateway that redirects to the thank you/order "
144
+ "received page after payment. Orders paid with gateways which do not do this "
145
+ "will not be tracked."
146
+ msgstr ""
147
+
148
+ #: includes/class-wc-google-analytics.php:167
149
+ msgid "Add to Cart Events"
150
+ msgstr ""
151
+
152
+ #: includes/class-wc-google-analytics.php:174
153
+ msgid "Enhanced eCommerce"
154
+ msgstr ""
155
+
156
+ #: includes/class-wc-google-analytics.php:175
157
+ msgid "Enable Enhanced eCommerce "
158
+ msgstr ""
159
+
160
+ #: includes/class-wc-google-analytics.php:176
161
+ msgid ""
162
+ "Enhanced eCommerce allows you to measure more user interactions with your "
163
+ "store, including: product impressions, product detail views, starting the "
164
+ "checkout process, adding cart items, and removing cart items. Universal "
165
+ "Analytics must be enabled for Enhanced eCommerce to work. Before enabling "
166
+ "this setting, turn on Enhanced eCommerce in your Google Analytics "
167
+ "dashboard. <a href=\"%s\">See here for more information</a>."
168
+ msgstr ""
169
+
170
+ #: includes/class-wc-google-analytics.php:185
171
+ msgid "Remove from Cart Events"
172
+ msgstr ""
173
+
174
+ #: includes/class-wc-google-analytics.php:193
175
+ msgid "Product Impressions from Listing Pages"
176
+ msgstr ""
177
+
178
+ #: includes/class-wc-google-analytics.php:201
179
+ msgid "Product Clicks from Listing Pages"
180
+ msgstr ""
181
+
182
+ #: includes/class-wc-google-analytics.php:209
183
+ msgid "Product Detail Views"
184
+ msgstr ""
185
+
186
+ #: includes/class-wc-google-analytics.php:217
187
+ msgid "Checkout Process Initiated"
188
+ msgstr ""
189
+
190
+ #: includes/class-wc-google-analytics.php:230
191
+ msgid "Please allow Google Analytics 24 hours to start displaying results."
192
+ msgstr ""
193
+
194
+ #: includes/class-wc-google-analytics.php:233
195
+ msgid ""
196
+ "Please note, for transaction tracking to work properly, you will need to "
197
+ "use a payment gateway that redirects the customer back to a WooCommerce "
198
+ "order received/thank you page."
199
+ msgstr ""
200
+
201
+ #: includes/class-wc-google-analytics.php:370
202
+ #: includes/class-wc-google-analytics.php:440
203
msgid "Products"
204
msgstr ""
205
206
+ #: includes/class-wc-google-analytics.php:371
207
+ #: includes/class-wc-google-analytics.php:441
208
msgid "Add to Cart"
209
msgstr ""
210
211
+ #: includes/class-wc-google-analytics.php:372
212
+ msgid "ID:"
213
+ msgstr ""
214
+
215
+ #: woocommerce-google-analytics-integration.php:71
216
+ msgid "Settings"
217
+ msgstr ""
218
+
219
+ #: woocommerce-google-analytics-integration.php:72
220
+ msgid "Support"
221
msgstr ""
222
223
+ #: woocommerce-google-analytics-integration.php:110
224
msgid "WooCommerce Google Analytics depends on the last version of %s to work!"
225
msgstr ""
226
227
+ #. Author of the plugin/theme
228
msgid "WooCommerce"
229
msgstr ""
230
242
"pages."
243
msgstr ""
244
245
#. Author URI of the plugin/theme
246
+ msgid "https://woocommerce.com"
247
msgstr ""
package.json CHANGED
@@ -1,22 +1,40 @@
1
{
2
"name": "woocommerce-google-analytics-integration",
3
"title": "WooCommerce Google Analytics Integration",
4
- "version": "1.4.3",
5
- "homepage": "https://wordpress.org/plugins/woocommerce-google-analytics-integration/",
6
"repository": {
7
"type": "git",
8
- "url": "https://github.com/woothemes/woocommerce-google-analytics-integration.git"
9
},
10
"main": "Gruntfile.js",
11
"devDependencies": {
12
- "grunt": "^0.4.5",
13
- "grunt-wp-i18n": "^0.4.9",
14
- "grunt-checktextdomain": "^0.1.1",
15
- "grunt-contrib-uglify": "~0.3.2",
16
- "grunt-contrib-watch": "~0.5.3"
17
},
18
"engines": {
19
- "node": ">=0.8.0",
20
- "npm": ">=1.1.0"
21
}
22
}
1
{
2
"name": "woocommerce-google-analytics-integration",
3
"title": "WooCommerce Google Analytics Integration",
4
+ "version": "1.4.4",
5
+ "license": "GPL-2.0",
6
+ "homepage": "http://wordpress.org/plugins/woocommerce-google-analytics-integration/",
7
"repository": {
8
"type": "git",
9
+ "url": "git://github.com/woocommerce/woocommerce-google-analytics-integration.git"
10
},
11
"main": "Gruntfile.js",
12
+ "scripts": {
13
+ "build": "grunt",
14
+ "update-deps": "npm install -g rimraf && rimraf node_modules && rimraf npm-shrinkwrap.json && npm install && npm shrinkwrap --dev"
15
+ },
16
"devDependencies": {
17
+ "config": "^1.24.0",
18
+ "cross-env": "^3.0.0",
19
+ "grunt": "~1.0.1",
20
+ "grunt-checktextdomain": "~1.0.1",
21
+ "grunt-contrib-clean": "~1.1.0",
22
+ "grunt-contrib-concat": "~1.0.1",
23
+ "grunt-contrib-cssmin": "~2.2.1",
24
+ "grunt-contrib-uglify": "~3.1.0",
25
+ "grunt-contrib-watch": "~1.0.0",
26
+ "grunt-phpcs": "~0.4.0",
27
+ "grunt-postcss": "~0.9.0",
28
+ "grunt-rtlcss": "~2.0.1",
29
+ "grunt-shell": "~2.1.0",
30
+ "grunt-wp-i18n": "~1.0.1",
31
+ "shortid": "^2.2.8"
32
},
33
"engines": {
34
+ "node": ">=8.9.3",
35
+ "npm": ">=5.5.1"
36
+ },
37
+ "dependencies": {
38
+ "npm": "^5.7.1"
39
}
40
}
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
=== WooCommerce Google Analytics Integration ===
2
- Contributors: woothemes, claudiosanches, bor0
3
Tags: woocommerce, google analytics
4
Requires at least: 3.8
5
- Tested up to: 4.5.2
6
- Stable tag: 1.4.3
7
License: GPLv3
8
License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
@@ -50,11 +50,15 @@ Until you've updated to WooCommerce 2.1, this plugin puts itself in some sort of
50
51
You can leave this plugin activated and it will seamlessly take over the integration that once was in the WooCommerce plugin, once you update to the next version.
52
53
= My national data privacy laws require that I offer an opt-out for users, how can I do this? =
54
55
Include the following html code snippet within the page where you want to have the opt-out, e.g. the your Imprint our Data Privacy page:
56
57
- https://gist.github.com/claudiosmweb/b12d15b245be21c92ebc
58
59
Exact wording depends on the national data privacy laws and should be adjusted.
60
@@ -64,64 +68,17 @@ Exact wording depends on the national data privacy laws and should be adjusted.
64
65
== Changelog ==
66
67
= 1.4.3 - 15/06/2017 =
68
* Fix - WC 3.x notice by using proper variation data.
69
* Add - Option to track 404 (Not found) errors.
70
71
- = 1.4.2 - 09/05/2017 =
72
- * Fix - Missing Google Analytics ID.
73
-
74
- = 1.4.1 - 01/05/2017 =
75
-
76
- * Add - Filters for GA snippet (woocommerce_ga_snippet_head, woocommerce_ga_snippet_create, woocommerce_ga_snippet_require, woocommerce_ga_snippet_output)
77
- * Add - Option to toggle on/off Enhanced Link Attribution
78
- * Fix - JavaScript break by wrapping it in quotes
79
- * Fix - Use ID and SKU data in a consistent way so that all products are correctly tracked.
80
- * Fix - Updates for WooCommerce 3.0 compatibility.
81
- * Add - Settings link to the plugin in the Plugins screen
82
- * Fix - Fatal error on shortcode usage for empty product
83
-
84
- = 1.4.0 - 20/11/2015 =
85
-
86
- * Feature - Support for enhanced eCommerce (tracking full store process from view to order)
87
- * Tweak - Setting up the plugin is now clearer with some helpful links and clearer language
88
- * Tweak - New filter on the ga global variable
89
- * Refactor - JavaScript generation functions have been moved to their own class
90
-
91
- = 1.3.0 - 12/11/2014 =
92
-
93
- * Feature - Added the transaction currency in the tracking code
94
- * Feature - Add data privacy option that are mandatory in some countries
95
- * Tweak - Moved the tracking code to the head of the page
96
- * Tweak - Remove the "SKU" prefix to the sku for addItem
97
- * Refactor - Integration class reformulated
98
-
99
- = 1.2.2 - 15/10/2014 =
100
-
101
- * Feature - Adding option to anonymize IP addresses
102
- * Feature - Adding gaOptOut function to be called from any page for OptOut
103
-
104
- = 1.2.1 - 17/09/2014 =
105
-
106
- * Tweak - Adding utmnooverride to return url for Google Adwords
107
-
108
- = 1.2.0 - 28/07/2014 =
109
-
110
- * Feature - Adding display advertising parameter to Universal Analytics
111
- * Fix - Using get_total_shipping() instead of get_shipping
112
- * Fix - Using wc_enqueue_js() instead of $woocommerce->add_inline_js(
113
- * Tweak - Updating plugin FAQ
114
- * Tweak - Adding parenthesis for clarity
115
-
116
- = 1.1 - 29/05/2014 =
117
-
118
- * Added option to enable Display Advertising
119
- * Added compatibility support for WooCommerce 2.1 beta releases
120
-
121
- = 1.0 - 22/11/2013 =
122
-
123
- * Initial release
124
-
125
126
== Upgrade Notice ==
127
= 1.4.0 =
1
=== WooCommerce Google Analytics Integration ===
2
+ Contributors: woocommerce, claudiosanches, bor0, royho, laurendavissmith001
3
Tags: woocommerce, google analytics
4
Requires at least: 3.8
5
+ Tested up to: 4.9
6
+ Stable tag: 1.4.4
7
License: GPLv3
8
License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
50
51
You can leave this plugin activated and it will seamlessly take over the integration that once was in the WooCommerce plugin, once you update to the next version.
52
53
+ = My settings are not saving! =
54
+
55
+ Do you have SUHOSIN installed/active on your server? If so, the default index length is 64 and some settings on this plugin requires longer lengths. Try setting your SUHOSIN configuration's "max_array_index_length" to "100" and test again.
56
+
57
= My national data privacy laws require that I offer an opt-out for users, how can I do this? =
58
59
Include the following html code snippet within the page where you want to have the opt-out, e.g. the your Imprint our Data Privacy page:
60
61
+ https://gist.github.com/claudiosanches/b12d15b245be21c92ebc
62
63
Exact wording depends on the national data privacy laws and should be adjusted.
64
68
69
== Changelog ==
70
71
+ = 1.4.4 - 20/03/2018 =
72
+ * Fix - WC30 compatibility error when using deprecated get_product_from_item method.
73
+ * Fix - Check object before using methods to prevent errors.
74
+ * Fix - Variations not reporting category in cart tracking.
75
+ * Add - Filter woocommerce_ga_disable_tracking added to disable tracking.
76
+ * Tweak - Rebuilt languages pot file.
77
+
78
= 1.4.3 - 15/06/2017 =
79
* Fix - WC 3.x notice by using proper variation data.
80
* Add - Option to track 404 (Not found) errors.
81
82
83
== Upgrade Notice ==
84
= 1.4.0 =
woocommerce-google-analytics-integration.php CHANGED
@@ -5,7 +5,9 @@
5
* Description: Allows Google Analytics tracking code to be inserted into WooCommerce store pages.
6
* Author: WooCommerce
7
* Author URI: https://woocommerce.com
8
- * Version: 1.4.3
9
* License: GPLv2 or later
10
* Text Domain: woocommerce-google-analytics-integration
11
* Domain Path: languages/
@@ -15,113 +17,113 @@ if ( ! defined( 'ABSPATH' ) ) {
15
exit;
16
}
17
18
- if ( ! class_exists( 'WC_Google_Analytics_Integration' ) ) :
19
-
20
- /**
21
- * WooCommerce Google Analytics Integration main class.
22
- */
23
- class WC_Google_Analytics_Integration {
24
-
25
- /**
26
- * Plugin version.
27
- *
28
- * @var string
29
- */
30
- const VERSION = '1.4.3';
31
32
/**
33
- * Instance of this class.
34
- *
35
- * @var object
36
*/
37
- protected static $instance = null;
38
-
39
- /**
40
- * Initialize the plugin.
41
- */
42
- private function __construct() {
43
- // Load plugin text domain
44
- add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
45
-
46
- // Checks with WooCommerce is installed.
47
- if ( class_exists( 'WC_Integration' ) && defined( 'WOOCOMMERCE_VERSION' ) && version_compare( WOOCOMMERCE_VERSION, '2.1-beta-1', '>=' ) ) {
48
- include_once 'includes/class-wc-google-analytics.php';
49
-
50
- // Register the integration.
51
- add_filter( 'woocommerce_integrations', array( $this, 'add_integration' ) );
52
- } else {
53
- add_action( 'admin_notices', array( $this, 'woocommerce_missing_notice' ) );
54
}
55
56
- add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_links' ) );
57
- }
58
-
59
- public function plugin_links( $links ) {
60
- $settings_url = add_query_arg(
61
- array(
62
- 'page' => 'wc-settings',
63
- 'tab' => 'integration',
64
- ),
65
- admin_url( 'admin.php' )
66
- );
67
-
68
- $plugin_links = array(
69
- '<a href="' . esc_url( $settings_url ) . '">' . __( 'Settings', 'woocommerce-google-analytics-integration' ) . '</a>',
70
- '<a href="https://wordpress.org/support/plugin/woocommerce-google-analytics-integration">' . __( 'Support', 'woocommerce-google-analytics-integration' ) . '</a>',
71
- );
72
-
73
- return array_merge( $plugin_links, $links );
74
- }
75
76
- /**
77
- * Return an instance of this class.
78
- *
79
- * @return object A single instance of this class.
80
- */
81
- public static function get_instance() {
82
- // If the single instance hasn't been set, set it now.
83
- if ( null == self::$instance ) {
84
- self::$instance = new self;
85
}
86
87
- return self::$instance;
88
- }
89
90
- /**
91
- * Load the plugin text domain for translation.
92
- *
93
- * @return void
94
- */
95
- public function load_plugin_textdomain() {
96
- $locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-google-analytics-integration' );
97
98
- load_textdomain( 'woocommerce-google-analytics-integration', trailingslashit( WP_LANG_DIR ) . 'woocommerce-google-analytics-integration/woocommerce-google-analytics-integration-' . $locale . '.mo' );
99
- load_plugin_textdomain( 'woocommerce-google-analytics-integration', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
100
- }
101
102
- /**
103
- * WooCommerce fallback notice.
104
- *
105
- * @return string
106
- */
107
- public function woocommerce_missing_notice() {
108
- echo '<div class="error"><p>' . sprintf( __( 'WooCommerce Google Analytics depends on the last version of %s to work!', 'woocommerce-google-analytics-integration' ), '<a href="http://www.woothemes.com/woocommerce/" target="_blank">' . __( 'WooCommerce', 'woocommerce-google-analytics-integration' ) . '</a>' ) . '</p></div>';
109
}
110
111
- /**
112
- * Add a new integration to WooCommerce.
113
- *
114
- * @param array $integrations WooCommerce integrations.
115
- *
116
- * @return array Google Analytics integration.
117
- */
118
- public function add_integration( $integrations ) {
119
- $integrations[] = 'WC_Google_Analytics';
120
121
- return $integrations;
122
- }
123
}
124
-
125
- add_action( 'plugins_loaded', array( 'WC_Google_Analytics_Integration', 'get_instance' ), 0 );
126
-
127
- endif;
5
* Description: Allows Google Analytics tracking code to be inserted into WooCommerce store pages.
6
* Author: WooCommerce
7
* Author URI: https://woocommerce.com
8
+ * Version: 1.4.4
9
+ * WC requires at least: 2.1
10
+ * WC tested up to: 3.3
11
* License: GPLv2 or later
12
* Text Domain: woocommerce-google-analytics-integration
13
* Domain Path: languages/
17
exit;
18
}
19
20
+ if ( ! class_exists( 'WC_Google_Analytics_Integration' ) ) {
21
22
/**
23
+ * WooCommerce Google Analytics Integration main class.
24
*/
25
+ class WC_Google_Analytics_Integration {
26
+
27
+ /**
28
+ * Plugin version.
29
+ *
30
+ * @var string
31
+ */
32
+ const VERSION = '1.4.4';
33
+
34
+ /**
35
+ * Instance of this class.
36
+ *
37
+ * @var object
38
+ */
39
+ protected static $instance = null;
40
+
41
+ /**
42
+ * Initialize the plugin.
43
+ */
44
+ private function __construct() {
45
+ // Load plugin text domain
46
+ add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
47
+
48
+ // Checks with WooCommerce is installed.
49
+ if ( class_exists( 'WC_Integration' ) && defined( 'WOOCOMMERCE_VERSION' ) && version_compare( WOOCOMMERCE_VERSION, '2.1-beta-1', '>=' ) ) {
50
+ include_once 'includes/class-wc-google-analytics.php';
51
+
52
+ // Register the integration.
53
+ add_filter( 'woocommerce_integrations', array( $this, 'add_integration' ) );
54
+ } else {
55
+ add_action( 'admin_notices', array( $this, 'woocommerce_missing_notice' ) );
56
+ }
57
+
58
+ add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_links' ) );
59
}
60
61
+ public function plugin_links( $links ) {
62
+ $settings_url = add_query_arg(
63
+ array(
64
+ 'page' => 'wc-settings',
65
+ 'tab' => 'integration',
66
+ ),
67
+ admin_url( 'admin.php' )
68
+ );
69
+
70
+ $plugin_links = array(
71
+ '<a href="' . esc_url( $settings_url ) . '">' . __( 'Settings', 'woocommerce-google-analytics-integration' ) . '</a>',
72
+ '<a href="https://wordpress.org/support/plugin/woocommerce-google-analytics-integration">' . __( 'Support', 'woocommerce-google-analytics-integration' ) . '</a>',
73
+ );
74
+
75
+ return array_merge( $plugin_links, $links );
76
+ }
77
78
+ /**
79
+ * Return an instance of this class.
80
+ *
81
+ * @return object A single instance of this class.
82
+ */
83
+ public static function get_instance() {
84
+ // If the single instance hasn't been set, set it now.
85
+ if ( null == self::$instance ) {
86
+ self::$instance = new self;
87
+ }
88
+
89
+ return self::$instance;
90
}
91
92
+ /**
93
+ * Load the plugin text domain for translation.
94
+ *
95
+ * @return void
96
+ */
97
+ public function load_plugin_textdomain() {
98
+ $locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-google-analytics-integration' );
99
100
+ load_textdomain( 'woocommerce-google-analytics-integration', trailingslashit( WP_LANG_DIR ) . 'woocommerce-google-analytics-integration/woocommerce-google-analytics-integration-' . $locale . '.mo' );
101
+ load_plugin_textdomain( 'woocommerce-google-analytics-integration', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
102
+ }
103
104
+ /**
105
+ * WooCommerce fallback notice.
106
+ *
107
+ * @return string
108
+ */
109
+ public function woocommerce_missing_notice() {
110
+ echo '<div class="error"><p>' . sprintf( __( 'WooCommerce Google Analytics depends on the last version of %s to work!', 'woocommerce-google-analytics-integration' ), '<a href="http://www.woothemes.com/woocommerce/" target="_blank">' . __( 'WooCommerce', 'woocommerce-google-analytics-integration' ) . '</a>' ) . '</p></div>';
111
+ }
112
113
+ /**
114
+ * Add a new integration to WooCommerce.
115
+ *
116
+ * @param array $integrations WooCommerce integrations.
117
+ *
118
+ * @return array Google Analytics integration.
119
+ */
120
+ public function add_integration( $integrations ) {
121
+ $integrations[] = 'WC_Google_Analytics';
122
+
123
+ return $integrations;
124
+ }
125
}
126
127
+ add_action( 'plugins_loaded', array( 'WC_Google_Analytics_Integration', 'get_instance' ), 0 );
128
129
}