DuracellTomi's Google Tag Manager for WordPress - Version 1.15.1

Version Description

  • Fixed: JavaScript error with the newly added console logging to debug code placement issues
  • Fixed: possible XSS Vulnerability if Cloudflare country code option enabled. Thanks Guillaume Fortier
  • Fixed: proven XSS Vulnerability if adding site search into the data layer was enabled. Original report by not_stoppable. Root cause analysis by Cory Buecker.
  • Removed: deprecated feature Google Ads remarketing. This is the outdated, classic way using the google_tag_params variable.
  • Dev: removed PHP constant GTM4WP_WPFILTER_COMPILE_REMARKTING (related to removed Google Ads remarketing feature)
  • Dev: removed gtm4wp_compile_remarkering WordPress filter (related to removed Google Ads remarketing feature)

Note to plugin users: I sincerely appologize for the vulnerabilities. To make sure, such cases do not happen again, the next version will be fully dedicacted to go through every peace of code and make sure proper data processing is happening in GTM4WP.

Download this release

Release Info

Developer duracelltomi
Plugin Icon 128x128 DuracellTomi's Google Tag Manager for WordPress
Version 1.15.1
Comparing to
See all releases

Code changes from version 1.15 to 1.15.1

admin/admin.php CHANGED
@@ -1,1570 +1,1564 @@
1
- <?php
2
- define( 'GTM4WP_ADMINSLUG', 'gtm4wp-settings' );
3
- define( 'GTM4WP_ADMIN_GROUP', 'gtm4wp-admin-group' );
4
-
5
- define( 'GTM4WP_ADMIN_GROUP_GENERAL', 'gtm4wp-admin-group-general' );
6
- define( 'GTM4WP_ADMIN_GROUP_GTMID', 'gtm4wp-admin-group-gtm-id' );
7
- define( 'GTM4WP_ADMIN_GROUP_CONTAINERON', 'gtm4wp-admin-container-on' );
8
- define( 'GTM4WP_ADMIN_GROUP_COMPATMODE', 'gtm4wp-admin-compat-mode' );
9
- define( 'GTM4WP_ADMIN_GROUP_INFO', 'gtm4wp-admin-group-datalayer-info' );
10
-
11
- define( 'GTM4WP_ADMIN_GROUP_INCLUDES', 'gtm4wp-admin-group-includes' );
12
- define( 'GTM4WP_ADMIN_GROUP_EVENTS', 'gtm4wp-admin-group-events' );
13
- define( 'GTM4WP_ADMIN_GROUP_SCROLLER', 'gtm4wp-admin-group-scroller' );
14
- define( 'GTM4WP_ADMIN_GROUP_BLACKLIST', 'gtm4wp-admin-group-blacklist-tags' );
15
- define( 'GTM4WP_ADMIN_GROUP_INTEGRATION', 'gtm4wp-admin-group-integration' );
16
- define( 'GTM4WP_ADMIN_GROUP_ADVANCED', 'gtm4wp-admin-group-advanced' );
17
- define( 'GTM4WP_ADMIN_GROUP_CREDITS', 'gtm4wp-admin-group-credits' );
18
-
19
- define( 'GTM4WP_USER_NOTICES_KEY', 'gtm4wp_user_notices_dismisses' );
20
-
21
- define( 'GTM4WP_PHASE_STABLE', 'gtm4wp-phase-stable' );
22
- define( 'GTM4WP_PHASE_BETA', 'gtm4wp-phase-beta' );
23
- define( 'GTM4WP_PHASE_EXPERIMENTAL', 'gtm4wp-phase-experimental' );
24
- define( 'GTM4WP_PHASE_DEPRECATED', 'gtm4wp-phase-deprecated' );
25
-
26
- $GLOBALS['gtm4wp_def_user_notices_dismisses'] = array(
27
- 'enter-gtm-code' => false,
28
- 'wc-ga-plugin-warning' => false,
29
- 'wc-gayoast-plugin-warning' => false,
30
- 'php72-warning' => false,
31
- 'deprecated-warning' => false,
32
- );
33
-
34
- $GLOBALS['gtm4wp_includefieldtexts'] = array(
35
- GTM4WP_OPTION_INCLUDE_POSTTYPE => array(
36
- 'label' => __( 'Posttype of current post/archive', 'duracelltomi-google-tag-manager' ),
37
- 'description' => __( 'Check this option to include the type of the current post or archive page (post, page or any custom post type).', 'duracelltomi-google-tag-manager' ),
38
- 'phase' => GTM4WP_PHASE_STABLE,
39
- ),
40
- GTM4WP_OPTION_INCLUDE_CATEGORIES => array(
41
- 'label' => __( 'Category list of current post/archive', 'duracelltomi-google-tag-manager' ),
42
- 'description' => __( 'Check this option to include the category names of the current post or archive page', 'duracelltomi-google-tag-manager' ),
43
- 'phase' => GTM4WP_PHASE_STABLE,
44
- ),
45
- GTM4WP_OPTION_INCLUDE_TAGS => array(
46
- 'label' => __( 'Tags of current post', 'duracelltomi-google-tag-manager' ),
47
- 'description' => __( 'Check this option to include the tags of the current post.', 'duracelltomi-google-tag-manager' ),
48
- 'phase' => GTM4WP_PHASE_STABLE,
49
- ),
50
- GTM4WP_OPTION_INCLUDE_AUTHORID => array(
51
- 'label' => __( 'Post author ID', 'duracelltomi-google-tag-manager' ),
52
- 'description' => __( 'Check this option to include the ID of the author on the current post or author page.', 'duracelltomi-google-tag-manager' ),
53
- 'phase' => GTM4WP_PHASE_STABLE,
54
- ),
55
- GTM4WP_OPTION_INCLUDE_AUTHOR => array(
56
- 'label' => __( 'Post author name', 'duracelltomi-google-tag-manager' ),
57
- 'description' => __( 'Check this option to include the name of the author on the current post or author page.', 'duracelltomi-google-tag-manager' ),
58
- 'phase' => GTM4WP_PHASE_STABLE,
59
- ),
60
- GTM4WP_OPTION_INCLUDE_POSTDATE => array(
61
- 'label' => __( 'Post date', 'duracelltomi-google-tag-manager' ),
62
- 'description' => __( 'Check this option to include the date of the current post. This will include 4 dataLayer variables: full date, post year, post month, post date.', 'duracelltomi-google-tag-manager' ),
63
- 'phase' => GTM4WP_PHASE_STABLE,
64
- ),
65
- GTM4WP_OPTION_INCLUDE_POSTTITLE => array(
66
- 'label' => __( 'Post title', 'duracelltomi-google-tag-manager' ),
67
- 'description' => __( 'Check this option to include the title of the current post.', 'duracelltomi-google-tag-manager' ),
68
- 'phase' => GTM4WP_PHASE_STABLE,
69
- ),
70
- GTM4WP_OPTION_INCLUDE_POSTCOUNT => array(
71
- 'label' => __( 'Post count', 'duracelltomi-google-tag-manager' ),
72
- 'description' => __( 'Check this option to include the count of the posts currently shown on the page and the total number of posts in the category/tag/any taxonomy.', 'duracelltomi-google-tag-manager' ),
73
- 'phase' => GTM4WP_PHASE_STABLE,
74
- ),
75
- GTM4WP_OPTION_INCLUDE_POSTID => array(
76
- 'label' => __( 'Post ID', 'duracelltomi-google-tag-manager' ),
77
- 'description' => __( 'Check this option to include the post id.', 'duracelltomi-google-tag-manager' ),
78
- 'phase' => GTM4WP_PHASE_STABLE,
79
- ),
80
- GTM4WP_OPTION_INCLUDE_POSTFORMAT => array(
81
- 'label' => __( 'Post Format', 'duracelltomi-google-tag-manager' ),
82
- 'description' => __( 'Check this option to include the post format.', 'duracelltomi-google-tag-manager' ),
83
- 'phase' => GTM4WP_PHASE_STABLE,
84
- ),
85
- GTM4WP_OPTION_INCLUDE_POSTTERMLIST => array(
86
- "label" => __( "Post Terms", 'duracelltomi-google-tag-manager' ),
87
- "description" => __( "Check this option to include taxonomy values associated with a given post.", 'duracelltomi-google-tag-manager' ),
88
- "phase" => GTM4WP_PHASE_STABLE
89
- ),
90
- GTM4WP_OPTION_INCLUDE_SEARCHDATA => array(
91
- 'label' => __( 'Search data', 'duracelltomi-google-tag-manager' ),
92
- 'description' => __( 'Check this option to include the search term, referring page URL and number of results on the search page.', 'duracelltomi-google-tag-manager' ),
93
- 'phase' => GTM4WP_PHASE_STABLE,
94
- ),
95
- GTM4WP_OPTION_INCLUDE_LOGGEDIN => array(
96
- 'label' => __( 'Logged in status', 'duracelltomi-google-tag-manager' ),
97
- 'description' => __( 'Check this option to include whether there is a logged in user on your website.', 'duracelltomi-google-tag-manager' ),
98
- 'phase' => GTM4WP_PHASE_STABLE,
99
- ),
100
- GTM4WP_OPTION_INCLUDE_USERROLE => array(
101
- 'label' => __( 'Logged in user role', 'duracelltomi-google-tag-manager' ),
102
- 'description' => __( 'Check this option to include the role of the logged in user.', 'duracelltomi-google-tag-manager' ),
103
- 'phase' => GTM4WP_PHASE_STABLE,
104
- ),
105
- GTM4WP_OPTION_INCLUDE_USERID => array(
106
- 'label' => __( 'Logged in user ID', 'duracelltomi-google-tag-manager' ),
107
- 'description' => __( 'Check this option to include the ID of the logged in user.', 'duracelltomi-google-tag-manager' ),
108
- 'phase' => GTM4WP_PHASE_STABLE,
109
- ),
110
- GTM4WP_OPTION_INCLUDE_USERNAME => array(
111
- 'label' => __( 'Logged in user name', 'duracelltomi-google-tag-manager' ),
112
- 'description' => __( 'Check this option to include the username of the logged in user.', 'duracelltomi-google-tag-manager' ),
113
- 'phase' => GTM4WP_PHASE_STABLE,
114
- ),
115
- GTM4WP_OPTION_INCLUDE_USEREMAIL => array(
116
- 'label' => __( 'Logged in user email', 'duracelltomi-google-tag-manager' ),
117
- 'description' => __( 'Check this option to include the email address of the logged in user.', 'duracelltomi-google-tag-manager' ),
118
- 'phase' => GTM4WP_PHASE_STABLE,
119
- ),
120
- GTM4WP_OPTION_INCLUDE_USERREGDATE => array(
121
- 'label' => __( 'Logged in user creation date', 'duracelltomi-google-tag-manager' ),
122
- 'description' => __( 'Check this option to include the date of creation (registration) of the logged in user.', 'duracelltomi-google-tag-manager' ),
123
- 'phase' => GTM4WP_PHASE_STABLE,
124
- ),
125
- GTM4WP_OPTION_INCLUDE_VISITOR_IP => array(
126
- 'label' => __( 'Visitor IP', 'duracelltomi-google-tag-manager' ),
127
- 'description' => __( 'Check this option to include the IP address of the visitor. You might use this to filter internal traffic inside your GTM container. Please be aware that per GDPR its not allowed to transmit this full IP address to Google Analytics or to any other measurement system without explicit consent from the visitor.', 'duracelltomi-google-tag-manager' ),
128
- 'phase' => GTM4WP_PHASE_STABLE,
129
- ),
130
- GTM4WP_OPTION_INCLUDE_REMARKETING => array(
131
- 'label' => __( 'Remarketing variable', 'duracelltomi-google-tag-manager' ),
132
- 'description' => __( 'Check this option to include a dataLayer variable where all dataLayer values are stored to be included in your Google Ads remarketing tag as a custom variable field', 'duracelltomi-google-tag-manager' ),
133
- 'phase' => GTM4WP_PHASE_DEPRECATED,
134
- ),
135
- GTM4WP_OPTION_INCLUDE_BROWSERDATA => array(
136
- 'label' => __( 'Browser data *', 'duracelltomi-google-tag-manager' ),
137
- 'description' => __( 'Check this option to include the name, version and engine data of the browser the visitor uses.', 'duracelltomi-google-tag-manager' )
138
- ),
139
- GTM4WP_OPTION_INCLUDE_OSDATA => array(
140
- 'label' => __( 'OS data *', 'duracelltomi-google-tag-manager' ),
141
- 'description' => __( 'Check this option to include the name and version of the operating system the visitor uses.', 'duracelltomi-google-tag-manager' )
142
- ),
143
- GTM4WP_OPTION_INCLUDE_DEVICEDATA => array(
144
- 'label' => __( 'Device data *', 'duracelltomi-google-tag-manager' ),
145
- 'description' => __( 'Check this option to include the type of device the user is currently using (desktop, tablet or mobile) including manufacturer and model data.', 'duracelltomi-google-tag-manager' )
146
- ),
147
- GTM4WP_OPTION_INCLUDE_MISCGEO => array(
148
- 'label' => __( 'Geo data', 'duracelltomi-google-tag-manager' ),
149
- 'description' => __( 'Add geo data (latitude, longitude, country, city, etc) of the current visitor (provided by ipstack.com)', 'duracelltomi-google-tag-manager' ),
150
- 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
151
- ),
152
- GTM4WP_OPTION_INCLUDE_MISCGEOAPI => array(
153
- 'label' => __( 'IPStack.com API key', 'duracelltomi-google-tag-manager' ),
154
- 'description' => sprintf( __( 'Enter your IPStack.com API key here. <a href="%s" target="_blank" rel="noopener">Get a free API key here</a>.', 'duracelltomi-google-tag-manager' ), 'https://ipstack.com/product?utm_source=gtm4wp&utm_medium=link&utm_campaign=gtm4wp-google-tag-manager-for-wordpress' ),
155
- 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
156
- ),
157
- GTM4WP_OPTION_INCLUDE_MISCGEOCF => array(
158
- 'label' => __( 'Cloudflare country code', 'duracelltomi-google-tag-manager' ),
159
- 'description' => __( 'Add the country code of the user provided by Cloudflare (if Cloudflare is used with your site)', 'duracelltomi-google-tag-manager' ),
160
- 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
161
- ),
162
- GTM4WP_OPTION_INCLUDE_WEATHER => array(
163
- 'label' => __( 'Weather data', 'duracelltomi-google-tag-manager' ),
164
- 'description' => sprintf(
165
- __(
166
- 'Check this option to include the current weather conditions around the current visitor.<br /><br />' .
167
- '<strong>Attention!</strong> This feature uses <a href="%s" target="_blank" rel="noopener">ipstack.com</a> and ' .
168
- '<a href="%s" target="_blank" rel="noopener">openweathermap.org</a> to collect data.<br />' .
169
- "Depending on your website's traffic, additional fees may apply!<br />" .
170
- 'This plugin caches weather data for 1 hour to lower the need to access those services.<br /><br />' .
171
- 'If you activate weather data, <strong>you will need</strong> to add an IPStack.com API key regardless of whether you ' .
172
- "activate the 'Geo data' option!",
173
- 'duracelltomi-google-tag-manager'
174
- ),
175
- 'https://ipstack.com/product?utm_source=gtm4wp&utm_medium=link&utm_campaign=gtm4wp-google-tag-manager-for-wordpress',
176
- 'http://openweathermap.org/price?utm_source=gtm4wp&utm_medium=link&utm_campaign=gtm4wp-google-tag-manager-for-wordpress'
177
- ),
178
- 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
179
- ),
180
- GTM4WP_OPTION_INCLUDE_WEATHERUNITS => array(
181
- 'label' => __( 'Weather data units', 'duracelltomi-google-tag-manager' ),
182
- 'description' => __( 'Select which temperature units you would like to use.', 'duracelltomi-google-tag-manager' ),
183
- 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
184
- ),
185
- GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI => array(
186
- 'label' => __( 'OpenWeatherMap API key', 'duracelltomi-google-tag-manager' ),
187
- 'description' => sprintf( __( 'Enter your OpenWeatherMap API key here. <a href="%s" target="_blank" rel="noopener">Get a free API key here</a>.', 'duracelltomi-google-tag-manager' ), 'http://openweathermap.org/price?utm_source=gtm4wp&utm_medium=link&utm_campaign=gtm4wp-google-tag-manager-for-wordpress' ),
188
- 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
189
- ),
190
- GTM4WP_OPTION_INCLUDE_SITEID => array(
191
- 'label' => __( 'Site ID', 'duracelltomi-google-tag-manager' ),
192
- 'description' => __( 'ID of the current site in a WordPress Multisite environment', 'duracelltomi-google-tag-manager' ),
193
- 'phase' => GTM4WP_PHASE_STABLE,
194
- ),
195
- GTM4WP_OPTION_INCLUDE_SITENAME => array(
196
- 'label' => __( 'Site name', 'duracelltomi-google-tag-manager' ),
197
- 'description' => __( 'Name of the current site in a WordPress Multisite environment', 'duracelltomi-google-tag-manager' ),
198
- 'phase' => GTM4WP_PHASE_STABLE,
199
- ),
200
- );
201
-
202
- $GLOBALS['gtm4wp_eventfieldtexts'] = array(
203
- GTM4WP_OPTION_EVENTS_FORMMOVE => array(
204
- 'label' => __( 'Form fill events (gtm4wp.formElementEnter & gtm4wp.formElementLeave)', 'duracelltomi-google-tag-manager' ),
205
- 'description' => __( 'Check this option to include a Tag Manager event when a visitor moves between elements of a form (comment, contact, etc).', 'duracelltomi-google-tag-manager' ),
206
- 'phase' => GTM4WP_PHASE_STABLE,
207
- ),
208
- GTM4WP_OPTION_EVENTS_NEWUSERREG => array(
209
- 'label' => __( 'New user registration', 'duracelltomi-google-tag-manager' ),
210
- 'description' => __( 'Check this option to include a Tag Manager event when a new user registration has been completed on the frontend of your site (admin events not included)', 'duracelltomi-google-tag-manager' ),
211
- 'phase' => GTM4WP_PHASE_STABLE,
212
- ),
213
- GTM4WP_OPTION_EVENTS_USERLOGIN => array(
214
- 'label' => __( 'User logged in', 'duracelltomi-google-tag-manager' ),
215
- 'description' => __( 'Check this option to include a Tag Manager event when an existing user has been logged in on the frontend of your site (admin events not included)', 'duracelltomi-google-tag-manager' ),
216
- 'phase' => GTM4WP_PHASE_STABLE,
217
- ),
218
- GTM4WP_OPTION_EVENTS_YOUTUBE => array(
219
- 'label' => __( 'YouTube video events', 'duracelltomi-google-tag-manager' ),
220
- 'description' => __( 'Check this option to include a Tag Manager event when a visitor interacts with a YouTube video embeded on your site.', 'duracelltomi-google-tag-manager' ),
221
- 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
222
- ),
223
- GTM4WP_OPTION_EVENTS_VIMEO => array(
224
- 'label' => __( 'Vimeo video events', 'duracelltomi-google-tag-manager' ),
225
- 'description' => __( 'Check this option to include a Tag Manager event when a visitor interacts with a Vimeo video embeded on your site.', 'duracelltomi-google-tag-manager' ),
226
- 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
227
- ),
228
- GTM4WP_OPTION_EVENTS_SOUNDCLOUD => array(
229
- 'label' => __( 'Soundcloud events', 'duracelltomi-google-tag-manager' ),
230
- 'description' => __( 'Check this option to include a Tag Manager event when a visitor interacts with a Soundcloud media embeded on your site.', 'duracelltomi-google-tag-manager' ),
231
- 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
232
- )
233
- );
234
-
235
- $GLOBALS['gtm4wp_scrollerfieldtexts'] = array(
236
- GTM4WP_OPTION_SCROLLER_ENABLED => array(
237
- 'label' => __( 'Enabled', 'duracelltomi-google-tag-manager' ),
238
- 'description' => __( 'Enable scroll tracker script on your website.', 'duracelltomi-google-tag-manager' ),
239
- 'phase' => GTM4WP_PHASE_STABLE,
240
- ),
241
- GTM4WP_OPTION_SCROLLER_DEBUGMODE => array(
242
- 'label' => __( 'Debug mode', 'duracelltomi-google-tag-manager' ),
243
- 'description' => __( 'Fire console.log() commands instead of dataLayer events.', 'duracelltomi-google-tag-manager' ),
244
- 'phase' => GTM4WP_PHASE_STABLE,
245
- ),
246
- GTM4WP_OPTION_SCROLLER_CALLBACKTIME => array(
247
- 'label' => __( 'Time delay before location check', 'duracelltomi-google-tag-manager' ),
248
- 'description' => __( 'Enter the number of milliseconds after the script checks the current location. It prevents too many events being fired while scrolling.', 'duracelltomi-google-tag-manager' ),
249
- 'phase' => GTM4WP_PHASE_STABLE,
250
- ),
251
- GTM4WP_OPTION_SCROLLER_DISTANCE => array(
252
- 'label' => __( 'Minimum distance', 'duracelltomi-google-tag-manager' ),
253
- 'description' => __( 'The minimum amount of pixels that a visitor has to scroll before we treat the move as scrolling.', 'duracelltomi-google-tag-manager' ),
254
- 'phase' => GTM4WP_PHASE_STABLE,
255
- ),
256
- GTM4WP_OPTION_SCROLLER_CONTENTID => array(
257
- 'label' => __( 'Content ID', 'duracelltomi-google-tag-manager' ),
258
- 'description' => __( 'Enter the DOM ID of the content element in your template. Leave it empty for default(content). Do not include the # sign.', 'duracelltomi-google-tag-manager' ),
259
- 'phase' => GTM4WP_PHASE_STABLE,
260
- ),
261
- GTM4WP_OPTION_SCROLLER_READERTIME => array(
262
- 'label' => __( 'Scroller time', 'duracelltomi-google-tag-manager' ),
263
- 'description' => __( 'Enter the number of seconds after the the scroller user is being treated as a reader, someone who really reads the content, not just scrolls through it.', 'duracelltomi-google-tag-manager' ),
264
- 'phase' => GTM4WP_PHASE_STABLE,
265
- ),
266
- );
267
-
268
- $GLOBALS['gtm4wp_integratefieldtexts'] = array(
269
- GTM4WP_OPTION_INTEGRATE_WPCF7 => array(
270
- 'label' => __( 'Contact Form 7', 'duracelltomi-google-tag-manager' ),
271
- 'description' => __( 'Check this to fire dataLayer events after Contact Form 7 submissions (supported events: invalid input, spam detected, form submitted, form submitted and mail sent, form submitted and mail send failed).', 'duracelltomi-google-tag-manager' ),
272
- 'phase' => GTM4WP_PHASE_STABLE,
273
- 'plugintocheck' => 'contact-form-7/wp-contact-form-7.php',
274
- ),
275
- GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC => array(
276
- 'label' => __( 'Track classic e-commerce', 'duracelltomi-google-tag-manager' ),
277
- 'description' => __( 'This feature is deprecated and will be removed soon! You should upgrade to enhanced ecommerce as soon as possible.', 'duracelltomi-google-tag-manager' ),
278
- 'phase' => GTM4WP_PHASE_DEPRECATED
279
- ),
280
- GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC => array(
281
- 'label' => __( 'Track enhanced e-commerce', 'duracelltomi-google-tag-manager' ),
282
- 'description' => sprintf(
283
- __(
284
- 'Choose this option if you would like to track e-commerce data using '.
285
- '<a href="%s" target="_blank" rel="noopener">enhanced ecommerce tracking</a>.<br>'.
286
- 'Use the plugin\'s official guides to setup your Google Tag Manager container:<br>'.
287
- '<ul><li><a href="%s" target="_blank" rel="noopener">Google Analytics 3 / Universal Analytics setup</a></li>'.
288
- '<li><a href="%s" target="_blank" rel="noopener">Google Analytics 4 setup</a></li></ul>'
289
- , 'duracelltomi-google-tag-manager' )
290
- , 'https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce'
291
- , 'https://gtm4wp.com/how-to-articles/how-to-setup-enhanced-ecommerce-tracking'
292
- , 'https://gtm4wp.com/how-to-articles/how-to-setup-enhanced-ecommerce-tracking-google-analytics-4-ga4-version' ),
293
- 'phase' => GTM4WP_PHASE_STABLE,
294
- 'plugintocheck' => 'woocommerce/woocommerce.php',
295
- ),
296
- GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION => array(
297
- 'label' => __( 'Products per impression', 'duracelltomi-google-tag-manager' ),
298
- 'description' => __(
299
- 'If you have many products shown on product category pages and/or on your site home, you could miss pageviews in Google Analytics due to the ' .
300
- 'amount of data that is needed to be sent. To prevent this, you can split product impression data into multiple Google Analytics events by ' .
301
- 'entering a number here (minimum 10-15 recommended) and adding gtm4wp.productImpressionEEC into your Google Analytics ecommerce event helper ' .
302
- "tag's trigger.<br /><br />Leave this value 0 to include product impression data in your pageview hit.",
303
- 'duracelltomi-google-tag-manager'
304
- ),
305
- 'phase' => GTM4WP_PHASE_STABLE
306
- ),
307
- GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP => array(
308
- 'label' => __( 'Cart as 1st checkout step', 'duracelltomi-google-tag-manager' ),
309
- 'description' => __( 'Enable this to track the cart page as the first checkout step in enhanced ecommerce instead of the checkout page itself', 'duracelltomi-google-tag-manager' ),
310
- 'phase' => GTM4WP_PHASE_STABLE
311
- ),
312
- GTM4WP_OPTION_INTEGRATE_WCEINCLUDECARTINDL => array(
313
- "label" => __( "Cart content in data layer", 'duracelltomi-google-tag-manager' ),
314
- "description" => __( "Enable this option to include the content of the cart in the data layer on each page. Needs WooCommerce v3.2 or newer. Especially useful for site personalization with Google Optimize.", 'duracelltomi-google-tag-manager' ),
315
- "phase" => GTM4WP_PHASE_STABLE
316
- ),
317
- GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH => array(
318
- 'label' => __( 'Include full category path.', 'duracelltomi-google-tag-manager' ),
319
- 'description' => __( 'Check this to inclulde the full category path of each product in enhanced ecommerce tracking. WARNING! This can lead to performance issues on large sites with lots of traffic!', 'duracelltomi-google-tag-manager' ),
320
- 'phase' => GTM4WP_PHASE_STABLE
321
- ),
322
- GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY => array(
323
- "label" => __( "Taxonomy to be used for product brands", 'duracelltomi-google-tag-manager' ),
324
- "description" => __( "Select which custom taxonomy is being used to add the brand of products", 'duracelltomi-google-tag-manager' ),
325
- "phase" => GTM4WP_PHASE_STABLE
326
- ),
327
- GTM4WP_OPTION_INTEGRATE_WCCUSTOMERDATA => array(
328
- 'label' => __( 'Customer data in data layer', 'duracelltomi-google-tag-manager' ),
329
- 'description' => __( 'Enable this to add all customer data (billing and shipping data, total number of orders and order value) into the data layer (WooCommerce 3.x required)', 'duracelltomi-google-tag-manager' ),
330
- 'phase' => GTM4WP_PHASE_STABLE
331
- ),
332
- GTM4WP_OPTION_INTEGRATE_WCORDERDATA => array(
333
- 'label' => __( 'Order data in data layer', 'duracelltomi-google-tag-manager' ),
334
- 'description' => __( 'Enable this to add all order attribute into the data layer on the order received page regardless and independently from classic and enhanced ecommerce tracking (WooCommerce 3.x required)', 'duracelltomi-google-tag-manager' ),
335
- 'phase' => GTM4WP_PHASE_STABLE
336
- ),
337
- GTM4WP_OPTION_INTEGRATE_WCEXCLUDETAX => array(
338
- 'label' => __( 'Exclude tax from revenue', 'duracelltomi-google-tag-manager' ),
339
- 'description' => __( 'Enable this to exclude tax from the revenue variable while generating the purchase data', 'duracelltomi-google-tag-manager' ),
340
- 'phase' => GTM4WP_PHASE_STABLE
341
- ), GTM4WP_OPTION_INTEGRATE_WCORDERMAXAGE => array(
342
- 'label' => __( 'Only track orders younger than', 'duracelltomi-google-tag-manager' ),
343
- 'description' => __( 'To prevent duplicate transaction tracking at the order received page, enter the maximum age (in minutes) of the order or its payment for the transaction to be measured. Viewing the order received page of older orders will be ignored from transaction tracking, as it is considered to be a measured in an earlier session.', 'duracelltomi-google-tag-manager' ),
344
- 'phase' => GTM4WP_PHASE_EXPERIMENTAL
345
- ),
346
- GTM4WP_OPTION_INTEGRATE_WCEXCLUDESHIPPING => array(
347
- 'label' => __( 'Exclude shipping from revenue', 'duracelltomi-google-tag-manager' ),
348
- 'description' => __( 'Enable this to exclude shipping costs from the revenue variable while generating the purchase data', 'duracelltomi-google-tag-manager' ),
349
- 'phase' => GTM4WP_PHASE_STABLE
350
- ),
351
- GTM4WP_OPTION_INTEGRATE_WCREMARKETING => array(
352
- 'label' => __( 'Google Ads Remarketing', 'duracelltomi-google-tag-manager' ),
353
- 'description' => __( 'Enable this to add Google Ads dynamic remarketing variables to the dataLayer', 'duracelltomi-google-tag-manager' ),
354
- 'phase' => GTM4WP_PHASE_DEPRECATED
355
- ),
356
- GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL => array(
357
- 'label' => __( 'Google Ads Business Vertical', 'duracelltomi-google-tag-manager' ),
358
- 'description' => sprintf(
359
- __(
360
- 'Select which vertical category to add next to each product to utilize dynamic remarketing for Google Ads.'.
361
- '<br>Use the plugin\'s <a href="%s" target="_blank" rel="noopener">official setup guide for dynamic remarketing</a> '.
362
- 'to setup your Google Tag Manager container.'
363
- , 'duracelltomi-google-tag-manager' )
364
- , 'https://gtm4wp.com/how-to-articles/how-to-setup-dynamic-remarketing-in-google-ads-adwords'),
365
- 'phase' => GTM4WP_PHASE_STABLE
366
- ),
367
- GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX => array(
368
- 'label' => __( 'Product ID prefix', 'duracelltomi-google-tag-manager' ),
369
- 'description' => __( "Some product feed generator plugins prefix product IDs with a fixed text like 'woocommerce_gpf'. You can enter this prefix here so that tags in your website include this prefix as well.", 'duracelltomi-google-tag-manager' ),
370
- 'phase' => GTM4WP_PHASE_STABLE
371
- ),
372
- GTM4WP_OPTION_INTEGRATE_WCUSESKU => array(
373
- 'label' => __( 'Use SKU instead of ID', 'duracelltomi-google-tag-manager' ),
374
- 'description' => __( 'Check this to use product SKU instead of the ID of the products for remarketing and ecommerce tracking. Will fallback to ID if no SKU is set.', 'duracelltomi-google-tag-manager' ),
375
- 'phase' => GTM4WP_PHASE_STABLE
376
- ),
377
- GTM4WP_OPTION_INTEGRATE_WCNOORDERTRACKEDFLAG => array(
378
- 'label' => __( 'Do not flag orders as being tracked', 'duracelltomi-google-tag-manager' ),
379
- 'description' => __(
380
- 'Turn this on to prevent the plugin to flag orders as being already tracked.<br /><br />'.
381
- 'Leaving this unchecked ensures that no order data will be tracked multiple times '.
382
- 'in any ad or measurement system.<br />'.
383
- 'Please only turn this feature on if you really need it!',
384
- 'duracelltomi-google-tag-manager'
385
- ),
386
- 'phase' => GTM4WP_PHASE_STABLE
387
- ),
388
-
389
- GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS => array(
390
- 'label' => __( 'Google Optimize container ID list', 'duracelltomi-google-tag-manager' ),
391
- 'description' => sprintf(
392
- __(
393
- 'Enter a comma separated list of Google Optimize container IDs that you would like to use on your site.<br />' .
394
- 'This plugin will add the <a href="%s">page-hiding snippet</a> to your pages.<br />',
395
- 'duracelltomi-google-tag-manager'
396
- ),
397
- 'https://developers.google.com/optimize/#the_page-hiding_snippet_code'
398
- ) .
399
- '<br /><span class="goid_validation_error">' . __( 'This does not seems to be a valid Google Optimize ID! Valid format: GTM-XXXXXX or OPT-XXXXXX where X can be numbers and capital letters. Use comma without any space (,) to enter multpile IDs.', 'duracelltomi-google-tag-manager' ) . '</span>',
400
- 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
401
- ),
402
- GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT => array(
403
- 'label' => __( 'Google Optimize page-hiding timeout', 'duracelltomi-google-tag-manager' ),
404
- 'description' => __( 'Enter here the amount of time in milliseconds that the page-hiding snippet should wait before page content gets visible even if Google Optimize has not been completely loaded yet.', 'duracelltomi-google-tag-manager' ),
405
- 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
406
- ),
407
-
408
- GTM4WP_OPTION_INTEGRATE_AMPID => array(
409
- 'label' => __( "Google Tag Manager 'AMP' Container ID", 'duracelltomi-google-tag-manager' ),
410
- 'description' => sprintf( __( 'Enter a comma separated list of Google Tag Manager container IDs that you would like to use on your site. This plugin will add the <a href="%s">AMP GTM snippet</a> to your AMP pages.', 'duracelltomi-google-tag-manager' ), 'https://support.google.com/tagmanager/answer/6103696?hl=en' ) .
411
- '<br /><span class="ampid_validation_error">' . __( 'This does not seems to be a valid Google Tag Manager Container ID! Valid format: GTM-XXXXXX where X can be numbers and capital letters. Use comma without any space (,) to enter multpile IDs.', 'duracelltomi-google-tag-manager' ) . '</span>',
412
- 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
413
- 'plugintocheck' => 'amp/amp.php',
414
- ),
415
-
416
- GTM4WP_OPTION_INTEGRATE_COOKIEBOT => array(
417
- 'label' => __( 'Cookiebot auto blocking', 'duracelltomi-google-tag-manager' ),
418
- 'description' => sprintf( __( 'Enable this checkbox if you wish to use the <a href="%s" target="_blank" rel="noopener">automatic cookie blocking mode of Cookiebot with Google Tag Manager</a>.', 'duracelltomi-google-tag-manager' ), 'https://support.cookiebot.com/hc/en-us/articles/360009192739-Google-Tag-Manager-and-Automatic-cookie-blocking' ),
419
- 'phase' => GTM4WP_PHASE_STABLE
420
- ),
421
- );
422
-
423
- $GLOBALS['gtm4wp_advancedfieldtexts'] = array(
424
- GTM4WP_OPTION_DATALAYER_NAME => array(
425
- 'label' => __( 'dataLayer variable name', 'duracelltomi-google-tag-manager' ),
426
- 'description' => __( 'In some cases you need to rename the dataLayer variable. You can enter your name here. Leave black for default name: dataLayer', 'duracelltomi-google-tag-manager' ),
427
- 'phase' => GTM4WP_PHASE_STABLE,
428
- ),
429
- GTM4WP_OPTION_ENV_GTM_AUTH => array(
430
- 'label' => __( 'Environment gtm_auth parameter', 'duracelltomi-google-tag-manager' ),
431
- 'description' => __( 'Enter the gtm_auth parameter of the Google Tag Manager environment that has to be activated on this site. Both gtm_auth and gtm_preview parameters are required to activate the desired environment.', 'duracelltomi-google-tag-manager' ),
432
- 'phase' => GTM4WP_PHASE_STABLE,
433
- ),
434
- GTM4WP_OPTION_ENV_GTM_PREVIEW => array(
435
- 'label' => __( 'Environment gtm_preview parameter', 'duracelltomi-google-tag-manager' ),
436
- 'description' => __( 'Enter the gtm_auth parameter of the Google Tag Manager environment that has to be activated on this site. Both gtm_auth and gtm_preview parameters are required to activate the desired environment.', 'duracelltomi-google-tag-manager' ),
437
- 'phase' => GTM4WP_PHASE_STABLE,
438
- ),
439
- GTM4WP_OPTION_DONOTTRACK => array(
440
- 'label' => __( "Include browser 'Do not track' setting", 'duracelltomi-google-tag-manager' ),
441
- 'description' => __( 'Add into the data layer whether the user has asked not to track any website interaction. You may want to respect this and disable all tags if this variable is set in the data layer.', 'duracelltomi-google-tag-manager' ),
442
- 'phase' => GTM4WP_PHASE_STABLE,
443
- ),
444
- GTM4WP_OPTION_LOADEARLY => array(
445
- 'label' => __( 'Load GTM container as early as possible', 'duracelltomi-google-tag-manager' ),
446
- 'description' => __( "Turning on this option will load your Google Tag Manager container as early as possible during page load. This can cause issues if you are using jQuery in your custom HTML tags that fire on 'Page View' events.", 'duracelltomi-google-tag-manager' ),
447
- 'phase' => GTM4WP_PHASE_STABLE,
448
- ),
449
- GTM4WP_OPTION_GTMDOMAIN => array(
450
- 'label' => __( 'Container domain name', 'duracelltomi-google-tag-manager' ),
451
- 'description' => __( "Enter your custom domain name if you are using a server side GTM container for tracking. Do not include https:// prefix. Leave this blank to use www.googletagmanager.com", 'duracelltomi-google-tag-manager' ),
452
- 'phase' => GTM4WP_PHASE_STABLE,
453
- ),
454
- GTM4WP_OPTION_NOGTMFORLOGGEDIN => array(
455
- 'label' => __( 'User roles to exclude', 'duracelltomi-google-tag-manager' ),
456
- 'description' => __( "Do not load GTM container on the frontend if role of the logged in user is any of this", 'duracelltomi-google-tag-manager' ),
457
- 'phase' => GTM4WP_PHASE_STABLE,
458
- )
459
- );
460
-
461
- function gtm4wp_admin_output_section( $args ) {
462
- echo '<span class="tabinfo">';
463
-
464
- switch ( $args['id'] ) {
465
- case GTM4WP_ADMIN_GROUP_GENERAL: {
466
- _e( 'This plugin is intended to be used by IT girls&guys and marketing staff. Please be sure you read the <a href="https://developers.google.com/tag-manager/" target="_blank" rel="noopener">Google Tag Manager Help Center</a> before you start using this plugin.<br /><br />', 'duracelltomi-google-tag-manager' );
467
-
468
- break;
469
- }
470
-
471
- case GTM4WP_ADMIN_GROUP_INCLUDES: {
472
- _e( 'Here you can check what data is needed to be included in the dataLayer to be able to access them in Google Tag Manager', 'duracelltomi-google-tag-manager' );
473
- echo '<br />';
474
- printf( __( '* Browser, OS and Device data is provided using <a href="%s">WhichBrowser</a> library.', 'duracelltomi-google-tag-manager' ), 'http://whichbrowser.net/' );
475
-
476
- break;
477
- }
478
-
479
- case GTM4WP_ADMIN_GROUP_EVENTS: {
480
- _e( 'Fire tags in Google Tag Manager on special events on your website', 'duracelltomi-google-tag-manager' );
481
-
482
- break;
483
- }
484
-
485
- case GTM4WP_ADMIN_GROUP_SCROLLER: {
486
- _e( 'Fire tags based on how the visitor scrolls through your page.', 'duracelltomi-google-tag-manager' );
487
- echo '<br />';
488
- printf( __( 'Based on the script originaly posted to <a href="%s">Analytics Talk</a>', 'duracelltomi-google-tag-manager' ), 'http://cutroni.com/blog/2012/02/21/advanced-content-tracking-with-google-analytics-part-1/' );
489
-
490
- break;
491
- }
492
-
493
- case GTM4WP_ADMIN_GROUP_BLACKLIST: {
494
- _e( 'Here you can control which types of tags, triggers and variables can be executed on your site regardless of what tags are included in your container on the Google Tag Manager site. Use this to increase security!', 'duracelltomi-google-tag-manager' );
495
- echo '<br />';
496
- _e( 'Do not modify if you do not know what to do, since it can cause issues with your tag deployment!', 'duracelltomi-google-tag-manager' );
497
- echo '<br />';
498
- _e( 'For example blacklisting everything and only whitelisting the Google Analytics tag without whitelisting the URL variable type will cause your Google Analytics tags to be blocked anyway since the attached triggers (Page View) can not fire!', 'duracelltomi-google-tag-manager' );
499
-
500
- break;
501
- }
502
-
503
- case GTM4WP_ADMIN_GROUP_INTEGRATION: {
504
- _e( 'Google Tag Manager for WordPress can integrate with several popular plugins. Please check the plugins you would like to integrate with:', 'duracelltomi-google-tag-manager' );
505
-
506
- break;
507
- }
508
-
509
- case GTM4WP_ADMIN_GROUP_ADVANCED: {
510
- _e( 'You usually do not need to modify thoose settings. Please be carefull while hacking here.', 'duracelltomi-google-tag-manager' );
511
-
512
- break;
513
- }
514
-
515
- case GTM4WP_ADMIN_GROUP_CREDITS: {
516
- _e( 'Some info about the author of this plugin', 'duracelltomi-google-tag-manager' );
517
-
518
- break;
519
- }
520
- } // end switch
521
-
522
- echo '</span>';
523
- }
524
-
525
- function gtm4wp_admin_output_field( $args ) {
526
- global $gtm4wp_options, $gtm4wp_business_verticals;
527
-
528
- switch ( $args['label_for'] ) {
529
- case GTM4WP_ADMIN_GROUP_GTMID: {
530
- if ( defined( 'GTM4WP_HARDCODED_GTM_ID' ) ) {
531
- $_gtm_id_value = GTM4WP_HARDCODED_GTM_ID;
532
- $_input_readonly = ' readonly="readonly"';
533
- $_warning_after = '<br /><span class="gtm_wpconfig_set">WARNING! Container ID was set and fixed in wp-config.php. If you wish to change this value, please edit your wp-config.php and change the container ID or remove the GTM4WP_HARDCODED_GTM_ID constant!</span>';
534
- } else {
535
- $_gtm_id_value = $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ];
536
- $_input_readonly = '';
537
- $_warning_after = '';
538
- }
539
-
540
- echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_CODE . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_CODE . ']" value="' . $_gtm_id_value . '" ' . $_input_readonly . '/><br />' . $args['description'];
541
- echo $_warning_after;
542
- echo '<br /><span class="gtmid_validation_error">' . __( 'This does not seems to be a valid Google Tag Manager ID! Valid format: GTM-XXXXX where X can be numbers and capital letters. Use comma without any space (,) to enter multpile container IDs.', 'duracelltomi-google-tag-manager' ) . '</span>';
543
-
544
- break;
545
- }
546
-
547
- case GTM4WP_ADMIN_GROUP_CONTAINERON: {
548
- echo $args['description'].'<br/><br/>';
549
- echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[container-on]_1" name="' . GTM4WP_OPTIONS . '[container-on]" value="1" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] != GTM4WP_PLACEMENT_OFF ? 'checked="checked"' : '' ) . '/> ' . __( 'On', 'duracelltomi-google-tag-manager' ) . '<br />';
550
- echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[container-on]_0" name="' . GTM4WP_OPTIONS . '[container-on]" value="0" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_OFF ? 'checked="checked"' : '' ) . '/> ' . __( 'Off', 'duracelltomi-google-tag-manager' ) . '<br />';
551
-
552
- break;
553
- }
554
-
555
- case GTM4WP_ADMIN_GROUP_COMPATMODE: {
556
- echo $args['description'].'<br/><br/>';
557
- echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[compat-mode]_' . GTM4WP_PLACEMENT_BODYOPEN_AUTO . '" name="' . GTM4WP_OPTIONS . '[compat-mode]" value="' . GTM4WP_PLACEMENT_BODYOPEN_AUTO . '" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_BODYOPEN_AUTO || $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_OFF ? 'checked="checked"' : '' ) . '/> ' . __( 'Off (no tweak, right placement)', 'duracelltomi-google-tag-manager' ) . '<br />';
558
- echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[compat-mode]_' . GTM4WP_PLACEMENT_FOOTER . '" name="' . GTM4WP_OPTIONS . '[compat-mode]" value="' . GTM4WP_PLACEMENT_FOOTER . '" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_FOOTER ? 'checked="checked"' : '' ) . '/> ' . __( 'Footer of the page (not recommended by Google, Search Console verification will not work)', 'duracelltomi-google-tag-manager' ) . '<br />';
559
- echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[compat-mode]_' . GTM4WP_PLACEMENT_BODYOPEN . '" name="' . GTM4WP_OPTIONS . '[compat-mode]" value="' . GTM4WP_PLACEMENT_BODYOPEN . '" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_BODYOPEN ? 'checked="checked"' : '' ) . '/> ' . __( 'Manually coded (needs tweak in your template)', 'duracelltomi-google-tag-manager' ) . '<br />';
560
-
561
- break;
562
- }
563
-
564
- case GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']': {
565
- echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']" value="' . $gtm4wp_options[ GTM4WP_OPTION_DATALAYER_NAME ] . '" /><br />' . $args['description'];
566
- echo '<br /><span class="datalayername_validation_error">' . __( 'This does not seems to be a valid JavaScript variable name! Please check and try again', 'duracelltomi-google-tag-manager' ) . '</span>';
567
-
568
- break;
569
- }
570
-
571
- case GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']': {
572
- if ( defined( 'GTM4WP_HARDCODED_GTM_ENV_AUTH' ) ) {
573
- $_gtm_auth_value = GTM4WP_HARDCODED_GTM_ENV_AUTH;
574
- $_input_readonly = ' readonly="readonly"';
575
- $_warning_after = '<br /><span class="gtm_wpconfig_set">WARNING! Environment auth parameter was set and fixed in wp-config.php. If you wish to change this value, please edit your wp-config.php and change the parameter value or remove the GTM4WP_HARDCODED_GTM_ENV_AUTH constant!</span>';
576
- } else {
577
- $_gtm_auth_value = $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ];
578
- $_input_readonly = '';
579
- $_warning_after = '';
580
- }
581
-
582
- echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']" value="' . $_gtm_auth_value . '" ' . $_input_readonly . '/><br />' . $args['description'];
583
- echo $_warning_after;
584
- echo '<br /><span class="gtmauth_validation_error">' . __( 'This does not seems to be a valid gtm_auth parameter! It should only contain letters, number and the &quot;-&quot; character. Please check and try again', 'duracelltomi-google-tag-manager' ) . '</span>';
585
-
586
- break;
587
- }
588
-
589
- case GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']': {
590
- if ( defined( 'GTM4WP_HARDCODED_GTM_ENV_PREVIEW' ) ) {
591
- $_gtm_preview_value = GTM4WP_HARDCODED_GTM_ENV_PREVIEW;
592
- $_input_readonly = ' readonly="readonly"';
593
- $_warning_after = '<br /><span class="gtm_wpconfig_set">WARNING! Environment preview parameter was set and fixed in wp-config.php. If you wish to change this value, please edit your wp-config.php and change the parameter value or remove the GTM4WP_HARDCODED_GTM_ENV_PREVIEW constant!</span>';
594
- } else {
595
- $_gtm_preview_value = $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ];
596
- $_input_readonly = '';
597
- $_warning_after = '';
598
- }
599
-
600
- echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']" value="' . $_gtm_preview_value . '" ' . $_input_readonly . '/><br />' . $args['description'];
601
- echo $_warning_after;
602
- echo '<br /><span class="gtmpreview_validation_error">' . __( 'This does not seems to be a valid gtm_preview parameter! It should have the format &quot;env-NN&quot; where NN is an integer number. Please check and try again', 'duracelltomi-google-tag-manager' ) . '</span>';
603
-
604
- break;
605
- }
606
-
607
- case GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']': {
608
- echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']_0" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']" value="0" ' . ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] == 0 ? 'checked="checked"' : '' ) . '/> ' . __( 'Disable feature: control everything on Google Tag Manager interface', 'duracelltomi-google-tag-manager' ) . '<br />';
609
- echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']_1" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']" value="1" ' . ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] == 1 ? 'checked="checked"' : '' ) . '/> ' . __( 'Allow all, except the checked items on all blacklist tabs (blacklist)', 'duracelltomi-google-tag-manager' ) . '<br />';
610
- echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']_2" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']" value="2" ' . ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] == 2 ? 'checked="checked"' : '' ) . '/> ' . __( 'Block all, except the checked items on all blacklist tabs (whitelist)', 'duracelltomi-google-tag-manager' ) . '<br />';
611
- echo $args['description'];
612
-
613
- break;
614
- }
615
-
616
- case GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']': {
617
- echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']_0" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']" value="0" ' . ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHERUNITS ] == 0 ? 'checked="checked"' : '' ) . '/> ' . __( 'Celsius', 'duracelltomi-google-tag-manager' ) . '<br />';
618
- echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']_1" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']" value="1" ' . ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHERUNITS ] == 1 ? 'checked="checked"' : '' ) . '/> ' . __( 'Fahrenheit', 'duracelltomi-google-tag-manager' ) . '<br />';
619
- echo $args['description'];
620
-
621
- break;
622
- }
623
-
624
- case GTM4WP_ADMIN_GROUP_INFO: {
625
- echo $args['description'];
626
-
627
- break;
628
- }
629
-
630
- case GTM4WP_OPTIONS . "[" . GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY . "]": {
631
- echo '<select id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY . ']">';
632
- echo '<option value="">(not set)</option>';
633
-
634
- $gtm4wp_taxonomies = get_taxonomies(array(
635
- "show_ui" => true,
636
- "public" => true,
637
- "_builtin" => false
638
- ), "object", "and");
639
-
640
- foreach( $gtm4wp_taxonomies as $onetaxonomy ) {
641
- echo '<option value="' . $onetaxonomy->name . '"' . ( $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY] === $onetaxonomy->name ? ' selected="selected"' : '' ) . '>' . $onetaxonomy->label . '</option>';
642
- }
643
-
644
- echo '</select>';
645
-
646
- break;
647
- }
648
-
649
- case GTM4WP_OPTIONS . "[" . GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL . "]": {
650
- echo '<select id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL . ']">';
651
-
652
- foreach( $gtm4wp_business_verticals as $vertical_id => $vertical_display_name ) {
653
- echo '<option value="' . $vertical_id . '"' . ( $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL] === $vertical_id ? ' selected="selected"' : '' ) . '>' . $vertical_display_name . '</option>';
654
- }
655
-
656
- echo '</select><br>' . $args['description'];
657
-
658
- break;
659
- }
660
-
661
- case GTM4WP_OPTIONS . "[" . GTM4WP_OPTION_NOGTMFORLOGGEDIN . "]": {
662
- $roles = get_editable_roles();
663
-
664
- echo $args['description'].'<br/><br/>';
665
-
666
- $saved_roles = explode(",", $gtm4wp_options[GTM4WP_OPTION_NOGTMFORLOGGEDIN]);
667
-
668
- foreach($roles as $role_id => $role_info) {
669
- $role_name = translate_user_role( $role_info['name'] );
670
- echo '<input type="checkbox" id="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']_' . $role_id . '" name="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . '][]" value="' . $role_id . '"' . ( in_array( $role_id, $saved_roles ) ? ' checked="checked"' : '' ) . '><label for="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']_' . $role_id . '">' . $role_name . '</label><br/>';
671
- }
672
-
673
- break;
674
- }
675
-
676
- default: {
677
- if ( preg_match( '/' . GTM4WP_OPTIONS . "\\[blacklist\\-[^\\]]+\\]/i", $args['label_for'] ) ) {
678
- if ( 'blacklist-sandboxed' == $args['entityid'] ) {
679
- echo '<input type="checkbox" id="' . $args['label_for'] . '" name="' . $args['label_for'] . '" value="1" ' . checked( 1, $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_SANDBOXED ], false ) . ' /><br />' . $args['description'];
680
- } else {
681
- echo '<input type="checkbox" id="' . $args['label_for'] . '" name="' . $args['label_for'] . '" value="1" ' . checked( 1, in_array( $args['entityid'], $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_STATUS ] ), false ) . ' /><br />' . $args['description'];
682
- }
683
- } else {
684
- $optval = $gtm4wp_options[ $args['optionfieldid'] ];
685
-
686
- switch ( gettype( $optval ) ) {
687
- case 'boolean': {
688
- echo '<input type="checkbox" id="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" name="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" value="1" ' . checked( 1, $optval, false ) . ' /><br />' . $args['description'];
689
-
690
- if ( isset( $args['plugintocheck'] ) && ( $args['plugintocheck'] != '' ) ) {
691
- if ( is_plugin_active( $args['plugintocheck'] ) ) {
692
- echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-active">active</strong>, it is strongly recommended to enable this integration!', 'duracelltomi-google-tag-manager' );
693
- } else {
694
- echo '<br />' . __( 'This plugin (' . $args['plugintocheck'] . ') is <strong class="gtm4wp-plugin-not-active">not active</strong>, enabling this integration could cause issues on frontend!', 'duracelltomi-google-tag-manager' );
695
- }
696
- }
697
-
698
- break;
699
- }
700
-
701
- case 'integer': {
702
- echo '<input type="number" step="1" min="0" class="small-text" id="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" name="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" value="' . esc_attr( $optval ) . '" /><br />' . $args['description'];
703
-
704
- if ( isset( $args['plugintocheck'] ) && ( $args['plugintocheck'] != '' ) ) {
705
- if ( is_plugin_active( $args['plugintocheck'] ) ) {
706
- echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-active">active</strong>, it is strongly recommended to enable this integration!', 'duracelltomi-google-tag-manager' );
707
- } else {
708
- echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-not-active">not active</strong>, enabling this integration could cause issues on frontend!', 'duracelltomi-google-tag-manager' );
709
- }
710
- }
711
-
712
- break;
713
- }
714
-
715
- default : {
716
- echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" name="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" value="' . esc_attr( $optval ) . '" size="80" /><br />' . $args['description'];
717
-
718
- if ( isset( $args['plugintocheck'] ) && ( $args['plugintocheck'] != '' ) ) {
719
- if ( is_plugin_active( $args['plugintocheck'] ) ) {
720
- echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-active">active</strong>, it is strongly recommended to enable this integration!', 'duracelltomi-google-tag-manager' );
721
- } else {
722
- echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-not-active">not active</strong>, enabling this integration could cause issues on frontend!', 'duracelltomi-google-tag-manager' );
723
- }
724
- }
725
- }
726
- } // end switch gettype optval
727
- }
728
- }
729
- } // end switch
730
- }
731
-
732
- function gtm4wp_sanitize_options( $options ) {
733
- global $wpdb, $gtm4wp_entity_ids;
734
-
735
- $output = gtm4wp_reload_options();
736
-
737
- foreach ( $output as $optionname => $optionvalue ) {
738
- if ( isset( $options[ $optionname ] ) ) {
739
- $newoptionvalue = $options[ $optionname ];
740
- } else {
741
- $newoptionvalue = '';
742
- }
743
-
744
- // "include" settings
745
- if ( substr( $optionname, 0, 8 ) == 'include-' ) {
746
- $output[ $optionname ] = (bool) $newoptionvalue;
747
-
748
- // dataLayer events
749
- } elseif ( substr( $optionname, 0, 6 ) == 'event-' ) {
750
- $output[ $optionname ] = (bool) $newoptionvalue;
751
-
752
- // clear oembed transients when feature is enabled because we need to hook into the oembed process to enable some 3rd party APIs
753
- if ( $output[ $optionname ] && ! $optionvalue ) {
754
- if ( GTM4WP_OPTION_EVENTS_YOUTUBE == $optionname ) {
755
- $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_value LIKE '%youtube.com%' AND meta_key LIKE '_oembed_%'" );
756
- }
757
-
758
- if ( GTM4WP_OPTION_EVENTS_VIMEO == $optionname ) {
759
- $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_value LIKE '%vimeo.com%' AND meta_key LIKE '_oembed_%'" );
760
- }
761
- }
762
-
763
- // blacklist / whitelist entities
764
- } elseif ( substr( $optionname, 0, 10 ) == 'blacklist-' ) {
765
- if ( GTM4WP_OPTION_BLACKLIST_ENABLE === $optionname ) {
766
- $output[ $optionname ] = (int) $options[ GTM4WP_OPTION_BLACKLIST_ENABLE ];
767
- } else if ( GTM4WP_OPTION_BLACKLIST_SANDBOXED == $optionname ) {
768
- $output[ $optionname ] = (bool) $newoptionvalue;
769
- } else if ( GTM4WP_OPTION_BLACKLIST_STATUS == $optionname ) {
770
- $selected_blacklist_entities = array();
771
-
772
- foreach( $gtm4wp_entity_ids as $gtm_entity_group_id => $gtm_entity_group_list ) {
773
- foreach( $gtm_entity_group_list as $gtm_entity_id => $gtm_entity_label ) {
774
- $entity_option_id = 'blacklist-' . $gtm_entity_group_id . '-' . $gtm_entity_id;
775
- if ( array_key_exists( $entity_option_id, $options ) ) {
776
- $newoptionvalue = (bool) $options[ $entity_option_id ];
777
- if ( $newoptionvalue ) {
778
- $selected_blacklist_entities[] = $gtm_entity_id;
779
- }
780
- }
781
- }
782
- }
783
-
784
- $output[ $optionname ] = implode( ',', $selected_blacklist_entities );
785
- }
786
-
787
- // Google Optimize settings
788
- } elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS ) {
789
- $_goid_val = trim( $newoptionvalue );
790
- if ( '' == $_goid_val ) {
791
- $_goid_list = array();
792
- } else {
793
- $_goid_list = explode( ',', $_goid_val );
794
- }
795
- $_goid_haserror = false;
796
-
797
- foreach ( $_goid_list as $one_go_id ) {
798
- $_goid_haserror = $_goid_haserror || ! preg_match( '/^(GTM|OPT)-[A-Z0-9]+$/', $one_go_id );
799
- }
800
-
801
- if ( $_goid_haserror && ( count( $_goid_list ) > 0 ) ) {
802
- add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS . ']', __( 'Invalid Google Optimize ID. Valid ID format: GTM-XXXXX or OPT-XXXXX. Use comma without additional space (,) to enter more than one ID.', 'duracelltomi-google-tag-manager' ) );
803
- } else {
804
- $output[ $optionname ] = $newoptionvalue;
805
- }
806
- } elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT ) {
807
- $output[ $optionname ] = (int) $newoptionvalue;
808
-
809
- } elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION ) {
810
- $output[ $optionname ] = (int) $newoptionvalue;
811
-
812
- } elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_WCORDERMAXAGE ) {
813
- $output[ $optionname ] = (int) $newoptionvalue;
814
-
815
- }elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX ) {
816
- $output[ $optionname ] = trim( (string) $newoptionvalue );
817
-
818
- } else if ( $optionname == GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ) {
819
- $output[$optionname] = trim( (string) $newoptionvalue );
820
-
821
- } else if ( $optionname == GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL ) {
822
- $output[$optionname] = trim( (string) $newoptionvalue );
823
-
824
- } else if ( $optionname == GTM4WP_OPTION_GTMDOMAIN ) {
825
- // for PHP 7- compatibility
826
- if ( !defined("FILTER_FLAG_HOSTNAME") ) {
827
- define( "FILTER_FLAG_HOSTNAME", 0 );
828
- }
829
-
830
- // remove https:// prefix if used
831
- $newoptionvalue = str_replace( 'https://', '', $newoptionvalue );
832
-
833
- $newoptionvalue = filter_var( $newoptionvalue, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME );
834
- if ( $newoptionvalue === false ) {
835
- $newoptionvalue = '';
836
- }
837
- $output[$optionname] = trim( (string) $newoptionvalue );
838
-
839
- // Accelerated Mobile Pages settings
840
- } elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_AMPID ) {
841
- $_ampid_val = trim( $newoptionvalue );
842
- if ( '' == $_ampid_val ) {
843
- $_ampid_list = array();
844
- } else {
845
- $_ampid_list = explode( ',', $_ampid_val );
846
- }
847
- $_ampid_haserror = false;
848
-
849
- foreach ( $_ampid_list as $one_amp_id ) {
850
- $_ampid_haserror = $_ampid_haserror || ! preg_match( '/^GTM-[A-Z0-9]+$/', $one_amp_id );
851
- }
852
-
853
- if ( $_ampid_haserror && ( count( $_ampid_list ) > 0 ) ) {
854
- add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_AMPID . ']', __( 'Invalid AMP Google Tag Manager Container ID. Valid ID format: GTM-XXXXX. Use comma without additional space (,) to enter more than one ID.', 'duracelltomi-google-tag-manager' ) );
855
- } else {
856
- $output[ $optionname ] = $newoptionvalue;
857
- }
858
-
859
- // integrations
860
- } elseif ( substr( $optionname, 0, 10 ) == 'integrate-' ) {
861
- $output[ $optionname ] = (bool) $newoptionvalue;
862
-
863
- // GTM code or dataLayer variable name
864
- } elseif ( ( $optionname == GTM4WP_OPTION_GTM_CODE ) || ( $optionname == GTM4WP_OPTION_DATALAYER_NAME ) || ( $optionname == GTM4WP_OPTION_ENV_GTM_AUTH ) || ( $optionname == GTM4WP_OPTION_ENV_GTM_PREVIEW ) ) {
865
- $newoptionvalue = trim( $newoptionvalue );
866
-
867
- if ( $optionname == GTM4WP_OPTION_GTM_CODE ) {
868
- $_gtmid_list = explode( ',', $newoptionvalue );
869
- $_gtmid_haserror = false;
870
-
871
- foreach ( $_gtmid_list as $one_gtm_id ) {
872
- $_gtmid_haserror = $_gtmid_haserror || ! preg_match( '/^GTM-[A-Z0-9]+$/', $one_gtm_id );
873
- }
874
-
875
- if ( $_gtmid_haserror ) {
876
- add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_CODE . ']', __( 'Invalid Google Tag Manager ID. Valid ID format: GTM-XXXXX. Use comma without additional space (,) to enter more than one container ID.', 'duracelltomi-google-tag-manager' ) );
877
- } else {
878
- $output[ $optionname ] = $newoptionvalue;
879
- }
880
- } elseif ( ( $optionname == GTM4WP_OPTION_DATALAYER_NAME ) && ( $newoptionvalue != '' ) && ( ! preg_match( '/^[a-zA-Z][a-zA-Z0-9_-]*$/', $newoptionvalue ) ) ) {
881
- add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']', __( "Invalid dataLayer variable name. Please start with a character from a-z or A-Z followed by characters from a-z, A-Z, 0-9 or '_' or '-'!", 'duracelltomi-google-tag-manager' ) );
882
-
883
- } elseif ( ( $optionname == GTM4WP_OPTION_ENV_GTM_AUTH ) && ( $newoptionvalue != '' ) && ( ! preg_match( '/^[a-zA-Z0-9-_]+$/', $newoptionvalue ) ) ) {
884
- add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']', __( "Invalid gtm_auth environment parameter value. It should only contain letters, numbers or the '-' and '_' characters.", 'duracelltomi-google-tag-manager' ) );
885
-
886
- } elseif ( ( $optionname == GTM4WP_OPTION_ENV_GTM_PREVIEW ) && ( $newoptionvalue != '' ) && ( ! preg_match( '/^env-[0-9]+$/', $newoptionvalue ) ) ) {
887
- add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']', __( "Invalid gtm_preview environment parameter value. It should have the format 'env-NN' where NN is an integer number.", 'duracelltomi-google-tag-manager' ) );
888
-
889
- } else {
890
- $output[ $optionname ] = $newoptionvalue;
891
- }
892
-
893
- // GTM container ON/OFF + compat mode
894
- } elseif ( $optionname == GTM4WP_OPTION_GTM_PLACEMENT ) {
895
- $container_on_off = (bool) $options['container-on'];
896
- $container_compat = (int) $options['compat-mode'];
897
-
898
- if ( !$container_on_off ) {
899
- $output[ $optionname ] = GTM4WP_PLACEMENT_OFF;
900
- } else {
901
- if ( ( $container_compat < 0 ) || ( $container_compat > 2 ) ) {
902
- $container_compat = 2;
903
- }
904
-
905
- $output[ $optionname ] = $container_compat;
906
- }
907
-
908
- // scroll tracking content ID
909
- } elseif ( $optionname == GTM4WP_OPTION_SCROLLER_CONTENTID ) {
910
- $output[ $optionname ] = trim( str_replace( '#', '', $newoptionvalue ) );
911
-
912
- // do not output GTM container code for specific user roles
913
- } elseif ( $optionname == GTM4WP_OPTION_NOGTMFORLOGGEDIN ) {
914
- if ( is_array( $newoptionvalue ) ) {
915
- $output[ $optionname ] = implode(",", $newoptionvalue );
916
- } else {
917
- $output[ $optionname ] = '';
918
- }
919
-
920
- // anything else
921
- } else {
922
- switch ( gettype( $optionvalue ) ) {
923
- case 'boolean': {
924
- $output[ $optionname ] = (bool) $newoptionvalue;
925
-
926
- break;
927
- }
928
-
929
- case 'integer': {
930
- $output[ $optionname ] = (int) $newoptionvalue;
931
-
932
- break;
933
- }
934
-
935
- default: {
936
- $output[ $optionname ] = $newoptionvalue;
937
- }
938
- } // end switch
939
- }
940
- }
941
-
942
- return $output;
943
- }
944
-
945
- function gtm4wp_admin_init() {
946
- global $gtm4wp_includefieldtexts, $gtm4wp_eventfieldtexts, $gtm4wp_integratefieldtexts, $gtm4wp_scrollerfieldtexts,
947
- $gtm4wp_advancedfieldtexts, $gtm4wp_entity_ids;
948
-
949
- register_setting( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS, 'gtm4wp_sanitize_options' );
950
-
951
- add_settings_section(
952
- GTM4WP_ADMIN_GROUP_GENERAL,
953
- __( 'General', 'duracelltomi-google-tag-manager' ),
954
- 'gtm4wp_admin_output_section',
955
- GTM4WP_ADMINSLUG
956
- );
957
-
958
- add_settings_field(
959
- GTM4WP_ADMIN_GROUP_GTMID,
960
- __( 'Google Tag Manager ID', 'duracelltomi-google-tag-manager' ),
961
- 'gtm4wp_admin_output_field',
962
- GTM4WP_ADMINSLUG,
963
- GTM4WP_ADMIN_GROUP_GENERAL,
964
- array(
965
- 'label_for' => GTM4WP_ADMIN_GROUP_GTMID,
966
- 'description' => __( 'Enter your Google Tag Manager ID here. Use comma without space (,) to enter multiple IDs.', 'duracelltomi-google-tag-manager' ),
967
- )
968
- );
969
-
970
- add_settings_field(
971
- GTM4WP_ADMIN_GROUP_CONTAINERON,
972
- __( 'Container code ON/OFF', 'duracelltomi-google-tag-manager' ),
973
- 'gtm4wp_admin_output_field',
974
- GTM4WP_ADMINSLUG,
975
- GTM4WP_ADMIN_GROUP_GENERAL,
976
- array(
977
- 'label_for' => GTM4WP_ADMIN_GROUP_CONTAINERON,
978
- 'description' => __( "Turning OFF the Google Tag Manager container itself will remove both the head and the body part of the container code but leave data layer codes working.<br/>This should be only used in specific cases where you need to place the container code manually or using another tool.", 'duracelltomi-google-tag-manager' ),
979
- )
980
- );
981
-
982
- add_settings_field(
983
- GTM4WP_ADMIN_GROUP_COMPATMODE,
984
- __( 'Container code compatibility mode', 'duracelltomi-google-tag-manager' ),
985
- 'gtm4wp_admin_output_field',
986
- GTM4WP_ADMINSLUG,
987
- GTM4WP_ADMIN_GROUP_GENERAL,
988
- array(
989
- 'label_for' => GTM4WP_ADMIN_GROUP_COMPATMODE,
990
- 'description' => __(
991
- 'Compatibility mode decides where to put the second, so called <code>&lt;noscript&gt;</code> or <code>&lt;iframe&gt;</code> part of the GTM container code.<br />'.
992
- 'This code is usually only executed if your visitor has disabled JavaScript for some reason.<br/>'.
993
- 'It is also mandatory in order to verify your site in Google Search Console using the GTM method.<br/>'.
994
- 'The main GTM container code will be placed into the <code>&lt;head&gt;</code> section of your webpages anyway (where it belongs to).<br/><br/>'.
995
- 'If you select "Manually coded", you need to edit your template files and add the following line just after the opening <code>&lt;body&gt;</code> tag:<br />'.
996
- "<code>&lt;?php if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); } ?&gt;</code>",
997
- 'duracelltomi-google-tag-manager'
998
- ),
999
- )
1000
- );
1001
-
1002
- add_settings_section(
1003
- GTM4WP_ADMIN_GROUP_INCLUDES,
1004
- __( 'Basic data', 'duracelltomi-google-tag-manager' ),
1005
- 'gtm4wp_admin_output_section',
1006
- GTM4WP_ADMINSLUG
1007
- );
1008
-
1009
- foreach ( $gtm4wp_includefieldtexts as $fieldid => $fielddata ) {
1010
- $phase = isset( $fielddata['phase'] ) ? $fielddata['phase'] : GTM4WP_PHASE_STABLE;
1011
-
1012
- add_settings_field(
1013
- 'gtm4wp-admin-' . $fieldid . '-id',
1014
- $fielddata['label'] . '<span class="' . $phase . '"></span>',
1015
- 'gtm4wp_admin_output_field',
1016
- GTM4WP_ADMINSLUG,
1017
- GTM4WP_ADMIN_GROUP_INCLUDES,
1018
- array(
1019
- 'label_for' => 'gtm4wp-options[' . $fieldid . ']',
1020
- 'description' => $fielddata['description'],
1021
- 'optionfieldid' => $fieldid,
1022
- )
1023
- );
1024
- }
1025
-
1026
- add_settings_section(
1027
- GTM4WP_ADMIN_GROUP_EVENTS,
1028
- __( 'Events', 'duracelltomi-google-tag-manager' ),
1029
- 'gtm4wp_admin_output_section',
1030
- GTM4WP_ADMINSLUG
1031
- );
1032
-
1033
- foreach ( $gtm4wp_eventfieldtexts as $fieldid => $fielddata ) {
1034
- $phase = isset( $fielddata['phase'] ) ? $fielddata['phase'] : GTM4WP_PHASE_STABLE;
1035
-
1036
- add_settings_field(
1037
- 'gtm4wp-admin-' . $fieldid . '-id',
1038
- $fielddata['label'] . '<span class="' . $phase . '"></span>',
1039
- 'gtm4wp_admin_output_field',
1040
- GTM4WP_ADMINSLUG,
1041
- GTM4WP_ADMIN_GROUP_EVENTS,
1042
- array(
1043
- 'label_for' => 'gtm4wp-options[' . $fieldid . ']',
1044
- 'description' => $fielddata['description'],
1045
- 'optionfieldid' => $fieldid,
1046
- )
1047
- );
1048
- }
1049
-
1050
- add_settings_section(
1051
- GTM4WP_ADMIN_GROUP_SCROLLER,
1052
- __( 'Scroll tracking', 'duracelltomi-google-tag-manager' ),
1053
- 'gtm4wp_admin_output_section',
1054
- GTM4WP_ADMINSLUG
1055
- );
1056
-
1057
- foreach ( $gtm4wp_scrollerfieldtexts as $fieldid => $fielddata ) {
1058
- $phase = isset( $fielddata['phase'] ) ? $fielddata['phase'] : GTM4WP_PHASE_STABLE;
1059
-
1060
- add_settings_field(
1061
- 'gtm4wp-admin-' . $fieldid . '-id',
1062
- $fielddata['label'] . '<span class="' . $phase . '"></span>',
1063
- 'gtm4wp_admin_output_field',
1064
- GTM4WP_ADMINSLUG,
1065
- GTM4WP_ADMIN_GROUP_SCROLLER,
1066
- array(
1067
- 'label_for' => 'gtm4wp-options[' . $fieldid . ']',
1068
- 'description' => $fielddata['description'],
1069
- 'optionfieldid' => $fieldid,
1070
- )
1071
- );
1072
- }
1073
-
1074
- add_settings_section(
1075
- GTM4WP_ADMIN_GROUP_BLACKLIST,
1076
- __( 'Security', 'duracelltomi-google-tag-manager' ),
1077
- 'gtm4wp_admin_output_section',
1078
- GTM4WP_ADMINSLUG
1079
- );
1080
-
1081
- add_settings_field(
1082
- GTM4WP_OPTION_BLACKLIST_ENABLE,
1083
- __( 'Enable blacklist/whitelist', 'duracelltomi-google-tag-manager' ),
1084
- 'gtm4wp_admin_output_field',
1085
- GTM4WP_ADMINSLUG,
1086
- GTM4WP_ADMIN_GROUP_BLACKLIST,
1087
- array(
1088
- 'label_for' => GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']',
1089
- 'description' => '',
1090
- 'optionsfieldid' => GTM4WP_OPTION_BLACKLIST_ENABLE
1091
- )
1092
- );
1093
-
1094
- add_settings_field(
1095
- GTM4WP_OPTION_BLACKLIST_SANDBOXED,
1096
- __( 'Custom tag/variable templates', 'duracelltomi-google-tag-manager' ),
1097
- 'gtm4wp_admin_output_field',
1098
- GTM4WP_ADMINSLUG,
1099
- GTM4WP_ADMIN_GROUP_BLACKLIST,
1100
- array(
1101
- 'label_for' => GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_SANDBOXED . ']',
1102
- 'description' => '',
1103
- 'entityid' => GTM4WP_OPTION_BLACKLIST_SANDBOXED
1104
- )
1105
- );
1106
-
1107
- foreach( $gtm4wp_entity_ids as $gtm_entity_group_id => $gtm_entity_group_list ) {
1108
- foreach( $gtm_entity_group_list as $gtm_entity_id => $gtm_entity_label ) {
1109
- add_settings_field(
1110
- 'gtm4wp-admin-blacklist-' . $gtm_entity_group_id . '-' . $gtm_entity_id . '-id',
1111
- $gtm_entity_label,
1112
- 'gtm4wp_admin_output_field',
1113
- GTM4WP_ADMINSLUG,
1114
- GTM4WP_ADMIN_GROUP_BLACKLIST,
1115
- array(
1116
- 'label_for' => 'gtm4wp-options[blacklist-' . $gtm_entity_group_id . '-' . $gtm_entity_id . ']',
1117
- 'description' => '',
1118
- 'entityid' => $gtm_entity_id,
1119
- )
1120
- );
1121
- }
1122
- }
1123
-
1124
- add_settings_section(
1125
- GTM4WP_ADMIN_GROUP_INTEGRATION,
1126
- __( 'Integration', 'duracelltomi-google-tag-manager' ),
1127
- 'gtm4wp_admin_output_section',
1128
- GTM4WP_ADMINSLUG
1129
- );
1130
-
1131
- foreach ( $gtm4wp_integratefieldtexts as $fieldid => $fielddata ) {
1132
- $phase = isset( $fielddata['phase'] ) ? $fielddata['phase'] : GTM4WP_PHASE_STABLE;
1133
-
1134
- add_settings_field(
1135
- 'gtm4wp-admin-' . $fieldid . '-id',
1136
- $fielddata['label'] . '<span class="' . $phase . '"></span>',
1137
- 'gtm4wp_admin_output_field',
1138
- GTM4WP_ADMINSLUG,
1139
- GTM4WP_ADMIN_GROUP_INTEGRATION,
1140
- array(
1141
- 'label_for' => 'gtm4wp-options[' . $fieldid . ']',
1142
- 'description' => $fielddata['description'],
1143
- 'optionfieldid' => $fieldid,
1144
- 'plugintocheck' => isset( $fielddata['plugintocheck'] ) ? $fielddata['plugintocheck'] : '',
1145
- )
1146
- );
1147
- }
1148
-
1149
- add_settings_section(
1150
- GTM4WP_ADMIN_GROUP_ADVANCED,
1151
- __( 'Advanced', 'duracelltomi-google-tag-manager' ),
1152
- 'gtm4wp_admin_output_section',
1153
- GTM4WP_ADMINSLUG
1154
- );
1155
-
1156
- foreach ( $gtm4wp_advancedfieldtexts as $fieldid => $fielddata ) {
1157
- $phase = isset( $fielddata['phase'] ) ? $fielddata['phase'] : GTM4WP_PHASE_STABLE;
1158
-
1159
- add_settings_field(
1160
- 'gtm4wp-admin-' . $fieldid . '-id',
1161
- $fielddata['label'] . '<span class="' . $phase . '"></span>',
1162
- 'gtm4wp_admin_output_field',
1163
- GTM4WP_ADMINSLUG,
1164
- GTM4WP_ADMIN_GROUP_ADVANCED,
1165
- array(
1166
- 'label_for' => 'gtm4wp-options[' . $fieldid . ']',
1167
- 'description' => $fielddata['description'],
1168
- 'optionfieldid' => $fieldid,
1169
- 'plugintocheck' => isset( $fielddata['plugintocheck'] ) ? $fielddata['plugintocheck'] : '',
1170
- )
1171
- );
1172
- }
1173
-
1174
- add_settings_section(
1175
- GTM4WP_ADMIN_GROUP_CREDITS,
1176
- __( 'Credits', 'duracelltomi-google-tag-manager' ),
1177
- 'gtm4wp_admin_output_section',
1178
- GTM4WP_ADMINSLUG
1179
- );
1180
-
1181
- add_settings_field(
1182
- GTM4WP_ADMIN_GROUP_INFO,
1183
- __( 'Author', 'duracelltomi-google-tag-manager' ),
1184
- 'gtm4wp_admin_output_field',
1185
- GTM4WP_ADMINSLUG,
1186
- GTM4WP_ADMIN_GROUP_CREDITS,
1187
- array(
1188
- 'label_for' => GTM4WP_ADMIN_GROUP_INFO,
1189
- 'description' => '<strong>Thomas Geiger</strong><br />
1190
- Website: <a href="https://gtm4wp.com/" target="_blank" rel="noopener">gtm4wp.com</a><br />
1191
- <a href="https://www.linkedin.com/in/duracelltomi" target="_blank" rel="noopener">Me on LinkedIn</a><br />
1192
- <a href="http://www.linkedin.com/company/jabjab-online-marketing-ltd" target="_blank" rel="noopener">JabJab Online Marketing on LinkedIn</a>',
1193
- )
1194
- );
1195
-
1196
- // apply oembed code changes on the admin as well since the oembed call on the admin is cached by WordPress into a transient
1197
- // that is applied on the frontend later
1198
- require_once dirname( __FILE__ ) . '/../integration/youtube.php';
1199
- require_once dirname( __FILE__ ) . '/../integration/vimeo.php';
1200
- require_once dirname( __FILE__ ) . '/../integration/soundcloud.php';
1201
- }
1202
-
1203
- function gtm4wp_show_admin_page() {
1204
- global $gtp4wp_plugin_url;
1205
- ?>
1206
- <div class="wrap">
1207
- <div id="gtm4wp-icon" class="icon32" style="background-image: url(<?php echo $gtp4wp_plugin_url; ?>admin/images/tag_manager-32.png);"><br /></div>
1208
- <h2><?php _e( 'Google Tag Manager for WordPress options', 'duracelltomi-google-tag-manager' ); ?></h2>
1209
- <form action="options.php" method="post">
1210
- <?php settings_fields( GTM4WP_ADMIN_GROUP ); ?>
1211
- <?php do_settings_sections( GTM4WP_ADMINSLUG ); ?>
1212
- <?php submit_button(); ?>
1213
-
1214
- </form>
1215
- </div>
1216
- <?php
1217
- }
1218
-
1219
- function gtm4wp_add_admin_page() {
1220
- add_options_page(
1221
- __( 'Google Tag Manager for WordPress settings', 'duracelltomi-google-tag-manager' ),
1222
- __( 'Google Tag Manager', 'duracelltomi-google-tag-manager' ),
1223
- 'manage_options',
1224
- GTM4WP_ADMINSLUG,
1225
- 'gtm4wp_show_admin_page'
1226
- );
1227
- }
1228
-
1229
- function gtm4wp_add_admin_js( $hook ) {
1230
- global $gtp4wp_plugin_url;
1231
-
1232
- if ( $hook == 'settings_page_' . GTM4WP_ADMINSLUG ) {
1233
- wp_register_script( 'admin-subtabs', $gtp4wp_plugin_url . 'js/admin-subtabs.js', array(), GTM4WP_VERSION );
1234
-
1235
- $subtabtexts = array(
1236
- 'posttabtitle' => __( 'Posts', 'duracelltomi-google-tag-manager' ),
1237
- 'searchtabtitle' => __( 'Search', 'duracelltomi-google-tag-manager' ),
1238
- 'visitortabtitle' => __( 'Visitors', 'duracelltomi-google-tag-manager' ),
1239
- 'adwordstabtitle' => __( 'Google Ads', 'duracelltomi-google-tag-manager' ),
1240
- 'browsertabtitle' => __( 'Browser/OS/Device', 'duracelltomi-google-tag-manager' ),
1241
- 'blocktagstabtitle' => __( 'Blacklist tags', 'duracelltomi-google-tag-manager' ),
1242
- 'blocktriggerstabtitle' => __( 'Blacklist triggers', 'duracelltomi-google-tag-manager' ),
1243
- 'blockmacrostabtitle' => __( 'Blacklist variables', 'duracelltomi-google-tag-manager' ),
1244
- 'wpcf7tabtitle' => __( 'Contact Form 7', 'duracelltomi-google-tag-manager' ),
1245
- 'wctabtitle' => __( 'WooCommerce', 'duracelltomi-google-tag-manager' ),
1246
- 'gotabtitle' => __( 'Google Optimize', 'duracelltomi-google-tag-manager' ),
1247
- 'amptabtitle' => __( 'Accelerated Mobile Pages', 'duracelltomi-google-tag-manager' ),
1248
- 'cookiebottabtitle' => __( 'Cookiebot', 'duracelltomi-google-tag-manager' ),
1249
- 'weathertabtitle' => __( 'Weather & geo data', 'duracelltomi-google-tag-manager' ),
1250
- 'generaleventstabtitle' => __( 'General events', 'duracelltomi-google-tag-manager' ),
1251
- 'mediaeventstabtitle' => __( 'Media events', 'duracelltomi-google-tag-manager' ),
1252
- 'depecratedeventstabtitle' => __( 'Deprecated', 'duracelltomi-google-tag-manager' ),
1253
- 'sitetabtitle' => __( 'Site', 'duracelltomi-google-tag-manager' ),
1254
- 'misctabtitle' => __( 'Misc', 'duracelltomi-google-tag-manager' ),
1255
- );
1256
- wp_localize_script( 'admin-subtabs', 'gtm4wp', $subtabtexts );
1257
-
1258
- wp_enqueue_script( 'admin-subtabs' );
1259
- wp_enqueue_script( 'admin-tabcreator', $gtp4wp_plugin_url . 'js/admin-tabcreator.js', array( 'jquery-core' ), GTM4WP_VERSION );
1260
-
1261
- wp_enqueue_style( 'gtm4wp-validate', $gtp4wp_plugin_url . 'css/admin-gtm4wp.css', array(), GTM4WP_VERSION );
1262
- }
1263
- }
1264
-
1265
- function gtm4wp_admin_head() {
1266
- echo '
1267
- <style type="text/css">
1268
- .gtmid_validation_error,
1269
- .goid_validation_error,
1270
- .goid_ga_validation_error,
1271
- .ampid_validation_error,
1272
- .datalayername_validation_error,
1273
- .gtmauth_validation_error,
1274
- .gtmpreview_validation_error,
1275
- .gtm_wpconfig_set {
1276
- color: #c00;
1277
- font-weight: bold;
1278
- }
1279
- .gtmid_validation_error,
1280
- .goid_validation_error,
1281
- .goid_ga_validation_error,
1282
- .ampid_validation_error,
1283
- .datalayername_validation_error,
1284
- .gtmauth_validation_error,
1285
- .gtmpreview_validation_error {
1286
- display: none;
1287
- }
1288
- </style>
1289
- <script type="text/javascript">
1290
- jQuery(function() {
1291
- jQuery( "#gtm4wp-options\\\\[gtm-code\\\\]" )
1292
- .on( "blur", function() {
1293
- var gtmid_regex = /^GTM-[A-Z0-9]+$/;
1294
- var gtmid_list_str = jQuery( this ).val();
1295
- if ( typeof gtmid_list_str != "string" ) {
1296
- return;
1297
- }
1298
- var gtmid_list = trim( gtmid_list_str ).split( "," );
1299
-
1300
- var gtmid_haserror = false;
1301
- for( var i=0; i<gtmid_list.length; i++ ) {
1302
- gtmid_haserror = gtmid_haserror || !gtmid_regex.test( gtmid_list[ i ] );
1303
- }
1304
-
1305
- if ( gtmid_haserror ) {
1306
- jQuery( ".gtmid_validation_error" )
1307
- .show();
1308
- } else {
1309
- jQuery( ".gtmid_validation_error" )
1310
- .hide();
1311
- }
1312
- });
1313
-
1314
- jQuery( "#gtm4wp-options\\\\[integrate-google-optimize-idlist\\\\]" )
1315
- .on( "blur", function() {
1316
- var goid_regex = /^(GTM|OPT)-[A-Z0-9]+$/;
1317
- var goid_val_str = jQuery( this ).val();
1318
- if ( typeof goid_val_str != "string" ) {
1319
- return;
1320
- }
1321
- var goid_val = trim( goid_val_str );
1322
- if ( "" == goid_val ) {
1323
- goid_list = [];
1324
- } else {
1325
- var goid_list = goid_val.split( "," );
1326
- }
1327
-
1328
- var goid_haserror = false;
1329
- for( var i=0; i<goid_list.length; i++ ) {
1330
- goid_haserror = goid_haserror || !goid_regex.test( goid_list[ i ] );
1331
- }
1332
-
1333
- if ( goid_haserror && (goid_list.length > 0) ) {
1334
- jQuery( ".goid_validation_error" )
1335
- .show();
1336
- } else {
1337
- jQuery( ".goid_validation_error" )
1338
- .hide();
1339
- }
1340
- });
1341
-
1342
- jQuery( "#gtm4wp-options\\\\[integrate-google-optimize-gaid\\\\]" )
1343
- .on( "blur", function() {
1344
- var gogaid_regex = /^UA-[0-9]+-[0-9]+$/;
1345
- var gogaid_val_str = jQuery( this ).val();
1346
- if ( typeof gogaid_val_str != "string" ) {
1347
- return;
1348
- }
1349
- var gogaid_val = trim( gogaid_val_str );
1350
- if ( "" == gogaid_val ) {
1351
- gogaid_list = [];
1352
- } else {
1353
- var gogaid_list = gogaid_val.split( "," );
1354
- }
1355
-
1356
- var gogaid_haserror = false;
1357
- for( var i=0; i<gogaid_list.length; i++ ) {
1358
- gogaid_haserror = gogaid_haserror || !gogaid_regex.test( gogaid_list[ i ] );
1359
- }
1360
-
1361
- if ( gogaid_haserror && (gogaid_list.length > 0) ) {
1362
- jQuery( ".goid_ga_validation_error" )
1363
- .show();
1364
- } else {
1365
- jQuery( ".goid_ga_validation_error" )
1366
- .hide();
1367
- }
1368
- });
1369
-
1370
- jQuery( "#gtm4wp-options\\\\[integrate-amp-gtm\\\\]" )
1371
- .on( "blur", function() {
1372
- var ampid_regex = /^GTM-[A-Z0-9]+$/;
1373
- var ampid_val_str = jQuery( this ).val();
1374
- if ( typeof ampid_val_str != "string" ) {
1375
- return;
1376
- }
1377
- var ampid_val = trim( ampid_val_str );
1378
- if ( "" == ampid_val ) {
1379
- ampid_list = [];
1380
- } else {
1381
- var ampid_list = ampid_val.split( "," );
1382
- }
1383
-
1384
- var ampid_haserror = false;
1385
- for( var i=0; i<ampid_list.length; i++ ) {
1386
- ampid_haserror = ampid_haserror || !ampid_regex.test( gogaid_list[ i ] );
1387
- }
1388
-
1389
- if ( ampid_haserror && (ampid_list.length > 0) ) {
1390
- jQuery( ".ampid_validation_error" )
1391
- .show();
1392
- } else {
1393
- jQuery( ".ampid_validation_error" )
1394
- .hide();
1395
- }
1396
- });
1397
-
1398
- jQuery( "#gtm4wp-options\\\\[gtm-datalayer-variable-name\\\\]" )
1399
- .on( "blur", function() {
1400
- var currentval = jQuery( this ).val();
1401
-
1402
- jQuery( ".datalayername_validation_error" )
1403
- .hide();
1404
-
1405
- if ( currentval != "" ) {
1406
- // I know this is not the exact definition for a variable name but I think other kind of variable names should not be used.
1407
- var gtmvarname_regex = /^[a-zA-Z][a-zA-Z0-9_-]*$/;
1408
- if ( ! gtmvarname_regex.test( currentval ) ) {
1409
- jQuery( ".datalayername_validation_error" )
1410
- .show();
1411
- }
1412
- }
1413
- });
1414
-
1415
- jQuery( "#gtm4wp-options\\\\[gtm-env-gtm-auth\\\\]" )
1416
- .on( "blur", function() {
1417
- var currentval = jQuery( this ).val();
1418
-
1419
- jQuery( ".gtmauth_validation_error" )
1420
- .hide();
1421
-
1422
- if ( currentval != "" ) {
1423
- var gtmauth_regex = /^[a-zA-Z0-9-_]+$/;
1424
- if ( ! gtmauth_regex.test( currentval ) ) {
1425
- jQuery( ".gtmauth_validation_error" )
1426
- .show();
1427
- }
1428
- }
1429
- });
1430
-
1431
- jQuery( "#gtm4wp-options\\\\[gtm-env-gtm-preview\\\\]" )
1432
- .on( "blur", function() {
1433
- var currentval = jQuery( this ).val();
1434
-
1435
- jQuery( ".gtmpreview_validation_error" )
1436
- .hide();
1437
-
1438
- if ( currentval != "" ) {
1439
- var gtmpreview_regex = /^env-[0-9]+$/;
1440
- if ( ! gtmpreview_regex.test( currentval ) ) {
1441
- jQuery( ".gtmpreview_validation_error" )
1442
- .show();
1443
- }
1444
- }
1445
- });
1446
-
1447
- jQuery( document )
1448
- .on( "click", ".gtm4wp-notice .notice-dismiss", function( e ) {
1449
- jQuery.post(ajaxurl, {
1450
- action: "gtm4wp_dismiss_notice",
1451
- noticeid: jQuery( this ).closest(".gtm4wp-notice")
1452
- .attr( "data-href" )
1453
- .substring( 1 )
1454
- });
1455
- });
1456
- });
1457
- </script>';
1458
- }
1459
-
1460
- function gtm4wp_show_warning() {
1461
- global $gtm4wp_options, $gtp4wp_plugin_url, $gtm4wp_integratefieldtexts, $current_user,
1462
- $gtm4wp_def_user_notices_dismisses;
1463
-
1464
- $woo_plugin_active = is_plugin_active( $gtm4wp_integratefieldtexts[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ]['plugintocheck'] );
1465
- if ( $woo_plugin_active && function_exists( 'WC' ) ) {
1466
- $woo = WC();
1467
- } else {
1468
- $woo = null;
1469
- }
1470
-
1471
- $gtm4wp_user_notices_dismisses = get_user_meta( $current_user->ID, GTM4WP_USER_NOTICES_KEY, true );
1472
- if ( $gtm4wp_user_notices_dismisses === '' ) {
1473
- if ( is_array( $gtm4wp_def_user_notices_dismisses ) ) {
1474
- $gtm4wp_user_notices_dismisses = $gtm4wp_def_user_notices_dismisses;
1475
- } else {
1476
- $gtm4wp_user_notices_dismisses = array();
1477
- }
1478
- } else {
1479
- $gtm4wp_user_notices_dismisses = @unserialize( $gtm4wp_user_notices_dismisses );
1480
- if ( false === $gtm4wp_user_notices_dismisses || !is_array( $gtm4wp_user_notices_dismisses ) ) {
1481
- $gtm4wp_user_notices_dismisses = array();
1482
- }
1483
- }
1484
- $gtm4wp_user_notices_dismisses = array_merge( $gtm4wp_def_user_notices_dismisses, $gtm4wp_user_notices_dismisses );
1485
-
1486
- if ( ( trim( $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] ) == '' ) && ( false === $gtm4wp_user_notices_dismisses['enter-gtm-code'] ) ) {
1487
- echo '<div class="gtm4wp-notice notice notice-error is-dismissible" data-href="?enter-gtm-code"><p><strong>' . sprintf( __( 'To start using Google Tag Manager for WordPress, please <a href="%s">enter your GTM ID</a>', 'duracelltomi-google-tag-manager' ), 'options-general.php?page=' . GTM4WP_ADMINSLUG ) . '</strong></p></div>';
1488
- }
1489
-
1490
- if ( (
1491
- ( '' != $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ] ) && ( '' == $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ] )
1492
- ) || (
1493
- ( '' == $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ] ) && ( '' != $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ] )
1494
- ) ) {
1495
- echo '<div class="gtm4wp-notice notice notice-error" data-href="?incomplete-gtm-env-config"><p><strong>' . sprintf( __( 'Incomplete Google Tag Manager environment configuration: either gtm_preview or gtm_auth parameter value is missing!', 'duracelltomi-google-tag-manager' ), 'options-general.php?page=' . GTM4WP_ADMINSLUG ) . '</strong></p></div>';
1496
- }
1497
-
1498
- if ( ( false === $gtm4wp_user_notices_dismisses['wc-ga-plugin-warning'] ) || ( false === $gtm4wp_user_notices_dismisses['wc-gayoast-plugin-warning'] ) ) {
1499
- $is_wc_active = $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ||
1500
- $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ||
1501
- $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ];
1502
-
1503
- if ( ( false === $gtm4wp_user_notices_dismisses['wc-ga-plugin-warning'] ) && $is_wc_active && is_plugin_active( 'woocommerce-google-analytics-integration/woocommerce-google-analytics-integration.php' ) ) {
1504
- echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?wc-ga-plugin-warning"><p><strong>' . __( 'Notice: you should deactivate the plugin "WooCommerce Google Analytics Integration" if you are using Google Analytics tags inside Google Tag Manager!', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
1505
- }
1506
-
1507
- if ( ( false === $gtm4wp_user_notices_dismisses['wc-gayoast-plugin-warning'] ) && $is_wc_active && is_plugin_active( 'google-analytics-for-wordpress/googleanalytics.php' ) ) {
1508
- echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?wc-gayoast-plugin-warning"><p><strong>' . __( 'Notice: you should deactivate the plugin "Google Analytics for WordPress by MonsterInsights" if you are using Google Analytics tags inside Google Tag Manager!', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
1509
- }
1510
- }
1511
-
1512
- if ( ( false === $gtm4wp_user_notices_dismisses['php72-warning'] ) && ( version_compare( PHP_VERSION, '7.2.0' ) < 0 ) ) {
1513
- echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?php72-warning"><p><strong>' . __( 'Warning: You are using an outdated version of PHP (v' . PHP_VERSION . ') that might be not compatible with future versions of the plugin Google Tag Manager for WordPress (GTM4WP). Please consider to upgrade your PHP.', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
1514
- }
1515
- }
1516
-
1517
- function gtm4wp_dismiss_notice() {
1518
- global $gtm4wp_def_user_notices_dismisses, $current_user;
1519
-
1520
- $gtm4wp_user_notices_dismisses = get_user_meta( $current_user->ID, GTM4WP_USER_NOTICES_KEY, true );
1521
- if ( $gtm4wp_user_notices_dismisses === '' ) {
1522
- if ( is_array( $gtm4wp_def_user_notices_dismisses ) ) {
1523
- $gtm4wp_user_notices_dismisses = $gtm4wp_def_user_notices_dismisses;
1524
- } else {
1525
- $gtm4wp_user_notices_dismisses = array();
1526
- }
1527
- } else {
1528
- $gtm4wp_user_notices_dismisses = @unserialize( $gtm4wp_user_notices_dismisses );
1529
- if ( false === $gtm4wp_user_notices_dismisses || !is_array( $gtm4wp_user_notices_dismisses ) ) {
1530
- $gtm4wp_user_notices_dismisses = array();
1531
- }
1532
- }
1533
- $gtm4wp_user_notices_dismisses = array_merge( $gtm4wp_def_user_notices_dismisses, $gtm4wp_user_notices_dismisses );
1534
-
1535
- $noticeid = trim( basename( $_POST['noticeid'] ) );
1536
- if ( array_key_exists( $noticeid, $gtm4wp_user_notices_dismisses ) ) {
1537
- $gtm4wp_user_notices_dismisses[ $noticeid ] = true;
1538
- update_user_meta( $current_user->ID, GTM4WP_USER_NOTICES_KEY, serialize( $gtm4wp_user_notices_dismisses ) );
1539
- }
1540
- }
1541
-
1542
- function gtm4wp_add_plugin_action_links( $links, $file ) {
1543
- global $gtp4wp_plugin_basename;
1544
-
1545
- if ( $file != $gtp4wp_plugin_basename ) {
1546
- return $links;
1547
- }
1548
-
1549
- $settings_link = '<a href="' . menu_page_url( GTM4WP_ADMINSLUG, false ) . '">' . esc_html( __( 'Settings' ) ) . '</a>';
1550
-
1551
- array_unshift( $links, $settings_link );
1552
-
1553
- return $links;
1554
- }
1555
-
1556
- function gtm4wp_show_upgrade_notification( $current_plugin_metadata, $new_plugin_metadata ) {
1557
- if ( isset( $new_plugin_metadata->upgrade_notice ) && strlen( trim( $new_plugin_metadata->upgrade_notice ) ) > 0 ) {
1558
- echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px"><strong>Important Upgrade Notice:</strong> ';
1559
- echo esc_html( $new_plugin_metadata->upgrade_notice ), '</p>';
1560
- }
1561
- }
1562
-
1563
- add_action( 'admin_init', 'gtm4wp_admin_init' );
1564
- add_action( 'admin_menu', 'gtm4wp_add_admin_page' );
1565
- add_action( 'admin_enqueue_scripts', 'gtm4wp_add_admin_js' );
1566
- add_action( 'admin_notices', 'gtm4wp_show_warning' );
1567
- add_action( 'admin_head', 'gtm4wp_admin_head' );
1568
- add_filter( 'plugin_action_links', 'gtm4wp_add_plugin_action_links', 10, 2 );
1569
- add_action( 'wp_ajax_gtm4wp_dismiss_notice', 'gtm4wp_dismiss_notice' );
1570
- add_action( 'in_plugin_update_message-duracelltomi-google-tag-manager-for-wordpress/duracelltomi-google-tag-manager-for-wordpress.php', 'gtm4wp_show_upgrade_notification', 10, 2 );
1
+ <?php
2
+ define( 'GTM4WP_ADMINSLUG', 'gtm4wp-settings' );
3
+ define( 'GTM4WP_ADMIN_GROUP', 'gtm4wp-admin-group' );
4
+
5
+ define( 'GTM4WP_ADMIN_GROUP_GENERAL', 'gtm4wp-admin-group-general' );
6
+ define( 'GTM4WP_ADMIN_GROUP_GTMID', 'gtm4wp-admin-group-gtm-id' );
7
+ define( 'GTM4WP_ADMIN_GROUP_CONTAINERON', 'gtm4wp-admin-container-on' );
8
+ define( 'GTM4WP_ADMIN_GROUP_COMPATMODE', 'gtm4wp-admin-compat-mode' );
9
+ define( 'GTM4WP_ADMIN_GROUP_INFO', 'gtm4wp-admin-group-datalayer-info' );
10
+
11
+ define( 'GTM4WP_ADMIN_GROUP_INCLUDES', 'gtm4wp-admin-group-includes' );
12
+ define( 'GTM4WP_ADMIN_GROUP_EVENTS', 'gtm4wp-admin-group-events' );
13
+ define( 'GTM4WP_ADMIN_GROUP_SCROLLER', 'gtm4wp-admin-group-scroller' );
14
+ define( 'GTM4WP_ADMIN_GROUP_BLACKLIST', 'gtm4wp-admin-group-blacklist-tags' );
15
+ define( 'GTM4WP_ADMIN_GROUP_INTEGRATION', 'gtm4wp-admin-group-integration' );
16
+ define( 'GTM4WP_ADMIN_GROUP_ADVANCED', 'gtm4wp-admin-group-advanced' );
17
+ define( 'GTM4WP_ADMIN_GROUP_CREDITS', 'gtm4wp-admin-group-credits' );
18
+
19
+ define( 'GTM4WP_USER_NOTICES_KEY', 'gtm4wp_user_notices_dismisses' );
20
+
21
+ define( 'GTM4WP_PHASE_STABLE', 'gtm4wp-phase-stable' );
22
+ define( 'GTM4WP_PHASE_BETA', 'gtm4wp-phase-beta' );
23
+ define( 'GTM4WP_PHASE_EXPERIMENTAL', 'gtm4wp-phase-experimental' );
24
+ define( 'GTM4WP_PHASE_DEPRECATED', 'gtm4wp-phase-deprecated' );
25
+
26
+ $GLOBALS['gtm4wp_def_user_notices_dismisses'] = array(
27
+ 'enter-gtm-code' => false,
28
+ 'wc-ga-plugin-warning' => false,
29
+ 'wc-gayoast-plugin-warning' => false,
30
+ 'php72-warning' => false,
31
+ 'deprecated-warning' => false,
32
+ );
33
+
34
+ $GLOBALS['gtm4wp_includefieldtexts'] = array(
35
+ GTM4WP_OPTION_INCLUDE_POSTTYPE => array(
36
+ 'label' => __( 'Posttype of current post/archive', 'duracelltomi-google-tag-manager' ),
37
+ 'description' => __( 'Check this option to include the type of the current post or archive page (post, page or any custom post type).', 'duracelltomi-google-tag-manager' ),
38
+ 'phase' => GTM4WP_PHASE_STABLE,
39
+ ),
40
+ GTM4WP_OPTION_INCLUDE_CATEGORIES => array(
41
+ 'label' => __( 'Category list of current post/archive', 'duracelltomi-google-tag-manager' ),
42
+ 'description' => __( 'Check this option to include the category names of the current post or archive page', 'duracelltomi-google-tag-manager' ),
43
+ 'phase' => GTM4WP_PHASE_STABLE,
44
+ ),
45
+ GTM4WP_OPTION_INCLUDE_TAGS => array(
46
+ 'label' => __( 'Tags of current post', 'duracelltomi-google-tag-manager' ),
47
+ 'description' => __( 'Check this option to include the tags of the current post.', 'duracelltomi-google-tag-manager' ),
48
+ 'phase' => GTM4WP_PHASE_STABLE,
49
+ ),
50
+ GTM4WP_OPTION_INCLUDE_AUTHORID => array(
51
+ 'label' => __( 'Post author ID', 'duracelltomi-google-tag-manager' ),
52
+ 'description' => __( 'Check this option to include the ID of the author on the current post or author page.', 'duracelltomi-google-tag-manager' ),
53
+ 'phase' => GTM4WP_PHASE_STABLE,
54
+ ),
55
+ GTM4WP_OPTION_INCLUDE_AUTHOR => array(
56
+ 'label' => __( 'Post author name', 'duracelltomi-google-tag-manager' ),
57
+ 'description' => __( 'Check this option to include the name of the author on the current post or author page.', 'duracelltomi-google-tag-manager' ),
58
+ 'phase' => GTM4WP_PHASE_STABLE,
59
+ ),
60
+ GTM4WP_OPTION_INCLUDE_POSTDATE => array(
61
+ 'label' => __( 'Post date', 'duracelltomi-google-tag-manager' ),
62
+ 'description' => __( 'Check this option to include the date of the current post. This will include 4 dataLayer variables: full date, post year, post month, post date.', 'duracelltomi-google-tag-manager' ),
63
+ 'phase' => GTM4WP_PHASE_STABLE,
64
+ ),
65
+ GTM4WP_OPTION_INCLUDE_POSTTITLE => array(
66
+ 'label' => __( 'Post title', 'duracelltomi-google-tag-manager' ),
67
+ 'description' => __( 'Check this option to include the title of the current post.', 'duracelltomi-google-tag-manager' ),
68
+ 'phase' => GTM4WP_PHASE_STABLE,
69
+ ),
70
+ GTM4WP_OPTION_INCLUDE_POSTCOUNT => array(
71
+ 'label' => __( 'Post count', 'duracelltomi-google-tag-manager' ),
72
+ 'description' => __( 'Check this option to include the count of the posts currently shown on the page and the total number of posts in the category/tag/any taxonomy.', 'duracelltomi-google-tag-manager' ),
73
+ 'phase' => GTM4WP_PHASE_STABLE,
74
+ ),
75
+ GTM4WP_OPTION_INCLUDE_POSTID => array(
76
+ 'label' => __( 'Post ID', 'duracelltomi-google-tag-manager' ),
77
+ 'description' => __( 'Check this option to include the post id.', 'duracelltomi-google-tag-manager' ),
78
+ 'phase' => GTM4WP_PHASE_STABLE,
79
+ ),
80
+ GTM4WP_OPTION_INCLUDE_POSTFORMAT => array(
81
+ 'label' => __( 'Post Format', 'duracelltomi-google-tag-manager' ),
82
+ 'description' => __( 'Check this option to include the post format.', 'duracelltomi-google-tag-manager' ),
83
+ 'phase' => GTM4WP_PHASE_STABLE,
84
+ ),
85
+ GTM4WP_OPTION_INCLUDE_POSTTERMLIST => array(
86
+ "label" => __( "Post Terms", 'duracelltomi-google-tag-manager' ),
87
+ "description" => __( "Check this option to include taxonomy values associated with a given post.", 'duracelltomi-google-tag-manager' ),
88
+ "phase" => GTM4WP_PHASE_STABLE
89
+ ),
90
+ GTM4WP_OPTION_INCLUDE_SEARCHDATA => array(
91
+ 'label' => __( 'Search data', 'duracelltomi-google-tag-manager' ),
92
+ 'description' => __( 'Check this option to include the search term, referring page URL and number of results on the search page.', 'duracelltomi-google-tag-manager' ),
93
+ 'phase' => GTM4WP_PHASE_STABLE,
94
+ ),
95
+ GTM4WP_OPTION_INCLUDE_LOGGEDIN => array(
96
+ 'label' => __( 'Logged in status', 'duracelltomi-google-tag-manager' ),
97
+ 'description' => __( 'Check this option to include whether there is a logged in user on your website.', 'duracelltomi-google-tag-manager' ),
98
+ 'phase' => GTM4WP_PHASE_STABLE,
99
+ ),
100
+ GTM4WP_OPTION_INCLUDE_USERROLE => array(
101
+ 'label' => __( 'Logged in user role', 'duracelltomi-google-tag-manager' ),
102
+ 'description' => __( 'Check this option to include the role of the logged in user.', 'duracelltomi-google-tag-manager' ),
103
+ 'phase' => GTM4WP_PHASE_STABLE,
104
+ ),
105
+ GTM4WP_OPTION_INCLUDE_USERID => array(
106
+ 'label' => __( 'Logged in user ID', 'duracelltomi-google-tag-manager' ),
107
+ 'description' => __( 'Check this option to include the ID of the logged in user.', 'duracelltomi-google-tag-manager' ),
108
+ 'phase' => GTM4WP_PHASE_STABLE,
109
+ ),
110
+ GTM4WP_OPTION_INCLUDE_USERNAME => array(
111
+ 'label' => __( 'Logged in user name', 'duracelltomi-google-tag-manager' ),
112
+ 'description' => __( 'Check this option to include the username of the logged in user.', 'duracelltomi-google-tag-manager' ),
113
+ 'phase' => GTM4WP_PHASE_STABLE,
114
+ ),
115
+ GTM4WP_OPTION_INCLUDE_USEREMAIL => array(
116
+ 'label' => __( 'Logged in user email', 'duracelltomi-google-tag-manager' ),
117
+ 'description' => __( 'Check this option to include the email address of the logged in user.', 'duracelltomi-google-tag-manager' ),
118
+ 'phase' => GTM4WP_PHASE_STABLE,
119
+ ),
120
+ GTM4WP_OPTION_INCLUDE_USERREGDATE => array(
121
+ 'label' => __( 'Logged in user creation date', 'duracelltomi-google-tag-manager' ),
122
+ 'description' => __( 'Check this option to include the date of creation (registration) of the logged in user.', 'duracelltomi-google-tag-manager' ),
123
+ 'phase' => GTM4WP_PHASE_STABLE,
124
+ ),
125
+ GTM4WP_OPTION_INCLUDE_VISITOR_IP => array(
126
+ 'label' => __( 'Visitor IP', 'duracelltomi-google-tag-manager' ),
127
+ 'description' => __( 'Check this option to include the IP address of the visitor. You might use this to filter internal traffic inside your GTM container. Please be aware that per GDPR its not allowed to transmit this full IP address to Google Analytics or to any other measurement system without explicit consent from the visitor.', 'duracelltomi-google-tag-manager' ),
128
+ 'phase' => GTM4WP_PHASE_STABLE,
129
+ ),
130
+ GTM4WP_OPTION_INCLUDE_BROWSERDATA => array(
131
+ 'label' => __( 'Browser data *', 'duracelltomi-google-tag-manager' ),
132
+ 'description' => __( 'Check this option to include the name, version and engine data of the browser the visitor uses.', 'duracelltomi-google-tag-manager' )
133
+ ),
134
+ GTM4WP_OPTION_INCLUDE_OSDATA => array(
135
+ 'label' => __( 'OS data *', 'duracelltomi-google-tag-manager' ),
136
+ 'description' => __( 'Check this option to include the name and version of the operating system the visitor uses.', 'duracelltomi-google-tag-manager' )
137
+ ),
138
+ GTM4WP_OPTION_INCLUDE_DEVICEDATA => array(
139
+ 'label' => __( 'Device data *', 'duracelltomi-google-tag-manager' ),
140
+ 'description' => __( 'Check this option to include the type of device the user is currently using (desktop, tablet or mobile) including manufacturer and model data.', 'duracelltomi-google-tag-manager' )
141
+ ),
142
+ GTM4WP_OPTION_INCLUDE_MISCGEO => array(
143
+ 'label' => __( 'Geo data', 'duracelltomi-google-tag-manager' ),
144
+ 'description' => __( 'Add geo data (latitude, longitude, country, city, etc) of the current visitor (provided by ipstack.com)', 'duracelltomi-google-tag-manager' ),
145
+ 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
146
+ ),
147
+ GTM4WP_OPTION_INCLUDE_MISCGEOAPI => array(
148
+ 'label' => __( 'IPStack.com API key', 'duracelltomi-google-tag-manager' ),
149
+ 'description' => sprintf( __( 'Enter your IPStack.com API key here. <a href="%s" target="_blank" rel="noopener">Get a free API key here</a>.', 'duracelltomi-google-tag-manager' ), 'https://ipstack.com/product?utm_source=gtm4wp&utm_medium=link&utm_campaign=gtm4wp-google-tag-manager-for-wordpress' ),
150
+ 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
151
+ ),
152
+ GTM4WP_OPTION_INCLUDE_MISCGEOCF => array(
153
+ 'label' => __( 'Cloudflare country code', 'duracelltomi-google-tag-manager' ),
154
+ 'description' => __( 'Add the country code of the user provided by Cloudflare (if Cloudflare is used with your site)', 'duracelltomi-google-tag-manager' ),
155
+ 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
156
+ ),
157
+ GTM4WP_OPTION_INCLUDE_WEATHER => array(
158
+ 'label' => __( 'Weather data', 'duracelltomi-google-tag-manager' ),
159
+ 'description' => sprintf(
160
+ __(
161
+ 'Check this option to include the current weather conditions around the current visitor.<br /><br />' .
162
+ '<strong>Attention!</strong> This feature uses <a href="%s" target="_blank" rel="noopener">ipstack.com</a> and ' .
163
+ '<a href="%s" target="_blank" rel="noopener">openweathermap.org</a> to collect data.<br />' .
164
+ "Depending on your website's traffic, additional fees may apply!<br />" .
165
+ 'This plugin caches weather data for 1 hour to lower the need to access those services.<br /><br />' .
166
+ 'If you activate weather data, <strong>you will need</strong> to add an IPStack.com API key regardless of whether you ' .
167
+ "activate the 'Geo data' option!",
168
+ 'duracelltomi-google-tag-manager'
169
+ ),
170
+ 'https://ipstack.com/product?utm_source=gtm4wp&utm_medium=link&utm_campaign=gtm4wp-google-tag-manager-for-wordpress',
171
+ 'http://openweathermap.org/price?utm_source=gtm4wp&utm_medium=link&utm_campaign=gtm4wp-google-tag-manager-for-wordpress'
172
+ ),
173
+ 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
174
+ ),
175
+ GTM4WP_OPTION_INCLUDE_WEATHERUNITS => array(
176
+ 'label' => __( 'Weather data units', 'duracelltomi-google-tag-manager' ),
177
+ 'description' => __( 'Select which temperature units you would like to use.', 'duracelltomi-google-tag-manager' ),
178
+ 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
179
+ ),
180
+ GTM4WP_OPTION_INCLUDE_WEATHEROWMAPI => array(
181
+ 'label' => __( 'OpenWeatherMap API key', 'duracelltomi-google-tag-manager' ),
182
+ 'description' => sprintf( __( 'Enter your OpenWeatherMap API key here. <a href="%s" target="_blank" rel="noopener">Get a free API key here</a>.', 'duracelltomi-google-tag-manager' ), 'http://openweathermap.org/price?utm_source=gtm4wp&utm_medium=link&utm_campaign=gtm4wp-google-tag-manager-for-wordpress' ),
183
+ 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
184
+ ),
185
+ GTM4WP_OPTION_INCLUDE_SITEID => array(
186
+ 'label' => __( 'Site ID', 'duracelltomi-google-tag-manager' ),
187
+ 'description' => __( 'ID of the current site in a WordPress Multisite environment', 'duracelltomi-google-tag-manager' ),
188
+ 'phase' => GTM4WP_PHASE_STABLE,
189
+ ),
190
+ GTM4WP_OPTION_INCLUDE_SITENAME => array(
191
+ 'label' => __( 'Site name', 'duracelltomi-google-tag-manager' ),
192
+ 'description' => __( 'Name of the current site in a WordPress Multisite environment', 'duracelltomi-google-tag-manager' ),
193
+ 'phase' => GTM4WP_PHASE_STABLE,
194
+ ),
195
+ );
196
+
197
+ $GLOBALS['gtm4wp_eventfieldtexts'] = array(
198
+ GTM4WP_OPTION_EVENTS_FORMMOVE => array(
199
+ 'label' => __( 'Form fill events (gtm4wp.formElementEnter & gtm4wp.formElementLeave)', 'duracelltomi-google-tag-manager' ),
200
+ 'description' => __( 'Check this option to include a Tag Manager event when a visitor moves between elements of a form (comment, contact, etc).', 'duracelltomi-google-tag-manager' ),
201
+ 'phase' => GTM4WP_PHASE_STABLE,
202
+ ),
203
+ GTM4WP_OPTION_EVENTS_NEWUSERREG => array(
204
+ 'label' => __( 'New user registration', 'duracelltomi-google-tag-manager' ),
205
+ 'description' => __( 'Check this option to include a Tag Manager event when a new user registration has been completed on the frontend of your site (admin events not included)', 'duracelltomi-google-tag-manager' ),
206
+ 'phase' => GTM4WP_PHASE_STABLE,
207
+ ),
208
+ GTM4WP_OPTION_EVENTS_USERLOGIN => array(
209
+ 'label' => __( 'User logged in', 'duracelltomi-google-tag-manager' ),
210
+ 'description' => __( 'Check this option to include a Tag Manager event when an existing user has been logged in on the frontend of your site (admin events not included)', 'duracelltomi-google-tag-manager' ),
211
+ 'phase' => GTM4WP_PHASE_STABLE,
212
+ ),
213
+ GTM4WP_OPTION_EVENTS_YOUTUBE => array(
214
+ 'label' => __( 'YouTube video events', 'duracelltomi-google-tag-manager' ),
215
+ 'description' => __( 'Check this option to include a Tag Manager event when a visitor interacts with a YouTube video embeded on your site.', 'duracelltomi-google-tag-manager' ),
216
+ 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
217
+ ),
218
+ GTM4WP_OPTION_EVENTS_VIMEO => array(
219
+ 'label' => __( 'Vimeo video events', 'duracelltomi-google-tag-manager' ),
220
+ 'description' => __( 'Check this option to include a Tag Manager event when a visitor interacts with a Vimeo video embeded on your site.', 'duracelltomi-google-tag-manager' ),
221
+ 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
222
+ ),
223
+ GTM4WP_OPTION_EVENTS_SOUNDCLOUD => array(
224
+ 'label' => __( 'Soundcloud events', 'duracelltomi-google-tag-manager' ),
225
+ 'description' => __( 'Check this option to include a Tag Manager event when a visitor interacts with a Soundcloud media embeded on your site.', 'duracelltomi-google-tag-manager' ),
226
+ 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
227
+ )
228
+ );
229
+
230
+ $GLOBALS['gtm4wp_scrollerfieldtexts'] = array(
231
+ GTM4WP_OPTION_SCROLLER_ENABLED => array(
232
+ 'label' => __( 'Enabled', 'duracelltomi-google-tag-manager' ),
233
+ 'description' => __( 'Enable scroll tracker script on your website.', 'duracelltomi-google-tag-manager' ),
234
+ 'phase' => GTM4WP_PHASE_STABLE,
235
+ ),
236
+ GTM4WP_OPTION_SCROLLER_DEBUGMODE => array(
237
+ 'label' => __( 'Debug mode', 'duracelltomi-google-tag-manager' ),
238
+ 'description' => __( 'Fire console.log() commands instead of dataLayer events.', 'duracelltomi-google-tag-manager' ),
239
+ 'phase' => GTM4WP_PHASE_STABLE,
240
+ ),
241
+ GTM4WP_OPTION_SCROLLER_CALLBACKTIME => array(
242
+ 'label' => __( 'Time delay before location check', 'duracelltomi-google-tag-manager' ),
243
+ 'description' => __( 'Enter the number of milliseconds after the script checks the current location. It prevents too many events being fired while scrolling.', 'duracelltomi-google-tag-manager' ),
244
+ 'phase' => GTM4WP_PHASE_STABLE,
245
+ ),
246
+ GTM4WP_OPTION_SCROLLER_DISTANCE => array(
247
+ 'label' => __( 'Minimum distance', 'duracelltomi-google-tag-manager' ),
248
+ 'description' => __( 'The minimum amount of pixels that a visitor has to scroll before we treat the move as scrolling.', 'duracelltomi-google-tag-manager' ),
249
+ 'phase' => GTM4WP_PHASE_STABLE,
250
+ ),
251
+ GTM4WP_OPTION_SCROLLER_CONTENTID => array(
252
+ 'label' => __( 'Content ID', 'duracelltomi-google-tag-manager' ),
253
+ 'description' => __( 'Enter the DOM ID of the content element in your template. Leave it empty for default(content). Do not include the # sign.', 'duracelltomi-google-tag-manager' ),
254
+ 'phase' => GTM4WP_PHASE_STABLE,
255
+ ),
256
+ GTM4WP_OPTION_SCROLLER_READERTIME => array(
257
+ 'label' => __( 'Scroller time', 'duracelltomi-google-tag-manager' ),
258
+ 'description' => __( 'Enter the number of seconds after the the scroller user is being treated as a reader, someone who really reads the content, not just scrolls through it.', 'duracelltomi-google-tag-manager' ),
259
+ 'phase' => GTM4WP_PHASE_STABLE,
260
+ ),
261
+ );
262
+
263
+ $GLOBALS['gtm4wp_integratefieldtexts'] = array(
264
+ GTM4WP_OPTION_INTEGRATE_WPCF7 => array(
265
+ 'label' => __( 'Contact Form 7', 'duracelltomi-google-tag-manager' ),
266
+ 'description' => __( 'Check this to fire dataLayer events after Contact Form 7 submissions (supported events: invalid input, spam detected, form submitted, form submitted and mail sent, form submitted and mail send failed).', 'duracelltomi-google-tag-manager' ),
267
+ 'phase' => GTM4WP_PHASE_STABLE,
268
+ 'plugintocheck' => 'contact-form-7/wp-contact-form-7.php',
269
+ ),
270
+ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC => array(
271
+ 'label' => __( 'Track classic e-commerce', 'duracelltomi-google-tag-manager' ),
272
+ 'description' => __( 'This feature is deprecated and will be removed soon! You should upgrade to enhanced ecommerce as soon as possible.', 'duracelltomi-google-tag-manager' ),
273
+ 'phase' => GTM4WP_PHASE_DEPRECATED
274
+ ),
275
+ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC => array(
276
+ 'label' => __( 'Track enhanced e-commerce', 'duracelltomi-google-tag-manager' ),
277
+ 'description' => sprintf(
278
+ __(
279
+ 'Choose this option if you would like to track e-commerce data using '.
280
+ '<a href="%s" target="_blank" rel="noopener">enhanced ecommerce tracking</a>.<br>'.
281
+ 'Use the plugin\'s official guides to setup your Google Tag Manager container:<br>'.
282
+ '<ul><li><a href="%s" target="_blank" rel="noopener">Google Analytics 3 / Universal Analytics setup</a></li>'.
283
+ '<li><a href="%s" target="_blank" rel="noopener">Google Analytics 4 setup</a></li></ul>'
284
+ , 'duracelltomi-google-tag-manager' )
285
+ , 'https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce'
286
+ , 'https://gtm4wp.com/how-to-articles/how-to-setup-enhanced-ecommerce-tracking'
287
+ , 'https://gtm4wp.com/how-to-articles/how-to-setup-enhanced-ecommerce-tracking-google-analytics-4-ga4-version' ),
288
+ 'phase' => GTM4WP_PHASE_STABLE,
289
+ 'plugintocheck' => 'woocommerce/woocommerce.php',
290
+ ),
291
+ GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION => array(
292
+ 'label' => __( 'Products per impression', 'duracelltomi-google-tag-manager' ),
293
+ 'description' => __(
294
+ 'If you have many products shown on product category pages and/or on your site home, you could miss pageviews in Google Analytics due to the ' .
295
+ 'amount of data that is needed to be sent. To prevent this, you can split product impression data into multiple Google Analytics events by ' .
296
+ 'entering a number here (minimum 10-15 recommended) and adding gtm4wp.productImpressionEEC into your Google Analytics ecommerce event helper ' .
297
+ "tag's trigger.<br /><br />Leave this value 0 to include product impression data in your pageview hit.",
298
+ 'duracelltomi-google-tag-manager'
299
+ ),
300
+ 'phase' => GTM4WP_PHASE_STABLE
301
+ ),
302
+ GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP => array(
303
+ 'label' => __( 'Cart as 1st checkout step', 'duracelltomi-google-tag-manager' ),
304
+ 'description' => __( 'Enable this to track the cart page as the first checkout step in enhanced ecommerce instead of the checkout page itself', 'duracelltomi-google-tag-manager' ),
305
+ 'phase' => GTM4WP_PHASE_STABLE
306
+ ),
307
+ GTM4WP_OPTION_INTEGRATE_WCEINCLUDECARTINDL => array(
308
+ "label" => __( "Cart content in data layer", 'duracelltomi-google-tag-manager' ),
309
+ "description" => __( "Enable this option to include the content of the cart in the data layer on each page. Needs WooCommerce v3.2 or newer. Especially useful for site personalization with Google Optimize.", 'duracelltomi-google-tag-manager' ),
310
+ "phase" => GTM4WP_PHASE_STABLE
311
+ ),
312
+ GTM4WP_OPTION_INTEGRATE_WCUSEFULLCATEGORYPATH => array(
313
+ 'label' => __( 'Include full category path.', 'duracelltomi-google-tag-manager' ),
314
+ 'description' => __( 'Check this to inclulde the full category path of each product in enhanced ecommerce tracking. WARNING! This can lead to performance issues on large sites with lots of traffic!', 'duracelltomi-google-tag-manager' ),
315
+ 'phase' => GTM4WP_PHASE_STABLE
316
+ ),
317
+ GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY => array(
318
+ "label" => __( "Taxonomy to be used for product brands", 'duracelltomi-google-tag-manager' ),
319
+ "description" => __( "Select which custom taxonomy is being used to add the brand of products", 'duracelltomi-google-tag-manager' ),
320
+ "phase" => GTM4WP_PHASE_STABLE
321
+ ),
322
+ GTM4WP_OPTION_INTEGRATE_WCCUSTOMERDATA => array(
323
+ 'label' => __( 'Customer data in data layer', 'duracelltomi-google-tag-manager' ),
324
+ 'description' => __( 'Enable this to add all customer data (billing and shipping data, total number of orders and order value) into the data layer (WooCommerce 3.x required)', 'duracelltomi-google-tag-manager' ),
325
+ 'phase' => GTM4WP_PHASE_STABLE
326
+ ),
327
+ GTM4WP_OPTION_INTEGRATE_WCORDERDATA => array(
328
+ 'label' => __( 'Order data in data layer', 'duracelltomi-google-tag-manager' ),
329
+ 'description' => __( 'Enable this to add all order attribute into the data layer on the order received page regardless and independently from classic and enhanced ecommerce tracking (WooCommerce 3.x required)', 'duracelltomi-google-tag-manager' ),
330
+ 'phase' => GTM4WP_PHASE_STABLE
331
+ ),
332
+ GTM4WP_OPTION_INTEGRATE_WCEXCLUDETAX => array(
333
+ 'label' => __( 'Exclude tax from revenue', 'duracelltomi-google-tag-manager' ),
334
+ 'description' => __( 'Enable this to exclude tax from the revenue variable while generating the purchase data', 'duracelltomi-google-tag-manager' ),
335
+ 'phase' => GTM4WP_PHASE_STABLE
336
+ ), GTM4WP_OPTION_INTEGRATE_WCORDERMAXAGE => array(
337
+ 'label' => __( 'Only track orders younger than', 'duracelltomi-google-tag-manager' ),
338
+ 'description' => __( 'To prevent duplicate transaction tracking at the order received page, enter the maximum age (in minutes) of the order or its payment for the transaction to be measured. Viewing the order received page of older orders will be ignored from transaction tracking, as it is considered to be a measured in an earlier session.', 'duracelltomi-google-tag-manager' ),
339
+ 'phase' => GTM4WP_PHASE_EXPERIMENTAL
340
+ ),
341
+ GTM4WP_OPTION_INTEGRATE_WCEXCLUDESHIPPING => array(
342
+ 'label' => __( 'Exclude shipping from revenue', 'duracelltomi-google-tag-manager' ),
343
+ 'description' => __( 'Enable this to exclude shipping costs from the revenue variable while generating the purchase data', 'duracelltomi-google-tag-manager' ),
344
+ 'phase' => GTM4WP_PHASE_STABLE
345
+ ),
346
+ GTM4WP_OPTION_INTEGRATE_WCREMARKETING => array(
347
+ 'label' => __( 'Google Ads Remarketing', 'duracelltomi-google-tag-manager' ),
348
+ 'description' => __( 'Enable this to add Google Ads dynamic remarketing variables to the dataLayer', 'duracelltomi-google-tag-manager' ),
349
+ 'phase' => GTM4WP_PHASE_DEPRECATED
350
+ ),
351
+ GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL => array(
352
+ 'label' => __( 'Google Ads Business Vertical', 'duracelltomi-google-tag-manager' ),
353
+ 'description' => sprintf(
354
+ __(
355
+ 'Select which vertical category to add next to each product to utilize dynamic remarketing for Google Ads.'.
356
+ '<br>Use the plugin\'s <a href="%s" target="_blank" rel="noopener">official setup guide for dynamic remarketing</a> '.
357
+ 'to setup your Google Tag Manager container.'
358
+ , 'duracelltomi-google-tag-manager' )
359
+ , 'https://gtm4wp.com/how-to-articles/how-to-setup-dynamic-remarketing-in-google-ads-adwords'),
360
+ 'phase' => GTM4WP_PHASE_STABLE
361
+ ),
362
+ GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX => array(
363
+ 'label' => __( 'Product ID prefix', 'duracelltomi-google-tag-manager' ),
364
+ 'description' => __( "Some product feed generator plugins prefix product IDs with a fixed text like 'woocommerce_gpf'. You can enter this prefix here so that tags in your website include this prefix as well.", 'duracelltomi-google-tag-manager' ),
365
+ 'phase' => GTM4WP_PHASE_STABLE
366
+ ),
367
+ GTM4WP_OPTION_INTEGRATE_WCUSESKU => array(
368
+ 'label' => __( 'Use SKU instead of ID', 'duracelltomi-google-tag-manager' ),
369
+ 'description' => __( 'Check this to use product SKU instead of the ID of the products for remarketing and ecommerce tracking. Will fallback to ID if no SKU is set.', 'duracelltomi-google-tag-manager' ),
370
+ 'phase' => GTM4WP_PHASE_STABLE
371
+ ),
372
+ GTM4WP_OPTION_INTEGRATE_WCNOORDERTRACKEDFLAG => array(
373
+ 'label' => __( 'Do not flag orders as being tracked', 'duracelltomi-google-tag-manager' ),
374
+ 'description' => __(
375
+ 'Turn this on to prevent the plugin to flag orders as being already tracked.<br /><br />'.
376
+ 'Leaving this unchecked ensures that no order data will be tracked multiple times '.
377
+ 'in any ad or measurement system.<br />'.
378
+ 'Please only turn this feature on if you really need it!',
379
+ 'duracelltomi-google-tag-manager'
380
+ ),
381
+ 'phase' => GTM4WP_PHASE_STABLE
382
+ ),
383
+
384
+ GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS => array(
385
+ 'label' => __( 'Google Optimize container ID list', 'duracelltomi-google-tag-manager' ),
386
+ 'description' => sprintf(
387
+ __(
388
+ 'Enter a comma separated list of Google Optimize container IDs that you would like to use on your site.<br />' .
389
+ 'This plugin will add the <a href="%s">page-hiding snippet</a> to your pages.<br />',
390
+ 'duracelltomi-google-tag-manager'
391
+ ),
392
+ 'https://developers.google.com/optimize/#the_page-hiding_snippet_code'
393
+ ) .
394
+ '<br /><span class="goid_validation_error">' . __( 'This does not seems to be a valid Google Optimize ID! Valid format: GTM-XXXXXX or OPT-XXXXXX where X can be numbers and capital letters. Use comma without any space (,) to enter multpile IDs.', 'duracelltomi-google-tag-manager' ) . '</span>',
395
+ 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
396
+ ),
397
+ GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT => array(
398
+ 'label' => __( 'Google Optimize page-hiding timeout', 'duracelltomi-google-tag-manager' ),
399
+ 'description' => __( 'Enter here the amount of time in milliseconds that the page-hiding snippet should wait before page content gets visible even if Google Optimize has not been completely loaded yet.', 'duracelltomi-google-tag-manager' ),
400
+ 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
401
+ ),
402
+
403
+ GTM4WP_OPTION_INTEGRATE_AMPID => array(
404
+ 'label' => __( "Google Tag Manager 'AMP' Container ID", 'duracelltomi-google-tag-manager' ),
405
+ 'description' => sprintf( __( 'Enter a comma separated list of Google Tag Manager container IDs that you would like to use on your site. This plugin will add the <a href="%s">AMP GTM snippet</a> to your AMP pages.', 'duracelltomi-google-tag-manager' ), 'https://support.google.com/tagmanager/answer/6103696?hl=en' ) .
406
+ '<br /><span class="ampid_validation_error">' . __( 'This does not seems to be a valid Google Tag Manager Container ID! Valid format: GTM-XXXXXX where X can be numbers and capital letters. Use comma without any space (,) to enter multpile IDs.', 'duracelltomi-google-tag-manager' ) . '</span>',
407
+ 'phase' => GTM4WP_PHASE_EXPERIMENTAL,
408
+ 'plugintocheck' => 'amp/amp.php',
409
+ ),
410
+
411
+ GTM4WP_OPTION_INTEGRATE_COOKIEBOT => array(
412
+ 'label' => __( 'Cookiebot auto blocking', 'duracelltomi-google-tag-manager' ),
413
+ 'description' => sprintf( __( 'Enable this checkbox if you wish to use the <a href="%s" target="_blank" rel="noopener">automatic cookie blocking mode of Cookiebot with Google Tag Manager</a>.', 'duracelltomi-google-tag-manager' ), 'https://support.cookiebot.com/hc/en-us/articles/360009192739-Google-Tag-Manager-and-Automatic-cookie-blocking' ),
414
+ 'phase' => GTM4WP_PHASE_STABLE
415
+ ),
416
+ );
417
+
418
+ $GLOBALS['gtm4wp_advancedfieldtexts'] = array(
419
+ GTM4WP_OPTION_DATALAYER_NAME => array(
420
+ 'label' => __( 'dataLayer variable name', 'duracelltomi-google-tag-manager' ),
421
+ 'description' => __( 'In some cases you need to rename the dataLayer variable. You can enter your name here. Leave black for default name: dataLayer', 'duracelltomi-google-tag-manager' ),
422
+ 'phase' => GTM4WP_PHASE_STABLE,
423
+ ),
424
+ GTM4WP_OPTION_ENV_GTM_AUTH => array(
425
+ 'label' => __( 'Environment gtm_auth parameter', 'duracelltomi-google-tag-manager' ),
426
+ 'description' => __( 'Enter the gtm_auth parameter of the Google Tag Manager environment that has to be activated on this site. Both gtm_auth and gtm_preview parameters are required to activate the desired environment.', 'duracelltomi-google-tag-manager' ),
427
+ 'phase' => GTM4WP_PHASE_STABLE,
428
+ ),
429
+ GTM4WP_OPTION_ENV_GTM_PREVIEW => array(
430
+ 'label' => __( 'Environment gtm_preview parameter', 'duracelltomi-google-tag-manager' ),
431
+ 'description' => __( 'Enter the gtm_auth parameter of the Google Tag Manager environment that has to be activated on this site. Both gtm_auth and gtm_preview parameters are required to activate the desired environment.', 'duracelltomi-google-tag-manager' ),
432
+ 'phase' => GTM4WP_PHASE_STABLE,
433
+ ),
434
+ GTM4WP_OPTION_DONOTTRACK => array(
435
+ 'label' => __( "Include browser 'Do not track' setting", 'duracelltomi-google-tag-manager' ),
436
+ 'description' => __( 'Add into the data layer whether the user has asked not to track any website interaction. You may want to respect this and disable all tags if this variable is set in the data layer.', 'duracelltomi-google-tag-manager' ),
437
+ 'phase' => GTM4WP_PHASE_STABLE,
438
+ ),
439
+ GTM4WP_OPTION_LOADEARLY => array(
440
+ 'label' => __( 'Load GTM container as early as possible', 'duracelltomi-google-tag-manager' ),
441
+ 'description' => __( "Turning on this option will load your Google Tag Manager container as early as possible during page load. This can cause issues if you are using jQuery in your custom HTML tags that fire on 'Page View' events.", 'duracelltomi-google-tag-manager' ),
442
+ 'phase' => GTM4WP_PHASE_STABLE,
443
+ ),
444
+ GTM4WP_OPTION_GTMDOMAIN => array(
445
+ 'label' => __( 'Container domain name', 'duracelltomi-google-tag-manager' ),
446
+ 'description' => __( "Enter your custom domain name if you are using a server side GTM container for tracking. Do not include https:// prefix. Leave this blank to use www.googletagmanager.com", 'duracelltomi-google-tag-manager' ),
447
+ 'phase' => GTM4WP_PHASE_STABLE,
448
+ ),
449
+ GTM4WP_OPTION_NOGTMFORLOGGEDIN => array(
450
+ 'label' => __( 'User roles to exclude', 'duracelltomi-google-tag-manager' ),
451
+ 'description' => __( "Do not load GTM container on the frontend if role of the logged in user is any of this", 'duracelltomi-google-tag-manager' ),
452
+ 'phase' => GTM4WP_PHASE_STABLE,
453
+ )
454
+ );
455
+
456
+ function gtm4wp_admin_output_section( $args ) {
457
+ echo '<span class="tabinfo">';
458
+
459
+ switch ( $args['id'] ) {
460
+ case GTM4WP_ADMIN_GROUP_GENERAL: {
461
+ _e( 'This plugin is intended to be used by IT girls&guys and marketing staff. Please be sure you read the <a href="https://developers.google.com/tag-manager/" target="_blank" rel="noopener">Google Tag Manager Help Center</a> before you start using this plugin.<br /><br />', 'duracelltomi-google-tag-manager' );
462
+
463
+ break;
464
+ }
465
+
466
+ case GTM4WP_ADMIN_GROUP_INCLUDES: {
467
+ _e( 'Here you can check what data is needed to be included in the dataLayer to be able to access them in Google Tag Manager', 'duracelltomi-google-tag-manager' );
468
+ echo '<br />';
469
+ printf( __( '* Browser, OS and Device data is provided using <a href="%s">WhichBrowser</a> library.', 'duracelltomi-google-tag-manager' ), 'http://whichbrowser.net/' );
470
+
471
+ break;
472
+ }
473
+
474
+ case GTM4WP_ADMIN_GROUP_EVENTS: {
475
+ _e( 'Fire tags in Google Tag Manager on special events on your website', 'duracelltomi-google-tag-manager' );
476
+
477
+ break;
478
+ }
479
+
480
+ case GTM4WP_ADMIN_GROUP_SCROLLER: {
481
+ _e( 'Fire tags based on how the visitor scrolls through your page.', 'duracelltomi-google-tag-manager' );
482
+ echo '<br />';
483
+ printf( __( 'Based on the script originaly posted to <a href="%s">Analytics Talk</a>', 'duracelltomi-google-tag-manager' ), 'http://cutroni.com/blog/2012/02/21/advanced-content-tracking-with-google-analytics-part-1/' );
484
+
485
+ break;
486
+ }
487
+
488
+ case GTM4WP_ADMIN_GROUP_BLACKLIST: {
489
+ _e( 'Here you can control which types of tags, triggers and variables can be executed on your site regardless of what tags are included in your container on the Google Tag Manager site. Use this to increase security!', 'duracelltomi-google-tag-manager' );
490
+ echo '<br />';
491
+ _e( 'Do not modify if you do not know what to do, since it can cause issues with your tag deployment!', 'duracelltomi-google-tag-manager' );
492
+ echo '<br />';
493
+ _e( 'For example blacklisting everything and only whitelisting the Google Analytics tag without whitelisting the URL variable type will cause your Google Analytics tags to be blocked anyway since the attached triggers (Page View) can not fire!', 'duracelltomi-google-tag-manager' );
494
+
495
+ break;
496
+ }
497
+
498
+ case GTM4WP_ADMIN_GROUP_INTEGRATION: {
499
+ _e( 'Google Tag Manager for WordPress can integrate with several popular plugins. Please check the plugins you would like to integrate with:', 'duracelltomi-google-tag-manager' );
500
+
501
+ break;
502
+ }
503
+
504
+ case GTM4WP_ADMIN_GROUP_ADVANCED: {
505
+ _e( 'You usually do not need to modify thoose settings. Please be carefull while hacking here.', 'duracelltomi-google-tag-manager' );
506
+
507
+ break;
508
+ }
509
+
510
+ case GTM4WP_ADMIN_GROUP_CREDITS: {
511
+ _e( 'Some info about the author of this plugin', 'duracelltomi-google-tag-manager' );
512
+
513
+ break;
514
+ }
515
+ } // end switch
516
+
517
+ echo '</span>';
518
+ }
519
+
520
+ function gtm4wp_admin_output_field( $args ) {
521
+ global $gtm4wp_options, $gtm4wp_business_verticals;
522
+
523
+ switch ( $args['label_for'] ) {
524
+ case GTM4WP_ADMIN_GROUP_GTMID: {
525
+ if ( defined( 'GTM4WP_HARDCODED_GTM_ID' ) ) {
526
+ $_gtm_id_value = GTM4WP_HARDCODED_GTM_ID;
527
+ $_input_readonly = ' readonly="readonly"';
528
+ $_warning_after = '<br /><span class="gtm_wpconfig_set">WARNING! Container ID was set and fixed in wp-config.php. If you wish to change this value, please edit your wp-config.php and change the container ID or remove the GTM4WP_HARDCODED_GTM_ID constant!</span>';
529
+ } else {
530
+ $_gtm_id_value = $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ];
531
+ $_input_readonly = '';
532
+ $_warning_after = '';
533
+ }
534
+
535
+ echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_CODE . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_CODE . ']" value="' . $_gtm_id_value . '" ' . $_input_readonly . '/><br />' . $args['description'];
536
+ echo $_warning_after;
537
+ echo '<br /><span class="gtmid_validation_error">' . __( 'This does not seems to be a valid Google Tag Manager ID! Valid format: GTM-XXXXX where X can be numbers and capital letters. Use comma without any space (,) to enter multpile container IDs.', 'duracelltomi-google-tag-manager' ) . '</span>';
538
+
539
+ break;
540
+ }
541
+
542
+ case GTM4WP_ADMIN_GROUP_CONTAINERON: {
543
+ echo $args['description'].'<br/><br/>';
544
+ echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[container-on]_1" name="' . GTM4WP_OPTIONS . '[container-on]" value="1" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] != GTM4WP_PLACEMENT_OFF ? 'checked="checked"' : '' ) . '/> ' . __( 'On', 'duracelltomi-google-tag-manager' ) . '<br />';
545
+ echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[container-on]_0" name="' . GTM4WP_OPTIONS . '[container-on]" value="0" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_OFF ? 'checked="checked"' : '' ) . '/> ' . __( 'Off', 'duracelltomi-google-tag-manager' ) . '<br />';
546
+
547
+ break;
548
+ }
549
+
550
+ case GTM4WP_ADMIN_GROUP_COMPATMODE: {
551
+ echo $args['description'].'<br/><br/>';
552
+ echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[compat-mode]_' . GTM4WP_PLACEMENT_BODYOPEN_AUTO . '" name="' . GTM4WP_OPTIONS . '[compat-mode]" value="' . GTM4WP_PLACEMENT_BODYOPEN_AUTO . '" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_BODYOPEN_AUTO || $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_OFF ? 'checked="checked"' : '' ) . '/> ' . __( 'Off (no tweak, right placement)', 'duracelltomi-google-tag-manager' ) . '<br />';
553
+ echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[compat-mode]_' . GTM4WP_PLACEMENT_FOOTER . '" name="' . GTM4WP_OPTIONS . '[compat-mode]" value="' . GTM4WP_PLACEMENT_FOOTER . '" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_FOOTER ? 'checked="checked"' : '' ) . '/> ' . __( 'Footer of the page (not recommended by Google, Search Console verification will not work)', 'duracelltomi-google-tag-manager' ) . '<br />';
554
+ echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[compat-mode]_' . GTM4WP_PLACEMENT_BODYOPEN . '" name="' . GTM4WP_OPTIONS . '[compat-mode]" value="' . GTM4WP_PLACEMENT_BODYOPEN . '" ' . ( $gtm4wp_options[ GTM4WP_OPTION_GTM_PLACEMENT ] == GTM4WP_PLACEMENT_BODYOPEN ? 'checked="checked"' : '' ) . '/> ' . __( 'Manually coded (needs tweak in your template)', 'duracelltomi-google-tag-manager' ) . '<br />';
555
+
556
+ break;
557
+ }
558
+
559
+ case GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']': {
560
+ echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']" value="' . $gtm4wp_options[ GTM4WP_OPTION_DATALAYER_NAME ] . '" /><br />' . $args['description'];
561
+ echo '<br /><span class="datalayername_validation_error">' . __( 'This does not seems to be a valid JavaScript variable name! Please check and try again', 'duracelltomi-google-tag-manager' ) . '</span>';
562
+
563
+ break;
564
+ }
565
+
566
+ case GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']': {
567
+ if ( defined( 'GTM4WP_HARDCODED_GTM_ENV_AUTH' ) ) {
568
+ $_gtm_auth_value = GTM4WP_HARDCODED_GTM_ENV_AUTH;
569
+ $_input_readonly = ' readonly="readonly"';
570
+ $_warning_after = '<br /><span class="gtm_wpconfig_set">WARNING! Environment auth parameter was set and fixed in wp-config.php. If you wish to change this value, please edit your wp-config.php and change the parameter value or remove the GTM4WP_HARDCODED_GTM_ENV_AUTH constant!</span>';
571
+ } else {
572
+ $_gtm_auth_value = $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ];
573
+ $_input_readonly = '';
574
+ $_warning_after = '';
575
+ }
576
+
577
+ echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']" value="' . $_gtm_auth_value . '" ' . $_input_readonly . '/><br />' . $args['description'];
578
+ echo $_warning_after;
579
+ echo '<br /><span class="gtmauth_validation_error">' . __( 'This does not seems to be a valid gtm_auth parameter! It should only contain letters, number and the &quot;-&quot; character. Please check and try again', 'duracelltomi-google-tag-manager' ) . '</span>';
580
+
581
+ break;
582
+ }
583
+
584
+ case GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']': {
585
+ if ( defined( 'GTM4WP_HARDCODED_GTM_ENV_PREVIEW' ) ) {
586
+ $_gtm_preview_value = GTM4WP_HARDCODED_GTM_ENV_PREVIEW;
587
+ $_input_readonly = ' readonly="readonly"';
588
+ $_warning_after = '<br /><span class="gtm_wpconfig_set">WARNING! Environment preview parameter was set and fixed in wp-config.php. If you wish to change this value, please edit your wp-config.php and change the parameter value or remove the GTM4WP_HARDCODED_GTM_ENV_PREVIEW constant!</span>';
589
+ } else {
590
+ $_gtm_preview_value = $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ];
591
+ $_input_readonly = '';
592
+ $_warning_after = '';
593
+ }
594
+
595
+ echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']" value="' . $_gtm_preview_value . '" ' . $_input_readonly . '/><br />' . $args['description'];
596
+ echo $_warning_after;
597
+ echo '<br /><span class="gtmpreview_validation_error">' . __( 'This does not seems to be a valid gtm_preview parameter! It should have the format &quot;env-NN&quot; where NN is an integer number. Please check and try again', 'duracelltomi-google-tag-manager' ) . '</span>';
598
+
599
+ break;
600
+ }
601
+
602
+ case GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']': {
603
+ echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']_0" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']" value="0" ' . ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] == 0 ? 'checked="checked"' : '' ) . '/> ' . __( 'Disable feature: control everything on Google Tag Manager interface', 'duracelltomi-google-tag-manager' ) . '<br />';
604
+ echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']_1" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']" value="1" ' . ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] == 1 ? 'checked="checked"' : '' ) . '/> ' . __( 'Allow all, except the checked items on all blacklist tabs (blacklist)', 'duracelltomi-google-tag-manager' ) . '<br />';
605
+ echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']_2" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']" value="2" ' . ( $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] == 2 ? 'checked="checked"' : '' ) . '/> ' . __( 'Block all, except the checked items on all blacklist tabs (whitelist)', 'duracelltomi-google-tag-manager' ) . '<br />';
606
+ echo $args['description'];
607
+
608
+ break;
609
+ }
610
+
611
+ case GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']': {
612
+ echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']_0" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']" value="0" ' . ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHERUNITS ] == 0 ? 'checked="checked"' : '' ) . '/> ' . __( 'Celsius', 'duracelltomi-google-tag-manager' ) . '<br />';
613
+ echo '<input type="radio" id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']_1" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INCLUDE_WEATHERUNITS . ']" value="1" ' . ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHERUNITS ] == 1 ? 'checked="checked"' : '' ) . '/> ' . __( 'Fahrenheit', 'duracelltomi-google-tag-manager' ) . '<br />';
614
+ echo $args['description'];
615
+
616
+ break;
617
+ }
618
+
619
+ case GTM4WP_ADMIN_GROUP_INFO: {
620
+ echo $args['description'];
621
+
622
+ break;
623
+ }
624
+
625
+ case GTM4WP_OPTIONS . "[" . GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY . "]": {
626
+ echo '<select id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY . ']">';
627
+ echo '<option value="">(not set)</option>';
628
+
629
+ $gtm4wp_taxonomies = get_taxonomies(array(
630
+ "show_ui" => true,
631
+ "public" => true,
632
+ "_builtin" => false
633
+ ), "object", "and");
634
+
635
+ foreach( $gtm4wp_taxonomies as $onetaxonomy ) {
636
+ echo '<option value="' . $onetaxonomy->name . '"' . ( $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY] === $onetaxonomy->name ? ' selected="selected"' : '' ) . '>' . $onetaxonomy->label . '</option>';
637
+ }
638
+
639
+ echo '</select>';
640
+
641
+ break;
642
+ }
643
+
644
+ case GTM4WP_OPTIONS . "[" . GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL . "]": {
645
+ echo '<select id="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL . ']" name="' . GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL . ']">';
646
+
647
+ foreach( $gtm4wp_business_verticals as $vertical_id => $vertical_display_name ) {
648
+ echo '<option value="' . $vertical_id . '"' . ( $gtm4wp_options[GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL] === $vertical_id ? ' selected="selected"' : '' ) . '>' . $vertical_display_name . '</option>';
649
+ }
650
+
651
+ echo '</select><br>' . $args['description'];
652
+
653
+ break;
654
+ }
655
+
656
+ case GTM4WP_OPTIONS . "[" . GTM4WP_OPTION_NOGTMFORLOGGEDIN . "]": {
657
+ $roles = get_editable_roles();
658
+
659
+ echo $args['description'].'<br/><br/>';
660
+
661
+ $saved_roles = explode(",", $gtm4wp_options[GTM4WP_OPTION_NOGTMFORLOGGEDIN]);
662
+
663
+ foreach($roles as $role_id => $role_info) {
664
+ $role_name = translate_user_role( $role_info['name'] );
665
+ echo '<input type="checkbox" id="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']_' . $role_id . '" name="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . '][]" value="' . $role_id . '"' . ( in_array( $role_id, $saved_roles ) ? ' checked="checked"' : '' ) . '><label for="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']_' . $role_id . '">' . $role_name . '</label><br/>';
666
+ }
667
+
668
+ break;
669
+ }
670
+
671
+ default: {
672
+ if ( preg_match( '/' . GTM4WP_OPTIONS . "\\[blacklist\\-[^\\]]+\\]/i", $args['label_for'] ) ) {
673
+ if ( 'blacklist-sandboxed' == $args['entityid'] ) {
674
+ echo '<input type="checkbox" id="' . $args['label_for'] . '" name="' . $args['label_for'] . '" value="1" ' . checked( 1, $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_SANDBOXED ], false ) . ' /><br />' . $args['description'];
675
+ } else {
676
+ echo '<input type="checkbox" id="' . $args['label_for'] . '" name="' . $args['label_for'] . '" value="1" ' . checked( 1, in_array( $args['entityid'], $gtm4wp_options[ GTM4WP_OPTION_BLACKLIST_STATUS ] ), false ) . ' /><br />' . $args['description'];
677
+ }
678
+ } else {
679
+ $optval = $gtm4wp_options[ $args['optionfieldid'] ];
680
+
681
+ switch ( gettype( $optval ) ) {
682
+ case 'boolean': {
683
+ echo '<input type="checkbox" id="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" name="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" value="1" ' . checked( 1, $optval, false ) . ' /><br />' . $args['description'];
684
+
685
+ if ( isset( $args['plugintocheck'] ) && ( $args['plugintocheck'] != '' ) ) {
686
+ if ( is_plugin_active( $args['plugintocheck'] ) ) {
687
+ echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-active">active</strong>, it is strongly recommended to enable this integration!', 'duracelltomi-google-tag-manager' );
688
+ } else {
689
+ echo '<br />' . __( 'This plugin (' . $args['plugintocheck'] . ') is <strong class="gtm4wp-plugin-not-active">not active</strong>, enabling this integration could cause issues on frontend!', 'duracelltomi-google-tag-manager' );
690
+ }
691
+ }
692
+
693
+ break;
694
+ }
695
+
696
+ case 'integer': {
697
+ echo '<input type="number" step="1" min="0" class="small-text" id="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" name="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" value="' . esc_attr( $optval ) . '" /><br />' . $args['description'];
698
+
699
+ if ( isset( $args['plugintocheck'] ) && ( $args['plugintocheck'] != '' ) ) {
700
+ if ( is_plugin_active( $args['plugintocheck'] ) ) {
701
+ echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-active">active</strong>, it is strongly recommended to enable this integration!', 'duracelltomi-google-tag-manager' );
702
+ } else {
703
+ echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-not-active">not active</strong>, enabling this integration could cause issues on frontend!', 'duracelltomi-google-tag-manager' );
704
+ }
705
+ }
706
+
707
+ break;
708
+ }
709
+
710
+ default : {
711
+ echo '<input type="text" id="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" name="' . GTM4WP_OPTIONS . '[' . $args['optionfieldid'] . ']" value="' . esc_attr( $optval ) . '" size="80" /><br />' . $args['description'];
712
+
713
+ if ( isset( $args['plugintocheck'] ) && ( $args['plugintocheck'] != '' ) ) {
714
+ if ( is_plugin_active( $args['plugintocheck'] ) ) {
715
+ echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-active">active</strong>, it is strongly recommended to enable this integration!', 'duracelltomi-google-tag-manager' );
716
+ } else {
717
+ echo '<br />' . __( 'This plugin is <strong class="gtm4wp-plugin-not-active">not active</strong>, enabling this integration could cause issues on frontend!', 'duracelltomi-google-tag-manager' );
718
+ }
719
+ }
720
+ }
721
+ } // end switch gettype optval
722
+ }
723
+ }
724
+ } // end switch
725
+ }
726
+
727
+ function gtm4wp_sanitize_options( $options ) {
728
+ global $wpdb, $gtm4wp_entity_ids;
729
+
730
+ $output = gtm4wp_reload_options();
731
+
732
+ foreach ( $output as $optionname => $optionvalue ) {
733
+ if ( isset( $options[ $optionname ] ) ) {
734
+ $newoptionvalue = $options[ $optionname ];
735
+ } else {
736
+ $newoptionvalue = '';
737
+ }
738
+
739
+ // "include" settings
740
+ if ( substr( $optionname, 0, 8 ) == 'include-' ) {
741
+ $output[ $optionname ] = (bool) $newoptionvalue;
742
+
743
+ // dataLayer events
744
+ } elseif ( substr( $optionname, 0, 6 ) == 'event-' ) {
745
+ $output[ $optionname ] = (bool) $newoptionvalue;
746
+
747
+ // clear oembed transients when feature is enabled because we need to hook into the oembed process to enable some 3rd party APIs
748
+ if ( $output[ $optionname ] && ! $optionvalue ) {
749
+ if ( GTM4WP_OPTION_EVENTS_YOUTUBE == $optionname ) {
750
+ $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_value LIKE '%youtube.com%' AND meta_key LIKE '_oembed_%'" );
751
+ }
752
+
753
+ if ( GTM4WP_OPTION_EVENTS_VIMEO == $optionname ) {
754
+ $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_value LIKE '%vimeo.com%' AND meta_key LIKE '_oembed_%'" );
755
+ }
756
+ }
757
+
758
+ // blacklist / whitelist entities
759
+ } elseif ( substr( $optionname, 0, 10 ) == 'blacklist-' ) {
760
+ if ( GTM4WP_OPTION_BLACKLIST_ENABLE === $optionname ) {
761
+ $output[ $optionname ] = (int) $options[ GTM4WP_OPTION_BLACKLIST_ENABLE ];
762
+ } else if ( GTM4WP_OPTION_BLACKLIST_SANDBOXED == $optionname ) {
763
+ $output[ $optionname ] = (bool) $newoptionvalue;
764
+ } else if ( GTM4WP_OPTION_BLACKLIST_STATUS == $optionname ) {
765
+ $selected_blacklist_entities = array();
766
+
767
+ foreach( $gtm4wp_entity_ids as $gtm_entity_group_id => $gtm_entity_group_list ) {
768
+ foreach( $gtm_entity_group_list as $gtm_entity_id => $gtm_entity_label ) {
769
+ $entity_option_id = 'blacklist-' . $gtm_entity_group_id . '-' . $gtm_entity_id;
770
+ if ( array_key_exists( $entity_option_id, $options ) ) {
771
+ $newoptionvalue = (bool) $options[ $entity_option_id ];
772
+ if ( $newoptionvalue ) {
773
+ $selected_blacklist_entities[] = $gtm_entity_id;
774
+ }
775
+ }
776
+ }
777
+ }
778
+
779
+ $output[ $optionname ] = implode( ',', $selected_blacklist_entities );
780
+ }
781
+
782
+ // Google Optimize settings
783
+ } elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS ) {
784
+ $_goid_val = trim( $newoptionvalue );
785
+ if ( '' == $_goid_val ) {
786
+ $_goid_list = array();
787
+ } else {
788
+ $_goid_list = explode( ',', $_goid_val );
789
+ }
790
+ $_goid_haserror = false;
791
+
792
+ foreach ( $_goid_list as $one_go_id ) {
793
+ $_goid_haserror = $_goid_haserror || ! preg_match( '/^(GTM|OPT)-[A-Z0-9]+$/', $one_go_id );
794
+ }
795
+
796
+ if ( $_goid_haserror && ( count( $_goid_list ) > 0 ) ) {
797
+ add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZEIDS . ']', __( 'Invalid Google Optimize ID. Valid ID format: GTM-XXXXX or OPT-XXXXX. Use comma without additional space (,) to enter more than one ID.', 'duracelltomi-google-tag-manager' ) );
798
+ } else {
799
+ $output[ $optionname ] = $newoptionvalue;
800
+ }
801
+ } elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_GOOGLEOPTIMIZETIMEOUT ) {
802
+ $output[ $optionname ] = (int) $newoptionvalue;
803
+
804
+ } elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION ) {
805
+ $output[ $optionname ] = (int) $newoptionvalue;
806
+
807
+ } elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_WCORDERMAXAGE ) {
808
+ $output[ $optionname ] = (int) $newoptionvalue;
809
+
810
+ }elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX ) {
811
+ $output[ $optionname ] = trim( (string) $newoptionvalue );
812
+
813
+ } else if ( $optionname == GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY ) {
814
+ $output[$optionname] = trim( (string) $newoptionvalue );
815
+
816
+ } else if ( $optionname == GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL ) {
817
+ $output[$optionname] = trim( (string) $newoptionvalue );
818
+
819
+ } else if ( $optionname == GTM4WP_OPTION_GTMDOMAIN ) {
820
+ // for PHP 7- compatibility
821
+ if ( !defined("FILTER_FLAG_HOSTNAME") ) {
822
+ define( "FILTER_FLAG_HOSTNAME", 0 );
823
+ }
824
+
825
+ // remove https:// prefix if used
826
+ $newoptionvalue = str_replace( 'https://', '', $newoptionvalue );
827
+
828
+ $newoptionvalue = filter_var( $newoptionvalue, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME );
829
+ if ( $newoptionvalue === false ) {
830
+ $newoptionvalue = '';
831
+ }
832
+ $output[$optionname] = trim( (string) $newoptionvalue );
833
+
834
+ // Accelerated Mobile Pages settings
835
+ } elseif ( $optionname == GTM4WP_OPTION_INTEGRATE_AMPID ) {
836
+ $_ampid_val = trim( $newoptionvalue );
837
+ if ( '' == $_ampid_val ) {
838
+ $_ampid_list = array();
839
+ } else {
840
+ $_ampid_list = explode( ',', $_ampid_val );
841
+ }
842
+ $_ampid_haserror = false;
843
+
844
+ foreach ( $_ampid_list as $one_amp_id ) {
845
+ $_ampid_haserror = $_ampid_haserror || ! preg_match( '/^GTM-[A-Z0-9]+$/', $one_amp_id );
846
+ }
847
+
848
+ if ( $_ampid_haserror && ( count( $_ampid_list ) > 0 ) ) {
849
+ add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_INTEGRATE_AMPID . ']', __( 'Invalid AMP Google Tag Manager Container ID. Valid ID format: GTM-XXXXX. Use comma without additional space (,) to enter more than one ID.', 'duracelltomi-google-tag-manager' ) );
850
+ } else {
851
+ $output[ $optionname ] = $newoptionvalue;
852
+ }
853
+
854
+ // integrations
855
+ } elseif ( substr( $optionname, 0, 10 ) == 'integrate-' ) {
856
+ $output[ $optionname ] = (bool) $newoptionvalue;
857
+
858
+ // GTM code or dataLayer variable name
859
+ } elseif ( ( $optionname == GTM4WP_OPTION_GTM_CODE ) || ( $optionname == GTM4WP_OPTION_DATALAYER_NAME ) || ( $optionname == GTM4WP_OPTION_ENV_GTM_AUTH ) || ( $optionname == GTM4WP_OPTION_ENV_GTM_PREVIEW ) ) {
860
+ $newoptionvalue = trim( $newoptionvalue );
861
+
862
+ if ( $optionname == GTM4WP_OPTION_GTM_CODE ) {
863
+ $_gtmid_list = explode( ',', $newoptionvalue );
864
+ $_gtmid_haserror = false;
865
+
866
+ foreach ( $_gtmid_list as $one_gtm_id ) {
867
+ $_gtmid_haserror = $_gtmid_haserror || ! preg_match( '/^GTM-[A-Z0-9]+$/', $one_gtm_id );
868
+ }
869
+
870
+ if ( $_gtmid_haserror ) {
871
+ add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_GTM_CODE . ']', __( 'Invalid Google Tag Manager ID. Valid ID format: GTM-XXXXX. Use comma without additional space (,) to enter more than one container ID.', 'duracelltomi-google-tag-manager' ) );
872
+ } else {
873
+ $output[ $optionname ] = $newoptionvalue;
874
+ }
875
+ } elseif ( ( $optionname == GTM4WP_OPTION_DATALAYER_NAME ) && ( $newoptionvalue != '' ) && ( ! preg_match( '/^[a-zA-Z][a-zA-Z0-9_-]*$/', $newoptionvalue ) ) ) {
876
+ add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_DATALAYER_NAME . ']', __( "Invalid dataLayer variable name. Please start with a character from a-z or A-Z followed by characters from a-z, A-Z, 0-9 or '_' or '-'!", 'duracelltomi-google-tag-manager' ) );
877
+
878
+ } elseif ( ( $optionname == GTM4WP_OPTION_ENV_GTM_AUTH ) && ( $newoptionvalue != '' ) && ( ! preg_match( '/^[a-zA-Z0-9-_]+$/', $newoptionvalue ) ) ) {
879
+ add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_AUTH . ']', __( "Invalid gtm_auth environment parameter value. It should only contain letters, numbers or the '-' and '_' characters.", 'duracelltomi-google-tag-manager' ) );
880
+
881
+ } elseif ( ( $optionname == GTM4WP_OPTION_ENV_GTM_PREVIEW ) && ( $newoptionvalue != '' ) && ( ! preg_match( '/^env-[0-9]+$/', $newoptionvalue ) ) ) {
882
+ add_settings_error( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_ENV_GTM_PREVIEW . ']', __( "Invalid gtm_preview environment parameter value. It should have the format 'env-NN' where NN is an integer number.", 'duracelltomi-google-tag-manager' ) );
883
+
884
+ } else {
885
+ $output[ $optionname ] = $newoptionvalue;
886
+ }
887
+
888
+ // GTM container ON/OFF + compat mode
889
+ } elseif ( $optionname == GTM4WP_OPTION_GTM_PLACEMENT ) {
890
+ $container_on_off = (bool) $options['container-on'];
891
+ $container_compat = (int) $options['compat-mode'];
892
+
893
+ if ( !$container_on_off ) {
894
+ $output[ $optionname ] = GTM4WP_PLACEMENT_OFF;
895
+ } else {
896
+ if ( ( $container_compat < 0 ) || ( $container_compat > 2 ) ) {
897
+ $container_compat = 2;
898
+ }
899
+
900
+ $output[ $optionname ] = $container_compat;
901
+ }
902
+
903
+ // scroll tracking content ID
904
+ } elseif ( $optionname == GTM4WP_OPTION_SCROLLER_CONTENTID ) {
905
+ $output[ $optionname ] = trim( str_replace( '#', '', $newoptionvalue ) );
906
+
907
+ // do not output GTM container code for specific user roles
908
+ } elseif ( $optionname == GTM4WP_OPTION_NOGTMFORLOGGEDIN ) {
909
+ if ( is_array( $newoptionvalue ) ) {
910
+ $output[ $optionname ] = implode(",", $newoptionvalue );
911
+ } else {
912
+ $output[ $optionname ] = '';
913
+ }
914
+
915
+ // anything else
916
+ } else {
917
+ switch ( gettype( $optionvalue ) ) {
918
+ case 'boolean': {
919
+ $output[ $optionname ] = (bool) $newoptionvalue;
920
+
921
+ break;
922
+ }
923
+
924
+ case 'integer': {
925
+ $output[ $optionname ] = (int) $newoptionvalue;
926
+
927
+ break;
928
+ }
929
+
930
+ default: {
931
+ $output[ $optionname ] = $newoptionvalue;
932
+ }
933
+ } // end switch
934
+ }
935
+ }
936
+
937
+ return $output;
938
+ }
939
+
940
+ function gtm4wp_admin_init() {
941
+ global $gtm4wp_includefieldtexts, $gtm4wp_eventfieldtexts, $gtm4wp_integratefieldtexts, $gtm4wp_scrollerfieldtexts,
942
+ $gtm4wp_advancedfieldtexts, $gtm4wp_entity_ids;
943
+
944
+ register_setting( GTM4WP_ADMIN_GROUP, GTM4WP_OPTIONS, 'gtm4wp_sanitize_options' );
945
+
946
+ add_settings_section(
947
+ GTM4WP_ADMIN_GROUP_GENERAL,
948
+ __( 'General', 'duracelltomi-google-tag-manager' ),
949
+ 'gtm4wp_admin_output_section',
950
+ GTM4WP_ADMINSLUG
951
+ );
952
+
953
+ add_settings_field(
954
+ GTM4WP_ADMIN_GROUP_GTMID,
955
+ __( 'Google Tag Manager ID', 'duracelltomi-google-tag-manager' ),
956
+ 'gtm4wp_admin_output_field',
957
+ GTM4WP_ADMINSLUG,
958
+ GTM4WP_ADMIN_GROUP_GENERAL,
959
+ array(
960
+ 'label_for' => GTM4WP_ADMIN_GROUP_GTMID,
961
+ 'description' => __( 'Enter your Google Tag Manager ID here. Use comma without space (,) to enter multiple IDs.', 'duracelltomi-google-tag-manager' ),
962
+ )
963
+ );
964
+
965
+ add_settings_field(
966
+ GTM4WP_ADMIN_GROUP_CONTAINERON,
967
+ __( 'Container code ON/OFF', 'duracelltomi-google-tag-manager' ),
968
+ 'gtm4wp_admin_output_field',
969
+ GTM4WP_ADMINSLUG,
970
+ GTM4WP_ADMIN_GROUP_GENERAL,
971
+ array(
972
+ 'label_for' => GTM4WP_ADMIN_GROUP_CONTAINERON,
973
+ 'description' => __( "Turning OFF the Google Tag Manager container itself will remove both the head and the body part of the container code but leave data layer codes working.<br/>This should be only used in specific cases where you need to place the container code manually or using another tool.", 'duracelltomi-google-tag-manager' ),
974
+ )
975
+ );
976
+
977
+ add_settings_field(
978
+ GTM4WP_ADMIN_GROUP_COMPATMODE,
979
+ __( 'Container code compatibility mode', 'duracelltomi-google-tag-manager' ),
980
+ 'gtm4wp_admin_output_field',
981
+ GTM4WP_ADMINSLUG,
982
+ GTM4WP_ADMIN_GROUP_GENERAL,
983
+ array(
984
+ 'label_for' => GTM4WP_ADMIN_GROUP_COMPATMODE,
985
+ 'description' => __(
986
+ 'Compatibility mode decides where to put the second, so called <code>&lt;noscript&gt;</code> or <code>&lt;iframe&gt;</code> part of the GTM container code.<br />'.
987
+ 'This code is usually only executed if your visitor has disabled JavaScript for some reason.<br/>'.
988
+ 'It is also mandatory in order to verify your site in Google Search Console using the GTM method.<br/>'.
989
+ 'The main GTM container code will be placed into the <code>&lt;head&gt;</code> section of your webpages anyway (where it belongs to).<br/><br/>'.
990
+ 'If you select "Manually coded", you need to edit your template files and add the following line just after the opening <code>&lt;body&gt;</code> tag:<br />'.
991
+ "<code>&lt;?php if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) { gtm4wp_the_gtm_tag(); } ?&gt;</code>",
992
+ 'duracelltomi-google-tag-manager'
993
+ ),
994
+ )
995
+ );
996
+
997
+ add_settings_section(
998
+ GTM4WP_ADMIN_GROUP_INCLUDES,
999
+ __( 'Basic data', 'duracelltomi-google-tag-manager' ),
1000
+ 'gtm4wp_admin_output_section',
1001
+ GTM4WP_ADMINSLUG
1002
+ );
1003
+
1004
+ foreach ( $gtm4wp_includefieldtexts as $fieldid => $fielddata ) {
1005
+ $phase = isset( $fielddata['phase'] ) ? $fielddata['phase'] : GTM4WP_PHASE_STABLE;
1006
+
1007
+ add_settings_field(
1008
+ 'gtm4wp-admin-' . $fieldid . '-id',
1009
+ $fielddata['label'] . '<span class="' . $phase . '"></span>',
1010
+ 'gtm4wp_admin_output_field',
1011
+ GTM4WP_ADMINSLUG,
1012
+ GTM4WP_ADMIN_GROUP_INCLUDES,
1013
+ array(
1014
+ 'label_for' => 'gtm4wp-options[' . $fieldid . ']',
1015
+ 'description' => $fielddata['description'],
1016
+ 'optionfieldid' => $fieldid,
1017
+ )
1018
+ );
1019
+ }
1020
+
1021
+ add_settings_section(
1022
+ GTM4WP_ADMIN_GROUP_EVENTS,
1023
+ __( 'Events', 'duracelltomi-google-tag-manager' ),
1024
+ 'gtm4wp_admin_output_section',
1025
+ GTM4WP_ADMINSLUG
1026
+ );
1027
+
1028
+ foreach ( $gtm4wp_eventfieldtexts as $fieldid => $fielddata ) {
1029
+ $phase = isset( $fielddata['phase'] ) ? $fielddata['phase'] : GTM4WP_PHASE_STABLE;
1030
+
1031
+ add_settings_field(
1032
+ 'gtm4wp-admin-' . $fieldid . '-id',
1033
+ $fielddata['label'] . '<span class="' . $phase . '"></span>',
1034
+ 'gtm4wp_admin_output_field',
1035
+ GTM4WP_ADMINSLUG,
1036
+ GTM4WP_ADMIN_GROUP_EVENTS,
1037
+ array(
1038
+ 'label_for' => 'gtm4wp-options[' . $fieldid . ']',
1039
+ 'description' => $fielddata['description'],
1040
+ 'optionfieldid' => $fieldid,
1041
+ )
1042
+ );
1043
+ }
1044
+
1045
+ add_settings_section(
1046
+ GTM4WP_ADMIN_GROUP_SCROLLER,
1047
+ __( 'Scroll tracking', 'duracelltomi-google-tag-manager' ),
1048
+ 'gtm4wp_admin_output_section',
1049
+ GTM4WP_ADMINSLUG
1050
+ );
1051
+
1052
+ foreach ( $gtm4wp_scrollerfieldtexts as $fieldid => $fielddata ) {
1053
+ $phase = isset( $fielddata['phase'] ) ? $fielddata['phase'] : GTM4WP_PHASE_STABLE;
1054
+
1055
+ add_settings_field(
1056
+ 'gtm4wp-admin-' . $fieldid . '-id',
1057
+ $fielddata['label'] . '<span class="' . $phase . '"></span>',
1058
+ 'gtm4wp_admin_output_field',
1059
+ GTM4WP_ADMINSLUG,
1060
+ GTM4WP_ADMIN_GROUP_SCROLLER,
1061
+ array(
1062
+ 'label_for' => 'gtm4wp-options[' . $fieldid . ']',
1063
+ 'description' => $fielddata['description'],
1064
+ 'optionfieldid' => $fieldid,
1065
+ )
1066
+ );
1067
+ }
1068
+
1069
+ add_settings_section(
1070
+ GTM4WP_ADMIN_GROUP_BLACKLIST,
1071
+ __( 'Security', 'duracelltomi-google-tag-manager' ),
1072
+ 'gtm4wp_admin_output_section',
1073
+ GTM4WP_ADMINSLUG
1074
+ );
1075
+
1076
+ add_settings_field(
1077
+ GTM4WP_OPTION_BLACKLIST_ENABLE,
1078
+ __( 'Enable blacklist/whitelist', 'duracelltomi-google-tag-manager' ),
1079
+ 'gtm4wp_admin_output_field',
1080
+ GTM4WP_ADMINSLUG,
1081
+ GTM4WP_ADMIN_GROUP_BLACKLIST,
1082
+ array(
1083
+ 'label_for' => GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_ENABLE . ']',
1084
+ 'description' => '',
1085
+ 'optionsfieldid' => GTM4WP_OPTION_BLACKLIST_ENABLE
1086
+ )
1087
+ );
1088
+
1089
+ add_settings_field(
1090
+ GTM4WP_OPTION_BLACKLIST_SANDBOXED,
1091
+ __( 'Custom tag/variable templates', 'duracelltomi-google-tag-manager' ),
1092
+ 'gtm4wp_admin_output_field',
1093
+ GTM4WP_ADMINSLUG,
1094
+ GTM4WP_ADMIN_GROUP_BLACKLIST,
1095
+ array(
1096
+ 'label_for' => GTM4WP_OPTIONS . '[' . GTM4WP_OPTION_BLACKLIST_SANDBOXED . ']',
1097
+ 'description' => '',
1098
+ 'entityid' => GTM4WP_OPTION_BLACKLIST_SANDBOXED
1099
+ )
1100
+ );
1101
+
1102
+ foreach( $gtm4wp_entity_ids as $gtm_entity_group_id => $gtm_entity_group_list ) {
1103
+ foreach( $gtm_entity_group_list as $gtm_entity_id => $gtm_entity_label ) {
1104
+ add_settings_field(
1105
+ 'gtm4wp-admin-blacklist-' . $gtm_entity_group_id . '-' . $gtm_entity_id . '-id',
1106
+ $gtm_entity_label,
1107
+ 'gtm4wp_admin_output_field',
1108
+ GTM4WP_ADMINSLUG,
1109
+ GTM4WP_ADMIN_GROUP_BLACKLIST,
1110
+ array(
1111
+ 'label_for' => 'gtm4wp-options[blacklist-' . $gtm_entity_group_id . '-' . $gtm_entity_id . ']',
1112
+ 'description' => '',
1113
+ 'entityid' => $gtm_entity_id,
1114
+ )
1115
+ );
1116
+ }
1117
+ }
1118
+
1119
+ add_settings_section(
1120
+ GTM4WP_ADMIN_GROUP_INTEGRATION,
1121
+ __( 'Integration', 'duracelltomi-google-tag-manager' ),
1122
+ 'gtm4wp_admin_output_section',
1123
+ GTM4WP_ADMINSLUG
1124
+ );
1125
+
1126
+ foreach ( $gtm4wp_integratefieldtexts as $fieldid => $fielddata ) {
1127
+ $phase = isset( $fielddata['phase'] ) ? $fielddata['phase'] : GTM4WP_PHASE_STABLE;
1128
+
1129
+ add_settings_field(
1130
+ 'gtm4wp-admin-' . $fieldid . '-id',
1131
+ $fielddata['label'] . '<span class="' . $phase . '"></span>',
1132
+ 'gtm4wp_admin_output_field',
1133
+ GTM4WP_ADMINSLUG,
1134
+ GTM4WP_ADMIN_GROUP_INTEGRATION,
1135
+ array(
1136
+ 'label_for' => 'gtm4wp-options[' . $fieldid . ']',
1137
+ 'description' => $fielddata['description'],
1138
+ 'optionfieldid' => $fieldid,
1139
+ 'plugintocheck' => isset( $fielddata['plugintocheck'] ) ? $fielddata['plugintocheck'] : '',
1140
+ )
1141
+ );
1142
+ }
1143
+
1144
+ add_settings_section(
1145
+ GTM4WP_ADMIN_GROUP_ADVANCED,
1146
+ __( 'Advanced', 'duracelltomi-google-tag-manager' ),
1147
+ 'gtm4wp_admin_output_section',
1148
+ GTM4WP_ADMINSLUG
1149
+ );
1150
+
1151
+ foreach ( $gtm4wp_advancedfieldtexts as $fieldid => $fielddata ) {
1152
+ $phase = isset( $fielddata['phase'] ) ? $fielddata['phase'] : GTM4WP_PHASE_STABLE;
1153
+
1154
+ add_settings_field(
1155
+ 'gtm4wp-admin-' . $fieldid . '-id',
1156
+ $fielddata['label'] . '<span class="' . $phase . '"></span>',
1157
+ 'gtm4wp_admin_output_field',
1158
+ GTM4WP_ADMINSLUG,
1159
+ GTM4WP_ADMIN_GROUP_ADVANCED,
1160
+ array(
1161
+ 'label_for' => 'gtm4wp-options[' . $fieldid . ']',
1162
+ 'description' => $fielddata['description'],
1163
+ 'optionfieldid' => $fieldid,
1164
+ 'plugintocheck' => isset( $fielddata['plugintocheck'] ) ? $fielddata['plugintocheck'] : '',
1165
+ )
1166
+ );
1167
+ }
1168
+
1169
+ add_settings_section(
1170
+ GTM4WP_ADMIN_GROUP_CREDITS,
1171
+ __( 'Credits', 'duracelltomi-google-tag-manager' ),
1172
+ 'gtm4wp_admin_output_section',
1173
+ GTM4WP_ADMINSLUG
1174
+ );
1175
+
1176
+ add_settings_field(
1177
+ GTM4WP_ADMIN_GROUP_INFO,
1178
+ __( 'Author', 'duracelltomi-google-tag-manager' ),
1179
+ 'gtm4wp_admin_output_field',
1180
+ GTM4WP_ADMINSLUG,
1181
+ GTM4WP_ADMIN_GROUP_CREDITS,
1182
+ array(
1183
+ 'label_for' => GTM4WP_ADMIN_GROUP_INFO,
1184
+ 'description' => '<strong>Thomas Geiger</strong><br />
1185
+ Website: <a href="https://gtm4wp.com/" target="_blank" rel="noopener">gtm4wp.com</a><br />
1186
+ <a href="https://www.linkedin.com/in/duracelltomi" target="_blank" rel="noopener">Me on LinkedIn</a><br />
1187
+ <a href="http://www.linkedin.com/company/jabjab-online-marketing-ltd" target="_blank" rel="noopener">JabJab Online Marketing on LinkedIn</a>',
1188
+ )
1189
+ );
1190
+
1191
+ // apply oembed code changes on the admin as well since the oembed call on the admin is cached by WordPress into a transient
1192
+ // that is applied on the frontend later
1193
+ require_once dirname( __FILE__ ) . '/../integration/youtube.php';
1194
+ require_once dirname( __FILE__ ) . '/../integration/vimeo.php';
1195
+ require_once dirname( __FILE__ ) . '/../integration/soundcloud.php';
1196
+ }
1197
+
1198
+ function gtm4wp_show_admin_page() {
1199
+ global $gtp4wp_plugin_url;
1200
+ ?>
1201
+ <div class="wrap">
1202
+ <div id="gtm4wp-icon" class="icon32" style="background-image: url(<?php echo $gtp4wp_plugin_url; ?>admin/images/tag_manager-32.png);"><br /></div>
1203
+ <h2><?php _e( 'Google Tag Manager for WordPress options', 'duracelltomi-google-tag-manager' ); ?></h2>
1204
+ <form action="options.php" method="post">
1205
+ <?php settings_fields( GTM4WP_ADMIN_GROUP ); ?>
1206
+ <?php do_settings_sections( GTM4WP_ADMINSLUG ); ?>
1207
+ <?php submit_button(); ?>
1208
+
1209
+ </form>
1210
+ </div>
1211
+ <?php
1212
+ }
1213
+
1214
+ function gtm4wp_add_admin_page() {
1215
+ add_options_page(
1216
+ __( 'Google Tag Manager for WordPress settings', 'duracelltomi-google-tag-manager' ),
1217
+ __( 'Google Tag Manager', 'duracelltomi-google-tag-manager' ),
1218
+ 'manage_options',
1219
+ GTM4WP_ADMINSLUG,
1220
+ 'gtm4wp_show_admin_page'
1221
+ );
1222
+ }
1223
+
1224
+ function gtm4wp_add_admin_js( $hook ) {
1225
+ global $gtp4wp_plugin_url;
1226
+
1227
+ if ( $hook == 'settings_page_' . GTM4WP_ADMINSLUG ) {
1228
+ wp_register_script( 'admin-subtabs', $gtp4wp_plugin_url . 'js/admin-subtabs.js', array(), GTM4WP_VERSION );
1229
+
1230
+ $subtabtexts = array(
1231
+ 'posttabtitle' => __( 'Posts', 'duracelltomi-google-tag-manager' ),
1232
+ 'searchtabtitle' => __( 'Search', 'duracelltomi-google-tag-manager' ),
1233
+ 'visitortabtitle' => __( 'Visitors', 'duracelltomi-google-tag-manager' ),
1234
+ 'browsertabtitle' => __( 'Browser/OS/Device', 'duracelltomi-google-tag-manager' ),
1235
+ 'blocktagstabtitle' => __( 'Blacklist tags', 'duracelltomi-google-tag-manager' ),
1236
+ 'blocktriggerstabtitle' => __( 'Blacklist triggers', 'duracelltomi-google-tag-manager' ),
1237
+ 'blockmacrostabtitle' => __( 'Blacklist variables', 'duracelltomi-google-tag-manager' ),
1238
+ 'wpcf7tabtitle' => __( 'Contact Form 7', 'duracelltomi-google-tag-manager' ),
1239
+ 'wctabtitle' => __( 'WooCommerce', 'duracelltomi-google-tag-manager' ),
1240
+ 'gotabtitle' => __( 'Google Optimize', 'duracelltomi-google-tag-manager' ),
1241
+ 'amptabtitle' => __( 'Accelerated Mobile Pages', 'duracelltomi-google-tag-manager' ),
1242
+ 'cookiebottabtitle' => __( 'Cookiebot', 'duracelltomi-google-tag-manager' ),
1243
+ 'weathertabtitle' => __( 'Weather & geo data', 'duracelltomi-google-tag-manager' ),
1244
+ 'generaleventstabtitle' => __( 'General events', 'duracelltomi-google-tag-manager' ),
1245
+ 'mediaeventstabtitle' => __( 'Media events', 'duracelltomi-google-tag-manager' ),
1246
+ 'depecratedeventstabtitle' => __( 'Deprecated', 'duracelltomi-google-tag-manager' ),
1247
+ 'sitetabtitle' => __( 'Site', 'duracelltomi-google-tag-manager' ),
1248
+ 'misctabtitle' => __( 'Misc', 'duracelltomi-google-tag-manager' ),
1249
+ );
1250
+ wp_localize_script( 'admin-subtabs', 'gtm4wp', $subtabtexts );
1251
+
1252
+ wp_enqueue_script( 'admin-subtabs' );
1253
+ wp_enqueue_script( 'admin-tabcreator', $gtp4wp_plugin_url . 'js/admin-tabcreator.js', array( 'jquery-core' ), GTM4WP_VERSION );
1254
+
1255
+ wp_enqueue_style( 'gtm4wp-validate', $gtp4wp_plugin_url . 'css/admin-gtm4wp.css', array(), GTM4WP_VERSION );
1256
+ }
1257
+ }
1258
+
1259
+ function gtm4wp_admin_head() {
1260
+ echo '
1261
+ <style type="text/css">
1262
+ .gtmid_validation_error,
1263
+ .goid_validation_error,
1264
+ .goid_ga_validation_error,
1265
+ .ampid_validation_error,
1266
+ .datalayername_validation_error,
1267
+ .gtmauth_validation_error,
1268
+ .gtmpreview_validation_error,
1269
+ .gtm_wpconfig_set {
1270
+ color: #c00;
1271
+ font-weight: bold;
1272
+ }
1273
+ .gtmid_validation_error,
1274
+ .goid_validation_error,
1275
+ .goid_ga_validation_error,
1276
+ .ampid_validation_error,
1277
+ .datalayername_validation_error,
1278
+ .gtmauth_validation_error,
1279
+ .gtmpreview_validation_error {
1280
+ display: none;
1281
+ }
1282
+ </style>
1283
+ <script type="text/javascript">
1284
+ jQuery(function() {
1285
+ jQuery( "#gtm4wp-options\\\\[gtm-code\\\\]" )
1286
+ .on( "blur", function() {
1287
+ var gtmid_regex = /^GTM-[A-Z0-9]+$/;
1288
+ var gtmid_list_str = jQuery( this ).val();
1289
+ if ( typeof gtmid_list_str != "string" ) {
1290
+ return;
1291
+ }
1292
+ var gtmid_list = trim( gtmid_list_str ).split( "," );
1293
+
1294
+ var gtmid_haserror = false;
1295
+ for( var i=0; i<gtmid_list.length; i++ ) {
1296
+ gtmid_haserror = gtmid_haserror || !gtmid_regex.test( gtmid_list[ i ] );
1297
+ }
1298
+
1299
+ if ( gtmid_haserror ) {
1300
+ jQuery( ".gtmid_validation_error" )
1301
+ .show();
1302
+ } else {
1303
+ jQuery( ".gtmid_validation_error" )
1304
+ .hide();
1305
+ }
1306
+ });
1307
+
1308
+ jQuery( "#gtm4wp-options\\\\[integrate-google-optimize-idlist\\\\]" )
1309
+ .on( "blur", function() {
1310
+ var goid_regex = /^(GTM|OPT)-[A-Z0-9]+$/;
1311
+ var goid_val_str = jQuery( this ).val();
1312
+ if ( typeof goid_val_str != "string" ) {
1313
+ return;
1314
+ }
1315
+ var goid_val = trim( goid_val_str );
1316
+ if ( "" == goid_val ) {
1317
+ goid_list = [];
1318
+ } else {
1319
+ var goid_list = goid_val.split( "," );
1320
+ }
1321
+
1322
+ var goid_haserror = false;
1323
+ for( var i=0; i<goid_list.length; i++ ) {
1324
+ goid_haserror = goid_haserror || !goid_regex.test( goid_list[ i ] );
1325
+ }
1326
+
1327
+ if ( goid_haserror && (goid_list.length > 0) ) {
1328
+ jQuery( ".goid_validation_error" )
1329
+ .show();
1330
+ } else {
1331
+ jQuery( ".goid_validation_error" )
1332
+ .hide();
1333
+ }
1334
+ });
1335
+
1336
+ jQuery( "#gtm4wp-options\\\\[integrate-google-optimize-gaid\\\\]" )
1337
+ .on( "blur", function() {
1338
+ var gogaid_regex = /^UA-[0-9]+-[0-9]+$/;
1339
+ var gogaid_val_str = jQuery( this ).val();
1340
+ if ( typeof gogaid_val_str != "string" ) {
1341
+ return;
1342
+ }
1343
+ var gogaid_val = trim( gogaid_val_str );
1344
+ if ( "" == gogaid_val ) {
1345
+ gogaid_list = [];
1346
+ } else {
1347
+ var gogaid_list = gogaid_val.split( "," );
1348
+ }
1349
+
1350
+ var gogaid_haserror = false;
1351
+ for( var i=0; i<gogaid_list.length; i++ ) {
1352
+ gogaid_haserror = gogaid_haserror || !gogaid_regex.test( gogaid_list[ i ] );
1353
+ }
1354
+
1355
+ if ( gogaid_haserror && (gogaid_list.length > 0) ) {
1356
+ jQuery( ".goid_ga_validation_error" )
1357
+ .show();
1358
+ } else {
1359
+ jQuery( ".goid_ga_validation_error" )
1360
+ .hide();
1361
+ }
1362
+ });
1363
+
1364
+ jQuery( "#gtm4wp-options\\\\[integrate-amp-gtm\\\\]" )
1365
+ .on( "blur", function() {
1366
+ var ampid_regex = /^GTM-[A-Z0-9]+$/;
1367
+ var ampid_val_str = jQuery( this ).val();
1368
+ if ( typeof ampid_val_str != "string" ) {
1369
+ return;
1370
+ }
1371
+ var ampid_val = trim( ampid_val_str );
1372
+ if ( "" == ampid_val ) {
1373
+ ampid_list = [];
1374
+ } else {
1375
+ var ampid_list = ampid_val.split( "," );
1376
+ }
1377
+
1378
+ var ampid_haserror = false;
1379
+ for( var i=0; i<ampid_list.length; i++ ) {
1380
+ ampid_haserror = ampid_haserror || !ampid_regex.test( gogaid_list[ i ] );
1381
+ }
1382
+
1383
+ if ( ampid_haserror && (ampid_list.length > 0) ) {
1384
+ jQuery( ".ampid_validation_error" )
1385
+ .show();
1386
+ } else {
1387
+ jQuery( ".ampid_validation_error" )
1388
+ .hide();
1389
+ }
1390
+ });
1391
+
1392
+ jQuery( "#gtm4wp-options\\\\[gtm-datalayer-variable-name\\\\]" )
1393
+ .on( "blur", function() {
1394
+ var currentval = jQuery( this ).val();
1395
+
1396
+ jQuery( ".datalayername_validation_error" )
1397
+ .hide();
1398
+
1399
+ if ( currentval != "" ) {
1400
+ // I know this is not the exact definition for a variable name but I think other kind of variable names should not be used.
1401
+ var gtmvarname_regex = /^[a-zA-Z][a-zA-Z0-9_-]*$/;
1402
+ if ( ! gtmvarname_regex.test( currentval ) ) {
1403
+ jQuery( ".datalayername_validation_error" )
1404
+ .show();
1405
+ }
1406
+ }
1407
+ });
1408
+
1409
+ jQuery( "#gtm4wp-options\\\\[gtm-env-gtm-auth\\\\]" )
1410
+ .on( "blur", function() {
1411
+ var currentval = jQuery( this ).val();
1412
+
1413
+ jQuery( ".gtmauth_validation_error" )
1414
+ .hide();
1415
+
1416
+ if ( currentval != "" ) {
1417
+ var gtmauth_regex = /^[a-zA-Z0-9-_]+$/;
1418
+ if ( ! gtmauth_regex.test( currentval ) ) {
1419
+ jQuery( ".gtmauth_validation_error" )
1420
+ .show();
1421
+ }
1422
+ }
1423
+ });
1424
+
1425
+ jQuery( "#gtm4wp-options\\\\[gtm-env-gtm-preview\\\\]" )
1426
+ .on( "blur", function() {
1427
+ var currentval = jQuery( this ).val();
1428
+
1429
+ jQuery( ".gtmpreview_validation_error" )
1430
+ .hide();
1431
+
1432
+ if ( currentval != "" ) {
1433
+ var gtmpreview_regex = /^env-[0-9]+$/;
1434
+ if ( ! gtmpreview_regex.test( currentval ) ) {
1435
+ jQuery( ".gtmpreview_validation_error" )
1436
+ .show();
1437
+ }
1438
+ }
1439
+ });
1440
+
1441
+ jQuery( document )
1442
+ .on( "click", ".gtm4wp-notice .notice-dismiss", function( e ) {
1443
+ jQuery.post(ajaxurl, {
1444
+ action: "gtm4wp_dismiss_notice",
1445
+ noticeid: jQuery( this ).closest(".gtm4wp-notice")
1446
+ .attr( "data-href" )
1447
+ .substring( 1 )
1448
+ });
1449
+ });
1450
+ });
1451
+ </script>';
1452
+ }
1453
+
1454
+ function gtm4wp_show_warning() {
1455
+ global $gtm4wp_options, $gtp4wp_plugin_url, $gtm4wp_integratefieldtexts, $current_user,
1456
+ $gtm4wp_def_user_notices_dismisses;
1457
+
1458
+ $woo_plugin_active = is_plugin_active( $gtm4wp_integratefieldtexts[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ]['plugintocheck'] );
1459
+ if ( $woo_plugin_active && function_exists( 'WC' ) ) {
1460
+ $woo = WC();
1461
+ } else {
1462
+ $woo = null;
1463
+ }
1464
+
1465
+ $gtm4wp_user_notices_dismisses = get_user_meta( $current_user->ID, GTM4WP_USER_NOTICES_KEY, true );
1466
+ if ( $gtm4wp_user_notices_dismisses === '' ) {
1467
+ if ( is_array( $gtm4wp_def_user_notices_dismisses ) ) {
1468
+ $gtm4wp_user_notices_dismisses = $gtm4wp_def_user_notices_dismisses;
1469
+ } else {
1470
+ $gtm4wp_user_notices_dismisses = array();
1471
+ }
1472
+ } else {
1473
+ $gtm4wp_user_notices_dismisses = @unserialize( $gtm4wp_user_notices_dismisses );
1474
+ if ( false === $gtm4wp_user_notices_dismisses || !is_array( $gtm4wp_user_notices_dismisses ) ) {
1475
+ $gtm4wp_user_notices_dismisses = array();
1476
+ }
1477
+ }
1478
+ $gtm4wp_user_notices_dismisses = array_merge( $gtm4wp_def_user_notices_dismisses, $gtm4wp_user_notices_dismisses );
1479
+
1480
+ if ( ( trim( $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] ) == '' ) && ( false === $gtm4wp_user_notices_dismisses['enter-gtm-code'] ) ) {
1481
+ echo '<div class="gtm4wp-notice notice notice-error is-dismissible" data-href="?enter-gtm-code"><p><strong>' . sprintf( __( 'To start using Google Tag Manager for WordPress, please <a href="%s">enter your GTM ID</a>', 'duracelltomi-google-tag-manager' ), 'options-general.php?page=' . GTM4WP_ADMINSLUG ) . '</strong></p></div>';
1482
+ }
1483
+
1484
+ if ( (
1485
+ ( '' != $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ] ) && ( '' == $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ] )
1486
+ ) || (
1487
+ ( '' == $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_AUTH ] ) && ( '' != $gtm4wp_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ] )
1488
+ ) ) {
1489
+ echo '<div class="gtm4wp-notice notice notice-error" data-href="?incomplete-gtm-env-config"><p><strong>' . sprintf( __( 'Incomplete Google Tag Manager environment configuration: either gtm_preview or gtm_auth parameter value is missing!', 'duracelltomi-google-tag-manager' ), 'options-general.php?page=' . GTM4WP_ADMINSLUG ) . '</strong></p></div>';
1490
+ }
1491
+
1492
+ if ( ( false === $gtm4wp_user_notices_dismisses['wc-ga-plugin-warning'] ) || ( false === $gtm4wp_user_notices_dismisses['wc-gayoast-plugin-warning'] ) ) {
1493
+ $is_wc_active = $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC ] ||
1494
+ $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC ] ||
1495
+ $gtm4wp_options[ GTM4WP_OPTION_INTEGRATE_WCREMARKETING ];
1496
+
1497
+ if ( ( false === $gtm4wp_user_notices_dismisses['wc-ga-plugin-warning'] ) && $is_wc_active && is_plugin_active( 'woocommerce-google-analytics-integration/woocommerce-google-analytics-integration.php' ) ) {
1498
+ echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?wc-ga-plugin-warning"><p><strong>' . __( 'Notice: you should deactivate the plugin "WooCommerce Google Analytics Integration" if you are using Google Analytics tags inside Google Tag Manager!', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
1499
+ }
1500
+
1501
+ if ( ( false === $gtm4wp_user_notices_dismisses['wc-gayoast-plugin-warning'] ) && $is_wc_active && is_plugin_active( 'google-analytics-for-wordpress/googleanalytics.php' ) ) {
1502
+ echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?wc-gayoast-plugin-warning"><p><strong>' . __( 'Notice: you should deactivate the plugin "Google Analytics for WordPress by MonsterInsights" if you are using Google Analytics tags inside Google Tag Manager!', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
1503
+ }
1504
+ }
1505
+
1506
+ if ( ( false === $gtm4wp_user_notices_dismisses['php72-warning'] ) && ( version_compare( PHP_VERSION, '7.2.0' ) < 0 ) ) {
1507
+ echo '<div class="gtm4wp-notice notice notice-warning is-dismissible" data-href="?php72-warning"><p><strong>' . __( 'Warning: You are using an outdated version of PHP (v' . PHP_VERSION . ') that might be not compatible with future versions of the plugin Google Tag Manager for WordPress (GTM4WP). Please consider to upgrade your PHP.', 'duracelltomi-google-tag-manager' ) . '</strong></p></div>';
1508
+ }
1509
+ }
1510
+
1511
+ function gtm4wp_dismiss_notice() {
1512
+ global $gtm4wp_def_user_notices_dismisses, $current_user;
1513
+
1514
+ $gtm4wp_user_notices_dismisses = get_user_meta( $current_user->ID, GTM4WP_USER_NOTICES_KEY, true );
1515
+ if ( $gtm4wp_user_notices_dismisses === '' ) {
1516
+ if ( is_array( $gtm4wp_def_user_notices_dismisses ) ) {
1517
+ $gtm4wp_user_notices_dismisses = $gtm4wp_def_user_notices_dismisses;
1518
+ } else {
1519
+ $gtm4wp_user_notices_dismisses = array();
1520
+ }
1521
+ } else {
1522
+ $gtm4wp_user_notices_dismisses = @unserialize( $gtm4wp_user_notices_dismisses );
1523
+ if ( false === $gtm4wp_user_notices_dismisses || !is_array( $gtm4wp_user_notices_dismisses ) ) {
1524
+ $gtm4wp_user_notices_dismisses = array();
1525
+ }
1526
+ }
1527
+ $gtm4wp_user_notices_dismisses = array_merge( $gtm4wp_def_user_notices_dismisses, $gtm4wp_user_notices_dismisses );
1528
+
1529
+ $noticeid = trim( basename( $_POST['noticeid'] ) );
1530
+ if ( array_key_exists( $noticeid, $gtm4wp_user_notices_dismisses ) ) {
1531
+ $gtm4wp_user_notices_dismisses[ $noticeid ] = true;
1532
+ update_user_meta( $current_user->ID, GTM4WP_USER_NOTICES_KEY, serialize( $gtm4wp_user_notices_dismisses ) );
1533
+ }
1534
+ }
1535
+
1536
+ function gtm4wp_add_plugin_action_links( $links, $file ) {
1537
+ global $gtp4wp_plugin_basename;
1538
+
1539
+ if ( $file != $gtp4wp_plugin_basename ) {
1540
+ return $links;
1541
+ }
1542
+
1543
+ $settings_link = '<a href="' . menu_page_url( GTM4WP_ADMINSLUG, false ) . '">' . esc_html( __( 'Settings' ) ) . '</a>';
1544
+
1545
+ array_unshift( $links, $settings_link );
1546
+
1547
+ return $links;
1548
+ }
1549
+
1550
+ function gtm4wp_show_upgrade_notification( $current_plugin_metadata, $new_plugin_metadata ) {
1551
+ if ( isset( $new_plugin_metadata->upgrade_notice ) && strlen( trim( $new_plugin_metadata->upgrade_notice ) ) > 0 ) {
1552
+ echo '<p style="background-color: #d54e21; padding: 10px; color: #f9f9f9; margin-top: 10px"><strong>Important Upgrade Notice:</strong> ';
1553
+ echo esc_html( $new_plugin_metadata->upgrade_notice ), '</p>';
1554
+ }
1555
+ }
1556
+
1557
+ add_action( 'admin_init', 'gtm4wp_admin_init' );
1558
+ add_action( 'admin_menu', 'gtm4wp_add_admin_page' );
1559
+ add_action( 'admin_enqueue_scripts', 'gtm4wp_add_admin_js' );
1560
+ add_action( 'admin_notices', 'gtm4wp_show_warning' );
1561
+ add_action( 'admin_head', 'gtm4wp_admin_head' );
1562
+ add_filter( 'plugin_action_links', 'gtm4wp_add_plugin_action_links', 10, 2 );
1563
+ add_action( 'wp_ajax_gtm4wp_dismiss_notice', 'gtm4wp_dismiss_notice' );
1564
+ add_action( 'in_plugin_update_message-duracelltomi-google-tag-manager-for-wordpress/duracelltomi-google-tag-manager-for-wordpress.php', 'gtm4wp_show_upgrade_notification', 10, 2 );
 
 
 
 
 
 
common/readoptions.php CHANGED
@@ -1,4 +1,13 @@
1
  <?php
 
 
 
 
 
 
 
 
 
