Version Description
- 2022-11-09 =
- Add - New Google Analytics task in WC.
Download this release
Release Info
Developer | automattic |
Plugin | WooCommerce Google Analytics Integration |
Version | 1.5.17 |
Comparing to | |
See all releases |
Code changes from version 1.5.16 to 1.5.17
- changelog.txt +3 -0
- includes/class-wc-google-analytics-task.php +76 -0
- includes/class-wc-google-analytics.php +33 -6
- readme.txt +4 -1
- woocommerce-google-analytics-integration.php +36 -10
changelog.txt
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
*** Changelog ***
|
2 |
|
|
|
|
|
|
|
3 |
= 1.5.16 - 2022-11-03 =
|
4 |
* Add - Declare compatibility for High Performance Order Storage.
|
5 |
* Tweak - WC 7.1 compatibility.
|
1 |
*** Changelog ***
|
2 |
|
3 |
+
= 1.5.17 - 2022-11-09 =
|
4 |
+
* Add - New Google Analytics task in WC.
|
5 |
+
|
6 |
= 1.5.16 - 2022-11-03 =
|
7 |
* Add - Declare compatibility for High Performance Order Storage.
|
8 |
* Tweak - WC 7.1 compatibility.
|
includes/class-wc-google-analytics-task.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Set up Google Analytics Integration task.
|
4 |
+
*
|
5 |
+
* Adds a set up Google Analytics Integration task to the task list.
|
6 |
+
*/
|
7 |
+
|
8 |
+
defined( 'ABSPATH' ) || exit;
|
9 |
+
|
10 |
+
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Task;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Setup Task class.
|
14 |
+
*
|
15 |
+
* @phpcs:disable Squiz.Classes.ClassFileName.NoMatch
|
16 |
+
* @phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps
|
17 |
+
*/
|
18 |
+
class WC_Google_Analytics_Task extends Task {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Get the ID of the task.
|
22 |
+
*
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
public function get_id() {
|
26 |
+
return 'setup-google-analytics-integration';
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Get the title for the task.
|
31 |
+
*
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
public function get_title() {
|
35 |
+
return esc_html__( 'Set up Google Analytics', 'woocommerce-google-analytics-integration' );
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Get the content for the task.
|
40 |
+
*
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
public function get_content() {
|
44 |
+
return esc_html__( 'Provides the integration between WooCommerce and Google Analytics.', 'woocommerce-google-analytics-integration' );
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Get the time required to perform the task.
|
49 |
+
*
|
50 |
+
* @return string
|
51 |
+
*/
|
52 |
+
public function get_time() {
|
53 |
+
return esc_html__( '5 minutes', 'woocommerce-google-analytics-integration' );
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Get the action URL for the task.
|
58 |
+
*
|
59 |
+
* @return string
|
60 |
+
*/
|
61 |
+
public function get_action_url() {
|
62 |
+
return WC_Google_Analytics_Integration::get_instance()->get_settings_url();
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Check if the task is complete.
|
67 |
+
*
|
68 |
+
* @return bool
|
69 |
+
*/
|
70 |
+
public function is_complete() {
|
71 |
+
return WC_Google_Analytics_Integration::get_integration()->is_setup_complete();
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
|
includes/class-wc-google-analytics.php
CHANGED
@@ -3,6 +3,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
3 |
exit; // Exit if accessed directly
|
4 |
}
|
5 |
|
|
|
|
|
6 |
/**
|
7 |
* Google Analytics Integration
|
8 |
*
|
@@ -68,12 +70,8 @@ class WC_Google_Analytics extends WC_Integration {
|
|
68 |
include_once( 'class-wc-google-gtag-js.php' );
|
69 |
$this->get_tracking_instance( $constructor );
|
70 |
|
71 |
-
// Display
|
72 |
-
|
73 |
-
include_once( 'class-wc-google-analytics-info-banner.php' );
|
74 |
-
WC_Google_Analytics_Info_Banner::get_instance( $this->dismissed_info_banner, $this->ga_id );
|
75 |
-
}
|
76 |
-
|
77 |
// Admin Options
|
78 |
add_filter( 'woocommerce_tracker_data', array( $this, 'track_options' ) );
|
79 |
add_action( 'woocommerce_update_options_integration_google_analytics', array( $this, 'process_admin_options') );
|
@@ -663,4 +661,33 @@ class WC_Google_Analytics extends WC_Integration {
|
|
663 |
|
664 |
return $return_url;
|
665 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
666 |
}
|
3 |
exit; // Exit if accessed directly
|
4 |
}
|
5 |
|
6 |
+
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists;
|
7 |
+
|
8 |
/**
|
9 |
* Google Analytics Integration
|
10 |
*
|
70 |
include_once( 'class-wc-google-gtag-js.php' );
|
71 |
$this->get_tracking_instance( $constructor );
|
72 |
|
73 |
+
// Display a task on "Things to do next section"
|
74 |
+
add_action( 'init', array( $this, 'add_wc_setup_task' ), 20 );
|
|
|
|
|
|
|
|
|
75 |
// Admin Options
|
76 |
add_filter( 'woocommerce_tracker_data', array( $this, 'track_options' ) );
|
77 |
add_action( 'woocommerce_update_options_integration_google_analytics', array( $this, 'process_admin_options') );
|
661 |
|
662 |
return $return_url;
|
663 |
}
|
664 |
+
|
665 |
+
/**
|
666 |
+
* Check if the Google Analytics Tracking ID has been set up.
|
667 |
+
*
|
668 |
+
* @since x.x.x
|
669 |
+
*
|
670 |
+
* @return bool Whether the Google Analytics setup is completed.
|
671 |
+
*/
|
672 |
+
public function is_setup_complete() {
|
673 |
+
return (bool) $this->get_option( 'ga_id' );
|
674 |
+
}
|
675 |
+
|
676 |
+
|
677 |
+
/**
|
678 |
+
* Adds the setup task to the Tasklists.
|
679 |
+
*
|
680 |
+
* @since x.x.x
|
681 |
+
*/
|
682 |
+
public function add_wc_setup_task() {
|
683 |
+
require_once 'class-wc-google-analytics-task.php';
|
684 |
+
|
685 |
+
TaskLists::add_task(
|
686 |
+
'extended',
|
687 |
+
new WC_Google_Analytics_Task(
|
688 |
+
TaskLists::get_list( 'extended' )
|
689 |
+
)
|
690 |
+
);
|
691 |
+
|
692 |
+
}
|
693 |
}
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: woocommerce, automattic, claudiosanches, bor0, royho, laurendaviss
|
|
3 |
Tags: woocommerce, google analytics
|
4 |
Requires at least: 3.9
|
5 |
Tested up to: 6.1
|
6 |
-
Stable tag: 1.5.
|
7 |
License: GPLv3
|
8 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
@@ -60,6 +60,9 @@ Exact wording depends on the national data privacy laws and should be adjusted.
|
|
60 |
|
61 |
== Changelog ==
|
62 |
|
|
|
|
|
|
|
63 |
= 1.5.16 - 2022-11-03 =
|
64 |
* Add - Declare compatibility for High Performance Order Storage.
|
65 |
* Tweak - WC 7.1 compatibility.
|
3 |
Tags: woocommerce, google analytics
|
4 |
Requires at least: 3.9
|
5 |
Tested up to: 6.1
|
6 |
+
Stable tag: 1.5.17
|
7 |
License: GPLv3
|
8 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
60 |
|
61 |
== Changelog ==
|
62 |
|
63 |
+
= 1.5.17 - 2022-11-09 =
|
64 |
+
* Add - New Google Analytics task in WC.
|
65 |
+
|
66 |
= 1.5.16 - 2022-11-03 =
|
67 |
* Add - Declare compatibility for High Performance Order Storage.
|
68 |
* Tweak - WC 7.1 compatibility.
|
woocommerce-google-analytics-integration.php
CHANGED
@@ -5,8 +5,8 @@
|
|
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.5.
|
9 |
-
* WC requires at least:
|
10 |
* WC tested up to: 7.1
|
11 |
* Tested up to: 6.1
|
12 |
* License: GPLv2 or later
|
@@ -22,7 +22,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
22 |
|
23 |
if ( ! class_exists( 'WC_Google_Analytics_Integration' ) ) {
|
24 |
|
25 |
-
define( 'WC_GOOGLE_ANALYTICS_INTEGRATION_VERSION', '1.5.
|
|
|
26 |
|
27 |
// Maybe show the GA Pro notice on plugin activation.
|
28 |
register_activation_hook(
|
@@ -66,7 +67,7 @@ if ( ! class_exists( 'WC_Google_Analytics_Integration' ) ) {
|
|
66 |
add_action( 'woocommerce_order_status_completed', array( $this, 'maybe_show_ga_pro_notices' ) );
|
67 |
|
68 |
// Checks which WooCommerce is installed.
|
69 |
-
if ( class_exists( 'WC_Integration' ) && defined( 'WOOCOMMERCE_VERSION' ) && version_compare( WOOCOMMERCE_VERSION,
|
70 |
include_once 'includes/class-wc-google-analytics.php';
|
71 |
|
72 |
// Register the integration.
|
@@ -79,13 +80,14 @@ if ( ! class_exists( 'WC_Google_Analytics_Integration' ) ) {
|
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
-
*
|
83 |
*
|
84 |
-
* @
|
85 |
-
*
|
|
|
86 |
*/
|
87 |
-
public function
|
88 |
-
|
89 |
array(
|
90 |
'page' => 'wc-settings',
|
91 |
'tab' => 'integration',
|
@@ -93,6 +95,16 @@ if ( ! class_exists( 'WC_Google_Analytics_Integration' ) ) {
|
|
93 |
),
|
94 |
admin_url( 'admin.php' )
|
95 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
$plugin_links = array(
|
98 |
'<a href="' . esc_url( $settings_url ) . '">' . __( 'Settings', 'woocommerce-google-analytics-integration' ) . '</a>',
|
@@ -130,7 +142,9 @@ if ( ! class_exists( 'WC_Google_Analytics_Integration' ) ) {
|
|
130 |
* WooCommerce fallback notice.
|
131 |
*/
|
132 |
public function woocommerce_missing_notice() {
|
133 |
-
|
|
|
|
|
134 |
}
|
135 |
|
136 |
/**
|
@@ -145,6 +159,18 @@ if ( ! class_exists( 'WC_Google_Analytics_Integration' ) ) {
|
|
145 |
return $integrations;
|
146 |
}
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
/**
|
149 |
* Logic for Google Analytics Pro notices.
|
150 |
*/
|
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.5.17
|
9 |
+
* WC requires at least: 6.8
|
10 |
* WC tested up to: 7.1
|
11 |
* Tested up to: 6.1
|
12 |
* License: GPLv2 or later
|
22 |
|
23 |
if ( ! class_exists( 'WC_Google_Analytics_Integration' ) ) {
|
24 |
|
25 |
+
define( 'WC_GOOGLE_ANALYTICS_INTEGRATION_VERSION', '1.5.17' ); // WRCS: DEFINED_VERSION.
|
26 |
+
define( 'WC_GOOGLE_ANALYTICS_INTEGRATION_MIN_WC_VER', '6.8' );
|
27 |
|
28 |
// Maybe show the GA Pro notice on plugin activation.
|
29 |
register_activation_hook(
|
67 |
add_action( 'woocommerce_order_status_completed', array( $this, 'maybe_show_ga_pro_notices' ) );
|
68 |
|
69 |
// Checks which WooCommerce is installed.
|
70 |
+
if ( class_exists( 'WC_Integration' ) && defined( 'WOOCOMMERCE_VERSION' ) && version_compare( WOOCOMMERCE_VERSION, WC_GOOGLE_ANALYTICS_INTEGRATION_MIN_WC_VER, '>=' ) ) {
|
71 |
include_once 'includes/class-wc-google-analytics.php';
|
72 |
|
73 |
// Register the integration.
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
+
* Gets the settings page URL.
|
84 |
*
|
85 |
+
* @since x.x.x
|
86 |
+
*
|
87 |
+
* @return string Settings URL
|
88 |
*/
|
89 |
+
public function get_settings_url() {
|
90 |
+
return add_query_arg(
|
91 |
array(
|
92 |
'page' => 'wc-settings',
|
93 |
'tab' => 'integration',
|
95 |
),
|
96 |
admin_url( 'admin.php' )
|
97 |
);
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Add links on the plugins page (Settings & Support)
|
102 |
+
*
|
103 |
+
* @param array $links Default links
|
104 |
+
* @return array Default + added links
|
105 |
+
*/
|
106 |
+
public function plugin_links( $links ) {
|
107 |
+
$settings_url = $this->get_settings_url();
|
108 |
|
109 |
$plugin_links = array(
|
110 |
'<a href="' . esc_url( $settings_url ) . '">' . __( 'Settings', 'woocommerce-google-analytics-integration' ) . '</a>',
|
142 |
* WooCommerce fallback notice.
|
143 |
*/
|
144 |
public function woocommerce_missing_notice() {
|
145 |
+
/* translators: 1 is the required component */
|
146 |
+
$error = sprintf( 'WooCommerce Google Analytics requires WooCommerce version %1$s or higher. You are using version %2$s', WC_GOOGLE_ANALYTICS_INTEGRATION_MIN_WC_VER, WOOCOMMERCE_VERSION );
|
147 |
+
echo '<div class="error"><p><strong>' . wp_kses_post( $error ) . '</strong></p></div>';
|
148 |
}
|
149 |
|
150 |
/**
|
159 |
return $integrations;
|
160 |
}
|
161 |
|
162 |
+
/**
|
163 |
+
* Get Google Analytics Integration
|
164 |
+
*
|
165 |
+
* @since x.x.x
|
166 |
+
*
|
167 |
+
* @return WC_Google_Analytics The Google Analytics integration.
|
168 |
+
*/
|
169 |
+
public static function get_integration() {
|
170 |
+
return \WooCommerce::instance()->integrations->get_integration( 'google_analytics' );
|
171 |
+
}
|
172 |
+
|
173 |
+
|
174 |
/**
|
175 |
* Logic for Google Analytics Pro notices.
|
176 |
*/
|