2
  define( 'GTM4WP_OPTIONS', 'gtm4wp-options' );
3
  define( 'GTM4WP_OPTION_GTM_CODE', 'gtm-code' );
4
  define( 'GTM4WP_OPTION_GTM_PLACEMENT', 'gtm-code-placement' );
@@ -10,7 +19,6 @@ define( 'GTM4WP_OPTION_LOADEARLY', 'gtm-load-gtm-early' );
10
  define( 'GTM4WP_OPTION_GTMDOMAIN', 'gtm-domain-name' );
11
  define( 'GTM4WP_OPTION_NOGTMFORLOGGEDIN', 'gtm-no-gtm-for-logged-in' );
12
 
13
- define( 'GTM4WP_OPTION_INCLUDE_REMARKETING', 'include-remarketing' );
14
  define( 'GTM4WP_OPTION_INCLUDE_LOGGEDIN', 'include-loggedin' );
15
  define( 'GTM4WP_OPTION_INCLUDE_USERROLE', 'include-userrole' );
16
  define( 'GTM4WP_OPTION_INCLUDE_USERID', 'include-userid' );
@@ -28,7 +36,7 @@ define( 'GTM4WP_OPTION_INCLUDE_POSTTITLE', 'include-posttitle' );
28
  define( 'GTM4WP_OPTION_INCLUDE_POSTCOUNT', 'include-postcount' );
29
  define( 'GTM4WP_OPTION_INCLUDE_POSTID', 'include-postid' );
30
  define( 'GTM4WP_OPTION_INCLUDE_POSTFORMAT', 'include-postformat' );
31
- define( 'GTM4WP_OPTION_INCLUDE_POSTTERMLIST', 'include-postterms' );
32
  define( 'GTM4WP_OPTION_INCLUDE_SEARCHDATA', 'include-searchdata' );
33
  define( 'GTM4WP_OPTION_INCLUDE_BROWSERDATA', 'include-browserdata' );
34
  define( 'GTM4WP_OPTION_INCLUDE_OSDATA', 'include-osdata' );
@@ -61,7 +69,7 @@ define( 'GTM4WP_OPTION_BLACKLIST_ENABLE', 'blacklist-enable' );
61
  define( 'GTM4WP_OPTION_BLACKLIST_SANDBOXED', 'blacklist-sandboxed' );
62
  define( 'GTM4WP_OPTION_BLACKLIST_STATUS', 'blacklist-status' );
63
 
64
- // deprecated options BEGIN
65
  define( 'GTM4WP_OPTION_BLACKLIST_ADADVISOR', 'blacklist-adadvisor' );
66
  define( 'GTM4WP_OPTION_BLACKLIST_ADROLL', 'blacklist-adroll' );
67
  define( 'GTM4WP_OPTION_BLACKLIST_AWCONV', 'blacklist-adwords-conversion' );
@@ -93,7 +101,7 @@ define( 'GTM4WP_OPTION_BLACKLIST_MACRO_RANDOMNUM', 'blacklist-macro-random-numbe
93
  define( 'GTM4WP_OPTION_BLACKLIST_MACRO_REFERRER', 'blacklist-macro-referrer' );
94
  define( 'GTM4WP_OPTION_BLACKLIST_MACRO_URL', 'blacklist-macro-url' );
95
  define( 'GTM4WP_OPTION_BLACKLIST_MACRO_AUTOEVENT', 'blacklist-macro-autoevent-variable' );
96
- // deprecated options END
97
 
98
  define( 'GTM4WP_OPTION_INTEGRATE_WPCF7', 'integrate-wpcf7' );
99
 
@@ -101,8 +109,8 @@ define( 'GTM4WP_OPTION_INTEGRATE_WCTRACKCLASSICEC', 'integrate-woocommerce-track
101
  define( 'GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC', 'integrate-woocommerce-track-enhanced-ecommerce' );
102
  define( 'GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION', 'integrate-woocommerce-product-per-impression' );
103
  define( 'GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP', 'integrate-woocommerce-cart-as-first-step' );
104
- define( 'GTM4WP_OPTION_INTEGRATE_WCEINCLUDECARTINDL', 'integrate-woocommerce-cart-content-in-datalayer' );
105
- define( 'GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY', 'integrate-woocommerce-brand-taxonomy' );
106
  define( 'GTM4WP_OPTION_INTEGRATE_WCREMARKETING', 'integrate-woocommerce-remarketing' );
107
  define( 'GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL', 'integrate-woocommerce-business-vertical' );
108
  define( 'GTM4WP_OPTION_INTEGRATE_WCUSESKU', 'integrate-woocommerce-remarketing-usesku' );
@@ -144,7 +152,6 @@ $gtm4wp_defaultoptions = array(
144
  GTM4WP_OPTION_GTMDOMAIN => '',
145
  GTM4WP_OPTION_NOGTMFORLOGGEDIN => '',
146
 
147
- GTM4WP_OPTION_INCLUDE_REMARKETING => false,
148
  GTM4WP_OPTION_INCLUDE_LOGGEDIN => false,
149
  GTM4WP_OPTION_INCLUDE_USERROLE => false,
150
  GTM4WP_OPTION_INCLUDE_USERID => false,
@@ -210,7 +217,7 @@ $gtm4wp_defaultoptions = array(
210
  GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX => '',
211
  GTM4WP_OPTION_INTEGRATE_WCCUSTOMERDATA => false,
212
  GTM4WP_OPTION_INTEGRATE_WCORDERDATA => false,
213
- GTM4WP_OPTION_INTEGRATE_WCORDERMAXAGE => 30,
214
  GTM4WP_OPTION_INTEGRATE_WCEXCLUDETAX => false,
215
  GTM4WP_OPTION_INTEGRATE_WCEXCLUDESHIPPING => false,
216
  GTM4WP_OPTION_INTEGRATE_WCNOORDERTRACKEDFLAG => false,
@@ -222,142 +229,148 @@ $gtm4wp_defaultoptions = array(
222
 
223
  GTM4WP_OPTION_INTEGRATE_AMPID => '',
224
 
225
- GTM4WP_OPTION_INTEGRATE_COOKIEBOT => false
226
  );
227
 
228
  $gtm4wp_business_verticals = array(
229
- 'retail' => 'Retail',
230
- 'education' => 'Education',
231
- 'flights' => 'Flights',
232
  'hotel_rental' => 'Hotel rental',
233
- 'jobs' => 'Jobs',
234
- 'local' => 'Local deals',
235
- 'real_estate' => 'Real estate',
236
- 'travel' => 'Travel',
237
- 'custom' => 'Custom'
238
  );
239
 
240
  $gtm4wp_business_verticals_ids = array(
241
  'flights' => 'destination',
242
- 'travel' => 'destination'
243
  );
244
 
245
  $gtm4wp_entity_ids = array(
246
- 'tags' => array(
247
- 'abtGeneric' => 'AB TASTY Generic Tag',
248
- 'ta' => 'AdAdvisor Tag',
249
- 'adm' => 'Adometry Tag',
250
- 'asp' => 'AdRoll Smart Pixel Tag',
251
- 'awct' => 'Google Ads Conversion Tracking Tag',
252
- 'sp' => 'Google Ads Remarketing Tag',
253
- 'awc' => 'Affiliate Window Conversion Tag',
254
- 'awj' => 'Affiliate Window Journey Tag',
255
- 'baut' => 'Bing Ads Universal Event Tracking',
256
- 'bb' => 'Bizrate Insights Buyer Survey Solution',
257
- 'bsa' => 'Bizrate Insights Site Abandonment Survey Solution',
258
- 'cts' => 'ClickTale Standard Tracking Tag',
259
- 'csm' => 'comScore Unified Digital Measurement Tag',
260
- 'mpm' => 'Conversant Mediaplex - IFRAME MCT Tag',
261
- 'mpr' => 'Conversant Mediaplex - Standard IMG ROI Tag',
262
- 'gclidw' => 'Conversion Linker',
263
- 'cegg' => 'Crazy Egg Tag',
264
- 'crto' => 'Criteo OneTag',
265
- 'html' => 'Custom HTML Tag',
266
- 'img' => 'Custom Image Tag',
267
- 'dstag' => 'DistroScale Tag',
268
- 'flc' => 'Floodlight Counter Tag',
269
- 'fls' => 'Floodlight Sales Tag',
270
- 'm6d' => 'Dstillery Universal Pixel Tag',
271
- 'ela' => 'Eulerian Analytics Tag',
272
- 'ga' => 'Google Analytics Tag (classic, legacy)',
273
- 'ua' => 'Google Analytics Tag (universal, latest)',
274
- 'gcs' => 'Google Consumer Surveys Website Satisfaction',
275
- 'opt' => 'Google Optimize',
276
- 'ts' => 'Google Trusted Stores Tag',
277
- 'hjtc' => 'Hotjar Tracking Code',
278
- 'infinity' => 'Infinity Call Tracking Tag',
279
- 'sca' => 'Intent Media - Search Compare Ads',
280
- 'k50Init' => 'K50 tracking tag',
281
- 'll' => 'LeadLab',
282
- 'bzi' => 'LinkedIn Tag',
283
- 'ljs' => 'Lytics JS Tag',
284
- 'ms' => 'Marin Software Tag',
285
- 'mpm' => 'Mediaplex - IFRAME MCT Tag',
286
- 'mpr' => 'Mediaplex - Standard IMG ROI Tag',
287
- 'messagemate' => 'Message Mate',
288
- 'mf' => 'Mouseflow Tag',
289
- 'ta' => 'Neustar Pixel',
290
- 'ndcr' => 'Nielsen DCR Static Lite Tag',
291
- 'nudge' => 'Nudge Content Analytics Tag',
292
- 'okt' => 'Oktopost Tracking Code',
293
- 'omc' => 'Optimise Conversion Tag',
294
- 'messagemate' => 'OwnerListens Message Mate',
295
- 'pa' => 'Perfect Audience Pixel',
296
- 'pc' => 'Personali Canvas',
297
- 'pntr' => 'Pinterest',
298
- 'placedPixel' => 'Placed',
299
- 'pijs' => 'Pulse Insights Voice of Customer Platform',
300
- 'qcm' => 'Quantcast Audience Measurement',
301
- 'qpx' => 'Quora Pixel',
302
- 'fxm' => 'Rawsoft FoxMetrics',
303
- 'scjs' => 'SaleCycle JavaScript Tag',
304
- 'scp' => 'SaleCycle Pixel Tag',
305
- 'sfc' => 'SearchForce JavaScript Tracking for Conversion Page',
306
- 'sfl' => 'SearchForce JavaScript Tracking for Landing Page',
307
- 'sfr' => 'SearchForce Redirection Tracking Tag',
308
- 'shareaholic' => 'Shareaholic',
309
- 'svw' => 'Survicate Widget',
310
- 'tdlc' => 'Tradedoubler Lead Conversion Tag',
311
- 'tdsc' => 'Tradedoubler Sale Conversion Tag',
312
- 'tc' => 'Turn Conversion Tracking Tag',
313
- 'tdc' => 'Turn Data Collection Tag',
314
  'twitter_website_tag' => 'Twitter Universal Website Tag',
315
- 'uslt' => 'Upsellit Global Footer Tag',
316
- 'uspt' => 'Upsellit Confirmation Tag',
317
- 'vei' => 'Ve Interactive JavaScript Tag',
318
- 'veip' => 'Ve Interactive Pixel',
319
- 'vdc' => 'VisualDNA Conversion Tag',
320
- 'xpsh' => 'Xtremepush',
321
- 'yieldify' => 'Yieldify',
322
- 'zone' => 'Zones'
323
  ),
324
- 'triggers' => array(
325
  'evl' => 'Element Visibility Listener/Trigger',
326
- 'cl' => 'Click Listener/Trigger',
327
  'fsl' => 'Form Submit Listener/Trigger',
328
- 'hl' => 'History Listener/Trigger',
329
  'jel' => 'JavaScript Error Listener/Trigger',
330
  'lcl' => 'Link Click Listener/Trigger',
331
  'sdl' => 'Scroll Depth Listener/Trigger',
332
- 'tl' => 'Timer Listener/Trigger',
333
- 'ytl' => 'YouTube Video Listener/Trigger'
334
  ),
335
  'variables' => array(
336
- 'k' => '1st Party Cookie',
337
- 'c' => 'Constant',
338
- 'ctv' => 'Container Version Number',
339
- 'e' => 'Custom Event',
340
- 'jsm' => 'Custom JavaScript Variable',
341
- 'v' => 'Data Layer Variable',
342
- 'dbg' => 'Debug Mode',
343
- 'd' => 'DOM Element',
344
- 'vis' => 'Element Visibility',
345
- 'f' => 'HTTP Referrer',
346
- 'j' => 'JavaScript Variable',
347
- 'smm' => 'Lookup Table',
348
- 'r' => 'Random Number',
349
  'remm' => 'RegEx Table',
350
- 'u' => 'URL'
351
- )
352
  );
353
 
 
 
 
 
 
 
354
  function gtm4wp_migrate_blacklist_whitelist( $current_options ) {
355
  if ( ( array_key_exists( GTM4WP_OPTION_BLACKLIST_ENABLE, $current_options ) )
356
- && ( $current_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] > 0 )
357
  ) {
358
  $_gtmrestrictlistitems = array();
359
 
360
- // IDs from https://developers.google.com/tag-manager/devguide#security
361
  if ( $current_options[ GTM4WP_OPTION_BLACKLIST_ADADVISOR ] ) {
362
  $_gtmrestrictlistitems[] = 'ta';
363
  }
@@ -422,6 +435,13 @@ function gtm4wp_migrate_blacklist_whitelist( $current_options ) {
422
  return $current_options;
423
  }
424
 
 
 
 
 
 
 
 
425
  function gtm4wp_reload_options() {
426
  global $gtm4wp_defaultoptions, $gtm4wp_business_verticals;
427
 
@@ -430,38 +450,47 @@ function gtm4wp_reload_options() {
430
  $gtm4wp_defaultoptions = array();
431
  }
432
 
433
- if ( !isset( $storedoptions[ GTM4WP_OPTION_BLACKLIST_STATUS ] ) ) {
434
  $storedoptions = gtm4wp_migrate_blacklist_whitelist( $storedoptions );
435
  }
436
 
 
437
  $return_options = array_merge( $gtm4wp_defaultoptions, $storedoptions );
438
  $return_options[ GTM4WP_OPTION_BLACKLIST_STATUS ] = explode( ',', $return_options[ GTM4WP_OPTION_BLACKLIST_STATUS ] );
439
 
440
  if ( defined( 'GTM4WP_HARDCODED_GTM_ID' ) ) {
441
- $return_options[ GTM4WP_OPTION_GTM_CODE ] = GTM4WP_HARDCODED_GTM_ID;
442
  }
443
 
444
  if ( defined( 'GTM4WP_HARDCODED_GTM_ENV_AUTH' ) ) {
445
- $return_options[ GTM4WP_OPTION_ENV_GTM_AUTH ] = GTM4WP_HARDCODED_GTM_ENV_AUTH;
446
  }
447
 
448
  if ( defined( 'GTM4WP_HARDCODED_GTM_ENV_PREVIEW' ) ) {
449
- $return_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ] = GTM4WP_HARDCODED_GTM_ENV_PREVIEW;
450
  }
451
 
452
- if ( !array_key_exists( $return_options[ GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL ], $gtm4wp_business_verticals ) ) {
453
  $return_options[ GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL ] = $gtm4wp_defaultoptions[ GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL ];
454
  }
455
 
456
  return $return_options;
457
  }
458
 
 
 
 
 
 
 
 
459
  function gtp4wp_debug_file( $debug_data ) {
460
- $fp = fopen( dirname( __FILE__ ) . '/' . date( 'Y-m-d-H-i-s-u' ) . '.txt', 'w' );
461
  if ( $fp ) {
462
  fwrite( $fp, $debug_data );
463
  fclose( $fp );
464
  }
465
  }
 
466
 
467
  $gtm4wp_options = gtm4wp_reload_options();
1
  <?php
2
+ /**
3
+ * Plugin constant declarations and default option values.
4
+ *
5
+ * @package GTM4WP
6
+ * @author Thomas Geiger
7
+ * @copyright 2013- Geiger Tamás e.v. (Thomas Geiger s.e.)
8
+ * @license GNU General Public License, version 3
9
+ */
10
+
11
  define( 'GTM4WP_OPTIONS', 'gtm4wp-options' );
12
  define( 'GTM4WP_OPTION_GTM_CODE', 'gtm-code' );
13
  define( 'GTM4WP_OPTION_GTM_PLACEMENT', 'gtm-code-placement' );
19
  define( 'GTM4WP_OPTION_GTMDOMAIN', 'gtm-domain-name' );
20
  define( 'GTM4WP_OPTION_NOGTMFORLOGGEDIN', 'gtm-no-gtm-for-logged-in' );
21
 
 
22
  define( 'GTM4WP_OPTION_INCLUDE_LOGGEDIN', 'include-loggedin' );
23
  define( 'GTM4WP_OPTION_INCLUDE_USERROLE', 'include-userrole' );
24
  define( 'GTM4WP_OPTION_INCLUDE_USERID', 'include-userid' );
36
  define( 'GTM4WP_OPTION_INCLUDE_POSTCOUNT', 'include-postcount' );
37
  define( 'GTM4WP_OPTION_INCLUDE_POSTID', 'include-postid' );
38
  define( 'GTM4WP_OPTION_INCLUDE_POSTFORMAT', 'include-postformat' );
39
+ define( 'GTM4WP_OPTION_INCLUDE_POSTTERMLIST', 'include-postterms' );
40
  define( 'GTM4WP_OPTION_INCLUDE_SEARCHDATA', 'include-searchdata' );
41
  define( 'GTM4WP_OPTION_INCLUDE_BROWSERDATA', 'include-browserdata' );
42
  define( 'GTM4WP_OPTION_INCLUDE_OSDATA', 'include-osdata' );
69
  define( 'GTM4WP_OPTION_BLACKLIST_SANDBOXED', 'blacklist-sandboxed' );
70
  define( 'GTM4WP_OPTION_BLACKLIST_STATUS', 'blacklist-status' );
71
 
72
+ // deprecated options BEGIN.
73
  define( 'GTM4WP_OPTION_BLACKLIST_ADADVISOR', 'blacklist-adadvisor' );
74
  define( 'GTM4WP_OPTION_BLACKLIST_ADROLL', 'blacklist-adroll' );
75
  define( 'GTM4WP_OPTION_BLACKLIST_AWCONV', 'blacklist-adwords-conversion' );
101
  define( 'GTM4WP_OPTION_BLACKLIST_MACRO_REFERRER', 'blacklist-macro-referrer' );
102
  define( 'GTM4WP_OPTION_BLACKLIST_MACRO_URL', 'blacklist-macro-url' );
103
  define( 'GTM4WP_OPTION_BLACKLIST_MACRO_AUTOEVENT', 'blacklist-macro-autoevent-variable' );
104
+ // deprecated options END.
105
 
106
  define( 'GTM4WP_OPTION_INTEGRATE_WPCF7', 'integrate-wpcf7' );
107
 
109
  define( 'GTM4WP_OPTION_INTEGRATE_WCTRACKENHANCEDEC', 'integrate-woocommerce-track-enhanced-ecommerce' );
110
  define( 'GTM4WP_OPTION_INTEGRATE_WCPRODPERIMPRESSION', 'integrate-woocommerce-product-per-impression' );
111
  define( 'GTM4WP_OPTION_INTEGRATE_WCEECCARTASFIRSTSTEP', 'integrate-woocommerce-cart-as-first-step' );
112
+ define( 'GTM4WP_OPTION_INTEGRATE_WCEINCLUDECARTINDL', 'integrate-woocommerce-cart-content-in-datalayer' );
113
+ define( 'GTM4WP_OPTION_INTEGRATE_WCEECBRANDTAXONOMY', 'integrate-woocommerce-brand-taxonomy' );
114
  define( 'GTM4WP_OPTION_INTEGRATE_WCREMARKETING', 'integrate-woocommerce-remarketing' );
115
  define( 'GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL', 'integrate-woocommerce-business-vertical' );
116
  define( 'GTM4WP_OPTION_INTEGRATE_WCUSESKU', 'integrate-woocommerce-remarketing-usesku' );
152
  GTM4WP_OPTION_GTMDOMAIN => '',
153
  GTM4WP_OPTION_NOGTMFORLOGGEDIN => '',
154
 
 
155
  GTM4WP_OPTION_INCLUDE_LOGGEDIN => false,
156
  GTM4WP_OPTION_INCLUDE_USERROLE => false,
157
  GTM4WP_OPTION_INCLUDE_USERID => false,
217
  GTM4WP_OPTION_INTEGRATE_WCREMPRODIDPREFIX => '',
218
  GTM4WP_OPTION_INTEGRATE_WCCUSTOMERDATA => false,
219
  GTM4WP_OPTION_INTEGRATE_WCORDERDATA => false,
220
+ GTM4WP_OPTION_INTEGRATE_WCORDERMAXAGE => 30,
221
  GTM4WP_OPTION_INTEGRATE_WCEXCLUDETAX => false,
222
  GTM4WP_OPTION_INTEGRATE_WCEXCLUDESHIPPING => false,
223
  GTM4WP_OPTION_INTEGRATE_WCNOORDERTRACKEDFLAG => false,
229
 
230
  GTM4WP_OPTION_INTEGRATE_AMPID => '',
231
 
232
+ GTM4WP_OPTION_INTEGRATE_COOKIEBOT => false,
233
  );
234
 
235
  $gtm4wp_business_verticals = array(
236
+ 'retail' => 'Retail',
237
+ 'education' => 'Education',
238
+ 'flights' => 'Flights',
239
  'hotel_rental' => 'Hotel rental',
240
+ 'jobs' => 'Jobs',
241
+ 'local' => 'Local deals',
242
+ 'real_estate' => 'Real estate',
243
+ 'travel' => 'Travel',
244
+ 'custom' => 'Custom',
245
  );
246
 
247
  $gtm4wp_business_verticals_ids = array(
248
  'flights' => 'destination',
249
+ 'travel' => 'destination',
250
  );
251
 
252
  $gtm4wp_entity_ids = array(
253
+ 'tags' => array(
254
+ 'abtGeneric' => 'AB TASTY Generic Tag',
255
+ 'ta' => 'AdAdvisor Tag',
256
+ 'adm' => 'Adometry Tag',
257
+ 'asp' => 'AdRoll Smart Pixel Tag',
258
+ 'awct' => 'Google Ads Conversion Tracking Tag',
259
+ 'sp' => 'Google Ads Remarketing Tag',
260
+ 'awc' => 'Affiliate Window Conversion Tag',
261
+ 'awj' => 'Affiliate Window Journey Tag',
262
+ 'baut' => 'Bing Ads Universal Event Tracking',
263
+ 'bb' => 'Bizrate Insights Buyer Survey Solution',
264
+ 'bsa' => 'Bizrate Insights Site Abandonment Survey Solution',
265
+ 'cts' => 'ClickTale Standard Tracking Tag',
266
+ 'csm' => 'comScore Unified Digital Measurement Tag',
267
+ 'mpm' => 'Conversant Mediaplex - IFRAME MCT Tag',
268
+ 'mpr' => 'Conversant Mediaplex - Standard IMG ROI Tag',
269
+ 'gclidw' => 'Conversion Linker',
270
+ 'cegg' => 'Crazy Egg Tag',
271
+ 'crto' => 'Criteo OneTag',
272
+ 'html' => 'Custom HTML Tag',
273
+ 'img' => 'Custom Image Tag',
274
+ 'dstag' => 'DistroScale Tag',
275
+ 'flc' => 'Floodlight Counter Tag',
276
+ 'fls' => 'Floodlight Sales Tag',
277
+ 'm6d' => 'Dstillery Universal Pixel Tag',
278
+ 'ela' => 'Eulerian Analytics Tag',
279
+ 'ga' => 'Google Analytics Tag (classic, legacy)',
280
+ 'ua' => 'Google Analytics Tag (universal, latest)',
281
+ 'gcs' => 'Google Consumer Surveys Website Satisfaction',
282
+ 'opt' => 'Google Optimize',
283
+ 'ts' => 'Google Trusted Stores Tag',
284
+ 'hjtc' => 'Hotjar Tracking Code',
285
+ 'infinity' => 'Infinity Call Tracking Tag',
286
+ 'sca' => 'Intent Media - Search Compare Ads',
287
+ 'k50Init' => 'K50 tracking tag',
288
+ 'll' => 'LeadLab',
289
+ 'bzi' => 'LinkedIn Tag',
290
+ 'ljs' => 'Lytics JS Tag',
291
+ 'ms' => 'Marin Software Tag',
292
+ 'mpm' => 'Mediaplex - IFRAME MCT Tag',
293
+ 'mpr' => 'Mediaplex - Standard IMG ROI Tag',
294
+ 'messagemate' => 'Message Mate',
295
+ 'mf' => 'Mouseflow Tag',
296
+ 'ta' => 'Neustar Pixel',
297
+ 'ndcr' => 'Nielsen DCR Static Lite Tag',
298
+ 'nudge' => 'Nudge Content Analytics Tag',
299
+ 'okt' => 'Oktopost Tracking Code',
300
+ 'omc' => 'Optimise Conversion Tag',
301
+ 'messagemate' => 'OwnerListens Message Mate',
302
+ 'pa' => 'Perfect Audience Pixel',
303
+ 'pc' => 'Personali Canvas',
304
+ 'pntr' => 'Pinterest',
305
+ 'placedPixel' => 'Placed',
306
+ 'pijs' => 'Pulse Insights Voice of Customer Platform',
307
+ 'qcm' => 'Quantcast Audience Measurement',
308
+ 'qpx' => 'Quora Pixel',
309
+ 'fxm' => 'Rawsoft FoxMetrics',
310
+ 'scjs' => 'SaleCycle JavaScript Tag',
311
+ 'scp' => 'SaleCycle Pixel Tag',
312
+ 'sfc' => 'SearchForce JavaScript Tracking for Conversion Page',
313
+ 'sfl' => 'SearchForce JavaScript Tracking for Landing Page',
314
+ 'sfr' => 'SearchForce Redirection Tracking Tag',
315
+ 'shareaholic' => 'Shareaholic',
316
+ 'svw' => 'Survicate Widget',
317
+ 'tdlc' => 'Tradedoubler Lead Conversion Tag',
318
+ 'tdsc' => 'Tradedoubler Sale Conversion Tag',
319
+ 'tc' => 'Turn Conversion Tracking Tag',
320
+ 'tdc' => 'Turn Data Collection Tag',
321
  'twitter_website_tag' => 'Twitter Universal Website Tag',
322
+ 'uslt' => 'Upsellit Global Footer Tag',
323
+ 'uspt' => 'Upsellit Confirmation Tag',
324
+ 'vei' => 'Ve Interactive JavaScript Tag',
325
+ 'veip' => 'Ve Interactive Pixel',
326
+ 'vdc' => 'VisualDNA Conversion Tag',
327
+ 'xpsh' => 'Xtremepush',
328
+ 'yieldify' => 'Yieldify',
329
+ 'zone' => 'Zones',
330
  ),
331
+ 'triggers' => array(
332
  'evl' => 'Element Visibility Listener/Trigger',
333
+ 'cl' => 'Click Listener/Trigger',
334
  'fsl' => 'Form Submit Listener/Trigger',
335
+ 'hl' => 'History Listener/Trigger',
336
  'jel' => 'JavaScript Error Listener/Trigger',
337
  'lcl' => 'Link Click Listener/Trigger',
338
  'sdl' => 'Scroll Depth Listener/Trigger',
339
+ 'tl' => 'Timer Listener/Trigger',
340
+ 'ytl' => 'YouTube Video Listener/Trigger',
341
  ),
342
  'variables' => array(
343
+ 'k' => '1st Party Cookie',
344
+ 'c' => 'Constant',
345
+ 'ctv' => 'Container Version Number',
346
+ 'e' => 'Custom Event',
347
+ 'jsm' => 'Custom JavaScript Variable',
348
+ 'v' => 'Data Layer Variable',
349
+ 'dbg' => 'Debug Mode',
350
+ 'd' => 'DOM Element',
351
+ 'vis' => 'Element Visibility',
352
+ 'f' => 'HTTP Referrer',
353
+ 'j' => 'JavaScript Variable',
354
+ 'smm' => 'Lookup Table',
355
+ 'r' => 'Random Number',
356
  'remm' => 'RegEx Table',
357
+ 'u' => 'URL',
358
+ ),
359
  );
360
 
361
+ /**
362
+ * Helper function to migrate blacklist / whitelist options from v1.12- to v1.12+
363
+ *
364
+ * @param array $current_options The current and possible outdated config array.
365
+ * @return array
366
+ */
367
  function gtm4wp_migrate_blacklist_whitelist( $current_options ) {
368
  if ( ( array_key_exists( GTM4WP_OPTION_BLACKLIST_ENABLE, $current_options ) )
369
+ && ( $current_options[ GTM4WP_OPTION_BLACKLIST_ENABLE ] > 0 )
370
  ) {
371
  $_gtmrestrictlistitems = array();
372
 
373
+ // IDs from https://developers.google.com/tag-manager/devguide#security .
374
  if ( $current_options[ GTM4WP_OPTION_BLACKLIST_ADADVISOR ] ) {
375
  $_gtmrestrictlistitems[] = 'ta';
376
  }
435
  return $current_options;
436
  }
437
 
438
+ /**
439
+ * Reads plugin options from database backend and merges this with default values.
440
+ * Migrates blacklist/whitelist options from v1.12- to v1.12+
441
+ * Overwrites some options that can be hard coded in wp-config.
442
+ *
443
+ * @return array
444
+ */
445
  function gtm4wp_reload_options() {
446
  global $gtm4wp_defaultoptions, $gtm4wp_business_verticals;
447
 
450
  $gtm4wp_defaultoptions = array();
451
  }
452
 
453
+ if ( ! isset( $storedoptions[ GTM4WP_OPTION_BLACKLIST_STATUS ] ) ) {
454
  $storedoptions = gtm4wp_migrate_blacklist_whitelist( $storedoptions );
455
  }
456
 
457
+ // phpcs:ignore
458
  $return_options = array_merge( $gtm4wp_defaultoptions, $storedoptions );
459
  $return_options[ GTM4WP_OPTION_BLACKLIST_STATUS ] = explode( ',', $return_options[ GTM4WP_OPTION_BLACKLIST_STATUS ] );
460
 
461
  if ( defined( 'GTM4WP_HARDCODED_GTM_ID' ) ) {
462
+ $return_options[ GTM4WP_OPTION_GTM_CODE ] = constant( 'GTM4WP_HARDCODED_GTM_ID' );
463
  }
464
 
465
  if ( defined( 'GTM4WP_HARDCODED_GTM_ENV_AUTH' ) ) {
466
+ $return_options[ GTM4WP_OPTION_ENV_GTM_AUTH ] = constant( 'GTM4WP_HARDCODED_GTM_ENV_AUTH' );
467
  }
468
 
469
  if ( defined( 'GTM4WP_HARDCODED_GTM_ENV_PREVIEW' ) ) {
470
+ $return_options[ GTM4WP_OPTION_ENV_GTM_PREVIEW ] = constant( 'GTM4WP_HARDCODED_GTM_ENV_PREVIEW' );
471
  }
472
 
473
+ if ( ! array_key_exists( $return_options[ GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL ], $gtm4wp_business_verticals ) ) {
474
  $return_options[ GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL ] = $gtm4wp_defaultoptions[ GTM4WP_OPTION_INTEGRATE_WCBUSINESSVERTICAL ];
475
  }
476
 
477
  return $return_options;
478
  }
479
 
480
+ /**
481
+ * Helper function for debug purposes. Not used in stable versions.
482
+ *
483
+ * @param string $debug_data The data that needs to be saved for debug logging.
484
+ * @return void
485
+ */
486
+ // phpcs:disable
487
  function gtp4wp_debug_file( $debug_data ) {
488
+ $fp = fopen( dirname( __FILE__ ) . '/' . gmdate( 'Y-m-d-H-i-s-u' ) . '.txt', 'w' );
489
  if ( $fp ) {
490
  fwrite( $fp, $debug_data );
491
  fclose( $fp );
492
  }
493
  }
494
+ // phpcs:enable
495
 
496
  $gtm4wp_options = gtm4wp_reload_options();
duracelltomi-google-tag-manager-for-wordpress.php CHANGED
@@ -1,26 +1,45 @@
1
  <?php
2
- /*
3
- Plugin Name: Google Tag Manager for Wordpress
4
- Version: 1.15
5
- Plugin URI: https://gtm4wp.com/
6
- Description: The first Google Tag Manager plugin for WordPress with business goals in mind
7
- Author: Thomas Geiger
8
- Author URI: https://gtm4wp.com/
9
- Text Domain: duracelltomi-google-tag-manager
10
- Domain Path: /languages
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- WC requires at least: 3.2
13
- WC tested up to: 6.3.1
14
- */
15
 
16
- define( 'GTM4WP_VERSION', '1.15' );
17
- define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );
18
 
19
  global $gtp4wp_plugin_url, $gtp4wp_plugin_basename;
20
  $gtp4wp_plugin_url = plugin_dir_url( __FILE__ );
21
  $gtp4wp_plugin_basename = plugin_basename( __FILE__ );
22
  require_once GTM4WP_PATH . '/common/readoptions.php';
23
 
 
 
 
 
 
 
 
24
  function gtm4wp_init() {
25
  load_plugin_textdomain( 'duracelltomi-google-tag-manager', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
26
  if ( is_admin() ) {
1
  <?php
2
+ /**
3
+ * Google Tag Manager for WordPress
4
+ *
5
+ * @package GTM4WP
6
+ * @author Thomas Geiger
7
+ * @copyright 2013- Geiger Tamás e.v. (Thomas Geiger s.e.)
8
+ * @license GNU General Public License, version 3
9
+ *
10
+ * @wordpress-plugin
11
+ * Plugin Name: GTM4WP
12
+ * Plugin URI: https://gtm4wp.com/
13
+ * Description: The first Google Tag Manager plugin for WordPress with business goals in mind
14
+ * Version: 1.15.1
15
+ * Requires at least: 3.4.0
16
+ * Requires PHP: 5.6
17
+ * Author: Thomas Geiger
18
+ * Author URI: https://gtm4wp.com/
19
+ * License: GPLv3
20
+ * License URI: https://www.gnu.org/licenses/gpl-3.0.html
21
+ * Text Domain: duracelltomi-google-tag-manager
22
+ * Domain Path: /languages
23
 
24
+ * WC requires at least: 3.2
25
+ * WC tested up to: 6.3.1
26
+ */
27
 
28
+ define( 'GTM4WP_VERSION', '1.15.1' );
29
+ define( 'GTM4WP_PATH', plugin_dir_path( __FILE__ ) );
30
 
31
  global $gtp4wp_plugin_url, $gtp4wp_plugin_basename;
32
  $gtp4wp_plugin_url = plugin_dir_url( __FILE__ );
33
  $gtp4wp_plugin_basename = plugin_basename( __FILE__ );
34
  require_once GTM4WP_PATH . '/common/readoptions.php';
35
 
36
+ /**
37
+ * WordPress hook function run after plugins have been loaded.
38
+ *
39
+ * @see https://developer.wordpress.org/reference/hooks/plugins_loaded/
40
+ *
41
+ * @return void
42
+ */
43
  function gtm4wp_init() {
44
  load_plugin_textdomain( 'duracelltomi-google-tag-manager', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
45
  if ( is_admin() ) {
public/frontend.php CHANGED
@@ -1,6 +1,5 @@
1
  <?php
2
  define( 'GTM4WP_WPFILTER_COMPILE_DATALAYER', 'gtm4wp_compile_datalayer' );
3
- define( 'GTM4WP_WPFILTER_COMPILE_REMARKTING', 'gtm4wp_compile_remarkering' );
4
  define( 'GTM4WP_WPFILTER_AFTER_DATALAYER', 'gtm4wp_after_datalayer' );
5
  define( 'GTM4WP_WPFILTER_GETTHEGTMTAG', 'gtm4wp_get_the_gtm_tag' );
6
  define( 'GTM4WP_WPFILTER_ADDGLOBALVARS', 'gtm4wp_add_global_vars' );
@@ -402,7 +401,7 @@ function gtm4wp_add_basic_datalayer_data( $dataLayer ) {
402
  }
403
 
404
  if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_MISCGEOCF ] && isset( $_SERVER['HTTP_CF_IPCOUNTRY'] ) ) {
405
- $dataLayer['geoCloudflareCountryCode'] = $_SERVER['HTTP_CF_IPCOUNTRY'];
406
  }
407
 
408
  if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHER ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_MISCGEO ] ) {
@@ -550,9 +549,8 @@ function gtm4wp_get_the_gtm_tag() {
550
 
551
  $_gtm_tag .= '
552
  <script' . ( $has_html5_support ? '' : ' type="text/javascript"' ) . ( $add_cookiebot_ignore ? ' data-cookieconsent="ignore"' : '' ) . '>
553
- const console_cmd = console.warn || console.log;
554
- console_cmd && console_cmd("[GTM4WP] Google Tag Manager container code placement set to OFF !!!");
555
- console_cmd && console_cmd("[GTM4WP] Data layer codes are active but GTM container must be loaded using custom coding !!!");
556
  </script>';
557
  }
558
 
@@ -678,16 +676,6 @@ function gtm4wp_wp_body_open() {
678
  }
679
  }
680
 
681
- function gtm4wp_filter_visitor_keys( $dataLayer ) {
682
- foreach ( $dataLayer as $dl_key => $dl_value ) {
683
- if ( strpos( $dl_key, 'visitor' ) !== false ) {
684
- unset( $dataLayer[ $dl_key ] );
685
- }
686
- }
687
-
688
- return $dataLayer;
689
- }
690
-
691
  /**
692
  * GTM4WP global JS variables WordPress filter
693
  *
@@ -752,38 +740,18 @@ function gtm4wp_wp_header_begin( $echo = true ) {
752
  $_gtm_header_content = '
753
  <!-- Google Tag Manager for WordPress by gtm4wp.com -->
754
  <!-- GTM Container placement set to ' . gtm4wp_get_container_placement_string() . ' -->
755
- <script data-cfasync="false" data-pagespeed-no-defer' . ( $has_html5_support ? ' type="text/javascript"' : '' ) . ( $add_cookiebot_ignore ? ' data-cookieconsent="ignore"' : '' ) . '>
756
- const console_cmd = console.warn || console.log;';
757
 
758
  if ( $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] != '' ) {
759
  $gtm4wp_datalayer_data = array();
760
  $gtm4wp_datalayer_data = (array) apply_filters( GTM4WP_WPFILTER_COMPILE_DATALAYER, $gtm4wp_datalayer_data );
761
 
762
- if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_REMARKETING ] ) {
763
- // add Google Ads remarketing tags as suggested here:
764
- // https://support.google.com/tagmanager/answer/3002580?hl=en
765
- add_filter( GTM4WP_WPFILTER_COMPILE_REMARKTING, 'gtm4wp_filter_visitor_keys' );
766
- $gtm4wp_remarketing_tags = (array) apply_filters( GTM4WP_WPFILTER_COMPILE_REMARKTING, $gtm4wp_datalayer_data );
767
-
768
- $_gtm_header_content .= "\nvar google_tag_params = ";
769
- $_gtm_header_content .= json_encode( $gtm4wp_remarketing_tags );
770
- $_gtm_header_content .= ';';
771
- $gtm4wp_datalayer_data['google_tag_params'] = '-~-window.google_tag_params-~-';
772
- }
773
-
774
  if ( version_compare( PHP_VERSION, '5.4.0' ) >= 0 ) {
775
  $gtm4wp_datalayer_json = json_encode( $gtm4wp_datalayer_data, JSON_UNESCAPED_UNICODE );
776
  } else {
777
  $gtm4wp_datalayer_json = json_encode( $gtm4wp_datalayer_data );
778
  }
779
 
780
- // Clean up and then push datalayer to AMP
781
- $gtm4wp_datalayer_json = str_replace(
782
- array( '"-~-', '-~-"' ),
783
- array( '', '' ),
784
- str_replace( '–', '-', $gtm4wp_datalayer_json )
785
- );
786
-
787
  $_gtm_header_content .= '
788
  var dataLayer_content = ' . $gtm4wp_datalayer_json . ';';
789
 
@@ -880,8 +848,8 @@ function gtm4wp_wp_header_begin( $echo = true ) {
880
 
881
  $_gtm_header_content .= '
882
  <script' . ( $has_html5_support ? '' : ' type="text/javascript"' ) . ( $add_cookiebot_ignore ? ' data-cookieconsent="ignore"' : '' ) . '>
883
- console_cmd && console_cmd("[GTM4WP] Google Tag Manager container code placement set to OFF !!!");
884
- console_cmd && console_cmd("[GTM4WP] Data layer codes are active but GTM container must be loaded using custom coding !!!");
885
  </script>';
886
  }
887
 
@@ -894,9 +862,9 @@ function gtm4wp_wp_header_begin( $echo = true ) {
894
 
895
  $_gtm_header_content .= '
896
  <script' . ( $has_html5_support ? '' : ' type="text/javascript"' ) . ( $add_cookiebot_ignore ? ' data-cookieconsent="ignore"' : '' ) . '>
897
- console_cmd && console_cmd("[GTM4WP] Google Tag Manager container code was disabled for this user role: ' . $user_role . ' !!!");
898
- console_cmd && console_cmd("[GTM4WP] Logout or login with a user having a different user role!");
899
- console_cmd && console_cmd("[GTM4WP] Data layer codes are active but GTM container code is omitted !!!");
900
  </script>';
901
 
902
  break;
1
  <?php
2
  define( 'GTM4WP_WPFILTER_COMPILE_DATALAYER', 'gtm4wp_compile_datalayer' );
 
3
  define( 'GTM4WP_WPFILTER_AFTER_DATALAYER', 'gtm4wp_after_datalayer' );
4
  define( 'GTM4WP_WPFILTER_GETTHEGTMTAG', 'gtm4wp_get_the_gtm_tag' );
5
  define( 'GTM4WP_WPFILTER_ADDGLOBALVARS', 'gtm4wp_add_global_vars' );
401
  }
402
 
403
  if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_MISCGEOCF ] && isset( $_SERVER['HTTP_CF_IPCOUNTRY'] ) ) {
404
+ $dataLayer['geoCloudflareCountryCode'] = esc_js( $_SERVER['HTTP_CF_IPCOUNTRY'] );
405
  }
406
 
407
  if ( $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_WEATHER ] || $gtm4wp_options[ GTM4WP_OPTION_INCLUDE_MISCGEO ] ) {
549
 
550
  $_gtm_tag .= '
551
  <script' . ( $has_html5_support ? '' : ' type="text/javascript"' ) . ( $add_cookiebot_ignore ? ' data-cookieconsent="ignore"' : '' ) . '>
552
+ console.warn && console.warn("[GTM4WP] Google Tag Manager container code placement set to OFF !!!");
553
+ console.warn && console.warn("[GTM4WP] Data layer codes are active but GTM container must be loaded using custom coding !!!");
 
554
  </script>';
555
  }
556
 
676
  }
677
  }
678
 
 
 
 
 
 
 
 
 
 
 
679
  /**
680
  * GTM4WP global JS variables WordPress filter
681
  *
740
  $_gtm_header_content = '
741
  <!-- Google Tag Manager for WordPress by gtm4wp.com -->
742
  <!-- GTM Container placement set to ' . gtm4wp_get_container_placement_string() . ' -->
743
+ <script data-cfasync="false" data-pagespeed-no-defer' . ( $has_html5_support ? ' type="text/javascript"' : '' ) . ( $add_cookiebot_ignore ? ' data-cookieconsent="ignore"' : '' ) . '>';
 
744
 
745
  if ( $gtm4wp_options[ GTM4WP_OPTION_GTM_CODE ] != '' ) {
746
  $gtm4wp_datalayer_data = array();
747
  $gtm4wp_datalayer_data = (array) apply_filters( GTM4WP_WPFILTER_COMPILE_DATALAYER, $gtm4wp_datalayer_data );
748
 
 
 
 
 
 
 
 
 
 
 
 
 
749
  if ( version_compare( PHP_VERSION, '5.4.0' ) >= 0 ) {
750
  $gtm4wp_datalayer_json = json_encode( $gtm4wp_datalayer_data, JSON_UNESCAPED_UNICODE );
751
  } else {
752
  $gtm4wp_datalayer_json = json_encode( $gtm4wp_datalayer_data );
753
  }
754
 
 
 
 
 
 
 
 
755
  $_gtm_header_content .= '
756
  var dataLayer_content = ' . $gtm4wp_datalayer_json . ';';
757
 
848
 
849
  $_gtm_header_content .= '
850
  <script' . ( $has_html5_support ? '' : ' type="text/javascript"' ) . ( $add_cookiebot_ignore ? ' data-cookieconsent="ignore"' : '' ) . '>
851
+ console.warn && console.warn("[GTM4WP] Google Tag Manager container code placement set to OFF !!!");
852
+ console.warn && console.warn("[GTM4WP] Data layer codes are active but GTM container must be loaded using custom coding !!!");
853
  </script>';
854
  }
855
 
862
 
863
  $_gtm_header_content .= '
864
  <script' . ( $has_html5_support ? '' : ' type="text/javascript"' ) . ( $add_cookiebot_ignore ? ' data-cookieconsent="ignore"' : '' ) . '>
865
+ console.warn && console.warn("[GTM4WP] Google Tag Manager container code was disabled for this user role: ' . $user_role . ' !!!");
866
+ console.warn && console.warn("[GTM4WP] Logout or login with a user having a different user role!");
867
+ console.warn && console.warn("[GTM4WP] Data layer codes are active but GTM container code is omitted !!!");
868
  </script>';
869
 
870
  break;
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
- === Google Tag Manager for WordPress ===
2
  Contributors: duracelltomi
3
  Donate link: https://gtm4wp.com/
4
  Tags: google tag manager, tag manager, gtm, google, adwords, google adwords, google ads, adwords remarketing, google ads remarketing, remarketing, google analytics, analytics, facebook ads, facebook remarketing, facebook pixel, google optimize, personalisation
5
  Requires at least: 3.4.0
6
  Requires PHP: 5.6
7
- Tested up to: 5.9.0
8
- Stable tag: 1.15
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl.html
11
 
@@ -136,7 +136,7 @@ http://cutroni.com/blog/2012/02/21/advanced-content-tracking-with-google-analyti
136
 
137
  = Google Ads remarketing =
138
 
139
- Google Tag Manager for WordPress can add each dataLayer variable as a Google Ads remarketing custom parameter list.
140
  This enables you to build sophisticated remarketing lists.
141
 
142
  = Blacklist & Whitelist Tag Manager tags, triggers and variables =
@@ -150,7 +150,7 @@ and/or custom JavaScript variables you can secure the Tag Manager container.
150
 
151
  = Integration =
152
 
153
- Google Tag Manager for WordPress integrates with several popular plugins. More integration to come!
154
 
155
  * Contact Form 7: fire an event when a Contact Form 7 form was submitted with any result (mail sent, mail failed, spam detected, invalid input)
156
  * WooCommerce:
@@ -235,6 +235,18 @@ https://gtm4wp.com/how-to-articles/how-to-exclude-admin-users-from-being-tracked
235
 
236
  == Changelog ==
237
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  = 1.15 =
239
 
240
  * Added: pagePostType data layer variable will now return 404-error on 404 pages and search-results on search result pages
1
+ === GTM4WP ===
2
  Contributors: duracelltomi
3
  Donate link: https://gtm4wp.com/
4
  Tags: google tag manager, tag manager, gtm, google, adwords, google adwords, google ads, adwords remarketing, google ads remarketing, remarketing, google analytics, analytics, facebook ads, facebook remarketing, facebook pixel, google optimize, personalisation
5
  Requires at least: 3.4.0
6
  Requires PHP: 5.6
7
+ Tested up to: 5.9.3
8
+ Stable tag: 1.15.1
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl.html
11
 
136
 
137
  = Google Ads remarketing =
138
 
139
+ GTM4WP can add each dataLayer variable as a Google Ads remarketing custom parameter list.
140
  This enables you to build sophisticated remarketing lists.
141
 
142
  = Blacklist & Whitelist Tag Manager tags, triggers and variables =
150
 
151
  = Integration =
152
 
153
+ GTM4WP integrates with several popular plugins. More integration to come!
154
 
155
  * Contact Form 7: fire an event when a Contact Form 7 form was submitted with any result (mail sent, mail failed, spam detected, invalid input)
156
  * WooCommerce:
235
 
236
  == Changelog ==
237
 
238
+ = 1.15.1 =
239
+
240
+ * Fixed: JavaScript error with the newly added console logging to debug code placement issues
241
+ * Fixed: possible XSS Vulnerability if Cloudflare country code option enabled. Thanks [Guillaume Fortier](https://www.linkedin.com/in/guillaume-f-a728711b0/)
242
+ * Fixed: proven XSS Vulnerability if adding site search into the data layer was enabled. Original report by [not_stoppable](https://hackerone.com/not_stoppable?type=user). Root cause analysis by [Cory Buecker](https://www.linkedin.com/in/corybuecker/).
243
+ * Removed: deprecated feature Google Ads remarketing. This is the outdated, classic way using the google_tag_params variable.
244
+ * Dev: removed PHP constant GTM4WP_WPFILTER_COMPILE_REMARKTING (related to removed Google Ads remarketing feature)
245
+ * Dev: removed gtm4wp_compile_remarkering WordPress filter (related to removed Google Ads remarketing feature)
246
+
247
+ Note to plugin users: I sincerely appologize for the vulnerabilities. To make sure, such cases do not happen again,
248
+ the next version will be fully dedicacted to go through every peace of code and make sure proper data processing is happening in GTM4WP.
249
+
250
  = 1.15 =
251
 
252
  * Added: pagePostType data layer variable will now return 404-error on 404 pages and search-results on search result pages
uninstall.php CHANGED
@@ -1,9 +1,19 @@
1
- <?php
2
- // if uninstall.php is not called by WordPress, die
3
- if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
4
- die;
5
- }
6
-
7
- require_once dirname( __FILE__ ) . '/common/readoptions.php';
8
-
9
- delete_option( GTM4WP_OPTIONS );
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Loaded when GTM4WP was uninstalled.
4
+ * Deletes plugin options from database.
5
+ *
6
+ * @package GTM4WP
7
+ * @author Thomas Geiger
8
+ * @copyright 2013- Geiger Tamás e.v. (Thomas Geiger s.e.)
9
+ * @license GNU General Public License, version 3
10
+ */
11
+
12
+ // if uninstall.php is not called by WordPress, die.
13
+ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
14
+ die;
15
+ }
16
+
17
+ require_once dirname( __FILE__ ) . '/common/readoptions.php';
18
+
19
+ delete_option( GTM4WP_OPTIONS );