Google Analytics for WordPress by MonsterInsights - Version 7.11.0

Version Description

= 7.0.0 =

This is a major release. Please back up your site before upgrading.

= 6.0.0 =

This is a major release. Please back up your site before upgrading.

Download this release

Release Info

Developer chriscct7
Plugin Icon 128x128 Google Analytics for WordPress by MonsterInsights
Version 7.11.0
Comparing to
See all releases

Code changes from version 7.10.4 to 7.11.0

Files changed (63) hide show
  1. README.md +0 -163
  2. assets/css/admin-common.css +66 -56
  3. assets/css/admin-common.min.css +1 -1
  4. assets/css/images/index.php +3 -3
  5. assets/css/index.php +3 -3
  6. assets/fonts/README.md +17 -17
  7. assets/fonts/index.php +3 -3
  8. assets/images/index.php +3 -3
  9. assets/index.php +3 -3
  10. assets/js/admin-common.js +24 -24
  11. assets/js/frontend.js +643 -643
  12. assets/js/index.php +3 -3
  13. assets/lib/index.php +3 -3
  14. assets/lib/pandora/class-am-deactivation-survey.php +358 -343
  15. assets/lib/pandora/class-am-notification.php +0 -472
  16. googleanalytics.php +760 -746
  17. includes/admin/admin.php +538 -494
  18. includes/admin/ajax.php +208 -208
  19. includes/admin/api-auth.php +583 -583
  20. includes/admin/common.php +1099 -1092
  21. includes/admin/index.php +3 -3
  22. includes/admin/licensing/autoupdate.php +93 -93
  23. includes/admin/licensing/plugin-upgrader.php +571 -0
  24. includes/admin/licensing/skin.php +116 -115
  25. includes/admin/notice.php +235 -235
  26. includes/admin/notifications.php +408 -0
  27. includes/admin/pages/addons.php +183 -183
  28. includes/admin/pages/reports.php +65 -65
  29. includes/admin/pages/settings.php +129 -124
  30. includes/admin/pages/tools.php +44 -44
  31. includes/admin/reporting.php +67 -67
  32. includes/admin/reports/abstract-report.php +456 -439
  33. includes/admin/reports/index.php +3 -3
  34. includes/admin/reports/overview.php +80 -80
  35. includes/admin/review.php +196 -192
  36. includes/admin/routes.php +789 -707
  37. includes/admin/tracking.php +246 -246
  38. includes/api-request.php +443 -439
  39. includes/auth.php +250 -250
  40. includes/capabilities.php +88 -88
  41. includes/deprecated.php +238 -236
  42. includes/emails/class-emails.php +664 -0
  43. includes/emails/templates/body-default-plain.php +2 -0
  44. includes/emails/templates/body-default.php +16 -0
  45. includes/emails/templates/footer-default.php +65 -0
  46. includes/emails/templates/header-default.php +273 -0
  47. includes/frontend/class-tracking-abstract.php +78 -78
  48. includes/frontend/events/class-analytics-events.php +115 -115
  49. includes/frontend/events/index.php +3 -3
  50. includes/frontend/frontend.php +400 -383
  51. includes/frontend/index.php +3 -3
  52. includes/frontend/seedprod.php +44 -44
  53. includes/frontend/tracking/class-tracking-analytics.php +346 -340
  54. includes/frontend/tracking/class-tracking-preview.php +80 -80
  55. includes/frontend/tracking/index.php +3 -3
  56. includes/helpers.php +1500 -1297
  57. includes/index.php +3 -3
  58. includes/install.php +705 -673
  59. includes/measurement-protocol.php +141 -141
  60. includes/options.php +419 -414
  61. index.php +3 -3
  62. languages/index.php +3 -3
  63. languages/vue.php +296 -267
README.md DELETED
@@ -1,163 +0,0 @@
1
- # [MonsterInsights](https://www.monsterinsights.com) #
2
- The best Google Analytics Integration for WordPress. Period.<br />
3
- ![Plugin Version](https://img.shields.io/wordpress/plugin/v/google-analytics-for-wordpress.svg?maxAge=2592000)
4
- ![Total Downloads](https://img.shields.io/wordpress/plugin/dt/google-analytics-for-wordpress.svg?maxAge=2592000)
5
- ![WordPress Compatibility](https://img.shields.io/wordpress/v/google-analytics-for-wordpress.svg?maxAge=2592000)
6
- [![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%205.2-8892BF.svg?style=flat-square)](https://php.net/)
7
- [![License](https://img.shields.io/badge/license-GPL--2.0%2B-red.svg)](https://github.com/awesomemotive/google-analytics-for-wordpress/blob/master/license.txt)
8
- [![Build Status](https://scrutinizer-ci.com/g/awesomemotive/google-analytics-for-wordpress/badges/build.png?b=master)](https://scrutinizer-ci.com/g/awesomemotive/google-analytics-for-wordpress/build-status/master)
9
- [![Code Intelligence Status](https://scrutinizer-ci.com/g/awesomemotive/google-analytics-for-wordpress/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence)
10
- [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/awesomemotive/google-analytics-for-wordpress/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/awesomemotive/google-analytics-for-wordpress/?branch=master)
11
- [![Codacy Badge](https://api.codacy.com/project/badge/Grade/2944b6d77fa342f59764e79285da02bf)](https://www.codacy.com/app/chriscct7/google-analytics-for-wordpress?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=awesomemotive/google-analytics-for-wordpress&amp;utm_campaign=Badge_Grade)
12
-
13
- ## Contributions ##
14
- Anyone is welcome to contribute to MonsterInsights. Please read the [guidelines for contributing](https://github.com/awesomemotive/google-analytics-for-wordpress/blob/master/CONTRIBUTING.md) to this repository.
15
-
16
- There are various ways you can contribute:
17
-
18
- 1. Raise an [Issue](https://github.com/awesomemotive/google-analytics-for-wordpress/issues) on GitHub
19
- 2. Send us a Pull Request with your bug fixes and/or new features
20
- 3. Provide feedback and suggestions on [enhancements](https://github.com/awesomemotive/google-analytics-for-wordpress/issues?direction=desc&labels=Enhancement&page=1&sort=created&state=open)
21
-
22
- ## Bugs ##
23
- If you find an issue, let us know [here](https://github.com/awesomemotive/google-analytics-for-wordpress/issues?state=open)!
24
-
25
- ## Support ##
26
- This is a developer's portal for Google Analytics for WordPress by MonsterInsights and should not be used for support.
27
-
28
- For the lite version please use monsterinsights.com [Lite support](https://www.monsterinsights.com/lite-support/).
29
-
30
- For users of the pro version, please use the support form, located on the Support tab of the My Account page of our website (note: you must be logged in & have
31
- an active license to use this form).
32
-
33
- Please report security issues to support@monsterinsights.com
34
-
35
- ## Backwards Compatibility Guidelines for Developers ##
36
- Note all functionality on the admin side of the plugin, including any php/js/css functions, class names, files (or filenames), hooks or otherwise will not be garunteed backwards compatibility as a general rule. Our admin code is subject to change at any time without warning. As MonsterInsights is a frontend focused plugin, we're not too sure why you'd be building stuff with our backend code anyways. If you for some reason do need to use our backend code (anything located in admin or enqueued only in admin), please contact us with your usecase so we can adjust this policy and ensure your code will not break in the future.
37
-
38
- For the frontend, we will not garuntee that the JS output will always be the same, nor can we, as we will adjust it over time to ensure continued Google Analytics compatibility and add features. However, we will garuntee the backwards compatibility of any hooks (filters or actions) found exclusively in the `lite/includes/frontend`, `pro/includes/frontend`, and `includes/frontend` directories to the best of our abilities. These hooks are documented as such. Any sort of future breakage will be announced well in advance of any changes, and we'll try to never break anyone's use of these hooks.
39
-
40
- ## Code Styling Documentation ##
41
-
42
- MonsterInsights adheres to the WordPress core PHP standard with a couple deviations noted below. See https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/ for information on documenting using this standard.
43
-
44
- ### Deviations ###
45
-
46
- - [Use `elseif`, not `else if`](https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#use-elseif-not-else-if)
47
- - In MonsterInsights, use `else if` as we do not permit use of the colon form of `if else`, rendering Core's reason for this rule null. Colon forms of `if else` are harder for text editors such as Sublime Text to parse the opening and closing of conditional logic, and thus are not permitted.
48
- - Avoid regular expressions wherever possible
49
- - Regular expressions make it more difficult for new contributors to contribute. Thus whenever possible, regular expressions should be avoided.
50
- - [Yoda Conditions](https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#yoda-conditions)
51
- - Code should never be written where a variable is being non-strictly compared to `true` or `false`. Use the appropriate way of writing the if statement. `if ( true == $var )` is equivolent to `if ( $var )` and the latter is much easier to read. However when strict comparison is required (`===`), one should use `if ( true === $var )`.
52
-
53
- ### Additions ###
54
-
55
- - Required: Code should be formatted using tabs, set to size of 4 spaces
56
- - 4 spaces per tab is the universally accepted default tab size. Tabs are easier to read through in most editors. Additionally, they take up less file space than 4 spaces.
57
- - Required: Filter and function names should use underscores, not dashes
58
- - For consistency, all filter and functions should use underscores not dashes or CamelCasing when seperating words. Additionally, all filter and (functions not in a class) names should be preceeded by `monsterinsights_`. The only exception to this is filters that need to be pro or lite only, in which case they should be proceeded by `monsterinsights_pro_` and `monsterinsights_lite_` respectively. Functions in a class should not be preceeded by `monsterinsights_`.
59
- - Required: Hooks tied to a function not within a class, will be tied to the function after the end of the function's declaration
60
- - Since MonsterInsights requires all functions have a function docbloc immediately preceeding the declaration of a function, to make it easier to locate hooks tied to a function, the `add_action` or `add_filter` call(s) to a function shall be placed immediately after the end of a function declaration. For functions in classes, this rule does not apply as it is impossible to do this.
61
- - Recommended: Use pre-increments (`++i`) instead of post-increments (`i++`)
62
- - The former is more performant as it does not require a copy of the variable to be made. This rule is not strictly enforced, and where it detracts from the readability or simplicity of code, it should be ignored.
63
- - Recommended: Where possible avoid stored data changes
64
- - This plugin has a lot of active installs. As such, whereever possible, we should try to avoid requiring an upgrade routine to convert stored data. Having a routine that adds data to make something more performant is fine as long as it either falls back to existing data, a smart default, or stops execution (in a controlled manner).
65
-
66
- ## Language Translations, Textdomains, and Internationalization ##
67
-
68
- MonsterInsights is translation ready. Thanks to an extensive team of .org translators, much of the plugin is available translated into a wide variety of languages.
69
-
70
- ### What Textdomain to Use ##
71
-
72
- In googleanalytics-premium.php and in the /pro/ folder only use `ga-premium`. Everywhere else use `google-analytics-for-wordpress`.
73
-
74
- MonsterInsights Lite uses WordPress.org provided translation files. MonsterInsights Pro loads the Lite translation files for files shared with Lite, and also loads Pro-only translation files for the Pro-only files. These files are created automatically from Pro translations. The latest copy of these files are pulled down and deployed with each Pro release.
75
-
76
- ### How To Contribute Translations ###
77
-
78
- Via the WordPress.org translation system located [here](https://www.wordpress.org/plugins/google-analytics-for-wordpress/translations/).
79
-
80
- ### I've found a non-translatable string that a user can see. What should I do? ###
81
-
82
- Please open a [issue](https://github.com/awesomemotive/google-analytics-for-wordpress/issues) for it.
83
-
84
- ## Automation and External Libraries ##
85
-
86
- A project goal of MonsterInsights, is to embrace automation whenever possible.
87
-
88
- The MonsterInsights project taskrunner standard is Robo, and tasks for this project can be found in RoboFile.php (not available to public), and executed via:
89
- robo {command}
90
-
91
- The entire deployment process, the thing that makes a new MonsterInsights version and releases it, is completely automated (no human interaction required) via Robo.
92
-
93
- The MonsterInsights project dependency management system is Composer. Please make sure you don't accidentily override our composer file in your PRs.
94
-
95
- We also use Node/NPM to manage packages used by our plugin primarily for admin styling and functionality.
96
-
97
- We generally will always use the latest stable version of any Composer or NPM dependency, pulled and packaged during our automated release process, when possible. Some reasons we might use an out of date package include (but are not limited to):
98
-
99
- - Lack of PHP version support
100
- - A bug in the current version of the dependency that affects our plugin's use of the dependency
101
- - Lack of time to test the current version of the dependency before the release of our plugin
102
- - A security issue, which may or may not be public
103
- - A compatibility issue between a dependency and a different dependency
104
- - A change in the dependency that affects MonsterInsights's ability to be conflict-free with other plugins
105
- - and so forth
106
-
107
- When possible, we will always override/prefix all CSS rules, JS functions, and PHP class and function names in the dependencies we include when possible. With ~2 million active installs, not doing so is not an option (too many badly coded plugins out there). This process is completely automated, and done on release, between the step when composer/npm brings down the latest dependency versions, and when the zip files are autogenerated.
108
-
109
- When possible, we will also minify all JS/CSS files from dependencies into a single file that gets used, except when there's compatibility issues, or if there's a bug in the parser of the CSS/JS minifier we use.
110
-
111
- ## Warning About Package Managing MonsterInsights ##
112
-
113
- We do not maintain, nor have any current plans, to allow our plugin to be installed via Composer, Packagist, or other similar systems.
114
-
115
- We also do not recommend you via direct code or a management system (such as via a GitHub repo download Composer package), assume our plugin, on any branch, will be the current and/or stable branch of our plugin.
116
-
117
- The only official and maintained source of our plugin is on WordPress.org for the Lite version, and from the My Account area (or via the automatic updates) for the Pro version.
118
-
119
- ## Development Checkout Procedure ##
120
-
121
- `composer install`
122
- `cd assets`
123
- `npm update`
124
-
125
- ## Constants ##
126
-
127
- The following constants can be defined in a wp-config file to allow for sections of MonsterInsights to be turned on and off across an installation base (and also for unit testing)
128
-
129
- ### Both Pro & Lite ###
130
-
131
- Plugin defined:
132
- - `MONSTERINSIGHTS_VERSION`
133
- - The version of pro/lite installed
134
- - `MONSTERINSIGHTS_PLUGIN_NAME`
135
- - The name of the plugin
136
- - `MONSTERINSIGHTS_PLUGIN_SLUG`
137
- - The slug of this plugin
138
- - `MONSTERINSIGHTS_PLUGIN_FILE`
139
- - The name of this file
140
- - `MONSTERINSIGHTS_PLUGIN_DIR`
141
- - Path to the MI base folder
142
- - `MONSTERINSIGHTS_PLUGIN_URL`
143
- - URL to the MI base folder
144
-
145
- User defined:
146
- - `MONSTERINSIGHTS_LICENSE_KEY`
147
- - MonsterInsights license key to use as the fallback (please use auth though not this, as you can do this on the network panel now on multisites)
148
- - `MONSTERINSIGHTS_FORCE_ACTIVATION`
149
- - Override the WP version activation check. Use at your own risk.
150
- - `MONSTERINSIGHTS_AIRPLANE_MODE`
151
- - For future use. Currently does nothing. Useful for local site testing.
152
- - `MONSTERINSIGHTS_GA_UA`
153
- - Don't use oAuth or the wizard, but hardcode to use UA. Note, this will not allow backend reports to work. You can also use the filter `monsterinsights_get_ua`.
154
- - `MONSTERINSIGHTS_MULTISITE_GA_UA`.
155
- - You can use this constant to force the same the same UA for all subsites of an MS install. Note, this will not allow backend reports to work.
156
-
157
- ### Lite Only ###
158
- - `MONSTERINSIGHTS_LITE_VERSION`
159
- - The version of lite installed
160
-
161
- ### Pro Only ###
162
- - `MONSTERINSIGHTS_PRO_VERSION`
163
- - The version of pro installed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/admin-common.css CHANGED
@@ -1,56 +1,66 @@
1
- #toplevel_page_monsterinsights_reports .wp-menu-image img,
2
- #toplevel_page_monsterinsights_settings .wp-menu-image img,
3
- #toplevel_page_monsterinsights_network .wp-menu-image img {
4
- width: 18px;
5
- height: auto;
6
- padding-top: 7px;
7
- }
8
-
9
- .monsterinsights-wooedd-upsell-left {
10
- width: 50%;
11
- display: table-cell;
12
- float: left;
13
- }
14
-
15
- .monsterinsights-wooedd-upsell-right {
16
- width: 50%;
17
- display: table-cell;
18
- float: left;
19
- }
20
-
21
- .monsterinsights-wooedd-upsell-image {
22
- width: 100%;
23
- height: auto;
24
- padding: 20px;
25
- }
26
-
27
- .monsterinsights-wooedd-upsell-image-small {
28
- display: none;
29
- }
30
-
31
- .monsterinsights-wooedd-upsell-row {
32
- display: table;
33
- }
34
-
35
- .monsterinsights-wooedd-upsell-left p {
36
- margin: 1em 0;
37
- font-size: 16px;
38
- }
39
-
40
- @media (max-width: 900px) {
41
- .monsterinsights-wooedd-upsell-left {
42
- width: 100%;
43
- }
44
-
45
- .monsterinsights-wooedd-upsell-right {
46
- display: none;
47
- }
48
-
49
- .monsterinsights-wooedd-upsell-image-small {
50
- display: block;
51
- }
52
-
53
- .monsterinsights-wooedd-upsell-image-large {
54
- display: none;
55
- }
56
- }
 
 
 
 
 
 
 
 
 
 
1
+ .monsterinsights-wooedd-upsell-left {
2
+ width: 50%;
3
+ display: table-cell;
4
+ float: left;
5
+ }
6
+
7
+ .monsterinsights-wooedd-upsell-right {
8
+ width: 50%;
9
+ display: table-cell;
10
+ float: left;
11
+ }
12
+
13
+ .monsterinsights-wooedd-upsell-image {
14
+ width: 100%;
15
+ height: auto;
16
+ padding: 20px;
17
+ }
18
+
19
+ .monsterinsights-wooedd-upsell-image-small {
20
+ display: none;
21
+ }
22
+
23
+ .monsterinsights-wooedd-upsell-row {
24
+ display: table;
25
+ }
26
+
27
+ .monsterinsights-wooedd-upsell-left p {
28
+ margin: 1em 0;
29
+ font-size: 16px;
30
+ }
31
+
32
+ @media (max-width: 900px) {
33
+ .monsterinsights-wooedd-upsell-left {
34
+ width: 100%;
35
+ }
36
+
37
+ .monsterinsights-wooedd-upsell-right {
38
+ display: none;
39
+ }
40
+
41
+ .monsterinsights-wooedd-upsell-image-small {
42
+ display: block;
43
+ }
44
+
45
+ .monsterinsights-wooedd-upsell-image-large {
46
+ display: none;
47
+ }
48
+ }
49
+
50
+ #wpadminbar .monsterinsights-menu-notification-indicator,
51
+ .monsterinsights-menu-notification-indicator {
52
+ width: 12px;
53
+ height: 12px;
54
+ border-radius: 50%;
55
+ background: #C84B29;
56
+ display: inline-block;
57
+ margin-left: 8px;
58
+ }
59
+
60
+ @media (max-width: 782px) {
61
+ #wpadminbar .monsterinsights-menu-notification-indicator {
62
+ margin: 0 0 10px -13px;
63
+ z-index: 10;
64
+ position: relative;
65
+ }
66
+ }
assets/css/admin-common.min.css CHANGED
@@ -1 +1 @@
1
- #toplevel_page_monsterinsights_reports .wp-menu-image img,#toplevel_page_monsterinsights_settings .wp-menu-image img,#toplevel_page_monsterinsights_network .wp-menu-image img{width:18px;height:auto;padding-top:7px}.monsterinsights-wooedd-upsell-left{width:50%;display:table-cell;float:left}.monsterinsights-wooedd-upsell-right{width:50%;display:table-cell;float:left}.monsterinsights-wooedd-upsell-image{width:100%;height:auto;padding:20px}.monsterinsights-wooedd-upsell-image-small{display:none}.monsterinsights-wooedd-upsell-row{display:table}.monsterinsights-wooedd-upsell-left p{margin:1em 0;font-size:16px}@media (max-width: 900px){.monsterinsights-wooedd-upsell-left{width:100%}.monsterinsights-wooedd-upsell-right{display:none}.monsterinsights-wooedd-upsell-image-small{display:block}.monsterinsights-wooedd-upsell-image-large{display:none}}
1
+ .monsterinsights-wooedd-upsell-left{width:50%;display:table-cell;float:left}.monsterinsights-wooedd-upsell-right{width:50%;display:table-cell;float:left}.monsterinsights-wooedd-upsell-image{width:100%;height:auto;padding:20px}.monsterinsights-wooedd-upsell-image-small{display:none}.monsterinsights-wooedd-upsell-row{display:table}.monsterinsights-wooedd-upsell-left p{margin:1em 0;font-size:16px}@media (max-width: 900px){.monsterinsights-wooedd-upsell-left{width:100%}.monsterinsights-wooedd-upsell-right{display:none}.monsterinsights-wooedd-upsell-image-small{display:block}.monsterinsights-wooedd-upsell-image-large{display:none}}#wpadminbar .monsterinsights-menu-notification-indicator,.monsterinsights-menu-notification-indicator{width:12px;height:12px;border-radius:50%;background:#C84B29;display:inline-block;margin-left:8px}@media (max-width: 782px){#wpadminbar .monsterinsights-menu-notification-indicator{margin:0 0 10px -13px;z-index:10;position:relative}}
assets/css/images/index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- //Nothing to see here
3
-
4
  header( 'HTTP/1.0 403 Forbidden' );
1
+ <?php
2
+ //Nothing to see here
3
+
4
  header( 'HTTP/1.0 403 Forbidden' );
assets/css/index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- //Nothing to see here
3
-
4
  header( 'HTTP/1.0 403 Forbidden' );
1
+ <?php
2
+ //Nothing to see here
3
+
4
  header( 'HTTP/1.0 403 Forbidden' );
assets/fonts/README.md CHANGED
@@ -1,17 +1,17 @@
1
- # Updating Icons
2
-
3
- The main font used by MonsterInsights for icons has the font-family: 'Misettings'.
4
-
5
- The files used by this font are
6
-
7
- - assets/fonts/icons.eot
8
- - assets/fonts/icons.otf
9
- - assets/fonts/icons.ttf
10
- - assets/fonts/icons.woff
11
- - assets/fonts/icons.woff2
12
-
13
- The font files are generated using [FortAwesome](https://fortawesome.com).
14
-
15
- After generating new files, you'll need to update the files mentioned above & the css
16
- used for the icons which can be found in assets/css/admin.css starting on line 135, look
17
- for the class `.monstericon-`.
1
+ # Updating Icons
2
+
3
+ The main font used by MonsterInsights for icons has the font-family: 'Misettings'.
4
+
5
+ The files used by this font are
6
+
7
+ - assets/fonts/icons.eot
8
+ - assets/fonts/icons.otf
9
+ - assets/fonts/icons.ttf
10
+ - assets/fonts/icons.woff
11
+ - assets/fonts/icons.woff2
12
+
13
+ The font files are generated using [FortAwesome](https://fortawesome.com).
14
+
15
+ After generating new files, you'll need to update the files mentioned above & the css
16
+ used for the icons which can be found in assets/css/admin.css starting on line 135, look
17
+ for the class `.monstericon-`.
assets/fonts/index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- //Nothing to see here
3
-
4
  header( 'HTTP/1.0 403 Forbidden' );
1
+ <?php
2
+ //Nothing to see here
3
+
4
  header( 'HTTP/1.0 403 Forbidden' );
assets/images/index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- //Nothing to see here
3
-
4
  header( 'HTTP/1.0 403 Forbidden' );
1
+ <?php
2
+ //Nothing to see here
3
+
4
  header( 'HTTP/1.0 403 Forbidden' );
assets/index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- //Nothing to see here
3
-
4
  header( 'HTTP/1.0 403 Forbidden' );
1
+ <?php
2
+ //Nothing to see here
3
+
4
  header( 'HTTP/1.0 403 Forbidden' );
assets/js/admin-common.js CHANGED
@@ -1,25 +1,25 @@
1
- jQuery( document ).ready( function( $ ) {
2
- /**
3
- * Dismissable Notices
4
- * - Sends an AJAX request to mark the notice as dismissed
5
- */
6
- $( 'div.monsterinsights-notice' ).on( 'click', 'button.notice-dismiss', function( e ) {
7
- e.preventDefault();
8
- $( this ).closest( 'div.monsterinsights-notice' ).fadeOut();
9
-
10
- // If this is a dismissible notice, it means we need to send an AJAX request
11
- if ( $( this ).parent().hasClass( 'is-dismissible' ) ) {
12
- $.post(
13
- monsterinsights_admin_common.ajax,
14
- {
15
- action: 'monsterinsights_ajax_dismiss_notice',
16
- nonce: monsterinsights_admin_common.dismiss_notice_nonce,
17
- notice: $( this ).parent().data( 'notice' )
18
- },
19
- function( response ) {},
20
- 'json'
21
- );
22
- }
23
-
24
- } );
25
  });
1
+ jQuery( document ).ready( function( $ ) {
2
+ /**
3
+ * Dismissable Notices
4
+ * - Sends an AJAX request to mark the notice as dismissed
5
+ */
6
+ $( 'div.monsterinsights-notice' ).on( 'click', 'button.notice-dismiss', function( e ) {
7
+ e.preventDefault();
8
+ $( this ).closest( 'div.monsterinsights-notice' ).fadeOut();
9
+
10
+ // If this is a dismissible notice, it means we need to send an AJAX request
11
+ if ( $( this ).parent().hasClass( 'is-dismissible' ) ) {
12
+ $.post(
13
+ monsterinsights_admin_common.ajax,
14
+ {
15
+ action: 'monsterinsights_ajax_dismiss_notice',
16
+ nonce: monsterinsights_admin_common.dismiss_notice_nonce,
17
+ notice: $( this ).parent().data( 'notice' )
18
+ },
19
+ function( response ) {},
20
+ 'json'
21
+ );
22
+ }
23
+
24
+ } );
25
  });
assets/js/frontend.js CHANGED
@@ -1,643 +1,643 @@
1
- /**
2
- * Developer's Notice:
3
- *
4
- * Note: JS in this file (and this file itself) is not garunteed backwards compatibility. JS can be added, changed or removed at any time without notice.
5
- * For more information see the `Backwards Compatibility Guidelines for Developers` section of the README.md file.
6
- */
7
- /**
8
- * Handles:
9
- * - JS Events handling
10
- *
11
- * @since 6.0.12
12
- */
13
- var MonsterInsights = function(){
14
- /* MonsterInsights JS events tracking works on all major browsers, including IE starting at IE 7, via polyfills for any major JS function used that
15
- is not supported by at least 95% of the global and/or US browser marketshare. Currently, IE 7 & 8 which as of 2/14/17 have under 0.25% global marketshare, require
16
- us to polyfill Array.prototype.lastIndexOf, and if they continue to drop, we might remove this polyfill at some point. In that case note that events tracking
17
- for IE 7/8 will continue to work, with the exception of events tracking of downloads. */
18
- var lastClicked = [];
19
- var internalAsOutboundCategory = '';
20
-
21
- this.setLastClicked = function(valuesArray,fieldsArray,tracked){
22
- valuesArray = typeof valuesArray !== 'undefined' ? valuesArray : [];
23
- fieldsArray = typeof fieldsArray !== 'undefined' ? fieldsArray : [];
24
- tracked = typeof tracked !== 'undefined' ? tracked : false;
25
-
26
- lastClicked.valuesArray = valuesArray;
27
- lastClicked.fieldsArray = fieldsArray;
28
- };
29
-
30
- this.getLastClicked = function () {
31
- return lastClicked;
32
- };
33
-
34
- this.setInternalAsOutboundCategory = function( category ){
35
- internalAsOutboundCategory = category;
36
- };
37
-
38
- this.getInternalAsOutboundCategory = function () {
39
- return internalAsOutboundCategory;
40
- };
41
-
42
- this.sendEvent = function ( fieldsArray ) {
43
- __gaTrackerSend( [], fieldsArray );
44
- };
45
-
46
- function __gaTrackerIsDebug () {
47
- if ( window.monsterinsights_debug_mode ) {
48
- return true;
49
- } else {
50
- return false;
51
- }
52
- }
53
-
54
- function __gaTrackerSend ( valuesArray, fieldsArray ) {
55
- valuesArray = typeof valuesArray !== 'undefined' ? valuesArray : [];
56
- fieldsArray = typeof fieldsArray !== 'undefined' ? fieldsArray : {};
57
-
58
- __gaTracker( 'send', fieldsArray );
59
-
60
- lastClicked.valuesArray = valuesArray;
61
- lastClicked.fieldsArray = fieldsArray;
62
- lastClicked.tracked = true;
63
- __gaTrackerLog( 'Tracked: ' + valuesArray.type );
64
- __gaTrackerLog( lastClicked );
65
- }
66
-
67
- function __gaTrackerNotSend ( valuesArray ) {
68
- valuesArray = typeof valuesArray !== 'undefined' ? valuesArray : [];
69
-
70
- lastClicked.valuesArray = valuesArray;
71
- lastClicked.fieldsArray = [];
72
- lastClicked.tracked = false;
73
- __gaTrackerLog( 'Not Tracked: ' + valuesArray.exit );
74
- __gaTrackerLog( lastClicked );
75
- }
76
-
77
- function __gaTrackerLog ( message ) {
78
- if ( __gaTrackerIsDebug() ) {
79
- console.dir( message );
80
- }
81
- }
82
-
83
- function __gaTrackerStringTrim( x ) {
84
- return x.replace(/^\s+|\s+$/gm,'');
85
- }
86
-
87
- function __gaTrackerGetDomain() {
88
- var i=0,currentdomain=document.domain,p=currentdomain.split('.'),s='_gd'+(new Date()).getTime();
89
- while(i<(p.length-1) && document.cookie.indexOf(s+'='+s)==-1){
90
- currentdomain = p.slice(-1-(++i)).join('.');
91
- document.cookie = s+"="+s+";domain="+currentdomain+";";
92
- }
93
- document.cookie = s+"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain="+currentdomain+";";
94
- return currentdomain;
95
- }
96
-
97
- function __gaTrackerGetExtension( extension ) {
98
- extension = extension.toString();
99
- extension = extension.substring( 0, (extension.indexOf( "#" ) == -1 ) ? extension.length : extension.indexOf( "#" ) ); /* Remove the anchor at the end, if there is one */
100
- extension = extension.substring( 0, (extension.indexOf( "?" ) == -1 ) ? extension.length : extension.indexOf( "?" ) ); /* Remove the query after the file name, if there is one */
101
- extension = extension.substring( extension.lastIndexOf( "/" ) + 1, extension.length ); /* Remove everything before the last slash in the path */
102
- if ( extension.length > 0 && extension.indexOf('.') !== -1 ) { /* If there's a period left in the URL, then there's a extension. Else it is not a extension. */
103
- extension = extension.substring( extension.indexOf( "." ) + 1 ); /* Remove everything but what's after the first period */
104
- return extension;
105
- } else {
106
- return "";
107
- }
108
- }
109
-
110
- function __gaTrackerLoaded() {
111
- return typeof(__gaTracker) !== 'undefined' && __gaTracker && __gaTracker.hasOwnProperty( "loaded" ) && __gaTracker.loaded == true; /* jshint ignore:line */
112
- }
113
-
114
- function __gaTrackerTrackedClick( event ) {
115
- return event.which == 1 || event.which == 2 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
116
- }
117
-
118
- function __gaTrackerGetDownloadExtensions() {
119
- var download_extensions = [];
120
- if ( typeof monsterinsights_frontend.download_extensions == 'string' ) {
121
- download_extensions = monsterinsights_frontend.download_extensions.split(",");
122
- }
123
- return download_extensions;
124
- }
125
-
126
- function __gaTrackerGetInboundPaths() {
127
- var inbound_paths = [];
128
- if ( typeof monsterinsights_frontend.inbound_paths == 'string' ) {
129
- inbound_paths = JSON.parse( monsterinsights_frontend.inbound_paths );
130
- }
131
-
132
- return inbound_paths;
133
- }
134
-
135
- function __gaTrackerTrackedClickType( event ) {
136
- if ( event.which == 1 ) {
137
- return 'event.which=1';
138
- } else if ( event.which == 2 ) {
139
- return 'event.which=2';
140
- } else if ( event.metaKey ){
141
- return 'metaKey';
142
- } else if ( event.ctrlKey ) {
143
- return 'ctrlKey';
144
- } else if ( event.shiftKey ) {
145
- return 'shiftKey';
146
- } else if ( event.altKey ) {
147
- return 'altKey';
148
- } else {
149
- return '';
150
- }
151
- }
152
-
153
- function __gaTrackerLinkType( el ) {
154
- var download_extensions = __gaTrackerGetDownloadExtensions();
155
- var inbound_paths = __gaTrackerGetInboundPaths();
156
- var type = 'unknown';
157
- var link = el.href;
158
- var extension = __gaTrackerGetExtension( el.href );
159
- var currentdomain = __gaTrackerGetDomain();
160
- var hostname = el.hostname;
161
- var protocol = el.protocol;
162
- var pathname = el.pathname;
163
- link = link.toString();
164
- var index, len;
165
- var category = el.getAttribute("data-vars-ga-category");
166
-
167
- if ( category ) {
168
- return category;
169
- }
170
-
171
- if ( link.match( /^javascript\:/i ) ) {
172
- type = 'internal'; /* if it's a JS link, it's internal */
173
- } else if ( protocol && protocol.length > 0 && ( __gaTrackerStringTrim( protocol ) == 'tel' || __gaTrackerStringTrim( protocol ) == 'tel:' ) ) { /* If it's a telephone link */
174
- type = "tel";
175
- } else if ( protocol && protocol.length > 0 && ( __gaTrackerStringTrim( protocol ) == 'mailto' || __gaTrackerStringTrim( protocol ) == 'mailto:' ) ) { /* If it's a email */
176
- type = "mailto";
177
- } else if ( hostname && currentdomain && hostname.length > 0 && currentdomain.length > 0 && ! hostname.endsWith( '.' + currentdomain) && hostname !== currentdomain ) { /* If it's a outbound */
178
- type = "external";
179
- } else if ( pathname && JSON.stringify( inbound_paths ) != "{}" && pathname.length > 0 ) { /* If it's an internal as outbound */
180
- var inbound_paths_length = inbound_paths.length;
181
- for ( var inbound_paths_index = 0; inbound_paths_index < inbound_paths_length; inbound_paths_index ++ ) {
182
- if ( inbound_paths[ inbound_paths_index ].path && inbound_paths[ inbound_paths_index ].label && inbound_paths[ inbound_paths_index ].path.length > 0 && inbound_paths[ inbound_paths_index ].label.length > 0 && pathname.startsWith( inbound_paths[ inbound_paths_index ].path ) ) {
183
- type = "internal-as-outbound";
184
- internalAsOutboundCategory = "outbound-link-" + inbound_paths[ inbound_paths_index ].label;
185
- break;
186
- }
187
- }
188
- /* Enable window.monsterinsights_experimental_mode at your own risk. We might eventually remove it. Also you may/can/will burn through GA quota for your property quickly. */
189
- } else if ( hostname && window.monsterinsights_experimental_mode && hostname.length > 0 && document.domain.length > 0 && hostname !== document.domain ) { /* If it's a cross-hostname link */
190
- type = "cross-hostname";
191
- }
192
-
193
- if ( extension && ( type === 'unknown' || 'external' === type ) && download_extensions.length > 0 && extension.length > 0 ) { /* If it's a download */
194
- for ( index = 0, len = download_extensions.length; index < len; ++index ) {
195
- if ( download_extensions[ index ].length > 0 && ( link.endsWith( download_extensions[ index ] ) || download_extensions[ index ] == extension ) ) {
196
- type = "download";
197
- break;
198
- }
199
- }
200
- }
201
-
202
- if ( type === 'unknown' ) {
203
- type = 'internal';
204
- }
205
- return type;
206
- }
207
-
208
- function __gaTrackerLinkTarget( el, event ) {
209
-
210
- /* Is actual target set and not _(self|parent|top)? */
211
- var target = ( el.target && !el.target.match( /^_(self|parent|top)$/i ) ) ? el.target : false;
212
-
213
- /* Assume a target if Ctrl|shift|meta-click */
214
- if ( event.ctrlKey || event.shiftKey || event.metaKey || event.which == 2 ) {
215
- target = "_blank";
216
- }
217
- return target;
218
- }
219
-
220
- function __gaTrackerGetTitle( el ) {
221
- if ( el.getAttribute("data-vars-ga-label") && el.getAttribute("data-vars-ga-label").replace(/\n/ig, '') ) {
222
- return el.getAttribute("data-vars-ga-label").replace(/\n/ig, '');
223
- } else if ( el.title && el.title.replace(/\n/ig, '') ) {
224
- return el.title.replace(/\n/ig, '');
225
- } else if ( el.innerText && el.innerText.replace(/\n/ig, '') ) {
226
- return el.innerText.replace(/\n/ig, '');
227
- } else if ( el.getAttribute('aria-label') && el.getAttribute('aria-label').replace(/\n/ig, '') ) {
228
- return el.getAttribute('aria-label').replace(/\n/ig, '');
229
- } else if ( el.alt && el.alt.replace(/\n/ig, '') ) {
230
- return el.alt.replace(/\n/ig, '');
231
- } else if ( el.textContent && el.textContent.replace(/\n/ig, '') ) {
232
- return el.textContent.replace(/\n/ig, '');
233
- } else {
234
- return undefined;
235
- }
236
- }
237
-
238
- function __gaTrackerGetInnerTitle( el ) {
239
- var children = el.children;
240
- var count = 0;
241
- var child;
242
- var value;
243
- for (var i = 0; i < children.length; i++) {
244
- child = children[i];
245
- value = __gaTrackerGetTitle( child );
246
- if ( value ) {
247
- return value;
248
- }
249
- /* max search 100 elements to ensure performance */
250
- if ( count == 99 ) {
251
- return undefined;
252
- }
253
- count++;
254
- }
255
- return undefined;
256
- }
257
-
258
- function __gaTrackerClickEvent( event ) {
259
- var el = event.srcElement || event.target;
260
- var valuesArray = [];
261
- var fieldsArray;
262
-
263
- /* Start Values Array */
264
- valuesArray.el = el;
265
- valuesArray.ga_loaded = __gaTrackerLoaded();
266
- valuesArray.click_type = __gaTrackerTrackedClickType( event );
267
-
268
- /* If GA is blocked or not loaded, or not main|middle|touch click then don't track */
269
- if ( ! __gaTrackerLoaded() || ! __gaTrackerTrackedClick( event ) ) {
270
- valuesArray.exit = 'loaded';
271
- __gaTrackerNotSend( valuesArray );
272
- return;
273
- }
274
-
275
- /* Loop up the DOM tree through parent elements if clicked element is not a link (eg: an image inside a link) */
276
- while ( el && (typeof el.tagName == 'undefined' || el.tagName.toLowerCase() != 'a' || ! el.href ) ) {
277
- el = el.parentNode;
278
- }
279
-
280
- /* if a link with valid href has been clicked */
281
- if ( el && el.href && ! el.hasAttribute('xlink:href') ) {
282
- var link = el.href; /* What link are we tracking */
283
- var extension = __gaTrackerGetExtension( el.href ); /* What extension is this link */
284
- var download_extensions = __gaTrackerGetDownloadExtensions(); /* Let's get the extensions to track */
285
- var inbound_paths = __gaTrackerGetInboundPaths(); /* Let's get the internal paths to track */
286
- var home_url = monsterinsights_frontend.home_url; /* Let's get the url to compare for external/internal use */
287
- var currentdomain = __gaTrackerGetDomain(); /* What domain are we on? */
288
- var type = __gaTrackerLinkType( el ); /* What type of link is this? */
289
- var target = __gaTrackerLinkTarget( el, event ); /* Is a new tab/window being opened? */
290
- var action = el.getAttribute("data-vars-ga-action");
291
- var label = el.getAttribute("data-vars-ga-label");
292
-
293
- /* Element */
294
- valuesArray.el = el; /* el is an a element so we can parse it */
295
- valuesArray.el_href = el.href; /* "http://example.com:3000/pathname/?search=test#hash" */
296
- valuesArray.el_protocol = el.protocol; /* "http:" */
297
- valuesArray.el_hostname = el.hostname; /* "example.com" */
298
- valuesArray.el_port = el.port; /* "3000" */
299
- valuesArray.el_pathname = el.pathname; /* "/pathname/" */
300
- valuesArray.el_search = el.search; /* "?search=test" */
301
- valuesArray.el_hash = el.hash; /* "#hash" */
302
- valuesArray.el_host = el.host; /* "example.com:3000" */
303
-
304
- /* Settings */
305
- valuesArray.debug_mode = __gaTrackerIsDebug(); /* "example.com:3000" */
306
- valuesArray.download_extensions = download_extensions; /* Let's get the extensions to track */
307
- valuesArray.inbound_paths = inbound_paths; /* Let's get the internal paths to track */
308
- valuesArray.home_url = home_url; /* Let's get the url to compare for external/internal use */
309
-
310
- /* Parsed/Logic */
311
- valuesArray.link = link; /* What link are we tracking */
312
- valuesArray.extension = extension; /* What extension is this link */
313
- valuesArray.type = type; /* What type of link is this */
314
- valuesArray.target = target; /* Is a new tab/window being opened? */
315
- valuesArray.title = __gaTrackerGetTitle( el ); /* Try link title, then text content */
316
-
317
- /* only find innerTitle if we need one */
318
- if ( ! valuesArray.label && ! valuesArray.title ) {
319
- valuesArray.title = __gaTrackerGetInnerTitle( el );
320
- }
321
-
322
- /* Let's track everything but internals (that aren't internal-as-externals) and javascript */
323
- if ( type !== 'internal' && type !== 'javascript' ) {
324
-
325
- var __gaTrackerHitBackRun = false; /* Tracker has not yet run */
326
-
327
- /* HitCallback to open link in same window after tracker */
328
- var __gaTrackerHitBack = function() {
329
- /* Run the hitback only once */
330
- if ( __gaTrackerHitBackRun ){
331
- return;
332
- }
333
- __gaTrackerHitBackRun = true;
334
- window.location.href = link;
335
- };
336
-
337
- var __gaTrackerNoRedirectExternal = function() {
338
- valuesArray.exit = 'external';
339
- __gaTrackerNotSend( valuesArray );
340
- };
341
-
342
- var __gaTrackerNoRedirectInboundAsExternal = function() {
343
- valuesArray.exit = 'internal-as-outbound';
344
- __gaTrackerNotSend( valuesArray );
345
- };
346
- var __gaTrackerNoRedirectCrossHostname = function() {
347
- valuesArray.exit = 'cross-hostname';
348
- __gaTrackerNotSend( valuesArray );
349
- };
350
-
351
- if ( target || type == 'mailto' || type == 'tel' ) { /* If target opens a new window then just track */
352
- if ( type == 'download' ) {
353
- fieldsArray = {
354
- hitType : 'event',
355
- eventCategory : 'download',
356
- eventAction : action || link,
357
- eventLabel : label || valuesArray.title,
358
- };
359
-
360
- __gaTrackerSend( valuesArray, fieldsArray );
361
- } else if ( type == 'tel' ) {
362
- fieldsArray = {
363
- hitType : 'event',
364
- eventCategory : 'tel',
365
- eventAction : action || link,
366
- eventLabel : label || valuesArray.title.replace('tel:', ''),
367
- };
368
-
369
- __gaTrackerSend( valuesArray, fieldsArray );
370
- } else if ( type == 'mailto' ) {
371
- fieldsArray = {
372
- hitType : 'event',
373
- eventCategory : 'mailto',
374
- eventAction : action || link,
375
- eventLabel : label || valuesArray.title.replace('mailto:', ''),
376
- };
377
-
378
- __gaTrackerSend( valuesArray, fieldsArray );
379
- } else if ( type == 'internal-as-outbound' ) {
380
- fieldsArray = {
381
- hitType : 'event',
382
- eventCategory : internalAsOutboundCategory,
383
- eventAction : action || link,
384
- eventLabel : label || valuesArray.title,
385
- };
386
-
387
- __gaTrackerSend( valuesArray, fieldsArray );
388
- } else if ( type == 'external' ) {
389
- fieldsArray = {
390
- hitType: 'event',
391
- eventCategory:'outbound-link',
392
- eventAction: action || link,
393
- eventLabel: label || valuesArray.title,
394
- };
395
-
396
- __gaTrackerSend( valuesArray, fieldsArray );
397
- } else if ( type == 'cross-hostname' ) {
398
- fieldsArray = {
399
- hitType: 'event',
400
- eventCategory:'cross-hostname',
401
- eventAction: action || link,
402
- eventLabel: label || valuesArray.title,
403
- };
404
-
405
- __gaTrackerSend( valuesArray, fieldsArray );
406
- } else {
407
- if ( type && type != 'internal' ) {
408
- fieldsArray = {
409
- hitType: 'event',
410
- eventCategory: type,
411
- eventAction: action || link,
412
- eventLabel: label || valuesArray.title,
413
- };
414
-
415
- __gaTrackerSend( valuesArray, fieldsArray );
416
- } else {
417
- valuesArray.exit = 'type';
418
- __gaTrackerNotSend( valuesArray );
419
- }
420
- }
421
- } else {
422
- /* Prevent standard click, track then open */
423
- if ( type != 'cross-hostname' && type != 'external' && type != 'internal-as-outbound' ) {
424
- if (! event.defaultPrevented ) {
425
- if ( event.preventDefault ) {
426
- event.preventDefault();
427
- } else {
428
- event.returnValue = false;
429
- }
430
- }
431
- }
432
-
433
- if ( type == 'download' ) {
434
- fieldsArray = {
435
- hitType : 'event',
436
- eventCategory : 'download',
437
- eventAction : action || link,
438
- eventLabel : label || valuesArray.title,
439
- hitCallback : __gaTrackerHitBack,
440
- };
441
-
442
- __gaTrackerSend( valuesArray, fieldsArray );
443
- } else if ( type == 'internal-as-outbound' ) {
444
- window.onbeforeunload = function(e) {
445
- if (! event.defaultPrevented ) {
446
- if ( event.preventDefault ) {
447
- event.preventDefault();
448
- } else {
449
- event.returnValue = false;
450
- }
451
- }
452
-
453
- fieldsArray = {
454
- hitType : 'event',
455
- eventCategory : internalAsOutboundCategory,
456
- eventAction : action || link,
457
- eventLabel : label || valuesArray.title,
458
- hitCallback : __gaTrackerHitBack,
459
- };
460
-
461
- if ( navigator.sendBeacon ) {
462
- fieldsArray.transport = 'beacon';
463
- }
464
-
465
- __gaTrackerSend( valuesArray, fieldsArray );
466
- setTimeout( __gaTrackerHitBack, 1000 );
467
- };
468
- } else if ( type == 'external' ) {
469
- window.onbeforeunload = function(e) {
470
- if (! event.defaultPrevented ) {
471
- if ( event.preventDefault ) {
472
- event.preventDefault();
473
- } else {
474
- event.returnValue = false;
475
- }
476
- }
477
-
478
- fieldsArray = {
479
- hitType : 'event',
480
- eventCategory : 'outbound-link',
481
- eventAction : action || link,
482
- eventLabel : label || valuesArray.title,
483
- hitCallback : __gaTrackerHitBack,
484
- };
485
-
486
- if ( navigator.sendBeacon ) {
487
- fieldsArray.transport = 'beacon';
488
- }
489
-
490
- __gaTrackerSend( valuesArray, fieldsArray );
491
- setTimeout( __gaTrackerHitBack, 1000 );
492
- };
493
- } else if ( type == 'cross-hostname' ) {
494
- window.onbeforeunload = function(e) {
495
- if (! event.defaultPrevented ) {
496
- if ( event.preventDefault ) {
497
- event.preventDefault();
498
- } else {
499
- event.returnValue = false;
500
- }
501
- }
502
-
503
- fieldsArray = {
504
- hitType : 'event',
505
- eventCategory : 'cross-hostname',
506
- eventAction : action || link,
507
- eventLabel : label || valuesArray.title,
508
- hitCallback : __gaTrackerHitBack,
509
- };
510
-
511
- if ( navigator.sendBeacon ) {
512
- fieldsArray.transport = 'beacon';
513
- }
514
-
515
- __gaTrackerSend( valuesArray, fieldsArray );
516
- setTimeout( __gaTrackerHitBack, 1000 );
517
- };
518
- } else {
519
- if ( type && type !== 'internal' ) {
520
- fieldsArray = {
521
- hitType: 'event',
522
- eventCategory: type,
523
- eventAction: action || link,
524
- eventLabel: label || valuesArray.title,
525
- hitCallback : __gaTrackerHitBack,
526
- };
527
-
528
- __gaTrackerSend( valuesArray, fieldsArray );
529
- } else {
530
- valuesArray.exit = 'type';
531
- __gaTrackerNotSend( valuesArray );
532
- }
533
- }
534
-
535
- if ( type != 'external' && type != 'cross-hostname' && type != 'internal-as-outbound' ) {
536
- /* Run hitCallback again if GA takes longer than 1 second */
537
- setTimeout( __gaTrackerHitBack, 1000 );
538
- } else {
539
- if ( type == 'external' ) {
540
- setTimeout( __gaTrackerNoRedirectExternal, 1100 );
541
- } else if ( type == 'cross-hostname' ) {
542
- setTimeout( __gaTrackerNoRedirectCrossHostname, 1100 );
543
- } else {
544
- setTimeout( __gaTrackerNoRedirectInboundAsExternal, 1100 );
545
- }
546
- }
547
- }
548
- } else {
549
- valuesArray.exit = 'internal';
550
- __gaTrackerNotSend( valuesArray );
551
- }
552
- } else {
553
- valuesArray.exit = 'notlink';
554
- __gaTrackerNotSend( valuesArray );
555
- }
556
- }
557
- var prevHash = window.location.hash;
558
- function __gaTrackerHashChangeEvent() {
559
- /* Todo: Ready this section for JS unit testing */
560
- if ( monsterinsights_frontend.hash_tracking === "true" && prevHash != window.location.hash ) {
561
- prevHash = window.location.hash;
562
- __gaTracker('set', 'page', location.pathname + location.search + location.hash );
563
- __gaTracker('send', 'pageview' );
564
- __gaTrackerLog( "Hash change to: " + location.pathname + location.search + location.hash );
565
- } else {
566
- __gaTrackerLog( "Hash change to (untracked): " + location.pathname + location.search + location.hash );
567
- }
568
- }
569
-
570
- /* Attach the event to all clicks in the document after page has loaded */
571
- var __gaTrackerWindow = window;
572
- if ( __gaTrackerWindow.addEventListener ) {
573
- __gaTrackerWindow.addEventListener(
574
- "load",
575
- function() {
576
- document.body.addEventListener(
577
- "click",
578
- __gaTrackerClickEvent,
579
- false
580
- );
581
- },
582
- false
583
- );
584
- window.addEventListener("hashchange", __gaTrackerHashChangeEvent, false );
585
- } else {
586
- if ( __gaTrackerWindow.attachEvent ) {
587
- __gaTrackerWindow.attachEvent(
588
- "onload",
589
- function() {
590
- document.body.attachEvent( "onclick", __gaTrackerClickEvent);
591
- }
592
- );
593
- window.attachEvent( "onhashchange", __gaTrackerHashChangeEvent);
594
- }
595
- }
596
-
597
- if (typeof String.prototype.endsWith !== 'function') {
598
- String.prototype.endsWith = function(suffix) {
599
- return this.indexOf(suffix, this.length - suffix.length) !== -1;
600
- };
601
- }
602
- if (typeof String.prototype.startsWith !== 'function') {
603
- String.prototype.startsWith = function(prefix) {
604
- return this.indexOf(prefix) === 0;
605
- };
606
- }
607
-
608
- if ( typeof Array.prototype.lastIndexOf !== 'function' ) {
609
- Array.prototype.lastIndexOf = function(searchElement /*, fromIndex*/) {
610
- 'use strict';
611
-
612
- if (this === void 0 || this === null) {
613
- throw new TypeError();
614
- }
615
-
616
- var n, k,
617
- t = Object(this),
618
- len = t.length >>> 0; /* jshint ignore:line */
619
- if (len === 0) {
620
- return -1;
621
- }
622
-
623
- n = len - 1;
624
- if (arguments.length > 1) {
625
- n = Number(arguments[1]);
626
- if (n != n) {
627
- n = 0;
628
- }
629
- else if (n != 0 && n != (1 / 0) && n != -(1 / 0)) { /* jshint ignore:line */
630
- n = (n > 0 || -1) * Math.floor(Math.abs(n));
631
- }
632
- }
633
-
634
- for (k = n >= 0 ? Math.min(n, len - 1) : len - Math.abs(n); k >= 0; k--) {
635
- if (k in t && t[k] === searchElement) {
636
- return k;
637
- }
638
- }
639
- return -1;
640
- };
641
- }
642
- };
643
- var MonsterInsightsObject = new MonsterInsights();
1
+ /**
2
+ * Developer's Notice:
3
+ *
4
+ * Note: JS in this file (and this file itself) is not garunteed backwards compatibility. JS can be added, changed or removed at any time without notice.
5
+ * For more information see the `Backwards Compatibility Guidelines for Developers` section of the README.md file.
6
+ */
7
+ /**
8
+ * Handles:
9
+ * - JS Events handling
10
+ *
11
+ * @since 6.0.12
12
+ */
13
+ var MonsterInsights = function(){
14
+ /* MonsterInsights JS events tracking works on all major browsers, including IE starting at IE 7, via polyfills for any major JS function used that
15
+ is not supported by at least 95% of the global and/or US browser marketshare. Currently, IE 7 & 8 which as of 2/14/17 have under 0.25% global marketshare, require
16
+ us to polyfill Array.prototype.lastIndexOf, and if they continue to drop, we might remove this polyfill at some point. In that case note that events tracking
17
+ for IE 7/8 will continue to work, with the exception of events tracking of downloads. */
18
+ var lastClicked = [];
19
+ var internalAsOutboundCategory = '';
20
+
21
+ this.setLastClicked = function(valuesArray,fieldsArray,tracked){
22
+ valuesArray = typeof valuesArray !== 'undefined' ? valuesArray : [];
23
+ fieldsArray = typeof fieldsArray !== 'undefined' ? fieldsArray : [];
24
+ tracked = typeof tracked !== 'undefined' ? tracked : false;
25
+
26
+ lastClicked.valuesArray = valuesArray;
27
+ lastClicked.fieldsArray = fieldsArray;
28
+ };
29
+
30
+ this.getLastClicked = function () {
31
+ return lastClicked;
32
+ };
33
+
34
+ this.setInternalAsOutboundCategory = function( category ){
35
+ internalAsOutboundCategory = category;
36
+ };
37
+
38
+ this.getInternalAsOutboundCategory = function () {
39
+ return internalAsOutboundCategory;
40
+ };
41
+
42
+ this.sendEvent = function ( fieldsArray ) {
43
+ __gaTrackerSend( [], fieldsArray );
44
+ };
45
+
46
+ function __gaTrackerIsDebug () {
47
+ if ( window.monsterinsights_debug_mode ) {
48
+ return true;
49
+ } else {
50
+ return false;
51
+ }
52
+ }
53
+
54
+ function __gaTrackerSend ( valuesArray, fieldsArray ) {
55
+ valuesArray = typeof valuesArray !== 'undefined' ? valuesArray : [];
56
+ fieldsArray = typeof fieldsArray !== 'undefined' ? fieldsArray : {};
57
+
58
+ __gaTracker( 'send', fieldsArray );
59
+
60
+ lastClicked.valuesArray = valuesArray;
61
+ lastClicked.fieldsArray = fieldsArray;
62
+ lastClicked.tracked = true;
63
+ __gaTrackerLog( 'Tracked: ' + valuesArray.type );
64
+ __gaTrackerLog( lastClicked );
65
+ }
66
+
67
+ function __gaTrackerNotSend ( valuesArray ) {
68
+ valuesArray = typeof valuesArray !== 'undefined' ? valuesArray : [];
69
+
70
+ lastClicked.valuesArray = valuesArray;
71
+ lastClicked.fieldsArray = [];
72
+ lastClicked.tracked = false;
73
+ __gaTrackerLog( 'Not Tracked: ' + valuesArray.exit );
74
+ __gaTrackerLog( lastClicked );
75
+ }
76
+
77
+ function __gaTrackerLog ( message ) {
78
+ if ( __gaTrackerIsDebug() ) {
79
+ console.dir( message );
80
+ }
81
+ }
82
+
83
+ function __gaTrackerStringTrim( x ) {
84
+ return x.replace(/^\s+|\s+$/gm,'');
85
+ }
86
+
87
+ function __gaTrackerGetDomain() {
88
+ var i=0,currentdomain=document.domain,p=currentdomain.split('.'),s='_gd'+(new Date()).getTime();
89
+ while(i<(p.length-1) && document.cookie.indexOf(s+'='+s)==-1){
90
+ currentdomain = p.slice(-1-(++i)).join('.');
91
+ document.cookie = s+"="+s+";domain="+currentdomain+";";
92
+ }
93
+ document.cookie = s+"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain="+currentdomain+";";
94
+ return currentdomain;
95
+ }
96
+
97
+ function __gaTrackerGetExtension( extension ) {
98
+ extension = extension.toString();
99
+ extension = extension.substring( 0, (extension.indexOf( "#" ) == -1 ) ? extension.length : extension.indexOf( "#" ) ); /* Remove the anchor at the end, if there is one */
100
+ extension = extension.substring( 0, (extension.indexOf( "?" ) == -1 ) ? extension.length : extension.indexOf( "?" ) ); /* Remove the query after the file name, if there is one */
101
+ extension = extension.substring( extension.lastIndexOf( "/" ) + 1, extension.length ); /* Remove everything before the last slash in the path */
102
+ if ( extension.length > 0 && extension.indexOf('.') !== -1 ) { /* If there's a period left in the URL, then there's a extension. Else it is not a extension. */
103
+ extension = extension.substring( extension.indexOf( "." ) + 1 ); /* Remove everything but what's after the first period */
104
+ return extension;
105
+ } else {
106
+ return "";
107
+ }
108
+ }
109
+
110
+ function __gaTrackerLoaded() {
111
+ return typeof(__gaTracker) !== 'undefined' && __gaTracker && __gaTracker.hasOwnProperty( "loaded" ) && __gaTracker.loaded == true; /* jshint ignore:line */
112
+ }
113
+
114
+ function __gaTrackerTrackedClick( event ) {
115
+ return event.which == 1 || event.which == 2 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
116
+ }
117
+
118
+ function __gaTrackerGetDownloadExtensions() {
119
+ var download_extensions = [];
120
+ if ( typeof monsterinsights_frontend.download_extensions == 'string' ) {
121
+ download_extensions = monsterinsights_frontend.download_extensions.split(",");
122
+ }
123
+ return download_extensions;
124
+ }
125
+
126
+ function __gaTrackerGetInboundPaths() {
127
+ var inbound_paths = [];
128
+ if ( typeof monsterinsights_frontend.inbound_paths == 'string' ) {
129
+ inbound_paths = JSON.parse( monsterinsights_frontend.inbound_paths );
130
+ }
131
+
132
+ return inbound_paths;
133
+ }
134
+
135
+ function __gaTrackerTrackedClickType( event ) {
136
+ if ( event.which == 1 ) {
137
+ return 'event.which=1';
138
+ } else if ( event.which == 2 ) {
139
+ return 'event.which=2';
140
+ } else if ( event.metaKey ){
141
+ return 'metaKey';
142
+ } else if ( event.ctrlKey ) {
143
+ return 'ctrlKey';
144
+ } else if ( event.shiftKey ) {
145
+ return 'shiftKey';
146
+ } else if ( event.altKey ) {
147
+ return 'altKey';
148
+ } else {
149
+ return '';
150
+ }
151
+ }
152
+
153
+ function __gaTrackerLinkType( el ) {
154
+ var download_extensions = __gaTrackerGetDownloadExtensions();
155
+ var inbound_paths = __gaTrackerGetInboundPaths();
156
+ var type = 'unknown';
157
+ var link = el.href;
158
+ var extension = __gaTrackerGetExtension( el.href );
159
+ var currentdomain = __gaTrackerGetDomain();
160
+ var hostname = el.hostname;
161
+ var protocol = el.protocol;
162
+ var pathname = el.pathname;
163
+ link = link.toString();
164
+ var index, len;
165
+ var category = el.getAttribute("data-vars-ga-category");
166
+
167
+ if ( category ) {
168
+ return category;
169
+ }
170
+
171
+ if ( link.match( /^javascript\:/i ) ) {
172
+ type = 'internal'; /* if it's a JS link, it's internal */
173
+ } else if ( protocol && protocol.length > 0 && ( __gaTrackerStringTrim( protocol ) == 'tel' || __gaTrackerStringTrim( protocol ) == 'tel:' ) ) { /* If it's a telephone link */
174
+ type = "tel";
175
+ } else if ( protocol && protocol.length > 0 && ( __gaTrackerStringTrim( protocol ) == 'mailto' || __gaTrackerStringTrim( protocol ) == 'mailto:' ) ) { /* If it's a email */
176
+ type = "mailto";
177
+ } else if ( hostname && currentdomain && hostname.length > 0 && currentdomain.length > 0 && ! hostname.endsWith( '.' + currentdomain) && hostname !== currentdomain ) { /* If it's a outbound */
178
+ type = "external";
179
+ } else if ( pathname && JSON.stringify( inbound_paths ) != "{}" && pathname.length > 0 ) { /* If it's an internal as outbound */
180
+ var inbound_paths_length = inbound_paths.length;
181
+ for ( var inbound_paths_index = 0; inbound_paths_index < inbound_paths_length; inbound_paths_index ++ ) {
182
+ if ( inbound_paths[ inbound_paths_index ].path && inbound_paths[ inbound_paths_index ].label && inbound_paths[ inbound_paths_index ].path.length > 0 && inbound_paths[ inbound_paths_index ].label.length > 0 && pathname.startsWith( inbound_paths[ inbound_paths_index ].path ) ) {
183
+ type = "internal-as-outbound";
184
+ internalAsOutboundCategory = "outbound-link-" + inbound_paths[ inbound_paths_index ].label;
185
+ break;
186
+ }
187
+ }
188
+ /* Enable window.monsterinsights_experimental_mode at your own risk. We might eventually remove it. Also you may/can/will burn through GA quota for your property quickly. */
189
+ } else if ( hostname && window.monsterinsights_experimental_mode && hostname.length > 0 && document.domain.length > 0 && hostname !== document.domain ) { /* If it's a cross-hostname link */
190
+ type = "cross-hostname";
191
+ }
192
+
193
+ if ( extension && ( type === 'unknown' || 'external' === type ) && download_extensions.length > 0 && extension.length > 0 ) { /* If it's a download */
194
+ for ( index = 0, len = download_extensions.length; index < len; ++index ) {
195
+ if ( download_extensions[ index ].length > 0 && ( link.endsWith( download_extensions[ index ] ) || download_extensions[ index ] == extension ) ) {
196
+ type = "download";
197
+ break;
198
+ }
199
+ }
200
+ }
201
+
202
+ if ( type === 'unknown' ) {
203
+ type = 'internal';
204
+ }
205
+ return type;
206
+ }
207
+
208
+ function __gaTrackerLinkTarget( el, event ) {
209
+
210
+ /* Is actual target set and not _(self|parent|top)? */
211
+ var target = ( el.target && !el.target.match( /^_(self|parent|top)$/i ) ) ? el.target : false;
212
+
213
+ /* Assume a target if Ctrl|shift|meta-click */
214
+ if ( event.ctrlKey || event.shiftKey || event.metaKey || event.which == 2 ) {
215
+ target = "_blank";
216
+ }
217
+ return target;
218
+ }
219
+
220
+ function __gaTrackerGetTitle( el ) {
221
+ if ( el.getAttribute("data-vars-ga-label") && el.getAttribute("data-vars-ga-label").replace(/\n/ig, '') ) {
222
+ return el.getAttribute("data-vars-ga-label").replace(/\n/ig, '');
223
+ } else if ( el.title && el.title.replace(/\n/ig, '') ) {
224
+ return el.title.replace(/\n/ig, '');
225
+ } else if ( el.innerText && el.innerText.replace(/\n/ig, '') ) {
226
+ return el.innerText.replace(/\n/ig, '');
227
+ } else if ( el.getAttribute('aria-label') && el.getAttribute('aria-label').replace(/\n/ig, '') ) {
228
+ return el.getAttribute('aria-label').replace(/\n/ig, '');
229
+ } else if ( el.alt && el.alt.replace(/\n/ig, '') ) {
230
+ return el.alt.replace(/\n/ig, '');
231
+ } else if ( el.textContent && el.textContent.replace(/\n/ig, '') ) {
232
+ return el.textContent.replace(/\n/ig, '');
233
+ } else {
234
+ return undefined;
235
+ }
236
+ }
237
+
238
+ function __gaTrackerGetInnerTitle( el ) {
239
+ var children = el.children;
240
+ var count = 0;
241
+ var child;
242
+ var value;
243
+ for (var i = 0; i < children.length; i++) {
244
+ child = children[i];
245
+ value = __gaTrackerGetTitle( child );
246
+ if ( value ) {
247
+ return value;
248
+ }
249
+ /* max search 100 elements to ensure performance */
250
+ if ( count == 99 ) {
251
+ return undefined;
252
+ }
253
+ count++;
254
+ }
255
+ return undefined;
256
+ }
257
+
258
+ function __gaTrackerClickEvent( event ) {
259
+ var el = event.srcElement || event.target;
260
+ var valuesArray = [];
261
+ var fieldsArray;
262
+
263
+ /* Start Values Array */
264
+ valuesArray.el = el;
265
+ valuesArray.ga_loaded = __gaTrackerLoaded();
266
+ valuesArray.click_type = __gaTrackerTrackedClickType( event );
267
+
268
+ /* If GA is blocked or not loaded, or not main|middle|touch click then don't track */
269
+ if ( ! __gaTrackerLoaded() || ! __gaTrackerTrackedClick( event ) ) {
270
+ valuesArray.exit = 'loaded';
271
+ __gaTrackerNotSend( valuesArray );
272
+ return;
273
+ }
274
+
275
+ /* Loop up the DOM tree through parent elements if clicked element is not a link (eg: an image inside a link) */
276
+ while ( el && (typeof el.tagName == 'undefined' || el.tagName.toLowerCase() != 'a' || ! el.href ) ) {
277
+ el = el.parentNode;
278
+ }
279
+
280
+ /* if a link with valid href has been clicked */
281
+ if ( el && el.href && ! el.hasAttribute('xlink:href') ) {
282
+ var link = el.href; /* What link are we tracking */
283
+ var extension = __gaTrackerGetExtension( el.href ); /* What extension is this link */
284
+ var download_extensions = __gaTrackerGetDownloadExtensions(); /* Let's get the extensions to track */
285
+ var inbound_paths = __gaTrackerGetInboundPaths(); /* Let's get the internal paths to track */
286
+ var home_url = monsterinsights_frontend.home_url; /* Let's get the url to compare for external/internal use */
287
+ var currentdomain = __gaTrackerGetDomain(); /* What domain are we on? */
288
+ var type = __gaTrackerLinkType( el ); /* What type of link is this? */
289
+ var target = __gaTrackerLinkTarget( el, event ); /* Is a new tab/window being opened? */
290
+ var action = el.getAttribute("data-vars-ga-action");
291
+ var label = el.getAttribute("data-vars-ga-label");
292
+
293
+ /* Element */
294
+ valuesArray.el = el; /* el is an a element so we can parse it */
295
+ valuesArray.el_href = el.href; /* "http://example.com:3000/pathname/?search=test#hash" */
296
+ valuesArray.el_protocol = el.protocol; /* "http:" */
297
+ valuesArray.el_hostname = el.hostname; /* "example.com" */
298
+ valuesArray.el_port = el.port; /* "3000" */
299
+ valuesArray.el_pathname = el.pathname; /* "/pathname/" */
300
+ valuesArray.el_search = el.search; /* "?search=test" */
301
+ valuesArray.el_hash = el.hash; /* "#hash" */
302
+ valuesArray.el_host = el.host; /* "example.com:3000" */
303
+
304
+ /* Settings */
305
+ valuesArray.debug_mode = __gaTrackerIsDebug(); /* "example.com:3000" */
306
+ valuesArray.download_extensions = download_extensions; /* Let's get the extensions to track */
307
+ valuesArray.inbound_paths = inbound_paths; /* Let's get the internal paths to track */
308
+ valuesArray.home_url = home_url; /* Let's get the url to compare for external/internal use */
309
+
310
+ /* Parsed/Logic */
311
+ valuesArray.link = link; /* What link are we tracking */
312
+ valuesArray.extension = extension; /* What extension is this link */
313
+ valuesArray.type = type; /* What type of link is this */
314
+ valuesArray.target = target; /* Is a new tab/window being opened? */
315
+ valuesArray.title = __gaTrackerGetTitle( el ); /* Try link title, then text content */
316
+
317
+ /* only find innerTitle if we need one */
318
+ if ( ! valuesArray.label && ! valuesArray.title ) {
319
+ valuesArray.title = __gaTrackerGetInnerTitle( el );
320
+ }
321
+
322
+ /* Let's track everything but internals (that aren't internal-as-externals) and javascript */
323
+ if ( type !== 'internal' && type !== 'javascript' ) {
324
+
325
+ var __gaTrackerHitBackRun = false; /* Tracker has not yet run */
326
+
327
+ /* HitCallback to open link in same window after tracker */
328
+ var __gaTrackerHitBack = function() {
329
+ /* Run the hitback only once */
330
+ if ( __gaTrackerHitBackRun ){
331
+ return;
332
+ }
333
+ __gaTrackerHitBackRun = true;
334
+ window.location.href = link;
335
+ };
336
+
337
+ var __gaTrackerNoRedirectExternal = function() {
338
+ valuesArray.exit = 'external';
339
+ __gaTrackerNotSend( valuesArray );
340
+ };
341
+
342
+ var __gaTrackerNoRedirectInboundAsExternal = function() {
343
+ valuesArray.exit = 'internal-as-outbound';
344
+ __gaTrackerNotSend( valuesArray );
345
+ };
346
+ var __gaTrackerNoRedirectCrossHostname = function() {
347
+ valuesArray.exit = 'cross-hostname';
348
+ __gaTrackerNotSend( valuesArray );
349
+ };
350
+
351
+ if ( target || type == 'mailto' || type == 'tel' ) { /* If target opens a new window then just track */
352
+ if ( type == 'download' ) {
353
+ fieldsArray = {
354
+ hitType : 'event',
355
+ eventCategory : 'download',
356
+ eventAction : action || link,
357
+ eventLabel : label || valuesArray.title,
358
+ };
359
+
360
+ __gaTrackerSend( valuesArray, fieldsArray );
361
+ } else if ( type == 'tel' ) {
362
+ fieldsArray = {
363
+ hitType : 'event',
364
+ eventCategory : 'tel',
365
+ eventAction : action || link,
366
+ eventLabel : label || valuesArray.title.replace('tel:', ''),
367
+ };
368
+
369
+ __gaTrackerSend( valuesArray, fieldsArray );
370
+ } else if ( type == 'mailto' ) {
371
+ fieldsArray = {
372
+ hitType : 'event',
373
+ eventCategory : 'mailto',
374
+ eventAction : action || link,
375
+ eventLabel : label || valuesArray.title.replace('mailto:', ''),
376
+ };
377
+
378
+ __gaTrackerSend( valuesArray, fieldsArray );
379
+ } else if ( type == 'internal-as-outbound' ) {
380
+ fieldsArray = {
381
+ hitType : 'event',
382
+ eventCategory : internalAsOutboundCategory,
383
+ eventAction : action || link,
384
+ eventLabel : label || valuesArray.title,
385
+ };
386
+
387
+ __gaTrackerSend( valuesArray, fieldsArray );
388
+ } else if ( type == 'external' ) {
389
+ fieldsArray = {
390
+ hitType: 'event',
391
+ eventCategory:'outbound-link',
392
+ eventAction: action || link,
393
+ eventLabel: label || valuesArray.title,
394
+ };
395
+
396
+ __gaTrackerSend( valuesArray, fieldsArray );
397
+ } else if ( type == 'cross-hostname' ) {
398
+ fieldsArray = {
399
+ hitType: 'event',
400
+ eventCategory:'cross-hostname',
401
+ eventAction: action || link,
402
+ eventLabel: label || valuesArray.title,
403
+ };
404
+
405
+ __gaTrackerSend( valuesArray, fieldsArray );
406
+ } else {
407
+ if ( type && type != 'internal' ) {
408
+ fieldsArray = {
409
+ hitType: 'event',
410
+ eventCategory: type,
411
+ eventAction: action || link,
412
+ eventLabel: label || valuesArray.title,
413
+ };
414
+
415
+ __gaTrackerSend( valuesArray, fieldsArray );
416
+ } else {
417
+ valuesArray.exit = 'type';
418
+ __gaTrackerNotSend( valuesArray );
419
+ }
420
+ }
421
+ } else {
422
+ /* Prevent standard click, track then open */
423
+ if ( type != 'cross-hostname' && type != 'external' && type != 'internal-as-outbound' ) {
424
+ if (! event.defaultPrevented ) {
425
+ if ( event.preventDefault ) {
426
+ event.preventDefault();
427
+ } else {
428
+ event.returnValue = false;
429
+ }
430
+ }
431
+ }
432
+
433
+ if ( type == 'download' ) {
434
+ fieldsArray = {
435
+ hitType : 'event',
436
+ eventCategory : 'download',
437
+ eventAction : action || link,
438
+ eventLabel : label || valuesArray.title,
439
+ hitCallback : __gaTrackerHitBack,
440
+ };
441
+
442
+ __gaTrackerSend( valuesArray, fieldsArray );
443
+ } else if ( type == 'internal-as-outbound' ) {
444
+ window.onbeforeunload = function(e) {
445
+ if (! event.defaultPrevented ) {
446
+ if ( event.preventDefault ) {
447
+ event.preventDefault();
448
+ } else {
449
+ event.returnValue = false;
450
+ }
451
+ }
452
+
453
+ fieldsArray = {
454
+ hitType : 'event',
455
+ eventCategory : internalAsOutboundCategory,
456
+ eventAction : action || link,
457
+ eventLabel : label || valuesArray.title,
458
+ hitCallback : __gaTrackerHitBack,
459
+ };
460
+
461
+ if ( navigator.sendBeacon ) {
462
+ fieldsArray.transport = 'beacon';
463
+ }
464
+
465
+ __gaTrackerSend( valuesArray, fieldsArray );
466
+ setTimeout( __gaTrackerHitBack, 1000 );
467
+ };
468
+ } else if ( type == 'external' ) {
469
+ window.onbeforeunload = function(e) {
470
+ if (! event.defaultPrevented ) {
471
+ if ( event.preventDefault ) {
472
+ event.preventDefault();
473
+ } else {
474
+ event.returnValue = false;
475
+ }
476
+ }
477
+
478
+ fieldsArray = {
479
+ hitType : 'event',
480
+ eventCategory : 'outbound-link',
481
+ eventAction : action || link,
482
+ eventLabel : label || valuesArray.title,
483
+ hitCallback : __gaTrackerHitBack,
484
+ };
485
+
486
+ if ( navigator.sendBeacon ) {
487
+ fieldsArray.transport = 'beacon';
488
+ }
489
+
490
+ __gaTrackerSend( valuesArray, fieldsArray );
491
+ setTimeout( __gaTrackerHitBack, 1000 );
492
+ };
493
+ } else if ( type == 'cross-hostname' ) {
494
+ window.onbeforeunload = function(e) {
495
+ if (! event.defaultPrevented ) {
496
+ if ( event.preventDefault ) {
497
+ event.preventDefault();
498
+ } else {
499
+ event.returnValue = false;
500
+ }
501
+ }
502
+
503
+ fieldsArray = {
504
+ hitType : 'event',
505
+ eventCategory : 'cross-hostname',
506
+ eventAction : action || link,
507
+ eventLabel : label || valuesArray.title,
508
+ hitCallback : __gaTrackerHitBack,
509
+ };
510
+
511
+ if ( navigator.sendBeacon ) {
512
+ fieldsArray.transport = 'beacon';
513
+ }
514
+
515
+ __gaTrackerSend( valuesArray, fieldsArray );
516
+ setTimeout( __gaTrackerHitBack, 1000 );
517
+ };
518
+ } else {
519
+ if ( type && type !== 'internal' ) {
520
+ fieldsArray = {
521
+ hitType: 'event',
522
+ eventCategory: type,
523
+ eventAction: action || link,
524
+ eventLabel: label || valuesArray.title,
525
+ hitCallback : __gaTrackerHitBack,
526
+ };
527
+
528
+ __gaTrackerSend( valuesArray, fieldsArray );
529
+ } else {
530
+ valuesArray.exit = 'type';
531
+ __gaTrackerNotSend( valuesArray );
532
+ }
533
+ }
534
+
535
+ if ( type != 'external' && type != 'cross-hostname' && type != 'internal-as-outbound' ) {
536
+ /* Run hitCallback again if GA takes longer than 1 second */
537
+ setTimeout( __gaTrackerHitBack, 1000 );
538
+ } else {
539
+ if ( type == 'external' ) {
540
+ setTimeout( __gaTrackerNoRedirectExternal, 1100 );
541
+ } else if ( type == 'cross-hostname' ) {
542
+ setTimeout( __gaTrackerNoRedirectCrossHostname, 1100 );
543
+ } else {
544
+ setTimeout( __gaTrackerNoRedirectInboundAsExternal, 1100 );
545
+ }
546
+ }
547
+ }
548
+ } else {
549
+ valuesArray.exit = 'internal';
550
+ __gaTrackerNotSend( valuesArray );
551
+ }
552
+ } else {
553
+ valuesArray.exit = 'notlink';
554
+ __gaTrackerNotSend( valuesArray );
555
+ }
556
+ }
557
+ var prevHash = window.location.hash;
558
+ function __gaTrackerHashChangeEvent() {
559
+ /* Todo: Ready this section for JS unit testing */
560
+ if ( monsterinsights_frontend.hash_tracking === "true" && prevHash != window.location.hash ) {
561
+ prevHash = window.location.hash;
562
+ __gaTracker('set', 'page', location.pathname + location.search + location.hash );
563
+ __gaTracker('send', 'pageview' );
564
+ __gaTrackerLog( "Hash change to: " + location.pathname + location.search + location.hash );
565
+ } else {
566
+ __gaTrackerLog( "Hash change to (untracked): " + location.pathname + location.search + location.hash );
567
+ }
568
+ }
569
+
570
+ /* Attach the event to all clicks in the document after page has loaded */
571
+ var __gaTrackerWindow = window;
572
+ if ( __gaTrackerWindow.addEventListener ) {
573
+ __gaTrackerWindow.addEventListener(
574
+ "load",
575
+ function() {
576
+ document.body.addEventListener(
577
+ "click",
578
+ __gaTrackerClickEvent,
579
+ false
580
+ );
581
+ },
582
+ false
583
+ );
584
+ window.addEventListener("hashchange", __gaTrackerHashChangeEvent, false );
585
+ } else {
586
+ if ( __gaTrackerWindow.attachEvent ) {
587
+ __gaTrackerWindow.attachEvent(
588
+ "onload",
589
+ function() {
590
+ document.body.attachEvent( "onclick", __gaTrackerClickEvent);
591
+ }
592
+ );
593
+ window.attachEvent( "onhashchange", __gaTrackerHashChangeEvent);
594
+ }
595
+ }
596
+
597
+ if (typeof String.prototype.endsWith !== 'function') {
598
+ String.prototype.endsWith = function(suffix) {
599
+ return this.indexOf(suffix, this.length - suffix.length) !== -1;
600
+ };
601
+ }
602
+ if (typeof String.prototype.startsWith !== 'function') {
603
+ String.prototype.startsWith = function(prefix) {
604
+ return this.indexOf(prefix) === 0;
605
+ };
606
+ }
607
+
608
+ if ( typeof Array.prototype.lastIndexOf !== 'function' ) {
609
+ Array.prototype.lastIndexOf = function(searchElement /*, fromIndex*/) {
610
+ 'use strict';
611
+
612
+ if (this === void 0 || this === null) {
613
+ throw new TypeError();
614
+ }
615
+
616
+ var n, k,
617
+ t = Object(this),
618
+ len = t.length >>> 0; /* jshint ignore:line */
619
+ if (len === 0) {
620
+ return -1;
621
+ }
622
+
623
+ n = len - 1;
624
+ if (arguments.length > 1) {
625
+ n = Number(arguments[1]);
626
+ if (n != n) {
627
+ n = 0;
628
+ }
629
+ else if (n != 0 && n != (1 / 0) && n != -(1 / 0)) { /* jshint ignore:line */
630
+ n = (n > 0 || -1) * Math.floor(Math.abs(n));
631
+ }
632
+ }
633
+
634
+ for (k = n >= 0 ? Math.min(n, len - 1) : len - Math.abs(n); k >= 0; k--) {
635
+ if (k in t && t[k] === searchElement) {
636
+ return k;
637
+ }
638
+ }
639
+ return -1;
640
+ };
641
+ }
642
+ };
643
+ var MonsterInsightsObject = new MonsterInsights();
assets/js/index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- //Nothing to see here
3
-
4
  header( 'HTTP/1.0 403 Forbidden' );
1
+ <?php
2
+ //Nothing to see here
3
+
4
  header( 'HTTP/1.0 403 Forbidden' );
assets/lib/index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- //Nothing to see here
3
-
4
  header( 'HTTP/1.0 403 Forbidden' );
1
+ <?php
2
+ //Nothing to see here
3
+
4
  header( 'HTTP/1.0 403 Forbidden' );
assets/lib/pandora/class-am-deactivation-survey.php CHANGED
@@ -1,343 +1,358 @@
1
- <?php
2
- if ( ! class_exists( 'AM_Deactivation_Survey' ) ) {
3
- /**
4
- * Awesome Motive Deactivation Survey.
5
- *
6
- * This prompts the user for more details when they deactivate the plugin.
7
- *
8
- * @version 1.2.1
9
- * @package AwesomeMotive
10
- * @author Jared Atchison and Chris Christoff
11
- * @license GPL-2.0+
12
- * @copyright Copyright (c) 2018
13
- */
14
- class AM_Deactivation_Survey {
15
-
16
- /**
17
- * The API URL we are calling.
18
- *
19
- * @since 1.0.0
20
- * @var string
21
- */
22
- public $api_url = 'https://api.awesomemotive.com/v1/deactivation-survey/';
23
-
24
- /**
25
- * Name for this plugin.
26
- *
27
- * @since 1.0.0
28
- * @var string
29
- */
30
- public $name;
31
-
32
- /**
33
- * Unique slug for this plugin.
34
- *
35
- * @since 1.0.0
36
- * @var string
37
- */
38
- public $plugin;
39
-
40
- /**
41
- * Primary class constructor.
42
- *
43
- * @since 1.0.0
44
- * @param string $name Plugin name.
45
- * @param string $plugin Plugin slug.
46
- */
47
- public function __construct( $name = '', $plugin = '' ) {
48
-
49
- $this->name = $name;
50
- $this->plugin = $plugin;
51
-
52
- // Don't run deactivation survey on dev sites.
53
- if ( $this->is_dev_url() ) {
54
- return;
55
- }
56
-
57
- add_action( 'admin_print_scripts', array( $this, 'js' ), 20 );
58
- add_action( 'admin_print_scripts', array( $this, 'css' ) );
59
- add_action( 'admin_footer', array( $this, 'modal' ) );
60
- }
61
-
62
- /**
63
- * Checks if current site is a development one.
64
- *
65
- * @since 1.2.0
66
- * @return bool
67
- */
68
- public function is_dev_url() {
69
- // If it is an AM dev site, return false, so we can see them on our dev sites.
70
- if ( defined ('AWESOMEMOTIVE_DEV_MODE' ) && AWESOMEMOTIVE_DEV_MODE ) {
71
- return false;
72
- }
73
-
74
- $url = network_site_url( '/' );
75
- $is_local_url = false;
76
-
77
- // Trim it up
78
- $url = strtolower( trim( $url ) );
79
-
80
- // Need to get the host...so let's add the scheme so we can use parse_url
81
- if ( false === strpos( $url, 'http://' ) && false === strpos( $url, 'https://' ) ) {
82
- $url = 'http://' . $url;
83
- }
84
- $url_parts = parse_url( $url );
85
- $host = ! empty( $url_parts['host'] ) ? $url_parts['host'] : false;
86
- if ( ! empty( $url ) && ! empty( $host ) ) {
87
- if ( false !== ip2long( $host ) ) {
88
- if ( ! filter_var( $host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) ) {
89
- $is_local_url = true;
90
- }
91
- } else if ( 'localhost' === $host ) {
92
- $is_local_url = true;
93
- }
94
-
95
- $tlds_to_check = array( '.dev', '.local', ':8888' );
96
- foreach ( $tlds_to_check as $tld ) {
97
- if ( false !== strpos( $host, $tld ) ) {
98
- $is_local_url = true;
99
- continue;
100
- }
101
-
102
- }
103
- if ( substr_count( $host, '.' ) > 1 ) {
104
- $subdomains_to_check = array( 'dev.', '*.staging.', 'beta.', 'test.' );
105
- foreach ( $subdomains_to_check as $subdomain ) {
106
- $subdomain = str_replace( '.', '(.)', $subdomain );
107
- $subdomain = str_replace( array( '*', '(.)' ), '(.*)', $subdomain );
108
- if ( preg_match( '/^(' . $subdomain . ')/', $host ) ) {
109
- $is_local_url = true;
110
- continue;
111
- }
112
- }
113
- }
114
- }
115
- return $is_local_url;
116
- }
117
-
118
- /**
119
- * Checks if current admin screen is the plugins page.
120
- *
121
- * @since 1.0.0
122
- * @return bool
123
- */
124
- public function is_plugin_page() {
125
- $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
126
- if ( empty( $screen ) ) {
127
- return false;
128
- }
129
- return ( ! empty( $screen->id ) && in_array( $screen->id, array( 'plugins', 'plugins-network' ), true ) );
130
- }
131
-
132
- /**
133
- * Survey javascript.
134
- *
135
- * @since 1.0.0
136
- */
137
- public function js() {
138
-
139
- if ( ! $this->is_plugin_page() ) {
140
- return;
141
- }
142
- ?>
143
- <script type="text/javascript">
144
- jQuery(function($){
145
- var $deactivateLink = $('#the-list').find('[data-slug="<?php echo $this->plugin; ?>"] span.deactivate a'),
146
- $overlay = $('#am-deactivate-survey-<?php echo $this->plugin; ?>'),
147
- $form = $overlay.find('form'),
148
- formOpen = false;
149
- // Plugin listing table deactivate link.
150
- $deactivateLink.on('click', function(event) {
151
- event.preventDefault();
152
- $overlay.css('display', 'table');
153
- formOpen = true;
154
- $form.find('.am-deactivate-survey-option:first-of-type input[type=radio]').focus();
155
- });
156
- // Survey radio option selected.
157
- $form.on('change', 'input[type=radio]', function(event) {
158
- event.preventDefault();
159
- $form.find('input[type=text], .error').hide();
160
- $form.find('.am-deactivate-survey-option').removeClass('selected');
161
- $(this).closest('.am-deactivate-survey-option').addClass('selected').find('input[type=text]').show();
162
- });
163
- // Survey Skip & Deactivate.
164
- $form.on('click', '.am-deactivate-survey-deactivate', function(event) {
165
- event.preventDefault();
166
- location.href = $deactivateLink.attr('href');
167
- });
168
- // Survey submit.
169
- $form.submit(function(event) {
170
- event.preventDefault();
171
- if (! $form.find('input[type=radio]:checked').val()) {
172
- $form.find('.am-deactivate-survey-footer').prepend('<span class="error"><?php echo esc_js( __( 'Please select an option', 'google-analytics-for-wordpress' ) ); ?></span>');
173
- return;
174
- }
175
- var data = {
176
- code: $form.find('.selected input[type=radio]').val(),
177
- reason: $form.find('.selected .am-deactivate-survey-option-reason').text(),
178
- details: $form.find('.selected input[type=text]').val(),
179
- site: '<?php echo esc_url( home_url() ); ?>',
180
- plugin: '<?php echo sanitize_key( $this->name ); ?>'
181
- }
182
- var submitSurvey = $.post('<?php echo $this->api_url; ?>', data);
183
- submitSurvey.always(function() {
184
- location.href = $deactivateLink.attr('href');
185
- });
186
- });
187
- // Exit key closes survey when open.
188
- $(document).keyup(function(event) {
189
- if (27 === event.keyCode && formOpen) {
190
- $overlay.hide();
191
- formOpen = false;
192
- $deactivateLink.focus();
193
- }
194
- });
195
- });
196
- </script>
197
- <?php
198
- }
199
-
200
- /**
201
- * Survey CSS.
202
- *
203
- * @since 1.0.0
204
- */
205
- public function css() {
206
-
207
- if ( ! $this->is_plugin_page() ) {
208
- return;
209
- }
210
- ?>
211
- <style type="text/css">
212
- .am-deactivate-survey-modal {
213
- display: none;
214
- table-layout: fixed;
215
- position: fixed;
216
- z-index: 9999;
217
- width: 100%;
218
- height: 100%;
219
- text-align: center;
220
- font-size: 14px;
221
- top: 0;
222
- left: 0;
223
- background: rgba(0,0,0,0.8);
224
- }
225
- .am-deactivate-survey-wrap {
226
- display: table-cell;
227
- vertical-align: middle;
228
- }
229
- .am-deactivate-survey {
230
- background-color: #fff;
231
- max-width: 550px;
232
- margin: 0 auto;
233
- padding: 30px;
234
- text-align: left;
235
- }
236
- .am-deactivate-survey .error {
237
- display: block;
238
- color: red;
239
- margin: 0 0 10px 0;
240
- }
241
- .am-deactivate-survey-title {
242
- display: block;
243
- font-size: 18px;
244
- font-weight: 700;
245
- text-transform: uppercase;
246
- border-bottom: 1px solid #ddd;
247
- padding: 0 0 18px 0;
248
- margin: 0 0 18px 0;
249
- }
250
- .am-deactivate-survey-title span {
251
- color: #999;
252
- margin-right: 10px;
253
- }
254
- .am-deactivate-survey-desc {
255
- display: block;
256
- font-weight: 600;
257
- margin: 0 0 18px 0;
258
- }
259
- .am-deactivate-survey-option {
260
- margin: 0 0 10px 0;
261
- }
262
- .am-deactivate-survey-option-input {
263
- margin-right: 10px !important;
264
- }
265
- .am-deactivate-survey-option-details {
266
- display: none;
267
- width: 90%;
268
- margin: 10px 0 0 30px;
269
- }
270
- .am-deactivate-survey-footer {
271
- margin-top: 18px;
272
- }
273
- .am-deactivate-survey-deactivate {
274
- float: right;
275
- font-size: 13px;
276
- color: #ccc;
277
- text-decoration: none;
278
- padding-top: 7px;
279
- }
280
- </style>
281
- <?php
282
- }
283
-
284
- /**
285
- * Survey modal.
286
- *
287
- * @since 1.0.0
288
- */
289
- public function modal() {
290
-
291
- if ( ! $this->is_plugin_page() ) {
292
- return;
293
- }
294
-
295
- $options = array(
296
- 1 => array(
297
- 'title' => esc_html__( 'I no longer need the plugin', 'google-analytics-for-wordpress' ),
298
- ),
299
- 2 => array(
300
- 'title' => esc_html__( 'I\'m switching to a different plugin', 'google-analytics-for-wordpress' ),
301
- 'details' => esc_html__( 'Please share which plugin', 'google-analytics-for-wordpress' ),
302
- ),
303
- 3 => array(
304
- 'title' => esc_html__( 'I couldn\'t get the plugin to work', 'google-analytics-for-wordpress' ),
305
- ),
306
- 4 => array(
307
- 'title' => esc_html__( 'It\'s a temporary deactivation', 'google-analytics-for-wordpress' ),
308
- ),
309
- 5 => array(
310
- 'title' => esc_html__( 'Other', 'google-analytics-for-wordpress' ),
311
- 'details' => esc_html__( 'Please share the reason', 'google-analytics-for-wordpress' ),
312
- ),
313
- );
314
- ?>
315
- <div class="am-deactivate-survey-modal" id="am-deactivate-survey-<?php echo $this->plugin; ?>">
316
- <div class="am-deactivate-survey-wrap">
317
- <form class="am-deactivate-survey" method="post">
318
- <span class="am-deactivate-survey-title"><span class="dashicons dashicons-testimonial"></span><?php echo ' ' . esc_html__( 'Quick Feedback', 'google-analytics-for-wordpress' ); ?></span>
319
- <span class="am-deactivate-survey-desc"><?php echo sprintf( esc_html__('If you have a moment, please share why you are deactivating %s:', 'google-analytics-for-wordpress' ), $this->name ); ?></span>
320
- <div class="am-deactivate-survey-options">
321
- <?php foreach ( $options as $id => $option ) : ?>
322
- <div class="am-deactivate-survey-option">
323
- <label for="am-deactivate-survey-option-<?php echo $this->plugin; ?>-<?php echo $id; ?>" class="am-deactivate-survey-option-label">
324
- <input id="am-deactivate-survey-option-<?php echo $this->plugin; ?>-<?php echo $id; ?>" class="am-deactivate-survey-option-input" type="radio" name="code" value="<?php echo $id; ?>" />
325
- <span class="am-deactivate-survey-option-reason"><?php echo $option['title']; ?></span>
326
- </label>
327
- <?php if ( ! empty( $option['details'] ) ) : ?>
328
- <input class="am-deactivate-survey-option-details" type="text" placeholder="<?php echo $option['details']; ?>" />
329
- <?php endif; ?>
330
- </div>
331
- <?php endforeach; ?>
332
- </div>
333
- <div class="am-deactivate-survey-footer">
334
- <button type="submit" class="am-deactivate-survey-submit button button-primary button-large"><?php echo sprintf( esc_html__('Submit %s Deactivate', 'google-analytics-for-wordpress' ), '&amp;' ); ?></button>
335
- <a href="#" class="am-deactivate-survey-deactivate"><?php echo sprintf( esc_html__('Skip %s Deactivate', 'google-analytics-for-wordpress' ), '&amp;' ); ?></a>
336
- </div>
337
- </form>
338
- </div>
339
- </div>
340
- <?php
341
- }
342
- }
343
- } // End if().
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! class_exists( 'AM_Deactivation_Survey' ) ) {
3
+ /**
4
+ * Awesome Motive Deactivation Survey.
5
+ *
6
+ * This prompts the user for more details when they deactivate the plugin.
7
+ *
8
+ * @version 1.2.1
9
+ * @package AwesomeMotive
10
+ * @author Jared Atchison and Chris Christoff
11
+ * @license GPL-2.0+
12
+ * @copyright Copyright (c) 2018
13
+ */
14
+ class AM_Deactivation_Survey {
15
+
16
+ /**
17
+ * The API URL we are calling.
18
+ *
19
+ * @since 1.0.0
20
+ * @var string
21
+ */
22
+ public $api_url = 'https://api.awesomemotive.com/v1/deactivation-survey/';
23
+
24
+ /**
25
+ * Name for this plugin.
26
+ *
27
+ * @since 1.0.0
28
+ * @var string
29
+ */
30
+ public $name;
31
+
32
+ /**
33
+ * Unique slug for this plugin.
34
+ *
35
+ * @since 1.0.0
36
+ * @var string
37
+ */
38
+ public $plugin;
39
+
40
+ /**
41
+ * Primary class constructor.
42
+ *
43
+ * @since 1.0.0
44
+ * @param string $name Plugin name.
45
+ * @param string $plugin Plugin slug.
46
+ */
47
+ public function __construct( $name = '', $plugin = '' ) {
48
+
49
+ $this->name = $name;
50
+ $this->plugin = $plugin;
51
+
52
+ // Don't run deactivation survey on dev sites.
53
+ if ( $this->is_dev_url() ) {
54
+ return;
55
+ }
56
+
57
+ add_action( 'admin_print_scripts', array( $this, 'js' ), 20 );
58
+ add_action( 'admin_print_scripts', array( $this, 'css' ) );
59
+ add_action( 'admin_footer', array( $this, 'modal' ) );
60
+ }
61
+
62
+ /**
63
+ * Checks if current site is a development one.
64
+ *
65
+ * @since 1.2.0
66
+ * @return bool
67
+ */
68
+ public function is_dev_url() {
69
+ // If it is an AM dev site, return false, so we can see them on our dev sites.
70
+ if ( defined ('AWESOMEMOTIVE_DEV_MODE' ) && AWESOMEMOTIVE_DEV_MODE ) {
71
+ return false;
72
+ }
73
+
74
+ $url = network_site_url( '/' );
75
+ $is_local_url = false;
76
+
77
+ // Trim it up
78
+ $url = strtolower( trim( $url ) );
79
+
80
+ // Need to get the host...so let's add the scheme so we can use parse_url
81
+ if ( false === strpos( $url, 'http://' ) && false === strpos( $url, 'https://' ) ) {
82
+ $url = 'http://' . $url;
83
+ }
84
+ $url_parts = parse_url( $url );
85
+ $host = ! empty( $url_parts['host'] ) ? $url_parts['host'] : false;
86
+ if ( ! empty( $url ) && ! empty( $host ) ) {
87
+ if ( false !== ip2long( $host ) ) {
88
+ if ( ! filter_var( $host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) ) {
89
+ $is_local_url = true;
90
+ }
91
+ } else if ( 'localhost' === $host ) {
92
+ $is_local_url = true;
93
+ }
94
+
95
+ $tlds_to_check = array( '.dev', '.local', ':8888' );
96
+ foreach ( $tlds_to_check as $tld ) {
97
+ if ( false !== strpos( $host, $tld ) ) {
98
+ $is_local_url = true;
99
+ continue;
100
+ }
101
+
102
+ }
103
+ if ( substr_count( $host, '.' ) > 1 ) {
104
+ $subdomains_to_check = array( 'dev.', '*.staging.', 'beta.', 'test.' );
105
+ foreach ( $subdomains_to_check as $subdomain ) {
106
+ $subdomain = str_replace( '.', '(.)', $subdomain );
107
+ $subdomain = str_replace( array( '*', '(.)' ), '(.*)', $subdomain );
108
+ if ( preg_match( '/^(' . $subdomain . ')/', $host ) ) {
109
+ $is_local_url = true;
110
+ continue;
111
+ }
112
+ }
113
+ }
114
+ }
115
+ return $is_local_url;
116
+ }
117
+
118
+ /**
119
+ * Checks if current admin screen is the plugins page.
120
+ *
121
+ * @since 1.0.0
122
+ * @return bool
123
+ */
124
+ public function is_plugin_page() {
125
+ $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
126
+ if ( empty( $screen ) ) {
127
+ return false;
128
+ }
129
+ return ( ! empty( $screen->id ) && in_array( $screen->id, array( 'plugins', 'plugins-network' ), true ) );
130
+ }
131
+
132
+ /**
133
+ * Survey javascript.
134
+ *
135
+ * @since 1.0.0
136
+ */
137
+ public function js() {
138
+
139
+ if ( ! $this->is_plugin_page() ) {
140
+ return;
141
+ }
142
+ ?>
143
+ <script type="text/javascript">
144
+ jQuery(function($){
145
+ var $deactivateLink = $('#the-list').find('[data-slug="<?php echo $this->plugin; ?>"] span.deactivate a'),
146
+ $overlay = $('#am-deactivate-survey-<?php echo $this->plugin; ?>'),
147
+ $form = $overlay.find('form'),
148
+ formOpen = false;
149
+ // Plugin listing table deactivate link.
150
+ $deactivateLink.on('click', function(event) {
151
+ event.preventDefault();
152
+ $overlay.css('display', 'table');
153
+ formOpen = true;
154
+ $form.find('.am-deactivate-survey-option:first-of-type input[type=radio]').focus();
155
+ });
156
+ // Survey radio option selected.
157
+ $form.on('change', 'input[type=radio]', function(event) {
158
+ event.preventDefault();
159
+ $form.find('input[type=text], .error').hide();
160
+ $form.find('.am-deactivate-survey-option').removeClass('selected');
161
+ $(this).closest('.am-deactivate-survey-option').addClass('selected').find('input[type=text]').show();
162
+ });
163
+ // Survey Skip & Deactivate.
164
+ $form.on('click', '.am-deactivate-survey-deactivate', function(event) {
165
+ event.preventDefault();
166
+ location.href = $deactivateLink.attr('href');
167
+ });
168
+ // Survey submit.
169
+ $form.submit(function(event) {
170
+ event.preventDefault();
171
+ if (! $form.find('input[type=radio]:checked').val()) {
172
+ $form.find('.am-deactivate-survey-footer').prepend('<span class="error"><?php echo esc_js( __( 'Please select an option', 'google-analytics-for-wordpress' ) ); ?></span>');
173
+ return;
174
+ }
175
+ var data = {
176
+ code: $form.find('.selected input[type=radio]').val(),
177
+ reason: $form.find('.selected .am-deactivate-survey-option-reason').text(),
178
+ details: $form.find('.selected input[type=text]').val(),
179
+ site: '<?php echo esc_url( home_url() ); ?>',
180
+ plugin: '<?php echo sanitize_key( $this->name ); ?>'
181
+ }
182
+ var submitSurvey = $.post('<?php echo $this->api_url; ?>', data);
183
+ submitSurvey.always(function() {
184
+ location.href = $deactivateLink.attr('href');
185
+ });
186
+ });
187
+ // Exit key closes survey when open.
188
+ $(document).keyup(function(event) {
189
+ if (27 === event.keyCode && formOpen) {
190
+ $overlay.hide();
191
+ formOpen = false;
192
+ $deactivateLink.focus();
193
+ }
194
+ });
195
+ });
196
+ </script>
197
+ <?php
198
+ }
199
+
200
+ /**
201
+ * Survey CSS.
202
+ *
203
+ * @since 1.0.0
204
+ */
205
+ public function css() {
206
+
207
+ if ( ! $this->is_plugin_page() ) {
208
+ return;
209
+ }
210
+ ?>
211
+ <style type="text/css">
212
+ .am-deactivate-survey-modal {
213
+ display: none;
214
+ table-layout: fixed;
215
+ position: fixed;
216
+ z-index: 9999;
217
+ width: 100%;
218
+ height: 100%;
219
+ text-align: center;
220
+ font-size: 14px;
221
+ top: 0;
222
+ left: 0;
223
+ background: rgba(0,0,0,0.8);
224
+ }
225
+ .am-deactivate-survey-wrap {
226
+ display: table-cell;
227
+ vertical-align: middle;
228
+ }
229
+ .am-deactivate-survey {
230
+ background-color: #fff;
231
+ max-width: 550px;
232
+ margin: 0 auto;
233
+ padding: 30px;
234
+ text-align: left;
235
+ }
236
+ .am-deactivate-survey .error {
237
+ display: block;
238
+ color: red;
239
+ margin: 0 0 10px 0;
240
+ }
241
+ .am-deactivate-survey-title {
242
+ display: block;
243
+ font-size: 18px;
244
+ font-weight: 700;
245
+ text-transform: uppercase;
246
+ border-bottom: 1px solid #ddd;
247
+ padding: 0 0 18px 0;
248
+ margin: 0 0 18px 0;
249
+ }
250
+ .am-deactivate-survey-title span {
251
+ color: #999;
252
+ margin-right: 10px;
253
+ }
254
+ .am-deactivate-survey-desc {
255
+ display: block;
256
+ font-weight: 600;
257
+ margin: 0 0 18px 0;
258
+ }
259
+ .am-deactivate-survey-option {
260
+ margin: 0 0 10px 0;
261
+ }
262
+ .am-deactivate-survey-option-input {
263
+ margin-right: 10px !important;
264
+ }
265
+ .am-deactivate-survey-option-details {
266
+ display: none;
267
+ width: 90%;
268
+ margin: 10px 0 0 30px;
269
+ }
270
+ .am-deactivate-survey-footer {
271
+ margin-top: 18px;
272
+ }
273
+ .am-deactivate-survey-deactivate {
274
+ float: right;
275
+ font-size: 13px;
276
+ color: #ccc;
277
+ text-decoration: none;
278
+ padding-top: 7px;
279
+ }
280
+ </style>
281
+ <?php
282
+ }
283
+
284
+ /**
285
+ * Survey modal.
286
+ *
287
+ * @since 1.0.0
288
+ */
289
+ public function modal() {
290
+
291
+ if ( ! $this->is_plugin_page() ) {
292
+ return;
293
+ }
294
+
295
+ $options = array(
296
+ 1 => array(
297
+ 'title' => esc_html__( 'I no longer need the plugin', 'google-analytics-for-wordpress' ),
298
+ ),
299
+ 2 => array(
300
+ 'title' => esc_html__( 'I\'m switching to a different plugin', 'google-analytics-for-wordpress' ),
301
+ 'details' => esc_html__( 'Please share which plugin', 'google-analytics-for-wordpress' ),
302
+ ),
303
+ 3 => array(
304
+ 'title' => esc_html__( 'I couldn\'t get the plugin to work', 'google-analytics-for-wordpress' ),
305
+ ),
306
+ 4 => array(
307
+ 'title' => esc_html__( 'It\'s a temporary deactivation', 'google-analytics-for-wordpress' ),
308
+ ),
309
+ 5 => array(
310
+ 'title' => esc_html__( 'Other', 'google-analytics-for-wordpress' ),
311
+ 'details' => esc_html__( 'Please share the reason', 'google-analytics-for-wordpress' ),
312
+ ),
313
+ );
314
+ ?>
315
+ <div class="am-deactivate-survey-modal" id="am-deactivate-survey-<?php echo $this->plugin; ?>">
316
+ <div class="am-deactivate-survey-wrap">
317
+ <form class="am-deactivate-survey" method="post">
318
+ <span class="am-deactivate-survey-title"><span class="dashicons dashicons-testimonial"></span><?php echo ' ' . esc_html__( 'Quick Feedback', 'google-analytics-for-wordpress' ); ?></span>
319
+ <span class="am-deactivate-survey-desc">
320
+ <?php
321
+ // Translators: Placeholder for the plugin name.
322
+ echo sprintf( esc_html__('If you have a moment, please share why you are deactivating %s:', 'google-analytics-for-wordpress' ), $this->name );
323
+ ?>
324
+ </span>
325
+ <div class="am-deactivate-survey-options">
326
+ <?php foreach ( $options as $id => $option ) : ?>
327
+ <div class="am-deactivate-survey-option">
328
+ <label for="am-deactivate-survey-option-<?php echo $this->plugin; ?>-<?php echo $id; ?>" class="am-deactivate-survey-option-label">
329
+ <input id="am-deactivate-survey-option-<?php echo $this->plugin; ?>-<?php echo $id; ?>" class="am-deactivate-survey-option-input" type="radio" name="code" value="<?php echo $id; ?>" />
330
+ <span class="am-deactivate-survey-option-reason"><?php echo $option['title']; ?></span>
331
+ </label>
332
+ <?php if ( ! empty( $option['details'] ) ) : ?>
333
+ <input class="am-deactivate-survey-option-details" type="text" placeholder="<?php echo $option['details']; ?>" />
334
+ <?php endif; ?>
335
+ </div>
336
+ <?php endforeach; ?>
337
+ </div>
338
+ <div class="am-deactivate-survey-footer">
339
+ <button type="submit" class="am-deactivate-survey-submit button button-primary button-large">
340
+ <?php
341
+ // Translators: Adds an ampersand.
342
+ echo sprintf( esc_html__('Submit %s Deactivate', 'google-analytics-for-wordpress' ), '&amp;' );
343
+ ?>
344
+ </button>
345
+ <a href="#" class="am-deactivate-survey-deactivate">
346
+ <?php
347
+ // Translators: Adds an ampersand.
348
+ echo sprintf( esc_html__('Skip %s Deactivate', 'google-analytics-for-wordpress' ), '&amp;' );
349
+ ?>
350
+ </a>
351
+ </div>
352
+ </form>
353
+ </div>
354
+ </div>
355
+ <?php
356
+ }
357
+ }
358
+ } // End if().
assets/lib/pandora/class-am-notification.php DELETED
@@ -1,472 +0,0 @@
1
- <?php
2
-
3
- if ( ! class_exists( 'AM_Notification', false ) ) {
4
- /**
5
- * Awesome Motive Notifications
6
- *
7
- * This creates a custom post type (if it doesn't exist) and calls the API to
8
- * retrieve notifications for this product.
9
- *
10
- * @package AwesomeMotive
11
- * @author AwesomeMotive Team
12
- * @license GPL-2.0+
13
- * @copyright Copyright (c) 2018, Awesome Motive LLC
14
- * @version 1.0.7
15
- */
16
- class AM_Notification {
17
-
18
- /**
19
- * The api url we are calling.
20
- *
21
- * @since 1.0.0
22
- *
23
- * @var string
24
- */
25
- public $api_url = 'https://api.awesomemotive.com/v1/notification/';
26
-
27
- /**
28
- * A unique slug for this plugin.
29
- * (Not the WordPress plugin slug)
30
- *
31
- * @since 1.0.0
32
- *
33
- * @var string
34
- */
35
- public $plugin;
36
-
37
- /**
38
- * The current plugin version.
39
- *
40
- * @since 1.0.0
41
- *
42
- * @var string
43
- */
44
- public $plugin_version;
45
-
46
- /**
47
- * Flag if a notice has been registered.
48
- *
49
- * @since 1.0.0
50
- *
51
- * @var bool
52
- */
53
- public static $registered = false;
54
-
55
- /**
56
- * Construct.
57
- *
58
- * @since 1.0.0
59
- *
60
- * @param string $plugin The plugin slug.
61
- * @param mixed $version The version of the plugin.
62
- */
63
- public function __construct( $plugin = '', $version = 0 ) {
64
- $this->plugin = $plugin;
65
- $this->plugin_version = $version;
66
-
67
- add_action( 'init', array( $this, 'custom_post_type' ) );
68
- add_action( 'admin_init', array( $this, 'get_remote_notifications' ), 100 );
69
- add_action( 'admin_notices', array( $this, 'display_notifications' ) );
70
- add_action( 'wp_ajax_am_notification_dismiss', array( $this, 'dismiss_notification' ) );
71
- }
72
-
73
- /**
74
- * Registers a custom post type.
75
- *
76
- * @since 1.0.0
77
- */
78
- public function custom_post_type() {
79
- register_post_type( 'amn_' . $this->plugin, array(
80
- 'label' => $this->plugin . ' Announcements',
81
- 'can_export' => false,
82
- 'supports' => false,
83
- 'capability_type' => 'manage_options',
84
- ) );
85
- }
86
-
87
- /**
88
- * Retrieve the remote notifications if the time has expired.
89
- *
90
- * @since 1.0.0
91
- */
92
- public function get_remote_notifications() {
93
- if ( ! apply_filters( 'am_notifications_display', is_super_admin() ) ) {
94
- return;
95
- }
96
-
97
- $to_check = get_option( '_amn_' . $this->plugin . '_to_check', false );
98
-
99
- if ( $to_check == false ) {
100
- // Non load balanced. Start checking in in 7 days + 2-4 days.
101
- $checktime = array();
102
- $checktime['day'] = rand( 0, 6 );
103
- $checktime['hour'] = rand( 0, 23 );
104
- $checktime['minute'] = rand( 0, 59 );
105
- $checktime['second'] = rand( 0, 59 );
106
- $checktime['offset'] = ( $checktime['day'] * DAY_IN_SECONDS ) +
107
- ( $checktime['hour'] * HOUR_IN_SECONDS ) +
108
- ( $checktime['minute'] * MINUTE_IN_SECONDS ) +
109
- $checktime['second'];
110
- $to_check = strtotime("next sunday") + $checktime['offset'];
111
- update_option( '_amn_' . $this->plugin . '_to_check', $to_check );
112
- }
113
-
114
- if ( $to_check < time() ) {
115
- $plugin_notifications = $this->get_plugin_notifications( 1 );
116
- $notification_id = null;
117
-
118
- if ( ! empty( $plugin_notifications ) ) {
119
- // Unset it from the array.
120
- $notification = $plugin_notifications[0];
121
- $notification_id = get_post_meta( $notification->ID, 'notification_id', true );
122
- }
123
-
124
- $response = wp_remote_retrieve_body( wp_remote_post( $this->api_url, array(
125
- 'body' => array(
126
- 'slug' => $this->plugin,
127
- 'version' => $this->plugin_version,
128
- 'last_notification' => $notification_id,
129
- ),
130
- ) ) );
131
-
132
- $data = json_decode( $response );
133
-
134
- if ( ! empty( $data->id ) ) {
135
- $notifications = array();
136
-
137
- foreach ( (array) $data->slugs as $slug ) {
138
- $notifications = array_merge(
139
- $notifications,
140
- (array) get_posts(
141
- array(
142
- 'post_type' => 'amn_' . $slug,
143
- 'post_status' => 'all',
144
- 'meta_key' => 'notification_id',
145
- 'meta_value' => $data->id,
146
- )
147
- )
148
- );
149
- }
150
-
151
- if ( empty( $notifications ) ) {
152
- $new_notification_id = wp_insert_post(
153
- array(
154
- 'post_content' => wp_kses_post( $data->content ),
155
- 'post_type' => 'amn_' . $this->plugin,
156
- )
157
- );
158
-
159
- update_post_meta( $new_notification_id, 'notification_id', absint( $data->id ) );
160
- update_post_meta( $new_notification_id, 'type', sanitize_text_field( trim( $data->type ) ) );
161
- update_post_meta( $new_notification_id, 'dismissable', (bool) $data->dismissible ? 1 : 0 );
162
- update_post_meta( $new_notification_id, 'location', function_exists( 'wp_json_encode' ) ? wp_json_encode( $data->location ) : json_encode( $data->location ) );
163
- update_post_meta( $new_notification_id, 'version', sanitize_text_field( trim( $data->version ) ) );
164
- update_post_meta( $new_notification_id, 'viewed', 0 );
165
- update_post_meta( $new_notification_id, 'expiration', $data->expiration ? absint( $data->expiration ) : false );
166
- update_post_meta( $new_notification_id, 'plans', function_exists( 'wp_json_encode' ) ? wp_json_encode( $data->plans ) : json_encode( $data->plans ) );
167
- }
168
- }
169
-
170
- // Possibly revoke notifications.
171
- if ( ! empty( $data->revoked ) ) {
172
- $this->revoke_notifications( $data->revoked );
173
- }
174
-
175
- // Set the option now so we can't run this again until after 24 hours.
176
- update_option( '_amn_' . $this->plugin . '_to_check', time() + 3 * DAY_IN_SECONDS );
177
- }
178
- }
179
-
180
- /**
181
- * Get local plugin notifications that have already been set.
182
- *
183
- * @since 1.0.0
184
- *
185
- * @param integer $limit Set the limit for how many posts to retrieve.
186
- * @param array $args Any top-level arguments to add to the array.
187
- *
188
- * @return WP_Post[] WP_Post that match the query.
189
- */
190
- public function get_plugin_notifications( $limit = - 1, $args = array() ) {
191
- return get_posts(
192
- array(
193
- 'posts_per_page' => $limit,
194
- 'post_type' => 'amn_' . $this->plugin,
195
- ) + $args
196
- );
197
- }
198
-
199
- /**
200
- * Display any notifications that should be displayed.
201
- *
202
- * @since 1.0.0
203
- */
204
- public function display_notifications() {
205
- if ( ! apply_filters( 'am_notifications_display', is_super_admin() ) ) {
206
- return;
207
- }
208
-
209
- $plugin_notifications = $this->get_plugin_notifications( - 1, array(
210
- 'post_status' => 'all',
211
- 'meta_key' => 'viewed',
212
- 'meta_value' => '0',
213
- ) );
214
-
215
- $plugin_notifications = $this->validate_notifications( $plugin_notifications );
216
-
217
- if ( ! empty( $plugin_notifications ) && ! self::$registered ) {
218
- foreach ( $plugin_notifications as $notification ) {
219
- $dismissable = get_post_meta( $notification->ID, 'dismissable', true );
220
- $type = get_post_meta( $notification->ID, 'type', true );
221
- ?>
222
- <div class="am-notification am-notification-<?php echo absint( $notification->ID ); ?> notice notice-<?php echo esc_attr( $type ); ?><?php echo $dismissable ? ' is-dismissible' : ''; ?>">
223
- <?php echo wp_kses_post( $notification->post_content ); ?>
224
- </div>
225
- <script type="text/javascript">
226
- jQuery( document ).ready( function ( $ ) {
227
- $( document ).on( 'click', '.am-notification-<?php echo absint( $notification->ID ); ?> button.notice-dismiss', function ( event ) {
228
- $.post( ajaxurl, {
229
- action: 'am_notification_dismiss',
230
- notification_id: '<?php echo absint( $notification->ID ); ?>'
231
- } );
232
- } );
233
- } );
234
- </script>
235
- <?php
236
- }
237
-
238
- self::$registered = true;
239
- }
240
- }
241
-
242
- /**
243
- * Validate the notifications before displaying them.
244
- *
245
- * @since 1.0.0
246
- *
247
- * @param array $plugin_notifications An array of plugin notifications.
248
- *
249
- * @return array A filtered array of plugin notifications.
250
- */
251
- public function validate_notifications( $plugin_notifications ) {
252
- global $pagenow;
253
-
254
- foreach ( $plugin_notifications as $key => $notification ) {
255
- // Location validation.
256
- $location = (array) json_decode( get_post_meta( $notification->ID, 'location', true ) );
257
- $continue = false;
258
- if ( ! in_array( 'everywhere', $location, true ) ) {
259
- if ( in_array( 'index.php', $location, true ) && 'index.php' === $pagenow ) {
260
- $continue = true;
261
- }
262
-
263
- if ( in_array( 'plugins.php', $location, true ) && 'plugins.php' === $pagenow ) {
264
- $continue = true;
265
- }
266
-
267
- if ( ! $continue ) {
268
- unset( $plugin_notifications[ $key ] );
269
- }
270
- }
271
-
272
- // Plugin validation (OR conditional).
273
- $plugins = (array) json_decode( get_post_meta( $notification->ID, 'plugins', true ) );
274
- $continue = false;
275
- if ( ! empty( $plugins ) ) {
276
- foreach ( $plugins as $plugin ) {
277
- if ( is_plugin_active( $plugin ) ) {
278
- $continue = true;
279
- }
280
- }
281
-
282
- if ( ! $continue ) {
283
- unset( $plugin_notifications[ $key ] );
284
- }
285
- }
286
-
287
- // Theme validation.
288
- $theme = get_post_meta( $notification->ID, 'theme', true );
289
- $continue = (string) wp_get_theme() === $theme;
290
-
291
- if ( ! empty( $theme ) && ! $continue ) {
292
- unset( $plugin_notifications[ $key ] );
293
- }
294
-
295
- // Version validation.
296
- $version = get_post_meta( $notification->ID, 'version', true );
297
- $continue = false;
298
- if ( ! empty( $version ) ) {
299
- if ( version_compare( $this->plugin_version, $version, '<=' ) ) {
300
- $continue = true;
301
- }
302
-
303
- if ( ! $continue ) {
304
- unset( $plugin_notifications[ $key ] );
305
- }
306
- }
307
-
308
- // Expiration validation.
309
- $expiration = get_post_meta( $notification->ID, 'expiration', true );
310
- $continue = false;
311
- if ( ! empty( $expiration ) ) {
312
- if ( $expiration > time() ) {
313
- $continue = true;
314
- }
315
-
316
- if ( ! $continue ) {
317
- unset( $plugin_notifications[ $key ] );
318
- }
319
- }
320
-
321
- // Plan validation.
322
- $plans = (array) json_decode( get_post_meta( $notification->ID, 'plans', true ) );
323
- $continue = false;
324
- if ( ! empty( $plans ) ) {
325
- $level = $this->get_plan_level();
326
- if ( in_array( $level, $plans, true ) ) {
327
- $continue = true;
328
- }
329
-
330
- if ( ! $continue ) {
331
- unset( $plugin_notifications[ $key ] );
332
- }
333
- }
334
- }
335
-
336
- return $plugin_notifications;
337
- }
338
-
339
- /**
340
- * Grab the current plan level.
341
- *
342
- * @since 1.0.0
343
- *
344
- * @return string The current plan level.
345
- */
346
- public function get_plan_level() {
347
- // Prepare variables.
348
- $key = '';
349
- $level = '';
350
-
351
- switch ( $this->plugin ) {
352
- case 'wpforms':
353
- $option = get_option( 'wpforms_license' );
354
- $key = is_array( $option ) && isset( $option['key'] ) ? $option['key'] : '';
355
- $level = is_array( $option ) && isset( $option['type'] ) ? $option['type'] : '';
356
-
357
- // Possibly check for a constant.
358
- if ( empty( $key ) && defined( 'WPFORMS_LICENSE_KEY' ) ) {
359
- $key = WPFORMS_LICENSE_KEY;
360
- }
361
- break;
362
- case 'mi-lite':
363
- case 'mi':
364
- if ( version_compare( MONSTERINSIGHTS_VERSION, '6.9.0', '>=' ) ) {
365
- if ( MonsterInsights()->license->get_site_license_type() ) {
366
- $key = MonsterInsights()->license->get_site_license_key();
367
- $type = MonsterInsights()->license->get_site_license_type();
368
- } else if ( MonsterInsights()->license->get_network_license_type() ) {
369
- $key = MonsterInsights()->license->get_network_license_key();
370
- $type = MonsterInsights()->license->get_network_license_type();
371
- }
372
-
373
- // Check key fallbacks.
374
- if ( empty( $key ) ) {
375
- $key = MonsterInsights()->license->get_license_key();
376
- }
377
- } else {
378
- $option = get_option( 'monsterinsights_license' );
379
- $key = is_array( $option ) && isset( $option['key'] ) ? $option['key'] : '';
380
- $level = is_array( $option ) && isset( $option['type'] ) ? $option['type'] : '';
381
-
382
- // Possibly check for a constant.
383
- if ( empty( $key ) && defined( 'MONSTERINSIGHTS_LICENSE_KEY' ) && is_string( MONSTERINSIGHTS_LICENSE_KEY ) && strlen( MONSTERINSIGHTS_LICENSE_KEY ) > 10 ) {
384
- $key = MONSTERINSIGHTS_LICENSE_KEY;
385
- }
386
- }
387
- break;
388
- case 'om':
389
- $option = get_option( 'optin_monster_api' );
390
- $key = is_array( $option ) && isset( $option['api']['apikey'] ) ? $option['api']['apikey'] : '';
391
-
392
- // Possibly check for a constant.
393
- if ( empty( $key ) && defined( 'OPTINMONSTER_REST_API_LICENSE_KEY' ) ) {
394
- $key = OPTINMONSTER_REST_API_LICENSE_KEY;
395
- }
396
-
397
- // If the key is still empty, check for the old legacy key.
398
- if ( empty( $key ) ) {
399
- $key = is_array( $option ) && isset( $option['api']['key'] ) ? $option['api']['key'] : '';
400
- }
401
- break;
402
- }
403
-
404
- // Possibly set the level to 'none' if the key is empty and no level has been set.
405
- if ( empty( $key ) && empty( $level ) ) {
406
- $level = 'none';
407
- }
408
-
409
- // Possibly set the level to 'unknown' if a key is entered, but no level can be determined (such as manually entered key)
410
- if ( ! empty( $key ) && empty( $level ) ) {
411
- $level = 'unknown';
412
- }
413
-
414
- // Normalize the level.
415
- switch ( $level ) {
416
- case 'bronze':
417
- case 'personal':
418
- $level = 'basic';
419
- break;
420
- case 'silver':
421
- case 'multi':
422
- $level = 'plus';
423
- break;
424
- case 'gold':
425
- case 'developer':
426
- $level = 'pro';
427
- break;
428
- case 'platinum':
429
- case 'master':
430
- $level = 'ultimate';
431
- break;
432
- }
433
-
434
- // Return the plan level.
435
- return $level;
436
- }
437
-
438
- /**
439
- * Dismiss the notification via AJAX.
440
- *
441
- * @since 1.0.0
442
- */
443
- public function dismiss_notification() {
444
- if ( ! apply_filters( 'am_notifications_display', is_super_admin() ) ) {
445
- die;
446
- }
447
-
448
- $notification_id = intval( $_POST['notification_id'] );
449
- update_post_meta( $notification_id, 'viewed', 1 );
450
- die;
451
- }
452
-
453
- /**
454
- * Revokes notifications.
455
- *
456
- * @since 1.0.0
457
- *
458
- * @param array $ids An array of notification IDs to revoke.
459
- */
460
- public function revoke_notifications( $ids ) {
461
- // Loop through each of the IDs and find the post that has it as meta.
462
- foreach ( (array) $ids as $id ) {
463
- $notifications = $this->get_plugin_notifications( - 1, array( 'post_status' => 'all', 'meta_key' => 'notification_id', 'meta_value' => $id ) );
464
- if ( $notifications ) {
465
- foreach ( $notifications as $notification ) {
466
- update_post_meta( $notification->ID, 'viewed', 1 );
467
- }
468
- }
469
- }
470
- }
471
- }
472
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
googleanalytics.php CHANGED
@@ -1,746 +1,760 @@
1
- <?php
2
- /**
3
- * Plugin Name: Google Analytics for WordPress by MonsterInsights
4
- * Plugin URI: https://www.monsterinsights.com/?utm_source=liteplugin&utm_medium=pluginheader&utm_campaign=pluginurl&utm_content=7%2E0%2E0
5
- * Description: The best Google Analytics plugin for WordPress. See how visitors find and use your website, so you can keep them coming back.
6
- * Author: MonsterInsights
7
- * Author URI: https://www.monsterinsights.com/?utm_source=liteplugin&utm_medium=pluginheader&utm_campaign=authoruri&utm_content=7%2E0%2E0
8
- *
9
- * Version: 7.10.4
10
- * Requires at least: 3.8.0
11
- *
12
- * License: GPL v3
13
- *
14
- * Text Domain: google-analytics-for-wordpress
15
- * Domain Path: /languages
16
- *
17
- * MonsterInsights Lite
18
- * Copyright (C) 2008-2018, MonsterInsights, support@monsterinsights.com
19
- *
20
- * This program is free software: you can redistribute it and/or modify
21
- * it under the terms of the GNU General Public License as published by
22
- * the Free Software Foundation, either version 3 of the License, or
23
- * (at your option) any later version.
24
- *
25
- * This program is distributed in the hope that it will be useful,
26
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28
- * GNU General Public License for more details.
29
- *
30
- * You should have received a copy of the GNU General Public License
31
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
32
- *
33
- * @category Plugin
34
- * @copyright Copyright © 2018 Chris Christoff
35
- * @author Chris Christoff
36
- * @package MonsterInsights
37
- */
38
-
39
- // Exit if accessed directly.
40
- if ( ! defined( 'ABSPATH' ) ) {
41
- exit;
42
- }
43
-
44
- /**
45
- * Main plugin class.
46
- *
47
- * @since 6.0.0
48
- *
49
- * @package MonsterInsights
50
- * @author Chris Christoff
51
- * @access public
52
- */
53
- final class MonsterInsights_Lite {
54
-
55
- /**
56
- * Holds the class object.
57
- *
58
- * @since 6.0.0
59
- * @access public
60
- * @var object Instance of instantiated MonsterInsights class.
61
- */
62
- public static $instance;
63
-
64
- /**
65
- * Plugin version, used for cache-busting of style and script file references.
66
- *
67
- * @since 6.0.0
68
- * @access public
69
- * @var string $version Plugin version.
70
- */
71
- public $version = '7.10.4';
72
-
73
- /**
74
- * Plugin file.
75
- *
76
- * @since 6.0.0
77
- * @access public
78
- * @var string $file PHP File constant for main file.
79
- */
80
- public $file;
81
-
82
- /**
83
- * The name of the plugin.
84
- *
85
- * @since 6.0.0
86
- * @access public
87
- * @var string $plugin_name Plugin name.
88
- */
89
- public $plugin_name = 'MonsterInsights Lite';
90
-
91
- /**
92
- * Unique plugin slug identifier.
93
- *
94
- * @since 6.0.0
95
- * @access public
96
- * @var string $plugin_slug Plugin slug.
97
- */
98
- public $plugin_slug = 'monsterinsights-lite';
99
-
100
- /**
101
- * Holds instance of MonsterInsights License class.
102
- *
103
- * @since 6.0.0
104
- * @access public
105
- * @var MonsterInsights_License $license Instance of License class.
106
- */
107
- protected $license;
108
-
109
- /**
110
- * Holds instance of MonsterInsights Admin Notice class.
111
- *
112
- * @since 6.0.0
113
- * @access public
114
- * @var MonsterInsights_Admin_Notice $notices Instance of Admin Notice class.
115
- */
116
- public $notices;
117
-
118
- /**
119
- * Holds instance of MonsterInsights Reporting class.
120
- *
121
- * @since 6.0.0
122
- * @access public
123
- * @var MonsterInsights_Reporting $reporting Instance of Reporting class.
124
- */
125
- public $reporting;
126
-
127
- /**
128
- * Holds instance of MonsterInsights Auth class.
129
- *
130
- * @since 7.0.0
131
- * @access public
132
- * @var MonsterInsights_Auth $auth Instance of Auth class.
133
- */
134
- protected $auth;
135
-
136
- /**
137
- * Holds instance of MonsterInsights API Auth class.
138
- *
139
- * @since 6.0.0
140
- * @access public
141
- * @var MonsterInsights_Auth $api_auth Instance of APIAuth class.
142
- */
143
- public $api_auth;
144
-
145
- /**
146
- * Holds instance of MonsterInsights API Rest Routes class.
147
- *
148
- * @since 7.4.0
149
- * @access public
150
- * @var MonsterInsights_Rest_Routes $routes Instance of rest routes.
151
- */
152
- public $routes;
153
-
154
- /**
155
- * Primary class constructor.
156
- *
157
- * @since 6.0.0
158
- * @access public
159
- */
160
- public function __construct() {
161
- // We don't use this
162
- }
163
-
164
- /**
165
- * Returns the singleton instance of the class.
166
- *
167
- * @access public
168
- * @since 6.0.0
169
- *
170
- * @return object The MonsterInsights_Lite object.
171
- */
172
- public static function get_instance() {
173
-
174
- if ( ! isset( self::$instance ) && ! ( self::$instance instanceof MonsterInsights_Lite ) ) {
175
- self::$instance = new MonsterInsights_Lite();
176
- self::$instance->file = __FILE__;
177
-
178
- global $wp_version;
179
-
180
- // Detect non-supported WordPress version and return early
181
- if ( version_compare( $wp_version, '3.8', '<' ) && ( ! defined( 'MONSTERINSIGHTS_FORCE_ACTIVATION' ) || ! MONSTERINSIGHTS_FORCE_ACTIVATION ) ) {
182
- add_action( 'admin_notices', array( self::$instance, 'monsterinsights_wp_notice' ) );
183
- return;
184
- }
185
-
186
- // Detect Pro version and return early
187
- if ( defined( 'MONSTERINSIGHTS_PRO_VERSION' ) ) {
188
- add_action( 'admin_notices', array( self::$instance, 'monsterinsights_pro_notice' ) );
189
- return;
190
- }
191
-
192
- // Define constants
193
- self::$instance->define_globals();
194
-
195
- // Load in settings
196
- self::$instance->load_settings();
197
-
198
- // Load in Licensing
199
- self::$instance->load_licensing();
200
-
201
- // Load in Auth
202
- self::$instance->load_auth();
203
-
204
- // Load files
205
- self::$instance->require_files();
206
-
207
- // This does the version to version background upgrade routines and initial install
208
- $mi_version = get_option( 'monsterinsights_current_version', '5.5.3' );
209
- if ( version_compare( $mi_version, '7.10.0', '<' ) ) {
210
- monsterinsights_lite_call_install_and_upgrade();
211
- }
212
-
213
- if ( is_admin() ) {
214
- new AM_Notification( 'mi-lite', self::$instance->version );
215
- new AM_Deactivation_Survey( 'MonsterInsights', basename( dirname( __FILE__ ) ) );
216
- }
217
-
218
- // Load the plugin textdomain.
219
- add_action( 'plugins_loaded', array( self::$instance, 'load_plugin_textdomain' ) );
220
-
221
- // Load admin only components.
222
- if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
223
- self::$instance->notices = new MonsterInsights_Notice_Admin();
224
- self::$instance->reporting = new MonsterInsights_Reporting();
225
- self::$instance->api_auth = new MonsterInsights_API_Auth();
226
- self::$instance->routes = new MonsterInsights_Rest_Routes();
227
- }
228
-
229
- if ( monsterinsights_is_pro_version() ) {
230
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'pro/includes/load.php';
231
- } else {
232
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/load.php';
233
- }
234
-
235
- // Run hook to load MonsterInsights addons.
236
- do_action( 'monsterinsights_load_plugins' ); // the updater class for each addon needs to be instantiated via `monsterinsights_updater`
237
- }
238
-
239
- return self::$instance;
240
-
241
- }
242
-
243
- /**
244
- * Throw error on object clone
245
- *
246
- * The whole idea of the singleton design pattern is that there is a single
247
- * object therefore, we don't want the object to be cloned.
248
- *
249
- * @since 6.0.0
250
- * @access public
251
- *
252
- * @return void
253
- */
254
- public function __clone() {
255
- _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'google-analytics-for-wordpress' ), '6.0.0' );
256
- }
257
-
258
- /**
259
- * Disable unserializing of the class
260
- *
261
- * Attempting to wakeup an MonsterInsights instance will throw a doing it wrong notice.
262
- *
263
- * @since 6.0.0
264
- * @access public
265
- *
266
- * @return void
267
- */
268
- public function __wakeup() {
269
- _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'google-analytics-for-wordpress' ), '6.0.0' );
270
- }
271
-
272
- /**
273
- * Magic get function.
274
- *
275
- * We use this to lazy load certain functionality. Right now used to lazyload
276
- * the API & Auth frontend, so it's only loaded if user is using a plugin
277
- * that requires it.
278
- *
279
- * @since 7.0.0
280
- * @access public
281
- *
282
- * @return void
283
- */
284
- public function __get( $key ) {
285
- if ( $key === 'auth' ) {
286
- if ( empty( self::$instance->auth ) ) {
287
- // LazyLoad Auth for Frontend
288
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/auth.php';
289
- self::$instance->auth = new MonsterInsights_Auth();
290
- }
291
- return self::$instance->$key;
292
- } else {
293
- return self::$instance->$key;
294
- }
295
- }
296
-
297
- /**
298
- * Define MonsterInsights constants.
299
- *
300
- * This function defines all of the MonsterInsights PHP constants.
301
- *
302
- * @since 6.0.0
303
- * @access public
304
- *
305
- * @return void
306
- */
307
- public function define_globals() {
308
-
309
- if ( ! defined( 'MONSTERINSIGHTS_VERSION' ) ) {
310
- define( 'MONSTERINSIGHTS_VERSION', $this->version );
311
- }
312
-
313
- if ( ! defined( 'MONSTERINSIGHTS_LITE_VERSION' ) ) {
314
- define( 'MONSTERINSIGHTS_LITE_VERSION', MONSTERINSIGHTS_VERSION );
315
- }
316
-
317
- if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_NAME' ) ) {
318
- define( 'MONSTERINSIGHTS_PLUGIN_NAME', $this->plugin_name );
319
- }
320
-
321
- if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_SLUG' ) ) {
322
- define( 'MONSTERINSIGHTS_PLUGIN_SLUG', $this->plugin_slug );
323
- }
324
-
325
- if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_FILE' ) ) {
326
- define( 'MONSTERINSIGHTS_PLUGIN_FILE', $this->file );
327
- }
328
-
329
- if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_DIR' ) ) {
330
- define( 'MONSTERINSIGHTS_PLUGIN_DIR', plugin_dir_path( $this->file ) );
331
- }
332
-
333
- if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_URL' ) ) {
334
- define( 'MONSTERINSIGHTS_PLUGIN_URL', plugin_dir_url( $this->file ) );
335
- }
336
- }
337
-
338
- /**
339
- * Loads the plugin textdomain for translation.
340
- *
341
- * @access public
342
- * @since 6.0.0
343
- *
344
- * @return void
345
- */
346
- public function load_plugin_textdomain() {
347
-
348
- $mi_locale = get_locale();
349
- if ( function_exists( 'get_user_locale' ) ) {
350
- $mi_locale = get_user_locale();
351
- }
352
-
353
- // Traditional WordPress plugin locale filter.
354
- $mi_locale = apply_filters( 'plugin_locale', $mi_locale, 'google-analytics-for-wordpress' );
355
- $mi_mofile = sprintf( '%1$s-%2$s.mo', 'google-analytics-for-wordpress', $mi_locale );
356
-
357
- // Look for wp-content/languages/google-analytics-for-wordpress/google-analytics-for-wordpress-{lang}_{country}.mo
358
- $mi_mofile1 = WP_LANG_DIR . '/google-analytics-for-wordpress/' . $mi_mofile;
359
-
360
- // Look in wp-content/languages/plugins/google-analytics-for-wordpress/google-analytics-for-wordpress-{lang}_{country}.mo
361
- $mi_mofile2 = WP_LANG_DIR . '/plugins/google-analytics-for-wordpress/' . $mi_mofile;
362
-
363
- // Look in wp-content/languages/plugins/google-analytics-for-wordpress-{lang}_{country}.mo
364
- $mi_mofile3 = WP_LANG_DIR . '/plugins/' . $mi_mofile;
365
-
366
- // Look in wp-content/plugins/google-analytics-for-wordpress/languages/google-analytics-for-wordpress-{lang}_{country}.mo
367
- $mi_mofile4 = dirname( plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ) ) . '/languages/';
368
- $mi_mofile4 = apply_filters( 'monsterinsights_lite_languages_directory', $mi_mofile4 );
369
-
370
- if ( file_exists( $mi_mofile1 ) ) {
371
- load_textdomain( 'google-analytics-for-wordpress', $mi_mofile1 );
372
- } elseif ( file_exists( $mi_mofile2 ) ) {
373
- load_textdomain( 'google-analytics-for-wordpress', $mi_mofile2 );
374
- } elseif ( file_exists( $mi_mofile3 ) ) {
375
- load_textdomain( 'google-analytics-for-wordpress', $mi_mofile3 );
376
- } else {
377
- load_plugin_textdomain( 'google-analytics-for-wordpress', false, $mi_mofile4 );
378
- }
379
-
380
- }
381
-
382
- /**
383
- * Output a nag notice if the user has an out of date WP version installed
384
- *
385
- * @access public
386
- * @since 6.0.0
387
- *
388
- * @return void
389
- */
390
- public function monsterinsights_wp_notice() {
391
- $url = admin_url( 'plugins.php' );
392
- // Check for MS dashboard
393
- if( is_network_admin() ) {
394
- $url = network_admin_url( 'plugins.php' );
395
- }
396
- ?>
397
- <div class="error">
398
- <p><?php echo sprintf( esc_html__( 'Sorry, but your version of WordPress does not meet MonsterInsights\'s required version of %1$s3.8%2$s to run properly. The plugin not been activated. %3$sClick here to return to the Dashboard%4$s.', 'google-analytics-for-wordpress' ), '<strong>', '</strong>', '<a href="' . $url . '">', '</a>' ); ?></p>
399
- </div>
400
- <?php
401
- }
402
-
403
- /**
404
- * Output a nag notice if the user has both Lite and Pro activated
405
- *
406
- * @access public
407
- * @since 6.0.0
408
- *
409
- * @return void
410
- */
411
- public function monsterinsights_pro_notice() {
412
- $url = admin_url( 'plugins.php' );
413
- // Check for MS dashboard
414
- if( is_network_admin() ) {
415
- $url = network_admin_url( 'plugins.php' );
416
- }
417
- ?>
418
- <div class="error">
419
- <p><?php echo sprintf( esc_html__( 'Please %1$suninstall%2$s the MonsterInsights Lite Plugin. Your Pro version of MonsterInsights may not work as expected until the Lite version is uninstalled.', 'google-analytics-for-wordpress' ), '<a href="' . $url . '">', '</a>' ); ?></p>
420
- </div>
421
- <?php
422
-
423
- }
424
-
425
- /**
426
- * Loads MonsterInsights settings
427
- *
428
- * Adds the items to the base object, and adds the helper functions.
429
- *
430
- * @since 6.0.0
431
- * @access public
432
- *
433
- * @return void
434
- */
435
- public function load_settings() {
436
- global $monsterinsights_settings;
437
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/options.php';
438
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/helpers.php';
439
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/deprecated.php';
440
- $monsterinsights_settings = monsterinsights_get_options();
441
- }
442
-
443
-
444
- /**
445
- * Loads MonsterInsights License
446
- *
447
- * Loads license class used by MonsterInsights
448
- *
449
- * @since 7.0.0
450
- * @access public
451
- *
452
- * @return void
453
- */
454
- public function load_licensing(){
455
- if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
456
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/license-compat.php';
457
- self::$instance->license = new MonsterInsights_License_Compat();
458
- }
459
- }
460
-
461
- /**
462
- * Loads MonsterInsights Auth
463
- *
464
- * Loads auth used by MonsterInsights
465
- *
466
- * @since 7.0.0
467
- * @access public
468
- *
469
- * @return void
470
- */
471
- public function load_auth() {
472
- if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
473
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/auth.php';
474
- self::$instance->auth = new MonsterInsights_Auth();
475
- }
476
- }
477
-
478
- /**
479
- * Loads all files into scope.
480
- *
481
- * @access public
482
- * @since 6.0.0
483
- *
484
- * @return void
485
- */
486
- public function require_files() {
487
-
488
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/capabilities.php';
489
-
490
- if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
491
-
492
- // Lite and Pro files
493
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'assets/lib/pandora/class-am-notification.php';
494
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'assets/lib/pandora/class-am-deactivation-survey.php';
495
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/ajax.php';
496
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/admin.php';
497
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/common.php';
498
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/notice.php';
499
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/licensing/autoupdate.php';
500
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/review.php';
501
-
502
- // Pages
503
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/settings.php';
504
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/tools.php';
505
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/reports.php';
506
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/addons.php';
507
-
508
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/api-auth.php';
509
-
510
- // Reports
511
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/reports/abstract-report.php';
512
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/reports/overview.php';
513
-
514
- // Reporting Functionality
515
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/reporting.php';
516
-
517
- // Routes used by Vue
518
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/routes.php';
519
- }
520
-
521
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/api-request.php';
522
-
523
- if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
524
- // Late loading classes (self instantiating)
525
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/tracking.php';
526
- }
527
-
528
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/frontend/frontend.php';
529
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/frontend/seedprod.php';
530
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/measurement-protocol.php';
531
- }
532
- }
533
-
534
- /**
535
- * Fired when the plugin is activated.
536
- *
537
- * @access public
538
- * @since 6.0.0
539
- *
540
- * @global int $wp_version The version of WordPress for this install.
541
- * @global object $wpdb The WordPress database object.
542
- * @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false otherwise.
543
- *
544
- * @return void
545
- */
546
- function monsterinsights_lite_activation_hook( $network_wide ) {
547
-
548
- global $wp_version;
549
-
550
- $url = admin_url( 'plugins.php' );
551
- // Check for MS dashboard
552
- if ( is_network_admin() ) {
553
- $url = network_admin_url( 'plugins.php' );
554
- }
555
-
556
- if ( version_compare( $wp_version, '3.8', '<' ) && ( ! defined( 'MONSTERINSIGHTS_FORCE_ACTIVATION' ) || ! MONSTERINSIGHTS_FORCE_ACTIVATION ) ) {
557
- deactivate_plugins( plugin_basename( __FILE__ ) );
558
- wp_die( sprintf( esc_html__( 'Sorry, but your version of WordPress does not meet MonsterInsight\'s required version of %1$s3.8%2$s to run properly. The plugin not been activated. %3$sClick here to return to the Dashboard%4$s.', 'google-analytics-by-wordpress' ), '<strong>', '</strong>', '<a href="' . $url . '">', '</a>' ) );
559
- }
560
-
561
- if ( class_exists( 'MonsterInsights' ) ) {
562
- deactivate_plugins( plugin_basename( __FILE__ ) );
563
- wp_die( sprintf( esc_html__( 'Please uninstall and remove MonsterInsights Pro before activating Google Analytics for WordPress by MonsterInsights. The Lite version has not been activated. %1$sClick here to return to the Dashboard%2$s.', 'google-analytics-by-wordpress' ), '<a href="' . $url . '">', '</a>' ) );
564
- }
565
-
566
- // Add transient to trigger redirect.
567
- set_transient( '_monsterinsights_activation_redirect', 1, 30 );
568
- }
569
- register_activation_hook( __FILE__, 'monsterinsights_lite_activation_hook' );
570
-
571
- /**
572
- * Fired when the plugin is uninstalled.
573
- *
574
- * @access public
575
- * @since 6.0.0
576
- *
577
- * @return void
578
- */
579
- function monsterinsights_lite_uninstall_hook() {
580
- wp_cache_flush();
581
-
582
- // Note, if both MI Pro and Lite are active, this is an MI Pro instance
583
- // Therefore MI Lite can only use functions of the instance common to
584
- // both plugins. If it needs to be pro specific, then include a file that
585
- // has that method.
586
- $instance = MonsterInsights();
587
-
588
- // If uninstalling via wp-cli load admin-specific files only here.
589
- if ( defined( 'WP_CLI' ) && WP_CLI ) {
590
- define( 'WP_ADMIN', true );
591
- $instance->require_files();
592
- $instance->load_auth();
593
- $instance->notices = new MonsterInsights_Notice_Admin();
594
- $instance->reporting = new MonsterInsights_Reporting();
595
- $instance->api_auth = new MonsterInsights_API_Auth();
596
- }
597
-
598
- // Don't delete any data if the PRO version is already active.
599
- if ( monsterinsights_is_pro_version() ) {
600
- return;
601
- }
602
-
603
- if ( is_multisite() ) {
604
- $site_list = get_sites();
605
- foreach ( (array) $site_list as $site ) {
606
- switch_to_blog( $site->blog_id );
607
-
608
- // Delete auth
609
- $instance->api_auth->delete_auth();
610
-
611
- // Delete data
612
- $instance->reporting->delete_aggregate_data('site');
613
-
614
- restore_current_blog();
615
- }
616
- // Delete network auth using a custom function as some variables are not initiated.
617
- $instance->api_auth->uninstall_network_auth();
618
-
619
- // Delete network data
620
- $instance->reporting->delete_aggregate_data('network');
621
- } else {
622
- // Delete auth
623
- $instance->api_auth->delete_auth();
624
-
625
- // Delete data
626
- $instance->reporting->delete_aggregate_data('site');
627
- }
628
-
629
- }
630
- register_uninstall_hook( __FILE__, 'monsterinsights_lite_uninstall_hook' );
631
-
632
- /**
633
- * The main function responsible for returning the one true MonsterInsights_Lite
634
- * Instance to functions everywhere.
635
- *
636
- * Use this function like you would a global variable, except without needing
637
- * to declare the global.
638
- *
639
- * Example: <?php $monsterinsights = MonsterInsights_Lite(); ?>
640
- *
641
- * @since 6.0.0
642
- *
643
- * @uses MonsterInsights_Lite::get_instance() Retrieve MonsterInsights_Lite instance.
644
- *
645
- * @return MonsterInsights_Lite The singleton MonsterInsights_Lite instance.
646
- */
647
- function MonsterInsights_Lite() {
648
- return MonsterInsights_Lite::get_instance();
649
- }
650
-
651
- /**
652
- * MonsterInsights Install and Updates.
653
- *
654
- * This function is used install and upgrade MonsterInsights. This is used for upgrade routines
655
- * that can be done automatically, behind the scenes without the need for user interaction
656
- * (for example pagination or user input required), as well as the initial install.
657
- *
658
- * @since 6.0.0
659
- * @access public
660
- *
661
- * @global string $wp_version WordPress version (provided by WordPress core).
662
- * @uses MonsterInsights_Lite::load_settings() Loads MonsterInsights settings
663
- * @uses MonsterInsights_Install::init() Runs upgrade process
664
- *
665
- * @return void
666
- */
667
- function monsterinsights_lite_install_and_upgrade() {
668
- global $wp_version;
669
-
670
- // If the WordPress site doesn't meet the correct WP version requirements, don't activate MonsterInsights
671
- if ( version_compare( $wp_version, '3.8', '<' ) ) {
672
- if ( is_plugin_active( plugin_basename( __FILE__ ) ) ) {
673
- return;
674
- }
675
- }
676
-
677
- // Don't run if MI Pro is installed
678
- if ( class_exists( 'MonsterInsights' ) ) {
679
- if ( is_plugin_active( plugin_basename( __FILE__ ) ) ) {
680
- return;
681
- }
682
- }
683
-
684
-
685
- // Load settings and globals (so we can use/set them during the upgrade process)
686
- MonsterInsights_Lite()->define_globals();
687
- MonsterInsights_Lite()->load_settings();
688
-
689
- // Load in Auth
690
- MonsterInsights()->load_auth();
691
-
692
- // Load upgrade file
693
- require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/install.php';
694
-
695
- // Run the MonsterInsights upgrade routines
696
- $updates = new MonsterInsights_Install();
697
- $updates->init();
698
- }
699
-
700
- /**
701
- * MonsterInsights check for install and update processes.
702
- *
703
- * This function is used to call the MonsterInsights automatic upgrade class, which in turn
704
- * checks to see if there are any update procedures to be run, and if
705
- * so runs them. Also installs MonsterInsights for the first time.
706
- *
707
- * @since 6.0.0
708
- * @access public
709
- *
710
- * @uses MonsterInsights_Install() Runs install and upgrade process.
711
- *
712
- * @return void
713
- */
714
- function monsterinsights_lite_call_install_and_upgrade(){
715
- add_action( 'wp_loaded', 'monsterinsights_lite_install_and_upgrade' );
716
- }
717
-
718
- /**
719
- * Returns the MonsterInsights combined object that you can use for both
720
- * MonsterInsights Lite and Pro Users. When both plugins active, defers to the
721
- * more complete Pro object.
722
- *
723
- * Warning: Do not use this in Lite or Pro specific code (use the individual objects instead).
724
- * Also do not use in the MonsterInsights Lite/Pro upgrade and install routines.
725
- *
726
- * Use this function like you would a global variable, except without needing
727
- * to declare the global.
728
- *
729
- * Prevents the need to do conditional global object logic when you have code that you want to work with
730
- * both Pro and Lite.
731
- *
732
- * Example: <?php $monsterinsights = MonsterInsights(); ?>
733
- *
734
- * @since 6.0.0
735
- *
736
- * @uses MonsterInsights::get_instance() Retrieve MonsterInsights Pro instance.
737
- * @uses MonsterInsights_Lite::get_instance() Retrieve MonsterInsights Lite instance.
738
- *
739
- * @return MonsterInsights The singleton MonsterInsights instance.
740
- */
741
- if ( ! function_exists( 'MonsterInsights' ) ) {
742
- function MonsterInsights() {
743
- return ( class_exists( 'MonsterInsights' ) ? MonsterInsights_Pro() : MonsterInsights_Lite() );
744
- }
745
- add_action( 'plugins_loaded', 'MonsterInsights' );
746
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: Google Analytics for WordPress by MonsterInsights
4
+ * Plugin URI: https://www.monsterinsights.com/?utm_source=liteplugin&utm_medium=pluginheader&utm_campaign=pluginurl&utm_content=7%2E0%2E0
5
+ * Description: The best Google Analytics plugin for WordPress. See how visitors find and use your website, so you can keep them coming back.
6
+ * Author: MonsterInsights
7
+ * Author URI: https://www.monsterinsights.com/?utm_source=liteplugin&utm_medium=pluginheader&utm_campaign=authoruri&utm_content=7%2E0%2E0
8
+ *
9
+ * Version: 7.11.0
10
+ * Requires at least: 3.8.0
11
+ *
12
+ * License: GPL v3
13
+ *
14
+ * Text Domain: google-analytics-for-wordpress
15
+ * Domain Path: /languages
16
+ *
17
+ * MonsterInsights Lite
18
+ * Copyright (C) 2008-2018, MonsterInsights, support@monsterinsights.com
19
+ *
20
+ * This program is free software: you can redistribute it and/or modify
21
+ * it under the terms of the GNU General Public License as published by
22
+ * the Free Software Foundation, either version 3 of the License, or
23
+ * (at your option) any later version.
24
+ *
25
+ * This program is distributed in the hope that it will be useful,
26
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28
+ * GNU General Public License for more details.
29
+ *
30
+ * You should have received a copy of the GNU General Public License
31
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
32
+ *
33
+ * @category Plugin
34
+ * @copyright Copyright © 2018 Chris Christoff
35
+ * @author Chris Christoff
36
+ * @package MonsterInsights
37
+ */
38
+
39
+ // Exit if accessed directly.
40
+ if ( ! defined( 'ABSPATH' ) ) {
41
+ exit;
42
+ }
43
+
44
+ /**
45
+ * Main plugin class.
46
+ *
47
+ * @since 6.0.0
48
+ *
49
+ * @package MonsterInsights
50
+ * @author Chris Christoff
51
+ * @access public
52
+ */
53
+ final class MonsterInsights_Lite {
54
+
55
+ /**
56
+ * Holds the class object.
57
+ *
58
+ * @since 6.0.0
59
+ * @access public
60
+ * @var object Instance of instantiated MonsterInsights class.
61
+ */
62
+ public static $instance;
63
+
64
+ /**
65
+ * Plugin version, used for cache-busting of style and script file references.
66
+ *
67
+ * @since 6.0.0
68
+ * @access public
69
+ * @var string $version Plugin version.
70
+ */
71
+ public $version = '7.11.0';
72
+
73
+ /**
74
+ * Plugin file.
75
+ *
76
+ * @since 6.0.0
77
+ * @access public
78
+ * @var string $file PHP File constant for main file.
79
+ */
80
+ public $file;
81
+
82
+ /**
83
+ * The name of the plugin.
84
+ *
85
+ * @since 6.0.0
86
+ * @access public
87
+ * @var string $plugin_name Plugin name.
88
+ */
89
+ public $plugin_name = 'MonsterInsights Lite';
90
+
91
+ /**
92
+ * Unique plugin slug identifier.
93
+ *
94
+ * @since 6.0.0
95
+ * @access public
96
+ * @var string $plugin_slug Plugin slug.
97
+ */
98
+ public $plugin_slug = 'monsterinsights-lite';
99
+
100
+ /**
101
+ * Holds instance of MonsterInsights License class.
102
+ *
103
+ * @since 6.0.0
104
+ * @access public
105
+ * @var MonsterInsights_License $license Instance of License class.
106
+ */
107
+ protected $license;
108
+
109
+ /**
110
+ * Holds instance of MonsterInsights Admin Notice class.
111
+ *
112
+ * @since 6.0.0
113
+ * @access public
114
+ * @var MonsterInsights_Admin_Notice $notices Instance of Admin Notice class.
115
+ */
116
+ public $notices;
117
+
118
+ /**
119
+ * Holds instance of MonsterInsights Reporting class.
120
+ *
121
+ * @since 6.0.0
122
+ * @access public
123
+ * @var MonsterInsights_Reporting $reporting Instance of Reporting class.
124
+ */
125
+ public $reporting;
126
+
127
+ /**
128
+ * Holds instance of MonsterInsights Notifications class.
129
+ *
130
+ * @since 7.11
131
+ * @access public
132
+ * @var MonsterInsights_Notifications $notifications Instance of Notifications class.
133
+ */
134
+ public $notifications;
135
+
136
+ /**
137
+ * Holds instance of MonsterInsights Auth class.
138
+ *
139
+ * @since 7.0.0
140
+ * @access public
141
+ * @var MonsterInsights_Auth $auth Instance of Auth class.
142
+ */
143
+ protected $auth;
144
+
145
+ /**
146
+ * Holds instance of MonsterInsights API Auth class.
147
+ *
148
+ * @since 6.0.0
149
+ * @access public
150
+ * @var MonsterInsights_Auth $api_auth Instance of APIAuth class.
151
+ */
152
+ public $api_auth;
153
+
154
+ /**
155
+ * Holds instance of MonsterInsights API Rest Routes class.
156
+ *
157
+ * @since 7.4.0
158
+ * @access public
159
+ * @var MonsterInsights_Rest_Routes $routes Instance of rest routes.
160
+ */
161
+ public $routes;
162
+
163
+ /**
164
+ * Primary class constructor.
165
+ *
166
+ * @since 6.0.0
167
+ * @access public
168
+ */
169
+ public function __construct() {
170
+ // We don't use this
171
+ }
172
+
173
+ /**
174
+ * Returns the singleton instance of the class.
175
+ *
176
+ * @access public
177
+ * @since 6.0.0
178
+ *
179
+ * @return object The MonsterInsights_Lite object.
180
+ */
181
+ public static function get_instance() {
182
+
183
+ if ( ! isset( self::$instance ) && ! ( self::$instance instanceof MonsterInsights_Lite ) ) {
184
+ self::$instance = new MonsterInsights_Lite();
185
+ self::$instance->file = __FILE__;
186
+
187
+ global $wp_version;
188
+
189
+ // Detect non-supported WordPress version and return early
190
+ if ( version_compare( $wp_version, '3.8', '<' ) && ( ! defined( 'MONSTERINSIGHTS_FORCE_ACTIVATION' ) || ! MONSTERINSIGHTS_FORCE_ACTIVATION ) ) {
191
+ add_action( 'admin_notices', array( self::$instance, 'monsterinsights_wp_notice' ) );
192
+ return;
193
+ }
194
+
195
+ // Detect Pro version and return early
196
+ if ( defined( 'MONSTERINSIGHTS_PRO_VERSION' ) ) {
197
+ add_action( 'admin_notices', array( self::$instance, 'monsterinsights_pro_notice' ) );
198
+ return;
199
+ }
200
+
201
+ // Define constants
202
+ self::$instance->define_globals();
203
+
204
+ // Load in settings
205
+ self::$instance->load_settings();
206
+
207
+ // Load in Licensing
208
+ self::$instance->load_licensing();
209
+
210
+ // Load in Auth
211
+ self::$instance->load_auth();
212
+
213
+ // Load files
214
+ self::$instance->require_files();
215
+
216
+ // This does the version to version background upgrade routines and initial install
217
+ $mi_version = get_option( 'monsterinsights_current_version', '5.5.3' );
218
+ if ( version_compare( $mi_version, '7.11.0', '<' ) ) {
219
+ monsterinsights_lite_call_install_and_upgrade();
220
+ }
221
+
222
+ if ( is_admin() ) {
223
+ new AM_Deactivation_Survey( 'MonsterInsights', basename( dirname( __FILE__ ) ) );
224
+ }
225
+
226
+ // Load the plugin textdomain.
227
+ add_action( 'plugins_loaded', array( self::$instance, 'load_plugin_textdomain' ) );
228
+
229
+ // Load admin only components.
230
+ if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
231
+ self::$instance->notices = new MonsterInsights_Notice_Admin();
232
+ self::$instance->reporting = new MonsterInsights_Reporting();
233
+ self::$instance->api_auth = new MonsterInsights_API_Auth();
234
+ self::$instance->routes = new MonsterInsights_Rest_Routes();
235
+ self::$instance->notifications = new MonsterInsights_Notifications();
236
+ }
237
+
238
+ if ( monsterinsights_is_pro_version() ) {
239
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'pro/includes/load.php';
240
+ } else {
241
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/load.php';
242
+ }
243
+
244
+ // Run hook to load MonsterInsights addons.
245
+ do_action( 'monsterinsights_load_plugins' ); // the updater class for each addon needs to be instantiated via `monsterinsights_updater`
246
+ }
247
+
248
+ return self::$instance;
249
+
250
+ }
251
+
252
+ /**
253
+ * Throw error on object clone
254
+ *
255
+ * The whole idea of the singleton design pattern is that there is a single
256
+ * object therefore, we don't want the object to be cloned.
257
+ *
258
+ * @since 6.0.0
259
+ * @access public
260
+ *
261
+ * @return void
262
+ */
263
+ public function __clone() {
264
+ _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'google-analytics-for-wordpress' ), '6.0.0' );
265
+ }
266
+
267
+ /**
268
+ * Disable unserializing of the class
269
+ *
270
+ * Attempting to wakeup an MonsterInsights instance will throw a doing it wrong notice.
271
+ *
272
+ * @since 6.0.0
273
+ * @access public
274
+ *
275
+ * @return void
276
+ */
277
+ public function __wakeup() {
278
+ _doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'google-analytics-for-wordpress' ), '6.0.0' );
279
+ }
280
+
281
+ /**
282
+ * Magic get function.
283
+ *
284
+ * We use this to lazy load certain functionality. Right now used to lazyload
285
+ * the API & Auth frontend, so it's only loaded if user is using a plugin
286
+ * that requires it.
287
+ *
288
+ * @since 7.0.0
289
+ * @access public
290
+ *
291
+ * @return void
292
+ */
293
+ public function __get( $key ) {
294
+ if ( $key === 'auth' ) {
295
+ if ( empty( self::$instance->auth ) ) {
296
+ // LazyLoad Auth for Frontend
297
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/auth.php';
298
+ self::$instance->auth = new MonsterInsights_Auth();
299
+ }
300
+ return self::$instance->$key;
301
+ } else {
302
+ return self::$instance->$key;
303
+ }
304
+ }
305
+
306
+ /**
307
+ * Define MonsterInsights constants.
308
+ *
309
+ * This function defines all of the MonsterInsights PHP constants.
310
+ *
311
+ * @since 6.0.0
312
+ * @access public
313
+ *
314
+ * @return void
315
+ */
316
+ public function define_globals() {
317
+
318
+ if ( ! defined( 'MONSTERINSIGHTS_VERSION' ) ) {
319
+ define( 'MONSTERINSIGHTS_VERSION', $this->version );
320
+ }
321
+
322
+ if ( ! defined( 'MONSTERINSIGHTS_LITE_VERSION' ) ) {
323
+ define( 'MONSTERINSIGHTS_LITE_VERSION', MONSTERINSIGHTS_VERSION );
324
+ }
325
+
326
+ if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_NAME' ) ) {
327
+ define( 'MONSTERINSIGHTS_PLUGIN_NAME', $this->plugin_name );
328
+ }
329
+
330
+ if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_SLUG' ) ) {
331
+ define( 'MONSTERINSIGHTS_PLUGIN_SLUG', $this->plugin_slug );
332
+ }
333
+
334
+ if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_FILE' ) ) {
335
+ define( 'MONSTERINSIGHTS_PLUGIN_FILE', $this->file );
336
+ }
337
+
338
+ if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_DIR' ) ) {
339
+ define( 'MONSTERINSIGHTS_PLUGIN_DIR', plugin_dir_path( $this->file ) );
340
+ }
341
+
342
+ if ( ! defined( 'MONSTERINSIGHTS_PLUGIN_URL' ) ) {
343
+ define( 'MONSTERINSIGHTS_PLUGIN_URL', plugin_dir_url( $this->file ) );
344
+ }
345
+ }
346
+
347
+ /**
348
+ * Loads the plugin textdomain for translation.
349
+ *
350
+ * @access public
351
+ * @since 6.0.0
352
+ *
353
+ * @return void
354
+ */
355
+ public function load_plugin_textdomain() {
356
+
357
+ $mi_locale = get_locale();
358
+ if ( function_exists( 'get_user_locale' ) ) {
359
+ $mi_locale = get_user_locale();
360
+ }
361
+
362
+ // Traditional WordPress plugin locale filter.
363
+ $mi_locale = apply_filters( 'plugin_locale', $mi_locale, 'google-analytics-for-wordpress' );
364
+ $mi_mofile = sprintf( '%1$s-%2$s.mo', 'google-analytics-for-wordpress', $mi_locale );
365
+
366
+ // Look for wp-content/languages/google-analytics-for-wordpress/google-analytics-for-wordpress-{lang}_{country}.mo
367
+ $mi_mofile1 = WP_LANG_DIR . '/google-analytics-for-wordpress/' . $mi_mofile;
368
+
369
+ // Look in wp-content/languages/plugins/google-analytics-for-wordpress/google-analytics-for-wordpress-{lang}_{country}.mo
370
+ $mi_mofile2 = WP_LANG_DIR . '/plugins/google-analytics-for-wordpress/' . $mi_mofile;
371
+
372
+ // Look in wp-content/languages/plugins/google-analytics-for-wordpress-{lang}_{country}.mo
373
+ $mi_mofile3 = WP_LANG_DIR . '/plugins/' . $mi_mofile;
374
+
375
+ // Look in wp-content/plugins/google-analytics-for-wordpress/languages/google-analytics-for-wordpress-{lang}_{country}.mo
376
+ $mi_mofile4 = dirname( plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ) ) . '/languages/';
377
+ $mi_mofile4 = apply_filters( 'monsterinsights_lite_languages_directory', $mi_mofile4 );
378
+
379
+ if ( file_exists( $mi_mofile1 ) ) {
380
+ load_textdomain( 'google-analytics-for-wordpress', $mi_mofile1 );
381
+ } elseif ( file_exists( $mi_mofile2 ) ) {
382
+ load_textdomain( 'google-analytics-for-wordpress', $mi_mofile2 );
383
+ } elseif ( file_exists( $mi_mofile3 ) ) {
384
+ load_textdomain( 'google-analytics-for-wordpress', $mi_mofile3 );
385
+ } else {
386
+ load_plugin_textdomain( 'google-analytics-for-wordpress', false, $mi_mofile4 );
387
+ }
388
+
389
+ }
390
+
391
+ /**
392
+ * Output a nag notice if the user has an out of date WP version installed
393
+ *
394
+ * @access public
395
+ * @since 6.0.0
396
+ *
397
+ * @return void
398
+ */
399
+ public function monsterinsights_wp_notice() {
400
+ $url = admin_url( 'plugins.php' );
401
+ // Check for MS dashboard
402
+ if( is_network_admin() ) {
403
+ $url = network_admin_url( 'plugins.php' );
404
+ }
405
+ ?>
406
+ <div class="error">
407
+ <p><?php echo sprintf( esc_html__( 'Sorry, but your version of WordPress does not meet MonsterInsights\'s required version of %1$s3.8%2$s to run properly. The plugin not been activated. %3$sClick here to return to the Dashboard%4$s.', 'google-analytics-for-wordpress' ), '<strong>', '</strong>', '<a href="' . $url . '">', '</a>' ); ?></p>
408
+ </div>
409
+ <?php
410
+ }
411
+
412
+ /**
413
+ * Output a nag notice if the user has both Lite and Pro activated
414
+ *
415
+ * @access public
416
+ * @since 6.0.0
417
+ *
418
+ * @return void
419
+ */
420
+ public function monsterinsights_pro_notice() {
421
+ $url = admin_url( 'plugins.php' );
422
+ // Check for MS dashboard
423
+ if( is_network_admin() ) {
424
+ $url = network_admin_url( 'plugins.php' );
425
+ }
426
+ ?>
427
+ <div class="error">
428
+ <p><?php echo sprintf( esc_html__( 'Please %1$suninstall%2$s the MonsterInsights Lite Plugin. Your Pro version of MonsterInsights may not work as expected until the Lite version is uninstalled.', 'google-analytics-for-wordpress' ), '<a href="' . $url . '">', '</a>' ); ?></p>
429
+ </div>
430
+ <?php
431
+
432
+ }
433
+
434
+ /**
435
+ * Loads MonsterInsights settings
436
+ *
437
+ * Adds the items to the base object, and adds the helper functions.
438
+ *
439
+ * @since 6.0.0
440
+ * @access public
441
+ *
442
+ * @return void
443
+ */
444
+ public function load_settings() {
445
+ global $monsterinsights_settings;
446
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/options.php';
447
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/helpers.php';
448
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/deprecated.php';
449
+ $monsterinsights_settings = monsterinsights_get_options();
450
+ }
451
+
452
+
453
+ /**
454
+ * Loads MonsterInsights License
455
+ *
456
+ * Loads license class used by MonsterInsights
457
+ *
458
+ * @since 7.0.0
459
+ * @access public
460
+ *
461
+ * @return void
462
+ */
463
+ public function load_licensing(){
464
+ if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
465
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'lite/includes/license-compat.php';
466
+ self::$instance->license = new MonsterInsights_License_Compat();
467
+ }
468
+ }
469
+
470
+ /**
471
+ * Loads MonsterInsights Auth
472
+ *
473
+ * Loads auth used by MonsterInsights
474
+ *
475
+ * @since 7.0.0
476
+ * @access public
477
+ *
478
+ * @return void
479
+ */
480
+ public function load_auth() {
481
+ if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
482
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/auth.php';
483
+ self::$instance->auth = new MonsterInsights_Auth();
484
+ }
485
+ }
486
+
487
+ /**
488
+ * Loads all files into scope.
489
+ *
490
+ * @access public
491
+ * @since 6.0.0
492
+ *
493
+ * @return void
494
+ */
495
+ public function require_files() {
496
+
497
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/capabilities.php';
498
+
499
+ if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
500
+
501
+ // Lite and Pro files
502
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'assets/lib/pandora/class-am-deactivation-survey.php';
503
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/ajax.php';
504
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/admin.php';
505
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/common.php';
506
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/notice.php';
507
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/licensing/autoupdate.php';
508
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/review.php';
509
+
510
+ // Pages
511
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/settings.php';
512
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/tools.php';
513
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/reports.php';
514
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/pages/addons.php';
515
+
516
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/api-auth.php';
517
+
518
+ // Reports
519
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/reports/abstract-report.php';
520
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/reports/overview.php';
521
+
522
+ // Reporting Functionality
523
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/reporting.php';
524
+
525
+ // Routes used by Vue
526
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/routes.php';
527
+
528
+ // Emails
529
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/emails/class-emails.php';
530
+
531
+ // Notifications class.
532
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/notifications.php';
533
+ }
534
+
535
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/api-request.php';
536
+
537
+ if ( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
538
+ // Late loading classes (self instantiating)
539
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/admin/tracking.php';
540
+ }
541
+
542
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/frontend/frontend.php';
543
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/frontend/seedprod.php';
544
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/measurement-protocol.php';
545
+ }
546
+ }
547
+
548
+ /**
549
+ * Fired when the plugin is activated.
550
+ *
551
+ * @access public
552
+ * @since 6.0.0
553
+ *
554
+ * @global int $wp_version The version of WordPress for this install.
555
+ * @global object $wpdb The WordPress database object.
556
+ * @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false otherwise.
557
+ *
558
+ * @return void
559
+ */
560
+ function monsterinsights_lite_activation_hook( $network_wide ) {
561
+
562
+ global $wp_version;
563
+
564
+ $url = admin_url( 'plugins.php' );
565
+ // Check for MS dashboard
566
+ if ( is_network_admin() ) {
567
+ $url = network_admin_url( 'plugins.php' );
568
+ }
569
+
570
+ if ( version_compare( $wp_version, '3.8', '<' ) && ( ! defined( 'MONSTERINSIGHTS_FORCE_ACTIVATION' ) || ! MONSTERINSIGHTS_FORCE_ACTIVATION ) ) {
571
+ deactivate_plugins( plugin_basename( __FILE__ ) );
572
+ wp_die( sprintf( esc_html__( 'Sorry, but your version of WordPress does not meet MonsterInsight\'s required version of %1$s3.8%2$s to run properly. The plugin not been activated. %3$sClick here to return to the Dashboard%4$s.', 'google-analytics-by-wordpress' ), '<strong>', '</strong>', '<a href="' . $url . '">', '</a>' ) );
573
+ }
574
+
575
+ if ( class_exists( 'MonsterInsights' ) ) {
576
+ deactivate_plugins( plugin_basename( __FILE__ ) );
577
+ wp_die( sprintf( esc_html__( 'Please uninstall and remove MonsterInsights Pro before activating Google Analytics for WordPress by MonsterInsights. The Lite version has not been activated. %1$sClick here to return to the Dashboard%2$s.', 'google-analytics-by-wordpress' ), '<a href="' . $url . '">', '</a>' ) );
578
+ }
579
+
580
+ // Add transient to trigger redirect.
581
+ set_transient( '_monsterinsights_activation_redirect', 1, 30 );
582
+ }
583
+ register_activation_hook( __FILE__, 'monsterinsights_lite_activation_hook' );
584
+
585
+ /**
586
+ * Fired when the plugin is uninstalled.
587
+ *
588
+ * @access public
589
+ * @since 6.0.0
590
+ *
591
+ * @return void
592
+ */
593
+ function monsterinsights_lite_uninstall_hook() {
594
+ wp_cache_flush();
595
+
596
+ // Note, if both MI Pro and Lite are active, this is an MI Pro instance
597
+ // Therefore MI Lite can only use functions of the instance common to
598
+ // both plugins. If it needs to be pro specific, then include a file that
599
+ // has that method.
600
+ $instance = MonsterInsights();
601
+
602
+ // If uninstalling via wp-cli load admin-specific files only here.
603
+ if ( defined( 'WP_CLI' ) && WP_CLI ) {
604
+ define( 'WP_ADMIN', true );
605
+ $instance->require_files();
606
+ $instance->load_auth();
607
+ $instance->notices = new MonsterInsights_Notice_Admin();
608
+ $instance->reporting = new MonsterInsights_Reporting();
609
+ $instance->api_auth = new MonsterInsights_API_Auth();
610
+ }
611
+
612
+ // Don't delete any data if the PRO version is already active.
613
+ if ( monsterinsights_is_pro_version() ) {
614
+ return;
615
+ }
616
+
617
+ if ( is_multisite() ) {
618
+ $site_list = get_sites();
619
+ foreach ( (array) $site_list as $site ) {
620
+ switch_to_blog( $site->blog_id );
621
+
622
+ // Delete auth
623
+ $instance->api_auth->delete_auth();
624
+
625
+ // Delete data
626
+ $instance->reporting->delete_aggregate_data('site');
627
+
628
+ restore_current_blog();
629
+ }
630
+ // Delete network auth using a custom function as some variables are not initiated.
631
+ $instance->api_auth->uninstall_network_auth();
632
+
633
+ // Delete network data
634
+ $instance->reporting->delete_aggregate_data('network');
635
+ } else {
636
+ // Delete auth
637
+ $instance->api_auth->delete_auth();
638
+
639
+ // Delete data
640
+ $instance->reporting->delete_aggregate_data('site');
641
+ }
642
+
643
+ }
644
+ register_uninstall_hook( __FILE__, 'monsterinsights_lite_uninstall_hook' );
645
+
646
+ /**
647
+ * The main function responsible for returning the one true MonsterInsights_Lite
648
+ * Instance to functions everywhere.
649
+ *
650
+ * Use this function like you would a global variable, except without needing
651
+ * to declare the global.
652
+ *
653
+ * Example: <?php $monsterinsights = MonsterInsights_Lite(); ?>
654
+ *
655
+ * @since 6.0.0
656
+ *
657
+ * @uses MonsterInsights_Lite::get_instance() Retrieve MonsterInsights_Lite instance.
658
+ *
659
+ * @return MonsterInsights_Lite The singleton MonsterInsights_Lite instance.
660
+ */
661
+ function MonsterInsights_Lite() {
662
+ return MonsterInsights_Lite::get_instance();
663
+ }
664
+
665
+ /**
666
+ * MonsterInsights Install and Updates.
667
+ *
668
+ * This function is used install and upgrade MonsterInsights. This is used for upgrade routines
669
+ * that can be done automatically, behind the scenes without the need for user interaction
670
+ * (for example pagination or user input required), as well as the initial install.
671
+ *
672
+ * @since 6.0.0
673
+ * @access public
674
+ *
675
+ * @global string $wp_version WordPress version (provided by WordPress core).
676
+ * @uses MonsterInsights_Lite::load_settings() Loads MonsterInsights settings
677
+ * @uses MonsterInsights_Install::init() Runs upgrade process
678
+ *
679
+ * @return void
680
+ */
681
+ function monsterinsights_lite_install_and_upgrade() {
682
+ global $wp_version;
683
+
684
+ // If the WordPress site doesn't meet the correct WP version requirements, don't activate MonsterInsights
685
+ if ( version_compare( $wp_version, '3.8', '<' ) ) {
686
+ if ( is_plugin_active( plugin_basename( __FILE__ ) ) ) {
687
+ return;
688
+ }
689
+ }
690
+
691
+ // Don't run if MI Pro is installed
692
+ if ( class_exists( 'MonsterInsights' ) ) {
693
+ if ( is_plugin_active( plugin_basename( __FILE__ ) ) ) {
694
+ return;
695
+ }
696
+ }
697
+
698
+
699
+ // Load settings and globals (so we can use/set them during the upgrade process)
700
+ MonsterInsights_Lite()->define_globals();
701
+ MonsterInsights_Lite()->load_settings();
702
+
703
+ // Load in Auth
704
+ MonsterInsights()->load_auth();
705
+
706
+ // Load upgrade file
707
+ require_once MONSTERINSIGHTS_PLUGIN_DIR . 'includes/install.php';
708
+
709
+ // Run the MonsterInsights upgrade routines
710
+ $updates = new MonsterInsights_Install();
711
+ $updates->init();
712
+ }
713
+
714
+ /**
715
+ * MonsterInsights check for install and update processes.
716
+ *
717
+ * This function is used to call the MonsterInsights automatic upgrade class, which in turn
718
+ * checks to see if there are any update procedures to be run, and if
719
+ * so runs them. Also installs MonsterInsights for the first time.
720
+ *
721
+ * @since 6.0.0
722
+ * @access public
723
+ *
724
+ * @uses MonsterInsights_Install() Runs install and upgrade process.
725
+ *
726
+ * @return void
727
+ */
728
+ function monsterinsights_lite_call_install_and_upgrade(){
729
+ add_action( 'wp_loaded', 'monsterinsights_lite_install_and_upgrade' );
730
+ }
731
+
732
+ /**
733
+ * Returns the MonsterInsights combined object that you can use for both
734
+ * MonsterInsights Lite and Pro Users. When both plugins active, defers to the
735
+ * more complete Pro object.
736
+ *
737
+ * Warning: Do not use this in Lite or Pro specific code (use the individual objects instead).
738
+ * Also do not use in the MonsterInsights Lite/Pro upgrade and install routines.
739
+ *
740
+ * Use this function like you would a global variable, except without needing
741
+ * to declare the global.
742
+ *
743
+ * Prevents the need to do conditional global object logic when you have code that you want to work with
744
+ * both Pro and Lite.
745
+ *
746
+ * Example: <?php $monsterinsights = MonsterInsights(); ?>
747
+ *
748
+ * @since 6.0.0
749
+ *
750
+ * @uses MonsterInsights::get_instance() Retrieve MonsterInsights Pro instance.
751
+ * @uses MonsterInsights_Lite::get_instance() Retrieve MonsterInsights Lite instance.
752
+ *
753
+ * @return MonsterInsights The singleton MonsterInsights instance.
754
+ */
755
+ if ( ! function_exists( 'MonsterInsights' ) ) {
756
+ function MonsterInsights() {
757
+ return ( class_exists( 'MonsterInsights' ) ? MonsterInsights_Pro() : MonsterInsights_Lite() );
758
+ }
759
+ add_action( 'plugins_loaded', 'MonsterInsights' );
760
+ }
includes/admin/admin.php CHANGED
@@ -1,494 +1,538 @@
1
- <?php
2
- /**
3
- * Admin class.
4
- *
5
- * @since 6.0.0
6
- *
7
- * @package MonsterInsights
8
- * @subpackage Admin
9
- * @author Chris Christoff
10
- */
11
-
12
- // Exit if accessed directly
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
-
17
- /**
18
- * Register menu items for MonsterInsights.
19
- *
20
- * @since 6.0.0
21
- * @access public
22
- *
23
- * @return void
24
- */
25
- function monsterinsights_admin_menu() {
26
- $hook = monsterinsights_get_menu_hook();
27
- $menu_icon_inline = monsterinsights_get_inline_menu_icon();
28
-
29
- if ( $hook === 'monsterinsights_settings' ) {
30
- // If dashboards disabled, first settings page
31
- add_menu_page( __( 'MonsterInsights', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page', $menu_icon_inline, '100.00013467543' );
32
- $hook = 'monsterinsights_settings';
33
-
34
- add_submenu_page( $hook, __( 'MonsterInsights', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings' );
35
- } else {
36
- // if dashboards enabled, first dashboard
37
- add_menu_page( __( 'General:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page', $menu_icon_inline, '100.00013467543' );
38
-
39
- add_submenu_page( $hook, __( 'General Reports:', 'google-analytics-for-wordpress' ), __( 'Reports', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page' );
40
-
41
- // then settings page
42
- add_submenu_page( $hook, __( 'MonsterInsights', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page' );
43
-
44
- // Add dashboard submenu.
45
- add_submenu_page( 'index.php', __( 'General Reports:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'admin.php?page=monsterinsights_reports' );
46
- }
47
-
48
- $submenu_base = add_query_arg( 'page', 'monsterinsights_settings', admin_url( 'admin.php' ) );
49
-
50
- // then tools
51
- add_submenu_page( $hook, __( 'Tools:', 'google-analytics-for-wordpress' ), __( 'Tools', 'google-analytics-for-wordpress' ), 'manage_options', $submenu_base . '#/tools' );
52
-
53
- // then addons
54
- $network_key = monsterinsights_is_pro_version() ? MonsterInsights()->license->get_network_license_key() : '';
55
- if ( ! monsterinsights_is_network_active() || ( monsterinsights_is_network_active() && empty( $network_key ) ) ) {
56
- add_submenu_page( $hook, __( 'Addons:', 'google-analytics-for-wordpress' ), '<span style="color:' . monsterinsights_menu_highlight_color() . '"> ' . __( 'Addons', 'google-analytics-for-wordpress' ) . '</span>', 'monsterinsights_save_settings', $submenu_base . '#/addons' );
57
- }
58
-
59
- // Add About us page.
60
- add_submenu_page( $hook, __( 'About Us:', 'google-analytics-for-wordpress' ), __( 'About Us', 'google-analytics-for-wordpress' ), 'manage_options', $submenu_base . '#/about' );
61
- }
62
- add_action( 'admin_menu', 'monsterinsights_admin_menu' );
63
-
64
- function monsterinsights_get_menu_hook() {
65
- $dashboards_disabled = monsterinsights_get_option( 'dashboards_disabled', false );
66
- if ( $dashboards_disabled || ( current_user_can( 'monsterinsights_save_settings' ) && ! current_user_can( 'monsterinsights_view_dashboard' ) ) ) {
67
- return 'monsterinsights_settings';
68
- } else {
69
- return 'monsterinsights_reports';
70
- }
71
- }
72
-
73
- function monsterinsights_network_admin_menu() {
74
- // Get the base class object.
75
- $base = MonsterInsights();
76
-
77
- // First, let's see if this is an MS network enabled plugin. If it is, we should load the license
78
- // menu page and the updater on the network panel
79
- if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
80
- require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
81
- }
82
-
83
- $plugin = plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE );
84
- if ( ! is_plugin_active_for_network( $plugin ) ) {
85
- return;
86
- }
87
-
88
- $menu_icon_inline = monsterinsights_get_inline_menu_icon();
89
- $hook = 'monsterinsights_network';
90
- $submenu_base = add_query_arg( 'page', 'monsterinsights_network', network_admin_url( 'admin.php' ) );
91
- add_menu_page( __( 'Network Settings:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_network', 'monsterinsights_network_page', $menu_icon_inline, '100.00013467543' );
92
-
93
- add_submenu_page( $hook, __( 'Network Settings:', 'google-analytics-for-wordpress' ), __( 'Network Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_network', 'monsterinsights_network_page' );
94
-
95
- add_submenu_page( $hook, __( 'General Reports:', 'google-analytics-for-wordpress' ), __( 'Reports', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page' );
96
-
97
- // then addons
98
- add_submenu_page( $hook, __( 'Addons:', 'google-analytics-for-wordpress' ), '<span style="color:' . monsterinsights_menu_highlight_color() . '"> ' . __( 'Addons', 'google-analytics-for-wordpress' ) . '</span>', 'monsterinsights_save_settings', $submenu_base . '#/addons' );
99
-
100
- $submenu_base = add_query_arg( 'page', 'monsterinsights_network', network_admin_url( 'admin.php' ) );
101
-
102
- // Add About us page.
103
- add_submenu_page( $hook, __( 'About Us:', 'google-analytics-for-wordpress' ), __( 'About Us', 'google-analytics-for-wordpress' ), 'manage_options', $submenu_base . '#/about' );
104
- }
105
- add_action( 'network_admin_menu', 'monsterinsights_network_admin_menu', 5 );
106
-
107
- /**
108
- * Adds one or more classes to the body tag in the dashboard.
109
- *
110
- * @param String $classes Current body classes.
111
- * @return String Altered body classes.
112
- */
113
- function monsterinsights_add_admin_body_class( $classes ) {
114
- $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
115
- if ( empty( $screen ) || empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
116
- return $classes;
117
- }
118
-
119
- return "$classes monsterinsights_page ";
120
- }
121
- add_filter( 'admin_body_class', 'monsterinsights_add_admin_body_class', 10, 1 );
122
-
123
- /**
124
- * Adds one or more classes to the body tag in the dashboard.
125
- *
126
- * @param String $classes Current body classes.
127
- * @return String Altered body classes.
128
- */
129
- function monsterinsights_add_admin_body_class_tools_page( $classes ) {
130
- $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
131
-
132
- if ( empty( $screen ) || empty( $screen->id ) || strpos( $screen->id, 'monsterinsights_tools' ) === false || 'insights_page_monsterinsights_tools' === $screen->id ) {
133
- return $classes;
134
- }
135
-
136
- return "$classes insights_page_monsterinsights_tools ";
137
- }
138
- add_filter( 'admin_body_class', 'monsterinsights_add_admin_body_class_tools_page', 10, 1 );
139
-
140
- /**
141
- * Adds one or more classes to the body tag in the dashboard.
142
- *
143
- * @param String $classes Current body classes.
144
- * @return String Altered body classes.
145
- */
146
- function monsterinsights_add_admin_body_class_addons_page( $classes ) {
147
- $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
148
- if ( empty( $screen ) || empty( $screen->id ) || strpos( $screen->id, 'monsterinsights_addons' ) === false || 'insights_page_monsterinsights_addons' === $screen->id ) {
149
- return $classes;
150
- }
151
-
152
- return "$classes insights_page_monsterinsights_addons ";
153
- }
154
- add_filter( 'admin_body_class', 'monsterinsights_add_admin_body_class_addons_page', 10, 1 );
155
-
156
- /**
157
- * Add a link to the settings page to the plugins list
158
- *
159
- * @param array $links array of links for the plugins, adapted when the current plugin is found.
160
- *
161
- * @return array $links
162
- */
163
- function monsterinsights_add_action_links( $links ) {
164
- $docs = '<a title="' . esc_html__( 'MonsterInsights Knowledge Base', 'google-analytics-for-wordpress' ) . '" href="'. monsterinsights_get_url( 'all-plugins', 'kb-link', "https://www.monsterinsights.com/docs/" ) .'"">' . esc_html__( 'Documentation', 'google-analytics-for-wordpress' ) . '</a>';
165
- array_unshift( $links, $docs );
166
-
167
- // If lite, show a link where they can get pro from
168
- if ( ! monsterinsights_is_pro_version() ) {
169
- $get_pro = '<a title="' . esc_html__( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ) .'" href="'. monsterinsights_get_upgrade_link( 'all-plugins', 'upgrade-link', "https://www.monsterinsights.com/docs/" ) .'">' . esc_html__( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ) . '</a>';
170
- array_unshift( $links, $get_pro );
171
- }
172
-
173
- // If Lite, support goes to forum. If pro, it goes to our website
174
- if ( monsterinsights_is_pro_version() ) {
175
- $support = '<a title="MonsterInsights Pro Support" href="'. monsterinsights_get_url( 'all-plugins', 'pro-support-link', "https://www.monsterinsights.com/my-account/support/" ) .'">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>';
176
- array_unshift( $links, $support );
177
- } else {
178
- $support = '<a title="MonsterInsights Lite Support" href="'. monsterinsights_get_url( 'all-plugins', 'lite-support-link', "https://www.monsterinsights.com/lite-support/" ) .'">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>';
179
- array_unshift( $links, $support );
180
- }
181
-
182
- $settings_link = '<a href="' . esc_url( admin_url( 'admin.php?page=monsterinsights_settings' ) ) . '">' . esc_html__( 'Settings', 'google-analytics-for-wordpress' ) . '</a>';
183
- array_unshift( $links, $settings_link );
184
-
185
- return $links;
186
- }
187
- add_filter( 'plugin_action_links_' . plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ), 'monsterinsights_add_action_links' );
188
-
189
-
190
-
191
- /**
192
- * Loads a partial view for the Administration screen
193
- *
194
- * @access public
195
- * @since 6.0.0
196
- *
197
- * @param string $template PHP file at includes/admin/partials, excluding file extension
198
- * @param array $data Any data to pass to the view
199
- * @return void
200
- */
201
- function monsterinsights_load_admin_partial( $template, $data = array() ) {
202
-
203
- if ( monsterinsights_is_pro_version() ) {
204
- $dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'pro/includes/admin/partials' );
205
-
206
- if ( file_exists( $dir . $template . '.php' ) ) {
207
- require_once( $dir . $template . '.php' );
208
- return true;
209
- }
210
- } else {
211
- $dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'lite/includes/admin/partials' );
212
-
213
- if ( file_exists( $dir . $template . '.php' ) ) {
214
- require_once( $dir . $template . '.php' );
215
- return true;
216
- }
217
- }
218
-
219
- $dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'includes/admin/partials' );
220
-
221
- if ( file_exists( $dir . $template . '.php' ) ) {
222
- require_once( $dir . $template . '.php' );
223
- return true;
224
- }
225
-
226
- return false;
227
- }
228
-
229
- /**
230
- * When user is on a MonsterInsights related admin page, display footer text
231
- * that graciously asks them to rate us.
232
- *
233
- * @since 6.0.0
234
- * @param string $text
235
- * @return string
236
- */
237
- function monsterinsights_admin_footer( $text ) {
238
- global $current_screen;
239
- if ( ! empty( $current_screen->id ) && strpos( $current_screen->id, 'monsterinsights' ) !== false ) {
240
- $url = 'https://wordpress.org/support/view/plugin-reviews/google-analytics-for-wordpress?filter=5';
241
- $text = sprintf( esc_html__( 'Please rate %sMonsterInsights%s %s on %sWordPress.org%s to help us spread the word. Thank you from the MonsterInsights team!', 'google-analytics-for-wordpress' ), '<strong>', '</strong>', '<a class="monsterinsights-no-text-decoration" href="' . $url . '" target="_blank" rel="noopener noreferrer"><i class="monstericon-star"></i><i class="monstericon-star"></i><i class="monstericon-star"></i><i class="monstericon-star"></i><i class="monstericon-star"></i></a>', '<a href="' . $url . '" target="_blank" rel="noopener noreferrer">', '</a>' );
242
- }
243
- return $text;
244
- }
245
- add_filter( 'admin_footer_text', 'monsterinsights_admin_footer', 1, 2 );
246
-
247
- function monsterinsights_admin_setup_notices() {
248
-
249
- // Don't show on MonsterInsights pages
250
- $screen = get_current_screen();
251
- if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) !== false ) {
252
- return;
253
- }
254
-
255
- // Make sure they have the permissions to do something
256
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
257
- return;
258
- }
259
-
260
- // Priority:
261
- // 1. Google Analytics not authenticated
262
- // 2. License key not entered for pro
263
- // 3. License key not valid/okay for pro
264
- // 4. WordPress + PHP min versions
265
- // 5. (old) Optin setting not configured
266
- // 6. Manual UA code
267
- // 7. Automatic updates not configured
268
- // 8. Woo upsell
269
- // 9. EDD upsell
270
-
271
-
272
- // 1. Google Analytics not authenticated
273
- if ( ! is_network_admin() && ! monsterinsights_get_ua() ) {
274
-
275
- $submenu_base = is_network_admin() ? add_query_arg( 'page', 'monsterinsights_network', network_admin_url( 'admin.php' ) ) : add_query_arg( 'page', 'monsterinsights_settings', admin_url( 'admin.php' ) );
276
- $title = esc_html__( 'Please Setup Website Analytics to See Audience Insights', 'google-analytics-for-wordpress' );
277
- $primary = esc_html__( 'Connect MonsterInsights and Setup Website Analytics', 'google-analytics-for-wordpress' );
278
- $urlone = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights-onboarding' ) : admin_url( 'admin.php?page=monsterinsights-onboarding' );
279
- $secondary = esc_html__( 'Learn More', 'google-analytics-for-wordpress' );
280
- $urltwo = $submenu_base . '#/about/getting-started';
281
- $message = esc_html__( 'MonsterInsights, WordPress analytics plugin, helps you connect your website with Google Analytics, so you can see how people find and use your website. Over 2 million website owners use MonsterInsights to see the stats that matter and grow their business.', 'google-analytics-for-wordpress' );
282
- echo '<div class="notice notice-info"><p style="font-weight:700">'. $title .'</p><p>'. $message.'</p><p><a href="'. $urlone .'" class="button-primary">'. $primary .'</a>&nbsp;&nbsp;&nbsp;<a href="'. $urltwo .'" class="button-secondary">'. $secondary .'</a></p></div>';
283
- return;
284
- }
285
-
286
- // 2. License key not entered for pro
287
- $key = monsterinsights_is_pro_version() ? MonsterInsights()->license->get_license_key() : '';
288
- if ( monsterinsights_is_pro_version() && empty( $key ) ) {
289
- $page = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
290
- $message = sprintf( esc_html__( 'Warning: No valid license key has been entered for MonsterInsights. You are currently not getting updates, and are not able to view reports. %1$sPlease click here to enter your license key and begin receiving updates and reports.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. esc_url( $page ) . '">', '</a>' );
291
- echo '<div class="error"><p>'. $message.'</p></div>';
292
- return;
293
- }
294
-
295
- // 3. License key not valid/okay for pro
296
- if ( monsterinsights_is_pro_version() ) {
297
- $message = '';
298
- if ( MonsterInsights()->license->get_site_license_key() ){
299
- if ( MonsterInsights()->license->site_license_expired() ) {
300
- $message = sprintf( esc_html__( 'Your license key for MonsterInsights has expired. %1$sPlease click here to renew your license key.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. monsterinsights_get_url( 'admin-notices', 'expired-license', "https://www.monsterinsights.com/login/" ) .'" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' );
301
- } else if ( MonsterInsights()->license->site_license_disabled() ) {
302
- $message = esc_html__( 'Your license key for MonsterInsights has been disabled. Please use a different key.', 'google-analytics-for-wordpress' );
303
- } else if ( MonsterInsights()->license->site_license_invalid() ) {
304
- $message = esc_html__( 'Your license key for MonsterInsights is invalid. The key no longer exists or the user associated with the key has been deleted. Please use a different key.', 'google-analytics-for-wordpress' );
305
- }
306
- } else if ( MonsterInsights()->license->get_network_license_key() ) {
307
- if ( MonsterInsights()->license->network_license_expired() ) {
308
- $message = sprintf( esc_html__( 'Your network license key for MonsterInsights has expired. %1$sPlease click here to renew your license key.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. monsterinsights_get_url( 'admin-notices', 'expired-license', "https://www.monsterinsights.com/login/" ) .'" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' );
309
- } else if ( MonsterInsights()->license->network_license_disabled() ) {
310
- $message = esc_html__( 'Your network license key for MonsterInsights has been disabled. Please use a different key.', 'google-analytics-for-wordpress' );
311
- } else if ( MonsterInsights()->license->network_license_invalid() ) {
312
- $message = esc_html__( 'Your network license key for MonsterInsights is invalid. The key no longer exists or the user associated with the key has been deleted. Please use a different key.', 'google-analytics-for-wordpress' );
313
- }
314
- }
315
- if ( ! empty( $message ) ) {
316
- echo '<div class="error"><p>'. $message.'</p></div>';
317
- return;
318
- }
319
- }
320
-
321
- // 4. Notices for PHP/WP version deprecations
322
- if ( current_user_can( 'update_core' ) ) {
323
- global $wp_version;
324
-
325
- // PHP 5.2/5.3
326
- if ( version_compare( phpversion(), '5.4', '<' ) ) {
327
- $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-php/' );
328
- $message = sprintf( esc_html__( 'Your site is running an outdated, insecure version of PHP (%1$s), which could be putting your site at risk for being hacked.%4$sWordPress will stop supporting your PHP version in April, 2019.%4$sUpdating PHP only takes a few minutes and will make your website significantly faster and more secure.%4$s%2$sLearn more about updating PHP%3$s', 'google-analytics-for-wordpress' ), phpversion(), '<a href="' . $url . '" target="_blank">', '</a>', '<br>' );
329
- echo '<div class="error"><p>'. $message.'</p></div>';
330
- return;
331
- }
332
- // WordPress 3.0 - 4.5
333
- else if ( version_compare( $wp_version, '4.6', '<' ) ) {
334
- $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-wordpress/' );
335
- $message = sprintf( esc_html__( 'Your site is running an outdated version of WordPress (%1$s).%4$sMonsterInsights will stop supporting WordPress versions lower than 4.6 in April, 2019.%4$sUpdating WordPress takes just a few minutes and will also solve many bugs that exist in your WordPress install.%4$s%2$sLearn more about updating WordPress%3$s', 'google-analytics-for-wordpress' ), $wp_version, '<a href="' . $url . '" target="_blank">', '</a>', '<br>' );
336
- echo '<div class="error"><p>'. $message.'</p></div>';
337
- return;
338
- }
339
- // PHP 5.4/5.5
340
- // else if ( version_compare( phpversion(), '5.6', '<' ) ) {
341
- // $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-php/' );
342
- // $message = sprintf( esc_html__( 'Your site is running an outdated, insecure version of PHP (%1$s), which could be putting your site at risk for being hacked.%4$sWordPress will stop supporting your PHP version in April, 2019.%4$sUpdating PHP only takes a few minutes and will make your website significantly faster and more secure.%4$s%2$sLearn more about updating PHP%3$s', 'google-analytics-for-wordpress' ), phpversion(), '<a href="' . $url . '" target="_blank">', '</a>', '<br>' );
343
- // echo '<div class="error"><p>'. $message.'</p></div>';
344
- // return;
345
- // }
346
- // // WordPress 4.6 - 4.8
347
- // else if ( version_compare( $wp_version, '4.9', '<' ) ) {
348
- // $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-wordpress/' );
349
- // $message = sprintf( esc_html__( 'Your site is running an outdated version of WordPress (%1$s).%4$sMonsterInsights will stop supporting WordPress versions lower than 4.9 in October, 2019.%4$sUpdating WordPress takes just a few minutes and will also solve many bugs that exist in your WordPress install.%4$s%2$sLearn more about updating WordPress%3$s', 'google-analytics-for-wordpress' ), $wp_version, '<a href="' . $url . '" target="_blank">', '</a>', '<br>' );
350
- // echo '<div class="error"><p>'. $message.'</p></div>';
351
- // return;
352
- // }
353
- }
354
-
355
- // 5. Optin setting not configured
356
- // if ( ! is_network_admin() ) {
357
- // if ( ! get_option( 'monsterinsights_tracking_notice' ) ) {
358
- // if ( ! monsterinsights_get_option( 'anonymous_data', false ) ) {
359
- // if ( ! monsterinsights_is_dev_url( network_site_url( '/' ) ) ) {
360
- // if ( monsterinsights_is_pro_version() ) {
361
- // monsterinsights_update_option( 'anonymous_data', 1 );
362
- // return;
363
- // }
364
- // $optin_url = add_query_arg( 'mi_action', 'opt_into_tracking' );
365
- // $optout_url = add_query_arg( 'mi_action', 'opt_out_of_tracking' );
366
- // echo '<div class="updated"><p>';
367
- // echo esc_html__( 'Allow MonsterInsights to track plugin usage? Opt-in to tracking and our newsletter to stay informed of the latest changes to MonsterInsights and help us ensure compatibility.', 'google-analytics-for-wordpress' );
368
- // echo '&nbsp;<a href="' . esc_url( $optin_url ) . '" class="button-secondary">' . __( 'Allow', 'google-analytics-for-wordpress' ) . '</a>';
369
- // echo '&nbsp;<a href="' . esc_url( $optout_url ) . '" class="button-secondary">' . __( 'Do not allow', 'google-analytics-for-wordpress' ) . '</a>';
370
- // echo '</p></div>';
371
- // return;
372
- // } else {
373
- // // is testing site
374
- // update_option( 'monsterinsights_tracking_notice', '1' );
375
- // }
376
- // }
377
- // }
378
- // }
379
-
380
- $notices = get_option( 'monsterinsights_notices' );
381
- if ( ! is_array( $notices ) ) {
382
- $notices = array();
383
- }
384
-
385
- // 6. Authenticate, not manual
386
- $authed = MonsterInsights()->auth->is_authed() || MonsterInsights()->auth->is_network_authed();
387
- $url = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
388
-
389
- if ( empty( $authed ) && ! isset( $notices['monsterinsights_auth_not_manual' ] ) ) {
390
- echo '<div class="notice notice-info is-dismissible monsterinsights-notice" data-notice="monsterinsights_auth_not_manual">';
391
- echo '<p>';
392
- echo sprintf( esc_html__( 'Important: You are currently using manual UA code output. We highly recommend %1$sauthenticating with MonsterInsights%2$s so that you can access our new reporting area and take advantage of new MonsterInsights features.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' );
393
- echo '</p>';
394
- echo '</div>';
395
- return;
396
- }
397
-
398
- // 7. Automatic updates not configured
399
- // if ( ! is_network_admin() ) {
400
- // $updates = monsterinsights_get_option( 'automatic_updates', false );
401
- // $url = admin_url( 'admin.php?page=monsterinsights_settings' );
402
-
403
- // if ( empty( $updates) && ! isset( $notices['monsterinsights_automatic_updates' ] ) ) {
404
- // echo '<div class="notice notice-info is-dismissible monsterinsights-notice" data-notice="monsterinsights_automatic_updates">';
405
- // echo '<p>';
406
- // echo sprintf( esc_html__( 'Important: Please %1$sconfigure the Automatic Updates Settings%2$s in MonsterInsights.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' );
407
- // echo '</p>';
408
- // echo '</div>';
409
- // return;
410
- // }
411
- // }
412
-
413
- // 8. WooUpsell
414
- if ( ! monsterinsights_is_pro_version() && class_exists( 'WooCommerce' ) ) {
415
- if ( ! isset( $notices['monsterinsights_woocommerce_tracking_available' ] ) ) {
416
- echo '<div class="notice notice-success is-dismissible monsterinsights-notice monsterinsights-wooedd-upsell-row" data-notice="monsterinsights_woocommerce_tracking_available">';
417
- echo '<div class="monsterinsights-wooedd-upsell-left">';
418
- echo '<p><strong>';
419
- echo esc_html( 'Enhanced Ecommerce Analytics for Your WooCommerce Store', 'google-analytics-for-wordpress' );
420
- echo '</strong></p>';
421
- echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-small" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
422
- echo '<p>';
423
- echo esc_html( 'MonsterInsights Pro gives you detailed stats and insights about your customers.', 'google-analytics-for-wordpress' );
424
- echo '</p>';
425
- echo '<p>';
426
- echo esc_html( 'This helps you make data-driven decisions about your content, and marketing strategy so you can increase your website traffic, leads, and sales.', 'google-analytics-for-wordpress' );
427
- echo '</p>';
428
- echo '<p>';
429
- echo esc_html( 'Pro customers also get Form Tracking, Custom Dimensions Tracking, UserID Tracking and much more.', 'google-analytics-for-wordpress' );
430
- echo '</p>';
431
- echo '<p>';
432
- echo esc_html( 'Start making data-driven decisions to grow your business.', 'google-analytics-for-wordpress' );
433
- echo '</p>';
434
- echo sprintf( esc_html__( '%1$sGet MonsterInsights Pro%2$s', 'google-analytics-for-wordpress' ), '<a class="button button-primary button-hero" href="'. monsterinsights_get_upgrade_link( 'admin-notices', 'woocommerce-upgrade' ) .'">', ' &raquo;</a>' );
435
- echo '</p>';
436
- echo '</div><div class="monsterinsights-wooedd-upsell-right">';
437
- echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-large" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
438
- echo '</div>';
439
- echo '</div>';
440
- return;
441
- }
442
- }
443
-
444
- // 9. EDDUpsell
445
- if ( ! monsterinsights_is_pro_version() && class_exists( 'Easy_Digital_Downloads' ) ) {
446
- if ( ! isset( $notices['monsterinsights_edd_tracking_available' ] ) ) {
447
- echo '<div class="notice notice-success is-dismissible monsterinsights-notice monsterinsights-wooedd-upsell-row" data-notice="monsterinsights_edd_tracking_available">';
448
- echo '<div class="monsterinsights-wooedd-upsell-left">';
449
- echo '<p><strong>';
450
- echo esc_html( 'Enhanced Ecommerce Analytics for Your Easy Digital Downloads Store', 'google-analytics-for-wordpress' );
451
- echo '</strong></p>';
452
- echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-small" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
453
- echo '<p>';
454
- echo esc_html( 'MonsterInsights Pro gives you detailed stats and insights about your customers.', 'google-analytics-for-wordpress' );
455
- echo '</p>';
456
- echo '<p>';
457
- echo esc_html( 'This helps you make data-driven decisions about your content, and marketing strategy so you can increase your website traffic, leads, and sales.', 'google-analytics-for-wordpress' );
458
- echo '</p>';
459
- echo '<p>';
460
- echo esc_html( 'Pro customers also get Form Tracking, Custom Dimensions Tracking, UserID Tracking and much more.', 'google-analytics-for-wordpress' );
461
- echo '</p>';
462
- echo '<p>';
463
- echo esc_html( 'Start making data-driven decisions to grow your business.', 'google-analytics-for-wordpress' );
464
- echo '</p>';
465
- echo sprintf( esc_html__( '%1$sGet MonsterInsights Pro%2$s', 'google-analytics-for-wordpress' ), '<a class="button button-primary button-hero" href="'. monsterinsights_get_upgrade_link( 'admin-notices', 'edd-upgrade' ) .'">', ' &raquo;</a>' );
466
- echo '</p>';
467
- echo '</div><div class="monsterinsights-wooedd-upsell-right">';
468
- echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-large" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
469
- echo '</div>';
470
- echo '</div>';
471
- return;
472
- }
473
- }
474
-
475
- if ( isset( $notices['monsterinsights_cross_domains_extracted'] ) && false === $notices['monsterinsights_cross_domains_extracted'] ) {
476
- $page = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
477
- $page = $page . '#/advanced';
478
- $message = sprintf( esc_html__( 'Warning: MonsterInsights found cross-domain settings in the custom code field and converted them to the new settings structure. %1$sPlease click here to review and remove the code no longer needed.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. esc_url( $page ) . '">', '</a>' );
479
- echo '<div class="notice notice-success is-dismissible monsterinsights-notice" data-notice="monsterinsights_cross_domains_extracted"><p>'. $message.'</p></div>';
480
- return;
481
- }
482
- }
483
- add_action( 'admin_notices', 'monsterinsights_admin_setup_notices' );
484
- add_action( 'network_admin_notices', 'monsterinsights_admin_setup_notices' );
485
-
486
-
487
- // AM Notices
488
- function monsterinsights_am_notice_optout( $super_admin ) {
489
- if ( monsterinsights_get_option( 'hide_am_notices', false ) || monsterinsights_get_option( 'network_hide_am_notices', false ) ) {
490
- return false;
491
- }
492
- return $super_admin;
493
- }
494
- add_filter( "am_notifications_display", 'monsterinsights_am_notice_optout', 10, 1 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin class.
4
+ *
5
+ * @since 6.0.0
6
+ *
7
+ * @package MonsterInsights
8
+ * @subpackage Admin
9
+ * @author Chris Christoff
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /**
18
+ * Register menu items for MonsterInsights.
19
+ *
20
+ * @since 6.0.0
21
+ * @access public
22
+ *
23
+ * @return void
24
+ */
25
+ function monsterinsights_admin_menu() {
26
+ $hook = monsterinsights_get_menu_hook();
27
+ $menu_icon_inline = monsterinsights_get_inline_menu_icon();
28
+
29
+ if ( $hook === 'monsterinsights_settings' ) {
30
+ // If dashboards disabled, first settings page
31
+ add_menu_page( __( 'MonsterInsights', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ) . MonsterInsights()->notifications->get_menu_count(), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page', $menu_icon_inline, '100.00013467543' );
32
+ $hook = 'monsterinsights_settings';
33
+
34
+ add_submenu_page( $hook, __( 'MonsterInsights', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings' );
35
+ } else {
36
+ // if dashboards enabled, first dashboard
37
+ add_menu_page( __( 'General:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ) . MonsterInsights()->notifications->get_menu_count(), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page', $menu_icon_inline, '100.00013467543' );
38
+
39
+ add_submenu_page( $hook, __( 'General Reports:', 'google-analytics-for-wordpress' ), __( 'Reports', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page' );
40
+
41
+ // then settings page
42
+ add_submenu_page( $hook, __( 'MonsterInsights', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page' );
43
+
44
+ // Add dashboard submenu.
45
+ add_submenu_page( 'index.php', __( 'General Reports:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'admin.php?page=monsterinsights_reports' );
46
+ }
47
+
48
+ $submenu_base = add_query_arg( 'page', 'monsterinsights_settings', admin_url( 'admin.php' ) );
49
+
50
+ // then tools
51
+ add_submenu_page( $hook, __( 'Tools:', 'google-analytics-for-wordpress' ), __( 'Tools', 'google-analytics-for-wordpress' ), 'manage_options', $submenu_base . '#/tools' );
52
+
53
+ // then addons
54
+ $network_key = monsterinsights_is_pro_version() ? MonsterInsights()->license->get_network_license_key() : '';
55
+ if ( ! monsterinsights_is_network_active() || ( monsterinsights_is_network_active() && empty( $network_key ) ) ) {
56
+ add_submenu_page( $hook, __( 'Addons:', 'google-analytics-for-wordpress' ), '<span style="color:' . monsterinsights_menu_highlight_color() . '"> ' . __( 'Addons', 'google-analytics-for-wordpress' ) . '</span>', 'monsterinsights_save_settings', $submenu_base . '#/addons' );
57
+ }
58
+
59
+ // Add About us page.
60
+ add_submenu_page( $hook, __( 'About Us:', 'google-analytics-for-wordpress' ), __( 'About Us', 'google-analytics-for-wordpress' ), 'manage_options', $submenu_base . '#/about' );
61
+ }
62
+ add_action( 'admin_menu', 'monsterinsights_admin_menu' );
63
+
64
+ function monsterinsights_get_menu_hook() {
65
+ $dashboards_disabled = monsterinsights_get_option( 'dashboards_disabled', false );
66
+ if ( $dashboards_disabled || ( current_user_can( 'monsterinsights_save_settings' ) && ! current_user_can( 'monsterinsights_view_dashboard' ) ) ) {
67
+ return 'monsterinsights_settings';
68
+ } else {
69
+ return 'monsterinsights_reports';
70
+ }
71
+ }
72
+
73
+ function monsterinsights_network_admin_menu() {
74
+ // Get the base class object.
75
+ $base = MonsterInsights();
76
+
77
+ // First, let's see if this is an MS network enabled plugin. If it is, we should load the license
78
+ // menu page and the updater on the network panel
79
+ if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
80
+ require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
81
+ }
82
+
83
+ $plugin = plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE );
84
+ if ( ! is_plugin_active_for_network( $plugin ) ) {
85
+ return;
86
+ }
87
+
88
+ $menu_icon_inline = monsterinsights_get_inline_menu_icon();
89
+ $hook = 'monsterinsights_network';
90
+ $submenu_base = add_query_arg( 'page', 'monsterinsights_network', network_admin_url( 'admin.php' ) );
91
+ add_menu_page( __( 'Network Settings:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ) . MonsterInsights()->notifications->get_menu_count(), 'monsterinsights_save_settings', 'monsterinsights_network', 'monsterinsights_network_page', $menu_icon_inline, '100.00013467543' );
92
+
93
+ add_submenu_page( $hook, __( 'Network Settings:', 'google-analytics-for-wordpress' ), __( 'Network Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_network', 'monsterinsights_network_page' );
94
+
95
+ add_submenu_page( $hook, __( 'General Reports:', 'google-analytics-for-wordpress' ), __( 'Reports', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page' );
96
+
97
+ // then addons
98
+ add_submenu_page( $hook, __( 'Addons:', 'google-analytics-for-wordpress' ), '<span style="color:' . monsterinsights_menu_highlight_color() . '"> ' . __( 'Addons', 'google-analytics-for-wordpress' ) . '</span>', 'monsterinsights_save_settings', $submenu_base . '#/addons' );
99
+
100
+ $submenu_base = add_query_arg( 'page', 'monsterinsights_network', network_admin_url( 'admin.php' ) );
101
+
102
+ // Add About us page.
103
+ add_submenu_page( $hook, __( 'About Us:', 'google-analytics-for-wordpress' ), __( 'About Us', 'google-analytics-for-wordpress' ), 'manage_options', $submenu_base . '#/about' );
104
+ }
105
+ add_action( 'network_admin_menu', 'monsterinsights_network_admin_menu', 5 );
106
+
107
+ /**
108
+ * Adds one or more classes to the body tag in the dashboard.
109
+ *
110
+ * @param String $classes Current body classes.
111
+ * @return String Altered body classes.
112
+ */
113
+ function monsterinsights_add_admin_body_class( $classes ) {
114
+ $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
115
+ if ( empty( $screen ) || empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
116
+ return $classes;
117
+ }
118
+
119
+ return "$classes monsterinsights_page ";
120
+ }
121
+ add_filter( 'admin_body_class', 'monsterinsights_add_admin_body_class', 10, 1 );
122
+
123
+ /**
124
+ * Adds one or more classes to the body tag in the dashboard.
125
+ *
126
+ * @param String $classes Current body classes.
127
+ * @return String Altered body classes.
128
+ */
129
+ function monsterinsights_add_admin_body_class_tools_page( $classes ) {
130
+ $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
131
+
132
+ if ( empty( $screen ) || empty( $screen->id ) || strpos( $screen->id, 'monsterinsights_tools' ) === false || 'insights_page_monsterinsights_tools' === $screen->id ) {
133
+ return $classes;
134
+ }
135
+
136
+ return "$classes insights_page_monsterinsights_tools ";
137
+ }
138
+ add_filter( 'admin_body_class', 'monsterinsights_add_admin_body_class_tools_page', 10, 1 );
139
+
140
+ /**
141
+ * Adds one or more classes to the body tag in the dashboard.
142
+ *
143
+ * @param String $classes Current body classes.
144
+ * @return String Altered body classes.
145
+ */
146
+ function monsterinsights_add_admin_body_class_addons_page( $classes ) {
147
+ $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
148
+ if ( empty( $screen ) || empty( $screen->id ) || strpos( $screen->id, 'monsterinsights_addons' ) === false || 'insights_page_monsterinsights_addons' === $screen->id ) {
149
+ return $classes;
150
+ }
151
+
152
+ return "$classes insights_page_monsterinsights_addons ";
153
+ }
154
+ add_filter( 'admin_body_class', 'monsterinsights_add_admin_body_class_addons_page', 10, 1 );
155
+
156
+ /**
157
+ * Add a link to the settings page to the plugins list
158
+ *
159
+ * @param array $links array of links for the plugins, adapted when the current plugin is found.
160
+ *
161
+ * @return array $links
162
+ */
163
+ function monsterinsights_add_action_links( $links ) {
164
+ $docs = '<a title="' . esc_html__( 'MonsterInsights Knowledge Base', 'google-analytics-for-wordpress' ) . '" href="'. monsterinsights_get_url( 'all-plugins', 'kb-link', "https://www.monsterinsights.com/docs/" ) .'">' . esc_html__( 'Documentation', 'google-analytics-for-wordpress' ) . '</a>';
165
+ array_unshift( $links, $docs );
166
+
167
+ // If lite, show a link where they can get pro from
168
+ if ( ! monsterinsights_is_pro_version() ) {
169
+ $get_pro = '<a title="' . esc_html__( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ) .'" href="'. monsterinsights_get_upgrade_link( 'all-plugins', 'upgrade-link', "https://www.monsterinsights.com/docs/" ) .'">' . esc_html__( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ) . '</a>';
170
+ array_unshift( $links, $get_pro );
171
+ }
172
+
173
+ // If Lite, support goes to forum. If pro, it goes to our website
174
+ if ( monsterinsights_is_pro_version() ) {
175
+ $support = '<a title="MonsterInsights Pro Support" href="'. monsterinsights_get_url( 'all-plugins', 'pro-support-link', "https://www.monsterinsights.com/my-account/support/" ) .'">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>';
176
+ array_unshift( $links, $support );
177
+ } else {
178
+ $support = '<a title="MonsterInsights Lite Support" href="'. monsterinsights_get_url( 'all-plugins', 'lite-support-link', "https://www.monsterinsights.com/lite-support/" ) .'">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>';
179
+ array_unshift( $links, $support );
180
+ }
181
+
182
+ if ( is_network_admin() ) {
183
+ $settings_link = '<a href="' . esc_url( network_admin_url( 'admin.php?page=monsterinsights_network' ) ) . '">' . esc_html__( 'Network Settings', 'google-analytics-for-wordpress' ) . '</a>';
184
+ } else {
185
+ $settings_link = '<a href="' . esc_url( admin_url( 'admin.php?page=monsterinsights_settings' ) ) . '">' . esc_html__( 'Settings', 'google-analytics-for-wordpress' ) . '</a>';
186
+ }
187
+
188
+ array_unshift( $links, $settings_link );
189
+
190
+ return $links;
191
+ }
192
+ add_filter( 'plugin_action_links_' . plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ), 'monsterinsights_add_action_links' );
193
+ add_filter( 'network_admin_plugin_action_links_' . plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ), 'monsterinsights_add_action_links' );
194
+
195
+
196
+
197
+ /**
198
+ * Loads a partial view for the Administration screen
199
+ *
200
+ * @access public
201
+ * @since 6.0.0
202
+ *
203
+ * @param string $template PHP file at includes/admin/partials, excluding file extension
204
+ * @param array $data Any data to pass to the view
205
+ * @return void
206
+ */
207
+ function monsterinsights_load_admin_partial( $template, $data = array() ) {
208
+
209
+ if ( monsterinsights_is_pro_version() ) {
210
+ $dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'pro/includes/admin/partials' );
211
+
212
+ if ( file_exists( $dir . $template . '.php' ) ) {
213
+ require_once( $dir . $template . '.php' );
214
+ return true;
215
+ }
216
+ } else {
217
+ $dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'lite/includes/admin/partials' );
218
+
219
+ if ( file_exists( $dir . $template . '.php' ) ) {
220
+ require_once( $dir . $template . '.php' );
221
+ return true;
222
+ }
223
+ }
224
+
225
+ $dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'includes/admin/partials' );
226
+
227
+ if ( file_exists( $dir . $template . '.php' ) ) {
228
+ require_once( $dir . $template . '.php' );
229
+ return true;
230
+ }
231
+
232
+ return false;
233
+ }
234
+
235
+ /**
236
+ * When user is on a MonsterInsights related admin page, display footer text
237
+ * that graciously asks them to rate us.
238
+ *
239
+ * @since 6.0.0
240
+ * @param string $text
241
+ * @return string
242
+ */
243
+ function monsterinsights_admin_footer( $text ) {
244
+ global $current_screen;
245
+ if ( ! empty( $current_screen->id ) && strpos( $current_screen->id, 'monsterinsights' ) !== false ) {
246
+ $url = 'https://wordpress.org/support/view/plugin-reviews/google-analytics-for-wordpress?filter=5';
247
+ // Translators: Placeholders add a link to the wordpress.org repository.
248
+ $text = sprintf( esc_html__( 'Please rate %1$sMonsterInsights%2$s on %3$s %4$sWordPress.org%5$s to help us spread the word. Thank you from the MonsterInsights team!', 'google-analytics-for-wordpress' ), '<strong>', '</strong>', '<a class="monsterinsights-no-text-decoration" href="' . $url . '" target="_blank" rel="noopener noreferrer"><i class="monstericon-star"></i><i class="monstericon-star"></i><i class="monstericon-star"></i><i class="monstericon-star"></i><i class="monstericon-star"></i></a>', '<a href="' . $url . '" target="_blank" rel="noopener noreferrer">', '</a>' );
249
+ }
250
+ return $text;
251
+ }
252
+ add_filter( 'admin_footer_text', 'monsterinsights_admin_footer', 1, 2 );
253
+
254
+ function monsterinsights_admin_setup_notices() {
255
+
256
+ // Don't show on MonsterInsights pages
257
+ $screen = get_current_screen();
258
+ if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) !== false ) {
259
+ return;
260
+ }
261
+
262
+ // Make sure they have the permissions to do something
263
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
264
+ return;
265
+ }
266
+
267
+ // Priority:
268
+ // 1. Google Analytics not authenticated
269
+ // 2. License key not entered for pro
270
+ // 3. License key not valid/okay for pro
271
+ // 4. WordPress + PHP min versions
272
+ // 5. (old) Optin setting not configured
273
+ // 6. Manual UA code
274
+ // 7. Automatic updates not configured
275
+ // 8. Woo upsell
276
+ // 9. EDD upsell
277
+
278
+
279
+ // 1. Google Analytics not authenticated
280
+ if ( ! is_network_admin() && ! monsterinsights_get_ua() && ! defined( 'MONSTERINSIGHTS_DISABLE_TRACKING' ) ) {
281
+
282
+ $submenu_base = is_network_admin() ? add_query_arg( 'page', 'monsterinsights_network', network_admin_url( 'admin.php' ) ) : add_query_arg( 'page', 'monsterinsights_settings', admin_url( 'admin.php' ) );
283
+ $title = esc_html__( 'Please Setup Website Analytics to See Audience Insights', 'google-analytics-for-wordpress' );
284
+ $primary = esc_html__( 'Connect MonsterInsights and Setup Website Analytics', 'google-analytics-for-wordpress' );
285
+ $urlone = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights-onboarding' ) : admin_url( 'admin.php?page=monsterinsights-onboarding' );
286
+ $secondary = esc_html__( 'Learn More', 'google-analytics-for-wordpress' );
287
+ $urltwo = $submenu_base . '#/about/getting-started';
288
+ $message = esc_html__( 'MonsterInsights, WordPress analytics plugin, helps you connect your website with Google Analytics, so you can see how people find and use your website. Over 2 million website owners use MonsterInsights to see the stats that matter and grow their business.', 'google-analytics-for-wordpress' );
289
+ echo '<div class="notice notice-info"><p style="font-weight:700">'. $title .'</p><p>'. $message.'</p><p><a href="'. $urlone .'" class="button-primary">'. $primary .'</a>&nbsp;&nbsp;&nbsp;<a href="'. $urltwo .'" class="button-secondary">'. $secondary .'</a></p></div>';
290
+ return;
291
+ }
292
+
293
+ // 2. License key not entered for pro
294
+ $key = monsterinsights_is_pro_version() ? MonsterInsights()->license->get_license_key() : '';
295
+ if ( monsterinsights_is_pro_version() && empty( $key ) ) {
296
+ $page = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
297
+ // Translators: Adds a link to retrieve the license.
298
+ $message = sprintf( esc_html__( 'Warning: No valid license key has been entered for MonsterInsights. You are currently not getting updates, and are not able to view reports. %1$sPlease click here to enter your license key and begin receiving updates and reports.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. esc_url( $page ) . '">', '</a>' );
299
+ echo '<div class="error"><p>'. $message.'</p></div>';
300
+ return;
301
+ }
302
+
303
+ // 3. License key not valid/okay for pro
304
+ if ( monsterinsights_is_pro_version() ) {
305
+ $message = '';
306
+ if ( MonsterInsights()->license->get_site_license_key() ){
307
+ if ( MonsterInsights()->license->site_license_expired() ) {
308
+ // Translators: Adds a link to the license renewal.
309
+ $message = sprintf( esc_html__( 'Your license key for MonsterInsights has expired. %1$sPlease click here to renew your license key.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. monsterinsights_get_url( 'admin-notices', 'expired-license', "https://www.monsterinsights.com/login/" ) .'" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' );
310
+ } else if ( MonsterInsights()->license->site_license_disabled() ) {
311
+ $message = esc_html__( 'Your license key for MonsterInsights has been disabled. Please use a different key.', 'google-analytics-for-wordpress' );
312
+ } else if ( MonsterInsights()->license->site_license_invalid() ) {
313
+ $message = esc_html__( 'Your license key for MonsterInsights is invalid. The key no longer exists or the user associated with the key has been deleted. Please use a different key.', 'google-analytics-for-wordpress' );
314
+ }
315
+ } else if ( MonsterInsights()->license->get_network_license_key() ) {
316
+ if ( MonsterInsights()->license->network_license_expired() ) {
317
+ // Translators: Adds a link to renew license.
318
+ $message = sprintf( esc_html__( 'Your network license key for MonsterInsights has expired. %1$sPlease click here to renew your license key.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. monsterinsights_get_url( 'admin-notices', 'expired-license', "https://www.monsterinsights.com/login/" ) .'" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' );
319
+ } else if ( MonsterInsights()->license->network_license_disabled() ) {
320
+ $message = esc_html__( 'Your network license key for MonsterInsights has been disabled. Please use a different key.', 'google-analytics-for-wordpress' );
321
+ } else if ( MonsterInsights()->license->network_license_invalid() ) {
322
+ $message = esc_html__( 'Your network license key for MonsterInsights is invalid. The key no longer exists or the user associated with the key has been deleted. Please use a different key.', 'google-analytics-for-wordpress' );
323
+ }
324
+ }
325
+ if ( ! empty( $message ) ) {
326
+ echo '<div class="error"><p>'. $message.'</p></div>';
327
+ return;
328
+ }
329
+ }
330
+
331
+ // 4. Notices for PHP/WP version deprecations
332
+ if ( current_user_can( 'update_core' ) ) {
333
+ global $wp_version;
334
+
335
+ // PHP 5.2/5.3
336
+ if ( version_compare( phpversion(), '5.4', '<' ) ) {
337
+ $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-php/' );
338
+ // Translators: Placeholders add the PHP version, a link to the MonsterInsights blog and a line break.
339
+ $message = sprintf( esc_html__( 'Your site is running an outdated, insecure version of PHP (%1$s), which could be putting your site at risk for being hacked.%4$sWordPress will stop supporting your PHP version in April, 2019.%4$sUpdating PHP only takes a few minutes and will make your website significantly faster and more secure.%4$s%2$sLearn more about updating PHP%3$s', 'google-analytics-for-wordpress' ), phpversion(), '<a href="' . $url . '" target="_blank">', '</a>', '<br>' );
340
+ echo '<div class="error"><p>'. $message.'</p></div>';
341
+ return;
342
+ }
343
+ // WordPress 3.0 - 4.5
344
+ else if ( version_compare( $wp_version, '4.6', '<' ) ) {
345
+ $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-wordpress/' );
346
+ // Translators: Placeholders add the current WordPress version and links to the MonsterInsights blog
347
+ $message = sprintf( esc_html__( 'Your site is running an outdated version of WordPress (%1$s).%4$sMonsterInsights will stop supporting WordPress versions lower than 4.6 in April, 2019.%4$sUpdating WordPress takes just a few minutes and will also solve many bugs that exist in your WordPress install.%4$s%2$sLearn more about updating WordPress%3$s', 'google-analytics-for-wordpress' ), $wp_version, '<a href="' . $url . '" target="_blank">', '</a>', '<br>' );
348
+ echo '<div class="error"><p>'. $message.'</p></div>';
349
+ return;
350
+ }
351
+ // PHP 5.4/5.5
352
+ // else if ( version_compare( phpversion(), '5.6', '<' ) ) {
353
+ // $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-php/' );
354
+ // $message = sprintf( esc_html__( 'Your site is running an outdated, insecure version of PHP (%1$s), which could be putting your site at risk for being hacked.%4$sWordPress will stop supporting your PHP version in April, 2019.%4$sUpdating PHP only takes a few minutes and will make your website significantly faster and more secure.%4$s%2$sLearn more about updating PHP%3$s', 'google-analytics-for-wordpress' ), phpversion(), '<a href="' . $url . '" target="_blank">', '</a>', '<br>' );
355
+ // echo '<div class="error"><p>'. $message.'</p></div>';
356
+ // return;
357
+ // }
358
+ // // WordPress 4.6 - 4.8
359
+ // else if ( version_compare( $wp_version, '4.9', '<' ) ) {
360
+ // $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-wordpress/' );
361
+ // $message = sprintf( esc_html__( 'Your site is running an outdated version of WordPress (%1$s).%4$sMonsterInsights will stop supporting WordPress versions lower than 4.9 in October, 2019.%4$sUpdating WordPress takes just a few minutes and will also solve many bugs that exist in your WordPress install.%4$s%2$sLearn more about updating WordPress%3$s', 'google-analytics-for-wordpress' ), $wp_version, '<a href="' . $url . '" target="_blank">', '</a>', '<br>' );
362
+ // echo '<div class="error"><p>'. $message.'</p></div>';
363
+ // return;
364
+ // }
365
+ }
366
+
367
+ // 5. Optin setting not configured
368
+ // if ( ! is_network_admin() ) {
369
+ // if ( ! get_option( 'monsterinsights_tracking_notice' ) ) {
370
+ // if ( ! monsterinsights_get_option( 'anonymous_data', false ) ) {
371
+ // if ( ! monsterinsights_is_dev_url( network_site_url( '/' ) ) ) {
372
+ // if ( monsterinsights_is_pro_version() ) {
373
+ // monsterinsights_update_option( 'anonymous_data', 1 );
374
+ // return;
375
+ // }
376
+ // $optin_url = add_query_arg( 'mi_action', 'opt_into_tracking' );
377
+ // $optout_url = add_query_arg( 'mi_action', 'opt_out_of_tracking' );
378
+ // echo '<div class="updated"><p>';
379
+ // echo esc_html__( 'Allow MonsterInsights to track plugin usage? Opt-in to tracking and our newsletter to stay informed of the latest changes to MonsterInsights and help us ensure compatibility.', 'google-analytics-for-wordpress' );
380
+ // echo '&nbsp;<a href="' . esc_url( $optin_url ) . '" class="button-secondary">' . __( 'Allow', 'google-analytics-for-wordpress' ) . '</a>';
381
+ // echo '&nbsp;<a href="' . esc_url( $optout_url ) . '" class="button-secondary">' . __( 'Do not allow', 'google-analytics-for-wordpress' ) . '</a>';
382
+ // echo '</p></div>';
383
+ // return;
384
+ // } else {
385
+ // // is testing site
386
+ // update_option( 'monsterinsights_tracking_notice', '1' );
387
+ // }
388
+ // }
389
+ // }
390
+ // }
391
+
392
+ $notices = get_option( 'monsterinsights_notices' );
393
+ if ( ! is_array( $notices ) ) {
394
+ $notices = array();
395
+ }
396
+
397
+ // 6. Authenticate, not manual
398
+ $authed = MonsterInsights()->auth->is_authed() || MonsterInsights()->auth->is_network_authed();
399
+ $url = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
400
+ $ua_code = monsterinsights_get_ua_to_output();
401
+ // Translators: Placeholders add links to the settings panel.
402
+ $manual_text = sprintf( esc_html__( 'Important: You are currently using manual UA code output. We highly recommend %1$sauthenticating with MonsterInsights%2$s so that you can access our new reporting area and take advantage of new MonsterInsights features.', 'google-analytics-for-wordpress' ), '<a href="' . $url . '">', '</a>' );
403
+ $migrated = monsterinsights_get_option( 'gadwp_migrated', 0 );
404
+ if ( $migrated > 0 ) {
405
+ $url = admin_url( 'admin.php?page=monsterinsights-getting-started&monsterinsights-migration=1' );
406
+ // Translators: Placeholders add links to the settings panel.
407
+ $text = esc_html__( 'Click %1$shere%2$s to reauthenticate to be able to access reports. For more information why this is required, see our %3$sblog post%4$s.', 'google-analytics-for-wordpress' );
408
+ $manual_text = sprintf( $text, '<a href="' . $url . '">', '</a>', '<a href="' . monsterinsights_get_url( 'notice', 'manual-ua', 'https://www.exactmetrics.com/why-did-we-implement-the-new-google-analytics-authentication-flow-challenges-explained/' ) . '" target="_blank">', '</a>' );
409
+ }
410
+
411
+ if ( empty( $authed ) && ! isset( $notices['monsterinsights_auth_not_manual'] ) && ! empty( $ua_code ) ) {
412
+ echo '<div class="notice notice-info is-dismissible monsterinsights-notice" data-notice="monsterinsights_auth_not_manual">';
413
+ echo '<p>';
414
+ echo $manual_text;
415
+ echo '</p>';
416
+ echo '</div>';
417
+
418
+ return;
419
+ }
420
+
421
+ // 7. Automatic updates not configured
422
+ // if ( ! is_network_admin() ) {
423
+ // $updates = monsterinsights_get_option( 'automatic_updates', false );
424
+ // $url = admin_url( 'admin.php?page=monsterinsights_settings' );
425
+
426
+ // if ( empty( $updates) && ! isset( $notices['monsterinsights_automatic_updates' ] ) ) {
427
+ // echo '<div class="notice notice-info is-dismissible monsterinsights-notice" data-notice="monsterinsights_automatic_updates">';
428
+ // echo '<p>';
429
+ // echo sprintf( esc_html__( 'Important: Please %1$sconfigure the Automatic Updates Settings%2$s in MonsterInsights.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' );
430
+ // echo '</p>';
431
+ // echo '</div>';
432
+ // return;
433
+ // }
434
+ // }
435
+
436
+ // 8. WooUpsell
437
+ if ( ! monsterinsights_is_pro_version() && class_exists( 'WooCommerce' ) ) {
438
+ if ( ! isset( $notices['monsterinsights_woocommerce_tracking_available' ] ) ) {
439
+ echo '<div class="notice notice-success is-dismissible monsterinsights-notice monsterinsights-wooedd-upsell-row" data-notice="monsterinsights_woocommerce_tracking_available">';
440
+ echo '<div class="monsterinsights-wooedd-upsell-left">';
441
+ echo '<p><strong>';
442
+ echo esc_html( 'Enhanced Ecommerce Analytics for Your WooCommerce Store', 'google-analytics-for-wordpress' );
443
+ echo '</strong></p>';
444
+ echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-small" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
445
+ echo '<p>';
446
+ echo esc_html( 'MonsterInsights Pro gives you detailed stats and insights about your customers.', 'google-analytics-for-wordpress' );
447
+ echo '</p>';
448
+ echo '<p>';
449
+ echo esc_html( 'This helps you make data-driven decisions about your content, and marketing strategy so you can increase your website traffic, leads, and sales.', 'google-analytics-for-wordpress' );
450
+ echo '</p>';
451
+ echo '<p>';
452
+ echo esc_html( 'Pro customers also get Form Tracking, Custom Dimensions Tracking, UserID Tracking and much more.', 'google-analytics-for-wordpress' );
453
+ echo '</p>';
454
+ echo '<p>';
455
+ echo esc_html( 'Start making data-driven decisions to grow your business.', 'google-analytics-for-wordpress' );
456
+ echo '</p>';
457
+ // Translators: Placeholders add a link to the MonsterInsights website.
458
+ echo sprintf( esc_html__( '%1$sGet MonsterInsights Pro%2$s', 'google-analytics-for-wordpress' ), '<a class="button button-primary button-hero" href="'. monsterinsights_get_upgrade_link( 'admin-notices', 'woocommerce-upgrade' ) .'">', ' &raquo;</a>' );
459
+ echo '</p>';
460
+ echo '</div><div class="monsterinsights-wooedd-upsell-right">';
461
+ echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-large" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
462
+ echo '</div>';
463
+ echo '</div>';
464
+ return;
465
+ }
466
+ }
467
+
468
+ // 9. EDDUpsell
469
+ if ( ! monsterinsights_is_pro_version() && class_exists( 'Easy_Digital_Downloads' ) ) {
470
+ if ( ! isset( $notices['monsterinsights_edd_tracking_available' ] ) ) {
471
+ echo '<div class="notice notice-success is-dismissible monsterinsights-notice monsterinsights-wooedd-upsell-row" data-notice="monsterinsights_edd_tracking_available">';
472
+ echo '<div class="monsterinsights-wooedd-upsell-left">';
473
+ echo '<p><strong>';
474
+ echo esc_html( 'Enhanced Ecommerce Analytics for Your Easy Digital Downloads Store', 'google-analytics-for-wordpress' );
475
+ echo '</strong></p>';
476
+ echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-small" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
477
+ echo '<p>';
478
+ echo esc_html( 'MonsterInsights Pro gives you detailed stats and insights about your customers.', 'google-analytics-for-wordpress' );
479
+ echo '</p>';
480
+ echo '<p>';
481
+ echo esc_html( 'This helps you make data-driven decisions about your content, and marketing strategy so you can increase your website traffic, leads, and sales.', 'google-analytics-for-wordpress' );
482
+ echo '</p>';
483
+ echo '<p>';
484
+ echo esc_html( 'Pro customers also get Form Tracking, Custom Dimensions Tracking, UserID Tracking and much more.', 'google-analytics-for-wordpress' );
485
+ echo '</p>';
486
+ echo '<p>';
487
+ echo esc_html( 'Start making data-driven decisions to grow your business.', 'google-analytics-for-wordpress' );
488
+ echo '</p>';
489
+ echo sprintf( esc_html__( '%1$sGet MonsterInsights Pro%2$s', 'google-analytics-for-wordpress' ), '<a class="button button-primary button-hero" href="'. monsterinsights_get_upgrade_link( 'admin-notices', 'edd-upgrade' ) .'">', ' &raquo;</a>' );
490
+ echo '</p>';
491
+ echo '</div><div class="monsterinsights-wooedd-upsell-right">';
492
+ echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-large" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
493
+ echo '</div>';
494
+ echo '</div>';
495
+ return;
496
+ }
497
+ }
498
+
499
+ if ( isset( $notices['monsterinsights_cross_domains_extracted'] ) && false === $notices['monsterinsights_cross_domains_extracted'] ) {
500
+ $page = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
501
+ $page = $page . '#/advanced';
502
+ // Translators: Adds a link to the settings panel.
503
+ $message = sprintf( esc_html__( 'Warning: MonsterInsights found cross-domain settings in the custom code field and converted them to the new settings structure. %1$sPlease click here to review and remove the code no longer needed.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. esc_url( $page ) . '">', '</a>' );
504
+ echo '<div class="notice notice-success is-dismissible monsterinsights-notice" data-notice="monsterinsights_cross_domains_extracted"><p>'. $message.'</p></div>';
505
+ return;
506
+ }
507
+ }
508
+ add_action( 'admin_notices', 'monsterinsights_admin_setup_notices' );
509
+ add_action( 'network_admin_notices', 'monsterinsights_admin_setup_notices' );
510
+
511
+
512
+ // AM Notices
513
+ function monsterinsights_am_notice_optout( $super_admin ) {
514
+ if ( monsterinsights_get_option( 'hide_am_notices', false ) || monsterinsights_get_option( 'network_hide_am_notices', false ) ) {
515
+ return false;
516
+ }
517
+ return $super_admin;
518
+ }
519
+ add_filter( "am_notifications_display", 'monsterinsights_am_notice_optout', 10, 1 );
520
+
521
+ /**
522
+ * Inline critical css for the menu to prevent breaking the layout when our scripts get blocked by browsers.
523
+ */
524
+ function monsterinsights_admin_menu_inline_styles() {
525
+ ?>
526
+ <style type="text/css">
527
+ #toplevel_page_monsterinsights_reports .wp-menu-image img,
528
+ #toplevel_page_monsterinsights_settings .wp-menu-image img,
529
+ #toplevel_page_monsterinsights_network .wp-menu-image img {
530
+ width: 18px;
531
+ height: auto;
532
+ padding-top: 7px;
533
+ }
534
+ </style>
535
+ <?php
536
+ }
537
+
538
+ add_action( 'admin_footer', 'monsterinsights_admin_menu_inline_styles', 300 );
includes/admin/ajax.php CHANGED
@@ -1,209 +1,209 @@
1
- <?php
2
- /**
3
- * Handles all admin ajax interactions for the MonsterInsights plugin.
4
- *
5
- * @since 6.0.0
6
- *
7
- * @package MonsterInsights
8
- * @subpackage Ajax
9
- * @author Chris Christoff
10
- */
11
-
12
- // Exit if accessed directly
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
-
17
- /**
18
- * Stores a user setting for the logged-in WordPress User
19
- *
20
- * @access public
21
- * @since 6.0.0
22
- */
23
- function monsterinsights_ajax_set_user_setting() {
24
-
25
- // Run a security check first.
26
- check_ajax_referer( 'monsterinsights-set-user-setting', 'nonce' );
27
-
28
- // Prepare variables.
29
- $name = stripslashes( $_POST['name'] );
30
- $value = stripslashes( $_POST['value'] );
31
-
32
- // Set user setting.
33
- set_user_setting( $name, $value );
34
-
35
- // Send back the response.
36
- wp_send_json_success();
37
- wp_die();
38
-
39
- }
40
- add_action( 'wp_ajax_monsterinsights_install_addon', 'monsterinsights_ajax_install_addon' );
41
-
42
- /**
43
- * Installs a MonsterInsights addon.
44
- *
45
- * @access public
46
- * @since 6.0.0
47
- */
48
- function monsterinsights_ajax_install_addon() {
49
-
50
- // Run a security check first.
51
- check_ajax_referer( 'monsterinsights-install', 'nonce' );
52
-
53
- if ( ! current_user_can( 'install_plugins' ) ) {
54
- echo json_encode( true );
55
- }
56
-
57
- // Install the addon.
58
- if ( isset( $_POST['plugin'] ) ) {
59
- $download_url = $_POST['plugin'];
60
- global $hook_suffix;
61
-
62
- // Set the current screen to avoid undefined notices.
63
- set_current_screen();
64
-
65
- // Prepare variables.
66
- $method = '';
67
- $url = add_query_arg(
68
- array(
69
- 'page' => 'monsterinsights-settings'
70
- ),
71
- admin_url( 'admin.php' )
72
- );
73
- $url = esc_url( $url );
74
-
75
- // Start output bufferring to catch the filesystem form if credentials are needed.
76
- ob_start();
77
- if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) {
78
- $form = ob_get_clean();
79
- echo json_encode( array( 'form' => $form ) );
80
- wp_die();
81
- }
82
-
83
- // If we are not authenticated, make it happen now.
84
- if ( ! WP_Filesystem( $creds ) ) {
85
- ob_start();
86
- request_filesystem_credentials( $url, $method, true, false, null );
87
- $form = ob_get_clean();
88
- echo json_encode( array( 'form' => $form ) );
89
- wp_die();
90
- }
91
-
92
- // We do not need any extra credentials if we have gotten this far, so let's install the plugin.
93
- require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
94
- $base = MonsterInsights();
95
- require_once plugin_dir_path( $base->file ) . '/includes/admin/licensing/skin.php';
96
-
97
- // Create the plugin upgrader with our custom skin.
98
- $installer = new Plugin_Upgrader( $skin = new MonsterInsights_Skin() );
99
- $installer->install( $download_url );
100
-
101
- // Flush the cache and return the newly installed plugin basename.
102
- wp_cache_flush();
103
- if ( $installer->plugin_info() ) {
104
- $plugin_basename = $installer->plugin_info();
105
- echo json_encode( array( 'plugin' => $plugin_basename ) );
106
- wp_die();
107
- }
108
- }
109
-
110
- // Send back a response.
111
- echo json_encode( true );
112
- wp_die();
113
-
114
- }
115
-
116
- add_action( 'wp_ajax_monsterinsights_activate_addon', 'monsterinsights_ajax_activate_addon' );
117
- /**
118
- * Activates a MonsterInsights addon.
119
- *
120
- * @access public
121
- * @since 6.0.0
122
- */
123
- function monsterinsights_ajax_activate_addon() {
124
-
125
- // Run a security check first.
126
- check_ajax_referer( 'monsterinsights-activate', 'nonce' );
127
-
128
- if ( ! current_user_can( 'activate_plugins' ) ) {
129
- echo json_encode( true );
130
- }
131
-
132
- // Activate the addon.
133
- if ( isset( $_POST['plugin'] ) ) {
134
- if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) {
135
- $activate = activate_plugin( $_POST['plugin'], NULL, true );
136
- } else {
137
- $activate = activate_plugin( $_POST['plugin'] );
138
- }
139
-
140
- if ( is_wp_error( $activate ) ) {
141
- echo json_encode( array( 'error' => $activate->get_error_message() ) );
142
- wp_die();
143
- }
144
- }
145
-
146
- echo json_encode( true );
147
- wp_die();
148
-
149
- }
150
-
151
- add_action( 'wp_ajax_monsterinsights_deactivate_addon', 'monsterinsights_ajax_deactivate_addon' );
152
- /**
153
- * Deactivates a MonsterInsights addon.
154
- *
155
- * @access public
156
- * @since 6.0.0
157
- */
158
- function monsterinsights_ajax_deactivate_addon() {
159
-
160
- // Run a security check first.
161
- check_ajax_referer( 'monsterinsights-deactivate', 'nonce' );
162
-
163
- if ( ! current_user_can( 'activate_plugins' ) ) {
164
- echo json_encode( true );
165
- }
166
-
167
- // Deactivate the addon.
168
- if ( isset( $_POST['plugin'] ) ) {
169
- if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) {
170
- $deactivate = deactivate_plugins( $_POST['plugin'], false, true );
171
- } else {
172
- $deactivate = deactivate_plugins( $_POST['plugin'] );
173
- }
174
- }
175
-
176
- echo json_encode( true );
177
- wp_die();
178
- }
179
-
180
- /**
181
- * Called whenever a notice is dismissed in MonsterInsights or its Addons.
182
- *
183
- * Updates a key's value in the options table to mark the notice as dismissed,
184
- * preventing it from displaying again
185
- *
186
- * @access public
187
- * @since 6.0.0
188
- */
189
- function monsterinsights_ajax_dismiss_notice() {
190
-
191
- // Run a security check first.
192
- check_ajax_referer( 'monsterinsights-dismiss-notice', 'nonce' );
193
-
194
- // Deactivate the notice
195
- if ( isset( $_POST['notice'] ) ) {
196
- // Init the notice class and mark notice as deactivated
197
- MonsterInsights()->notices->dismiss( $_POST['notice'] );
198
-
199
- // Return true
200
- echo json_encode( true );
201
- wp_die();
202
- }
203
-
204
- // If here, an error occurred
205
- echo json_encode( false );
206
- wp_die();
207
-
208
- }
209
  add_action( 'wp_ajax_monsterinsights_ajax_dismiss_notice', 'monsterinsights_ajax_dismiss_notice' );
1
+ <?php
2
+ /**
3
+ * Handles all admin ajax interactions for the MonsterInsights plugin.
4
+ *
5
+ * @since 6.0.0
6
+ *
7
+ * @package MonsterInsights
8
+ * @subpackage Ajax
9
+ * @author Chris Christoff
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ /**
18
+ * Stores a user setting for the logged-in WordPress User
19
+ *
20
+ * @access public
21
+ * @since 6.0.0
22
+ */
23
+ function monsterinsights_ajax_set_user_setting() {
24
+
25
+ // Run a security check first.
26
+ check_ajax_referer( 'monsterinsights-set-user-setting', 'nonce' );
27
+
28
+ // Prepare variables.
29
+ $name = stripslashes( $_POST['name'] );
30
+ $value = stripslashes( $_POST['value'] );
31
+
32
+ // Set user setting.
33
+ set_user_setting( $name, $value );
34
+
35
+ // Send back the response.
36
+ wp_send_json_success();
37
+ wp_die();
38
+
39
+ }
40
+ add_action( 'wp_ajax_monsterinsights_install_addon', 'monsterinsights_ajax_install_addon' );
41
+
42
+ /**
43
+ * Installs a MonsterInsights addon.
44
+ *
45
+ * @access public
46
+ * @since 6.0.0
47
+ */
48
+ function monsterinsights_ajax_install_addon() {
49
+
50
+ // Run a security check first.
51
+ check_ajax_referer( 'monsterinsights-install', 'nonce' );
52
+
53
+ if ( ! current_user_can( 'install_plugins' ) ) {
54
+ echo json_encode( true );
55
+ }
56
+
57
+ // Install the addon.
58
+ if ( isset( $_POST['plugin'] ) ) {
59
+ $download_url = $_POST['plugin'];
60
+ global $hook_suffix;
61
+
62
+ // Set the current screen to avoid undefined notices.
63
+ set_current_screen();
64
+
65
+ // Prepare variables.
66
+ $method = '';
67
+ $url = add_query_arg(
68
+ array(
69
+ 'page' => 'monsterinsights-settings'
70
+ ),
71
+ admin_url( 'admin.php' )
72
+ );
73
+ $url = esc_url( $url );
74
+
75
+ // Start output bufferring to catch the filesystem form if credentials are needed.
76
+ ob_start();
77
+ if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) {
78
+ $form = ob_get_clean();
79
+ echo json_encode( array( 'form' => $form ) );
80
+ wp_die();
81
+ }
82
+
83
+ // If we are not authenticated, make it happen now.
84
+ if ( ! WP_Filesystem( $creds ) ) {
85
+ ob_start();
86
+ request_filesystem_credentials( $url, $method, true, false, null );
87
+ $form = ob_get_clean();
88
+ echo json_encode( array( 'form' => $form ) );
89
+ wp_die();
90
+ }
91
+
92
+ // We do not need any extra credentials if we have gotten this far, so let's install the plugin.
93
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
94
+ $base = MonsterInsights();
95
+ require_once plugin_dir_path( $base->file ) . '/includes/admin/licensing/skin.php';
96
+
97
+ // Create the plugin upgrader with our custom skin.
98
+ $installer = new Plugin_Upgrader( $skin = new MonsterInsights_Skin() );
99
+ $installer->install( $download_url );
100
+
101
+ // Flush the cache and return the newly installed plugin basename.
102
+ wp_cache_flush();
103
+ if ( $installer->plugin_info() ) {
104
+ $plugin_basename = $installer->plugin_info();
105
+ echo json_encode( array( 'plugin' => $plugin_basename ) );
106
+ wp_die();
107
+ }
108
+ }
109
+
110
+ // Send back a response.
111
+ echo json_encode( true );
112
+ wp_die();
113
+
114
+ }
115
+
116
+ add_action( 'wp_ajax_monsterinsights_activate_addon', 'monsterinsights_ajax_activate_addon' );
117
+ /**
118
+ * Activates a MonsterInsights addon.
119
+ *
120
+ * @access public
121
+ * @since 6.0.0
122
+ */
123
+ function monsterinsights_ajax_activate_addon() {
124
+
125
+ // Run a security check first.
126
+ check_ajax_referer( 'monsterinsights-activate', 'nonce' );
127
+
128
+ if ( ! current_user_can( 'activate_plugins' ) ) {
129
+ echo json_encode( true );
130
+ }
131
+
132
+ // Activate the addon.
133
+ if ( isset( $_POST['plugin'] ) ) {
134
+ if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) {
135
+ $activate = activate_plugin( $_POST['plugin'], NULL, true );
136
+ } else {
137
+ $activate = activate_plugin( $_POST['plugin'] );
138
+ }
139
+
140
+ if ( is_wp_error( $activate ) ) {
141
+ echo json_encode( array( 'error' => $activate->get_error_message() ) );
142
+ wp_die();
143
+ }
144
+ }
145
+
146
+ echo json_encode( true );
147
+ wp_die();
148
+
149
+ }
150
+
151
+ add_action( 'wp_ajax_monsterinsights_deactivate_addon', 'monsterinsights_ajax_deactivate_addon' );
152
+ /**
153
+ * Deactivates a MonsterInsights addon.
154
+ *
155
+ * @access public
156
+ * @since 6.0.0
157
+ */
158
+ function monsterinsights_ajax_deactivate_addon() {
159
+
160
+ // Run a security check first.
161
+ check_ajax_referer( 'monsterinsights-deactivate', 'nonce' );
162
+
163
+ if ( ! current_user_can( 'activate_plugins' ) ) {
164
+ echo json_encode( true );
165
+ }
166
+
167
+ // Deactivate the addon.
168
+ if ( isset( $_POST['plugin'] ) ) {
169
+ if ( isset( $_POST['isnetwork'] ) && $_POST['isnetwork'] ) {
170
+ $deactivate = deactivate_plugins( $_POST['plugin'], false, true );
171
+ } else {
172
+ $deactivate = deactivate_plugins( $_POST['plugin'] );
173
+ }
174
+ }
175
+
176
+ echo json_encode( true );
177
+ wp_die();
178
+ }
179
+
180
+ /**
181
+ * Called whenever a notice is dismissed in MonsterInsights or its Addons.
182
+ *
183
+ * Updates a key's value in the options table to mark the notice as dismissed,
184
+ * preventing it from displaying again
185
+ *
186
+ * @access public
187
+ * @since 6.0.0
188
+ */
189
+ function monsterinsights_ajax_dismiss_notice() {
190
+
191
+ // Run a security check first.
192
+ check_ajax_referer( 'monsterinsights-dismiss-notice', 'nonce' );
193
+
194
+ // Deactivate the notice
195
+ if ( isset( $_POST['notice'] ) ) {
196
+ // Init the notice class and mark notice as deactivated
197
+ MonsterInsights()->notices->dismiss( $_POST['notice'] );
198
+
199
+ // Return true
200
+ echo json_encode( true );
201
+ wp_die();
202
+ }
203
+
204
+ // If here, an error occurred
205
+ echo json_encode( false );
206
+ wp_die();
207
+
208
+ }
209
  add_action( 'wp_ajax_monsterinsights_ajax_dismiss_notice', 'monsterinsights_ajax_dismiss_notice' );
includes/admin/api-auth.php CHANGED
@@ -1,583 +1,583 @@
1
- <?php
2
- /**
3
- * Google Client admin class.
4
- *
5
- * Handles retrieving whether a particular notice has been dismissed or not,
6
- * as well as marking a notice as dismissed.
7
- *
8
- * @since 7.0.0
9
- *
10
- * @package MonsterInsights
11
- * @subpackage GA Client
12
- * @author Chris Christoff
13
- */
14
-
15
- // Exit if accessed directly
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- exit;
18
- }
19
-
20
- final class MonsterInsights_API_Auth {
21
-
22
- /**
23
- * Primary class constructor.
24
- *
25
- * @access public
26
- * @since 7.0.0
27
- */
28
- public function __construct() {
29
-
30
- // Authentication Actions
31
- add_action( 'wp_ajax_monsterinsights_maybe_authenticate', array( $this, 'maybe_authenticate' ) );
32
- add_action( 'wp_ajax_monsterinsights_maybe_reauthenticate', array( $this, 'maybe_reauthenticate' ) );
33
- add_action( 'wp_ajax_monsterinsights_maybe_verify', array( $this, 'maybe_verify' ) );
34
- add_action( 'wp_ajax_monsterinsights_maybe_delete', array( $this, 'maybe_delete' ) );
35
-
36
- add_action( 'admin_init', array( $this, 'authenticate_listener' ) );
37
- add_action( 'admin_init', array( $this, 'reauthenticate_listener' ) );
38
-
39
- add_action( 'wp_ajax_nopriv_monsterinsights_is_installed', array( $this, 'is_installed' ) );
40
- add_action( 'wp_ajax_nopriv_monsterinsights_rauthenticate', array( $this, 'rauthenticate' ) );
41
-
42
- add_filter( 'monsterinsights_maybe_authenticate_siteurl', array( $this, 'before_redirect' ) );
43
- }
44
-
45
- public function get_tt(){
46
- $tt = is_network_admin() ? get_site_option( 'monsterinsights_network_tt', '' ) : get_option( 'monsterinsights_site_tt', '' );
47
- if ( empty( $tt ) ) {
48
- // if TT is empty, generate a new one, save it and then return it
49
- $tt = $this->generate_tt();
50
- $this->is_network_admin() ? update_site_option( 'monsterinsights_network_tt', $tt ) : update_option( 'monsterinsights_site_tt', $tt );
51
- }
52
- return $tt;
53
- }
54
-
55
- public function rotate_tt(){
56
- $tt = $this->generate_tt();
57
- is_network_admin() ? update_site_option( 'monsterinsights_network_tt', $tt ) : update_option( 'monsterinsights_site_tt', $tt );
58
- }
59
-
60
- public function generate_tt(){
61
- return hash( 'sha512', wp_generate_password( 128, true, true ) . AUTH_SALT . uniqid( "", true ) );
62
- }
63
-
64
- public function validate_tt( $passed_tt = '' ) {
65
- $tt = $this->get_tt();
66
- return hash_equals( $tt, $passed_tt );
67
- }
68
-
69
- public function is_installed() {
70
- wp_send_json_success(
71
- array(
72
- 'version' => MONSTERINSIGHTS_VERSION,
73
- 'pro' => monsterinsights_is_pro_version(),
74
- )
75
- );
76
- }
77
-
78
- public function maybe_authenticate(){
79
-
80
- // Check nonce
81
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
82
-
83
- // current user can authenticate
84
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
85
- wp_send_json_error( array( 'message' => __( "You don't have permission to authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
86
- }
87
-
88
- if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
89
- define( 'WP_NETWORK_ADMIN', true );
90
- }
91
-
92
- // Only for Pro users, require a license key to be entered first so we can link to things.
93
- if ( monsterinsights_is_pro_version() ) {
94
- $valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed();
95
- if ( ! $valid ) {
96
- wp_send_json_error( array( 'message' => __( "Cannot authenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
97
- }
98
- }
99
-
100
- // we do not have a current auth
101
- if ( ! $this->is_network_admin() && MonsterInsights()->auth->is_authed() ) {
102
- wp_send_json_error( array( 'message' => __( "Cannot authenticate. Please re-authenticate.", 'google-analytics-for-wordpress' ) ) );
103
- } else if ( $this->is_network_admin() && MonsterInsights()->auth->is_network_authed() ) {
104
- wp_send_json_error( array( 'message' => __( "Cannot network authenticate. Please re-authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) );
105
- }
106
-
107
- $sitei = $this->get_sitei();
108
- //update_network_option( get_current_network_id(), 'monsterinsights_network_sitei', $sitei );
109
-
110
- $siteurl = add_query_arg( array(
111
- 'tt' => $this->get_tt(),
112
- 'sitei' => $sitei,
113
- 'miversion' => MONSTERINSIGHTS_VERSION,
114
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
115
- 'network' => is_network_admin() ? 'network' : 'site',
116
- 'siteurl' => is_network_admin() ? network_admin_url() : site_url(),
117
- 'return' => is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ),
118
- 'testurl' => 'https://' . monsterinsights_get_api_url() . 'test/',
119
- ), $this->get_route( 'https://' . monsterinsights_get_api_url() . 'auth/new/{type}' ) );
120
-
121
- if ( monsterinsights_is_pro_version() ) {
122
- $key = is_network_admin() ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key();
123
- $siteurl = add_query_arg( 'license', $key, $siteurl );
124
- }
125
-
126
- $siteurl = apply_filters( 'monsterinsights_maybe_authenticate_siteurl', $siteurl );
127
- wp_send_json_success( array( 'redirect' => $siteurl ) );
128
- }
129
-
130
- public function rauthenticate() {
131
- // Check for missing params
132
- $reqd_args = array( 'key', 'token', 'ua', 'miview', 'a', 'w', 'p', 'tt', 'network' );
133
- foreach ( $reqd_args as $arg ) {
134
- if ( empty( $_REQUEST[$arg] ) ) {
135
- wp_send_json_error(
136
- array(
137
- 'error' => 'authenticate_missing_arg',
138
- 'message' => 'Authenticate missing parameter: ' . $arg,
139
- 'version' => MONSTERINSIGHTS_VERSION,
140
- 'pro' => monsterinsights_is_pro_version(),
141
- )
142
- );
143
- }
144
- }
145
-
146
- if ( ! empty( $_REQUEST['network'] ) && 'network' === $_REQUEST['network'] ) {
147
- define( 'WP_NETWORK_ADMIN', true );
148
- }
149
-
150
- if ( ! $this->validate_tt( $_REQUEST['tt'] ) ) {
151
- wp_send_json_error(
152
- array(
153
- 'error' => 'authenticate_invalid_tt',
154
- 'message' => 'Invalid TT sent',
155
- 'version' => MONSTERINSIGHTS_VERSION,
156
- 'pro' => monsterinsights_is_pro_version(),
157
- )
158
- );
159
- }
160
-
161
- // If the tt is validated, send a success response to trigger the regular auth process.
162
- wp_send_json_success();
163
- }
164
-
165
- public function authenticate_listener(){
166
- // Make sure it's for us
167
- if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'auth' ) {
168
- return;
169
- }
170
-
171
- // User can authenticate
172
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
173
- return;
174
- }
175
-
176
- // Invalid request
177
- if ( empty( $_REQUEST['tt'] ) || ! $this->validate_tt( $_REQUEST['tt'] ) ) {
178
- return;
179
- }
180
-
181
- // Make sure has required params
182
- if ( empty( $_REQUEST['key'] ) ||
183
- empty( $_REQUEST['token'] ) ||
184
- empty( $_REQUEST['ua'] ) ||
185
- empty( $_REQUEST['miview'] ) ||
186
- empty( $_REQUEST['a'] ) ||
187
- empty( $_REQUEST['w'] ) ||
188
- empty( $_REQUEST['p'] )
189
- ) {
190
- return;
191
- }
192
-
193
- // Invalid UA code
194
- $ua = monsterinsights_is_valid_ua( $_REQUEST['ua'] );
195
- if ( empty( $ua ) ) {
196
- return;
197
- }
198
-
199
- $profile = array(
200
- 'key' => sanitize_text_field( $_REQUEST['key'] ),
201
- 'token' => sanitize_text_field( $_REQUEST['token'] ),
202
- 'ua' => monsterinsights_is_valid_ua( $_REQUEST['ua'] ),
203
- 'viewname' => sanitize_text_field( $_REQUEST['miview'] ),
204
- 'a' => sanitize_text_field( $_REQUEST['a'] ), // AccountID
205
- 'w' => sanitize_text_field( $_REQUEST['w'] ), // PropertyID
206
- 'p' => sanitize_text_field( $_REQUEST['p'] ), // View ID
207
- 'siteurl' => site_url(),
208
- 'neturl' => network_admin_url(),
209
- );
210
-
211
- $worked = $this->verify_auth( $profile );
212
- if ( ! $worked || is_wp_error( $worked ) ) {
213
- return;
214
- }
215
-
216
- // Save Profile
217
- $this->is_network_admin() ? MonsterInsights()->auth->set_network_analytics_profile( $profile ) : MonsterInsights()->auth->set_analytics_profile( $profile );
218
-
219
- // Clear cache
220
- $where = $this->is_network_admin() ? 'network' : 'site';
221
- MonsterInsights()->reporting->delete_aggregate_data( $where );
222
-
223
- $url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ) ;
224
- $url = add_query_arg( array(
225
- 'mi_action' => 'auth',
226
- 'success' => 'true',
227
- ), $url );
228
- $url = apply_filters( 'monsterinsights_auth_success_redirect_url', $url );
229
- wp_safe_redirect( $url );
230
- exit;
231
- }
232
-
233
- public function maybe_reauthenticate(){
234
-
235
- // Check nonce
236
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
237
-
238
- // current user can authenticate
239
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
240
- wp_send_json_error( array( 'message' => __( "You don't have permission to re-authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
241
- }
242
-
243
- if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
244
- define( 'WP_NETWORK_ADMIN', true );
245
- }
246
-
247
- // Only for Pro users, require a license key to be entered first so we can link to things.
248
- if ( monsterinsights_is_pro_version() ) {
249
- $valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed();
250
- if ( monsterinsights_is_pro_version() && ! $valid ) {
251
- wp_send_json_error( array( 'message' => __( "Cannot re-authenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
252
- }
253
- }
254
-
255
- // we do have a current auth
256
- if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
257
- wp_send_json_error( array( 'message' => __( "Cannot re-authenticate. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
258
- } else if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
259
- wp_send_json_error( array( 'message' => __( "Cannot re-authenticate the network. Please authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) );
260
- }
261
-
262
- $siteurl = add_query_arg( array(
263
- 'tt' => $this->get_tt(),
264
- 'sitei' => $this->get_sitei(),
265
- 'miversion' => MONSTERINSIGHTS_VERSION,
266
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
267
- 'network' => is_network_admin() ? 'network' : 'site',
268
- 'siteurl' => is_network_admin() ? network_admin_url() : site_url(),
269
- 'key' => MonsterInsights()->auth->get_key(),
270
- 'token' => MonsterInsights()->auth->get_token(),
271
- 'return' => is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ),
272
- 'testurl' => 'https://' . monsterinsights_get_api_url() . 'test/',
273
- ), $this->get_route( 'https://' . monsterinsights_get_api_url() . 'auth/reauth/{type}' ) );
274
-
275
- if ( monsterinsights_is_pro_version() ) {
276
- $key = is_network_admin() ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key();
277
- $siteurl = add_query_arg( 'license', $key, $siteurl );
278
- }
279
-
280
- $siteurl = apply_filters( 'monsterinsights_maybe_authenticate_siteurl', $siteurl );
281
-
282
- wp_send_json_success( array( 'redirect' => $siteurl ) );
283
- }
284
-
285
- public function reauthenticate_listener(){
286
- // Make sure it's for us
287
- if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'reauth' ) {
288
- return;
289
- }
290
-
291
- // User can authenticate
292
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
293
- return;
294
- }
295
-
296
- // Invalid request
297
- if ( empty( $_REQUEST['tt'] ) || ! $this->validate_tt( $_REQUEST['tt'] ) ) {
298
- return;
299
- }
300
-
301
- // Make sure has required params
302
- if (
303
- empty( $_REQUEST['ua'] ) ||
304
- empty( $_REQUEST['miview'] ) ||
305
- empty( $_REQUEST['a'] ) ||
306
- empty( $_REQUEST['w'] ) ||
307
- empty( $_REQUEST['p'] )
308
- ) {
309
- return;
310
- }
311
-
312
- // Invalid UA code
313
- $ua = monsterinsights_is_valid_ua( $_REQUEST['ua'] );
314
- if ( empty( $ua ) ) {
315
- return;
316
- }
317
-
318
- // we do have a current auth
319
- $existing = $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile() : MonsterInsights()->auth->get_analytics_profile();
320
- if ( empty( $existing['key'] ) || empty( $existing['token'] ) ) {
321
- return;
322
- }
323
-
324
- $profile = array(
325
- 'key' => $existing['key'],
326
- 'token' => $existing['token'],
327
- 'ua' => monsterinsights_is_valid_ua( $_REQUEST['ua'] ),
328
- 'viewname' => sanitize_text_field( $_REQUEST['miview'] ),
329
- 'a' => sanitize_text_field( $_REQUEST['a'] ),
330
- 'w' => sanitize_text_field( $_REQUEST['w'] ),
331
- 'p' => sanitize_text_field( $_REQUEST['p'] ),
332
- 'siteurl' => site_url(),
333
- 'neturl' => network_admin_url(),
334
- );
335
-
336
- // Save Profile
337
- $this->is_network_admin() ? MonsterInsights()->auth->set_network_analytics_profile( $profile ) : MonsterInsights()->auth->set_analytics_profile( $profile );
338
-
339
- // Clear cache
340
- $where = $this->is_network_admin() ? 'network' : 'site';
341
- MonsterInsights()->reporting->delete_aggregate_data( $where );
342
-
343
- $url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ) ;
344
- $url = add_query_arg( array(
345
- 'mi_action' => 'reauth',
346
- 'success' => 'true',
347
- ), $url );
348
- $url = apply_filters( 'monsterinsights_reauth_success_redirect_url', $url );
349
-
350
- wp_safe_redirect( $url );
351
- exit;
352
- }
353
-
354
- public function maybe_verify(){
355
-
356
- // Check nonce
357
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
358
-
359
- // current user can verify
360
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
361
- wp_send_json_error( array( 'message' => __( "You don't have permission to verify MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
362
- }
363
-
364
- if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
365
- define( 'WP_NETWORK_ADMIN', true );
366
- }
367
-
368
- // we have an auth to verify
369
- if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
370
- wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
371
- } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
372
- wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
373
- }
374
-
375
- if ( monsterinsights_is_pro_version() ) {
376
- $valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed();
377
- if ( ! $valid ) {
378
- wp_send_json_error( array( 'message' => __( "Cannot verify. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
379
- }
380
- }
381
-
382
- $worked = $this->verify_auth();
383
- if ( $worked && ! is_wp_error( $worked ) ) {
384
- wp_send_json_success( array( 'message' => __( "Successfully verified.", 'google-analytics-for-wordpress' ) ) );
385
- } else {
386
- wp_send_json_error( array( 'message' => __( "Could not verify.", 'google-analytics-for-wordpress' ) ) );
387
- }
388
- }
389
-
390
- public function verify_auth( $credentials = array() ){
391
- $creds = ! empty( $credentials ) ? $credentials : ( $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile( true ) : MonsterInsights()->auth->get_analytics_profile( true ) );
392
-
393
- if ( empty( $creds['key'] ) ) {
394
- return new WP_Error( 'validation-error', sprintf( __( 'Verify auth key not passed', 'google-analytics-for-wordpress' ) ) );
395
- }
396
-
397
- $network = ! empty( $_REQUEST['network'] ) ? $_REQUEST['network'] === 'network' : $this->is_network_admin();
398
- $api = new MonsterInsights_API_Request( $this->get_route( 'auth/verify/{type}/' ), array( 'network' => $network, 'tt' => $this->get_tt(), 'key' => $creds['key'], 'token' => $creds['token'], 'testurl' => 'https://' . monsterinsights_get_api_url() . 'test/' ) );
399
- $ret = $api->request();
400
-
401
- $this->rotate_tt();
402
- if ( is_wp_error( $ret ) ) {
403
- return $ret;
404
- } else {
405
- return true;
406
- }
407
- }
408
-
409
- public function maybe_delete(){
410
-
411
- // Check nonce
412
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
413
-
414
- // current user can delete
415
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
416
- wp_send_json_error( array( 'message' => __( "You don't have permission to deauthenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
417
- }
418
-
419
- if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
420
- define( 'WP_NETWORK_ADMIN', true );
421
- }
422
-
423
- // we have an auth to delete
424
- if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
425
- wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) );
426
- } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
427
- wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) );
428
- }
429
-
430
- if ( monsterinsights_is_pro_version() ) {
431
- $valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed();
432
- if ( ! $valid ) {
433
- wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
434
- }
435
- }
436
-
437
- $force = ! empty( $_REQUEST['forcedelete'] ) && $_REQUEST['forcedelete'] === 'true';
438
-
439
- $worked = $this->delete_auth( $force );
440
- if ( $worked && ! is_wp_error( $worked ) ) {
441
- wp_send_json_success( array( 'message' => __( "Successfully deauthenticated.", 'google-analytics-for-wordpress' ) ) );
442
- } else {
443
- if ( $force ) {
444
- wp_send_json_success( array( 'message' => __( "Successfully force deauthenticated.", 'google-analytics-for-wordpress' ) ) );
445
- } else {
446
- wp_send_json_error( array( 'message' => __( "Could not deauthenticate.", 'google-analytics-for-wordpress' ) ) );
447
- }
448
- }
449
- }
450
-
451
- public function delete_auth( $force = false ){
452
- if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
453
- return false;
454
- } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
455
- return false;
456
- }
457
-
458
- $creds = $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile( true ) : MonsterInsights()->auth->get_analytics_profile( true );
459
-
460
- if ( empty( $creds['key'] ) ) {
461
- return false;
462
- }
463
-
464
- // If we have a new siteurl enabled option and the profile site doesn't match the current site, deactivate anyways
465
- if ( is_network_admin() ) {
466
- $siteurl = network_admin_url();
467
- if ( ! empty( $creds['neturl' ] ) && $creds['neturl'] !== $siteurl ) {
468
- MonsterInsights()->auth->delete_network_analytics_profile( true );
469
- return true;
470
- }
471
- } else {
472
- $siteurl = site_url();
473
- if ( ! empty( $creds['siteurl' ] ) && $creds['siteurl'] !== $siteurl ) {
474
- MonsterInsights()->auth->delete_analytics_profile( true );
475
- return true;
476
- }
477
- }
478
-
479
- $api = new MonsterInsights_API_Request( $this->get_route( 'auth/delete/{type}/' ), array( 'network' => $this->is_network_admin(), 'tt' => $this->get_tt(), 'key' => $creds['key'], 'token' => $creds['token'], 'testurl' => 'https://' . monsterinsights_get_api_url() . 'test/' ) );
480
- $ret = $api->request();
481
-
482
- $this->rotate_tt();
483
- if ( is_wp_error( $ret ) && ! $force ) {
484
- return false;
485
- } else {
486
- if ( $this->is_network_admin() ) {
487
- MonsterInsights()->auth->delete_network_analytics_profile( true );
488
- } else {
489
- MonsterInsights()->auth->delete_analytics_profile( true );
490
-
491
- }
492
- return true;
493
- }
494
- }
495
-
496
- /**
497
- * Function to delete network auth in the uninstall process where we can't check if is network admin.
498
- *
499
- * @return bool
500
- */
501
- public function uninstall_network_auth() {
502
-
503
- if ( ! MonsterInsights()->auth->is_network_authed() ) {
504
- return false;
505
- }
506
-
507
- $creds = MonsterInsights()->auth->get_network_analytics_profile( true );
508
-
509
- $api = new MonsterInsights_API_Request( $this->get_route( 'auth/delete/{type}/' ), array(
510
- 'network' => true,
511
- 'tt' => $this->get_tt(),
512
- 'key' => $creds['key'],
513
- 'token' => $creds['token'],
514
- 'testurl' => 'https://' . monsterinsights_get_api_url() . 'test/'
515
- ) );
516
- // Force the network admin url otherwise this will fail not finding the url in relay.
517
- $api->site_url = network_admin_url();
518
- $ret = $api->request();
519
-
520
- $this->rotate_tt();
521
- if ( is_wp_error( $ret ) ) {
522
- return false;
523
- } else {
524
- MonsterInsights()->auth->delete_network_analytics_profile( true );
525
- return true;
526
- }
527
- }
528
-
529
- public function get_type() {
530
- $base = monsterinsights_is_pro_version() ? 'pro' : 'lite';
531
- return apply_filters( 'monsterinsights_api_auth_get_type', $base );
532
- }
533
-
534
- public function get_route( $route = '' ) {
535
- $route = str_replace( '{type}', $this->get_type(), $route );
536
- $route = trailingslashit( $route );
537
- return $route;
538
- }
539
-
540
- public function is_network_admin() {
541
- return is_multisite() && is_network_admin();
542
- }
543
-
544
- public function get_sitei() {
545
- // $sitei = get_network_option( get_current_network_id(), 'monsterinsights_network_sitei', false );
546
- // if ( ! empty( $sitei ) && strlen( $sitei ) >= 1 ) {
547
- // return $sitei;
548
- // }
549
-
550
- $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
551
- $secure_auth_key = defined( 'SECURE_AUTH_KEY' ) ? SECURE_AUTH_KEY : '';
552
- $logged_in_key = defined( 'LOGGED_IN_KEY' ) ? LOGGED_IN_KEY : '';
553
-
554
- $sitei = $auth_key . $secure_auth_key . $logged_in_key;
555
- $sitei = preg_replace('/[^a-zA-Z0-9]/', '', $sitei );
556
- $sitei = sanitize_text_field( $sitei );
557
- $sitei = trim( $sitei );
558
- $sitei = ( strlen($sitei) > 30 ) ? substr($sitei, 0, 30 ) : $sitei;
559
- return $sitei;
560
- }
561
-
562
- /**
563
- * Logic to run before serving the redirect url during auth.
564
- *
565
- * @param string $url
566
- *
567
- * @return string
568
- */
569
- public function before_redirect( $url ) {
570
-
571
- // If Bad Behavior plugin is installed.
572
- if ( function_exists( 'bb2_read_settings' ) ) {
573
- // Make sure the offsite_forms option is enabled to allow auth.
574
- $bb_settings = get_option( 'bad_behavior_settings' );
575
- if ( empty( $bb_settings['offsite_forms'] ) || false === $bb_settings['offsite_forms'] ) {
576
- $bb_settings['offsite_forms'] = true;
577
- update_option( 'bad_behavior_settings', $bb_settings );
578
- }
579
- }
580
-
581
- return $url;
582
- }
583
- }
1
+ <?php
2
+ /**
3
+ * Google Client admin class.
4
+ *
5
+ * Handles retrieving whether a particular notice has been dismissed or not,
6
+ * as well as marking a notice as dismissed.
7
+ *
8
+ * @since 7.0.0
9
+ *
10
+ * @package MonsterInsights
11
+ * @subpackage GA Client
12
+ * @author Chris Christoff
13
+ */
14
+
15
+ // Exit if accessed directly
16
+ if ( ! defined( 'ABSPATH' ) ) {
17
+ exit;
18
+ }
19
+
20
+ final class MonsterInsights_API_Auth {
21
+
22
+ /**
23
+ * Primary class constructor.
24
+ *
25
+ * @access public
26
+ * @since 7.0.0
27
+ */
28
+ public function __construct() {
29
+
30
+ // Authentication Actions
31
+ add_action( 'wp_ajax_monsterinsights_maybe_authenticate', array( $this, 'maybe_authenticate' ) );
32
+ add_action( 'wp_ajax_monsterinsights_maybe_reauthenticate', array( $this, 'maybe_reauthenticate' ) );
33
+ add_action( 'wp_ajax_monsterinsights_maybe_verify', array( $this, 'maybe_verify' ) );
34
+ add_action( 'wp_ajax_monsterinsights_maybe_delete', array( $this, 'maybe_delete' ) );
35
+
36
+ add_action( 'admin_init', array( $this, 'authenticate_listener' ) );
37
+ add_action( 'admin_init', array( $this, 'reauthenticate_listener' ) );
38
+
39
+ add_action( 'wp_ajax_nopriv_monsterinsights_is_installed', array( $this, 'is_installed' ) );
40
+ add_action( 'wp_ajax_nopriv_monsterinsights_rauthenticate', array( $this, 'rauthenticate' ) );
41
+
42
+ add_filter( 'monsterinsights_maybe_authenticate_siteurl', array( $this, 'before_redirect' ) );
43
+ }
44
+
45
+ public function get_tt(){
46
+ $tt = is_network_admin() ? get_site_option( 'monsterinsights_network_tt', '' ) : get_option( 'monsterinsights_site_tt', '' );
47
+ if ( empty( $tt ) ) {
48
+ // if TT is empty, generate a new one, save it and then return it
49
+ $tt = $this->generate_tt();
50
+ $this->is_network_admin() ? update_site_option( 'monsterinsights_network_tt', $tt ) : update_option( 'monsterinsights_site_tt', $tt );
51
+ }
52
+ return $tt;
53
+ }
54
+
55
+ public function rotate_tt(){
56
+ $tt = $this->generate_tt();
57
+ is_network_admin() ? update_site_option( 'monsterinsights_network_tt', $tt ) : update_option( 'monsterinsights_site_tt', $tt );
58
+ }
59
+
60
+ public function generate_tt(){
61
+ return hash( 'sha512', wp_generate_password( 128, true, true ) . AUTH_SALT . uniqid( "", true ) );
62
+ }
63
+
64
+ public function validate_tt( $passed_tt = '' ) {
65
+ $tt = $this->get_tt();
66
+ return hash_equals( $tt, $passed_tt );
67
+ }
68
+
69
+ public function is_installed() {
70
+ wp_send_json_success(
71
+ array(
72
+ 'version' => MONSTERINSIGHTS_VERSION,
73
+ 'pro' => monsterinsights_is_pro_version(),
74
+ )
75
+ );
76
+ }
77
+
78
+ public function maybe_authenticate(){
79
+
80
+ // Check nonce
81
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
82
+
83
+ // current user can authenticate
84
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
85
+ wp_send_json_error( array( 'message' => __( "You don't have permission to authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
86
+ }
87
+
88
+ if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
89
+ define( 'WP_NETWORK_ADMIN', true );
90
+ }
91
+
92
+ // Only for Pro users, require a license key to be entered first so we can link to things.
93
+ if ( monsterinsights_is_pro_version() ) {
94
+ $valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed();
95
+ if ( ! $valid ) {
96
+ wp_send_json_error( array( 'message' => __( "Cannot authenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
97
+ }
98
+ }
99
+
100
+ // we do not have a current auth
101
+ if ( ! $this->is_network_admin() && MonsterInsights()->auth->is_authed() ) {
102
+ wp_send_json_error( array( 'message' => __( "Cannot authenticate. Please re-authenticate.", 'google-analytics-for-wordpress' ) ) );
103
+ } else if ( $this->is_network_admin() && MonsterInsights()->auth->is_network_authed() ) {
104
+ wp_send_json_error( array( 'message' => __( "Cannot network authenticate. Please re-authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) );
105
+ }
106
+
107
+ $sitei = $this->get_sitei();
108
+ //update_network_option( get_current_network_id(), 'monsterinsights_network_sitei', $sitei );
109
+
110
+ $siteurl = add_query_arg( array(
111
+ 'tt' => $this->get_tt(),
112
+ 'sitei' => $sitei,
113
+ 'miversion' => MONSTERINSIGHTS_VERSION,
114
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
115
+ 'network' => is_network_admin() ? 'network' : 'site',
116
+ 'siteurl' => is_network_admin() ? network_admin_url() : site_url(),
117
+ 'return' => is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ),
118
+ 'testurl' => 'https://' . monsterinsights_get_api_url() . 'test/',
119
+ ), $this->get_route( 'https://' . monsterinsights_get_api_url() . 'auth/new/{type}' ) );
120
+
121
+ if ( monsterinsights_is_pro_version() ) {
122
+ $key = is_network_admin() ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key();
123
+ $siteurl = add_query_arg( 'license', $key, $siteurl );
124
+ }
125
+
126
+ $siteurl = apply_filters( 'monsterinsights_maybe_authenticate_siteurl', $siteurl );
127
+ wp_send_json_success( array( 'redirect' => $siteurl ) );
128
+ }
129
+
130
+ public function rauthenticate() {
131
+ // Check for missing params
132
+ $reqd_args = array( 'key', 'token', 'ua', 'miview', 'a', 'w', 'p', 'tt', 'network' );
133
+ foreach ( $reqd_args as $arg ) {
134
+ if ( empty( $_REQUEST[$arg] ) ) {
135
+ wp_send_json_error(
136
+ array(
137
+ 'error' => 'authenticate_missing_arg',
138
+ 'message' => 'Authenticate missing parameter: ' . $arg,
139
+ 'version' => MONSTERINSIGHTS_VERSION,
140
+ 'pro' => monsterinsights_is_pro_version(),
141
+ )
142
+ );
143
+ }
144
+ }
145
+
146
+ if ( ! empty( $_REQUEST['network'] ) && 'network' === $_REQUEST['network'] ) {
147
+ define( 'WP_NETWORK_ADMIN', true );
148
+ }
149
+
150
+ if ( ! $this->validate_tt( $_REQUEST['tt'] ) ) {
151
+ wp_send_json_error(
152
+ array(
153
+ 'error' => 'authenticate_invalid_tt',
154
+ 'message' => 'Invalid TT sent',
155
+ 'version' => MONSTERINSIGHTS_VERSION,
156
+ 'pro' => monsterinsights_is_pro_version(),
157
+ )
158
+ );
159
+ }
160
+
161
+ // If the tt is validated, send a success response to trigger the regular auth process.
162
+ wp_send_json_success();
163
+ }
164
+
165
+ public function authenticate_listener(){
166
+ // Make sure it's for us
167
+ if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'auth' ) {
168
+ return;
169
+ }
170
+
171
+ // User can authenticate
172
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
173
+ return;
174
+ }
175
+
176
+ // Invalid request
177
+ if ( empty( $_REQUEST['tt'] ) || ! $this->validate_tt( $_REQUEST['tt'] ) ) {
178
+ return;
179
+ }
180
+
181
+ // Make sure has required params
182
+ if ( empty( $_REQUEST['key'] ) ||
183
+ empty( $_REQUEST['token'] ) ||
184
+ empty( $_REQUEST['ua'] ) ||
185
+ empty( $_REQUEST['miview'] ) ||
186
+ empty( $_REQUEST['a'] ) ||
187
+ empty( $_REQUEST['w'] ) ||
188
+ empty( $_REQUEST['p'] )
189
+ ) {
190
+ return;
191
+ }
192
+
193
+ // Invalid UA code
194
+ $ua = monsterinsights_is_valid_ua( $_REQUEST['ua'] );
195
+ if ( empty( $ua ) ) {
196
+ return;
197
+ }
198
+
199
+ $profile = array(
200
+ 'key' => sanitize_text_field( $_REQUEST['key'] ),
201
+ 'token' => sanitize_text_field( $_REQUEST['token'] ),
202
+ 'ua' => monsterinsights_is_valid_ua( $_REQUEST['ua'] ),
203
+ 'viewname' => sanitize_text_field( $_REQUEST['miview'] ),
204
+ 'a' => sanitize_text_field( $_REQUEST['a'] ), // AccountID
205
+ 'w' => sanitize_text_field( $_REQUEST['w'] ), // PropertyID
206
+ 'p' => sanitize_text_field( $_REQUEST['p'] ), // View ID
207
+ 'siteurl' => site_url(),
208
+ 'neturl' => network_admin_url(),
209
+ );
210
+
211
+ $worked = $this->verify_auth( $profile );
212
+ if ( ! $worked || is_wp_error( $worked ) ) {
213
+ return;
214
+ }
215
+
216
+ // Save Profile
217
+ $this->is_network_admin() ? MonsterInsights()->auth->set_network_analytics_profile( $profile ) : MonsterInsights()->auth->set_analytics_profile( $profile );
218
+
219
+ // Clear cache
220
+ $where = $this->is_network_admin() ? 'network' : 'site';
221
+ MonsterInsights()->reporting->delete_aggregate_data( $where );
222
+
223
+ $url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ) ;
224
+ $url = add_query_arg( array(
225
+ 'mi_action' => 'auth',
226
+ 'success' => 'true',
227
+ ), $url );
228
+ $url = apply_filters( 'monsterinsights_auth_success_redirect_url', $url );
229
+ wp_safe_redirect( $url );
230
+ exit;
231
+ }
232
+
233
+ public function maybe_reauthenticate(){
234
+
235
+ // Check nonce
236
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
237
+
238
+ // current user can authenticate
239
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
240
+ wp_send_json_error( array( 'message' => __( "You don't have permission to re-authenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
241
+ }
242
+
243
+ if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
244
+ define( 'WP_NETWORK_ADMIN', true );
245
+ }
246
+
247
+ // Only for Pro users, require a license key to be entered first so we can link to things.
248
+ if ( monsterinsights_is_pro_version() ) {
249
+ $valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed();
250
+ if ( monsterinsights_is_pro_version() && ! $valid ) {
251
+ wp_send_json_error( array( 'message' => __( "Cannot re-authenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
252
+ }
253
+ }
254
+
255
+ // we do have a current auth
256
+ if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
257
+ wp_send_json_error( array( 'message' => __( "Cannot re-authenticate. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
258
+ } else if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
259
+ wp_send_json_error( array( 'message' => __( "Cannot re-authenticate the network. Please authenticate on the network settings panel.", 'google-analytics-for-wordpress' ) ) );
260
+ }
261
+
262
+ $siteurl = add_query_arg( array(
263
+ 'tt' => $this->get_tt(),
264
+ 'sitei' => $this->get_sitei(),
265
+ 'miversion' => MONSTERINSIGHTS_VERSION,
266
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
267
+ 'network' => is_network_admin() ? 'network' : 'site',
268
+ 'siteurl' => is_network_admin() ? network_admin_url() : site_url(),
269
+ 'key' => is_network_admin() ? MonsterInsights()->auth->get_network_key() : MonsterInsights()->auth->get_key(),
270
+ 'token' => is_network_admin() ? MonsterInsights()->auth->get_network_token() : MonsterInsights()->auth->get_token(),
271
+ 'return' => is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ),
272
+ 'testurl' => 'https://' . monsterinsights_get_api_url() . 'test/',
273
+ ), $this->get_route( 'https://' . monsterinsights_get_api_url() . 'auth/reauth/{type}' ) );
274
+
275
+ if ( monsterinsights_is_pro_version() ) {
276
+ $key = is_network_admin() ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key();
277
+ $siteurl = add_query_arg( 'license', $key, $siteurl );
278
+ }
279
+
280
+ $siteurl = apply_filters( 'monsterinsights_maybe_authenticate_siteurl', $siteurl );
281
+
282
+ wp_send_json_success( array( 'redirect' => $siteurl ) );
283
+ }
284
+
285
+ public function reauthenticate_listener(){
286
+ // Make sure it's for us
287
+ if ( empty( $_REQUEST['mi-oauth-action'] ) || $_REQUEST['mi-oauth-action'] !== 'reauth' ) {
288
+ return;
289
+ }
290
+
291
+ // User can authenticate
292
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
293
+ return;
294
+ }
295
+
296
+ // Invalid request
297
+ if ( empty( $_REQUEST['tt'] ) || ! $this->validate_tt( $_REQUEST['tt'] ) ) {
298
+ return;
299
+ }
300
+
301
+ // Make sure has required params
302
+ if (
303
+ empty( $_REQUEST['ua'] ) ||
304
+ empty( $_REQUEST['miview'] ) ||
305
+ empty( $_REQUEST['a'] ) ||
306
+ empty( $_REQUEST['w'] ) ||
307
+ empty( $_REQUEST['p'] )
308
+ ) {
309
+ return;
310
+ }
311
+
312
+ // Invalid UA code
313
+ $ua = monsterinsights_is_valid_ua( $_REQUEST['ua'] );
314
+ if ( empty( $ua ) ) {
315
+ return;
316
+ }
317
+
318
+ // we do have a current auth
319
+ $existing = $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile() : MonsterInsights()->auth->get_analytics_profile();
320
+ if ( empty( $existing['key'] ) || empty( $existing['token'] ) ) {
321
+ return;
322
+ }
323
+
324
+ $profile = array(
325
+ 'key' => $existing['key'],
326
+ 'token' => $existing['token'],
327
+ 'ua' => monsterinsights_is_valid_ua( $_REQUEST['ua'] ),
328
+ 'viewname' => sanitize_text_field( $_REQUEST['miview'] ),
329
+ 'a' => sanitize_text_field( $_REQUEST['a'] ),
330
+ 'w' => sanitize_text_field( $_REQUEST['w'] ),
331
+ 'p' => sanitize_text_field( $_REQUEST['p'] ),
332
+ 'siteurl' => site_url(),
333
+ 'neturl' => network_admin_url(),
334
+ );
335
+
336
+ // Save Profile
337
+ $this->is_network_admin() ? MonsterInsights()->auth->set_network_analytics_profile( $profile ) : MonsterInsights()->auth->set_analytics_profile( $profile );
338
+
339
+ // Clear cache
340
+ $where = $this->is_network_admin() ? 'network' : 'site';
341
+ MonsterInsights()->reporting->delete_aggregate_data( $where );
342
+
343
+ $url = $this->is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' ) ;
344
+ $url = add_query_arg( array(
345
+ 'mi_action' => 'reauth',
346
+ 'success' => 'true',
347
+ ), $url );
348
+ $url = apply_filters( 'monsterinsights_reauth_success_redirect_url', $url );
349
+
350
+ wp_safe_redirect( $url );
351
+ exit;
352
+ }
353
+
354
+ public function maybe_verify(){
355
+
356
+ // Check nonce
357
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
358
+
359
+ // current user can verify
360
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
361
+ wp_send_json_error( array( 'message' => __( "You don't have permission to verify MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
362
+ }
363
+
364
+ if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
365
+ define( 'WP_NETWORK_ADMIN', true );
366
+ }
367
+
368
+ // we have an auth to verify
369
+ if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
370
+ wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
371
+ } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
372
+ wp_send_json_error( array( 'message' => __( "Cannot verify. Please authenticate.", 'google-analytics-for-wordpress' ) ) );
373
+ }
374
+
375
+ if ( monsterinsights_is_pro_version() ) {
376
+ $valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed();
377
+ if ( ! $valid ) {
378
+ wp_send_json_error( array( 'message' => __( "Cannot verify. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
379
+ }
380
+ }
381
+
382
+ $worked = $this->verify_auth();
383
+ if ( $worked && ! is_wp_error( $worked ) ) {
384
+ wp_send_json_success( array( 'message' => __( "Successfully verified.", 'google-analytics-for-wordpress' ) ) );
385
+ } else {
386
+ wp_send_json_error( array( 'message' => __( "Could not verify.", 'google-analytics-for-wordpress' ) ) );
387
+ }
388
+ }
389
+
390
+ public function verify_auth( $credentials = array() ){
391
+ $creds = ! empty( $credentials ) ? $credentials : ( $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile( true ) : MonsterInsights()->auth->get_analytics_profile( true ) );
392
+
393
+ if ( empty( $creds['key'] ) ) {
394
+ return new WP_Error( 'validation-error', sprintf( __( 'Verify auth key not passed', 'google-analytics-for-wordpress' ) ) );
395
+ }
396
+
397
+ $network = ! empty( $_REQUEST['network'] ) ? $_REQUEST['network'] === 'network' : $this->is_network_admin();
398
+ $api = new MonsterInsights_API_Request( $this->get_route( 'auth/verify/{type}/' ), array( 'network' => $network, 'tt' => $this->get_tt(), 'key' => $creds['key'], 'token' => $creds['token'], 'testurl' => 'https://' . monsterinsights_get_api_url() . 'test/' ) );
399
+ $ret = $api->request();
400
+
401
+ $this->rotate_tt();
402
+ if ( is_wp_error( $ret ) ) {
403
+ return $ret;
404
+ } else {
405
+ return true;
406
+ }
407
+ }
408
+
409
+ public function maybe_delete(){
410
+
411
+ // Check nonce
412
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
413
+
414
+ // current user can delete
415
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
416
+ wp_send_json_error( array( 'message' => __( "You don't have permission to deauthenticate MonsterInsights.", 'google-analytics-for-wordpress' ) ) );
417
+ }
418
+
419
+ if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
420
+ define( 'WP_NETWORK_ADMIN', true );
421
+ }
422
+
423
+ // we have an auth to delete
424
+ if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
425
+ wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) );
426
+ } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
427
+ wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. You are not currently authed.", 'google-analytics-for-wordpress' ) ) );
428
+ }
429
+
430
+ if ( monsterinsights_is_pro_version() ) {
431
+ $valid = is_network_admin() ? MonsterInsights()->license->is_network_licensed() : MonsterInsights()->license->is_site_licensed();
432
+ if ( ! $valid ) {
433
+ wp_send_json_error( array( 'message' => __( "Cannot deauthenticate. Please enter a valid, active license key for MonsterInsights Pro into the settings.", 'google-analytics-for-wordpress' ) ) );
434
+ }
435
+ }
436
+
437
+ $force = ! empty( $_REQUEST['forcedelete'] ) && $_REQUEST['forcedelete'] === 'true';
438
+
439
+ $worked = $this->delete_auth( $force );
440
+ if ( $worked && ! is_wp_error( $worked ) ) {
441
+ wp_send_json_success( array( 'message' => __( "Successfully deauthenticated.", 'google-analytics-for-wordpress' ) ) );
442
+ } else {
443
+ if ( $force ) {
444
+ wp_send_json_success( array( 'message' => __( "Successfully force deauthenticated.", 'google-analytics-for-wordpress' ) ) );
445
+ } else {
446
+ wp_send_json_error( array( 'message' => __( "Could not deauthenticate.", 'google-analytics-for-wordpress' ) ) );
447
+ }
448
+ }
449
+ }
450
+
451
+ public function delete_auth( $force = false ){
452
+ if ( $this->is_network_admin() && ! MonsterInsights()->auth->is_network_authed() ) {
453
+ return false;
454
+ } else if ( ! $this->is_network_admin() && ! MonsterInsights()->auth->is_authed() ) {
455
+ return false;
456
+ }
457
+
458
+ $creds = $this->is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile( true ) : MonsterInsights()->auth->get_analytics_profile( true );
459
+
460
+ if ( empty( $creds['key'] ) ) {
461
+ return false;
462
+ }
463
+
464
+ // If we have a new siteurl enabled option and the profile site doesn't match the current site, deactivate anyways
465
+ if ( is_network_admin() ) {
466
+ $siteurl = network_admin_url();
467
+ if ( ! empty( $creds['neturl' ] ) && $creds['neturl'] !== $siteurl ) {
468
+ MonsterInsights()->auth->delete_network_analytics_profile( true );
469
+ return true;
470
+ }
471
+ } else {
472
+ $siteurl = site_url();
473
+ if ( ! empty( $creds['siteurl' ] ) && $creds['siteurl'] !== $siteurl ) {
474
+ MonsterInsights()->auth->delete_analytics_profile( true );
475
+ return true;
476
+ }
477
+ }
478
+
479
+ $api = new MonsterInsights_API_Request( $this->get_route( 'auth/delete/{type}/' ), array( 'network' => $this->is_network_admin(), 'tt' => $this->get_tt(), 'key' => $creds['key'], 'token' => $creds['token'], 'testurl' => 'https://' . monsterinsights_get_api_url() . 'test/' ) );
480
+ $ret = $api->request();
481
+
482
+ $this->rotate_tt();
483
+ if ( is_wp_error( $ret ) && ! $force ) {
484
+ return false;
485
+ } else {
486
+ if ( $this->is_network_admin() ) {
487
+ MonsterInsights()->auth->delete_network_analytics_profile( true );
488
+ } else {
489
+ MonsterInsights()->auth->delete_analytics_profile( true );
490
+
491
+ }
492
+ return true;
493
+ }
494
+ }
495
+
496
+ /**
497
+ * Function to delete network auth in the uninstall process where we can't check if is network admin.
498
+ *
499
+ * @return bool
500
+ */
501
+ public function uninstall_network_auth() {
502
+
503
+ if ( ! MonsterInsights()->auth->is_network_authed() ) {
504
+ return false;
505
+ }
506
+
507
+ $creds = MonsterInsights()->auth->get_network_analytics_profile( true );
508
+
509
+ $api = new MonsterInsights_API_Request( $this->get_route( 'auth/delete/{type}/' ), array(
510
+ 'network' => true,
511
+ 'tt' => $this->get_tt(),
512
+ 'key' => $creds['key'],
513
+ 'token' => $creds['token'],
514
+ 'testurl' => 'https://' . monsterinsights_get_api_url() . 'test/'
515
+ ) );
516
+ // Force the network admin url otherwise this will fail not finding the url in relay.
517
+ $api->site_url = network_admin_url();
518
+ $ret = $api->request();
519
+
520
+ $this->rotate_tt();
521
+ if ( is_wp_error( $ret ) ) {
522
+ return false;
523
+ } else {
524
+ MonsterInsights()->auth->delete_network_analytics_profile( true );
525
+ return true;
526
+ }
527
+ }
528
+
529
+ public function get_type() {
530
+ $base = monsterinsights_is_pro_version() ? 'pro' : 'lite';
531
+ return apply_filters( 'monsterinsights_api_auth_get_type', $base );
532
+ }
533
+
534
+ public function get_route( $route = '' ) {
535
+ $route = str_replace( '{type}', $this->get_type(), $route );
536
+ $route = trailingslashit( $route );
537
+ return $route;
538
+ }
539
+
540
+ public function is_network_admin() {
541
+ return is_multisite() && is_network_admin();
542
+ }
543
+
544
+ public function get_sitei() {
545
+ // $sitei = get_network_option( get_current_network_id(), 'monsterinsights_network_sitei', false );
546
+ // if ( ! empty( $sitei ) && strlen( $sitei ) >= 1 ) {
547
+ // return $sitei;
548
+ // }
549
+
550
+ $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
551
+ $secure_auth_key = defined( 'SECURE_AUTH_KEY' ) ? SECURE_AUTH_KEY : '';
552
+ $logged_in_key = defined( 'LOGGED_IN_KEY' ) ? LOGGED_IN_KEY : '';
553
+
554
+ $sitei = $auth_key . $secure_auth_key . $logged_in_key;
555
+ $sitei = preg_replace('/[^a-zA-Z0-9]/', '', $sitei );
556
+ $sitei = sanitize_text_field( $sitei );
557
+ $sitei = trim( $sitei );
558
+ $sitei = ( strlen($sitei) > 30 ) ? substr($sitei, 0, 30 ) : $sitei;
559
+ return $sitei;
560
+ }
561
+
562
+ /**
563
+ * Logic to run before serving the redirect url during auth.
564
+ *
565
+ * @param string $url
566
+ *
567
+ * @return string
568
+ */
569
+ public function before_redirect( $url ) {
570
+
571
+ // If Bad Behavior plugin is installed.
572
+ if ( function_exists( 'bb2_read_settings' ) ) {
573
+ // Make sure the offsite_forms option is enabled to allow auth.
574
+ $bb_settings = get_option( 'bad_behavior_settings' );
575
+ if ( empty( $bb_settings['offsite_forms'] ) || false === $bb_settings['offsite_forms'] ) {
576
+ $bb_settings['offsite_forms'] = true;
577
+ update_option( 'bad_behavior_settings', $bb_settings );
578
+ }
579
+ }
580
+
581
+ return $url;
582
+ }
583
+ }
includes/admin/common.php CHANGED
@@ -1,1092 +1,1099 @@
1
- <?php
2
- /**
3
- * Common admin class.
4
- *
5
- * @since 6.0.0
6
- *
7
- * @package MonsterInsights
8
- * @subpackage Common
9
- * @author Chris Christoff
10
- */
11
-
12
- // Exit if accessed directly
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
-
17
- function monsterinsights_is_settings_page() {
18
- $current_screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
19
- global $admin_page_hooks;
20
-
21
- if ( ! is_object( $current_screen ) || empty( $current_screen->id ) || empty( $admin_page_hooks ) ) {
22
- return false;
23
- }
24
-
25
- $settings_page = false;
26
- if ( ! empty( $admin_page_hooks['monsterinsights_settings'] ) && $current_screen->id === $admin_page_hooks['monsterinsights_settings'] ) {
27
- $settings_page = true;
28
- }
29
-
30
- if ( $current_screen->id === 'toplevel_page_monsterinsights_settings' ) {
31
- $settings_page = true;
32
- }
33
-
34
- if ( $current_screen->id === 'insights_page_monsterinsights_settings' ) {
35
- $settings_page = true;
36
- }
37
-
38
- if ( strpos( $current_screen->id, 'monsterinsights_settings' ) !== false ) {
39
- $settings_page = true;
40
- }
41
-
42
- if ( ! empty( $current_screen->base ) && strpos( $current_screen->base, 'monsterinsights_network' ) !== false ) {
43
- $settings_page = true;
44
- }
45
- return $settings_page;
46
- }
47
-
48
- /**
49
- * Determine if the current page is the Reports page.
50
- *
51
- * @return bool
52
- */
53
- function monsterinsights_is_reports_page() {
54
- $current_screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
55
- global $admin_page_hooks;
56
-
57
- if ( ! is_object( $current_screen ) || empty( $current_screen->id ) || empty( $admin_page_hooks ) ) {
58
- return false;
59
- }
60
-
61
- $settings_page = false;
62
- if ( ! empty( $admin_page_hooks['monsterinsights_reports'] ) && $current_screen->id === $admin_page_hooks['monsterinsights_reports'] ) {
63
- $settings_page = true;
64
- }
65
-
66
- if ( 'toplevel_page_monsterinsights_reports' === $current_screen->id ) {
67
- $settings_page = true;
68
- }
69
-
70
- if ( strpos( $current_screen->id, 'monsterinsights_reports' ) !== false ) {
71
- $settings_page = true;
72
- }
73
-
74
- if ( ! empty( $current_screen->base ) && strpos( $current_screen->base, 'monsterinsights_network' ) !== false ) {
75
- $settings_page = true;
76
- }
77
-
78
- return $settings_page;
79
- }
80
-
81
- /**
82
- * Loads styles for all MonsterInsights-based Administration Screens.
83
- *
84
- * @return null Return early if not on the proper screen.
85
- * @since 6.0.0
86
- * @access public
87
- *
88
- */
89
- function monsterinsights_admin_styles() {
90
-
91
- $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
92
-
93
- // Load Common admin styles.
94
- wp_register_style( 'monsterinsights-admin-common-style', plugins_url( 'assets/css/admin-common' . $suffix . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
95
- wp_enqueue_style( 'monsterinsights-admin-common-style' );
96
-
97
- // Get current screen.
98
- $screen = get_current_screen();
99
-
100
- // Bail if we're not on a MonsterInsights screen.
101
- if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
102
- return;
103
- }
104
-
105
- $version_path = monsterinsights_is_pro_version() ? 'pro' : 'lite';
106
- $rtl = is_rtl() ? '.rtl' : '';
107
-
108
- // For the settings page, load the Vue app styles.
109
- if ( monsterinsights_is_settings_page() ) {
110
- if ( ! defined( 'MONSTERINSIGHTS_LOCAL_JS_URL' ) ) {
111
- wp_enqueue_style( 'monsterinsights-vue-style-vendors', plugins_url( $version_path . '/assets/vue/css/chunk-vendors' . $rtl . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
112
- wp_enqueue_style( 'monsterinsights-vue-style-common', plugins_url( $version_path . '/assets/vue/css/chunk-common' . $rtl . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
113
- wp_enqueue_style( 'monsterinsights-vue-style', plugins_url( $version_path . '/assets/vue/css/settings' . $rtl . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
114
- }
115
-
116
- // Don't load other styles on the settings page.
117
- return;
118
- }
119
-
120
- if ( monsterinsights_is_reports_page() ) {
121
- if ( ! defined( 'MONSTERINSIGHTS_LOCAL_REPORTS_JS_URL' ) ) {
122
- wp_enqueue_style( 'monsterinsights-vue-style-vendors', plugins_url( $version_path . '/assets/vue/css/chunk-vendors' . $rtl . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
123
- wp_enqueue_style( 'monsterinsights-vue-style-common', plugins_url( $version_path . '/assets/vue/css/chunk-common' . $rtl . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
124
- wp_enqueue_style( 'monsterinsights-vue-style', plugins_url( $version_path . '/assets/vue/css/reports' . $rtl . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
125
- }
126
-
127
- return;
128
- }
129
-
130
- // Tooltips
131
- wp_enqueue_script( 'jquery-ui-tooltip' );
132
- }
133
-
134
- add_action( 'admin_enqueue_scripts', 'monsterinsights_admin_styles' );
135
-
136
- /**
137
- * Loads scripts for all MonsterInsights-based Administration Screens.
138
- *
139
- * @return null Return early if not on the proper screen.
140
- * @since 6.0.0
141
- * @access public
142
- *
143
- */
144
- function monsterinsights_admin_scripts() {
145
-
146
- // Our Common Admin JS.
147
- $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
148
-
149
- wp_register_script( 'monsterinsights-admin-common-script', plugins_url( 'assets/js/admin-common' . $suffix . '.js', MONSTERINSIGHTS_PLUGIN_FILE ), array( 'jquery' ), monsterinsights_get_asset_version() );
150
- wp_enqueue_script( 'monsterinsights-admin-common-script' );
151
- wp_localize_script(
152
- 'monsterinsights-admin-common-script',
153
- 'monsterinsights_admin_common',
154
- array(
155
- 'ajax' => admin_url( 'admin-ajax.php' ),
156
- 'dismiss_notice_nonce' => wp_create_nonce( 'monsterinsights-dismiss-notice' ),
157
- )
158
- );
159
-
160
- // Get current screen.
161
- $screen = get_current_screen();
162
-
163
- // Bail if we're not on a MonsterInsights screen.
164
- if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
165
- return;
166
- }
167
-
168
- $version_path = monsterinsights_is_pro_version() ? 'pro' : 'lite';
169
-
170
- // For the settings page, load the Vue app.
171
- if ( monsterinsights_is_settings_page() ) {
172
- global $wp_version;
173
-
174
- if ( ! defined( 'MONSTERINSIGHTS_LOCAL_VENDORS_JS_URL' ) ) {
175
- wp_enqueue_script( 'monsterinsights-vue-vendors', plugins_url( $version_path . '/assets/vue/js/chunk-vendors.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true );
176
- wp_enqueue_script( 'monsterinsights-vue-common', plugins_url( $version_path . '/assets/vue/js/chunk-common.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true );
177
- } else {
178
- wp_enqueue_script( 'monsterinsights-vue-vendors', MONSTERINSIGHTS_LOCAL_VENDORS_JS_URL, array(), monsterinsights_get_asset_version(), true );
179
- wp_enqueue_script( 'monsterinsights-vue-common', MONSTERINSIGHTS_LOCAL_COMMON_JS_URL, array(), monsterinsights_get_asset_version(), true );
180
- }
181
- $app_js_url = defined( 'MONSTERINSIGHTS_LOCAL_JS_URL' ) && MONSTERINSIGHTS_LOCAL_JS_URL ? MONSTERINSIGHTS_LOCAL_JS_URL : plugins_url( $version_path . '/assets/vue/js/settings.js', MONSTERINSIGHTS_PLUGIN_FILE );
182
- wp_register_script( 'monsterinsights-vue-script', $app_js_url, array(), monsterinsights_get_asset_version(), true );
183
- wp_enqueue_script( 'monsterinsights-vue-script' );
184
- $plugins = get_plugins();
185
- $install_amp_url = false;
186
- if ( current_user_can( 'install_plugins' ) ) {
187
- $amp_key = 'amp/amp.php';
188
- if ( array_key_exists( $amp_key, $plugins ) ) {
189
- $install_amp_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=' . $amp_key ), 'activate-plugin_' . $amp_key );
190
- } else {
191
- $install_amp_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=amp' ), 'install-plugin_amp' );
192
- }
193
- }
194
- $install_fbia_url = false;
195
- if ( current_user_can( 'install_plugins' ) ) {
196
- $fbia_key = 'fb-instant-articles/facebook-instant-articles.php';
197
- if ( array_key_exists( $fbia_key, $plugins ) ) {
198
- $install_fbia_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=' . $fbia_key ), 'activate-plugin_' . $fbia_key );
199
- } else {
200
- $install_fbia_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=fb-instant-articles' ), 'install-plugin_fb-instant-articles' );
201
- }
202
- }
203
-
204
- $prepared_dimensions = array();
205
- if ( class_exists( 'MonsterInsights_Admin_Custom_Dimensions' ) ) {
206
- $dimensions = new MonsterInsights_Admin_Custom_Dimensions();
207
- $dimensions = $dimensions->custom_dimensions();
208
- $prepared_dimensions = array();
209
- foreach ( $dimensions as $dimension_type => $dimension ) {
210
- $dimension['type'] = $dimension_type;
211
- $prepared_dimensions[] = $dimension;
212
- }
213
- }
214
- $is_authed = ( MonsterInsights()->auth->is_authed() || MonsterInsights()->auth->is_network_authed() );
215
-
216
- wp_localize_script(
217
- 'monsterinsights-vue-script',
218
- 'monsterinsights',
219
- array(
220
- 'ajax' => admin_url( 'admin-ajax.php' ),
221
- 'nonce' => wp_create_nonce( 'mi-admin-nonce' ),
222
- 'network' => is_network_admin(),
223
- 'translations' => wp_get_jed_locale_data( monsterinsights_is_pro_version() ? 'ga-premium' : 'google-analytics-for-wordpress' ),
224
- 'assets' => plugins_url( $version_path . '/assets/vue', MONSTERINSIGHTS_PLUGIN_FILE ),
225
- 'roles' => monsterinsights_get_roles(),
226
- 'roles_manage_options' => monsterinsights_get_manage_options_roles(),
227
- 'shareasale_id' => monsterinsights_get_shareasale_id(),
228
- 'shareasale_url' => monsterinsights_get_shareasale_url( monsterinsights_get_shareasale_id(), '' ),
229
- 'addons_url' => is_multisite() ? network_admin_url( 'admin.php?page=monsterinsights_network#/addons' ) : admin_url( 'admin.php?page=monsterinsights_settings#/addons' ),
230
- 'install_amp_url' => $install_amp_url,
231
- 'install_fbia_url' => $install_fbia_url,
232
- 'dimensions' => $prepared_dimensions,
233
- 'wizard_url' => admin_url( 'index.php?page=monsterinsights-onboarding' ),
234
- 'install_plugins' => current_user_can( 'install_plugins' ),
235
- 'unfiltered_html' => current_user_can( 'unfiltered_html' ),
236
- 'activate_nonce' => wp_create_nonce( 'monsterinsights-activate' ),
237
- 'deactivate_nonce' => wp_create_nonce( 'monsterinsights-deactivate' ),
238
- 'install_nonce' => wp_create_nonce( 'monsterinsights-install' ),
239
- // Used to add notices for future deprecations.
240
- 'versions' => array(
241
- 'php_version' => phpversion(),
242
- 'php_version_below_54' => apply_filters( 'monsterinsights_temporarily_hide_php_52_and_53_upgrade_warnings', version_compare( phpversion(), '5.4', '<' ) ),
243
- 'php_version_below_56' => apply_filters( 'monsterinsights_temporarily_hide_php_54_and_55_upgrade_warnings', version_compare( phpversion(), '5.6', '<' ) ),
244
- 'php_update_link' => monsterinsights_get_url( 'settings-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-php/' ),
245
- 'wp_version' => $wp_version,
246
- 'wp_version_below_46' => version_compare( $wp_version, '4.6', '<' ),
247
- 'wp_version_below_49' => version_compare( $wp_version, '4.9', '<' ),
248
- 'wp_update_link' => monsterinsights_get_url( 'settings-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-wordpress/' ),
249
- ),
250
- 'plugin_version' => MONSTERINSIGHTS_VERSION,
251
- 'is_admin' => true,
252
- 'reports_url' => add_query_arg( 'page', 'monsterinsights_reports', admin_url( 'admin.php' ) ),
253
- 'first_run_notice' => apply_filters( 'monsterinsights_settings_first_time_notice_hide', monsterinsights_get_option( 'monsterinsights_first_run_notice' ) ),
254
- 'getting_started_url' => is_multisite() ? network_admin_url( 'admin.php?page=monsterinsights_network#/about/getting-started' ) : admin_url( 'admin.php?page=monsterinsights_settings#/about/getting-started' ),
255
- 'authed' => $is_authed,
256
- )
257
- );
258
-
259
- // Don't load other scripts on the settings page.
260
- return;
261
- }
262
-
263
- if ( monsterinsights_is_reports_page() ) {
264
- global $wp_version;
265
- if ( ! defined( 'MONSTERINSIGHTS_LOCAL_VENDORS_JS_URL' ) ) {
266
- wp_enqueue_script( 'monsterinsights-vue-vendors', plugins_url( $version_path . '/assets/vue/js/chunk-vendors.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true );
267
- wp_enqueue_script( 'monsterinsights-vue-common', plugins_url( $version_path . '/assets/vue/js/chunk-common.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true );
268
- } else {
269
- wp_enqueue_script( 'monsterinsights-vue-vendors', MONSTERINSIGHTS_LOCAL_VENDORS_JS_URL, array(), monsterinsights_get_asset_version(), true );
270
- wp_enqueue_script( 'monsterinsights-vue-common', MONSTERINSIGHTS_LOCAL_COMMON_JS_URL, array(), monsterinsights_get_asset_version(), true );
271
- }
272
- $app_js_url = defined( 'MONSTERINSIGHTS_LOCAL_REPORTS_JS_URL' ) && MONSTERINSIGHTS_LOCAL_REPORTS_JS_URL ? MONSTERINSIGHTS_LOCAL_REPORTS_JS_URL : plugins_url( $version_path . '/assets/vue/js/reports.js', MONSTERINSIGHTS_PLUGIN_FILE );
273
- wp_register_script( 'monsterinsights-vue-reports', $app_js_url, array(), monsterinsights_get_asset_version(), true );
274
- wp_enqueue_script( 'monsterinsights-vue-reports' );
275
-
276
- // We do not have a current auth.
277
- $site_auth = MonsterInsights()->auth->get_viewname();
278
- $ms_auth = is_multisite() && MonsterInsights()->auth->get_network_viewname();
279
-
280
- wp_localize_script(
281
- 'monsterinsights-vue-reports',
282
- 'monsterinsights',
283
- array(
284
- 'ajax' => admin_url( 'admin-ajax.php' ),
285
- 'nonce' => wp_create_nonce( 'mi-admin-nonce' ),
286
- 'network' => is_network_admin(),
287
- 'translations' => wp_get_jed_locale_data( monsterinsights_is_pro_version() ? 'ga-premium' : 'google-analytics-for-wordpress' ),
288
- 'assets' => plugins_url( $version_path . '/assets/vue', MONSTERINSIGHTS_PLUGIN_FILE ),
289
- 'shareasale_id' => monsterinsights_get_shareasale_id(),
290
- 'shareasale_url' => monsterinsights_get_shareasale_url( monsterinsights_get_shareasale_id(), '' ),
291
- 'addons_url' => is_multisite() ? network_admin_url( 'admin.php?page=monsterinsights_network#/addons' ) : admin_url( 'admin.php?page=monsterinsights_settings#/addons' ),
292
- 'timezone' => date( 'e' ),
293
- 'authed' => $site_auth || $ms_auth,
294
- 'settings_url' => add_query_arg( 'page', 'monsterinsights_settings', admin_url( 'admin.php' ) ),
295
- // Used to add notices for future deprecations.
296
- 'versions' => array(
297
- 'php_version' => phpversion(),
298
- 'php_version_below_54' => apply_filters( 'monsterinsights_temporarily_hide_php_52_and_53_upgrade_warnings', version_compare( phpversion(), '5.4', '<' ) ),
299
- 'php_version_below_56' => apply_filters( 'monsterinsights_temporarily_hide_php_54_and_55_upgrade_warnings', version_compare( phpversion(), '5.6', '<' ) ),
300
- 'php_update_link' => monsterinsights_get_url( 'settings-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-php/' ),
301
- 'wp_version' => $wp_version,
302
- 'wp_version_below_46' => version_compare( $wp_version, '4.6', '<' ),
303
- 'wp_version_below_49' => version_compare( $wp_version, '4.9', '<' ),
304
- 'wp_update_link' => monsterinsights_get_url( 'settings-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-wordpress/' ),
305
- ),
306
- 'plugin_version' => MONSTERINSIGHTS_VERSION,
307
- 'is_admin' => true,
308
- 'wizard_url' => admin_url( 'index.php?page=monsterinsights-onboarding' ),
309
- 'install_nonce' => wp_create_nonce( 'monsterinsights-install' ),
310
- 'activate_nonce' => wp_create_nonce( 'monsterinsights-activate' ),
311
- 'deactivate_nonce'=> wp_create_nonce( 'monsterinsights-deactivate' ),
312
- 'update_settings' => current_user_can( 'monsterinsights_save_settings' ),
313
- )
314
- );
315
-
316
- return;
317
- }
318
- // ublock notice
319
- add_action( 'admin_print_footer_scripts', 'monsterinsights_settings_ublock_error_js', 9999999 );
320
- }
321
-
322
- add_action( 'admin_enqueue_scripts', 'monsterinsights_admin_scripts' );
323
-
324
- /**
325
- * Remove Assets that conflict with ours from our screens.
326
- *
327
- * @return null Return early if not on the proper screen.
328
- * @since 6.0.4
329
- * @access public
330
- *
331
- */
332
- function monsterinsights_remove_conflicting_asset_files() {
333
-
334
- // Get current screen.
335
- $screen = get_current_screen();
336
-
337
- // Bail if we're not on a MonsterInsights screen.
338
- if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
339
- return;
340
- }
341
-
342
- $styles = array(
343
- 'kt_admin_css', // Pinnacle theme
344
- 'select2-css', // Schema theme
345
- 'tweetshare_style', // TweetShare - Click To Tweet
346
- 'tweetshare_custom_style', // TweetShare - Click To Tweet
347
- 'tweeetshare_custome_style', // TweetShare - Click To Tweet
348
- 'tweeetshare_notice_style', // TweetShare - Click To Tweet
349
- 'tweeetshare_theme_style', // TweetShare - Click To Tweet
350
- 'tweeetshare_tweet_box_style', // TweetShare - Click To Tweet
351
- 'soultype2-admin', // SoulType Plugin
352
- 'thesis-options-stylesheet', // Thesis Options Stylesheet
353
- 'imagify-sweetalert-core', // Imagify
354
- 'imagify-sweetalert', // Imagify
355
- 'smls-backend-style', // Smart Logo Showcase Lite
356
- 'wp-reactjs-starter', // wp-real-media-library
357
- 'control-panel-modal-plugin', // Ken Theme
358
- 'theme-admin-css', // Vitrine Theme
359
- 'qi-framework-styles', // Artisan Nayma Theme
360
- 'artisan-pages-style', // Artisan Pages Plugin
361
- 'control-panel-modal-plugin', // Ken Theme
362
- 'sweetalert', // Church Suite Theme by Webnus
363
- 'woo_stock_alerts_admin_css', // WooCommerce bolder product alerts
364
- 'custom_wp_admin_css', // Fix for Add Social Share
365
- 'fo_css', // Fix for Add Social Share
366
- 'font_css', // Fix for Add Social Share
367
- 'font2_css', // Fix for Add Social Share
368
- 'font3_css', // Fix for Add Social Share
369
- 'hover_css', // Fix for Add Social Share
370
- 'fontend_styling', // Fix for Add Social Share
371
- 'datatable', // WP Todo
372
- 'bootstrap', // WP Todo
373
- 'flipclock', // WP Todo
374
- 'repuso_css_admin', // Social testimonials and reviews by Repuso
375
- );
376
-
377
- $scripts = array(
378
- 'kad_admin_js', // Pinnacle theme
379
- 'dt-chart', // DesignThemes core features plugin
380
- 'tweeetshare_font_script', // TweetShare - Click To Tweet
381
- 'tweeetshare_jquery_script', // TweetShare - Click To Tweet
382
- 'tweeetshare_jqueryui_script', // TweetShare - Click To Tweet
383
- 'tweeetshare_custom_script', // TweetShare - Click To Tweet
384
- 'imagify-promise-polyfill', // Imagify
385
- 'imagify-sweetalert', // Imagify
386
- 'imagify-chart', // Imagify
387
- 'chartjs', // Comet Cache Pro
388
- 'wp-reactjs-starter', // wp-real-media-library
389
- 'jquery-tooltipster', // WP Real Media Library
390
- 'jquery-nested-sortable', // WP Real Media Library
391
- 'jquery-aio-tree', // WP Real Media Library
392
- 'wp-media-picker', // WP Real Media Library
393
- 'rml-general', // WP Real Media Library
394
- 'rml-library', // WP Real Media Library
395
- 'rml-grid', // WP Real Media Library
396
- 'rml-list', // WP Real Media Library
397
- 'rml-modal', // WP Real Media Library
398
- 'rml-order', // WP Real Media Library
399
- 'rml-meta', // WP Real Media Library
400
- 'rml-uploader', // WP Real Media Library
401
- 'rml-options', // WP Real Media Library
402
- 'rml-usersettings', // WP Real Media Library
403
- 'rml-main', // WP Real Media Library
404
- 'control-panel-sweet-alert', // Ken Theme
405
- 'sweet-alert-js', // Vitrine Theme
406
- 'theme-admin-script', // Vitrine Theme
407
- 'sweetalert', // Church Suite Theme by Webnus
408
- 'be_alerts_charts', // WooCommerce bolder product alerts
409
- 'magayo-lottery-results', // Magayo Lottery Results
410
- 'control-panel-sweet-alert', // Ken Theme
411
- 'cpm_chart', // WP Project Manager
412
- 'adminscripts', // Artisan Nayma Theme
413
- 'artisan-pages-script', // Artisan Pages Plugin
414
- 'tooltipster', // Grand News Theme
415
- 'fancybox', // Grand News Theme
416
- 'grandnews-admin-cript', // Grand News Theme
417
- 'colorpicker', // Grand News Theme
418
- 'eye', // Grand News Theme
419
- 'icheck', // Grand News Theme
420
- 'learn-press-chart', // LearnPress
421
- 'theme-script-main', // My Listing Theme by 27collective
422
- 'selz', // Selz eCommerce
423
- 'tie-admin-scripts', // Tie Theme
424
- 'blossomthemes-toolkit', // BlossomThemes Toolkit
425
- 'illdy-widget-upload-image', // Illdy Companion By Colorlib
426
- 'moment.js', // WooCommerce Table Rate Shipping
427
- 'default', // Bridge Theme
428
- 'qode-tax-js', // Bridge Theme
429
- 'wc_smartship_moment_js', // WooCommerce Posti SmartShip by markup.fi
430
- 'ecwid-admin-js', // Fixes Conflict for Ecwid Shopping Cart
431
- 'td-wp-admin-js', // Newspaper by tagDiv
432
- 'moment', // Screets Live Chat
433
- 'wpmf-base', // WP Media Folder Fix
434
- 'wpmf-media-filters', // WP Media Folder Fix
435
- 'wpmf-folder-tree', // WP Media Folder Fix
436
- 'wpmf-assign-tree', // WP Media Folder Fix
437
- 'js_files_for_wp_admin', // TagDiv Composer Fix
438
- 'tdb_js_files_for_wp_admin_last', // TagDiv Composer Fix
439
- 'tdb_js_files_for_wp_admin', // TagDiv Composer Fix
440
- 'wd-functions', // affiliate boxes
441
- 'ellk-aliExpansion', // Ali Dropship Plugin
442
- 'ftmetajs', // Houzez Theme
443
- 'qode_admin_default', // Fix For Stockholm Theme
444
- 'qodef-tax-js', // Fix for Prowess Theme
445
- 'qodef-user-js', // Fix for Prowess Theme
446
- 'qodef-ui-admin', // Fix for Prowess Theme
447
- 'ssi_script', // Fix for Add Social Share
448
- 'live_templates', // Fix for Add Social Share
449
- 'default', // Fix for Add Social Share
450
- 'handsontable', // Fix WP Tables
451
- 'moment-js', // Magee Shortcodes
452
- 'postbox', // Scripts from wp-admin enqueued everywhere by WP Posts Filter
453
- 'link', // Scripts from wp-admin enqueued everywhere by WP Posts Filter
454
- 'wpvr_scripts', // WP Video Robot
455
- 'wpvr_scripts_loaded', // WP Video Robot
456
- 'wpvr_scripts_assets', // WP Video Robot
457
- 'writee_widget_admin', // Fix for the Writtee theme
458
- '__ytprefs_admin__', // Fix for YouTube by EmbedPlus plugin
459
- 'momentjs', // Fix for Blog Time plugin
460
- 'c2c_BlogTime', // Fix for Blog Time plugin
461
- 'material-wp', // Fix for MaterialWP plugin
462
- 'wp-color-picker-alpha', // Fix for MaterialWP plugin
463
- 'grandtour-theme-script', // Grandtour Theme
464
- 'swifty-img-widget-admin-script', // Fix for Swifty Image Widget
465
- 'datatable', // WP Todo
466
- 'flipclock', // WP Todo
467
- 'bootstrap', // WP Todo
468
- 'repuso_js_admin', // Social testimonials and reviews by Repuso
469
- 'chart', // Video Mate Pro Theme
470
- 'reuse_vendor', // RedQ Reuse Form
471
- 'jetpack-onboarding-vendor', // Jetpack Onboarding Bluehost
472
- 'date-js', // Google Analytics by Web Dorado
473
- );
474
-
475
- if ( ! empty( $styles ) ) {
476
- foreach ( $styles as $style ) {
477
- wp_dequeue_style( $style ); // Remove CSS file from MI screen
478
- wp_deregister_style( $style );
479
- }
480
- }
481
- if ( ! empty( $scripts ) ) {
482
- foreach ( $scripts as $script ) {
483
- wp_dequeue_script( $script ); // Remove JS file from MI screen
484
- wp_deregister_script( $script );
485
- }
486
- }
487
-
488
- $third_party = array(
489
- 'select2',
490
- 'sweetalert',
491
- 'clipboard',
492
- 'matchHeight',
493
- 'inputmask',
494
- 'jquery-confirm',
495
- 'list',
496
- 'toastr',
497
- 'tooltipster',
498
- 'flag-icon',
499
- 'bootstrap',
500
- );
501
-
502
- global $wp_styles;
503
- foreach ( $wp_styles->queue as $handle ) {
504
- if ( strpos( $wp_styles->registered[ $handle ]->src, 'wp-content' ) === false ) {
505
- return;
506
- }
507
-
508
- if ( strpos( $wp_styles->registered[ $handle ]->handle, 'monsterinsights' ) !== false ) {
509
- return;
510
- }
511
-
512
- foreach ( $third_party as $partial ) {
513
- if ( strpos( $wp_styles->registered[ $handle ]->handle, $partial ) !== false ) {
514
- wp_dequeue_style( $handle ); // Remove css file from MI screen
515
- wp_deregister_style( $handle );
516
- break;
517
- } else if ( strpos( $wp_styles->registered[ $handle ]->src, $partial ) !== false ) {
518
- wp_dequeue_style( $handle ); // Remove css file from MI screen
519
- wp_deregister_style( $handle );
520
- break;
521
- }
522
- }
523
- }
524
-
525
- global $wp_scripts;
526
- foreach ( $wp_scripts->queue as $handle ) {
527
- if ( strpos( $wp_scripts->registered[ $handle ]->src, 'wp-content' ) === false ) {
528
- return;
529
- }
530
-
531
- if ( strpos( $wp_scripts->registered[ $handle ]->handle, 'monsterinsights' ) !== false ) {
532
- return;
533
- }
534
-
535
- foreach ( $third_party as $partial ) {
536
- if ( strpos( $wp_scripts->registered[ $handle ]->handle, $partial ) !== false ) {
537
- wp_dequeue_script( $handle ); // Remove JS file from MI screen
538
- wp_deregister_script( $handle );
539
- break;
540
- } else if ( strpos( $wp_scripts->registered[ $handle ]->src, $partial ) !== false ) {
541
- wp_dequeue_script( $handle ); // Remove JS file from MI screen
542
- wp_deregister_script( $handle );
543
- break;
544
- }
545
- }
546
- }
547
-
548
- // Remove actions from themes that are not following best practices and break the admin doing so
549
- // Theme: Newspaper by tagDiv
550
- remove_action( 'admin_enqueue_scripts', 'load_wp_admin_js' );
551
- remove_action( 'admin_enqueue_scripts', 'load_wp_admin_css' );
552
- remove_action( 'admin_print_scripts-widgets.php', 'td_on_admin_print_scripts_farbtastic' );
553
- remove_action( 'admin_print_styles-widgets.php', 'td_on_admin_print_styles_farbtastic' );
554
- remove_action( 'admin_print_footer_scripts', 'check_if_media_uploads_is_loaded', 9999 );
555
- remove_action( 'print_media_templates', 'td_custom_gallery_settings_hook' );
556
- remove_action( 'print_media_templates', 'td_change_backbone_js_hook' );
557
- remove_action( 'admin_head', 'tdc_on_admin_head' ); // TagDiv Composer Fix
558
- remove_action( 'print_media_templates', 'us_media_templates' ); // Impreza Theme Fix
559
- remove_action( 'admin_footer', 'gt3pg_add_gallery_template' ); // GT3 Photo & Video Gallery By GT3 Themes Plugin Fix
560
- // Plugin WP Booklist:
561
- remove_action( 'admin_footer', 'wpbooklist_jre_dismiss_prem_notice_forever_action_javascript' );
562
- remove_action( 'admin_footer', 'wpbooklist_dashboard_add_book_action_javascript' );
563
- remove_action( 'admin_footer', 'wpbooklist_edit_book_show_form_action_javascript' );
564
- remove_action( 'admin_footer', 'wpbooklist_show_book_in_colorbox_action_javascript' );
565
- remove_action( 'admin_footer', 'wpbooklist_new_lib_shortcode_action_javascript' );
566
- remove_action( 'admin_footer', 'wpbooklist_dashboard_save_library_display_options_action_javascript' );
567
- remove_action( 'admin_footer', 'wpbooklist_dashboard_save_post_display_options_action_javascript' );
568
- remove_action( 'admin_footer', 'wpbooklist_dashboard_save_page_display_options_action_javascript' );
569
- remove_action( 'admin_footer', 'wpbooklist_update_display_options_action_javascript' );
570
- remove_action( 'admin_footer', 'wpbooklist_edit_book_pagination_action_javascript' );
571
- remove_action( 'admin_footer', 'wpbooklist_edit_book_switch_lib_action_javascript' );
572
- remove_action( 'admin_footer', 'wpbooklist_edit_book_search_action_javascript' );
573
- remove_action( 'admin_footer', 'wpbooklist_edit_book_actual_action_javascript' );
574
- remove_action( 'admin_footer', 'wpbooklist_delete_book_action_javascript' );
575
- remove_action( 'admin_footer', 'wpbooklist_user_apis_action_javascript' );
576
- remove_action( 'admin_footer', 'wpbooklist_upload_new_stylepak_action_javascript' );
577
- remove_action( 'admin_footer', 'wpbooklist_upload_new_post_template_action_javascript' );
578
- remove_action( 'admin_footer', 'wpbooklist_upload_new_page_template_action_javascript' );
579
- remove_action( 'admin_footer', 'wpbooklist_create_db_library_backup_action_javascript' );
580
- remove_action( 'admin_footer', 'wpbooklist_restore_db_library_backup_action_javascript' );
581
- remove_action( 'admin_footer', 'wpbooklist_create_csv_action_javascript' );
582
- remove_action( 'admin_footer', 'wpbooklist_amazon_localization_action_javascript' );
583
- remove_action( 'admin_footer', 'wpbooklist_delete_book_bulk_action_javascript' );
584
- remove_action( 'admin_footer', 'wpbooklist_reorder_action_javascript' );
585
- remove_action( 'admin_footer', 'wpbooklist_exit_results_action_javascript' );
586
- remove_action( 'admin_footer', 'wpbooklist_storytime_select_category_action_javascript' );
587
- remove_action( 'admin_footer', 'wpbooklist_storytime_get_story_action_javascript' );
588
- remove_action( 'admin_footer', 'wpbooklist_storytime_expand_browse_action_javascript' );
589
- remove_action( 'admin_footer', 'wpbooklist_storytime_save_settings_action_javascript' );
590
- remove_action( 'admin_footer', 'wpbooklist_delete_story_action_javascript' );
591
- }
592
-
593
- add_action( 'admin_enqueue_scripts', 'monsterinsights_remove_conflicting_asset_files', 9999 );
594
-
595
- /**
596
- * Remove non-MI notices from MI page.
597
- *
598
- * @return null Return early if not on the proper screen.
599
- * @since 6.0.0
600
- * @access public
601
- *
602
- */
603
- function hide_non_monsterinsights_warnings() {
604
- // Bail if we're not on a MonsterInsights screen.
605
- if ( empty( $_REQUEST['page'] ) || strpos( $_REQUEST['page'], 'monsterinsights' ) === false ) {
606
- return;
607
- }
608
-
609
- global $wp_filter;
610
- if ( ! empty( $wp_filter['user_admin_notices']->callbacks ) && is_array( $wp_filter['user_admin_notices']->callbacks ) ) {
611
- foreach ( $wp_filter['user_admin_notices']->callbacks as $priority => $hooks ) {
612
- foreach ( $hooks as $name => $arr ) {
613
- if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
614
- unset( $wp_filter['user_admin_notices']->callbacks[ $priority ][ $name ] );
615
- continue;
616
- }
617
- if ( ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) && strpos( strtolower( get_class( $arr['function'][0] ) ), 'monsterinsights' ) !== false ) {
618
- continue;
619
- }
620
- if ( ! empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) {
621
- unset( $wp_filter['user_admin_notices']->callbacks[ $priority ][ $name ] );
622
- }
623
- }
624
- }
625
- }
626
-
627
- if ( ! empty( $wp_filter['admin_notices']->callbacks ) && is_array( $wp_filter['admin_notices']->callbacks ) ) {
628
- foreach ( $wp_filter['admin_notices']->callbacks as $priority => $hooks ) {
629
- foreach ( $hooks as $name => $arr ) {
630
- if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
631
- unset( $wp_filter['admin_notices']->callbacks[ $priority ][ $name ] );
632
- continue;
633
- }
634
- if ( ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) && strpos( strtolower( get_class( $arr['function'][0] ) ), 'monsterinsights' ) !== false ) {
635
- continue;
636
- }
637
- if ( ! empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) {
638
- unset( $wp_filter['admin_notices']->callbacks[ $priority ][ $name ] );
639
- }
640
- }
641
- }
642
- }
643
-
644
- if ( ! empty( $wp_filter['all_admin_notices']->callbacks ) && is_array( $wp_filter['all_admin_notices']->callbacks ) ) {
645
- foreach ( $wp_filter['all_admin_notices']->callbacks as $priority => $hooks ) {
646
- foreach ( $hooks as $name => $arr ) {
647
- if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
648
- unset( $wp_filter['all_admin_notices']->callbacks[ $priority ][ $name ] );
649
- continue;
650
- }
651
- if ( ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) && strpos( strtolower( get_class( $arr['function'][0] ) ), 'monsterinsights' ) !== false ) {
652
- continue;
653
- }
654
- if ( ! empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) {
655
- unset( $wp_filter['all_admin_notices']->callbacks[ $priority ][ $name ] );
656
- }
657
- }
658
- }
659
- }
660
- }
661
-
662
- add_action( 'admin_print_scripts', 'hide_non_monsterinsights_warnings' );
663
- add_action( 'admin_head', 'hide_non_monsterinsights_warnings', PHP_INT_MAX );
664
-
665
- /**
666
- * Called whenever an upgrade button / link is displayed in Lite, this function will
667
- * check if there's a shareasale ID specified.
668
- *
669
- * There are three ways to specify an ID, ordered by highest to lowest priority
670
- * - add_filter( 'monsterinsights_shareasale_id', function() { return 1234; } );
671
- * - define( 'MONSTERINSIGHTS_SHAREASALE_ID', 1234 );
672
- * - get_option( 'monsterinsights_shareasale_id' ); (with the option being in the wp_options table)
673
- *
674
- * If an ID is present, returns the ShareASale link with the affiliate ID, and tells
675
- * ShareASale to then redirect to monsterinsights.com/lite
676
- *
677
- * If no ID is present, just returns the monsterinsights.com/lite URL with UTM tracking.
678
- *
679
- * @return string Upgrade link.
680
- * @since 6.0.0
681
- * @access public
682
- *
683
- */
684
- function monsterinsights_get_upgrade_link( $medium = '', $campaign = '', $url = '' ) {
685
- $url = monsterinsights_get_url( $medium, $campaign, $url, false );
686
-
687
- if ( monsterinsights_is_pro_version() ) {
688
- return esc_url( $url );
689
- }
690
-
691
- // Get the ShareASale ID
692
- $shareasale_id = monsterinsights_get_shareasale_id();
693
-
694
- // If we have a shareasale ID return the shareasale url
695
- if ( ! empty( $shareasale_id ) ) {
696
- $shareasale_id = absint( $shareasale_id );
697
-
698
- return esc_url( monsterinsights_get_shareasale_url( $shareasale_id, $url ) );
699
- } else {
700
- return esc_url( $url );
701
- }
702
- }
703
-
704
- function monsterinsights_get_url( $medium = '', $campaign = '', $url = '', $escape = true ) {
705
- // Setup Campaign variables
706
- $source = monsterinsights_is_pro_version() ? 'proplugin' : 'liteplugin';
707
- $medium = ! empty( $medium ) ? $medium : 'defaultmedium';
708
- $campaign = ! empty( $campaign ) ? $campaign : 'defaultcampaign';
709
- $content = MONSTERINSIGHTS_VERSION;
710
- $default_url = monsterinsights_is_pro_version() ? '' : 'lite/';
711
- $url = ! empty( $url ) ? $url : 'https://www.monsterinsights.com/' . $default_url;
712
-
713
- // Put together redirect URL
714
- $url = add_query_arg(
715
- array(
716
- 'utm_source' => $source, // Pro/Lite Plugin
717
- 'utm_medium' => sanitize_key( $medium ), // Area of MonsterInsights (example Reports)
718
- 'utm_campaign' => sanitize_key( $campaign ), // Which link (example eCommerce Report)
719
- 'utm_content' => $content, // Version number of MI
720
- ),
721
- trailingslashit( $url )
722
- );
723
-
724
- if ( $escape ) {
725
- return esc_url( $url );
726
- } else {
727
- return $url;
728
- }
729
- }
730
-
731
- function monsterinsights_settings_ublock_error_js() {
732
- echo "<script type='text/javascript'>\n";
733
- echo "jQuery( document ).ready( function( $ ) {
734
- if ( window.uorigindetected == null){
735
- $('#monsterinsights-ublock-origin-error').show();
736
- $('.monsterinsights-nav-tabs').hide();
737
- $('.monsterinsights-nav-container').hide();
738
- $('#monsterinsights-addon-heading').hide();
739
- $('#monsterinsights-addons').hide();
740
- $('#monsterinsights-reports').hide();
741
- }
742
- });";
743
- echo "\n</script>";
744
- }
745
-
746
- function monsterinsights_ublock_notice() {
747
- ob_start(); ?>
748
- <div id="monsterinsights-ublock-origin-error" class="error inline" style="display:none;">
749
- <?php echo sprintf( esc_html__( 'MonsterInsights has detected that it\'s files are being blocked. This is usually caused by a adblock browser plugin (particularly uBlock Origin), or a conflicting WordPress theme or plugin. This issue only affects the admin side of MonsterInsights. To solve this, ensure MonsterInsights is whitelisted for your website URL in any adblock browser plugin you use. For step by step directions on how to do this, %1$sclick here%2$s. If this doesn\'t solve the issue (rare), send us a ticket %3$shere%2$s and we\'ll be happy to help diagnose the issue.', 'google-analytics-for-wordpress' ), '<a href="https://monsterinsights.com/docs/monsterinsights-asset-files-blocked/" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>', '<a href="https://monsterinsights.com/contact/" target="_blank" rel="noopener noreferrer" referrer="no-referrer">' );
750
- ?>
751
- </div>
752
- <?php
753
- return ob_get_clean();
754
- }
755
-
756
- /**
757
- * Some themes/plugins don't add proper checks and load JS code in all admin pages causing conflicts.
758
- */
759
- function monsterinsights_remove_unnecessary_footer_hooks() {
760
-
761
- $screen = get_current_screen();
762
- // Bail if we're not on a MonsterInsights screen.
763
- if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
764
- return;
765
- }
766
-
767
- // Remove js code added by Newspaper theme - version 8.8.0.
768
- remove_action( 'print_media_templates', 'td_custom_gallery_settings_hook' );
769
- remove_action( 'print_media_templates', 'td_change_backbone_js_hook' );
770
- // Remove js code added by the Brooklyn theme - version 4.5.3.1.
771
- remove_action( 'print_media_templates', 'ut_create_gallery_options' );
772
-
773
- // Remove js code added by WordPress Book List Plugin - version 5.8.1.
774
- remove_action( 'admin_footer', 'wpbooklist_jre_dismiss_prem_notice_forever_action_javascript' );
775
- remove_action( 'admin_footer', 'wpbooklist_dashboard_add_book_action_javascript' );
776
- remove_action( 'admin_footer', 'wpbooklist_edit_book_show_form_action_javascript' );
777
- remove_action( 'admin_footer', 'wpbooklist_show_book_in_colorbox_action_javascript' );
778
- remove_action( 'admin_footer', 'wpbooklist_new_lib_shortcode_action_javascript' );
779
- remove_action( 'admin_footer', 'wpbooklist_dashboard_save_library_display_options_action_javascript' );
780
- remove_action( 'admin_footer', 'wpbooklist_dashboard_save_post_display_options_action_javascript' );
781
- remove_action( 'admin_footer', 'wpbooklist_dashboard_save_page_display_options_action_javascript' );
782
- remove_action( 'admin_footer', 'wpbooklist_update_display_options_action_javascript' );
783
- remove_action( 'admin_footer', 'wpbooklist_edit_book_pagination_action_javascript' );
784
- remove_action( 'admin_footer', 'wpbooklist_edit_book_switch_lib_action_javascript' );
785
- remove_action( 'admin_footer', 'wpbooklist_edit_book_search_action_javascript' );
786
- remove_action( 'admin_footer', 'wpbooklist_edit_book_actual_action_javascript' );
787
- remove_action( 'admin_footer', 'wpbooklist_delete_book_action_javascript' );
788
- remove_action( 'admin_footer', 'wpbooklist_user_apis_action_javascript' );
789
- remove_action( 'admin_footer', 'wpbooklist_upload_new_stylepak_action_javascript' );
790
- remove_action( 'admin_footer', 'wpbooklist_upload_new_post_template_action_javascript' );
791
- remove_action( 'admin_footer', 'wpbooklist_upload_new_page_template_action_javascript' );
792
- remove_action( 'admin_footer', 'wpbooklist_create_db_library_backup_action_javascript' );
793
- remove_action( 'admin_footer', 'wpbooklist_restore_db_library_backup_action_javascript' );
794
- remove_action( 'admin_footer', 'wpbooklist_create_csv_action_javascript' );
795
- remove_action( 'admin_footer', 'wpbooklist_amazon_localization_action_javascript' );
796
- remove_action( 'admin_footer', 'wpbooklist_delete_book_bulk_action_javascript' );
797
- remove_action( 'admin_footer', 'wpbooklist_reorder_action_javascript' );
798
- remove_action( 'admin_footer', 'wpbooklist_exit_results_action_javascript' );
799
- remove_action( 'admin_footer', 'wpbooklist_storytime_select_category_action_javascript' );
800
- remove_action( 'admin_footer', 'wpbooklist_storytime_get_story_action_javascript' );
801
- remove_action( 'admin_footer', 'wpbooklist_storytime_expand_browse_action_javascript' );
802
- remove_action( 'admin_footer', 'wpbooklist_storytime_save_settings_action_javascript' );
803
- remove_action( 'admin_footer', 'wpbooklist_delete_story_action_javascript' );
804
- }
805
-
806
- add_action( 'admin_head', 'monsterinsights_remove_unnecessary_footer_hooks', 15 );
807
-
808
- /**
809
- * Display dismissable admin pointer for year in review 2019 report
810
- *
811
- */
812
- function monsterinsights_yearinreview_admin_menu_tooltip() {
813
-
814
- $dismiss_tooltip = get_option( 'monsterinsights_yearinreview_dismiss_admin_tooltip', false );
815
- $activated = get_option( 'monsterinsights_over_time', array() );
816
- $ua_code = monsterinsights_get_ua();
817
- $dashboards_disabled = monsterinsights_get_option( 'dashboards_disabled', false );
818
-
819
- if ( $dashboards_disabled ) {
820
- return;
821
- }
822
-
823
- if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) {
824
- return;
825
- }
826
-
827
- if ( monsterinsights_is_reports_page() || monsterinsights_is_settings_page() ) {
828
- // Don't show on MI pages.
829
- return;
830
- }
831
-
832
- // equivalent to: 01/01/2020 @ 12:00am (UTC)
833
- $new_year = '1577836800';
834
-
835
- // equivalent to: 01/02/2020 @ 12:00am (UTC)
836
- $start_time = '1577923200';
837
-
838
- // equivalent to: 01/13/2020 @ 12:00am (UTC)
839
- $end_time = '1578873600';
840
-
841
- if ( $dismiss_tooltip ) {
842
- return;
843
- }
844
-
845
- // don't show before January 02, 2020
846
- if ( $start_time > time() ) {
847
- return;
848
- }
849
-
850
- // don't show after January 13, 2020
851
- if ( $end_time < time() ) {
852
- return;
853
- }
854
-
855
- if ( empty( $activated['connected_date'] ) || ( $activated['connected_date'] > $new_year ) || empty( $ua_code ) ) {
856
- return;
857
- }
858
-
859
- // remove lite upsell
860
- remove_action( 'adminmenu', 'monsterinsights_get_admin_menu_tooltip' );
861
-
862
- $url = admin_url( 'admin.php?page=monsterinsights_reports#/year-in-review' );
863
- ?>
864
- <div id="monsterinsights-yearinreview-admin-menu-tooltip" class="monsterinsights-yearinreview-admin-menu-tooltip-hide">
865
- <div class="monsterinsights-yearinreview-admin-menu-tooltip-header">
866
- <span class="monsterinsights-yearinreview-admin-menu-tooltip-icon">
867
- <span class="dashicons dashicons-megaphone"></span>
868
- </span>
869
- <?php esc_html_e( 'Your 2019 Analytics Report', 'google-analytics-for-wordpress' ); ?>
870
- <a href="#" class="monsterinsights-yearinreview-admin-menu-tooltip-close">
871
- <span class="dashicons dashicons-dismiss"></span>
872
- </a>
873
- </div>
874
- <div class="monsterinsights-yearinreview-admin-menu-tooltip-content">
875
- <strong><?php esc_html_e( 'See how your website performed this year and find tips along the way to help grow even more in 2020!', 'google-analytics-for-wordpress' ); ?></strong>
876
- <p>
877
- <a href="<?php echo esc_url( $url ); ?>" class="button button-primary monsterinsights-yearinreview-admin-menu-tooltip-btn-link"><?php esc_html_e( 'View 2019 Year in Review report!', 'google-analytics-for-wordpress' ); ?></a>
878
- </p>
879
- </div>
880
- </div>
881
- <style type="text/css">
882
- #monsterinsights-yearinreview-admin-menu-tooltip {
883
- position: absolute;
884
- left: 100%;
885
- top: 100%;
886
- background: #fff;
887
- margin-left: 16px;
888
- width: 350px;
889
- box-shadow: 0px 4px 7px 0px #ccc;
890
- }
891
-
892
- #monsterinsights-yearinreview-admin-menu-tooltip:before {
893
- content: '';
894
- width: 0;
895
- height: 0;
896
- border-style: solid;
897
- border-width: 12px 12px 12px 0;
898
- border-color: transparent #fff transparent transparent;
899
- position: absolute;
900
- right: 100%;
901
- top: 130px;
902
- z-index: 10;
903
- }
904
-
905
- #monsterinsights-yearinreview-admin-menu-tooltip:after {
906
- content: '';
907
- width: 0;
908
- height: 0;
909
- border-style: solid;
910
- border-width: 13px 13px 13px 0;
911
- border-color: transparent #ccc transparent transparent;
912
- position: absolute;
913
- right: 100%;
914
- margin-left: -1px;
915
- top: 129px;
916
- z-index: 5;
917
- }
918
-
919
- #monsterinsights-yearinreview-admin-menu-tooltip.monsterinsights-yearinreview-tooltip-arrow-top:before {
920
- top: 254px;
921
- }
922
-
923
- #monsterinsights-yearinreview-admin-menu-tooltip.monsterinsights-yearinreview-tooltip-arrow-top:after {
924
- top: 253px;
925
- }
926
-
927
- .monsterinsights-yearinreview-admin-menu-tooltip-header {
928
- background: #03a0d2;
929
- padding: 5px 12px;
930
- font-size: 14px;
931
- font-weight: 700;
932
- font-family: Arial, Helvetica, "Trebuchet MS", sans-serif;
933
- color: #fff;
934
- line-height: 1.6;
935
- }
936
-
937
- .monsterinsights-yearinreview-admin-menu-tooltip-icon {
938
- background: #fff;
939
- border-radius: 50%;
940
- width: 28px;
941
- height: 25px;
942
- display: inline-block;
943
- color: #03a0d2;
944
- text-align: center;
945
- padding: 3px 0 0;
946
- margin-right: 6px;
947
- }
948
-
949
- .monsterinsights-yearinreview-admin-menu-tooltip-hide {
950
- display: none;
951
- }
952
-
953
- .monsterinsights-yearinreview-admin-menu-tooltip-content {
954
- padding: 20px 15px 7px;
955
- }
956
-
957
- .monsterinsights-yearinreview-admin-menu-tooltip-content strong {
958
- font-size: 14px;
959
- }
960
-
961
- .monsterinsights-yearinreview-admin-menu-tooltip-content p strong {
962
- font-size: 13px;
963
- }
964
-
965
- .monsterinsights-yearinreview-admin-menu-tooltip-close {
966
- color: #fff;
967
- text-decoration: none;
968
- position: absolute;
969
- right: 10px;
970
- top: 12px;
971
- display: block;
972
- }
973
-
974
- .monsterinsights-yearinreview-admin-menu-tooltip-close:hover {
975
- color: #fff;
976
- text-decoration: none;
977
- }
978
-
979
- .monsterinsights-yearinreview-admin-menu-tooltip-close .dashicons {
980
- font-size: 14px;
981
- }
982
-
983
- @media ( max-width: 782px ) {
984
- #monsterinsights-yearinreview-admin-menu-tooltip {
985
- display: none;
986
- }
987
- }
988
- </style>
989
- <script type="text/javascript">
990
- if ( 'undefined' !== typeof jQuery ) {
991
- jQuery( function ( $ ) {
992
- var $tooltip = $( document.getElementById( 'monsterinsights-yearinreview-admin-menu-tooltip' ) );
993
- var $menuwrapper = $( document.getElementById( 'adminmenuwrap' ) );
994
- var $menuitem = $( document.getElementById( 'toplevel_page_monsterinsights_reports' ) );
995
- if ( 0 === $menuitem.length ) {
996
- $menuitem = $( document.getElementById( 'toplevel_page_monsterinsights_network' ) );
997
- }
998
-
999
- if ( $menuitem.length ) {
1000
- $menuwrapper.append( $tooltip );
1001
- $tooltip.removeClass( 'monsterinsights-yearinreview-admin-menu-tooltip-hide' );
1002
- }
1003
-
1004
- function alignTooltip() {
1005
- var sticky = $( 'body' ).hasClass( 'sticky-menu' );
1006
-
1007
- var menuitem_pos = $menuitem.position();
1008
- var tooltip_top = menuitem_pos.top - 124;
1009
- if ( sticky && $( window ).height() > $menuwrapper.height() + 150 ) {
1010
- $tooltip.removeClass( 'monsterinsights-yearinreview-tooltip-arrow-top' );
1011
- } else {
1012
- tooltip_top = menuitem_pos.top - 250;
1013
- $tooltip.addClass( 'monsterinsights-yearinreview-tooltip-arrow-top' );
1014
- }
1015
- // Don't let the tooltip go outside of the screen and make the close button not visible.
1016
- if ( tooltip_top < 40 ) {
1017
- tooltip_top = 40;
1018
- }
1019
- $tooltip.css( {
1020
- top: tooltip_top + 'px'
1021
- } );
1022
- }
1023
-
1024
- var $document = $( document );
1025
- var timeout = setTimeout( alignTooltip, 10 );
1026
- $document.on( 'wp-pin-menu wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu wp-collapse-menu.pin-menu wp-scroll-start.pin-menu', function () {
1027
- if ( timeout ) {
1028
- clearTimeout( timeout );
1029
- }
1030
- timeout = setTimeout( alignTooltip, 10 );
1031
- } );
1032
-
1033
- $( '.monsterinsights-yearinreview-admin-menu-tooltip-btn-link' ).on( 'click', function ( e ) {
1034
- hideYearInReviewTooltip();
1035
- } );
1036
-
1037
- $( '.monsterinsights-yearinreview-admin-menu-tooltip-close' ).on( 'click', function ( e ) {
1038
- e.preventDefault();
1039
- hideYearInReviewTooltip();
1040
- } );
1041
-
1042
- function hideYearInReviewTooltip() {
1043
- $tooltip.addClass( 'monsterinsights-yearinreview-admin-menu-tooltip-hide' );
1044
- $.post( ajaxurl, {
1045
- action: 'monsterinsights_yearinreview_hide_admin_tooltip',
1046
- nonce: '<?php echo esc_js( wp_create_nonce( 'mi-admin-nonce' ) ); ?>',
1047
- } );
1048
- }
1049
- } );
1050
- }
1051
- </script>
1052
- <?php
1053
- }
1054
-
1055
- add_action( 'adminmenu', 'monsterinsights_yearinreview_admin_menu_tooltip', 5 );
1056
-
1057
- /**
1058
- * Store the time when the year in review tooltip was hidden so it won't show again
1059
- */
1060
- function monsterinsights_mark_yearinreview_tooltip_hidden() {
1061
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
1062
- update_option( 'monsterinsights_yearinreview_dismiss_admin_tooltip', true );
1063
- wp_send_json_success();
1064
- }
1065
-
1066
- add_action( 'wp_ajax_monsterinsights_yearinreview_hide_admin_tooltip', 'monsterinsights_mark_yearinreview_tooltip_hidden' );
1067
-
1068
- /**
1069
- * Prevent plugins/themes from removing the version number from scripts loaded by our plugin.
1070
- * Ideally those plugins/themes would follow WordPress coding best practices, but in lieu of that
1071
- * we can at least attempt to prevent 99% of them from doing bad things.
1072
- *
1073
- * @param string $src The script source.
1074
- *
1075
- * @return string
1076
- */
1077
- function monsterinsights_prevent_version_number_removal( $src ) {
1078
- // Apply this only to admin-side scripts.
1079
- if ( ! is_admin() ) {
1080
- return $src;
1081
- }
1082
-
1083
- // Make sure are only changing our scripts and only if the version number is missing.
1084
- if ( ( false !== strpos( $src, 'monsterinsights' ) || false !== strpos( $src, 'google-analytics-for-wordpress' ) || false !== strpos( $src, 'google-analytics-premium' ) ) && false === strpos( $src, '?ver' ) ) {
1085
- $src = add_query_arg( 'ver', monsterinsights_get_asset_version(), $src );
1086
- }
1087
-
1088
- return $src;
1089
- }
1090
-
1091
- add_filter( 'script_loader_src', 'monsterinsights_prevent_version_number_removal', 9999, 1 );
1092
- add_filter( 'style_loader_src', 'monsterinsights_prevent_version_number_removal', 9999, 1 );
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Common admin class.
4
+ *
5
+ * @since 6.0.0
6
+ *
7
+ * @package MonsterInsights
8
+ * @subpackage Common
9
+ * @author Chris Christoff
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ function monsterinsights_is_settings_page() {
18
+ $current_screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
19
+ global $admin_page_hooks;
20
+
21
+ if ( ! is_object( $current_screen ) || empty( $current_screen->id ) || empty( $admin_page_hooks ) ) {
22
+ return false;
23
+ }
24
+
25
+ $settings_page = false;
26
+ if ( ! empty( $admin_page_hooks['monsterinsights_settings'] ) && $current_screen->id === $admin_page_hooks['monsterinsights_settings'] ) {
27
+ $settings_page = true;
28
+ }
29
+
30
+ if ( $current_screen->id === 'toplevel_page_monsterinsights_settings' ) {
31
+ $settings_page = true;
32
+ }
33
+
34
+ if ( $current_screen->id === 'insights_page_monsterinsights_settings' ) {
35
+ $settings_page = true;
36
+ }
37
+
38
+ if ( strpos( $current_screen->id, 'monsterinsights_settings' ) !== false ) {
39
+ $settings_page = true;
40
+ }
41
+
42
+ if ( ! empty( $current_screen->base ) && strpos( $current_screen->base, 'monsterinsights_network' ) !== false ) {
43
+ $settings_page = true;
44
+ }
45
+ return $settings_page;
46
+ }
47
+
48
+ /**
49
+ * Determine if the current page is the Reports page.
50
+ *
51
+ * @return bool
52
+ */
53
+ function monsterinsights_is_reports_page() {
54
+ $current_screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
55
+ global $admin_page_hooks;
56
+
57
+ if ( ! is_object( $current_screen ) || empty( $current_screen->id ) || empty( $admin_page_hooks ) ) {
58
+ return false;
59
+ }
60
+
61
+ $reports_page = false;
62
+ if ( ! empty( $admin_page_hooks['monsterinsights_reports'] ) && $current_screen->id === $admin_page_hooks['monsterinsights_reports'] ) {
63
+ $reports_page = true;
64
+ }
65
+
66
+ if ( 'toplevel_page_monsterinsights_reports' === $current_screen->id ) {
67
+ $reports_page = true;
68
+ }
69
+
70
+ if ( strpos( $current_screen->id, 'monsterinsights_reports' ) !== false ) {
71
+ $reports_page = true;
72
+ }
73
+
74
+ return $reports_page;
75
+ }
76
+
77
+ /**
78
+ * Loads styles for all MonsterInsights-based Administration Screens.
79
+ *
80
+ * @return null Return early if not on the proper screen.
81
+ * @since 6.0.0
82
+ * @access public
83
+ *
84
+ */
85
+ function monsterinsights_admin_styles() {
86
+
87
+ $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
88
+
89
+ // Load Common admin styles.
90
+ wp_register_style( 'monsterinsights-admin-common-style', plugins_url( 'assets/css/admin-common' . $suffix . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
91
+ wp_enqueue_style( 'monsterinsights-admin-common-style' );
92
+
93
+ // Get current screen.
94
+ $screen = get_current_screen();
95
+
96
+ // Bail if we're not on a MonsterInsights screen.
97
+ if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
98
+ return;
99
+ }
100
+
101
+ $version_path = monsterinsights_is_pro_version() ? 'pro' : 'lite';
102
+ $rtl = is_rtl() ? '.rtl' : '';
103
+
104
+ // For the settings page, load the Vue app styles.
105
+ if ( monsterinsights_is_settings_page() ) {
106
+ if ( ! defined( 'MONSTERINSIGHTS_LOCAL_JS_URL' ) ) {
107
+ wp_enqueue_style( 'monsterinsights-vue-style-vendors', plugins_url( $version_path . '/assets/vue/css/chunk-vendors' . $rtl . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
108
+ wp_enqueue_style( 'monsterinsights-vue-style-common', plugins_url( $version_path . '/assets/vue/css/chunk-common' . $rtl . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
109
+ wp_enqueue_style( 'monsterinsights-vue-style', plugins_url( $version_path . '/assets/vue/css/settings' . $rtl . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
110
+ }
111
+
112
+ // Don't load other styles on the settings page.
113
+ return;
114
+ }
115
+
116
+ if ( monsterinsights_is_reports_page() ) {
117
+ if ( ! defined( 'MONSTERINSIGHTS_LOCAL_REPORTS_JS_URL' ) ) {
118
+ wp_enqueue_style( 'monsterinsights-vue-style-vendors', plugins_url( $version_path . '/assets/vue/css/chunk-vendors' . $rtl . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
119
+ wp_enqueue_style( 'monsterinsights-vue-style-common', plugins_url( $version_path . '/assets/vue/css/chunk-common' . $rtl . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
120
+ wp_enqueue_style( 'monsterinsights-vue-style', plugins_url( $version_path . '/assets/vue/css/reports' . $rtl . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
121
+ }
122
+
123
+ return;
124
+ }
125
+
126
+ // Tooltips
127
+ wp_enqueue_script( 'jquery-ui-tooltip' );
128
+ }
129
+
130
+ add_action( 'admin_enqueue_scripts', 'monsterinsights_admin_styles' );
131
+
132
+ /**
133
+ * Loads scripts for all MonsterInsights-based Administration Screens.
134
+ *
135
+ * @return null Return early if not on the proper screen.
136
+ * @since 6.0.0
137
+ * @access public
138
+ *
139
+ */
140
+ function monsterinsights_admin_scripts() {
141
+
142
+ // Our Common Admin JS.
143
+ $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
144
+
145
+ wp_register_script( 'monsterinsights-admin-common-script', plugins_url( 'assets/js/admin-common' . $suffix . '.js', MONSTERINSIGHTS_PLUGIN_FILE ), array( 'jquery' ), monsterinsights_get_asset_version() );
146
+ wp_enqueue_script( 'monsterinsights-admin-common-script' );
147
+
148
+ wp_localize_script(
149
+ 'monsterinsights-admin-common-script',
150
+ 'monsterinsights_admin_common',
151
+ array(
152
+ 'ajax' => admin_url( 'admin-ajax.php' ),
153
+ 'dismiss_notice_nonce' => wp_create_nonce( 'monsterinsights-dismiss-notice' ),
154
+ )
155
+ );
156
+
157
+ // Get current screen.
158
+ $screen = get_current_screen();
159
+
160
+ // Bail if we're not on a MonsterInsights screen.
161
+ if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
162
+ return;
163
+ }
164
+
165
+ $version_path = monsterinsights_is_pro_version() ? 'pro' : 'lite';
166
+
167
+ // For the settings page, load the Vue app.
168
+ if ( monsterinsights_is_settings_page() ) {
169
+ global $wp_version;
170
+
171
+ if ( ! defined( 'MONSTERINSIGHTS_LOCAL_VENDORS_JS_URL' ) ) {
172
+ wp_enqueue_script( 'monsterinsights-vue-vendors', plugins_url( $version_path . '/assets/vue/js/chunk-vendors.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true );
173
+ wp_enqueue_script( 'monsterinsights-vue-common', plugins_url( $version_path . '/assets/vue/js/chunk-common.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true );
174
+ } else {
175
+ wp_enqueue_script( 'monsterinsights-vue-vendors', MONSTERINSIGHTS_LOCAL_VENDORS_JS_URL, array(), monsterinsights_get_asset_version(), true );
176
+ wp_enqueue_script( 'monsterinsights-vue-common', MONSTERINSIGHTS_LOCAL_COMMON_JS_URL, array(), monsterinsights_get_asset_version(), true );
177
+ }
178
+ $app_js_url = defined( 'MONSTERINSIGHTS_LOCAL_JS_URL' ) && MONSTERINSIGHTS_LOCAL_JS_URL ? MONSTERINSIGHTS_LOCAL_JS_URL : plugins_url( $version_path . '/assets/vue/js/settings.js', MONSTERINSIGHTS_PLUGIN_FILE );
179
+ wp_register_script( 'monsterinsights-vue-script', $app_js_url, array(), monsterinsights_get_asset_version(), true );
180
+ wp_enqueue_script( 'monsterinsights-vue-script' );
181
+ $plugins = get_plugins();
182
+ $install_amp_url = false;
183
+ if ( current_user_can( 'install_plugins' ) ) {
184
+ $amp_key = 'amp/amp.php';
185
+ if ( array_key_exists( $amp_key, $plugins ) ) {
186
+ $install_amp_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=' . $amp_key ), 'activate-plugin_' . $amp_key );
187
+ } else {
188
+ $install_amp_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=amp' ), 'install-plugin_amp' );
189
+ }
190
+ }
191
+ $install_fbia_url = false;
192
+ if ( current_user_can( 'install_plugins' ) ) {
193
+ $fbia_key = 'fb-instant-articles/facebook-instant-articles.php';
194
+ if ( array_key_exists( $fbia_key, $plugins ) ) {
195
+ $install_fbia_url = wp_nonce_url( self_admin_url( 'plugins.php?action=activate&plugin=' . $fbia_key ), 'activate-plugin_' . $fbia_key );
196
+ } else {
197
+ $install_fbia_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=fb-instant-articles' ), 'install-plugin_fb-instant-articles' );
198
+ }
199
+ }
200
+
201
+ $prepared_dimensions = array();
202
+ if ( class_exists( 'MonsterInsights_Admin_Custom_Dimensions' ) ) {
203
+ $dimensions = new MonsterInsights_Admin_Custom_Dimensions();
204
+ $dimensions = $dimensions->custom_dimensions();
205
+ $prepared_dimensions = array();
206
+ foreach ( $dimensions as $dimension_type => $dimension ) {
207
+ $dimension['type'] = $dimension_type;
208
+ $prepared_dimensions[] = $dimension;
209
+ }
210
+ }
211
+ $is_authed = ( MonsterInsights()->auth->is_authed() || MonsterInsights()->auth->is_network_authed() );
212
+
213
+ wp_localize_script(
214
+ 'monsterinsights-vue-script',
215
+ 'monsterinsights',
216
+ array(
217
+ 'ajax' => admin_url( 'admin-ajax.php' ),
218
+ 'nonce' => wp_create_nonce( 'mi-admin-nonce' ),
219
+ 'network' => is_network_admin(),
220
+ 'translations' => wp_get_jed_locale_data( monsterinsights_is_pro_version() ? 'ga-premium' : 'google-analytics-for-wordpress' ),
221
+ 'assets' => plugins_url( $version_path . '/assets/vue', MONSTERINSIGHTS_PLUGIN_FILE ),
222
+ 'roles' => monsterinsights_get_roles(),
223
+ 'roles_manage_options' => monsterinsights_get_manage_options_roles(),
224
+ 'shareasale_id' => monsterinsights_get_shareasale_id(),
225
+ 'shareasale_url' => monsterinsights_get_shareasale_url( monsterinsights_get_shareasale_id(), '' ),
226
+ 'addons_url' => is_multisite() ? network_admin_url( 'admin.php?page=monsterinsights_network#/addons' ) : admin_url( 'admin.php?page=monsterinsights_settings#/addons' ),
227
+ 'email_summary_url' => admin_url( 'admin.php?monsterinsights_email_preview&monsterinsights_email_template=summary' ),
228
+ 'install_amp_url' => $install_amp_url,
229
+ 'install_fbia_url' => $install_fbia_url,
230
+ 'dimensions' => $prepared_dimensions,
231
+ 'wizard_url' => is_network_admin() ? network_admin_url( 'index.php?page=monsterinsights-onboarding' ) : admin_url( 'index.php?page=monsterinsights-onboarding' ),
232
+ 'install_plugins' => current_user_can( 'install_plugins' ),
233
+ 'unfiltered_html' => current_user_can( 'unfiltered_html' ),
234
+ 'activate_nonce' => wp_create_nonce( 'monsterinsights-activate' ),
235
+ 'deactivate_nonce' => wp_create_nonce( 'monsterinsights-deactivate' ),
236
+ 'install_nonce' => wp_create_nonce( 'monsterinsights-install' ),
237
+ // Used to add notices for future deprecations.
238
+ 'versions' => array(
239
+ 'php_version' => phpversion(),
240
+ 'php_version_below_54' => apply_filters( 'monsterinsights_temporarily_hide_php_52_and_53_upgrade_warnings', version_compare( phpversion(), '5.4', '<' ) ),
241
+ 'php_version_below_56' => apply_filters( 'monsterinsights_temporarily_hide_php_54_and_55_upgrade_warnings', version_compare( phpversion(), '5.6', '<' ) ),
242
+ 'php_update_link' => monsterinsights_get_url( 'settings-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-php/' ),
243
+ 'wp_version' => $wp_version,
244
+ 'wp_version_below_46' => version_compare( $wp_version, '4.6', '<' ),
245
+ 'wp_version_below_49' => version_compare( $wp_version, '4.9', '<' ),
246
+ 'wp_update_link' => monsterinsights_get_url( 'settings-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-wordpress/' ),
247
+ ),
248
+ 'plugin_version' => MONSTERINSIGHTS_VERSION,
249
+ 'is_admin' => true,
250
+ 'admin_email' => get_option( 'admin_email' ),
251
+ 'site_url' => get_site_url(),
252
+ 'reports_url' => add_query_arg( 'page', 'monsterinsights_reports', admin_url( 'admin.php' ) ),
253
+ 'first_run_notice' => apply_filters( 'monsterinsights_settings_first_time_notice_hide', monsterinsights_get_option( 'monsterinsights_first_run_notice' ) ),
254
+ 'getting_started_url' => is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network#/about' ) : admin_url( 'admin.php?page=monsterinsights_settings#/about/getting-started' ),
255
+ 'authed' => $is_authed,
256
+ 'new_pretty_link_url' => admin_url( 'post-new.php?post_type=pretty-link' ),
257
+ 'wpmailsmtp_admin_url' => admin_url( 'admin.php?page=wp-mail-smtp' ),
258
+ )
259
+ );
260
+
261
+ // Don't load other scripts on the settings page.
262
+ return;
263
+ }
264
+
265
+ if ( monsterinsights_is_reports_page() ) {
266
+ global $wp_version;
267
+ if ( ! defined( 'MONSTERINSIGHTS_LOCAL_VENDORS_JS_URL' ) ) {
268
+ wp_enqueue_script( 'monsterinsights-vue-vendors', plugins_url( $version_path . '/assets/vue/js/chunk-vendors.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true );
269
+ wp_enqueue_script( 'monsterinsights-vue-common', plugins_url( $version_path . '/assets/vue/js/chunk-common.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true );
270
+ } else {
271
+ wp_enqueue_script( 'monsterinsights-vue-vendors', MONSTERINSIGHTS_LOCAL_VENDORS_JS_URL, array(), monsterinsights_get_asset_version(), true );
272
+ wp_enqueue_script( 'monsterinsights-vue-common', MONSTERINSIGHTS_LOCAL_COMMON_JS_URL, array(), monsterinsights_get_asset_version(), true );
273
+ }
274
+ $app_js_url = defined( 'MONSTERINSIGHTS_LOCAL_REPORTS_JS_URL' ) && MONSTERINSIGHTS_LOCAL_REPORTS_JS_URL ? MONSTERINSIGHTS_LOCAL_REPORTS_JS_URL : plugins_url( $version_path . '/assets/vue/js/reports.js', MONSTERINSIGHTS_PLUGIN_FILE );
275
+ wp_register_script( 'monsterinsights-vue-reports', $app_js_url, array(), monsterinsights_get_asset_version(), true );
276
+ wp_enqueue_script( 'monsterinsights-vue-reports' );
277
+
278
+ // We do not have a current auth.
279
+ $site_auth = MonsterInsights()->auth->get_viewname();
280
+ $ms_auth = is_multisite() && MonsterInsights()->auth->get_network_viewname();
281
+
282
+ wp_localize_script(
283
+ 'monsterinsights-vue-reports',
284
+ 'monsterinsights',
285
+ array(
286
+ 'ajax' => admin_url( 'admin-ajax.php' ),
287
+ 'nonce' => wp_create_nonce( 'mi-admin-nonce' ),
288
+ 'network' => is_network_admin(),
289
+ 'translations' => wp_get_jed_locale_data( monsterinsights_is_pro_version() ? 'ga-premium' : 'google-analytics-for-wordpress' ),
290
+ 'assets' => plugins_url( $version_path . '/assets/vue', MONSTERINSIGHTS_PLUGIN_FILE ),
291
+ 'shareasale_id' => monsterinsights_get_shareasale_id(),
292
+ 'shareasale_url' => monsterinsights_get_shareasale_url( monsterinsights_get_shareasale_id(), '' ),
293
+ 'addons_url' => is_multisite() ? network_admin_url( 'admin.php?page=monsterinsights_network#/addons' ) : admin_url( 'admin.php?page=monsterinsights_settings#/addons' ),
294
+ 'timezone' => date( 'e' ),
295
+ 'authed' => $site_auth || $ms_auth,
296
+ 'settings_url' => add_query_arg( 'page', 'monsterinsights_settings', admin_url( 'admin.php' ) ),
297
+ // Used to add notices for future deprecations.
298
+ 'versions' => array(
299
+ 'php_version' => phpversion(),
300
+ 'php_version_below_54' => apply_filters( 'monsterinsights_temporarily_hide_php_52_and_53_upgrade_warnings', version_compare( phpversion(), '5.4', '<' ) ),
301
+ 'php_version_below_56' => apply_filters( 'monsterinsights_temporarily_hide_php_54_and_55_upgrade_warnings', version_compare( phpversion(), '5.6', '<' ) ),
302
+ 'php_update_link' => monsterinsights_get_url( 'settings-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-php/' ),
303
+ 'wp_version' => $wp_version,
304
+ 'wp_version_below_46' => version_compare( $wp_version, '4.6', '<' ),
305
+ 'wp_version_below_49' => version_compare( $wp_version, '4.9', '<' ),
306
+ 'wp_update_link' => monsterinsights_get_url( 'settings-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-wordpress/' ),
307
+ ),
308
+ 'plugin_version' => MONSTERINSIGHTS_VERSION,
309
+ 'is_admin' => true,
310
+ 'admin_email' => get_option( 'admin_email' ),
311
+ 'site_url' => get_site_url(),
312
+ 'wizard_url' => is_network_admin() ? network_admin_url( 'index.php?page=monsterinsights-onboarding' ) : admin_url( 'index.php?page=monsterinsights-onboarding' ),
313
+ 'install_nonce' => wp_create_nonce( 'monsterinsights-install' ),
314
+ 'activate_nonce' => wp_create_nonce( 'monsterinsights-activate' ),
315
+ 'deactivate_nonce' => wp_create_nonce( 'monsterinsights-deactivate' ),
316
+ 'update_settings' => current_user_can( 'monsterinsights_save_settings' ),
317
+ 'migrated' => monsterinsights_get_option( 'gadwp_migrated', 0 ),
318
+ )
319
+ );
320
+
321
+ return;
322
+ }
323
+ // ublock notice
324
+ add_action( 'admin_print_footer_scripts', 'monsterinsights_settings_ublock_error_js', 9999999 );
325
+ }
326
+
327
+ add_action( 'admin_enqueue_scripts', 'monsterinsights_admin_scripts' );
328
+
329
+ /**
330
+ * Remove Assets that conflict with ours from our screens.
331
+ *
332
+ * @return null Return early if not on the proper screen.
333
+ * @since 6.0.4
334
+ * @access public
335
+ *
336
+ */
337
+ function monsterinsights_remove_conflicting_asset_files() {
338
+
339
+ // Get current screen.
340
+ $screen = get_current_screen();
341
+
342
+ // Bail if we're not on a MonsterInsights screen.
343
+ if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
344
+ return;
345
+ }
346
+
347
+ $styles = array(
348
+ 'kt_admin_css', // Pinnacle theme
349
+ 'select2-css', // Schema theme
350
+ 'tweetshare_style', // TweetShare - Click To Tweet
351
+ 'tweetshare_custom_style', // TweetShare - Click To Tweet
352
+ 'tweeetshare_custome_style', // TweetShare - Click To Tweet
353
+ 'tweeetshare_notice_style', // TweetShare - Click To Tweet
354
+ 'tweeetshare_theme_style', // TweetShare - Click To Tweet
355
+ 'tweeetshare_tweet_box_style', // TweetShare - Click To Tweet
356
+ 'soultype2-admin', // SoulType Plugin
357
+ 'thesis-options-stylesheet', // Thesis Options Stylesheet
358
+ 'imagify-sweetalert-core', // Imagify
359
+ 'imagify-sweetalert', // Imagify
360
+ 'smls-backend-style', // Smart Logo Showcase Lite
361
+ 'wp-reactjs-starter', // wp-real-media-library
362
+ 'control-panel-modal-plugin', // Ken Theme
363
+ 'theme-admin-css', // Vitrine Theme
364
+ 'qi-framework-styles', // Artisan Nayma Theme
365
+ 'artisan-pages-style', // Artisan Pages Plugin
366
+ 'control-panel-modal-plugin', // Ken Theme
367
+ 'sweetalert', // Church Suite Theme by Webnus
368
+ 'woo_stock_alerts_admin_css', // WooCommerce bolder product alerts
369
+ 'custom_wp_admin_css', // Fix for Add Social Share
370
+ 'fo_css', // Fix for Add Social Share
371
+ 'font_css', // Fix for Add Social Share
372
+ 'font2_css', // Fix for Add Social Share
373
+ 'font3_css', // Fix for Add Social Share
374
+ 'hover_css', // Fix for Add Social Share
375
+ 'fontend_styling', // Fix for Add Social Share
376
+ 'datatable', // WP Todo
377
+ 'bootstrap', // WP Todo
378
+ 'flipclock', // WP Todo
379
+ 'repuso_css_admin', // Social testimonials and reviews by Repuso
380
+ );
381
+
382
+ $scripts = array(
383
+ 'kad_admin_js', // Pinnacle theme
384
+ 'dt-chart', // DesignThemes core features plugin
385
+ 'tweeetshare_font_script', // TweetShare - Click To Tweet
386
+ 'tweeetshare_jquery_script', // TweetShare - Click To Tweet
387
+ 'tweeetshare_jqueryui_script', // TweetShare - Click To Tweet
388
+ 'tweeetshare_custom_script', // TweetShare - Click To Tweet
389
+ 'imagify-promise-polyfill', // Imagify
390
+ 'imagify-sweetalert', // Imagify
391
+ 'imagify-chart', // Imagify
392
+ 'chartjs', // Comet Cache Pro
393
+ 'wp-reactjs-starter', // wp-real-media-library
394
+ 'jquery-tooltipster', // WP Real Media Library
395
+ 'jquery-nested-sortable', // WP Real Media Library
396
+ 'jquery-aio-tree', // WP Real Media Library
397
+ 'wp-media-picker', // WP Real Media Library
398
+ 'rml-general', // WP Real Media Library
399
+ 'rml-library', // WP Real Media Library
400
+ 'rml-grid', // WP Real Media Library
401
+ 'rml-list', // WP Real Media Library
402
+ 'rml-modal', // WP Real Media Library
403
+ 'rml-order', // WP Real Media Library
404
+ 'rml-meta', // WP Real Media Library
405
+ 'rml-uploader', // WP Real Media Library
406
+ 'rml-options', // WP Real Media Library
407
+ 'rml-usersettings', // WP Real Media Library
408
+ 'rml-main', // WP Real Media Library
409
+ 'control-panel-sweet-alert', // Ken Theme
410
+ 'sweet-alert-js', // Vitrine Theme
411
+ 'theme-admin-script', // Vitrine Theme
412
+ 'sweetalert', // Church Suite Theme by Webnus
413
+ 'be_alerts_charts', // WooCommerce bolder product alerts
414
+ 'magayo-lottery-results', // Magayo Lottery Results
415
+ 'control-panel-sweet-alert', // Ken Theme
416
+ 'cpm_chart', // WP Project Manager
417
+ 'adminscripts', // Artisan Nayma Theme
418
+ 'artisan-pages-script', // Artisan Pages Plugin
419
+ 'tooltipster', // Grand News Theme
420
+ 'fancybox', // Grand News Theme
421
+ 'grandnews-admin-cript', // Grand News Theme
422
+ 'colorpicker', // Grand News Theme
423
+ 'eye', // Grand News Theme
424
+ 'icheck', // Grand News Theme
425
+ 'learn-press-chart', // LearnPress
426
+ 'theme-script-main', // My Listing Theme by 27collective
427
+ 'selz', // Selz eCommerce
428
+ 'tie-admin-scripts', // Tie Theme
429
+ 'blossomthemes-toolkit', // BlossomThemes Toolkit
430
+ 'illdy-widget-upload-image', // Illdy Companion By Colorlib
431
+ 'moment.js', // WooCommerce Table Rate Shipping
432
+ 'default', // Bridge Theme
433
+ 'qode-tax-js', // Bridge Theme
434
+ 'wc_smartship_moment_js', // WooCommerce Posti SmartShip by markup.fi
435
+ 'ecwid-admin-js', // Fixes Conflict for Ecwid Shopping Cart
436
+ 'td-wp-admin-js', // Newspaper by tagDiv
437
+ 'moment', // Screets Live Chat
438
+ 'wpmf-base', // WP Media Folder Fix
439
+ 'wpmf-media-filters', // WP Media Folder Fix
440
+ 'wpmf-folder-tree', // WP Media Folder Fix
441
+ 'wpmf-assign-tree', // WP Media Folder Fix
442
+ 'js_files_for_wp_admin', // TagDiv Composer Fix
443
+ 'tdb_js_files_for_wp_admin_last', // TagDiv Composer Fix
444
+ 'tdb_js_files_for_wp_admin', // TagDiv Composer Fix
445
+ 'wd-functions', // affiliate boxes
446
+ 'ellk-aliExpansion', // Ali Dropship Plugin
447
+ 'ftmetajs', // Houzez Theme
448
+ 'qode_admin_default', // Fix For Stockholm Theme
449
+ 'qodef-tax-js', // Fix for Prowess Theme
450
+ 'qodef-user-js', // Fix for Prowess Theme
451
+ 'qodef-ui-admin', // Fix for Prowess Theme
452
+ 'ssi_script', // Fix for Add Social Share
453
+ 'live_templates', // Fix for Add Social Share
454
+ 'default', // Fix for Add Social Share
455
+ 'handsontable', // Fix WP Tables
456
+ 'moment-js', // Magee Shortcodes
457
+ 'postbox', // Scripts from wp-admin enqueued everywhere by WP Posts Filter
458
+ 'link', // Scripts from wp-admin enqueued everywhere by WP Posts Filter
459
+ 'wpvr_scripts', // WP Video Robot
460
+ 'wpvr_scripts_loaded', // WP Video Robot
461
+ 'wpvr_scripts_assets', // WP Video Robot
462
+ 'writee_widget_admin', // Fix for the Writtee theme
463
+ '__ytprefs_admin__', // Fix for YouTube by EmbedPlus plugin
464
+ 'momentjs', // Fix for Blog Time plugin
465
+ 'c2c_BlogTime', // Fix for Blog Time plugin
466
+ 'material-wp', // Fix for MaterialWP plugin
467
+ 'wp-color-picker-alpha', // Fix for MaterialWP plugin
468
+ 'grandtour-theme-script', // Grandtour Theme
469
+ 'swifty-img-widget-admin-script', // Fix for Swifty Image Widget
470
+ 'datatable', // WP Todo
471
+ 'flipclock', // WP Todo
472
+ 'bootstrap', // WP Todo
473
+ 'repuso_js_admin', // Social testimonials and reviews by Repuso
474
+ 'chart', // Video Mate Pro Theme
475
+ 'reuse_vendor', // RedQ Reuse Form
476
+ 'jetpack-onboarding-vendor', // Jetpack Onboarding Bluehost
477
+ 'date-js', // Google Analytics by Web Dorado
478
+ );
479
+
480
+ if ( ! empty( $styles ) ) {
481
+ foreach ( $styles as $style ) {
482
+ wp_dequeue_style( $style ); // Remove CSS file from MI screen
483
+ wp_deregister_style( $style );
484
+ }
485
+ }
486
+ if ( ! empty( $scripts ) ) {
487
+ foreach ( $scripts as $script ) {
488
+ wp_dequeue_script( $script ); // Remove JS file from MI screen
489
+ wp_deregister_script( $script );
490
+ }
491
+ }
492
+
493
+ $third_party = array(
494
+ 'select2',
495
+ 'sweetalert',
496
+ 'clipboard',
497
+ 'matchHeight',
498
+ 'inputmask',
499
+ 'jquery-confirm',
500
+ 'list',
501
+ 'toastr',
502
+ 'tooltipster',
503
+ 'flag-icon',
504
+ 'bootstrap',
505
+ );
506
+
507
+ global $wp_styles;
508
+ foreach ( $wp_styles->queue as $handle ) {
509
+ if ( strpos( $wp_styles->registered[ $handle ]->src, 'wp-content' ) === false ) {
510
+ return;
511
+ }
512
+
513
+ if ( strpos( $wp_styles->registered[ $handle ]->handle, 'monsterinsights' ) !== false ) {
514
+ return;
515
+ }
516
+
517
+ foreach ( $third_party as $partial ) {
518
+ if ( strpos( $wp_styles->registered[ $handle ]->handle, $partial ) !== false ) {
519
+ wp_dequeue_style( $handle ); // Remove css file from MI screen
520
+ wp_deregister_style( $handle );
521
+ break;
522
+ } else if ( strpos( $wp_styles->registered[ $handle ]->src, $partial ) !== false ) {
523
+ wp_dequeue_style( $handle ); // Remove css file from MI screen
524
+ wp_deregister_style( $handle );
525
+ break;
526
+ }
527
+ }
528
+ }
529
+
530
+ global $wp_scripts;
531
+ foreach ( $wp_scripts->queue as $handle ) {
532
+ if ( strpos( $wp_scripts->registered[ $handle ]->src, 'wp-content' ) === false ) {
533
+ return;
534
+ }
535
+
536
+ if ( strpos( $wp_scripts->registered[ $handle ]->handle, 'monsterinsights' ) !== false ) {
537
+ return;
538
+ }
539
+
540
+ foreach ( $third_party as $partial ) {
541
+ if ( strpos( $wp_scripts->registered[ $handle ]->handle, $partial ) !== false ) {
542
+ wp_dequeue_script( $handle ); // Remove JS file from MI screen
543
+ wp_deregister_script( $handle );
544
+ break;
545
+ } else if ( strpos( $wp_scripts->registered[ $handle ]->src, $partial ) !== false ) {
546
+ wp_dequeue_script( $handle ); // Remove JS file from MI screen
547
+ wp_deregister_script( $handle );
548
+ break;
549
+ }
550
+ }
551
+ }
552
+
553
+ // Remove actions from themes that are not following best practices and break the admin doing so
554
+ // Theme: Newspaper by tagDiv
555
+ remove_action( 'admin_enqueue_scripts', 'load_wp_admin_js' );
556
+ remove_action( 'admin_enqueue_scripts', 'load_wp_admin_css' );
557
+ remove_action( 'admin_print_scripts-widgets.php', 'td_on_admin_print_scripts_farbtastic' );
558
+ remove_action( 'admin_print_styles-widgets.php', 'td_on_admin_print_styles_farbtastic' );
559
+ remove_action( 'admin_print_footer_scripts', 'check_if_media_uploads_is_loaded', 9999 );
560
+ remove_action( 'print_media_templates', 'td_custom_gallery_settings_hook' );
561
+ remove_action( 'print_media_templates', 'td_change_backbone_js_hook' );
562
+ remove_action( 'admin_head', 'tdc_on_admin_head' ); // TagDiv Composer Fix
563
+ remove_action( 'print_media_templates', 'us_media_templates' ); // Impreza Theme Fix
564
+ remove_action( 'admin_footer', 'gt3pg_add_gallery_template' ); // GT3 Photo & Video Gallery By GT3 Themes Plugin Fix
565
+ // Plugin WP Booklist:
566
+ remove_action( 'admin_footer', 'wpbooklist_jre_dismiss_prem_notice_forever_action_javascript' );
567
+ remove_action( 'admin_footer', 'wpbooklist_dashboard_add_book_action_javascript' );
568
+ remove_action( 'admin_footer', 'wpbooklist_edit_book_show_form_action_javascript' );
569
+ remove_action( 'admin_footer', 'wpbooklist_show_book_in_colorbox_action_javascript' );
570
+ remove_action( 'admin_footer', 'wpbooklist_new_lib_shortcode_action_javascript' );
571
+ remove_action( 'admin_footer', 'wpbooklist_dashboard_save_library_display_options_action_javascript' );
572
+ remove_action( 'admin_footer', 'wpbooklist_dashboard_save_post_display_options_action_javascript' );
573
+ remove_action( 'admin_footer', 'wpbooklist_dashboard_save_page_display_options_action_javascript' );
574
+ remove_action( 'admin_footer', 'wpbooklist_update_display_options_action_javascript' );
575
+ remove_action( 'admin_footer', 'wpbooklist_edit_book_pagination_action_javascript' );
576
+ remove_action( 'admin_footer', 'wpbooklist_edit_book_switch_lib_action_javascript' );
577
+ remove_action( 'admin_footer', 'wpbooklist_edit_book_search_action_javascript' );
578
+ remove_action( 'admin_footer', 'wpbooklist_edit_book_actual_action_javascript' );
579
+ remove_action( 'admin_footer', 'wpbooklist_delete_book_action_javascript' );
580
+ remove_action( 'admin_footer', 'wpbooklist_user_apis_action_javascript' );
581
+ remove_action( 'admin_footer', 'wpbooklist_upload_new_stylepak_action_javascript' );
582
+ remove_action( 'admin_footer', 'wpbooklist_upload_new_post_template_action_javascript' );
583
+ remove_action( 'admin_footer', 'wpbooklist_upload_new_page_template_action_javascript' );
584
+ remove_action( 'admin_footer', 'wpbooklist_create_db_library_backup_action_javascript' );
585
+ remove_action( 'admin_footer', 'wpbooklist_restore_db_library_backup_action_javascript' );
586
+ remove_action( 'admin_footer', 'wpbooklist_create_csv_action_javascript' );
587
+ remove_action( 'admin_footer', 'wpbooklist_amazon_localization_action_javascript' );
588
+ remove_action( 'admin_footer', 'wpbooklist_delete_book_bulk_action_javascript' );
589
+ remove_action( 'admin_footer', 'wpbooklist_reorder_action_javascript' );
590
+ remove_action( 'admin_footer', 'wpbooklist_exit_results_action_javascript' );
591
+ remove_action( 'admin_footer', 'wpbooklist_storytime_select_category_action_javascript' );
592
+ remove_action( 'admin_footer', 'wpbooklist_storytime_get_story_action_javascript' );
593
+ remove_action( 'admin_footer', 'wpbooklist_storytime_expand_browse_action_javascript' );
594
+ remove_action( 'admin_footer', 'wpbooklist_storytime_save_settings_action_javascript' );
595
+ remove_action( 'admin_footer', 'wpbooklist_delete_story_action_javascript' );
596
+ }
597
+
598
+ add_action( 'admin_enqueue_scripts', 'monsterinsights_remove_conflicting_asset_files', 9999 );
599
+
600
+ /**
601
+ * Remove non-MI notices from MI page.
602
+ *
603
+ * @return null Return early if not on the proper screen.
604
+ * @since 6.0.0
605
+ * @access public
606
+ *
607
+ */
608
+ function hide_non_monsterinsights_warnings() {
609
+ // Bail if we're not on a MonsterInsights screen.
610
+ if ( empty( $_REQUEST['page'] ) || strpos( $_REQUEST['page'], 'monsterinsights' ) === false ) {
611
+ return;
612
+ }
613
+
614
+ global $wp_filter;
615
+ if ( ! empty( $wp_filter['user_admin_notices']->callbacks ) && is_array( $wp_filter['user_admin_notices']->callbacks ) ) {
616
+ foreach ( $wp_filter['user_admin_notices']->callbacks as $priority => $hooks ) {
617
+ foreach ( $hooks as $name => $arr ) {
618
+ if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
619
+ unset( $wp_filter['user_admin_notices']->callbacks[ $priority ][ $name ] );
620
+ continue;
621
+ }
622
+ if ( ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) && strpos( strtolower( get_class( $arr['function'][0] ) ), 'monsterinsights' ) !== false ) {
623
+ continue;
624
+ }
625
+ if ( ! empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) {
626
+ unset( $wp_filter['user_admin_notices']->callbacks[ $priority ][ $name ] );
627
+ }
628
+ }
629
+ }
630
+ }
631
+
632
+ if ( ! empty( $wp_filter['admin_notices']->callbacks ) && is_array( $wp_filter['admin_notices']->callbacks ) ) {
633
+ foreach ( $wp_filter['admin_notices']->callbacks as $priority => $hooks ) {
634
+ foreach ( $hooks as $name => $arr ) {
635
+ if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
636
+ unset( $wp_filter['admin_notices']->callbacks[ $priority ][ $name ] );
637
+ continue;
638
+ }
639
+ if ( ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) && strpos( strtolower( get_class( $arr['function'][0] ) ), 'monsterinsights' ) !== false ) {
640
+ continue;
641
+ }
642
+ if ( ! empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) {
643
+ unset( $wp_filter['admin_notices']->callbacks[ $priority ][ $name ] );
644
+ }
645
+ }
646
+ }
647
+ }
648
+
649
+ if ( ! empty( $wp_filter['all_admin_notices']->callbacks ) && is_array( $wp_filter['all_admin_notices']->callbacks ) ) {
650
+ foreach ( $wp_filter['all_admin_notices']->callbacks as $priority => $hooks ) {
651
+ foreach ( $hooks as $name => $arr ) {
652
+ if ( is_object( $arr['function'] ) && $arr['function'] instanceof Closure ) {
653
+ unset( $wp_filter['all_admin_notices']->callbacks[ $priority ][ $name ] );
654
+ continue;
655
+ }
656
+ if ( ! empty( $arr['function'][0] ) && is_object( $arr['function'][0] ) && strpos( strtolower( get_class( $arr['function'][0] ) ), 'monsterinsights' ) !== false ) {
657
+ continue;
658
+ }
659
+ if ( ! empty( $name ) && strpos( $name, 'monsterinsights' ) === false ) {
660
+ unset( $wp_filter['all_admin_notices']->callbacks[ $priority ][ $name ] );
661
+ }
662
+ }
663
+ }
664
+ }
665
+ }
666
+
667
+ add_action( 'admin_print_scripts', 'hide_non_monsterinsights_warnings' );
668
+ add_action( 'admin_head', 'hide_non_monsterinsights_warnings', PHP_INT_MAX );
669
+
670
+ /**
671
+ * Called whenever an upgrade button / link is displayed in Lite, this function will
672
+ * check if there's a shareasale ID specified.
673
+ *
674
+ * There are three ways to specify an ID, ordered by highest to lowest priority
675
+ * - add_filter( 'monsterinsights_shareasale_id', function() { return 1234; } );
676
+ * - define( 'MONSTERINSIGHTS_SHAREASALE_ID', 1234 );
677
+ * - get_option( 'monsterinsights_shareasale_id' ); (with the option being in the wp_options table)
678
+ *
679
+ * If an ID is present, returns the ShareASale link with the affiliate ID, and tells
680
+ * ShareASale to then redirect to monsterinsights.com/lite
681
+ *
682
+ * If no ID is present, just returns the monsterinsights.com/lite URL with UTM tracking.
683
+ *
684
+ * @return string Upgrade link.
685
+ * @since 6.0.0
686
+ * @access public
687
+ *
688
+ */
689
+ function monsterinsights_get_upgrade_link( $medium = '', $campaign = '', $url = '' ) {
690
+ $url = monsterinsights_get_url( $medium, $campaign, $url, false );
691
+
692
+ if ( monsterinsights_is_pro_version() ) {
693
+ return esc_url( $url );
694
+ }
695
+
696
+ // Get the ShareASale ID
697
+ $shareasale_id = monsterinsights_get_shareasale_id();
698
+
699
+ // If we have a shareasale ID return the shareasale url
700
+ if ( ! empty( $shareasale_id ) ) {
701
+ $shareasale_id = absint( $shareasale_id );
702
+
703
+ return esc_url( monsterinsights_get_shareasale_url( $shareasale_id, $url ) );
704
+ } else {
705
+ return esc_url( $url );
706
+ }
707
+ }
708
+
709
+ function monsterinsights_get_url( $medium = '', $campaign = '', $url = '', $escape = true ) {
710
+ // Setup Campaign variables
711
+ $source = monsterinsights_is_pro_version() ? 'proplugin' : 'liteplugin';
712
+ $medium = ! empty( $medium ) ? $medium : 'defaultmedium';
713
+ $campaign = ! empty( $campaign ) ? $campaign : 'defaultcampaign';
714
+ $content = MONSTERINSIGHTS_VERSION;
715
+ $default_url = monsterinsights_is_pro_version() ? '' : 'lite/';
716
+ $url = ! empty( $url ) ? $url : 'https://www.monsterinsights.com/' . $default_url;
717
+
718
+ // Put together redirect URL
719
+ $url = add_query_arg(
720
+ array(
721
+ 'utm_source' => $source, // Pro/Lite Plugin
722
+ 'utm_medium' => sanitize_key( $medium ), // Area of MonsterInsights (example Reports)
723
+ 'utm_campaign' => sanitize_key( $campaign ), // Which link (example eCommerce Report)
724
+ 'utm_content' => $content, // Version number of MI
725
+ ),
726
+ trailingslashit( $url )
727
+ );
728
+
729
+ if ( $escape ) {
730
+ return esc_url( $url );
731
+ } else {
732
+ return $url;
733
+ }
734
+ }
735
+
736
+ function monsterinsights_settings_ublock_error_js() {
737
+ echo "<script type='text/javascript'>\n";
738
+ echo "jQuery( document ).ready( function( $ ) {
739
+ if ( window.uorigindetected == null){
740
+ $('#monsterinsights-ublock-origin-error').show();
741
+ $('.monsterinsights-nav-tabs').hide();
742
+ $('.monsterinsights-nav-container').hide();
743
+ $('#monsterinsights-addon-heading').hide();
744
+ $('#monsterinsights-addons').hide();
745
+ $('#monsterinsights-reports').hide();
746
+ }
747
+ });";
748
+ echo "\n</script>";
749
+ }
750
+
751
+ function monsterinsights_ublock_notice() {
752
+ ob_start(); ?>
753
+ <div id="monsterinsights-ublock-origin-error" class="error inline" style="display:none;">
754
+ <?php
755
+ // Translators: Placeholders are for links to fix the issue.
756
+ echo sprintf( esc_html__( 'MonsterInsights has detected that it\'s files are being blocked. This is usually caused by a adblock browser plugin (particularly uBlock Origin), or a conflicting WordPress theme or plugin. This issue only affects the admin side of MonsterInsights. To solve this, ensure MonsterInsights is whitelisted for your website URL in any adblock browser plugin you use. For step by step directions on how to do this, %1$sclick here%2$s. If this doesn\'t solve the issue (rare), send us a ticket %3$shere%2$s and we\'ll be happy to help diagnose the issue.', 'google-analytics-for-wordpress' ), '<a href="https://monsterinsights.com/docs/monsterinsights-asset-files-blocked/" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>', '<a href="https://monsterinsights.com/contact/" target="_blank" rel="noopener noreferrer" referrer="no-referrer">' );
757
+ ?>
758
+ </div>
759
+ <?php
760
+ return ob_get_clean();
761
+ }
762
+
763
+ /**
764
+ * Some themes/plugins don't add proper checks and load JS code in all admin pages causing conflicts.
765
+ */
766
+ function monsterinsights_remove_unnecessary_footer_hooks() {
767
+
768
+ $screen = get_current_screen();
769
+ // Bail if we're not on a MonsterInsights screen.
770
+ if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
771
+ return;
772
+ }
773
+
774
+ // Remove js code added by Newspaper theme - version 8.8.0.
775
+ remove_action( 'print_media_templates', 'td_custom_gallery_settings_hook' );
776
+ remove_action( 'print_media_templates', 'td_change_backbone_js_hook' );
777
+ // Remove js code added by the Brooklyn theme - version 4.5.3.1.
778
+ remove_action( 'print_media_templates', 'ut_create_gallery_options' );
779
+
780
+ // Remove js code added by WordPress Book List Plugin - version 5.8.1.
781
+ remove_action( 'admin_footer', 'wpbooklist_jre_dismiss_prem_notice_forever_action_javascript' );
782
+ remove_action( 'admin_footer', 'wpbooklist_dashboard_add_book_action_javascript' );
783
+ remove_action( 'admin_footer', 'wpbooklist_edit_book_show_form_action_javascript' );
784
+ remove_action( 'admin_footer', 'wpbooklist_show_book_in_colorbox_action_javascript' );
785
+ remove_action( 'admin_footer', 'wpbooklist_new_lib_shortcode_action_javascript' );
786
+ remove_action( 'admin_footer', 'wpbooklist_dashboard_save_library_display_options_action_javascript' );
787
+ remove_action( 'admin_footer', 'wpbooklist_dashboard_save_post_display_options_action_javascript' );
788
+ remove_action( 'admin_footer', 'wpbooklist_dashboard_save_page_display_options_action_javascript' );
789
+ remove_action( 'admin_footer', 'wpbooklist_update_display_options_action_javascript' );
790
+ remove_action( 'admin_footer', 'wpbooklist_edit_book_pagination_action_javascript' );
791
+ remove_action( 'admin_footer', 'wpbooklist_edit_book_switch_lib_action_javascript' );
792
+ remove_action( 'admin_footer', 'wpbooklist_edit_book_search_action_javascript' );
793
+ remove_action( 'admin_footer', 'wpbooklist_edit_book_actual_action_javascript' );
794
+ remove_action( 'admin_footer', 'wpbooklist_delete_book_action_javascript' );
795
+ remove_action( 'admin_footer', 'wpbooklist_user_apis_action_javascript' );
796
+ remove_action( 'admin_footer', 'wpbooklist_upload_new_stylepak_action_javascript' );
797
+ remove_action( 'admin_footer', 'wpbooklist_upload_new_post_template_action_javascript' );
798
+ remove_action( 'admin_footer', 'wpbooklist_upload_new_page_template_action_javascript' );
799
+ remove_action( 'admin_footer', 'wpbooklist_create_db_library_backup_action_javascript' );
800
+ remove_action( 'admin_footer', 'wpbooklist_restore_db_library_backup_action_javascript' );
801
+ remove_action( 'admin_footer', 'wpbooklist_create_csv_action_javascript' );
802
+ remove_action( 'admin_footer', 'wpbooklist_amazon_localization_action_javascript' );
803
+ remove_action( 'admin_footer', 'wpbooklist_delete_book_bulk_action_javascript' );
804
+ remove_action( 'admin_footer', 'wpbooklist_reorder_action_javascript' );
805
+ remove_action( 'admin_footer', 'wpbooklist_exit_results_action_javascript' );
806
+ remove_action( 'admin_footer', 'wpbooklist_storytime_select_category_action_javascript' );
807
+ remove_action( 'admin_footer', 'wpbooklist_storytime_get_story_action_javascript' );
808
+ remove_action( 'admin_footer', 'wpbooklist_storytime_expand_browse_action_javascript' );
809
+ remove_action( 'admin_footer', 'wpbooklist_storytime_save_settings_action_javascript' );
810
+ remove_action( 'admin_footer', 'wpbooklist_delete_story_action_javascript' );
811
+ }
812
+
813
+ add_action( 'admin_head', 'monsterinsights_remove_unnecessary_footer_hooks', 15 );
814
+
815
+ /**
816
+ * Display dismissable admin pointer for year in review 2019 report
817
+ *
818
+ */
819
+ function monsterinsights_yearinreview_admin_menu_tooltip() {
820
+
821
+ $dismiss_tooltip = get_option( 'monsterinsights_yearinreview_dismiss_admin_tooltip', false );
822
+ $activated = get_option( 'monsterinsights_over_time', array() );
823
+ $ua_code = monsterinsights_get_ua();
824
+ $dashboards_disabled = monsterinsights_get_option( 'dashboards_disabled', false );
825
+
826
+ if ( $dashboards_disabled ) {
827
+ return;
828
+ }
829
+
830
+ if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) {
831
+ return;
832
+ }
833
+
834
+ if ( monsterinsights_is_reports_page() || monsterinsights_is_settings_page() ) {
835
+ // Don't show on MI pages.
836
+ return;
837
+ }
838
+
839
+ // equivalent to: 01/01/2020 @ 12:00am (UTC)
840
+ $new_year = '1577836800';
841
+
842
+ // equivalent to: 01/02/2020 @ 12:00am (UTC)
843
+ $start_time = '1577923200';
844
+
845
+ // equivalent to: 01/13/2020 @ 12:00am (UTC)
846
+ $end_time = '1578873600';
847
+
848
+ if ( $dismiss_tooltip ) {
849
+ return;
850
+ }
851
+
852
+ // don't show before January 02, 2020
853
+ if ( $start_time > time() ) {
854
+ return;
855
+ }
856
+
857
+ // don't show after January 13, 2020
858
+ if ( $end_time < time() ) {
859
+ return;
860
+ }
861
+
862
+ if ( empty( $activated['connected_date'] ) || ( $activated['connected_date'] > $new_year ) || empty( $ua_code ) ) {
863
+ return;
864
+ }
865
+
866
+ // remove lite upsell
867
+ remove_action( 'adminmenu', 'monsterinsights_get_admin_menu_tooltip' );
868
+
869
+ $url = admin_url( 'admin.php?page=monsterinsights_reports#/year-in-review' );
870
+ ?>
871
+ <div id="monsterinsights-yearinreview-admin-menu-tooltip" class="monsterinsights-yearinreview-admin-menu-tooltip-hide">
872
+ <div class="monsterinsights-yearinreview-admin-menu-tooltip-header">
873
+ <span class="monsterinsights-yearinreview-admin-menu-tooltip-icon">
874
+ <span class="dashicons dashicons-megaphone"></span>
875
+ </span>
876
+ <?php esc_html_e( 'Your 2019 Analytics Report', 'google-analytics-for-wordpress' ); ?>
877
+ <a href="#" class="monsterinsights-yearinreview-admin-menu-tooltip-close">
878
+ <span class="dashicons dashicons-dismiss"></span>
879
+ </a>
880
+ </div>
881
+ <div class="monsterinsights-yearinreview-admin-menu-tooltip-content">
882
+ <strong><?php esc_html_e( 'See how your website performed this year and find tips along the way to help grow even more in 2020!', 'google-analytics-for-wordpress' ); ?></strong>
883
+ <p>
884
+ <a href="<?php echo esc_url( $url ); ?>" class="button button-primary monsterinsights-yearinreview-admin-menu-tooltip-btn-link"><?php esc_html_e( 'View 2019 Year in Review report!', 'google-analytics-for-wordpress' ); ?></a>
885
+ </p>
886
+ </div>
887
+ </div>
888
+ <style type="text/css">
889
+ #monsterinsights-yearinreview-admin-menu-tooltip {
890
+ position: absolute;
891
+ left: 100%;
892
+ top: 100%;
893
+ background: #fff;
894
+ margin-left: 16px;
895
+ width: 350px;
896
+ box-shadow: 0px 4px 7px 0px #ccc;
897
+ }
898
+
899
+ #monsterinsights-yearinreview-admin-menu-tooltip:before {
900
+ content: '';
901
+ width: 0;
902
+ height: 0;
903
+ border-style: solid;
904
+ border-width: 12px 12px 12px 0;
905
+ border-color: transparent #fff transparent transparent;
906
+ position: absolute;
907
+ right: 100%;
908
+ top: 130px;
909
+ z-index: 10;
910
+ }
911
+
912
+ #monsterinsights-yearinreview-admin-menu-tooltip:after {
913
+ content: '';
914
+ width: 0;
915
+ height: 0;
916
+ border-style: solid;
917
+ border-width: 13px 13px 13px 0;
918
+ border-color: transparent #ccc transparent transparent;
919
+ position: absolute;
920
+ right: 100%;
921
+ margin-left: -1px;
922
+ top: 129px;
923
+ z-index: 5;
924
+ }
925
+
926
+ #monsterinsights-yearinreview-admin-menu-tooltip.monsterinsights-yearinreview-tooltip-arrow-top:before {
927
+ top: 254px;
928
+ }
929
+
930
+ #monsterinsights-yearinreview-admin-menu-tooltip.monsterinsights-yearinreview-tooltip-arrow-top:after {
931
+ top: 253px;
932
+ }
933
+
934
+ .monsterinsights-yearinreview-admin-menu-tooltip-header {
935
+ background: #03a0d2;
936
+ padding: 5px 12px;
937
+ font-size: 14px;
938
+ font-weight: 700;
939
+ font-family: Arial, Helvetica, "Trebuchet MS", sans-serif;
940
+ color: #fff;
941
+ line-height: 1.6;
942
+ }
943
+
944
+ .monsterinsights-yearinreview-admin-menu-tooltip-icon {
945
+ background: #fff;
946
+ border-radius: 50%;
947
+ width: 28px;
948
+ height: 25px;
949
+ display: inline-block;
950
+ color: #03a0d2;
951
+ text-align: center;
952
+ padding: 3px 0 0;
953
+ margin-right: 6px;
954
+ }
955
+
956
+ .monsterinsights-yearinreview-admin-menu-tooltip-hide {
957
+ display: none;
958
+ }
959
+
960
+ .monsterinsights-yearinreview-admin-menu-tooltip-content {
961
+ padding: 20px 15px 7px;
962
+ }
963
+
964
+ .monsterinsights-yearinreview-admin-menu-tooltip-content strong {
965
+ font-size: 14px;
966
+ }
967
+
968
+ .monsterinsights-yearinreview-admin-menu-tooltip-content p strong {
969
+ font-size: 13px;
970
+ }
971
+
972
+ .monsterinsights-yearinreview-admin-menu-tooltip-close {
973
+ color: #fff;
974
+ text-decoration: none;
975
+ position: absolute;
976
+ right: 10px;
977
+ top: 12px;
978
+ display: block;
979
+ }
980
+
981
+ .monsterinsights-yearinreview-admin-menu-tooltip-close:hover {
982
+ color: #fff;
983
+ text-decoration: none;
984
+ }
985
+
986
+ .monsterinsights-yearinreview-admin-menu-tooltip-close .dashicons {
987
+ font-size: 14px;
988
+ }
989
+
990
+ @media ( max-width: 782px ) {
991
+ #monsterinsights-yearinreview-admin-menu-tooltip {
992
+ display: none;
993
+ }
994
+ }
995
+ </style>
996
+ <script type="text/javascript">
997
+ if ( 'undefined' !== typeof jQuery ) {
998
+ jQuery( function ( $ ) {
999
+ var $tooltip = $( document.getElementById( 'monsterinsights-yearinreview-admin-menu-tooltip' ) );
1000
+ var $menuwrapper = $( document.getElementById( 'adminmenuwrap' ) );
1001
+ var $menuitem = $( document.getElementById( 'toplevel_page_monsterinsights_reports' ) );
1002
+ if ( 0 === $menuitem.length ) {
1003
+ $menuitem = $( document.getElementById( 'toplevel_page_monsterinsights_network' ) );
1004
+ }
1005
+
1006
+ if ( $menuitem.length ) {
1007
+ $menuwrapper.append( $tooltip );
1008
+ $tooltip.removeClass( 'monsterinsights-yearinreview-admin-menu-tooltip-hide' );
1009
+ }
1010
+
1011
+ function alignTooltip() {
1012
+ var sticky = $( 'body' ).hasClass( 'sticky-menu' );
1013
+
1014
+ var menuitem_pos = $menuitem.position();
1015
+ var tooltip_top = menuitem_pos.top - 124;
1016
+ if ( sticky && $( window ).height() > $menuwrapper.height() + 150 ) {
1017
+ $tooltip.removeClass( 'monsterinsights-yearinreview-tooltip-arrow-top' );
1018
+ } else {
1019
+ tooltip_top = menuitem_pos.top - 250;
1020
+ $tooltip.addClass( 'monsterinsights-yearinreview-tooltip-arrow-top' );
1021
+ }
1022
+ // Don't let the tooltip go outside of the screen and make the close button not visible.
1023
+ if ( tooltip_top < 40 ) {
1024
+ tooltip_top = 40;
1025
+ }
1026
+ $tooltip.css( {
1027
+ top: tooltip_top + 'px'
1028
+ } );
1029
+ }
1030
+
1031
+ var $document = $( document );
1032
+ var timeout = setTimeout( alignTooltip, 10 );
1033
+ $document.on( 'wp-pin-menu wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu wp-collapse-menu.pin-menu wp-scroll-start.pin-menu', function () {
1034
+ if ( timeout ) {
1035
+ clearTimeout( timeout );
1036
+ }
1037
+ timeout = setTimeout( alignTooltip, 10 );
1038
+ } );
1039
+
1040
+ $( '.monsterinsights-yearinreview-admin-menu-tooltip-btn-link' ).on( 'click', function ( e ) {
1041
+ hideYearInReviewTooltip();
1042
+ } );
1043
+
1044
+ $( '.monsterinsights-yearinreview-admin-menu-tooltip-close' ).on( 'click', function ( e ) {
1045
+ e.preventDefault();
1046
+ hideYearInReviewTooltip();
1047
+ } );
1048
+
1049
+ function hideYearInReviewTooltip() {
1050
+ $tooltip.addClass( 'monsterinsights-yearinreview-admin-menu-tooltip-hide' );
1051
+ $.post( ajaxurl, {
1052
+ action: 'monsterinsights_yearinreview_hide_admin_tooltip',
1053
+ nonce: '<?php echo esc_js( wp_create_nonce( 'mi-admin-nonce' ) ); ?>',
1054
+ } );
1055
+ }
1056
+ } );
1057
+ }
1058
+ </script>
1059
+ <?php
1060
+ }
1061
+
1062
+ add_action( 'adminmenu', 'monsterinsights_yearinreview_admin_menu_tooltip', 5 );
1063
+
1064
+ /**
1065
+ * Store the time when the year in review tooltip was hidden so it won't show again
1066
+ */
1067
+ function monsterinsights_mark_yearinreview_tooltip_hidden() {
1068
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
1069
+ update_option( 'monsterinsights_yearinreview_dismiss_admin_tooltip', true );
1070
+ wp_send_json_success();
1071
+ }
1072
+
1073
+ add_action( 'wp_ajax_monsterinsights_yearinreview_hide_admin_tooltip', 'monsterinsights_mark_yearinreview_tooltip_hidden' );
1074
+
1075
+ /**
1076
+ * Prevent plugins/themes from removing the version number from scripts loaded by our plugin.
1077
+ * Ideally those plugins/themes would follow WordPress coding best practices, but in lieu of that
1078
+ * we can at least attempt to prevent 99% of them from doing bad things.
1079
+ *
1080
+ * @param string $src The script source.
1081
+ *
1082
+ * @return string
1083
+ */
1084
+ function monsterinsights_prevent_version_number_removal( $src ) {
1085
+ // Apply this only to admin-side scripts.
1086
+ if ( ! is_admin() ) {
1087
+ return $src;
1088
+ }
1089
+
1090
+ // Make sure are only changing our scripts and only if the version number is missing.
1091
+ if ( ( false !== strpos( $src, 'monsterinsights' ) || false !== strpos( $src, 'google-analytics-for-wordpress' ) || false !== strpos( $src, 'google-analytics-premium' ) ) && false === strpos( $src, '?ver' ) ) {
1092
+ $src = add_query_arg( 'ver', monsterinsights_get_asset_version(), $src );
1093
+ }
1094
+
1095
+ return $src;
1096
+ }
1097
+
1098
+ add_filter( 'script_loader_src', 'monsterinsights_prevent_version_number_removal', 9999, 1 );
1099
+ add_filter( 'style_loader_src', 'monsterinsights_prevent_version_number_removal', 9999, 1 );
includes/admin/index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- //Nothing to see here
3
-
4
  header( 'HTTP/1.0 403 Forbidden' );
1
+ <?php
2
+ //Nothing to see here
3
+
4
  header( 'HTTP/1.0 403 Forbidden' );
includes/admin/licensing/autoupdate.php CHANGED
@@ -1,94 +1,94 @@
1
- <?php
2
- /**
3
- * Filters the auto update plugin routine to allow MonsterInsights to be
4
- * automatically updated.
5
- *
6
- * @since 6.3.0
7
- *
8
- * @param bool $update Flag to update the plugin or not.
9
- * @param array $item Update data about a specific plugin.
10
- * @return bool $update The new update state.
11
- */
12
- function monsterinsights_automatic_updates( $update, $item ) {
13
-
14
- // If this is multisite and is not on the main site, return early.
15
- if ( is_multisite() && ! is_main_site() ) {
16
- return $update;
17
- }
18
-
19
- // If we don't have everything we need, return early.
20
- $item = (array) $item;
21
- if ( ! isset( $item['new_version'] ) || ! isset( $item['slug'] ) ) {
22
- return $update;
23
- }
24
-
25
- // If the plugin isn't ours, return early.
26
- $is_free = 'google-analytics-for-wordpress' === $item['slug'];
27
- $is_paid = isset( $item['monsterinsights_plugin'] ); // see updater class
28
- if ( ! $is_free && ! $is_paid ) {
29
- return $update;
30
- }
31
-
32
- $version = $is_free ? MONSTERINSIGHTS_LITE_VERSION : $item['old_version'];
33
- $automatic_updates = monsterinsights_get_option( 'automatic_updates', false );
34
- $current_major = monsterinsights_get_major_version( $version );
35
- $new_major = monsterinsights_get_major_version( $item['new_version'] );
36
-
37
- // If the opt in update allows major updates but there is no major version update, return early.
38
- if ( $current_major < $new_major ) {
39
- if ( $automatic_updates === 'all' ) {
40
- return true;
41
- } else {
42
- return $update;
43
- }
44
- }
45
-
46
- // If the opt in update allows minor updates but there is no minor version update, return early.
47
- if ( $current_major == $new_major ) {
48
- if ( $automatic_updates === 'all' || $automatic_updates === 'minor' ) {
49
- return true;
50
- } else {
51
- return $update;
52
- }
53
- }
54
-
55
- // All our checks have passed - this plugin can be updated!
56
- return true;
57
- }
58
-
59
- add_filter( 'auto_update_plugin', 'monsterinsights_automatic_updates', 10, 2 );
60
- /**
61
- * Notes about autoupdater:
62
- * This runs on the normal WordPress auto-update sequence:
63
- * 1. In wp-includes/update.php, wp_version_check() is called by the WordPress update cron (every 8 or 12 hours; can be overriden to be faster/long or turned off by plugins)
64
- * 2. In wp-includes/update.php, wp_version_check() ends with a action call to do_action( 'wp_maybe_auto_update' ) if cron is running
65
- * 3. In wp-includes/update.php, wp_maybe_auto_update() hooks into wp_maybe_auto_update action, creates a new WP_Automatic_Updater instance and calls WP_Automatic_Updater->run
66
- * 4. In wp-admin/includes/class-wp-automatic-updater.php $this->run() checks to make sure we're on the main site if on a network, and also if the autoupdates are disabled (by plugin, by being on a version controlled site, etc )
67
- * 5. In wp-admin/includes/class-wp-automatic-updater.php $this->run() then checks to see which plugins have new versions (version/update check)
68
- * 6. In wp-admin/includes/class-wp-automatic-updater.php $this->run() then calls $this->update() for each plugin installed who has an upgrade.
69
- * 7 In wp-admin/includes/class-wp-automatic-updater.php $this->update() double checks filesystem access and then installs the plugin if able
70
- *
71
- * Notes:
72
- * - This autoupdater only works if WordPress core detects no version control. If you want to test this, do it on a new WP site without any .git folders anywhere.
73
- * - This autoupdater only works if the file access is able to be written to
74
- * - This autoupdater only works if a new version has been detected, and will run not the second the update is released, but whenever the cron for wp_version_check is next released. This is generally run every 8-12 hours.
75
- * - However, that cron can be disabled, the autoupdater can be turned off via constant or filter, version control or file lock can be detected, and other plugins can be installed (incl in functions of theme) that turn off all
76
- * all automatic plugin updates.
77
- * - If you want to test this is working, you have to manually run the wp_version_check cron. Install the WP Crontrol plugin or Core Control plugin, and run the cron manually using it.
78
- * - Again, because you skimmed over it the first time, if you want to test this manually you need to test this on a new WP install without version control for core, plugins, etc, without file lock, with license key entered (for pro only)
79
- * and use the WP Crontrol or Core Control plugin to run wp_version_check
80
- * - You may have to manually remove an option called "auto_update.lock" from the WP options table
81
- * - You may need to run wp_version_check multiple times (note though that they must be spaced at least 60 seconds apart)
82
- * - Because WP's updater asks the OS if the file is writable, make sure you do not have any files/folders for the plugin you are trying to autoupdate open when testing.
83
- * - You may need to delete the plugin info transient to get it to hard refresh the plugin info.
84
- */
85
-
86
-
87
- function monsterinsights_get_major_version( $version ) {
88
- $exploded_version = explode( '.', $version );
89
- if ( isset( $exploded_version[2] ) ) {
90
- return $exploded_version[0] . '.' . $exploded_version[1] . '.' . $exploded_version[2];
91
- } else {
92
- return $exploded_version[0] . '.' . $exploded_version[1] . '.0';
93
- }
94
  }
1
+ <?php
2
+ /**
3
+ * Filters the auto update plugin routine to allow MonsterInsights to be
4
+ * automatically updated.
5
+ *
6
+ * @since 6.3.0
7
+ *
8
+ * @param bool $update Flag to update the plugin or not.
9
+ * @param array $item Update data about a specific plugin.
10
+ * @return bool $update The new update state.
11
+ */
12
+ function monsterinsights_automatic_updates( $update, $item ) {
13
+
14
+ // If this is multisite and is not on the main site, return early.
15
+ if ( is_multisite() && ! is_main_site() ) {
16
+ return $update;
17
+ }
18
+
19
+ // If we don't have everything we need, return early.
20
+ $item = (array) $item;
21
+ if ( ! isset( $item['new_version'] ) || ! isset( $item['slug'] ) ) {
22
+ return $update;
23
+ }
24
+
25
+ // If the plugin isn't ours, return early.
26
+ $is_free = 'google-analytics-for-wordpress' === $item['slug'];
27
+ $is_paid = isset( $item['monsterinsights_plugin'] ); // see updater class
28
+ if ( ! $is_free && ! $is_paid ) {
29
+ return $update;
30
+ }
31
+
32
+ $version = $is_free ? MONSTERINSIGHTS_LITE_VERSION : $item['old_version'];
33
+ $automatic_updates = monsterinsights_get_option( 'automatic_updates', false );
34
+ $current_major = monsterinsights_get_major_version( $version );
35
+ $new_major = monsterinsights_get_major_version( $item['new_version'] );
36
+
37
+ // If the opt in update allows major updates but there is no major version update, return early.
38
+ if ( $current_major < $new_major ) {
39
+ if ( $automatic_updates === 'all' ) {
40
+ return true;
41
+ } else {
42
+ return $update;
43
+ }
44
+ }
45
+
46
+ // If the opt in update allows minor updates but there is no minor version update, return early.
47
+ if ( $current_major == $new_major ) {
48
+ if ( $automatic_updates === 'all' || $automatic_updates === 'minor' ) {
49
+ return true;
50
+ } else {
51
+ return $update;
52
+ }
53
+ }
54
+
55
+ // All our checks have passed - this plugin can be updated!
56
+ return true;
57
+ }
58
+
59
+ add_filter( 'auto_update_plugin', 'monsterinsights_automatic_updates', 10, 2 );
60
+ /**
61
+ * Notes about autoupdater:
62
+ * This runs on the normal WordPress auto-update sequence:
63
+ * 1. In wp-includes/update.php, wp_version_check() is called by the WordPress update cron (every 8 or 12 hours; can be overriden to be faster/long or turned off by plugins)
64
+ * 2. In wp-includes/update.php, wp_version_check() ends with a action call to do_action( 'wp_maybe_auto_update' ) if cron is running
65
+ * 3. In wp-includes/update.php, wp_maybe_auto_update() hooks into wp_maybe_auto_update action, creates a new WP_Automatic_Updater instance and calls WP_Automatic_Updater->run
66
+ * 4. In wp-admin/includes/class-wp-automatic-updater.php $this->run() checks to make sure we're on the main site if on a network, and also if the autoupdates are disabled (by plugin, by being on a version controlled site, etc )
67
+ * 5. In wp-admin/includes/class-wp-automatic-updater.php $this->run() then checks to see which plugins have new versions (version/update check)
68
+ * 6. In wp-admin/includes/class-wp-automatic-updater.php $this->run() then calls $this->update() for each plugin installed who has an upgrade.
69
+ * 7 In wp-admin/includes/class-wp-automatic-updater.php $this->update() double checks filesystem access and then installs the plugin if able
70
+ *
71
+ * Notes:
72
+ * - This autoupdater only works if WordPress core detects no version control. If you want to test this, do it on a new WP site without any .git folders anywhere.
73
+ * - This autoupdater only works if the file access is able to be written to
74
+ * - This autoupdater only works if a new version has been detected, and will run not the second the update is released, but whenever the cron for wp_version_check is next released. This is generally run every 8-12 hours.
75
+ * - However, that cron can be disabled, the autoupdater can be turned off via constant or filter, version control or file lock can be detected, and other plugins can be installed (incl in functions of theme) that turn off all
76
+ * all automatic plugin updates.
77
+ * - If you want to test this is working, you have to manually run the wp_version_check cron. Install the WP Crontrol plugin or Core Control plugin, and run the cron manually using it.
78
+ * - Again, because you skimmed over it the first time, if you want to test this manually you need to test this on a new WP install without version control for core, plugins, etc, without file lock, with license key entered (for pro only)
79
+ * and use the WP Crontrol or Core Control plugin to run wp_version_check
80
+ * - You may have to manually remove an option called "auto_update.lock" from the WP options table
81
+ * - You may need to run wp_version_check multiple times (note though that they must be spaced at least 60 seconds apart)
82
+ * - Because WP's updater asks the OS if the file is writable, make sure you do not have any files/folders for the plugin you are trying to autoupdate open when testing.
83
+ * - You may need to delete the plugin info transient to get it to hard refresh the plugin info.
84
+ */
85
+
86
+
87
+ function monsterinsights_get_major_version( $version ) {
88
+ $exploded_version = explode( '.', $version );
89
+ if ( isset( $exploded_version[2] ) ) {
90
+ return $exploded_version[0] . '.' . $exploded_version[1] . '.' . $exploded_version[2];
91
+ } else {
92
+ return $exploded_version[0] . '.' . $exploded_version[1] . '.0';
93
+ }
94
  }
includes/admin/licensing/plugin-upgrader.php ADDED
@@ -0,0 +1,571 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /** WP_Upgrader class */
4
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
5
+
6
+ /** Plugin_Upgrader class */
7
+ require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php';
8
+
9
+
10
+ /**
11
+ * In WP 5.3 a PHP 5.6 splat operator (...$args) was added to WP_Upgrader_Skin::feedback().
12
+ * We need to remove all calls to *Skin::feedback() method, as we can't override it in own Skins
13
+ * without breaking support for PHP 5.3-5.5.
14
+ *
15
+ * @internal Please do not use this class outside of core MonsterInsights development. May be removed at any time.
16
+ *
17
+ * @since 7.10.6
18
+ */
19
+ class MonsterInsights_Plugin_Upgrader extends Plugin_Upgrader {
20
+
21
+ /**
22
+ * Run an upgrade/installation.
23
+ *
24
+ * Attempt to download the package (if it is not a local file), unpack it, and
25
+ * install it in the destination folder.
26
+ *
27
+ * @since 1.5.6.1
28
+ *
29
+ * @param array $options {
30
+ * Array or string of arguments for upgrading/installing a package.
31
+ *
32
+ * @type string $package The full path or URI of the package to install.
33
+ * Default empty.
34
+ * @type string $destination The full path to the destination folder.
35
+ * Default empty.
36
+ * @type bool $clear_destination Whether to delete any files already in the
37
+ * destination folder. Default false.
38
+ * @type bool $clear_working Whether to delete the files form the working
39
+ * directory after copying to the destination.
40
+ * Default false.
41
+ * @type bool $abort_if_destination_exists Whether to abort the installation if the destination
42
+ * folder already exists. When true, `$clear_destination`
43
+ * should be false. Default true.
44
+ * @type bool $is_multi Whether this run is one of multiple upgrade/installation
45
+ * actions being performed in bulk. When true, the skin
46
+ * WP_Upgrader::header() and WP_Upgrader::footer()
47
+ * aren't called. Default false.
48
+ * @type array $hook_extra Extra arguments to pass to the filter hooks called by
49
+ * WP_Upgrader::run().
50
+ * }
51
+ * @return array|false|WP_error The result from self::install_package() on success, otherwise a WP_Error,
52
+ * or false if unable to connect to the filesystem.
53
+ */
54
+ public function run( $options ) {
55
+
56
+ $defaults = array(
57
+ 'package' => '', // Please always pass this.
58
+ 'destination' => '', // And this
59
+ 'clear_destination' => false,
60
+ 'abort_if_destination_exists' => true, // Abort if the Destination directory exists, Pass clear_destination as false please
61
+ 'clear_working' => true,
62
+ 'is_multi' => false,
63
+ 'hook_extra' => array(), // Pass any extra $hook_extra args here, this will be passed to any hooked filters.
64
+ );
65
+
66
+ $options = wp_parse_args( $options, $defaults );
67
+
68
+ /**
69
+ * Filter the package options before running an update.
70
+ *
71
+ * See also {@see 'upgrader_process_complete'}.
72
+ *
73
+ * @since 4.3.0
74
+ *
75
+ * @param array $options {
76
+ * Options used by the upgrader.
77
+ *
78
+ * @type string $package Package for update.
79
+ * @type string $destination Update location.
80
+ * @type bool $clear_destination Clear the destination resource.
81
+ * @type bool $clear_working Clear the working resource.
82
+ * @type bool $abort_if_destination_exists Abort if the Destination directory exists.
83
+ * @type bool $is_multi Whether the upgrader is running multiple times.
84
+ * @type array $hook_extra {
85
+ * Extra hook arguments.
86
+ *
87
+ * @type string $action Type of action. Default 'update'.
88
+ * @type string $type Type of update process. Accepts 'plugin', 'theme', or 'core'.
89
+ * @type bool $bulk Whether the update process is a bulk update. Default true.
90
+ * @type string $plugin Path to the plugin file relative to the plugins directory.
91
+ * @type string $theme The stylesheet or template name of the theme.
92
+ * @type string $language_update_type The language pack update type. Accepts 'plugin', 'theme',
93
+ * or 'core'.
94
+ * @type object $language_update The language pack update offer.
95
+ * }
96
+ * }
97
+ */
98
+ $options = apply_filters( 'upgrader_package_options', $options );
99
+
100
+ if ( ! $options['is_multi'] ) { // call $this->header separately if running multiple times
101
+ $this->skin->header();
102
+ }
103
+
104
+ // Connect to the Filesystem first.
105
+ $res = $this->fs_connect( array( WP_CONTENT_DIR, $options['destination'] ) );
106
+ // Mainly for non-connected filesystem.
107
+ if ( ! $res ) {
108
+ if ( ! $options['is_multi'] ) {
109
+ $this->skin->footer();
110
+ }
111
+ return false;
112
+ }
113
+
114
+ $this->skin->before();
115
+
116
+ if ( is_wp_error( $res ) ) {
117
+ $this->skin->error( $res );
118
+ $this->skin->after();
119
+ if ( ! $options['is_multi'] ) {
120
+ $this->skin->footer();
121
+ }
122
+ return $res;
123
+ }
124
+
125
+ /*
126
+ * Download the package (Note, This just returns the filename
127
+ * of the file if the package is a local file)
128
+ */
129
+ $download = $this->download_package( $options['package'], true );
130
+
131
+ // Allow for signature soft-fail.
132
+ // WARNING: This may be removed in the future.
133
+ if ( is_wp_error( $download ) && $download->get_error_data( 'softfail-filename' ) ) {
134
+
135
+ // Don't output the 'no signature could be found' failure message for now.
136
+ if ( 'signature_verification_no_signature' != $download->get_error_code() || WP_DEBUG ) {
137
+ // Outout the failure error as a normal feedback, and not as an error:
138
+ //$this->skin->feedback( $download->get_error_message() );
139
+
140
+ // Report this failure back to WordPress.org for debugging purposes.
141
+ wp_version_check(
142
+ array(
143
+ 'signature_failure_code' => $download->get_error_code(),
144
+ 'signature_failure_data' => $download->get_error_data(),
145
+ )
146
+ );
147
+ }
148
+
149
+ // Pretend this error didn't happen.
150
+ $download = $download->get_error_data( 'softfail-filename' );
151
+ }
152
+
153
+ if ( is_wp_error( $download ) ) {
154
+ $this->skin->error( $download );
155
+ $this->skin->after();
156
+ if ( ! $options['is_multi'] ) {
157
+ $this->skin->footer();
158
+ }
159
+ return $download;
160
+ }
161
+
162
+ $delete_package = ( $download != $options['package'] ); // Do not delete a "local" file
163
+
164
+ // Unzips the file into a temporary directory.
165
+ $working_dir = $this->unpack_package( $download, $delete_package );
166
+ if ( is_wp_error( $working_dir ) ) {
167
+ $this->skin->error( $working_dir );
168
+ $this->skin->after();
169
+ if ( ! $options['is_multi'] ) {
170
+ $this->skin->footer();
171
+ }
172
+ return $working_dir;
173
+ }
174
+
175
+ // With the given options, this installs it to the destination directory.
176
+ $result = $this->install_package(
177
+ array(
178
+ 'source' => $working_dir,
179
+ 'destination' => $options['destination'],
180
+ 'clear_destination' => $options['clear_destination'],
181
+ 'abort_if_destination_exists' => $options['abort_if_destination_exists'],
182
+ 'clear_working' => $options['clear_working'],
183
+ 'hook_extra' => $options['hook_extra'],
184
+ )
185
+ );
186
+
187
+ $this->skin->set_result( $result );
188
+ if ( is_wp_error( $result ) ) {
189
+ $this->skin->error( $result );
190
+ //$this->skin->feedback( 'process_failed' );
191
+ } else {
192
+ // Installation succeeded.
193
+ //$this->skin->feedback( 'process_success' );
194
+ }
195
+
196
+ $this->skin->after();
197
+
198
+ if ( ! $options['is_multi'] ) {
199
+
200
+ /**
201
+ * Fire when the upgrader process is complete.
202
+ *
203
+ * See also {@see 'upgrader_package_options'}.
204
+ *
205
+ * @since 3.6.0
206
+ * @since 3.7.0 Added to WP_Upgrader::run().
207
+ * @since 4.6.0 `$translations` was added as a possible argument to `$hook_extra`.
208
+ *
209
+ * @param WP_Upgrader $this WP_Upgrader instance. In other contexts, $this, might be a
210
+ * Theme_Upgrader, Plugin_Upgrader, Core_Upgrade, or Language_Pack_Upgrader instance.
211
+ * @param array $hook_extra {
212
+ * Array of bulk item update data.
213
+ *
214
+ * @type string $action Type of action. Default 'update'.
215
+ * @type string $type Type of update process. Accepts 'plugin', 'theme', 'translation', or 'core'.
216
+ * @type bool $bulk Whether the update process is a bulk update. Default true.
217
+ * @type array $plugins Array of the basename paths of the plugins' main files.
218
+ * @type array $themes The theme slugs.
219
+ * @type array $translations {
220
+ * Array of translations update data.
221
+ *
222
+ * @type string $language The locale the translation is for.
223
+ * @type string $type Type of translation. Accepts 'plugin', 'theme', or 'core'.
224
+ * @type string $slug Text domain the translation is for. The slug of a theme/plugin or
225
+ * 'default' for core translations.
226
+ * @type string $version The version of a theme, plugin, or core.
227
+ * }
228
+ * }
229
+ */
230
+ do_action( 'upgrader_process_complete', $this, $options['hook_extra'] );
231
+
232
+ $this->skin->footer();
233
+ }
234
+
235
+ return $result;
236
+ }
237
+
238
+ /**
239
+ * Toggle maintenance mode for the site.
240
+ *
241
+ * Create/delete the maintenance file to enable/disable maintenance mode.
242
+ *
243
+ * @since 2.8.0
244
+ *
245
+ * @global WP_Filesystem_Base $wp_filesystem Subclass
246
+ *
247
+ * @param bool $enable True to enable maintenance mode, false to disable.
248
+ */
249
+ public function maintenance_mode( $enable = false ) {
250
+ global $wp_filesystem;
251
+ $file = $wp_filesystem->abspath() . '.maintenance';
252
+ if ( $enable ) {
253
+ //$this->skin->feedback( 'maintenance_start' );
254
+ // Create maintenance file to signal that we are upgrading
255
+ $maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
256
+ $wp_filesystem->delete( $file );
257
+ $wp_filesystem->put_contents( $file, $maintenance_string, FS_CHMOD_FILE );
258
+ } elseif ( ! $enable && $wp_filesystem->exists( $file ) ) {
259
+ //$this->skin->feedback( 'maintenance_end' );
260
+ $wp_filesystem->delete( $file );
261
+ }
262
+ }
263
+
264
+ /**
265
+ * Download a package.
266
+ *
267
+ * @since 2.8.0
268
+ *
269
+ * @param string $package The URI of the package. If this is the full path to an
270
+ * existing local file, it will be returned untouched.
271
+ * @param bool $check_signatures Whether to validate file signatures. Default false.
272
+ * @return string|WP_Error The full path to the downloaded package file, or a WP_Error object.
273
+ */
274
+ public function download_package( $package, $check_signatures = false ) {
275
+
276
+ /**
277
+ * Filter whether to return the package.
278
+ *
279
+ * @since 3.7.0
280
+ *
281
+ * @param bool $reply Whether to bail without returning the package.
282
+ * Default false.
283
+ * @param string $package The package file name.
284
+ * @param WP_Upgrader $this The WP_Upgrader instance.
285
+ */
286
+ $reply = apply_filters( 'upgrader_pre_download', false, $package, $this );
287
+ if ( false !== $reply ) {
288
+ return $reply;
289
+ }
290
+
291
+ if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { //Local file or remote?
292
+ return $package; //must be a local file..
293
+ }
294
+
295
+ if ( empty( $package ) ) {
296
+ return new WP_Error( 'no_package', $this->strings['no_package'] );
297
+ }
298
+
299
+ //$this->skin->feedback( 'downloading_package', $package );
300
+
301
+ $download_file = download_url( $package, 300, $check_signatures );
302
+
303
+ if ( is_wp_error( $download_file ) && ! $download_file->get_error_data( 'softfail-filename' ) ) {
304
+ return new WP_Error( 'download_failed', $this->strings['download_failed'], $download_file->get_error_message() );
305
+ }
306
+
307
+ return $download_file;
308
+ }
309
+
310
+ /**
311
+ * Unpack a compressed package file.
312
+ *
313
+ * @since 2.8.0
314
+ *
315
+ * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
316
+ *
317
+ * @param string $package Full path to the package file.
318
+ * @param bool $delete_package Optional. Whether to delete the package file after attempting
319
+ * to unpack it. Default true.
320
+ * @return string|WP_Error The path to the unpacked contents, or a WP_Error on failure.
321
+ */
322
+ public function unpack_package( $package, $delete_package = true ) {
323
+ global $wp_filesystem;
324
+
325
+ //$this->skin->feedback( 'unpack_package' );
326
+
327
+ $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
328
+
329
+ //Clean up contents of upgrade directory beforehand.
330
+ $upgrade_files = $wp_filesystem->dirlist( $upgrade_folder );
331
+ if ( ! empty( $upgrade_files ) ) {
332
+ foreach ( $upgrade_files as $file ) {
333
+ $wp_filesystem->delete( $upgrade_folder . $file['name'], true );
334
+ }
335
+ }
336
+
337
+ // We need a working directory - Strip off any .tmp or .zip suffixes
338
+ $working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' );
339
+
340
+ // Clean up working directory
341
+ if ( $wp_filesystem->is_dir( $working_dir ) ) {
342
+ $wp_filesystem->delete( $working_dir, true );
343
+ }
344
+
345
+ // Unzip package to working directory
346
+ $result = unzip_file( $package, $working_dir );
347
+
348
+ // Once extracted, delete the package if required.
349
+ if ( $delete_package ) {
350
+ unlink( $package );
351
+ }
352
+
353
+ if ( is_wp_error( $result ) ) {
354
+ $wp_filesystem->delete( $working_dir, true );
355
+ if ( 'incompatible_archive' == $result->get_error_code() ) {
356
+ return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], $result->get_error_data() );
357
+ }
358
+ return $result;
359
+ }
360
+
361
+ return $working_dir;
362
+ }
363
+
364
+ /**
365
+ * Install a package.
366
+ *
367
+ * Copies the contents of a package form a source directory, and installs them in
368
+ * a destination directory. Optionally removes the source. It can also optionally
369
+ * clear out the destination folder if it already exists.
370
+ *
371
+ * @since 2.8.0
372
+ *
373
+ * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
374
+ * @global array $wp_theme_directories
375
+ *
376
+ * @param array|string $args {
377
+ * Optional. Array or string of arguments for installing a package. Default empty array.
378
+ *
379
+ * @type string $source Required path to the package source. Default empty.
380
+ * @type string $destination Required path to a folder to install the package in.
381
+ * Default empty.
382
+ * @type bool $clear_destination Whether to delete any files already in the destination
383
+ * folder. Default false.
384
+ * @type bool $clear_working Whether to delete the files form the working directory
385
+ * after copying to the destination. Default false.
386
+ * @type bool $abort_if_destination_exists Whether to abort the installation if
387
+ * the destination folder already exists. Default true.
388
+ * @type array $hook_extra Extra arguments to pass to the filter hooks called by
389
+ * WP_Upgrader::install_package(). Default empty array.
390
+ * }
391
+ *
392
+ * @return array|WP_Error The result (also stored in `WP_Upgrader::$result`), or a WP_Error on failure.
393
+ */
394
+ public function install_package( $args = array() ) {
395
+ global $wp_filesystem, $wp_theme_directories;
396
+
397
+ $defaults = array(
398
+ 'source' => '', // Please always pass this
399
+ 'destination' => '', // and this
400
+ 'clear_destination' => false,
401
+ 'clear_working' => false,
402
+ 'abort_if_destination_exists' => true,
403
+ 'hook_extra' => array(),
404
+ );
405
+
406
+ $args = wp_parse_args( $args, $defaults );
407
+
408
+ // These were previously extract()'d.
409
+ $source = $args['source'];
410
+ $destination = $args['destination'];
411
+ $clear_destination = $args['clear_destination'];
412
+
413
+ set_time_limit( 300 );
414
+
415
+ if ( empty( $source ) || empty( $destination ) ) {
416
+ return new WP_Error( 'bad_request', $this->strings['bad_request'] );
417
+ }
418
+ //$this->skin->feedback( 'installing_package' );
419
+
420
+ /**
421
+ * Filter the install response before the installation has started.
422
+ *
423
+ * Returning a truthy value, or one that could be evaluated as a WP_Error
424
+ * will effectively short-circuit the installation, returning that value
425
+ * instead.
426
+ *
427
+ * @since 2.8.0
428
+ *
429
+ * @param bool|WP_Error $response Response.
430
+ * @param array $hook_extra Extra arguments passed to hooked filters.
431
+ */
432
+ $res = apply_filters( 'upgrader_pre_install', true, $args['hook_extra'] );
433
+
434
+ if ( is_wp_error( $res ) ) {
435
+ return $res;
436
+ }
437
+
438
+ //Retain the Original source and destinations
439
+ $remote_source = $args['source'];
440
+ $local_destination = $destination;
441
+
442
+ $source_files = array_keys( $wp_filesystem->dirlist( $remote_source ) );
443
+ $remote_destination = $wp_filesystem->find_folder( $local_destination );
444
+
445
+ //Locate which directory to copy to the new folder, This is based on the actual folder holding the files.
446
+ if ( 1 == count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) { //Only one folder? Then we want its contents.
447
+ $source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] );
448
+ } elseif ( count( $source_files ) == 0 ) {
449
+ return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] ); // There are no files?
450
+ } else { // It's only a single file, the upgrader will use the folder name of this file as the destination folder. Folder name is based on zip filename.
451
+ $source = trailingslashit( $args['source'] );
452
+ }
453
+
454
+ /**
455
+ * Filter the source file location for the upgrade package.
456
+ *
457
+ * @since 2.8.0
458
+ * @since 4.4.0 The $hook_extra parameter became available.
459
+ *
460
+ * @param string $source File source location.
461
+ * @param string $remote_source Remote file source location.
462
+ * @param WP_Upgrader $this WP_Upgrader instance.
463
+ * @param array $hook_extra Extra arguments passed to hooked filters.
464
+ */
465
+ $source = apply_filters( 'upgrader_source_selection', $source, $remote_source, $this, $args['hook_extra'] );
466
+
467
+ if ( is_wp_error( $source ) ) {
468
+ return $source;
469
+ }
470
+
471
+ // Has the source location changed? If so, we need a new source_files list.
472
+ if ( $source !== $remote_source ) {
473
+ $source_files = array_keys( $wp_filesystem->dirlist( $source ) );
474
+ }
475
+
476
+ /*
477
+ * Protection against deleting files in any important base directories.
478
+ * Theme_Upgrader & Plugin_Upgrader also trigger this, as they pass the
479
+ * destination directory (WP_PLUGIN_DIR / wp-content/themes) intending
480
+ * to copy the directory into the directory, whilst they pass the source
481
+ * as the actual files to copy.
482
+ */
483
+ $protected_directories = array( ABSPATH, WP_CONTENT_DIR, WP_PLUGIN_DIR, WP_CONTENT_DIR . '/themes' );
484
+
485
+ if ( is_array( $wp_theme_directories ) ) {
486
+ $protected_directories = array_merge( $protected_directories, $wp_theme_directories );
487
+ }
488
+
489
+ if ( in_array( $destination, $protected_directories ) ) {
490
+ $remote_destination = trailingslashit( $remote_destination ) . trailingslashit( basename( $source ) );
491
+ $destination = trailingslashit( $destination ) . trailingslashit( basename( $source ) );
492
+ }
493
+
494
+ if ( $clear_destination ) {
495
+ // We're going to clear the destination if there's something there.
496
+ //$this->skin->feedback( 'remove_old' );
497
+
498
+ $removed = $this->clear_destination( $remote_destination );
499
+
500
+ /**
501
+ * Filter whether the upgrader cleared the destination.
502
+ *
503
+ * @since 2.8.0
504
+ *
505
+ * @param mixed $removed Whether the destination was cleared. true on success, WP_Error on failure
506
+ * @param string $local_destination The local package destination.
507
+ * @param string $remote_destination The remote package destination.
508
+ * @param array $hook_extra Extra arguments passed to hooked filters.
509
+ */
510
+ $removed = apply_filters( 'upgrader_clear_destination', $removed, $local_destination, $remote_destination, $args['hook_extra'] );
511
+
512
+ if ( is_wp_error( $removed ) ) {
513
+ return $removed;
514
+ }
515
+ } elseif ( $args['abort_if_destination_exists'] && $wp_filesystem->exists( $remote_destination ) ) {
516
+ //If we're not clearing the destination folder and something exists there already, Bail.
517
+ //But first check to see if there are actually any files in the folder.
518
+ $_files = $wp_filesystem->dirlist( $remote_destination );
519
+ if ( ! empty( $_files ) ) {
520
+ $wp_filesystem->delete( $remote_source, true ); //Clear out the source files.
521
+ return new WP_Error( 'folder_exists', $this->strings['folder_exists'], $remote_destination );
522
+ }
523
+ }
524
+
525
+ //Create destination if needed
526
+ if ( ! $wp_filesystem->exists( $remote_destination ) ) {
527
+ if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) {
528
+ return new WP_Error( 'mkdir_failed_destination', $this->strings['mkdir_failed'], $remote_destination );
529
+ }
530
+ }
531
+ // Copy new version of item into place.
532
+ $result = copy_dir( $source, $remote_destination );
533
+ if ( is_wp_error( $result ) ) {
534
+ if ( $args['clear_working'] ) {
535
+ $wp_filesystem->delete( $remote_source, true );
536
+ }
537
+ return $result;
538
+ }
539
+
540
+ //Clear the Working folder?
541
+ if ( $args['clear_working'] ) {
542
+ $wp_filesystem->delete( $remote_source, true );
543
+ }
544
+
545
+ $destination_name = basename( str_replace( $local_destination, '', $destination ) );
546
+ if ( '.' == $destination_name ) {
547
+ $destination_name = '';
548
+ }
549
+
550
+ $this->result = compact( 'source', 'source_files', 'destination', 'destination_name', 'local_destination', 'remote_destination', 'clear_destination' );
551
+
552
+ /**
553
+ * Filter the installation response after the installation has finished.
554
+ *
555
+ * @since 2.8.0
556
+ *
557
+ * @param bool $response Installation response.
558
+ * @param array $hook_extra Extra arguments passed to hooked filters.
559
+ * @param array $result Installation result data.
560
+ */
561
+ $res = apply_filters( 'upgrader_post_install', true, $args['hook_extra'], $this->result );
562
+
563
+ if ( is_wp_error( $res ) ) {
564
+ $this->result = $res;
565
+ return $res;
566
+ }
567
+
568
+ //Bombard the calling function will all the info which we've just used.
569
+ return $this->result;
570
+ }
571
+ }
includes/admin/licensing/skin.php CHANGED
@@ -1,115 +1,116 @@
1
- <?php
2
- /**
3
- * Skin class.
4
- *
5
- * @since 6.0.0
6
- *
7
- * @package MonsterInsights
8
- * @subpackage Upgrader Skin
9
- * @author Chris Christoff
10
- */
11
-
12
- // Exit if accessed directly
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
-
17
- class MonsterInsights_Skin extends WP_Upgrader_Skin {
18
-
19
- /**
20
- * Primary class constructor.
21
- *
22
- * @since 6.0.0
23
- *
24
- * @param array $args Empty array of args (we will use defaults).
25
- */
26
- public function __construct( $args = array() ) {
27
-
28
- parent::__construct();
29
-
30
- }
31
-
32
- /**
33
- * Set the upgrader object and store it as a property in the parent class.
34
- *
35
- * @since 6.0.0
36
- *
37
- * @param object $upgrader The upgrader object (passed by reference).
38
- */
39
- public function set_upgrader( &$upgrader ) {
40
-
41
- if ( is_object( $upgrader ) ) {
42
- $this->upgrader =& $upgrader;
43
- }
44
-
45
- }
46
-
47
- /**
48
- * Set the upgrader result and store it as a property in the parent class.
49
- *
50
- * @since 6.0.0
51
- *
52
- * @param object $result The result of the install process.
53
- */
54
- public function set_result( $result ) {
55
-
56
- $this->result = $result;
57
-
58
- }
59
-
60
- /**
61
- * Empty out the header of its HTML content and only check to see if it has
62
- * been performed or not.
63
- *
64
- * @since 6.0.0
65
- */
66
- public function header() {}
67
-
68
- /**
69
- * Empty out the footer of its HTML contents.
70
- *
71
- * @since 6.0.0
72
- */
73
- function footer() {}
74
-
75
- /**
76
- * Instead of outputting HTML for errors, json_encode the errors and send them
77
- * back to the Ajax script for processing.
78
- *
79
- * @since 6.0.0
80
- *
81
- * @param array $errors Array of errors with the install process.
82
- */
83
- function error( $errors ) {
84
-
85
- if ( ! empty( $errors ) ) {
86
- $error_message = esc_html__( 'There was an error installing the addon. Please try again.', 'google-analytics-for-wordpress' );
87
- if ( is_wp_error( $errors ) ) {
88
- /**
89
- * @var WP_Error $errors
90
- */
91
- $message = $errors->get_error_message();
92
-
93
- if ( ! empty( $message ) ) {
94
- $error_message = sprintf( esc_html__( 'There was an error installing the addon: %s', 'google-analytics-for-wordpress' ), esc_html( $message ) );
95
- }
96
- }
97
-
98
- wp_send_json( array( 'error' => $error_message ) );
99
- }
100
-
101
- }
102
-
103
- /**
104
- * Empty out the feedback method to prevent outputting HTML strings as the install
105
- * is progressing.
106
- *
107
- * @since 6.0.0
108
- *
109
- * @param string $string The feedback string.
110
- */
111
- function feedback( $string ) {
112
-
113
- }
114
-
115
- }
 
1
+ <?php
2
+ /**
3
+ * Skin class.
4
+ *
5
+ * @since 6.0.0
6
+ *
7
+ * @package MonsterInsights
8
+ * @subpackage Upgrader Skin
9
+ * @author Chris Christoff
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ class MonsterInsights_Skin extends WP_Upgrader_Skin {
18
+
19
+ /**
20
+ * Primary class constructor.
21
+ *
22
+ * @since 6.0.0
23
+ *
24
+ * @param array $args Empty array of args (we will use defaults).
25
+ */
26
+ public function __construct( $args = array() ) {
27
+
28
+ parent::__construct();
29
+
30
+ }
31
+
32
+ /**
33
+ * Set the upgrader object and store it as a property in the parent class.
34
+ *
35
+ * @since 6.0.0
36
+ *
37
+ * @param object $upgrader The upgrader object (passed by reference).
38
+ */
39
+ public function set_upgrader( &$upgrader ) {
40
+
41
+ if ( is_object( $upgrader ) ) {
42
+ $this->upgrader =& $upgrader;
43
+ }
44
+
45
+ }
46
+
47
+ /**
48
+ * Set the upgrader result and store it as a property in the parent class.
49
+ *
50
+ * @since 6.0.0
51
+ *
52
+ * @param object $result The result of the install process.
53
+ */
54
+ public function set_result( $result ) {
55
+
56
+ $this->result = $result;
57
+
58
+ }
59
+
60
+ /**
61
+ * Empty out the header of its HTML content and only check to see if it has
62
+ * been performed or not.
63
+ *
64
+ * @since 6.0.0
65
+ */
66
+ public function header() {}
67
+
68
+ /**
69
+ * Empty out the footer of its HTML contents.
70
+ *
71
+ * @since 6.0.0
72
+ */
73
+ function footer() {}
74
+
75
+ /**
76
+ * Instead of outputting HTML for errors, json_encode the errors and send them
77
+ * back to the Ajax script for processing.
78
+ *
79
+ * @since 6.0.0
80
+ *
81
+ * @param array $errors Array of errors with the install process.
82
+ */
83
+ function error( $errors ) {
84
+
85
+ if ( ! empty( $errors ) ) {
86
+ $error_message = esc_html__( 'There was an error installing the addon. Please try again.', 'google-analytics-for-wordpress' );
87
+ if ( is_wp_error( $errors ) ) {
88
+ /**
89
+ * @var WP_Error $errors
90
+ */
91
+ $message = $errors->get_error_message();
92
+
93
+ if ( ! empty( $message ) ) {
94
+ // Translators: The name of the addon that can't be installed.
95
+ $error_message = sprintf( esc_html__( 'There was an error installing the addon: %s', 'google-analytics-for-wordpress' ), esc_html( $message ) );
96
+ }
97
+ }
98
+
99
+ wp_send_json( array( 'error' => $error_message ) );
100
+ }
101
+
102
+ }
103
+
104
+ /**
105
+ * Empty out the feedback method to prevent outputting HTML strings as the install
106
+ * is progressing.
107
+ *
108
+ * @since 6.0.0
109
+ *
110
+ * @param string $string The feedback string.
111
+ */
112
+ function feedback( $string ) {
113
+
114
+ }
115
+
116
+ }
includes/admin/notice.php CHANGED
@@ -1,236 +1,236 @@
1
- <?php
2
- /**
3
- * Notices admin class.
4
- *
5
- * Handles retrieving whether a particular notice has been dismissed or not,
6
- * as well as marking a notice as dismissed.
7
- *
8
- * @since 6.0.0
9
- *
10
- * @package MonsterInsights
11
- * @subpackage Notices
12
- * @author Chris Christoff
13
- */
14
-
15
- // Exit if accessed directly
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- exit;
18
- }
19
-
20
- final class MonsterInsights_Notice_Admin {
21
-
22
- /**
23
- * Holds all dismissed notices
24
- *
25
- * @access public
26
- * @since 6.0.0
27
- * @var array $notices Array of dismissed notices.
28
- */
29
- public $notices;
30
-
31
- /**
32
- * Primary class constructor.
33
- *
34
- * @access public
35
- * @since 6.0.0
36
- */
37
- public function __construct() {
38
-
39
- // Populate $notices
40
- $this->notices = get_option( 'monsterinsights_notices' );
41
- if ( ! is_array( $this->notices ) ) {
42
- $this->notices = array();
43
- }
44
-
45
- }
46
-
47
- /**
48
- * Checks if a given notice has been dismissed or not
49
- *
50
- * @access public
51
- * @since 6.0.0
52
- *
53
- * @param string $notice Programmatic Notice Name
54
- * @return bool Notice Dismissed
55
- */
56
-
57
- public function is_dismissed( $notice ) {
58
- if ( ! isset( $this->notices[ $notice ] ) ) {
59
- return false;
60
- }
61
- return true;
62
-
63
- }
64
-
65
- /**
66
- * Marks the given notice as dismissed
67
- *
68
- * @access public
69
- * @since 6.0.0
70
- *
71
- * @param string $notice Programmatic Notice Name
72
- * @return null
73
- */
74
- public function dismiss( $notice ) {
75
- $this->notices[ $notice ] = true;
76
- update_option( 'monsterinsights_notices', $this->notices );
77
-
78
- }
79
-
80
-
81
- /**
82
- * Marks a notice as not dismissed
83
- *
84
- * @access public
85
- * @since 6.0.0
86
- *
87
- * @param string $notice Programmatic Notice Name
88
- * @return null
89
- */
90
- public function undismiss( $notice ) {
91
- unset( $this->notices[ $notice ] );
92
- update_option( 'monsterinsights_notices', $this->notices );
93
-
94
- }
95
-
96
- /**
97
- * Displays an inline notice with some MonsterInsights styling.
98
- *
99
- * @access public
100
- * @since 6.0.0
101
- *
102
- * @param string $notice Programmatic Notice Name
103
- * @param string $title Title
104
- * @param string $message Message
105
- * @param string $type Message Type (updated|warning|error) - green, yellow/orange and red respectively.
106
- * @param string $button_text Button Text (optional)
107
- * @param string $button_url Button URL (optional)
108
- * @param bool $is_dismissible User can Dismiss Message (default: false)
109
- */
110
- public function display_inline_notice( $name, $title, $message, $type = 'success', $is_dismissible = false, $args = array() ) {
111
- /* Available/Planned $args options
112
- * $args = array(
113
- * 'primary' => array(
114
- * 'text' => '',
115
- * 'url' => '',
116
- * 'target' => '',
117
- * 'class' => 'button button-primary',
118
- * ),
119
- * 'secondary' => array(
120
- * 'text' => '',
121
- * 'url' => '',
122
- * 'target' => '',
123
- * 'class' => 'button button-secondary',
124
- * ),
125
- * 'skip_message_escape' => true // note: This param is for internal use only. Do not use as a developer.
126
- * );
127
- */
128
-
129
-
130
- // Check if the notice is dismissible, and if so has been dismissed.
131
- if ( $is_dismissible && $this->is_dismissed( $name ) ) {
132
- // Nothing to show here, return!
133
- return '';
134
- }
135
-
136
- $dismissible = ( $is_dismissible ) ? ' is-dismissible': '';
137
-
138
- // Display inline notice
139
- ob_start();
140
- ?>
141
- <div class="monsterinsights-notice <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice' . $dismissible; ?>" data-notice="<?php echo esc_attr( $name ); ?>">
142
- <div class="monsterinsights-notice-icon <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice-icon'?>">
143
- </div>
144
- <div class="monsterinsights-notice-text <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice-text'?>">
145
- <?php
146
- // Title
147
- if ( ! empty ( $title ) ) {
148
- ?>
149
- <p class="monsterinsights-notice-title"><?php echo esc_html( $title ); ?></p>
150
- <?php
151
- }
152
-
153
- // Message
154
- if ( ! empty( $message ) ) {
155
- if ( empty( $args['skip_message_escape'] ) ) {
156
- ?>
157
- <p class="monsterinsights-notice-message"><?php echo esc_html( $message ); ?></p>
158
- <?php
159
- } else {
160
- ?>
161
- <p class="monsterinsights-notice-message"><?php echo $message; ?></p>
162
- <?php
163
- }
164
- }
165
-
166
- // Primary Button
167
- if ( ! empty( $args['primary']['text'] ) ) {
168
-
169
- $text = '';
170
- if ( ! empty( $args['primary']['text'] ) ) {
171
- $text = $args['primary']['text'];
172
- }
173
-
174
- $url = '#';
175
- if ( ! empty( $args['primary']['url'] ) ) {
176
- $url = $args['primary']['url'];
177
- }
178
-
179
- $target = '';
180
- if ( ! empty( $args['primary']['target'] ) && $args['primary']['target'] === 'blank') {
181
- $target = ' target="_blank" rel="noopener noreferrer"';
182
- }
183
-
184
- $class = 'button button-primary';
185
- if ( ! empty( $args['primary']['class'] ) ) {
186
- $class = ' class="'. $args['primary']['class'] . '"';
187
- }
188
- ?>
189
- <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class;?>><?php echo esc_html( $text ); ?></a>
190
- <?php
191
- }
192
-
193
- // Secondary Button
194
- if ( ! empty( $args['secondary']['text'] ) ) {
195
-
196
- $text = '';
197
- if ( ! empty( $args['secondary']['text'] ) ) {
198
- $text = $args['secondary']['text'];
199
- }
200
-
201
- $url = '#';
202
- if ( ! empty( $args['secondary']['url'] ) ) {
203
- $url = $args['secondary']['url'];
204
- }
205
-
206
- $target = '';
207
- if ( ! empty( $args['secondary']['target'] ) && $args['secondary']['target'] === 'blank') {
208
- $target = ' target="_blank" rel="noopener noreferrer"';
209
- }
210
-
211
- $class = 'button button-secondary';
212
- if ( ! empty( $args['secondary']['class'] ) ) {
213
- $class = ' class="'. $args['secondary']['class'] . '"';
214
- }
215
- ?>
216
- <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class;?>><?php echo esc_html( $text ); ?></a>
217
- <?php
218
- }
219
-
220
- // Dismiss Button
221
- if ( $is_dismissible ) {
222
- ?>
223
- <button type="button" class="notice-dismiss<?php echo $dismissible; ?>">
224
- <span class="screen-reader-text">
225
- <?php esc_html_e( 'Dismiss this notice', 'google-analytics-for-wordpress' ); ?>
226
- </span>
227
- </button>
228
- <?php
229
- }
230
- ?>
231
- </div>
232
- </div>
233
- <?php
234
- return ob_get_clean();
235
- }
236
  }
1
+ <?php
2
+ /**
3
+ * Notices admin class.
4
+ *
5
+ * Handles retrieving whether a particular notice has been dismissed or not,
6
+ * as well as marking a notice as dismissed.
7
+ *
8
+ * @since 6.0.0
9
+ *
10
+ * @package MonsterInsights
11
+ * @subpackage Notices
12
+ * @author Chris Christoff
13
+ */
14
+
15
+ // Exit if accessed directly
16
+ if ( ! defined( 'ABSPATH' ) ) {
17
+ exit;
18
+ }
19
+
20
+ final class MonsterInsights_Notice_Admin {
21
+
22
+ /**
23
+ * Holds all dismissed notices
24
+ *
25
+ * @access public
26
+ * @since 6.0.0
27
+ * @var array $notices Array of dismissed notices.
28
+ */
29
+ public $notices;
30
+
31
+ /**
32
+ * Primary class constructor.
33
+ *
34
+ * @access public
35
+ * @since 6.0.0
36
+ */
37
+ public function __construct() {
38
+
39
+ // Populate $notices
40
+ $this->notices = get_option( 'monsterinsights_notices' );
41
+ if ( ! is_array( $this->notices ) ) {
42
+ $this->notices = array();
43
+ }
44
+
45
+ }
46
+
47
+ /**
48
+ * Checks if a given notice has been dismissed or not
49
+ *
50
+ * @access public
51
+ * @since 6.0.0
52
+ *
53
+ * @param string $notice Programmatic Notice Name
54
+ * @return bool Notice Dismissed
55
+ */
56
+
57
+ public function is_dismissed( $notice ) {
58
+ if ( ! isset( $this->notices[ $notice ] ) ) {
59
+ return false;
60
+ }
61
+ return true;
62
+
63
+ }
64
+
65
+ /**
66
+ * Marks the given notice as dismissed
67
+ *
68
+ * @access public
69
+ * @since 6.0.0
70
+ *
71
+ * @param string $notice Programmatic Notice Name
72
+ * @return null
73
+ */
74
+ public function dismiss( $notice ) {
75
+ $this->notices[ $notice ] = true;
76
+ update_option( 'monsterinsights_notices', $this->notices );
77
+
78
+ }
79
+
80
+
81
+ /**
82
+ * Marks a notice as not dismissed
83
+ *
84
+ * @access public
85
+ * @since 6.0.0
86
+ *
87
+ * @param string $notice Programmatic Notice Name
88
+ * @return null
89
+ */
90
+ public function undismiss( $notice ) {
91
+ unset( $this->notices[ $notice ] );
92
+ update_option( 'monsterinsights_notices', $this->notices );
93
+
94
+ }
95
+
96
+ /**
97
+ * Displays an inline notice with some MonsterInsights styling.
98
+ *
99
+ * @access public
100
+ * @since 6.0.0
101
+ *
102
+ * @param string $notice Programmatic Notice Name
103
+ * @param string $title Title
104
+ * @param string $message Message
105
+ * @param string $type Message Type (updated|warning|error) - green, yellow/orange and red respectively.
106
+ * @param string $button_text Button Text (optional)
107
+ * @param string $button_url Button URL (optional)
108
+ * @param bool $is_dismissible User can Dismiss Message (default: false)
109
+ */
110
+ public function display_inline_notice( $name, $title, $message, $type = 'success', $is_dismissible = false, $args = array() ) {
111
+ /* Available/Planned $args options
112
+ * $args = array(
113
+ * 'primary' => array(
114
+ * 'text' => '',
115
+ * 'url' => '',
116
+ * 'target' => '',
117
+ * 'class' => 'button button-primary',
118
+ * ),
119
+ * 'secondary' => array(
120
+ * 'text' => '',
121
+ * 'url' => '',
122
+ * 'target' => '',
123
+ * 'class' => 'button button-secondary',
124
+ * ),
125
+ * 'skip_message_escape' => true // note: This param is for internal use only. Do not use as a developer.
126
+ * );
127
+ */
128
+
129
+
130
+ // Check if the notice is dismissible, and if so has been dismissed.
131
+ if ( $is_dismissible && $this->is_dismissed( $name ) ) {
132
+ // Nothing to show here, return!
133
+ return '';
134
+ }
135
+
136
+ $dismissible = ( $is_dismissible ) ? ' is-dismissible': '';
137
+
138
+ // Display inline notice
139
+ ob_start();
140
+ ?>
141
+ <div class="monsterinsights-notice <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice' . $dismissible; ?>" data-notice="<?php echo esc_attr( $name ); ?>">
142
+ <div class="monsterinsights-notice-icon <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice-icon'?>">
143
+ </div>
144
+ <div class="monsterinsights-notice-text <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice-text'?>">
145
+ <?php
146
+ // Title
147
+ if ( ! empty ( $title ) ) {
148
+ ?>
149
+ <p class="monsterinsights-notice-title"><?php echo esc_html( $title ); ?></p>
150
+ <?php
151
+ }
152
+
153
+ // Message
154
+ if ( ! empty( $message ) ) {
155
+ if ( empty( $args['skip_message_escape'] ) ) {
156
+ ?>
157
+ <p class="monsterinsights-notice-message"><?php echo esc_html( $message ); ?></p>
158
+ <?php
159
+ } else {
160
+ ?>
161
+ <p class="monsterinsights-notice-message"><?php echo $message; ?></p>
162
+ <?php
163
+ }
164
+ }
165
+
166
+ // Primary Button
167
+ if ( ! empty( $args['primary']['text'] ) ) {
168
+
169
+ $text = '';
170
+ if ( ! empty( $args['primary']['text'] ) ) {
171
+ $text = $args['primary']['text'];
172
+ }
173
+
174
+ $url = '#';
175
+ if ( ! empty( $args['primary']['url'] ) ) {
176
+ $url = $args['primary']['url'];
177
+ }
178
+
179
+ $target = '';
180
+ if ( ! empty( $args['primary']['target'] ) && $args['primary']['target'] === 'blank') {
181
+ $target = ' target="_blank" rel="noopener noreferrer"';
182
+ }
183
+
184
+ $class = 'button button-primary';
185
+ if ( ! empty( $args['primary']['class'] ) ) {
186
+ $class = ' class="'. $args['primary']['class'] . '"';
187
+ }
188
+ ?>
189
+ <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class;?>><?php echo esc_html( $text ); ?></a>
190
+ <?php
191
+ }
192
+
193
+ // Secondary Button
194
+ if ( ! empty( $args['secondary']['text'] ) ) {
195
+
196
+ $text = '';
197
+ if ( ! empty( $args['secondary']['text'] ) ) {
198
+ $text = $args['secondary']['text'];
199
+ }
200
+
201
+ $url = '#';
202
+ if ( ! empty( $args['secondary']['url'] ) ) {
203
+ $url = $args['secondary']['url'];
204
+ }
205
+
206
+ $target = '';
207
+ if ( ! empty( $args['secondary']['target'] ) && $args['secondary']['target'] === 'blank') {
208
+ $target = ' target="_blank" rel="noopener noreferrer"';
209
+ }
210
+
211
+ $class = 'button button-secondary';
212
+ if ( ! empty( $args['secondary']['class'] ) ) {
213
+ $class = ' class="'. $args['secondary']['class'] . '"';
214
+ }
215
+ ?>
216
+ <a href="<?php echo esc_attr( $url ); ?>"<?php echo $target; ?><?php echo $class;?>><?php echo esc_html( $text ); ?></a>
217
+ <?php
218
+ }
219
+
220
+ // Dismiss Button
221
+ if ( $is_dismissible ) {
222
+ ?>
223
+ <button type="button" class="notice-dismiss<?php echo $dismissible; ?>">
224
+ <span class="screen-reader-text">
225
+ <?php esc_html_e( 'Dismiss this notice', 'google-analytics-for-wordpress' ); ?>
226
+ </span>
227
+ </button>
228
+ <?php
229
+ }
230
+ ?>
231
+ </div>
232
+ </div>
233
+ <?php
234
+ return ob_get_clean();
235
+ }
236
  }
includes/admin/notifications.php ADDED
@@ -0,0 +1,408 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Notifications.
5
+ *
6
+ * @since 7.10.5
7
+ */
8
+ class MonsterInsights_Notifications {
9
+
10
+ /**
11
+ * Source of notifications content.
12
+ *
13
+ * @since {VERSION}
14
+ *
15
+ * @var string
16
+ */
17
+ const SOURCE_URL = 'https://plugin-cdn.monsterinsights.com/notifications.json';
18
+
19
+ /**
20
+ * Option value.
21
+ *
22
+ * @since {VERSION}
23
+ *
24
+ * @var bool|array
25
+ */
26
+ public $option = false;
27
+
28
+ /**
29
+ * The name of the option used to store the data.
30
+ *
31
+ * @var string
32
+ */
33
+ public $option_name = 'monsterinsights_notifications';
34
+
35
+ /**
36
+ * MonsterInsights_Notifications constructor.
37
+ */
38
+ public function __construct() {
39
+ $this->init();
40
+ }
41
+
42
+ /**
43
+ * Initialize class.
44
+ *
45
+ * @since {VERSION}
46
+ */
47
+ public function init() {
48
+
49
+ $this->hooks();
50
+ }
51
+
52
+ /**
53
+ * Register hooks.
54
+ *
55
+ * @since {VERSION}
56
+ */
57
+ public function hooks() {
58
+ add_action( 'wp_ajax_monsterinsights_notification_dismiss', array( $this, 'dismiss' ) );
59
+
60
+ add_action( 'wp_ajax_monsterinsights_vue_get_notifications', array( $this, 'ajax_get_notifications' ) );
61
+
62
+ add_action( 'monsterinsights_admin_notifications_update', array( $this, 'update' ) );
63
+
64
+ }
65
+
66
+ /**
67
+ * Check if user has access and is enabled.
68
+ *
69
+ * @return bool
70
+ * @since {VERSION}
71
+ *
72
+ */
73
+ public function has_access() {
74
+
75
+ $access = false;
76
+
77
+ if ( current_user_can( 'monsterinsights_view_dashboard' ) && ! monsterinsights_get_option( 'hide_am_notices', false ) ) {
78
+ $access = true;
79
+ }
80
+
81
+ return apply_filters( 'monsterinsights_admin_notifications_has_access', $access );
82
+ }
83
+
84
+ /**
85
+ * Get option value.
86
+ *
87
+ * @param bool $cache Reference property cache if available.
88
+ *
89
+ * @return array
90
+ * @since {VERSION}
91
+ *
92
+ */
93
+ public function get_option( $cache = true ) {
94
+
95
+ if ( $this->option && $cache ) {
96
+ return $this->option;
97
+ }
98
+
99
+ $option = get_option( $this->option_name, array() );
100
+
101
+ $this->option = array(
102
+ 'update' => ! empty( $option['update'] ) ? $option['update'] : 0,
103
+ 'events' => ! empty( $option['events'] ) ? $option['events'] : array(),
104
+ 'feed' => ! empty( $option['feed'] ) ? $option['feed'] : array(),
105
+ 'dismissed' => ! empty( $option['dismissed'] ) ? $option['dismissed'] : array(),
106
+ );
107
+
108
+ return $this->option;
109
+ }
110
+
111
+ /**
112
+ * Fetch notifications from feed.
113
+ *
114
+ * @return array
115
+ * @since {VERSION}
116
+ *
117
+ */
118
+ public function fetch_feed() {
119
+
120
+ $res = wp_remote_get( self::SOURCE_URL );
121
+
122
+ if ( is_wp_error( $res ) ) {
123
+ return array();
124
+ }
125
+
126
+ $body = wp_remote_retrieve_body( $res );
127
+
128
+ if ( empty( $body ) ) {
129
+ return array();
130
+ }
131
+
132
+ return $this->verify( json_decode( $body, true ) );
133
+ }
134
+
135
+ /**
136
+ * Verify notification data before it is saved.
137
+ *
138
+ * @param array $notifications Array of notifications items to verify.
139
+ *
140
+ * @return array
141
+ * @since {VERSION}
142
+ *
143
+ */
144
+ public function verify( $notifications ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
145
+
146
+ $data = array();
147
+
148
+ if ( ! is_array( $notifications ) || empty( $notifications ) ) {
149
+ return $data;
150
+ }
151
+
152
+ $option = $this->get_option();
153
+
154
+ foreach ( $notifications as $notification ) {
155
+
156
+ // The message and license should never be empty, if they are, ignore.
157
+ if ( empty( $notification['content'] ) || empty( $notification['type'] ) ) {
158
+ continue;
159
+ }
160
+
161
+ // Ignore if license type does not match.
162
+ if ( ! in_array( MonsterInsights()->license->get_license_type(), $notification['type'] ) ) {
163
+ continue;
164
+ }
165
+
166
+ // Ignore if expired.
167
+ if ( ! empty( $notification['end'] ) && time() > strtotime( $notification['end'] ) ) {
168
+ continue;
169
+ }
170
+
171
+ // Ignore if notification has already been dismissed.
172
+ if ( ! empty( $option['dismissed'] ) && in_array( $notification['id'], $option['dismissed'] ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
173
+ continue;
174
+ }
175
+
176
+ // Ignore if notification existed before installing MonsterInsights.
177
+ // Prevents bombarding the user with notifications after activation.
178
+ $over_time = get_option( 'monsterinsights_over_time', array() );
179
+
180
+ if (
181
+ ! empty( $over_time['installed_date'] ) &&
182
+ ! empty( $notification['start'] ) &&
183
+ $over_time['installed_date'] > strtotime( $notification['start'] )
184
+ ) {
185
+ continue;
186
+ }
187
+
188
+ $data[] = $notification;
189
+ }
190
+
191
+ return $data;
192
+ }
193
+
194
+ /**
195
+ * Verify saved notification data for active notifications.
196
+ *
197
+ * @param array $notifications Array of notifications items to verify.
198
+ *
199
+ * @return array
200
+ * @since {VERSION}
201
+ *
202
+ */
203
+ public function verify_active( $notifications ) {
204
+
205
+ if ( ! is_array( $notifications ) || empty( $notifications ) ) {
206
+ return array();
207
+ }
208
+
209
+ // Remove notifications that are not active.
210
+ foreach ( $notifications as $key => $notification ) {
211
+ if (
212
+ ( ! empty( $notification['start'] ) && time() < strtotime( $notification['start'] ) ) ||
213
+ ( ! empty( $notification['end'] ) && time() > strtotime( $notification['end'] ) )
214
+ ) {
215
+ unset( $notifications[ $key ] );
216
+ }
217
+ }
218
+
219
+ return $notifications;
220
+ }
221
+
222
+ /**
223
+ * Get notification data.
224
+ *
225
+ * @return array
226
+ * @since {VERSION}
227
+ *
228
+ */
229
+ public function get() {
230
+
231
+ if ( ! $this->has_access() ) {
232
+ return array();
233
+ }
234
+
235
+ $option = $this->get_option();
236
+
237
+ // Update notifications using async task.
238
+ if ( empty( $option['update'] ) || time() > $option['update'] + DAY_IN_SECONDS ) {
239
+ if ( false === wp_next_scheduled( 'monsterinsights_admin_notifications_update' ) ) {
240
+ wp_schedule_single_event( time(), 'monsterinsights_admin_notifications_update' );
241
+ }
242
+ }
243
+
244
+ $events = ! empty( $option['events'] ) ? $this->verify_active( $option['events'] ) : array();
245
+ $feed = ! empty( $option['feed'] ) ? $this->verify_active( $option['feed'] ) : array();
246
+
247
+ return array_merge( $events, $feed );
248
+ }
249
+
250
+ /**
251
+ * Get notification count.
252
+ *
253
+ * @return int
254
+ * @since {VERSION}
255
+ *
256
+ */
257
+ public function get_count() {
258
+
259
+ return count( $this->get() );
260
+ }
261
+
262
+ /**
263
+ * Add a manual notification event.
264
+ *
265
+ * @param array $notification Notification data.
266
+ *
267
+ * @since {VERSION}
268
+ *
269
+ */
270
+ public function add( $notification ) {
271
+
272
+ if ( empty( $notification['id'] ) ) {
273
+ return;
274
+ }
275
+
276
+ $option = $this->get_option();
277
+
278
+ if ( in_array( $notification['id'], $option['dismissed'] ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
279
+ return;
280
+ }
281
+
282
+ foreach ( $option['events'] as $item ) {
283
+ if ( $item['id'] === $notification['id'] ) {
284
+ return;
285
+ }
286
+ }
287
+
288
+ $notification = $this->verify( array( $notification ) );
289
+
290
+ update_option(
291
+ $this->option_name,
292
+ array(
293
+ 'update' => $option['update'],
294
+ 'feed' => $option['feed'],
295
+ 'events' => array_merge( $notification, $option['events'] ),
296
+ 'dismissed' => $option['dismissed'],
297
+ )
298
+ );
299
+ }
300
+
301
+ /**
302
+ * Update notification data from feed.
303
+ *
304
+ * @since {VERSION}
305
+ */
306
+ public function update() {
307
+
308
+ $feed = $this->fetch_feed();
309
+ $option = $this->get_option();
310
+
311
+ update_option(
312
+ $this->option_name,
313
+ array(
314
+ 'update' => time(),
315
+ 'feed' => $feed,
316
+ 'events' => $option['events'],
317
+ 'dismissed' => $option['dismissed'],
318
+ )
319
+ );
320
+ }
321
+
322
+ /**
323
+ * Dismiss notification via AJAX.
324
+ *
325
+ * @since {VERSION}
326
+ */
327
+ public function dismiss() {
328
+
329
+ // Run a security check.
330
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
331
+
332
+ // Check for access and required param.
333
+ if ( ! $this->has_access() || empty( $_POST['id'] ) ) {
334
+ wp_send_json_error();
335
+ }
336
+
337
+ $id = sanitize_text_field( wp_unslash( $_POST['id'] ) );
338
+ $option = $this->get_option();
339
+ $type = is_numeric( $id ) ? 'feed' : 'events';
340
+
341
+ $option['dismissed'][] = $id;
342
+ $option['dismissed'] = array_unique( $option['dismissed'] );
343
+
344
+ // Remove notification.
345
+ if ( is_array( $option[ $type ] ) && ! empty( $option[ $type ] ) ) {
346
+ foreach ( $option[ $type ] as $key => $notification ) {
347
+ if ( $notification['id'] == $id ) { // phpcs:ignore WordPress.PHP.StrictComparisons
348
+ unset( $option[ $type ][ $key ] );
349
+ break;
350
+ }
351
+ }
352
+ }
353
+
354
+ update_option( $this->option_name, $option );
355
+
356
+ wp_send_json_success();
357
+ }
358
+
359
+ /**
360
+ * This generates the markup for the notifications indicator if needed.
361
+ *
362
+ * @return string
363
+ */
364
+ public function get_menu_count() {
365
+
366
+ if ( $this->get_count() > 0 ) {
367
+ return '<span class="monsterinsights-menu-notification-indicator"></span>';
368
+ }
369
+
370
+ return '';
371
+
372
+ }
373
+
374
+ /**
375
+ * Retrieve the notifications via an ajax call.
376
+ */
377
+ public function ajax_get_notifications() {
378
+
379
+ // Run a security check.
380
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
381
+
382
+ $notifications_data = array(
383
+ 'notifications' => $this->get(),
384
+ 'view_url' => $this->get_view_url(),
385
+ );
386
+
387
+ wp_send_json_success( $notifications_data );
388
+ }
389
+
390
+ /**
391
+ * Get the URL for the page where users can see/read notifications.
392
+ *
393
+ * @return string
394
+ */
395
+ public function get_view_url() {
396
+
397
+ $disabled = monsterinsights_get_option( 'dashboards_disabled', false );
398
+
399
+ $url = add_query_arg( 'page', 'monsterinsights_reports', admin_url( 'admin.php' ) );
400
+
401
+ if ( false !== $disabled ) {
402
+ $url = is_multisite() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
403
+ }
404
+
405
+ return $url;
406
+
407
+ }
408
+ }
includes/admin/pages/addons.php CHANGED
@@ -1,183 +1,183 @@
1
- <?php
2
- /**
3
- * Addons class.
4
- *
5
- * @since 6.0.0
6
- *
7
- * @package MonsterInsights
8
- * @author Chris Christoff
9
- */
10
-
11
- // Exit if accessed directly
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit;
14
- }
15
-
16
-
17
- /**
18
- * Callback to output the MonsterInsights addons page.
19
- *
20
- * @since 6.0.0
21
- */
22
- function monsterinsights_addons_page() {
23
- echo monsterinsights_ublock_notice();
24
- monsterinsights_settings_error_page( 'monsterinsights-addons' );
25
- monsterinsights_settings_inline_js();
26
- }
27
-
28
- /**
29
- * Retrieves addons from the stored transient or remote server.
30
- *
31
- * @since 6.0.0
32
- *
33
- * @return bool | array false | Array of licensed and unlicensed Addons.
34
- */
35
- function monsterinsights_get_addons() {
36
-
37
- // Get license key and type.
38
- $key = '';
39
- $type = 'lite';
40
- if ( monsterinsights_is_pro_version() ) {
41
- $key = is_network_admin() ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key();
42
- $type = is_network_admin() ? MonsterInsights()->license->get_network_license_type() : MonsterInsights()->license->get_site_license_type();
43
- }
44
-
45
- // Get addons data from transient or perform API query if no transient.
46
- if ( false === ( $addons = get_transient( '_monsterinsights_addons' ) ) ) {
47
- $addons = monsterinsights_get_addons_data( $key );
48
- }
49
-
50
- // If no Addons exist, return false
51
- if ( ! $addons ) {
52
- return false;
53
- }
54
-
55
- // Iterate through Addons, to build two arrays:
56
- // - Addons the user is licensed to use,
57
- // - Addons the user isn't licensed to use.
58
- $results = array(
59
- 'licensed' => array(),
60
- 'unlicensed'=> array(),
61
- );
62
- foreach ( (array) $addons as $i => $addon ) {
63
-
64
- // Determine whether the user is licensed to use this Addon or not.
65
- if (
66
- empty( $type ) ||
67
- ( in_array( 'Pro', $addon->categories ) && ( $type != 'pro' && $type != 'master' ) ) ||
68
- ( in_array( 'Plus', $addon->categories ) && $type != 'plus' && $type != 'pro' && $type != 'master' ) ||
69
- ( in_array( 'Basic', $addon->categories ) && ( $type != 'basic' && $type != 'plus' && $type != 'pro' && $type != 'master' ) )
70
- ) {
71
- // Unlicensed
72
- $results['unlicensed'][] = $addon;
73
- continue;
74
- }
75
-
76
- // Licensed
77
- $results['licensed'][] = $addon;
78
-
79
- }
80
-
81
- // Return Addons, split by licensed and unlicensed.
82
- return $results;
83
-
84
- }
85
-
86
- /**
87
- * Pings the remote server for addons data.
88
- *
89
- * @since 6.0.0
90
- *
91
- * @param string $key The user license key.
92
- * @return array Array of addon data otherwise.
93
- */
94
- function monsterinsights_get_addons_data( $key ) {
95
- // Get Addons
96
- // If the key is valid, we'll get personalised upgrade URLs for each Addon (if necessary) and plugin update information.
97
- if ( monsterinsights_is_pro_version() && $key ) {
98
- $addons = MonsterInsights()->license_actions->perform_remote_request( 'get-addons-data-v600', array( 'tgm-updater-key' => $key ) );
99
- } else {
100
- $addons = monsterinsights_get_all_addons_data();
101
- }
102
-
103
- // If there was an API error, set transient for only 10 minutes.
104
- if ( ! $addons ) {
105
- set_transient( '_monsterinsights_addons', false, 10 * MINUTE_IN_SECONDS );
106
- return false;
107
- }
108
-
109
- // If there was an error retrieving the addons, set the error.
110
- if ( isset( $addons->error ) ) {
111
- set_transient( '_monsterinsights_addons', false, 10 * MINUTE_IN_SECONDS );
112
- return false;
113
- }
114
-
115
- // Otherwise, our request worked. Save the data and return it.
116
- set_transient( '_monsterinsights_addons', $addons, 4 * HOUR_IN_SECONDS );
117
- return $addons;
118
-
119
- }
120
-
121
- /**
122
- * Get all addons without a license, for lite users.
123
- *
124
- * @return array|bool|mixed|object
125
- */
126
- function monsterinsights_get_all_addons_data() {
127
- // Build the body of the request.
128
- $body = array(
129
- 'tgm-updater-action' => 'get-all-addons-data',
130
- 'tgm-updater-key' => '',
131
- 'tgm-updater-wp-version' => get_bloginfo( 'version' ),
132
- 'tgm-updater-referer' => site_url(),
133
- 'tgm-updater-mi-version' => MONSTERINSIGHTS_VERSION,
134
- 'tgm-updater-is-pro' => false,
135
- );
136
- $body = http_build_query( $body, '', '&' );
137
-
138
- // Build the headers of the request.
139
- $headers = array(
140
- 'Content-Type' => 'application/x-www-form-urlencoded',
141
- 'Content-Length' => strlen( $body ),
142
- );
143
-
144
- // Setup variable for wp_remote_post.
145
- $post = array(
146
- 'headers' => $headers,
147
- 'body' => $body,
148
- );
149
-
150
- // Perform the query and retrieve the response.
151
- $response = wp_remote_post( monsterinsights_get_licensing_url(), $post );
152
- $response_code = wp_remote_retrieve_response_code( $response );
153
- $response_body = wp_remote_retrieve_body( $response );
154
-
155
- // Bail out early if there are any errors.
156
- if ( 200 !== $response_code || is_wp_error( $response_body ) ) {
157
- return false;
158
- }
159
-
160
- // Return the json decoded content.
161
- return json_decode( $response_body );
162
- }
163
-
164
- /**
165
- * Retrieve the plugin basename from the plugin slug.
166
- *
167
- * @since 6.0.0
168
- *
169
- * @param string $slug The plugin slug.
170
- * @return string The plugin basename if found, else the plugin slug.
171
- */
172
- function monsterinsights_get_plugin_basename_from_slug( $slug ) {
173
- $keys = array_keys( get_plugins() );
174
-
175
- foreach ( $keys as $key ) {
176
- if ( preg_match( '|^' . $slug . '|', $key ) ) {
177
- return $key;
178
- }
179
- }
180
-
181
- return $slug;
182
-
183
- }
1
+ <?php
2
+ /**
3
+ * Addons class.
4
+ *
5
+ * @since 6.0.0
6
+ *
7
+ * @package MonsterInsights
8
+ * @author Chris Christoff
9
+ */
10
+
11
+ // Exit if accessed directly
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+
16
+
17
+ /**
18
+ * Callback to output the MonsterInsights addons page.
19
+ *
20
+ * @since 6.0.0
21
+ */
22
+ function monsterinsights_addons_page() {
23
+ echo monsterinsights_ublock_notice();
24
+ monsterinsights_settings_error_page( 'monsterinsights-addons' );
25
+ monsterinsights_settings_inline_js();
26
+ }
27
+
28
+ /**
29
+ * Retrieves addons from the stored transient or remote server.
30
+ *
31
+ * @since 6.0.0
32
+ *
33
+ * @return bool | array false | Array of licensed and unlicensed Addons.
34
+ */
35
+ function monsterinsights_get_addons() {
36
+
37
+ // Get license key and type.
38
+ $key = '';
39
+ $type = 'lite';
40
+ if ( monsterinsights_is_pro_version() ) {
41
+ $key = is_network_admin() ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key();
42
+ $type = is_network_admin() ? MonsterInsights()->license->get_network_license_type() : MonsterInsights()->license->get_site_license_type();
43
+ }
44
+
45
+ // Get addons data from transient or perform API query if no transient.
46
+ if ( false === ( $addons = get_transient( '_monsterinsights_addons' ) ) ) {
47
+ $addons = monsterinsights_get_addons_data( $key );
48
+ }
49
+
50
+ // If no Addons exist, return false
51
+ if ( ! $addons ) {
52
+ return false;
53
+ }
54
+
55
+ // Iterate through Addons, to build two arrays:
56
+ // - Addons the user is licensed to use,
57
+ // - Addons the user isn't licensed to use.
58
+ $results = array(
59
+ 'licensed' => array(),
60
+ 'unlicensed'=> array(),
61
+ );
62
+ foreach ( (array) $addons as $i => $addon ) {
63
+
64
+ // Determine whether the user is licensed to use this Addon or not.
65
+ if (
66
+ empty( $type ) ||
67
+ ( in_array( 'Pro', $addon->categories ) && ( $type != 'pro' && $type != 'master' ) ) ||
68
+ ( in_array( 'Plus', $addon->categories ) && $type != 'plus' && $type != 'pro' && $type != 'master' ) ||
69
+ ( in_array( 'Basic', $addon->categories ) && ( $type != 'basic' && $type != 'plus' && $type != 'pro' && $type != 'master' ) )
70
+ ) {
71
+ // Unlicensed
72
+ $results['unlicensed'][] = $addon;
73
+ continue;
74
+ }
75
+
76
+ // Licensed
77
+ $results['licensed'][] = $addon;
78
+
79
+ }
80
+
81
+ // Return Addons, split by licensed and unlicensed.
82
+ return $results;
83
+
84
+ }
85
+
86
+ /**
87
+ * Pings the remote server for addons data.
88
+ *
89
+ * @since 6.0.0
90
+ *
91
+ * @param string $key The user license key.
92
+ * @return array Array of addon data otherwise.
93
+ */
94
+ function monsterinsights_get_addons_data( $key ) {
95
+ // Get Addons
96
+ // If the key is valid, we'll get personalised upgrade URLs for each Addon (if necessary) and plugin update information.
97
+ if ( monsterinsights_is_pro_version() && $key ) {
98
+ $addons = MonsterInsights()->license_actions->perform_remote_request( 'get-addons-data-v600', array( 'tgm-updater-key' => $key ) );
99
+ } else {
100
+ $addons = monsterinsights_get_all_addons_data();
101
+ }
102
+
103
+ // If there was an API error, set transient for only 10 minutes.
104
+ if ( ! $addons ) {
105
+ set_transient( '_monsterinsights_addons', false, 10 * MINUTE_IN_SECONDS );
106
+ return false;
107
+ }
108
+
109
+ // If there was an error retrieving the addons, set the error.
110
+ if ( isset( $addons->error ) ) {
111
+ set_transient( '_monsterinsights_addons', false, 10 * MINUTE_IN_SECONDS );
112
+ return false;
113
+ }
114
+
115
+ // Otherwise, our request worked. Save the data and return it.
116
+ set_transient( '_monsterinsights_addons', $addons, 4 * HOUR_IN_SECONDS );
117
+ return $addons;
118
+
119
+ }
120
+
121
+ /**
122
+ * Get all addons without a license, for lite users.
123
+ *
124
+ * @return array|bool|mixed|object
125
+ */
126
+ function monsterinsights_get_all_addons_data() {
127
+ // Build the body of the request.
128
+ $body = array(
129
+ 'tgm-updater-action' => 'get-all-addons-data',
130
+ 'tgm-updater-key' => '',
131
+ 'tgm-updater-wp-version' => get_bloginfo( 'version' ),
132
+ 'tgm-updater-referer' => site_url(),
133
+ 'tgm-updater-mi-version' => MONSTERINSIGHTS_VERSION,
134
+ 'tgm-updater-is-pro' => false,
135
+ );
136
+ $body = http_build_query( $body, '', '&' );
137
+
138
+ // Build the headers of the request.
139
+ $headers = array(
140
+ 'Content-Type' => 'application/x-www-form-urlencoded',
141
+ 'Content-Length' => strlen( $body ),
142
+ );
143
+
144
+ // Setup variable for wp_remote_post.
145
+ $post = array(
146
+ 'headers' => $headers,
147
+ 'body' => $body,
148
+ );
149
+
150
+ // Perform the query and retrieve the response.
151
+ $response = wp_remote_post( monsterinsights_get_licensing_url(), $post );
152
+ $response_code = wp_remote_retrieve_response_code( $response );
153
+ $response_body = wp_remote_retrieve_body( $response );
154
+
155
+ // Bail out early if there are any errors.
156
+ if ( 200 !== $response_code || is_wp_error( $response_body ) ) {
157
+ return false;
158
+ }
159
+
160
+ // Return the json decoded content.
161
+ return json_decode( $response_body );
162
+ }
163
+
164
+ /**
165
+ * Retrieve the plugin basename from the plugin slug.
166
+ *
167
+ * @since 6.0.0
168
+ *
169
+ * @param string $slug The plugin slug.
170
+ * @return string The plugin basename if found, else the plugin slug.
171
+ */
172
+ function monsterinsights_get_plugin_basename_from_slug( $slug ) {
173
+ $keys = array_keys( get_plugins() );
174
+
175
+ foreach ( $keys as $key ) {
176
+ if ( preg_match( '|^' . $slug . '|', $key ) ) {
177
+ return $key;
178
+ }
179
+ }
180
+
181
+ return $slug;
182
+
183
+ }
includes/admin/pages/reports.php CHANGED
@@ -1,65 +1,65 @@
1
- <?php
2
- /**
3
- * Reports class.
4
- *
5
- * @since 6.0.0
6
- *
7
- * @package MonsterInsights
8
- * @subpackage Reports
9
- * @author Chris Christoff
10
- */
11
-
12
- // Exit if accessed directly
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
-
17
- function monsterinsights_reports_page_body_class( $classes ) {
18
- if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] === 'monsterinsights_reports' ) {
19
- $classes .= ' monsterinsights-reporting-page ';
20
- }
21
- return $classes;
22
- }
23
- add_filter( 'admin_body_class', 'monsterinsights_reports_page_body_class' );
24
-
25
- /**
26
- * Callback for getting all of the reports tabs for MonsterInsights.
27
- *
28
- * @since 6.0.0
29
- * @access public
30
- *
31
- * @return array Array of tab information.
32
- */
33
- function monsterinsights_get_reports() {
34
- /**
35
- * Developer Alert:
36
- *
37
- * Per the README, this is considered an internal hook and should
38
- * not be used by other developers. This hook's behavior may be modified
39
- * or the hook may be removed at any time, without warning.
40
- */
41
- $reports = apply_filters( 'monsterinsights_get_reports', array() );
42
- return $reports;
43
- }
44
-
45
- /**
46
- * Callback to output the MonsterInsights reports page.
47
- *
48
- * @since 6.0.0
49
- * @access public
50
- *
51
- * @return void
52
- */
53
- function monsterinsights_reports_page() {
54
- /**
55
- * Developer Alert:
56
- *
57
- * Per the README, this is considered an internal hook and should
58
- * not be used by other developers. This hook's behavior may be modified
59
- * or the hook may be removed at any time, without warning.
60
- */
61
- do_action( 'monsterinsights_head' );
62
- echo monsterinsights_ublock_notice();
63
- monsterinsights_settings_error_page( 'monsterinsights-reports');
64
- monsterinsights_settings_inline_js();
65
- }
1
+ <?php
2
+ /**
3
+ * Reports class.
4
+ *
5
+ * @since 6.0.0
6
+ *
7
+ * @package MonsterInsights
8
+ * @subpackage Reports
9
+ * @author Chris Christoff
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ function monsterinsights_reports_page_body_class( $classes ) {
18
+ if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] === 'monsterinsights_reports' ) {
19
+ $classes .= ' monsterinsights-reporting-page ';
20
+ }
21
+ return $classes;
22
+ }
23
+ add_filter( 'admin_body_class', 'monsterinsights_reports_page_body_class' );
24
+
25
+ /**
26
+ * Callback for getting all of the reports tabs for MonsterInsights.
27
+ *
28
+ * @since 6.0.0
29
+ * @access public
30
+ *
31
+ * @return array Array of tab information.
32
+ */
33
+ function monsterinsights_get_reports() {
34
+ /**
35
+ * Developer Alert:
36
+ *
37
+ * Per the README, this is considered an internal hook and should
38
+ * not be used by other developers. This hook's behavior may be modified
39
+ * or the hook may be removed at any time, without warning.
40
+ */
41
+ $reports = apply_filters( 'monsterinsights_get_reports', array() );
42
+ return $reports;
43
+ }
44
+
45
+ /**
46
+ * Callback to output the MonsterInsights reports page.
47
+ *
48
+ * @since 6.0.0
49
+ * @access public
50
+ *
51
+ * @return void
52
+ */
53
+ function monsterinsights_reports_page() {
54
+ /**
55
+ * Developer Alert:
56
+ *
57
+ * Per the README, this is considered an internal hook and should
58
+ * not be used by other developers. This hook's behavior may be modified
59
+ * or the hook may be removed at any time, without warning.
60
+ */
61
+ do_action( 'monsterinsights_head' );
62
+ echo monsterinsights_ublock_notice();
63
+ monsterinsights_settings_error_page( 'monsterinsights-reports');
64
+ monsterinsights_settings_inline_js();
65
+ }
includes/admin/pages/settings.php CHANGED
@@ -1,124 +1,129 @@
1
- <?php
2
- // Exit if accessed directly
3
- if ( ! defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- /**
8
- * Callback to output the MonsterInsights settings page.
9
- *
10
- * @since 7.4.0
11
- * @access public
12
- *
13
- * @return void
14
- */
15
- function monsterinsights_settings_page() {
16
- echo monsterinsights_ublock_notice();
17
- monsterinsights_settings_error_page( 'monsterinsights-vue-site-settings' );
18
- monsterinsights_settings_inline_js();
19
- }
20
-
21
- function monsterinsights_network_page() {
22
- echo monsterinsights_ublock_notice();
23
- monsterinsights_settings_error_page( 'monsterinsights-vue-network-settings' );
24
- monsterinsights_settings_inline_js();
25
- }
26
-
27
- /**
28
- * Attempt to catch the js error preventing the Vue app from loading and displaying that message for better support.
29
- */
30
- function monsterinsights_settings_inline_js() {
31
- ?>
32
- <script type="text/javascript">
33
- var ua = window.navigator.userAgent;
34
- var msie = ua.indexOf( 'MSIE ' );
35
- if ( msie > 0 ) {
36
- var browser_error = document.getElementById( 'monsterinsights-error-browser' );
37
- var js_error = document.getElementById( 'monsterinsights-error-js' );
38
- js_error.style.display = 'none';
39
- browser_error.style.display = 'block';
40
- } else {
41
- window.onerror = function myErrorHandler( errorMsg, url, lineNumber ) {
42
- /* Don't try to put error in container that no longer exists post-vue loading */
43
- var message_container = document.getElementById( 'monsterinsights-nojs-error-message' );
44
- if ( ! message_container ) {
45
- return false;
46
- }
47
- var message = document.getElementById( 'monsterinsights-alert-message' );
48
- message.innerHTML = errorMsg;
49
- message_container.style.display = 'block';
50
- return false;
51
- }
52
- }
53
- </script>
54
- <?php
55
- }
56
-
57
-
58
- /**
59
- * Error page HTML
60
- **/
61
- function monsterinsights_settings_error_page( $id = 'monsterinsights-vue-site-settings', $footer = '', $margin = '82px 0' ) {
62
- $inline_logo_image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAd4AAABaCAYAAAAWyDe5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyhpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ1IDc5LjE2MzQ5OSwgMjAxOC8wOC8xMy0xNjo0MDoyMiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTkgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MDJFRDBENkZFQ0Y2MTFFOEE5OUNCODFENzIyODU1MzEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MDJFRDBENzBFQ0Y2MTFFOEE5OUNCODFENzIyODU1MzEiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDowMkVEMEQ2REVDRjYxMUU4QTk5Q0I4MUQ3MjI4NTUzMSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDowMkVEMEQ2RUVDRjYxMUU4QTk5Q0I4MUQ3MjI4NTUzMSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pv4HgdQAAD64SURBVHja7F0HfBzF1X/XT3fq3XKTewHjgmkB0x0IBkIoAZIQEggJnSTABwQ+AqmQEOoHSSAJIQQIxbRgIDamYweDwQbbuNuyZcuSrH69fu+/OyedTrd7RSdbQvP3b3yn252Z3dnZ+c97894bA+0HXLNgiZE/lnJ68L5F858bwHrs/HEvp+1czx00SBCNRklCQkJCYnjCsJ+I91L++KP480FO1zIx+nNcxyT+eJbTTE4uTlO5jl2SeCUkJCQk9ieM+4F0i/njl3E/XcFpGf8+IYd1nMsfnwjSBfI53SEft4SEhITEsCNexnWcyvGluDwv9tscTh8zYZ7aT8K1cIJq+V8gWwPL83lOc+zwt/nYQfKRS0hISEgMG+Jl4hvBHz9WRNAiG42bWkSTDyolg3oVkIT/zef8LydDFmWDzN/AV/xtthhp1IRipR6TSSkO//1GPnIJCQkJieEk8ULadUISLa92UDQSZanXRgcdXkl2R7dk+gtOTzKRWjMg3Wn8sYLT0fjbkW+hMZNKyJ5npgjXUVBii526gM89VD52CQkJCYkvPfEy4Tn54wcxaddiNTEpqsdsdhMdeEg5lVR2q57P4/Qa5ylMo9zD+ONdTuPwd2mlg0aOK4pJuRQORwi2TCZztxB9lXzsEhISEhLDQeK9gJNCpCUVKsFGwj3WvUYmyokHFFNNbX7sp+M5LWFiLdIh3SP4401O5ZCiq0YVUFmVo/s4CBd1wIq4oKhb6v0m56uUj15CQkJCYkgSbwbrsZfhP6iUbXazkEZ7u9WAPEeNL6Cxk7u5Fmrh17kOR5J6lWOcHAajgQm7iAp7VMrd0m6SO4UK+/s5vjcJCQkJCYmBJ14mprH88bxQI+udB1chxaK4sMQeR4zJ/VmrRjmodmpx7M/DSV3zNcaVV8sf/0ZxIN2RtYXKum4iwsEe4oXk6yjoXjY+O417m02qdbSEhISEhMSgkXiP5HQGp/cFCWvhGzGJNk7lS1HmxUgkeYbKmjwaNaF7iffrnH4lCNEhSLcS5Y0YU0B5TkvSMoLBcK+/bXmm2Ne5XM5oHdI9E/eE6xbRryQkJCQkJAYF8R4lPmeR6od7gsZ5IGeyOyzKWm4vqTSkHcWpZqxTsX4WuJHLn09qCMgD8UPFiHxyFmgbP4eCvVkdVtRxOD0J4Zo4/Zq/LuSEisHoc2U3kZCQkJAYLMR7cNx3+NEuZuK6jZM5jswg4h6C78lIMpEcE1E7tTDmagTGRlznS/AH1nOLyvSF0YC/t8QL1yJbj9vSvATShQT8H04/SyjmENlNJCQkJCT2O/FCOuyRPB1kyzPHyvs5p//y8Vi4RnwqjGvviSIVR7z6cYuNRoMSZENA0T0jOEZFTb5uvmAgnDQmst1u7kWoWDvmdDF//ZyTIrFjvdjac95M2U0kJCQkJAaDxAu/WUUPbHNYaMah5UyGjnhJ+FMmtEdJXZ9V5NU40utFvBF9oZclXhONGt/j0gu3IRCyHvy+UPIb7vHnHc/XByOrjzj9hVMRrhHuSEjwLRaYIbuJhISEhESuYO5H3hHdZGYwUDhMSghIrMluXttGQX8YDPe92DkWi4kMGmQZDESY6PTnANVjHNSw00V5LFkns2BOl3iptxD8bDe5c7mVI/MVyb2txRu/Fl0ju4mEhISExGAg3m5/H0iKAV9EiUZVUGyhmUdUUPNuL+3c0tkdJMNiM2kWhLypiBcS7rgpxUzSqbfUgzWz1tpxpLeBlaK2RrSrolJ1vRjXG2DSNhq7rydPdhMJCQkJicFAvN0ipYEl3oA/QnkRo0KQSPDFrRiRR817vLRraxeZzdrECnUzrJvjwjomZ/oyK3W0hlJemMcV1DyGdV9symA2m6i43M6Em6e4OcXgdgVkr5CQkJCQGJTE29ktRSoRokzk9zL5OnskW6hrq0Y6qLLGQV5XiKXVvhJnDD5PhJyFvaXiUChCHrdflUBNRrKYTUo9eghzHp9Xm3gh4daMRcCNvhbWcDfyuoPd3xPvU0JCQkJCYn8Sb32PxKqqdUG89jxTbJs/6pGIiRwFalVQK/s5JVozQ2K2BSExR2nntlZq3OWmUAAqZjMZRYGQVsOREFntRqocUUgFRX21wF0d/sR1XAVWm0khW5td+5Y9TLoxS+hIT7jJetlNJCQkJCRyhWz2vYU181c5nUIiCAWsgLFOCtjyjExwppTlQPIN+qMs1TKZQtUcjlJbSxftqe8ks9GWMn+U/5ksEaqdWEEmocaGtNrZ7lNnFPyb2WoiKyeQbWLgjj6SMtff0ujuJl6fN0wBr6LWbuH0JKclnN66b9F8V38bPZmbk4SEhISEJN4Y0cKP5zhBtkgTE89BYIya2h53n4JiM5kt6XM6iGjdql3U3OAhh70goxuIRMM0bmoZE6xZCZiB7QChljZkOKVob/F2W0LD+rpjry/ZadBDL+e0mNQNGj5lIo4MJeLFevwRx5yKXZ0u5VTCaROne5e/88rOXNbDdeBBXs4J2zaiYZ/iOl6Qr5zEvsDJj+zB1qJnkeoyiRCzj71+SXV0GN0/AhrdTWpcekgy73G6mtvgM9k7hgbxPigG0J5MRhg62amk3E7OQqsSAxkqZK9bjRQF46rCUnPa5Lf6ox3UuLuDTEYzFTiLEyTRkKJejkQiipQbIw+jwURmE0uyRhP/GqaJB1Sm9O3VgscVUFXUgnSLSuxKHZCgY0nDSno2E++qoUS8Xzn2NGgqXqbei+W7OB3ExNiaI9KFPv8DUneXiseVXMeD8rWTGGDSuZlEbPc4/B+TzlXD5P5hwPJfjE8Jhzo4HcztsGUQXCMG65+Q6nIKdelSTjfytbUNh2eUTgCNhtiXMZOK6MBDK2ju0SNo0owSKh+RpxhTwfPG7jAqZGu1GRVicXWE0rqA7ZubFdJVSJYJNhRmkmOy9fi6qMPVQl2edvL63RQxBMlqNzDRWyi/yEKOQiNZHGGKmnxKvt07tJ+Xq9NPTQ0uatrt6ibYGAL+EHXxcRCuw2mh8kqnoprGmjBcjKpHF7BEXUpjJ5dQRY0zFr4yhqYh+MzvpL4WaiM53ZbDOs5PQrpK3UzKDkkNEgM4oFeTGj0vEVfysTnDpBnOT0K6APZbvXmQXOMvOf2B1ABF2L3uh5wW8zMyD4cHlM5N7o19gYuQnhQLNa9imRw1MRlGld2HDDrU7mfS27K+N3e5PCoJ2+wWqq4qpaJiJznz87KWZr2eILm7Ar2kW5QVixsNybaswqm6O+lUASK22vKU830eV5+2GUI4UOP3HzAp/oIl0n7dE5eBVrxe4zC2j5zK6RNJERIDBGwjqhVh55hh0veOStE++3tyVKAxRmBDmlM5vSiJN45c4GJjMKVBgAaVhFOhbvPe3pvVM/IL86hmVLlCuLlAIEkEK0i5MeJF0I9MAHelmNrmvkXzv0xOvzARx7rvr/pZzomkH2YzQhIDAp70gHAQWxwGCmt5EjUcrfiKdY4VDZM20Bt8TYPg+jD51tpWbsZAEi+TPrR7YzhteP2S6tb91QDpqJr3dJNOWPs9xrKllo+uZsG72nt6g9lE4yfV0LQDx+aMdJUbNBnT+i1t4u1pg6Yv4Qt7FQ/etn6WcZ2kwP1CulDtbyY19jg2/PiYfxspW2ZYYqXOsRWD4Pqc+3piwIRr4vQnUt1Dl3HazX9fPpiJt1vijSQhXvyG9dz2vUHqaFE/Pa4wpbIfggo4Fugiz2GjA2fWUllFYe6fcL6Vpe+e24SaOV9nD98MJN69X8IXtpLTBf0Y/DFb/aoc9/Y56ULKe0XM5GPAeuY/ZOsMSzzOKZkBFTQhvx2mbXIjpx/F/Q0B40Em36MGPfEmbloP0u1sC/WKnwzCRSANkLEe+Xo9qpGTw2mnaTPGktVmGZgbNBkUP2OEhkQqr3J2+/1mg8iXW+IFfiLWabPBtXLM2y84k1NFkt+P52c5XjbP8MLrl1TDCOV4Ui2FY9jA6SQ+tm6YNssVGr9ftD8uJuUa732L5u+9ZsES+AmZQqHey3MeV0STXBGZStn8IC85yWG/XIvVTJOnj+olkXaDh/6Rk/KparyTnMVMykygwUiEvL4wdj6igCdMXib9riY/dTUG4kM89i3KYFB2H0oFH0vhsHqGVAySRnjJPhJvz5r0l5V4p3P6GqdXM5S6sIvTt+Swt18wJsWxrbKJhh357uCPE1miw7p2Hv+9Z5g3yQiN38cNSuIVaOZUHQpEEshT305GCQOpQbyRsEFZ07VYel/CqCn5NOvYKqoZ7SRLEkIGvXoCIerwBandF6AIwkjydezd4qHGdS5q2+nLujE62/2KKxTWquGCVFzWNyRlnNS/90vcSa/NlHgZ8JG0kISExGAiYLiJdMiW0JbLBj3xBuOCSKQTA0LvHIczj+z2OMKdWkhHnV5DZSX2lK3kZEkZqSrfTk1uH7WSn6qm5SvJ1RSgbcvbqHWbN+PGgD9yOCzq0XBfilvjbfoSd0aoKGcvf+eVT9OUdvNJtYiWkJCQkMgR8TZymhEv4cKfFz66UR2hV8ulKBKBxKt+t9iMNP/CWqodV5jx1MPE5DiiII8KbRba2eGmEEuq+ZVWmvH1KmrZ6qGNS1soIKJppQOol+HzC9ItKLQlnUjEWW43fcn7BqTe76R5LtZJigfyYkTgjUmkhrlEV4GRwBaeHDQOcL0Fot5CUS+kh01cb1cOysYsE6rgUlKVOX7RrxoGoysQXy+CU1SLtkA71PN1tgxwnVCV1nLKFwIAnnl4f7bDyY/sweAwTvRFPCe4pWxj6TKYg7IxJleJPmEU7dzCZXdlURYshBFIA+/OR1yGN4sycA0IcFEjrgfvG1xxwgnnwWJ1jjhnJR/356itS0XdpaItdnHZg0rbKKJwjSbVzgJqUpdIO/haA1mL2dcsWPIUf5yH7f1qp/a4wmErP68OsWnFbAaBuzrCVD7KQadePJ6c9v4HKwmEI7St1aWsA3f/5gnTukXN1LHLl5MGxhr3ti+6Xb9Oum/R/MXZlLOfQ0amWzkcoMfxIFefYmDEw9skBsd0AEk6rTCbXDY68ffFBADuMslcDeo4IQb0/VzutjQHckTNQehMfIf152OcHo4N6HwO3B1+QKqF92zqa4SITvY2p19xnrcyJBIMUN8U5SOYQTL3LQyQcPt4g9OzXMcGjXIQhew0TuWk7aOKgTL+BcAA/gCX+XCa1zsNQwCnrwvSTdb+sKh+kMv8Io3y8BxvITWQC9rxHVJjhX8edw4GjXM4Xc3pyCT3czuf/0eNQfB7/PGoRvW380B4m8bg/r+kWuRjMrQRZfC5z8Sdg754MfVEZTMneWavoW9xvlUZDtxmcb/f5TSPkrvbYEK2XPSJ57mO3SnKHEXqclHMpx6TlnM531tpXhMmFjeRGuu5JOEwwgQ+y+nXWEvmc2O+tzFDPlzbGXzsI42yj+UPreu4XTw/aNDOEpPeROD5PEJqGFCfzj0gYMpvSI3MN1bjNEwQEte/P+b0Yy67PkUboW/CaGu+eAcpyTjxhbhXtM9bXGYkE+K9nz+uQgjFKbN6PwN3Z1hZy00EdijSWt+F1XMpk+4p3xmXdB03W/hCYdrC5BtPbDC6+uK1vdS8yd1/cveFqW5Td2jKrOI0DyHiBe7iAe76FAMpBoxnMigzLeLlck8QL+DoNMsNipfsl3oSEZe7SJBuIt4QJHY0p79yGpVmvSC/m9KRULnuowTJZ2ppjInvhVxHMK6sB/jjyn50hbO5vIUpJgi/FJqPdHwr0eYYJ27kcgM6EvMWIYElTvK+x/me4HNAgtgN7KQU9aE9/pEj4sUk6pgk5z8uJn4niIF+TJrtcB3Xc2+aBIc+8XchVaYL1HGfqCeqUW6ye4J2YiLnaU9xTeeJNrSnuA6QFuIt/5jT5IRjeM5Tua5QhsT7uSBbexrtsJbTqVzH9iR1TBBl5WX5fqyGBB8jyoSyK8UYcWqGZWICvQCxstNlPUWdh4hPiUCIyPwik7JHrsVqUMi2sMSsSbpAxRgHLfjO+JySLmA3m6g6v/fzgtp4+ikVVDa+/yGCE6y6v+yqZuASoWrVw/UDoF6E6npxBqQLwLALMXoXCtLQkqC/ppEfEbeWCqllVAb13iCkpVT3tIA/3syCdElIWYnuEP11g7goBem+xOl/KP2ABiYxCL+qE4Tl+CSkS0J6/DvnO1oMyCelUd/FOVITlmuQLgmNx2sijcmgHe7hcn+YRt2niT4xIcPLRh0/JQ0vAiGtJrunMhJbuepcE44/kSbx4Tk/lIR0SdzToVk8khlp1g0cgHdWWG4n4qx+kC6ACHCzkrQPrKOXZUG6wBROfyFKz48XUHTq2MA+6YhnNZKzAARsViRdk1lbkM7Lt9D882rJbBoYY7JSh42siYTOVYF8neWpA2dEIiFq7qqj9Q3LaMXWf9O7G56idzY8SW+tf5w+2vE87Qx8QC2hjbTa8/fhEOwfHfqSFBLcITkm3flCush2VvZ1MRgkgyGFlucrWdZ7K1/3RJ17wkD4NPXP6vvkJINef6D3MjyUpL50AenwAY1jemtKZkFCB6VZT0WOulyqQWF+ln3iHjFIaxHc1Bz0Ca3BP5V7mdY1FQtiyJVENHYfjFGYyN6W5PdcjM+2hPYxCu3ehH6UeSyWLdJt4GaFlMIR6q+WdN7ZY8hmGbhwoRhVyxx9xyQjTwYOOLVC+eyLKO3p2Ervb3yanv3ot7R4zV9o5fbXaFPjCtrZuo7qW7+g3W0bqb5jDTUEPqYtvtfIH+nYxAPq55x+xqnyS0CyWk/2GrGOm4m0m5Xxi5BIc/HiXyxU1b2w/J1XPKTuo5xroENfo3P896QfJi/tdzAO/b2P1zWewYk5kCYvEdJrIt7m5EnRjulicy4enFgr/XQA+gQG/gv1iLmfEhnQpjMMUhaTnytyOKHJxeQwXfyIySwx7OGr/SwT676JG2p8m/Q3oEgHnZx8xgwuQpUIw9kz7+TDyqi81D7gT6HInnwSm1dsodrDexvf7m7fSK9+9hAtXfco1bWsoVBEXZ4qr6ygmQfPpmPmH08nnnKykg6fdyRNnDKZbD1+UDAQ+TWnOh5o7uFUNoSJ9xWdGfLZSQZoqJdO08iT7Yb3F1H6Kr1UuF3jd7w8aweg/U7XIDJIPd/QyYf1G0QTwprSdp0J0BOJgw2nbDc1xxrq/RrH9EIKwrIQ8W6hgsaWbnU6596cZOKDoA6wCQjmoL0fzPGz2zUAfeJsDclyXAqNAlSLaCsYLepZjf8rx9d7EQ1N5AnNRPyEaoXop9n0NSytnpfEMvuyFPm2i/cYBlVaVt1PYl0+XXPinnjNkShPSzNXEyN044xDK/bJUzAbDWQzm8gf6it4jZpTSLtWd1FnWyet2Poy7WjpGYPHT5pIXzl2HhPuHCoq0faOgXHUlg2baOWHK3gweY88bg+YGAYG3+GB9nIeYJ4dgp0XxgLHkeq2kYhrk7zkP9GYWaPRH9AadFLgwhTHYRkIIyhYMsLaFoYvpRrnHolwifwstiYM/q38O4yrYOiQahaIvajxAsNiFdbNU3TOHQPDIJSfqFrSkeDRT37IedrjiLpYDMpniLyYCcJ6+vWE+wBRzOTzsR59nY7EjfXh/8b93aXlAsRlwR1krkY5mBwcx3mb4s6HdfLLiYOewHxEM+PzdydcN9aAbxTEnQrtQrKFZSTuEyo+uGnczOX8J1cdH9arTIYni4lMqsENmodVYkBHnxihc+4suNkkcSmZn4JMr+Q8LXFEDVuHBaJPHCPa4xY+591ctQHXgaUSPfuDJdBwcZ2rhUoaSzq3UfreDNkABlrbxDs+O8WzQd9dmPBcfy82RigT5STDhyDZ+OGdVJelUEL7YFw8TKMMlH0651kTdz649UjxzBaIa3hBjKVp+/F2v2yI3GQRAiViNAf9EcUXF4ZVeph2ZMWAqZgjLg8ZTEYy5PWMozazMSnxwtjKMrqTXn37QfIEOpXfJk6dTGd9+zyaMFm1XMcascNiVoy18KgDXI6Xky8YVp4KSH3GjGlKvjPOO4fefG0xvfbiv8nn9cJQ4xkeWP4PxMSDQ2gIEW+HIN9kA/hcqA75ft4VAy7u83sa5SwUs/WMIIy4DtYj5UQrVs7zO0EqWmHfoDZ9OJnkxXnX6JCMT0yk/hr/DDnPj4WKUAsw9ngv4Tet9SAMxhdx+a6Ea2sXg29a0gzcvfi69KxU9/A529N8DKfpHLs0nnRF3T5MNIVk1udVExOHJzU0In9IQbgwTno+3kJd+D0HB8KPF4MmD5YY6Cfq9AlMNv8a89cVfrLQeN2gkQfHpybRTEzWUUN+P9FFhv/eKTQNfxrA919vbR3WwafGJhDCKvoxvv8XxWT42BxfC6TGHwqpNUZkGJzhkTBJ591L9lzhPtfF+bXq8iWzik6CWp0J9A3xpCvqxbjxjkg/6SMcptMK9y2a337NgiXobJbYtnixXYkAGF0Vlpp19+CdcEDu4iuENm0jz3OvU6huF0WDoXhRlAw2K5nHjSLL6TypLOkrDK1fs47+9vgfeNIQICufe84F31bUyQgIUmy3KuvDkJjbvAElJKUvCXnnWy1UU5inEPtej5VOOeM0OmzeV+jxP/+V1q5W3BHh5jGWB4qztVwrBimgfrxaY2aJ9dzYDPtyHWnx7izrPkynYy9N5joCIhBS1xM6ZWr5q+r5l53LZb+cpL57uT744B6hka8szd9i6kTPIHv+WjP6Rr739zSIfzO3yXpBMImYrUG8bSmu4/xECT9G9AN8/00axItB70weTF9LGFzDPKDD1/V0oYHpb5/w6PmlDjAm61FAskAQCEfJ9/9YjokXk5R5iQFD+O9NXBfGptc08g20nY3eMmLGwU0yMWJR1M1hETYykmDgrBfBqqTGTvl5/Q/jG2ltp/af/Z467vgzBTfX9SZdZY5toGggSMEN28hy+71U8My/yeDvUbVv27yFHrhTJd3i0hL6n1/cqpAuiHRSWSFV5edRqydAG/Z2UqPLl5R0ldmKmGBA8h1Z6KAJZQVUU1VJV990PZ244OR46eGf/djpZ59DqGVf0ji8gO9lijCA0vIf/S+X8WGW1eupuV7ROfZvnWOTsmyHl3UOv6lzrFhDeksGTFxuHmRdQEvq2Zgi39YsBnMtrEpGuvsIWuuBnYmkG0cIIGW9oBRFGfSJaiaXS/bTvettFvDBPryOF3SidOmp1gsG+Lr0tEo3CVV02sgkZBRmgyNi8ZoRkQq+uoqq2WpMGqGqW0bPgbQb2l5P7ideonBTa3oZwmFyvPEuWdesp/Yrv0+tFjM9dNe9CumWlJXSdT+/mSqZLEG25U6bsunC7i4PhSOpjcfMxt7zFaikJ5QW0K5OD33zu9+m/Px8evHp53AIhiRYaP/5EJJ6oUo9Q0N1CN9BRHWpyLG0C5TqHNukQ5JdPBmAMURVsjnfALRPpkY4DTrHfgGtCCZoQiW1mu/Hvx+ffbnG71a+zlqdfFqz6mzav46GHupz2CceFgEssNQALcMGrSAZOYaevcOg2NmI28HDbQMtkWM/EK/eM4MF/3Yh/WMtfAVfa2suiZdCcRslwGeX8lOv2xaW99+q3Fw7iopuvoJCO3aT6+GnKNygeles6mqhL1ztBL48oKCYZhWoGoGo2L7PvKeJSu/6E93H19nR1k42m42uuvE6hXRHFjkU9fIel5f2utMf78xJNlCAqnoUl2fkL6ec+XVq2dtC7y1VJsK38KC1mAfUD4bCCIJ1XL5emNHPSXIYIe1O1BkwXxigFz9V2DHfPpwFZxrvdnkaUubvYhIXtz3WtyDxPRMfRnGgIcJkar2oUEFvy6LYQhoeyLRPrEhx/HiRFGmbB3RMduEe86zY7m8gUKRDeO2DqK2D+6NSboMmfg7Q7Ghp5sqEYIKENenNQkKHAeXSxDjemaiaFeJNtRVg8vlw7rSt5jE1VHj9D+mh1u108qdL6H+2fEKPNm6lx5q2Kt+/xr/ds/1zioZ61NDLmhvps7Xq/s/fuvhCGjVmNFUX5Cmku7szM9JNJN7g5yxRX/8b2nv+1dR6xa1U+slqKrBZ6PyLvksjx4yOtfGfeGAzDaGB5B4dctTqeA8MMWOyfTWRAXmuTvdNIdXgC+vWn2ECxOlr++hS5ZaO+w7vU/oGiIWChO/C5JYH9Dc5HSGbcL/g8QzOha0A3LOwRLGbn9kNnCzZEK/iFhDwZ25QGMltZEgyFhVQ9SknUCQJn4f5t5ebd9Kt9WspGI0ovi2P+9Qlg2kzDuCZ/TxlNyMYUSlbCnoz1+zFVM3BDVup/ef3UnDjNop6vBSub6Cue/5KlZ9+RnarlS689AcsCSsXCX/fC4dQB3smhWolEbDM/Yt8LzUBf8Js1IUwToL7zS9lE355ICxes13fh8vfezyIXyZbcp8D8bHrs8iHJZw7OL0ZC2+ZCSU2Z0u8/mgk5y0we/ZszWOBQIDe6Giiuxo20odBH+2JhBUCPOs75yuqYFgkuwMhanJlZ0AYk3i9Ly/p2cA3Dr4X/sMStZ1qJ4ynuUd0G4peO1QMrYQldiYBCuB2Izfb1m5PxJ1GNKhs3WCwXPHdIXjrO+TT1yRfrOvfkGV2aM8eEr7HEvvumcEa/6QsyRdA1KtHMyVexagEO/RkClgHhyK5JV8hSfZBKBRSEvByWwM961V9daccMI3G1I6l0jwrmTgvDKGykrY5r1HUHWnrTHqOd3cjvf/GYtq57jOad/ThsZ+nU//Dje1LwGcwnZkJJLn75WuZknzxwmHdHFbj2bwMdwiL8qECrGndLZ+87kCOtf1jqa/vd7q4W8QPzgU0B0Suwy6fVvczw5ol7DLgh57N2vc3uD2PzsS4SpF4fd7Ml/Hg8wu/2Apn7p7f6tXJl818vh6uMBhNtE1I20cdp27WgU0UWvhaAuHsJgLx67vwFw6u7etp4SkrosbGRhaG1aA9EyeNp82bFI+LM/rxku1romjhgR6+s6l2WXkxMTqUhGabwkfxDG7XKtEXYA2JjjkyjeyIkISg+MmioumtlxTl4NIR5euOTG832T7CEn0GclizHy0CRHxD9AnsyZuOYdo0Qdxv5uBS9PpQQZqT8MGMiIag6cjimUHyvY6fGZYLEAXvOPHcQMjpaDV/lAnx7o7JNwgbaTSmrzUN+yK01+JX1lWNhv5rW9va2uipp55KSrrhONWv1eZQxDGj0UgHzp6puP1gK8IWT/YeG/GuRI6zTyH3eyvI2NETfMhgt1Ht9ZfShAljaW9rG63ZvpNauMsK4j1hiHXW+9Ig3ntyVJfejC7VjE2rH7sHY6MyIcH96c8ixeI5I7zct0g/rvMRGsTrzgHx6i0VIPrV3yVNDigBw2UOEvDvhBQ7SRDwBWJQ18KROSJePZuOKdR3k46hhi6Nd6GkH88MRPKCSNAMwDMAxpEIp3mxzuTpiIzXeFUJNsOpVGdI8Y9t6MrM6t7194UU9fUmybq6OrriiiuotbW3m1QwGCS/v/e5Zqs6XlfXjCCH00lOq5lc/iAFw9mrvXu5EhUV0HvHzaLNU0aT5ZCDKO+0E6jknlvJPLFWUYVXlJXS6NrxVDupO47AgUNJXciDLdQqesEMVmpFNMpmPqVzTHN/XLF3bJXG4dYh0s4NnJ7jdKaYQWsZYlVr/L5Xp/iJaV4D6uzUODyUVNxfBhKOcIL/7l84HUP6u0WNyFG1elorvbjrziHSrFqbTYxFPO0cPTc3NBic4FKEpcUtGqdWZbo+EFWJNzMDTW+bGm0M6makdBFY/gm1XX8HdT30T3L/4wW67LLL6JxzzqENGzb0IV2Pp+8Shcmktqdw61Ek3i5//9zA4iXejRs3UmvQT9ZzF1DxLVdR/g/OI1NN78hlqLNmdDdvwChi7BAbB+7dB9Juqhn38TrH5ulIvNuH2qDLBAj3g88yHOTWZ9l2idAKXjGdJzjS3Wj/EfHfSNtQLT9H1WzSOXa5COrRDf67RKha/zBEmlHrHUG/PmoAnhlsov6pcdiRFvFes2AJZs1w+lbEvVAoM4mxq6FHEt3d6VFiIKcDgyNPcdMJrFxDvnc+pNUrPuqlSlakaZZyk5EuYDSp43FspyETS6vuYE9+dyRAr7evoydbPqIPXdt5VpFO1CphWBWJ0KpVq8hqtdKMGTM0z4dqO2Gno6oh9t7DIjdZqDYssj+dw3pW6hw7hwf+2RrS7u06+VbQ0ITWDFwrlN5GHSn5SLHHbjpYpTO4nyUpcL/CmGGfyBQI0hHQIaenmGgRnWkxp49IjevwK9p3e+4OFPECt4jdhPbVe+xOWRmTLtYa4PBdaTYbFdLFDkWZwN0UoJA/QmabURkd6js85GUCrMq36675mseOpMDnPdLt3IIy+qBL1aqBgLGmGwppLw3GSs5zOLrl9YCIv1wfaKebdr5EraGe5bE5ztH085ELyGzQno/E4jRv3ryZOjs7adasWQr5al4Dn24292pm81B626GC5IEba4/Yuegk8TN2BDonlwEzuKw6nWD7aLM3+TgMfLAtIGZaMCyBf+xhOsW+PxjakK8bftzYZBxrH9hhZRHfr1fj3KtJO+B+vUbbuTgfNnOfo5FvER+HVfUHYqBGp1/G+RLXhhFl6wKNMu5GHckMpsSuQYhNjm0aazg9yOc9IrlSGzzQQxV5iSBUxAZ/G5suaJwL1aXWcsvuHElobq4H2pav65w2loaexi4GCA8/1TgG46iP+P4fF5oFqEU3cpt8kfAcsEaMHcqmi7FlIZ+zW+OZzeKPS7XeY3MK0sXDRtzDyvJqJ3ndQQp1BXqFjUwH0UiU2rd7qHxKj1YEBk5Q+8LSGRGkkvFv3mnH9yLe68fNoBWr3qQOn1dRL6eC3WhSHCcRnxkIspQamzL8sfHdXqQLfOLeSa+2r6HTSw7SkXiNyn68kHZBqAcddJD+vUfV/XvTmAUNZvKF2uRkHmARFs3Ifw+UocVTOhIs1AaZWNau5+v8dBCQ7gFC8o6tk34PxMe/v82f2EoMLgl+QViQTGfpFLdM59hzOsSLPvcjkWJoRFSshDbCFm/3a0wOsZa4ivO8LCRsDAIVYqJ0OPVeB36Yz9vNZS+SFKs5KC+LazNMtpr5d8T5XSsmRhi0qsVkV29yuTyHl3ZPCuIdylgsJp1aYWRnJb57/DweYmK9QnxXJv9x7xh2KbuPf/9QaAuaRPnF4hzYamhFK1xm1iFdzGJhrTWyrMpBJRV53cEzAgF96yoQc9MuD7U1+8gPv1/mnXUr99LYQ0tpypFlVDpalUDh0gN/WsRKRjQpGD9hTRTkBiI2jB9DhpJCijSylBsMkZ0J9KHq6XT5tk90rUmAKouNZtjzaVU4SB3tHd31xfCZJ3ms+zXehhTEa6CtW7dSe3s7zZw5k+x2fYNb+C93dfayWdkzVHuu1gbqOcRDpG4UnYsYv78ZJM32Q+prnIS12gUipQv0Gz1DN0iYN1P6xi5Y8kC0sYPjnm8DEya28dMK1mEXA046+KaQ7iWSDK9J+gQmMd/KsJw60t+xJ1Op9x0mEkx+z/+yNTjfm5fvDf39Jxlkw9r2q5wX/fjoJBNbg5h0Hp7h5Tyqt8aLme/cwhIblVaqRGkyq2IpdiRKhZrafJo6u0zZh7eiJo/83jCtXdJIz9+2jpb+cQt5O3okVlg8w+gKKujNLV20vrmDvmhSU+NF51PEH6Co16tEiRptzaNHJxxCRxeUa9Z9XGEF/W38XBplUu1Bmvc0Kp/euPVdhym54OltbqbmnXXKGm4yNLv99PHKlWQymXTXdmPwhyLU2NCLa2U0H21i36ujDsoEkBz+meKcyD66rdE5KucGvb2dRdv9KsMy5zDRJkoAN1JurMFrZI/WRK7UtdeL8JO5xA9IXc5JF4Nlv/F03udfCck0ExyX4/cY6un3jBrSLmbil+Q5LVRZ06MeNlvU01OFjcR58PUFUReV2mj0xEKadWQVjZ9WTFabibZ93EbP376O9m5P7WYZLiuhju+f2+u3crOV7hwzg56aeBhdXT2RziwdSWdzuoa/Pz3pMPrN6AOplM+ZIIi3btt2ijBpe+P21z0xP/lWoQc0m2jTJx/Sx/95merWriaf202GaISqPv0HTfvX+TT2kZPomPp/0bRqB0XM+lpjqJhR5/bN3VblO/eB1JgtQvuoLG8K8sVa8u/7UTfUt98S7jGpJMhkSGWsouf2lCzvlhy0J9ZM/5HGeWi3lzIoF7NfT0L7w7r8XOr/LjDv6Bzr1Cm/v6Svlz9VpCGtIBGuFPn0fKCTDXLbctAnHuAB/Nks7rM5hWSI/oBQlNdxatQ5FfYGPxPSe6bQI79Uba01fu5MQ+pF3ziHMttNKqZc3ZyDZ4axSdlv2ZiEdCHePgSvmamzS8lo7ll8NZkF8aYRvSoxwAZUx+Uj8mjGYRVUUmFXJN7X7t5E7Q2pA6L458ygzu+eQ4kLwbU2B51fNpquHzGZruV0Hn8fY+0JRDJdECPWeDesW99rrfWoehPNabdzA6hlFphs9NPqE+iseWfS2OkHkdlsoV2bN9Anbywiy79/SRWfPU0mf6eyaFsdaqTDNv6Ndu3aTltbXeQJJm+PrkBIqXPNqm7vkJyphfqBDzUGh89yKLnipdyqQXab08gPo6kfU+bRcrBGeZSQ/lLh5Qx/j+FtjcEBvyULZPAXyj6QR0TM0q9Ks90xs4SKF3G207GAfEnkSSwHEs98ym5ZBNeMfUnv0rlOnLNY4/Br/ex+y3T6TSpJTks1/moaGpagBkks0+gTwX70iV+mILzPNYgIef+TBkGFOcFNCBHVELTlSlJtL+4Q9eK3Wj7nt6Rvs6LlF75ehygXp7q8LPPF7g1jMGwp0tn3ORw3HmAt/eN+9EuMDceJqFdJTdQRuHtM7ZRiZYN7i6XnFLMgXq83nHXtkIInzSihqlFO8rtDtPShLWlZSXuPOpRar7+MwpXladdVXlNNI6tU750VH/TYIDTWbaO2XfX0regklpAvpkfHX0D/nPB9OqFoCllsNho5aSrNOfEUmnb4PCqvqqSJbX3b2xT0UMmmJQrpgnx3dnj6BOaA+ry9rU0h/TQH9X2BnyaZ8d3Ig2Fnjuu5PGFwQeNcnmyg1xicETULhjsP67zAsXKXcoKh0Dcy2KwBrlCJUuQXlELVLcq/MEHFBinhfD7WluR8WAceSqpVeLpqLhAHdog6mPP/bxrSe3x9AU4YKGeLAV5rgIOF82U65UBihWHY3SkkungJCBL3BM77PU6pJk1XJrk2WJU+159OxwMbJl03Jjl0Jx9bkyL7n5IM7GuFZKdXZ724n2hCn7gA1sJJzsdgdCzUjhlMyoJiYnkI57+VU1SPOEm1Tk/0s/wfPrY5g7YEAf+X04OcbuN0E6f7xW+x97g4U+0QAoSQamSYOA79go+lEgB+TmoI017dlTKIC851YDI0TYxR71NydTna7ociNnPsmo8XE5BM9smGoIM18xNF31QF0QRpF424w5ZnLjjo8ApFwPR5I+R1CaMqf5jqNqpteehxI9KKSgkhU8tjaOsX7bS3wUuHfXMUzTipOq27MITCZF/2EeW99yFZ6pJ4V3BlwdrR5J13GPkOP5hef/V1WvjEv3gSYaU7H7qX4A20+u3FZLZYaOaxJylEqweLp4WmPJvc1qRt8sm064geYQSuUZX5dip32JT15C2tXfTSMwtp0cIXYyqwkRiQEqyc9ykQUeuIY05Fp0M0HKgHFvI1LR2IurgeGO6g8WDd9wTXszzLcsyCSLA+UBH3YkCN+3F/dkbiso8WZUPF+nIahBHLNwZkL4j/FaGiTZXHIMgM1ntY54OVuDlOOtgtNA+farkbZXmPWC+Kn7EGhaV6uvnxksCydoZof4cgDKgtt3Nax+Vtz+K6YESHqEiwmF7BZSzJ1T2f/MieU0TZ6Hsv8aD3fJr5IF2cKu4V9/Q8DHPSzHug6BM+UeeONPJAYjxE1FdLqnFcgZC2MNjiOcFn/iMuryvDNoDEeqZ4Xos5f86t/LkOTJS0fLwP5DrX6uQdJ1S/uN8lQhpNp0600bdFe4EYn07caD7DezCKPhgfJKY52aQpLg8I63BxDZXUE/PZKzQduO+VXEbSyXYi8d4KRp8ys5SKylRCCgWj1NWuqlIRsWrLOlXFPveYajKatJkXls3rP22l0RMKqKw6L6kLEtyM1n7corwa5911UEbxnxWi63KTeVcDf7qUW4kU5lNo1AiKOHvUzfVr99Jvfn0DhcIBOuHkr9LUcVXk7minA75yDBVVpBPLIsrE+z0m4L7ay11fuYbaJn21z++wzo4wuTa1tNPPrvop+dWNG+7ggeUmdTKyf4lXQkJCIgekWyAmi/kaEno+E09AtlQS7oojXbD9ZTB+KiztkQLjIiQqRBsbuFOph1ubfORxBal6bD5986ppdO4102n20VUUzzkGJtrx04vI2xmkPRtcGV98pMBJgakTyXfILE4zKTBlQg/pcj3bl7XTljdcNL1GjQj27tI3lb16oUpOj3TVucnuwy+nqKG3S5a76kBqn5A8Gh/2+oXE+8xj/4yRLiSy38nuJiEhMURI1ZTGab8j7ZCVH0rS1Ua8Hy8cp6tHji/opRpOlGphsRwMhBXitehoaWP5PnqrgU65YALZ8kzU3OClhjqX4moUgyPfQuUjHLRlWQvVTCvIyU11Nvhp01st5GpSn/u0miNpa9On5PK30Rtvr6Af33J8RuV1jT6Mtpx6H5VsXkymgJs8FVNY0j2Jokbt+CP/ffcD+vD9bruKnyVb/5OQkJAYZISLYB4w3rLydwxgr5BqULgWRCoIGf6s15OqJtbC87I105B4SThNl5T3DQgRL/V2+/KmiF5VWmlXjLM8XUF69Z+qR8Vny5vJ5uhLVjUsFe/Z0EUrn9hNTevdFA1np4ptr/fR5y820qdPN3STrjJZMFrpK5POYtnVQNu2bKOH73uwT8znVPCVjqOGQ39E9Uf9lFqnLNAl3Q1r19HjD/9V+V5kGkOH5l9dKLuahITEICdd+KzCqBHjFYgAEgqMlj7h5OfjUEti3XFFCtLF2uhjskVTEK9wITqlqMzOEm3fNcD4dcGYS1GqsJFYrx01XpVg33lpB7386GZq3uWmopIe6/PYLkeQhguKrBTxhmn9f5pp2cM7acOSvQoJ+zq1XZcC7jC1bPPSlvda6cO/1dPq5/ZQ6/bkdhAVBWNp7rhTle9rV31Gf/rDfRTw514Tsu6zNfTAnX9QQloWOcto7mjYNhh+y218lexuEhISgxinpDieblS0O4XPrIQGYmIbZjb2ihHJt91U9gwQAmLMpShV2EiF7Goc1NHqV9Z731y4XfHfNce5J8XU0VBdFzIh2/KMZLUbye+NKKS7Z62r+zyr06RssgCEg1EKMkmH/JkFH5pcfSj5gl30ef3btHrlp3THLbfRpddeQ5XVudkwaMkrr9HCJ59WgnU47YV0+uEXUaGjjDaubuN28N3N5LvsvkXzV8puJyEhMQjhzkEZ2LnoDtmUaUi8pDoUU0Fxcl/o+DXfGHEG0yS9CdOLqbhcXQxG7OYNq1rJ6+4txVqsJsovsnbXZXcYqajUzGRsJke+iY8bKBKIUIClX1dzgLztwYxJN4aDRp9AB9d+TVE71+/YSbdfdxO9+sLLaW26oIX6uh101+2/pmcff1Ih3bLCEXT2vMsUiRf3M+HAYp48KLrp/5NdTkJCYpACYVb748YGt6cF/XHtGS5QKJUlsRVMqIfMmZdc8nN1hruJliU3atrlotIqB008oCitSmDJvGtbF+2uc3W7mCOUJCTg/EILS7mqAV2A6whB+i1NbrUF1XRHa24iGzZ0bKHlmxeSN6C6xmHP3GO/eiIdeezRVFxakjI/YjmvX7OO3lmylFZ9tLLbRWjq6IPpmBlfJ0tCOMmGHW7auVmJAzHv3ldO3G/b1Ul3IgkJCS2c/MieI0kNvDI1g2wgWmxwcguTrku2YhrjsNiFyFVZ4zDVTi1KSbzurgDt3t7JhGml6XPLUhJu/Djv7gzSzi2d1NmmvbYKQp4yq3TAiVch+pCPVu9cQpsbV1IkGu4mpjHjamn85Ik0cvRoKikrJZvNxvcSoc6OTtrb1Ex1W7fRhrVfkNvl6nWzpxz6XaopnkzhUIScBb0nDx0tQdqwWvEFfpCJ90pJvBISEoOUfDFIgIARDARBcBDoApsExNYiQQbw30UkMITh/BcT7i7ZcunDLGY2ppiqN/lgHZchFjbSnZoAG+vdVD3aSdjoB0U4WbrFjkXurqCy7tvZ6ievJ9RtZAUf4pHj8vfZzVvNdjpk3Gk0bcRRtGHPctra/KlCxiBWpHQQDodYUvdRMOinjqYw1X26mYxGE809aiw58229lAtQqQcD4aP35wPfn8E7JCQkhgQwSLwvUnr4gRxXMiVehDmjPKc5vQxijTccjlA0IgyvNNCyx6u4FJVV5SlSMwJTwXjKWWBREk1QrZ4hIQJGk5H2h0CWby+hg2tPodljT6LGzu20p30z7WndSS5/C4XI2y0Ng6idtiIqdBbThrpPKBQKKCpnrBePtR9P7fU2ctgLFOl49YqddMSxE5QgIcFAVNmtCSp1Jt6psttJSEhIDG/inRiTNtMB3IlAjhCcwiypmnXCPBaUWGnLunZFokWQDK87rISfRH74A6uRsFSJGoS8v7WgRoOJRhRNUFKjqYs62/w0aUbfTRnyC020p7mOmttV7coY+7E00nmwQrqqhsDEUrCBdte3U83oEvKIWNcmkzJLschuJyEhITF8ASaoVUghif+u3xeh9pYgBXyRPuQbL6lqYcSYfGV3o23rO2jjZ62KxW9RmYUcBSZFEjYx8Vq4XrvDpHwfXFCvB5JqItxdYZoyeq7yvcQykUbkzekm3VA4SD6/mwIhPzU1dJKro0eVLsqKyG4nISEhMbyJdxQiUyVuUICQkB4mmGgSmoipm7GBgh5ArtPnliuqZhhWYdOELWvamIgiissQksW2/yVdrWsHgv6+/sqQ9keXzFSlX1ONoorucrdRe1cLuTwd5At4mWTDLOEHe7WRKGub7HYSEhISwxdQNVfbHH21n3qbIMQMrLAJgrNQf23YZjfRhAOKh1zD2EWb4B5teb3vEbsq2aiERhbMpA7PVjIb8qjMMiUJeZvj2jNCfp9ikLZcdjsJCQmJ4U285VZr3/XdZKrnGKx2ztYZoG3r26luY7tirWvmBLWymSVFSMQgZ4SfhFoa0jRUyQZO+K4m4dpi6IkFHftb+U7q7kWJkmYkSRzneHUwvscsd+NVvCBLWFcrn9HY31HlHCXx97DyGen+Dehs81FJRU9Er71NHdSws4MQD2OS83QliJrX76Yd7nepxDKJHKYKMTmxKBJvMBBSCLijzR8rYqHsdhISEhLDm3jzk8VnBlE6C01MHhGV2OL4rpSJCMTU2e5TPv2+sJK+jAj4wwr5Fpaom0fAmttssigJBA/ShUuRK7KH9rhXUm3efBqZP4fsVodi3bxlYwNNmjqS2puxb7uycfsrsttJSEhIDG/idcInF2uRiQRstRmVBEvk+LVKSKIVNU4lBZhw6zYpO959wOkuTtArIxLHGZyOVa2XjaoUGlWlVvynlBaNSbLRbom2v+hZLzb0fDfEfu+xosZ/iJLFdWIV+35OG0ndNxepUyTc2AfNu92joHqG5bc9z0rBUKeyhuvze1h6VhfBgxEXjc07nkYVzCWbxS6uxUhBX5TqNu9lclbE+uvuWzQ/dC9JnzcJCQmJYUu8/oA3QC6yrvpgD1WPKSBslIDdguKhR4hxmx7sZVJ5EV+uWbAEC56/xzFHQT+8Z7heDwyUAgq5nUY9Dt2/5XRpntOiGGdli4jdRO7OgJHv7wj+86d8/X3ulO/lWyzxL921rcMyclwRFRY5mGyDLOH3hDT1RdrIaaqikY6DyWqxUTjCE5VQkAk6oFg5R7rCsHr+c6x9JCQkJCSGL4y+gKcdX7C+uXt7F61e3kSrP2ii+q0u6mwNKCrkUChjD5hfGwwGS0GxTfj9Zmm23Dubi4mrHYm/+3tLt1ncOEvtkGDzi5ToUodxOjvZeVzfe/xxfigYCe7c3M7Sv5/GTxrB+XsIv963jArNteQP+qijq4W63O2KChqkq7RtJNzEH1fI7iYhISEhYY5Go19Eo5HKUDik+J9aLXks4doUEt4dz4EG1X9XBIHoBtY8EyTEyfxxZmllHpVWOnpLmMLISdU6R7tdlWDxi/XinN0US9r5hTaF8FXVssrQBuE21WsiwNfi94SwzeEN/NezGuS7kO/rBL7+JxvrXaNA2GPGjiAvS715DivVbQlQXddSMhksVGwe3yd/OBx6nssIy+4mISEhIQEWfT8YCirq0TB8T/2uKKS1GAJBv1CZIiZxKOr3hTp83mDQ5w2Q1xNQ9tLFemcg6Ivppy8Gx8WMkRKlTJNZtXq2WEyKxKkkuym3N8X12OxmpWzF4tqi1mkyJZG++c+icsVq+WAm19laZQrJdzqnXwT84bb2vX7yu4zU0RymEuNUikRDtNnzCm33LiV/pLPXfIPTI7KrSUhISEjEiPcxf8DLUlm3QHYnrHSFpEYeXxe5vZ2K+rTT3foaE1Bxh6vl1g5XK/4G4SrGUR6fa4vIfxbiPsdveD/YgZ2WBM7UO4/vvYvTz/nrCE4L0FZ878+VWid/GDtnb3Atfe56jNa6ngAJw2f3uMfePf8T2dUkJCQkJAAzk8KmC49+6q8s8YJIbuO//8x/HxuJRA5H2MM4NHK6XHx/gNN3OU3DOqawUf6AJUZYUhXC0hluOOnGf97fcHV232dZOucz+SLDqyIpOGDWESv5Y476V5S8kRak2UzEH8huJiEhISERL/ECP2LCHQHSFX//zR/0KlvdCazmNI+P1+EP/oQu+jhOS0C8/oCvmb+/zIQEa6KvhsPRjvot7eTzqJJzMqtovz9IrXs7uY7QgN2c2+WjttYuJUSlFlqbPdS8W1Gtv8Xp2n5U90zC37jre9euWi7XdiUkJCQkeiReQaSJ5AD18zX8iZ3b/8bpST6nF0Py35CAv8rS8UzmGCP/7RfS4CqWfA9n8l20c0v7eIM5QC4mQGe+lcaMr1LWdndsa1J2/gECwQaqrikli9mes5uC2nzjup3U0e5WNi/YGW1Rdgkqryyi9lYX7axrwiWTw+GgSFCZezzJ6WK+9v5YeP2d1M2jobf+iNPjTLobZReTkJCQkIjHgG1PwORb7PZ2rrRZ8xQzX2weYLVamHjNLGbblJCLMNzCGjLgdDqpIL+gTzlQWYvwjccxMb4tyr4XHxZb312NsN7c2tbSLUkX5ZcpBlVYx87LN1FrS6fyN373BTzIcL/d5vxxMh/egYLcjF5CQkJimEu8A4H2rr1zmFzHB8Vm8QqJBoJMoghHib/8iiV1DG63m8wGmxLtKV1gt59gIlEHfb3U13CRijn8trd6BfGp8ZXF+ef6At7r8VV2BwkJCQmJgcb/CzAAgMnNiHBbpicAAAAASUVORK5CYII=';
63
- ?>
64
- <style type="text/css">
65
- #monsterinsights-settings-area {
66
- visibility: hidden;
67
- animation: loadMonsterInsightsSettingsNoJSView 0s 2s forwards;
68
- }
69
-
70
- @keyframes loadMonsterInsightsSettingsNoJSView{
71
- to { visibility: visible; }
72
- }
73
- </style>
74
- <!--[if IE]>
75
- <style>
76
- #monsterinsights-settings-area{
77
- visibility: visible !important;
78
- }
79
- </style>
80
- <![endif]-->
81
- <div id="<?php echo $id; ?>">
82
- <div id="monsterinsights-settings-area" class="monsterinsights-settings-area mi-container" style="font-family:'Helvetica Neue', 'HelveticaNeue-Light', 'Helvetica Neue Light', Helvetica, Arial, 'Lucida Grande', sans-serif;margin: auto;width: 750px;max-width: 100%;">
83
- <div id="monsterinsights-settings-error-loading-area">
84
- <div class="" style="text-align: center; background-color: #fff;border: 1px solid #D6E2EC; padding: 15px 50px 30px; color: #777777; margin: <?php echo esc_attr( $margin ); ?>">
85
- <div class="" style="border-bottom: 0;padding: 5px 20px 0;">
86
- <img class="" src="<?php echo esc_attr( $inline_logo_image ); ?>" alt="" style="max-width: 100%;width: 240px;padding: 30px 0 15px;">
87
- </div>
88
- <div id="monsterinsights-error-js">
89
- <h3 class="" style="font-size: 20px;color: #434343;font-weight: 500;line-height:1.4;"><?php esc_html_e( 'Ooops! It Appears JavaScript Didn’t Load', 'google-analytics-for-wordpress' ); ?></h3>
90
- <p class="info" style="line-height: 1.5;margin: 1em 0;font-size: 16px;color: #434343;padding: 5px 20px 20px;"><?php esc_html_e( 'There seems to be an issue running JavaScript on your website, which MonsterInsights is crafted in to give you the best experience possible.', 'google-analytics-for-wordpress' ); ?></p>
91
- <p class="info"style="line-height: 1.5;margin: 1em 0;font-size: 16px;color: #434343;padding: 5px 20px 20px;"><?php printf( esc_html__( 'If you are using an %sad blocker%s, please disable or whitelist the current page to load MonsterInsights correctly.', 'google-analytics-for-wordpress' ), '<strong>', '</strong>' ); ?></p>
92
- <div style="display: none" id="monsterinsights-nojs-error-message">
93
- <div class="" style=" border: 1px solid #E75066;
94
- border-left: 3px solid #E75066;
95
- background-color: #FEF8F9;
96
- color: #E75066;
97
- font-size: 14px;
98
- padding: 18px 18px 18px 21px;
99
- font-weight: 300;
100
- text-align: left;">
101
- <strong style="font-weight: 500;" id="monsterinsights-alert-message"></strong>
102
- </div>
103
- <p class="" style="font-size: 14px;color: #777777;padding-bottom: 15px;"><?php esc_html_e( 'Copy the error message above and paste it in a message to the MonsterInsights support team.', 'google-analytics-for-wordpress' ); ?></p>
104
- </div>
105
- <a href="https://www.monsterinsights.com/docs/fix-javascript-error" target="_blank" style="margin-left: auto;background-color: #54A0E0;border-color: #3380BC;border-bottom-width: 2px;color: #fff;border-radius: 3px;font-weight: 500;transition: all 0.1s ease-in-out;transition-duration: 0.2s;padding: 14px 35px;font-size: 16px;margin-top: 10px;margin-bottom: 20px; text-decoration: none; display: inline-block;">
106
- <?php esc_html_e( 'Resolve This Issue', 'google-analytics-for-wordpress' ); ?>
107
- </a>
108
- </div>
109
- <div id="monsterinsights-error-browser" style="display: none">
110
- <h3 class="" style="font-size: 20px;color: #434343;font-weight: 500;"><?php esc_html_e( 'Your browser version is not supported', 'google-analytics-for-wordpress' ); ?></h3>
111
- <p class="info" style="line-height: 1.5;margin: 1em 0;font-size: 16px;color: #434343;padding: 5px 20px 20px;"><?php esc_html_e( 'You are using a browser which is no longer supported by MonsterInsights. Please update or use another browser in order to access the plugin settings.', 'google-analytics-for-wordpress' ); ?></p>
112
- <a href="https://www.monsterinsights.com/docs/browser-support-policy/" target="_blank" style="margin-left: auto;background-color: #54A0E0;border-color: #3380BC;border-bottom-width: 2px;color: #fff;border-radius: 3px;font-weight: 500;transition: all 0.1s ease-in-out;transition-duration: 0.2s;padding: 14px 35px;font-size: 16px;margin-top: 10px;margin-bottom: 20px; text-decoration: none; display: inline-block;">
113
- <?php esc_html_e( 'View supported browsers', 'google-analytics-for-wordpress' ); ?>
114
- </a>
115
- </div>
116
- </div>
117
- </div>
118
- <div style="text-align: center;">
119
- <?php echo wp_kses_post( $footer ); ?>
120
- </div>
121
- </div>
122
- </div>
123
- <?php
124
- }
 
 
 
 
 
1
+ <?php
2
+ // Exit if accessed directly
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * Callback to output the MonsterInsights settings page.
9
+ *
10
+ * @since 7.4.0
11
+ * @access public
12
+ *
13
+ * @return void
14
+ */
15
+ function monsterinsights_settings_page() {
16
+ echo monsterinsights_ublock_notice();
17
+ monsterinsights_settings_error_page( 'monsterinsights-vue-site-settings' );
18
+ monsterinsights_settings_inline_js();
19
+ }
20
+
21
+ function monsterinsights_network_page() {
22
+ echo monsterinsights_ublock_notice();
23
+ monsterinsights_settings_error_page( 'monsterinsights-vue-network-settings' );
24
+ monsterinsights_settings_inline_js();
25
+ }
26
+
27
+ /**
28
+ * Attempt to catch the js error preventing the Vue app from loading and displaying that message for better support.
29
+ */
30
+ function monsterinsights_settings_inline_js() {
31
+ ?>
32
+ <script type="text/javascript">
33
+ var ua = window.navigator.userAgent;
34
+ var msie = ua.indexOf( 'MSIE ' );
35
+ if ( msie > 0 ) {
36
+ var browser_error = document.getElementById( 'monsterinsights-error-browser' );
37
+ var js_error = document.getElementById( 'monsterinsights-error-js' );
38
+ js_error.style.display = 'none';
39
+ browser_error.style.display = 'block';
40
+ } else {
41
+ window.onerror = function myErrorHandler( errorMsg, url, lineNumber ) {
42
+ /* Don't try to put error in container that no longer exists post-vue loading */
43
+ var message_container = document.getElementById( 'monsterinsights-nojs-error-message' );
44
+ if ( ! message_container ) {
45
+ return false;
46
+ }
47
+ var message = document.getElementById( 'monsterinsights-alert-message' );
48
+ message.innerHTML = errorMsg;
49
+ message_container.style.display = 'block';
50
+ return false;
51
+ }
52
+ }
53
+ </script>
54
+ <?php
55
+ }
56
+
57
+
58
+ /**
59
+ * Error page HTML
60
+ **/
61
+ function monsterinsights_settings_error_page( $id = 'monsterinsights-vue-site-settings', $footer = '', $margin = '82px 0' ) {
62
+ $inline_logo_image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAd4AAABaCAYAAAAWyDe5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyhpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ1IDc5LjE2MzQ5OSwgMjAxOC8wOC8xMy0xNjo0MDoyMiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTkgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6MDJFRDBENkZFQ0Y2MTFFOEE5OUNCODFENzIyODU1MzEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MDJFRDBENzBFQ0Y2MTFFOEE5OUNCODFENzIyODU1MzEiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDowMkVEMEQ2REVDRjYxMUU4QTk5Q0I4MUQ3MjI4NTUzMSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDowMkVEMEQ2RUVDRjYxMUU4QTk5Q0I4MUQ3MjI4NTUzMSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pv4HgdQAAD64SURBVHja7F0HfBzF1X/XT3fq3XKTewHjgmkB0x0IBkIoAZIQEggJnSTABwQ+AqmQEOoHSSAJIQQIxbRgIDamYweDwQbbuNuyZcuSrH69fu+/OyedTrd7RSdbQvP3b3yn252Z3dnZ+c97894bA+0HXLNgiZE/lnJ68L5F858bwHrs/HEvp+1czx00SBCNRklCQkJCYnjCsJ+I91L++KP480FO1zIx+nNcxyT+eJbTTE4uTlO5jl2SeCUkJCQk9ieM+4F0i/njl3E/XcFpGf8+IYd1nMsfnwjSBfI53SEft4SEhITEsCNexnWcyvGluDwv9tscTh8zYZ7aT8K1cIJq+V8gWwPL83lOc+zwt/nYQfKRS0hISEgMG+Jl4hvBHz9WRNAiG42bWkSTDyolg3oVkIT/zef8LydDFmWDzN/AV/xtthhp1IRipR6TSSkO//1GPnIJCQkJieEk8ULadUISLa92UDQSZanXRgcdXkl2R7dk+gtOTzKRWjMg3Wn8sYLT0fjbkW+hMZNKyJ5npgjXUVBii526gM89VD52CQkJCYkvPfEy4Tn54wcxaddiNTEpqsdsdhMdeEg5lVR2q57P4/Qa5ylMo9zD+ONdTuPwd2mlg0aOK4pJuRQORwi2TCZztxB9lXzsEhISEhLDQeK9gJNCpCUVKsFGwj3WvUYmyokHFFNNbX7sp+M5LWFiLdIh3SP4401O5ZCiq0YVUFmVo/s4CBd1wIq4oKhb6v0m56uUj15CQkJCYkgSbwbrsZfhP6iUbXazkEZ7u9WAPEeNL6Cxk7u5Fmrh17kOR5J6lWOcHAajgQm7iAp7VMrd0m6SO4UK+/s5vjcJCQkJCYmBJ14mprH88bxQI+udB1chxaK4sMQeR4zJ/VmrRjmodmpx7M/DSV3zNcaVV8sf/0ZxIN2RtYXKum4iwsEe4oXk6yjoXjY+O417m02qdbSEhISEhMSgkXiP5HQGp/cFCWvhGzGJNk7lS1HmxUgkeYbKmjwaNaF7iffrnH4lCNEhSLcS5Y0YU0B5TkvSMoLBcK+/bXmm2Ne5XM5oHdI9E/eE6xbRryQkJCQkJAYF8R4lPmeR6od7gsZ5IGeyOyzKWm4vqTSkHcWpZqxTsX4WuJHLn09qCMgD8UPFiHxyFmgbP4eCvVkdVtRxOD0J4Zo4/Zq/LuSEisHoc2U3kZCQkJAYLMR7cNx3+NEuZuK6jZM5jswg4h6C78lIMpEcE1E7tTDmagTGRlznS/AH1nOLyvSF0YC/t8QL1yJbj9vSvATShQT8H04/SyjmENlNJCQkJCT2O/FCOuyRPB1kyzPHyvs5p//y8Vi4RnwqjGvviSIVR7z6cYuNRoMSZENA0T0jOEZFTb5uvmAgnDQmst1u7kWoWDvmdDF//ZyTIrFjvdjac95M2U0kJCQkJAaDxAu/WUUPbHNYaMah5UyGjnhJ+FMmtEdJXZ9V5NU40utFvBF9oZclXhONGt/j0gu3IRCyHvy+UPIb7vHnHc/XByOrjzj9hVMRrhHuSEjwLRaYIbuJhISEhESuYO5H3hHdZGYwUDhMSghIrMluXttGQX8YDPe92DkWi4kMGmQZDESY6PTnANVjHNSw00V5LFkns2BOl3iptxD8bDe5c7mVI/MVyb2txRu/Fl0ju4mEhISExGAg3m5/H0iKAV9EiUZVUGyhmUdUUPNuL+3c0tkdJMNiM2kWhLypiBcS7rgpxUzSqbfUgzWz1tpxpLeBlaK2RrSrolJ1vRjXG2DSNhq7rydPdhMJCQkJicFAvN0ipYEl3oA/QnkRo0KQSPDFrRiRR817vLRraxeZzdrECnUzrJvjwjomZ/oyK3W0hlJemMcV1DyGdV9symA2m6i43M6Em6e4OcXgdgVkr5CQkJCQGJTE29ktRSoRokzk9zL5OnskW6hrq0Y6qLLGQV5XiKXVvhJnDD5PhJyFvaXiUChCHrdflUBNRrKYTUo9eghzHp9Xm3gh4daMRcCNvhbWcDfyuoPd3xPvU0JCQkJCYn8Sb32PxKqqdUG89jxTbJs/6pGIiRwFalVQK/s5JVozQ2K2BSExR2nntlZq3OWmUAAqZjMZRYGQVsOREFntRqocUUgFRX21wF0d/sR1XAVWm0khW5td+5Y9TLoxS+hIT7jJetlNJCQkJCRyhWz2vYU181c5nUIiCAWsgLFOCtjyjExwppTlQPIN+qMs1TKZQtUcjlJbSxftqe8ks9GWMn+U/5ksEaqdWEEmocaGtNrZ7lNnFPyb2WoiKyeQbWLgjj6SMtff0ujuJl6fN0wBr6LWbuH0JKclnN66b9F8V38bPZmbk4SEhISEJN4Y0cKP5zhBtkgTE89BYIya2h53n4JiM5kt6XM6iGjdql3U3OAhh70goxuIRMM0bmoZE6xZCZiB7QChljZkOKVob/F2W0LD+rpjry/ZadBDL+e0mNQNGj5lIo4MJeLFevwRx5yKXZ0u5VTCaROne5e/88rOXNbDdeBBXs4J2zaiYZ/iOl6Qr5zEvsDJj+zB1qJnkeoyiRCzj71+SXV0GN0/AhrdTWpcekgy73G6mtvgM9k7hgbxPigG0J5MRhg62amk3E7OQqsSAxkqZK9bjRQF46rCUnPa5Lf6ox3UuLuDTEYzFTiLEyTRkKJejkQiipQbIw+jwURmE0uyRhP/GqaJB1Sm9O3VgscVUFXUgnSLSuxKHZCgY0nDSno2E++qoUS8Xzn2NGgqXqbei+W7OB3ExNiaI9KFPv8DUneXiseVXMeD8rWTGGDSuZlEbPc4/B+TzlXD5P5hwPJfjE8Jhzo4HcztsGUQXCMG65+Q6nIKdelSTjfytbUNh2eUTgCNhtiXMZOK6MBDK2ju0SNo0owSKh+RpxhTwfPG7jAqZGu1GRVicXWE0rqA7ZubFdJVSJYJNhRmkmOy9fi6qMPVQl2edvL63RQxBMlqNzDRWyi/yEKOQiNZHGGKmnxKvt07tJ+Xq9NPTQ0uatrt6ibYGAL+EHXxcRCuw2mh8kqnoprGmjBcjKpHF7BEXUpjJ5dQRY0zFr4yhqYh+MzvpL4WaiM53ZbDOs5PQrpK3UzKDkkNEgM4oFeTGj0vEVfysTnDpBnOT0K6APZbvXmQXOMvOf2B1ABF2L3uh5wW8zMyD4cHlM5N7o19gYuQnhQLNa9imRw1MRlGld2HDDrU7mfS27K+N3e5PCoJ2+wWqq4qpaJiJznz87KWZr2eILm7Ar2kW5QVixsNybaswqm6O+lUASK22vKU830eV5+2GUI4UOP3HzAp/oIl0n7dE5eBVrxe4zC2j5zK6RNJERIDBGwjqhVh55hh0veOStE++3tyVKAxRmBDmlM5vSiJN45c4GJjMKVBgAaVhFOhbvPe3pvVM/IL86hmVLlCuLlAIEkEK0i5MeJF0I9MAHelmNrmvkXzv0xOvzARx7rvr/pZzomkH2YzQhIDAp70gHAQWxwGCmt5EjUcrfiKdY4VDZM20Bt8TYPg+jD51tpWbsZAEi+TPrR7YzhteP2S6tb91QDpqJr3dJNOWPs9xrKllo+uZsG72nt6g9lE4yfV0LQDx+aMdJUbNBnT+i1t4u1pg6Yv4Qt7FQ/etn6WcZ2kwP1CulDtbyY19jg2/PiYfxspW2ZYYqXOsRWD4Pqc+3piwIRr4vQnUt1Dl3HazX9fPpiJt1vijSQhXvyG9dz2vUHqaFE/Pa4wpbIfggo4Fugiz2GjA2fWUllFYe6fcL6Vpe+e24SaOV9nD98MJN69X8IXtpLTBf0Y/DFb/aoc9/Y56ULKe0XM5GPAeuY/ZOsMSzzOKZkBFTQhvx2mbXIjpx/F/Q0B40Em36MGPfEmbloP0u1sC/WKnwzCRSANkLEe+Xo9qpGTw2mnaTPGktVmGZgbNBkUP2OEhkQqr3J2+/1mg8iXW+IFfiLWabPBtXLM2y84k1NFkt+P52c5XjbP8MLrl1TDCOV4Ui2FY9jA6SQ+tm6YNssVGr9ftD8uJuUa732L5u+9ZsES+AmZQqHey3MeV0STXBGZStn8IC85yWG/XIvVTJOnj+olkXaDh/6Rk/KparyTnMVMykygwUiEvL4wdj6igCdMXib9riY/dTUG4kM89i3KYFB2H0oFH0vhsHqGVAySRnjJPhJvz5r0l5V4p3P6GqdXM5S6sIvTt+Swt18wJsWxrbKJhh357uCPE1miw7p2Hv+9Z5g3yQiN38cNSuIVaOZUHQpEEshT305GCQOpQbyRsEFZ07VYel/CqCn5NOvYKqoZ7SRLEkIGvXoCIerwBandF6AIwkjydezd4qHGdS5q2+nLujE62/2KKxTWquGCVFzWNyRlnNS/90vcSa/NlHgZ8JG0kISExGAiYLiJdMiW0JbLBj3xBuOCSKQTA0LvHIczj+z2OMKdWkhHnV5DZSX2lK3kZEkZqSrfTk1uH7WSn6qm5SvJ1RSgbcvbqHWbN+PGgD9yOCzq0XBfilvjbfoSd0aoKGcvf+eVT9OUdvNJtYiWkJCQkMgR8TZymhEv4cKfFz66UR2hV8ulKBKBxKt+t9iMNP/CWqodV5jx1MPE5DiiII8KbRba2eGmEEuq+ZVWmvH1KmrZ6qGNS1soIKJppQOol+HzC9ItKLQlnUjEWW43fcn7BqTe76R5LtZJigfyYkTgjUmkhrlEV4GRwBaeHDQOcL0Fot5CUS+kh01cb1cOysYsE6rgUlKVOX7RrxoGoysQXy+CU1SLtkA71PN1tgxwnVCV1nLKFwIAnnl4f7bDyY/sweAwTvRFPCe4pWxj6TKYg7IxJleJPmEU7dzCZXdlURYshBFIA+/OR1yGN4sycA0IcFEjrgfvG1xxwgnnwWJ1jjhnJR/356itS0XdpaItdnHZg0rbKKJwjSbVzgJqUpdIO/haA1mL2dcsWPIUf5yH7f1qp/a4wmErP68OsWnFbAaBuzrCVD7KQadePJ6c9v4HKwmEI7St1aWsA3f/5gnTukXN1LHLl5MGxhr3ti+6Xb9Oum/R/MXZlLOfQ0amWzkcoMfxIFefYmDEw9skBsd0AEk6rTCbXDY68ffFBADuMslcDeo4IQb0/VzutjQHckTNQehMfIf152OcHo4N6HwO3B1+QKqF92zqa4SITvY2p19xnrcyJBIMUN8U5SOYQTL3LQyQcPt4g9OzXMcGjXIQhew0TuWk7aOKgTL+BcAA/gCX+XCa1zsNQwCnrwvSTdb+sKh+kMv8Io3y8BxvITWQC9rxHVJjhX8edw4GjXM4Xc3pyCT3czuf/0eNQfB7/PGoRvW380B4m8bg/r+kWuRjMrQRZfC5z8Sdg754MfVEZTMneWavoW9xvlUZDtxmcb/f5TSPkrvbYEK2XPSJ57mO3SnKHEXqclHMpx6TlnM531tpXhMmFjeRGuu5JOEwwgQ+y+nXWEvmc2O+tzFDPlzbGXzsI42yj+UPreu4XTw/aNDOEpPeROD5PEJqGFCfzj0gYMpvSI3MN1bjNEwQEte/P+b0Yy67PkUboW/CaGu+eAcpyTjxhbhXtM9bXGYkE+K9nz+uQgjFKbN6PwN3Z1hZy00EdijSWt+F1XMpk+4p3xmXdB03W/hCYdrC5BtPbDC6+uK1vdS8yd1/cveFqW5Td2jKrOI0DyHiBe7iAe76FAMpBoxnMigzLeLlck8QL+DoNMsNipfsl3oSEZe7SJBuIt4QJHY0p79yGpVmvSC/m9KRULnuowTJZ2ppjInvhVxHMK6sB/jjyn50hbO5vIUpJgi/FJqPdHwr0eYYJ27kcgM6EvMWIYElTvK+x/me4HNAgtgN7KQU9aE9/pEj4sUk6pgk5z8uJn4niIF+TJrtcB3Xc2+aBIc+8XchVaYL1HGfqCeqUW6ye4J2YiLnaU9xTeeJNrSnuA6QFuIt/5jT5IRjeM5Tua5QhsT7uSBbexrtsJbTqVzH9iR1TBBl5WX5fqyGBB8jyoSyK8UYcWqGZWICvQCxstNlPUWdh4hPiUCIyPwik7JHrsVqUMi2sMSsSbpAxRgHLfjO+JySLmA3m6g6v/fzgtp4+ikVVDa+/yGCE6y6v+yqZuASoWrVw/UDoF6E6npxBqQLwLALMXoXCtLQkqC/ppEfEbeWCqllVAb13iCkpVT3tIA/3syCdElIWYnuEP11g7goBem+xOl/KP2ABiYxCL+qE4Tl+CSkS0J6/DvnO1oMyCelUd/FOVITlmuQLgmNx2sijcmgHe7hcn+YRt2niT4xIcPLRh0/JQ0vAiGtJrunMhJbuepcE44/kSbx4Tk/lIR0SdzToVk8khlp1g0cgHdWWG4n4qx+kC6ACHCzkrQPrKOXZUG6wBROfyFKz48XUHTq2MA+6YhnNZKzAARsViRdk1lbkM7Lt9D882rJbBoYY7JSh42siYTOVYF8neWpA2dEIiFq7qqj9Q3LaMXWf9O7G56idzY8SW+tf5w+2vE87Qx8QC2hjbTa8/fhEOwfHfqSFBLcITkm3flCush2VvZ1MRgkgyGFlucrWdZ7K1/3RJ17wkD4NPXP6vvkJINef6D3MjyUpL50AenwAY1jemtKZkFCB6VZT0WOulyqQWF+ln3iHjFIaxHc1Bz0Ca3BP5V7mdY1FQtiyJVENHYfjFGYyN6W5PdcjM+2hPYxCu3ehH6UeSyWLdJt4GaFlMIR6q+WdN7ZY8hmGbhwoRhVyxx9xyQjTwYOOLVC+eyLKO3p2Ervb3yanv3ot7R4zV9o5fbXaFPjCtrZuo7qW7+g3W0bqb5jDTUEPqYtvtfIH+nYxAPq55x+xqnyS0CyWk/2GrGOm4m0m5Xxi5BIc/HiXyxU1b2w/J1XPKTuo5xroENfo3P896QfJi/tdzAO/b2P1zWewYk5kCYvEdJrIt7m5EnRjulicy4enFgr/XQA+gQG/gv1iLmfEhnQpjMMUhaTnytyOKHJxeQwXfyIySwx7OGr/SwT676JG2p8m/Q3oEgHnZx8xgwuQpUIw9kz7+TDyqi81D7gT6HInnwSm1dsodrDexvf7m7fSK9+9hAtXfco1bWsoVBEXZ4qr6ygmQfPpmPmH08nnnKykg6fdyRNnDKZbD1+UDAQ+TWnOh5o7uFUNoSJ9xWdGfLZSQZoqJdO08iT7Yb3F1H6Kr1UuF3jd7w8aweg/U7XIDJIPd/QyYf1G0QTwprSdp0J0BOJgw2nbDc1xxrq/RrH9EIKwrIQ8W6hgsaWbnU6596cZOKDoA6wCQjmoL0fzPGz2zUAfeJsDclyXAqNAlSLaCsYLepZjf8rx9d7EQ1N5AnNRPyEaoXop9n0NSytnpfEMvuyFPm2i/cYBlVaVt1PYl0+XXPinnjNkShPSzNXEyN044xDK/bJUzAbDWQzm8gf6it4jZpTSLtWd1FnWyet2Poy7WjpGYPHT5pIXzl2HhPuHCoq0faOgXHUlg2baOWHK3gweY88bg+YGAYG3+GB9nIeYJ4dgp0XxgLHkeq2kYhrk7zkP9GYWaPRH9AadFLgwhTHYRkIIyhYMsLaFoYvpRrnHolwifwstiYM/q38O4yrYOiQahaIvajxAsNiFdbNU3TOHQPDIJSfqFrSkeDRT37IedrjiLpYDMpniLyYCcJ6+vWE+wBRzOTzsR59nY7EjfXh/8b93aXlAsRlwR1krkY5mBwcx3mb4s6HdfLLiYOewHxEM+PzdydcN9aAbxTEnQrtQrKFZSTuEyo+uGnczOX8J1cdH9arTIYni4lMqsENmodVYkBHnxihc+4suNkkcSmZn4JMr+Q8LXFEDVuHBaJPHCPa4xY+591ctQHXgaUSPfuDJdBwcZ2rhUoaSzq3UfreDNkABlrbxDs+O8WzQd9dmPBcfy82RigT5STDhyDZ+OGdVJelUEL7YFw8TKMMlH0651kTdz649UjxzBaIa3hBjKVp+/F2v2yI3GQRAiViNAf9EcUXF4ZVeph2ZMWAqZgjLg8ZTEYy5PWMozazMSnxwtjKMrqTXn37QfIEOpXfJk6dTGd9+zyaMFm1XMcascNiVoy18KgDXI6Xky8YVp4KSH3GjGlKvjPOO4fefG0xvfbiv8nn9cJQ4xkeWP4PxMSDQ2gIEW+HIN9kA/hcqA75ft4VAy7u83sa5SwUs/WMIIy4DtYj5UQrVs7zO0EqWmHfoDZ9OJnkxXnX6JCMT0yk/hr/DDnPj4WKUAsw9ngv4Tet9SAMxhdx+a6Ea2sXg29a0gzcvfi69KxU9/A529N8DKfpHLs0nnRF3T5MNIVk1udVExOHJzU0In9IQbgwTno+3kJd+D0HB8KPF4MmD5YY6Cfq9AlMNv8a89cVfrLQeN2gkQfHpybRTEzWUUN+P9FFhv/eKTQNfxrA919vbR3WwafGJhDCKvoxvv8XxWT42BxfC6TGHwqpNUZkGJzhkTBJ591L9lzhPtfF+bXq8iWzik6CWp0J9A3xpCvqxbjxjkg/6SMcptMK9y2a337NgiXobJbYtnixXYkAGF0Vlpp19+CdcEDu4iuENm0jz3OvU6huF0WDoXhRlAw2K5nHjSLL6TypLOkrDK1fs47+9vgfeNIQICufe84F31bUyQgIUmy3KuvDkJjbvAElJKUvCXnnWy1UU5inEPtej5VOOeM0OmzeV+jxP/+V1q5W3BHh5jGWB4qztVwrBimgfrxaY2aJ9dzYDPtyHWnx7izrPkynYy9N5joCIhBS1xM6ZWr5q+r5l53LZb+cpL57uT744B6hka8szd9i6kTPIHv+WjP6Rr739zSIfzO3yXpBMImYrUG8bSmu4/xECT9G9AN8/00axItB70weTF9LGFzDPKDD1/V0oYHpb5/w6PmlDjAm61FAskAQCEfJ9/9YjokXk5R5iQFD+O9NXBfGptc08g20nY3eMmLGwU0yMWJR1M1hETYykmDgrBfBqqTGTvl5/Q/jG2ltp/af/Z467vgzBTfX9SZdZY5toGggSMEN28hy+71U8My/yeDvUbVv27yFHrhTJd3i0hL6n1/cqpAuiHRSWSFV5edRqydAG/Z2UqPLl5R0ldmKmGBA8h1Z6KAJZQVUU1VJV990PZ244OR46eGf/djpZ59DqGVf0ji8gO9lijCA0vIf/S+X8WGW1eupuV7ROfZvnWOTsmyHl3UOv6lzrFhDeksGTFxuHmRdQEvq2Zgi39YsBnMtrEpGuvsIWuuBnYmkG0cIIGW9oBRFGfSJaiaXS/bTvettFvDBPryOF3SidOmp1gsG+Lr0tEo3CVV02sgkZBRmgyNi8ZoRkQq+uoqq2WpMGqGqW0bPgbQb2l5P7ideonBTa3oZwmFyvPEuWdesp/Yrv0+tFjM9dNe9CumWlJXSdT+/mSqZLEG25U6bsunC7i4PhSOpjcfMxt7zFaikJ5QW0K5OD33zu9+m/Px8evHp53AIhiRYaP/5EJJ6oUo9Q0N1CN9BRHWpyLG0C5TqHNukQ5JdPBmAMURVsjnfALRPpkY4DTrHfgGtCCZoQiW1mu/Hvx+ffbnG71a+zlqdfFqz6mzav46GHupz2CceFgEssNQALcMGrSAZOYaevcOg2NmI28HDbQMtkWM/EK/eM4MF/3Yh/WMtfAVfa2suiZdCcRslwGeX8lOv2xaW99+q3Fw7iopuvoJCO3aT6+GnKNygeles6mqhL1ztBL48oKCYZhWoGoGo2L7PvKeJSu/6E93H19nR1k42m42uuvE6hXRHFjkU9fIel5f2utMf78xJNlCAqnoUl2fkL6ec+XVq2dtC7y1VJsK38KC1mAfUD4bCCIJ1XL5emNHPSXIYIe1O1BkwXxigFz9V2DHfPpwFZxrvdnkaUubvYhIXtz3WtyDxPRMfRnGgIcJkar2oUEFvy6LYQhoeyLRPrEhx/HiRFGmbB3RMduEe86zY7m8gUKRDeO2DqK2D+6NSboMmfg7Q7Ghp5sqEYIKENenNQkKHAeXSxDjemaiaFeJNtRVg8vlw7rSt5jE1VHj9D+mh1u108qdL6H+2fEKPNm6lx5q2Kt+/xr/ds/1zioZ61NDLmhvps7Xq/s/fuvhCGjVmNFUX5Cmku7szM9JNJN7g5yxRX/8b2nv+1dR6xa1U+slqKrBZ6PyLvksjx4yOtfGfeGAzDaGB5B4dctTqeA8MMWOyfTWRAXmuTvdNIdXgC+vWn2ECxOlr++hS5ZaO+w7vU/oGiIWChO/C5JYH9Dc5HSGbcL/g8QzOha0A3LOwRLGbn9kNnCzZEK/iFhDwZ25QGMltZEgyFhVQ9SknUCQJn4f5t5ebd9Kt9WspGI0ovi2P+9Qlg2kzDuCZ/TxlNyMYUSlbCnoz1+zFVM3BDVup/ef3UnDjNop6vBSub6Cue/5KlZ9+RnarlS689AcsCSsXCX/fC4dQB3smhWolEbDM/Yt8LzUBf8Js1IUwToL7zS9lE355ICxes13fh8vfezyIXyZbcp8D8bHrs8iHJZw7OL0ZC2+ZCSU2Z0u8/mgk5y0we/ZszWOBQIDe6Giiuxo20odBH+2JhBUCPOs75yuqYFgkuwMhanJlZ0AYk3i9Ly/p2cA3Dr4X/sMStZ1qJ4ynuUd0G4peO1QMrYQldiYBCuB2Izfb1m5PxJ1GNKhs3WCwXPHdIXjrO+TT1yRfrOvfkGV2aM8eEr7HEvvumcEa/6QsyRdA1KtHMyVexagEO/RkClgHhyK5JV8hSfZBKBRSEvByWwM961V9daccMI3G1I6l0jwrmTgvDKGykrY5r1HUHWnrTHqOd3cjvf/GYtq57jOad/ThsZ+nU//Dje1LwGcwnZkJJLn75WuZknzxwmHdHFbj2bwMdwiL8qECrGndLZ+87kCOtf1jqa/vd7q4W8QPzgU0B0Suwy6fVvczw5ol7DLgh57N2vc3uD2PzsS4SpF4fd7Ml/Hg8wu/2Apn7p7f6tXJl818vh6uMBhNtE1I20cdp27WgU0UWvhaAuHsJgLx67vwFw6u7etp4SkrosbGRhaG1aA9EyeNp82bFI+LM/rxku1romjhgR6+s6l2WXkxMTqUhGabwkfxDG7XKtEXYA2JjjkyjeyIkISg+MmioumtlxTl4NIR5euOTG832T7CEn0GclizHy0CRHxD9AnsyZuOYdo0Qdxv5uBS9PpQQZqT8MGMiIag6cjimUHyvY6fGZYLEAXvOPHcQMjpaDV/lAnx7o7JNwgbaTSmrzUN+yK01+JX1lWNhv5rW9va2uipp55KSrrhONWv1eZQxDGj0UgHzp6puP1gK8IWT/YeG/GuRI6zTyH3eyvI2NETfMhgt1Ht9ZfShAljaW9rG63ZvpNauMsK4j1hiHXW+9Ig3ntyVJfejC7VjE2rH7sHY6MyIcH96c8ixeI5I7zct0g/rvMRGsTrzgHx6i0VIPrV3yVNDigBw2UOEvDvhBQ7SRDwBWJQ18KROSJePZuOKdR3k46hhi6Nd6GkH88MRPKCSNAMwDMAxpEIp3mxzuTpiIzXeFUJNsOpVGdI8Y9t6MrM6t7194UU9fUmybq6OrriiiuotbW3m1QwGCS/v/e5Zqs6XlfXjCCH00lOq5lc/iAFw9mrvXu5EhUV0HvHzaLNU0aT5ZCDKO+0E6jknlvJPLFWUYVXlJXS6NrxVDupO47AgUNJXciDLdQqesEMVmpFNMpmPqVzTHN/XLF3bJXG4dYh0s4NnJ7jdKaYQWsZYlVr/L5Xp/iJaV4D6uzUODyUVNxfBhKOcIL/7l84HUP6u0WNyFG1elorvbjrziHSrFqbTYxFPO0cPTc3NBic4FKEpcUtGqdWZbo+EFWJNzMDTW+bGm0M6makdBFY/gm1XX8HdT30T3L/4wW67LLL6JxzzqENGzb0IV2Pp+8Shcmktqdw61Ek3i5//9zA4iXejRs3UmvQT9ZzF1DxLVdR/g/OI1NN78hlqLNmdDdvwChi7BAbB+7dB9Juqhn38TrH5ulIvNuH2qDLBAj3g88yHOTWZ9l2idAKXjGdJzjS3Wj/EfHfSNtQLT9H1WzSOXa5COrRDf67RKha/zBEmlHrHUG/PmoAnhlsov6pcdiRFvFes2AJZs1w+lbEvVAoM4mxq6FHEt3d6VFiIKcDgyNPcdMJrFxDvnc+pNUrPuqlSlakaZZyk5EuYDSp43FspyETS6vuYE9+dyRAr7evoydbPqIPXdt5VpFO1CphWBWJ0KpVq8hqtdKMGTM0z4dqO2Gno6oh9t7DIjdZqDYssj+dw3pW6hw7hwf+2RrS7u06+VbQ0ITWDFwrlN5GHSn5SLHHbjpYpTO4nyUpcL/CmGGfyBQI0hHQIaenmGgRnWkxp49IjevwK9p3e+4OFPECt4jdhPbVe+xOWRmTLtYa4PBdaTYbFdLFDkWZwN0UoJA/QmabURkd6js85GUCrMq36675mseOpMDnPdLt3IIy+qBL1aqBgLGmGwppLw3GSs5zOLrl9YCIv1wfaKebdr5EraGe5bE5ztH085ELyGzQno/E4jRv3ryZOjs7adasWQr5al4Dn24292pm81B626GC5IEba4/Yuegk8TN2BDonlwEzuKw6nWD7aLM3+TgMfLAtIGZaMCyBf+xhOsW+PxjakK8bftzYZBxrH9hhZRHfr1fj3KtJO+B+vUbbuTgfNnOfo5FvER+HVfUHYqBGp1/G+RLXhhFl6wKNMu5GHckMpsSuQYhNjm0aazg9yOc9IrlSGzzQQxV5iSBUxAZ/G5suaJwL1aXWcsvuHElobq4H2pav65w2loaexi4GCA8/1TgG46iP+P4fF5oFqEU3cpt8kfAcsEaMHcqmi7FlIZ+zW+OZzeKPS7XeY3MK0sXDRtzDyvJqJ3ndQQp1BXqFjUwH0UiU2rd7qHxKj1YEBk5Q+8LSGRGkkvFv3mnH9yLe68fNoBWr3qQOn1dRL6eC3WhSHCcRnxkIspQamzL8sfHdXqQLfOLeSa+2r6HTSw7SkXiNyn68kHZBqAcddJD+vUfV/XvTmAUNZvKF2uRkHmARFs3Ifw+UocVTOhIs1AaZWNau5+v8dBCQ7gFC8o6tk34PxMe/v82f2EoMLgl+QViQTGfpFLdM59hzOsSLPvcjkWJoRFSshDbCFm/3a0wOsZa4ivO8LCRsDAIVYqJ0OPVeB36Yz9vNZS+SFKs5KC+LazNMtpr5d8T5XSsmRhi0qsVkV29yuTyHl3ZPCuIdylgsJp1aYWRnJb57/DweYmK9QnxXJv9x7xh2KbuPf/9QaAuaRPnF4hzYamhFK1xm1iFdzGJhrTWyrMpBJRV53cEzAgF96yoQc9MuD7U1+8gPv1/mnXUr99LYQ0tpypFlVDpalUDh0gN/WsRKRjQpGD9hTRTkBiI2jB9DhpJCijSylBsMkZ0J9KHq6XT5tk90rUmAKouNZtjzaVU4SB3tHd31xfCZJ3ms+zXehhTEa6CtW7dSe3s7zZw5k+x2fYNb+C93dfayWdkzVHuu1gbqOcRDpG4UnYsYv78ZJM32Q+prnIS12gUipQv0Gz1DN0iYN1P6xi5Y8kC0sYPjnm8DEya28dMK1mEXA046+KaQ7iWSDK9J+gQmMd/KsJw60t+xJ1Op9x0mEkx+z/+yNTjfm5fvDf39Jxlkw9r2q5wX/fjoJBNbg5h0Hp7h5Tyqt8aLme/cwhIblVaqRGkyq2IpdiRKhZrafJo6u0zZh7eiJo/83jCtXdJIz9+2jpb+cQt5O3okVlg8w+gKKujNLV20vrmDvmhSU+NF51PEH6Co16tEiRptzaNHJxxCRxeUa9Z9XGEF/W38XBplUu1Bmvc0Kp/euPVdhym54OltbqbmnXXKGm4yNLv99PHKlWQymXTXdmPwhyLU2NCLa2U0H21i36ujDsoEkBz+meKcyD66rdE5KucGvb2dRdv9KsMy5zDRJkoAN1JurMFrZI/WRK7UtdeL8JO5xA9IXc5JF4Nlv/F03udfCck0ExyX4/cY6un3jBrSLmbil+Q5LVRZ06MeNlvU01OFjcR58PUFUReV2mj0xEKadWQVjZ9WTFabibZ93EbP376O9m5P7WYZLiuhju+f2+u3crOV7hwzg56aeBhdXT2RziwdSWdzuoa/Pz3pMPrN6AOplM+ZIIi3btt2ijBpe+P21z0xP/lWoQc0m2jTJx/Sx/95merWriaf202GaISqPv0HTfvX+TT2kZPomPp/0bRqB0XM+lpjqJhR5/bN3VblO/eB1JgtQvuoLG8K8sVa8u/7UTfUt98S7jGpJMhkSGWsouf2lCzvlhy0J9ZM/5HGeWi3lzIoF7NfT0L7w7r8XOr/LjDv6Bzr1Cm/v6Svlz9VpCGtIBGuFPn0fKCTDXLbctAnHuAB/Nks7rM5hWSI/oBQlNdxatQ5FfYGPxPSe6bQI79Uba01fu5MQ+pF3ziHMttNKqZc3ZyDZ4axSdlv2ZiEdCHePgSvmamzS8lo7ll8NZkF8aYRvSoxwAZUx+Uj8mjGYRVUUmFXJN7X7t5E7Q2pA6L458ygzu+eQ4kLwbU2B51fNpquHzGZruV0Hn8fY+0JRDJdECPWeDesW99rrfWoehPNabdzA6hlFphs9NPqE+iseWfS2OkHkdlsoV2bN9Anbywiy79/SRWfPU0mf6eyaFsdaqTDNv6Ndu3aTltbXeQJJm+PrkBIqXPNqm7vkJyphfqBDzUGh89yKLnipdyqQXab08gPo6kfU+bRcrBGeZSQ/lLh5Qx/j+FtjcEBvyULZPAXyj6QR0TM0q9Ks90xs4SKF3G207GAfEnkSSwHEs98ym5ZBNeMfUnv0rlOnLNY4/Br/ex+y3T6TSpJTks1/moaGpagBkks0+gTwX70iV+mILzPNYgIef+TBkGFOcFNCBHVELTlSlJtL+4Q9eK3Wj7nt6Rvs6LlF75ehygXp7q8LPPF7g1jMGwp0tn3ORw3HmAt/eN+9EuMDceJqFdJTdQRuHtM7ZRiZYN7i6XnFLMgXq83nHXtkIInzSihqlFO8rtDtPShLWlZSXuPOpRar7+MwpXladdVXlNNI6tU750VH/TYIDTWbaO2XfX0regklpAvpkfHX0D/nPB9OqFoCllsNho5aSrNOfEUmnb4PCqvqqSJbX3b2xT0UMmmJQrpgnx3dnj6BOaA+ry9rU0h/TQH9X2BnyaZ8d3Ig2Fnjuu5PGFwQeNcnmyg1xicETULhjsP67zAsXKXcoKh0Dcy2KwBrlCJUuQXlELVLcq/MEHFBinhfD7WluR8WAceSqpVeLpqLhAHdog6mPP/bxrSe3x9AU4YKGeLAV5rgIOF82U65UBihWHY3SkkungJCBL3BM77PU6pJk1XJrk2WJU+159OxwMbJl03Jjl0Jx9bkyL7n5IM7GuFZKdXZ724n2hCn7gA1sJJzsdgdCzUjhlMyoJiYnkI57+VU1SPOEm1Tk/0s/wfPrY5g7YEAf+X04OcbuN0E6f7xW+x97g4U+0QAoSQamSYOA79go+lEgB+TmoI017dlTKIC851YDI0TYxR71NydTna7ociNnPsmo8XE5BM9smGoIM18xNF31QF0QRpF424w5ZnLjjo8ApFwPR5I+R1CaMqf5jqNqpteehxI9KKSgkhU8tjaOsX7bS3wUuHfXMUzTipOq27MITCZF/2EeW99yFZ6pJ4V3BlwdrR5J13GPkOP5hef/V1WvjEv3gSYaU7H7qX4A20+u3FZLZYaOaxJylEqweLp4WmPJvc1qRt8sm064geYQSuUZX5dip32JT15C2tXfTSMwtp0cIXYyqwkRiQEqyc9ykQUeuIY05Fp0M0HKgHFvI1LR2IurgeGO6g8WDd9wTXszzLcsyCSLA+UBH3YkCN+3F/dkbiso8WZUPF+nIahBHLNwZkL4j/FaGiTZXHIMgM1ntY54OVuDlOOtgtNA+farkbZXmPWC+Kn7EGhaV6uvnxksCydoZof4cgDKgtt3Nax+Vtz+K6YESHqEiwmF7BZSzJ1T2f/MieU0TZ6Hsv8aD3fJr5IF2cKu4V9/Q8DHPSzHug6BM+UeeONPJAYjxE1FdLqnFcgZC2MNjiOcFn/iMuryvDNoDEeqZ4Xos5f86t/LkOTJS0fLwP5DrX6uQdJ1S/uN8lQhpNp0600bdFe4EYn07caD7DezCKPhgfJKY52aQpLg8I63BxDZXUE/PZKzQduO+VXEbSyXYi8d4KRp8ys5SKylRCCgWj1NWuqlIRsWrLOlXFPveYajKatJkXls3rP22l0RMKqKw6L6kLEtyM1n7corwa5911UEbxnxWi63KTeVcDf7qUW4kU5lNo1AiKOHvUzfVr99Jvfn0DhcIBOuHkr9LUcVXk7minA75yDBVVpBPLIsrE+z0m4L7ay11fuYbaJn21z++wzo4wuTa1tNPPrvop+dWNG+7ggeUmdTKyf4lXQkJCIgekWyAmi/kaEno+E09AtlQS7oojXbD9ZTB+KiztkQLjIiQqRBsbuFOph1ubfORxBal6bD5986ppdO4102n20VUUzzkGJtrx04vI2xmkPRtcGV98pMBJgakTyXfILE4zKTBlQg/pcj3bl7XTljdcNL1GjQj27tI3lb16oUpOj3TVucnuwy+nqKG3S5a76kBqn5A8Gh/2+oXE+8xj/4yRLiSy38nuJiEhMURI1ZTGab8j7ZCVH0rS1Ua8Hy8cp6tHji/opRpOlGphsRwMhBXitehoaWP5PnqrgU65YALZ8kzU3OClhjqX4moUgyPfQuUjHLRlWQvVTCvIyU11Nvhp01st5GpSn/u0miNpa9On5PK30Rtvr6Af33J8RuV1jT6Mtpx6H5VsXkymgJs8FVNY0j2Jokbt+CP/ffcD+vD9bruKnyVb/5OQkJAYZISLYB4w3rLydwxgr5BqULgWRCoIGf6s15OqJtbC87I105B4SThNl5T3DQgRL/V2+/KmiF5VWmlXjLM8XUF69Z+qR8Vny5vJ5uhLVjUsFe/Z0EUrn9hNTevdFA1np4ptr/fR5y820qdPN3STrjJZMFrpK5POYtnVQNu2bKOH73uwT8znVPCVjqOGQ39E9Uf9lFqnLNAl3Q1r19HjD/9V+V5kGkOH5l9dKLuahITEICdd+KzCqBHjFYgAEgqMlj7h5OfjUEti3XFFCtLF2uhjskVTEK9wITqlqMzOEm3fNcD4dcGYS1GqsJFYrx01XpVg33lpB7386GZq3uWmopIe6/PYLkeQhguKrBTxhmn9f5pp2cM7acOSvQoJ+zq1XZcC7jC1bPPSlvda6cO/1dPq5/ZQ6/bkdhAVBWNp7rhTle9rV31Gf/rDfRTw514Tsu6zNfTAnX9QQloWOcto7mjYNhh+y218lexuEhISgxinpDieblS0O4XPrIQGYmIbZjb2ihHJt91U9gwQAmLMpShV2EiF7Goc1NHqV9Z731y4XfHfNce5J8XU0VBdFzIh2/KMZLUbye+NKKS7Z62r+zyr06RssgCEg1EKMkmH/JkFH5pcfSj5gl30ef3btHrlp3THLbfRpddeQ5XVudkwaMkrr9HCJ59WgnU47YV0+uEXUaGjjDaubuN28N3N5LvsvkXzV8puJyEhMQjhzkEZ2LnoDtmUaUi8pDoUU0Fxcl/o+DXfGHEG0yS9CdOLqbhcXQxG7OYNq1rJ6+4txVqsJsovsnbXZXcYqajUzGRsJke+iY8bKBKIUIClX1dzgLztwYxJN4aDRp9AB9d+TVE71+/YSbdfdxO9+sLLaW26oIX6uh101+2/pmcff1Ih3bLCEXT2vMsUiRf3M+HAYp48KLrp/5NdTkJCYpACYVb748YGt6cF/XHtGS5QKJUlsRVMqIfMmZdc8nN1hruJliU3atrlotIqB008oCitSmDJvGtbF+2uc3W7mCOUJCTg/EILS7mqAV2A6whB+i1NbrUF1XRHa24iGzZ0bKHlmxeSN6C6xmHP3GO/eiIdeezRVFxakjI/YjmvX7OO3lmylFZ9tLLbRWjq6IPpmBlfJ0tCOMmGHW7auVmJAzHv3ldO3G/b1Ul3IgkJCS2c/MieI0kNvDI1g2wgWmxwcguTrku2YhrjsNiFyFVZ4zDVTi1KSbzurgDt3t7JhGml6XPLUhJu/Djv7gzSzi2d1NmmvbYKQp4yq3TAiVch+pCPVu9cQpsbV1IkGu4mpjHjamn85Ik0cvRoKikrJZvNxvcSoc6OTtrb1Ex1W7fRhrVfkNvl6nWzpxz6XaopnkzhUIScBb0nDx0tQdqwWvEFfpCJ90pJvBISEoOUfDFIgIARDARBcBDoApsExNYiQQbw30UkMITh/BcT7i7ZcunDLGY2ppiqN/lgHZchFjbSnZoAG+vdVD3aSdjoB0U4WbrFjkXurqCy7tvZ6ievJ9RtZAUf4pHj8vfZzVvNdjpk3Gk0bcRRtGHPctra/KlCxiBWpHQQDodYUvdRMOinjqYw1X26mYxGE809aiw58229lAtQqQcD4aP35wPfn8E7JCQkhgQwSLwvUnr4gRxXMiVehDmjPKc5vQxijTccjlA0IgyvNNCyx6u4FJVV5SlSMwJTwXjKWWBREk1QrZ4hIQJGk5H2h0CWby+hg2tPodljT6LGzu20p30z7WndSS5/C4XI2y0Ng6idtiIqdBbThrpPKBQKKCpnrBePtR9P7fU2ctgLFOl49YqddMSxE5QgIcFAVNmtCSp1Jt6psttJSEhIDG/inRiTNtMB3IlAjhCcwiypmnXCPBaUWGnLunZFokWQDK87rISfRH74A6uRsFSJGoS8v7WgRoOJRhRNUFKjqYs62/w0aUbfTRnyC020p7mOmttV7coY+7E00nmwQrqqhsDEUrCBdte3U83oEvKIWNcmkzJLschuJyEhITF8ASaoVUghif+u3xeh9pYgBXyRPuQbL6lqYcSYfGV3o23rO2jjZ62KxW9RmYUcBSZFEjYx8Vq4XrvDpHwfXFCvB5JqItxdYZoyeq7yvcQykUbkzekm3VA4SD6/mwIhPzU1dJKro0eVLsqKyG4nISEhMbyJdxQiUyVuUICQkB4mmGgSmoipm7GBgh5ArtPnliuqZhhWYdOELWvamIgiissQksW2/yVdrWsHgv6+/sqQ9keXzFSlX1ONoorucrdRe1cLuTwd5At4mWTDLOEHe7WRKGub7HYSEhISwxdQNVfbHH21n3qbIMQMrLAJgrNQf23YZjfRhAOKh1zD2EWb4B5teb3vEbsq2aiERhbMpA7PVjIb8qjMMiUJeZvj2jNCfp9ikLZcdjsJCQmJ4U285VZr3/XdZKrnGKx2ztYZoG3r26luY7tirWvmBLWymSVFSMQgZ4SfhFoa0jRUyQZO+K4m4dpi6IkFHftb+U7q7kWJkmYkSRzneHUwvscsd+NVvCBLWFcrn9HY31HlHCXx97DyGen+Dehs81FJRU9Er71NHdSws4MQD2OS83QliJrX76Yd7nepxDKJHKYKMTmxKBJvMBBSCLijzR8rYqHsdhISEhLDm3jzk8VnBlE6C01MHhGV2OL4rpSJCMTU2e5TPv2+sJK+jAj4wwr5Fpaom0fAmttssigJBA/ShUuRK7KH9rhXUm3efBqZP4fsVodi3bxlYwNNmjqS2puxb7uycfsrsttJSEhIDG/idcInF2uRiQRstRmVBEvk+LVKSKIVNU4lBZhw6zYpO959wOkuTtArIxLHGZyOVa2XjaoUGlWlVvynlBaNSbLRbom2v+hZLzb0fDfEfu+xosZ/iJLFdWIV+35OG0ndNxepUyTc2AfNu92joHqG5bc9z0rBUKeyhuvze1h6VhfBgxEXjc07nkYVzCWbxS6uxUhBX5TqNu9lclbE+uvuWzQ/dC9JnzcJCQmJYUu8/oA3QC6yrvpgD1WPKSBslIDdguKhR4hxmx7sZVJ5EV+uWbAEC56/xzFHQT+8Z7heDwyUAgq5nUY9Dt2/5XRpntOiGGdli4jdRO7OgJHv7wj+86d8/X3ulO/lWyzxL921rcMyclwRFRY5mGyDLOH3hDT1RdrIaaqikY6DyWqxUTjCE5VQkAk6oFg5R7rCsHr+c6x9JCQkJCSGL4y+gKcdX7C+uXt7F61e3kSrP2ii+q0u6mwNKCrkUChjD5hfGwwGS0GxTfj9Zmm23Dubi4mrHYm/+3tLt1ncOEvtkGDzi5ToUodxOjvZeVzfe/xxfigYCe7c3M7Sv5/GTxrB+XsIv963jArNteQP+qijq4W63O2KChqkq7RtJNzEH1fI7iYhISEhYY5Go19Eo5HKUDik+J9aLXks4doUEt4dz4EG1X9XBIHoBtY8EyTEyfxxZmllHpVWOnpLmMLISdU6R7tdlWDxi/XinN0US9r5hTaF8FXVssrQBuE21WsiwNfi94SwzeEN/NezGuS7kO/rBL7+JxvrXaNA2GPGjiAvS715DivVbQlQXddSMhksVGwe3yd/OBx6nssIy+4mISEhIQEWfT8YCirq0TB8T/2uKKS1GAJBv1CZIiZxKOr3hTp83mDQ5w2Q1xNQ9tLFemcg6Ivppy8Gx8WMkRKlTJNZtXq2WEyKxKkkuym3N8X12OxmpWzF4tqi1mkyJZG++c+icsVq+WAm19laZQrJdzqnXwT84bb2vX7yu4zU0RymEuNUikRDtNnzCm33LiV/pLPXfIPTI7KrSUhISEjEiPcxf8DLUlm3QHYnrHSFpEYeXxe5vZ2K+rTT3foaE1Bxh6vl1g5XK/4G4SrGUR6fa4vIfxbiPsdveD/YgZ2WBM7UO4/vvYvTz/nrCE4L0FZ878+VWid/GDtnb3Atfe56jNa6ngAJw2f3uMfePf8T2dUkJCQkJAAzk8KmC49+6q8s8YJIbuO//8x/HxuJRA5H2MM4NHK6XHx/gNN3OU3DOqawUf6AJUZYUhXC0hluOOnGf97fcHV232dZOucz+SLDqyIpOGDWESv5Y476V5S8kRak2UzEH8huJiEhISERL/ECP2LCHQHSFX//zR/0KlvdCazmNI+P1+EP/oQu+jhOS0C8/oCvmb+/zIQEa6KvhsPRjvot7eTzqJJzMqtovz9IrXs7uY7QgN2c2+WjttYuJUSlFlqbPdS8W1Gtv8Xp2n5U90zC37jre9euWi7XdiUkJCQkeiReQaSJ5AD18zX8iZ3b/8bpST6nF0Py35CAv8rS8UzmGCP/7RfS4CqWfA9n8l20c0v7eIM5QC4mQGe+lcaMr1LWdndsa1J2/gECwQaqrikli9mes5uC2nzjup3U0e5WNi/YGW1Rdgkqryyi9lYX7axrwiWTw+GgSFCZezzJ6WK+9v5YeP2d1M2jobf+iNPjTLobZReTkJCQkIjHgG1PwORb7PZ2rrRZ8xQzX2weYLVamHjNLGbblJCLMNzCGjLgdDqpIL+gTzlQWYvwjccxMb4tyr4XHxZb312NsN7c2tbSLUkX5ZcpBlVYx87LN1FrS6fyN373BTzIcL/d5vxxMh/egYLcjF5CQkJimEu8A4H2rr1zmFzHB8Vm8QqJBoJMoghHib/8iiV1DG63m8wGmxLtKV1gt59gIlEHfb3U13CRijn8trd6BfGp8ZXF+ef6At7r8VV2BwkJCQmJgcb/CzAAgMnNiHBbpicAAAAASUVORK5CYII=';
63
+ ?>
64
+ <style type="text/css">
65
+ #monsterinsights-settings-area {
66
+ visibility: hidden;
67
+ animation: loadMonsterInsightsSettingsNoJSView 0s 2s forwards;
68
+ }
69
+
70
+ @keyframes loadMonsterInsightsSettingsNoJSView{
71
+ to { visibility: visible; }
72
+ }
73
+ </style>
74
+ <!--[if IE]>
75
+ <style>
76
+ #monsterinsights-settings-area{
77
+ visibility: visible !important;
78
+ }
79
+ </style>
80
+ <![endif]-->
81
+ <div id="<?php echo $id; ?>">
82
+ <div id="monsterinsights-settings-area" class="monsterinsights-settings-area mi-container" style="font-family:'Helvetica Neue', 'HelveticaNeue-Light', 'Helvetica Neue Light', Helvetica, Arial, 'Lucida Grande', sans-serif;margin: auto;width: 750px;max-width: 100%;">
83
+ <div id="monsterinsights-settings-error-loading-area">
84
+ <div class="" style="text-align: center; background-color: #fff;border: 1px solid #D6E2EC; padding: 15px 50px 30px; color: #777777; margin: <?php echo esc_attr( $margin ); ?>">
85
+ <div class="" style="border-bottom: 0;padding: 5px 20px 0;">
86
+ <img class="" src="<?php echo esc_attr( $inline_logo_image ); ?>" alt="" style="max-width: 100%;width: 240px;padding: 30px 0 15px;">
87
+ </div>
88
+ <div id="monsterinsights-error-js">
89
+ <h3 class="" style="font-size: 20px;color: #434343;font-weight: 500;line-height:1.4;"><?php esc_html_e( 'Ooops! It Appears JavaScript Didn’t Load', 'google-analytics-for-wordpress' ); ?></h3>
90
+ <p class="info" style="line-height: 1.5;margin: 1em 0;font-size: 16px;color: #434343;padding: 5px 20px 20px;"><?php esc_html_e( 'There seems to be an issue running JavaScript on your website, which MonsterInsights is crafted in to give you the best experience possible.', 'google-analytics-for-wordpress' ); ?></p>
91
+ <p class="info"style="line-height: 1.5;margin: 1em 0;font-size: 16px;color: #434343;padding: 5px 20px 20px;">
92
+ <?php
93
+ // Translators: Placeholders make the text bold.
94
+ printf( esc_html__( 'If you are using an %1$sad blocker%2$s, please disable or whitelist the current page to load MonsterInsights correctly.', 'google-analytics-for-wordpress' ), '<strong>', '</strong>' );
95
+ ?>
96
+ </p>
97
+ <div style="display: none" id="monsterinsights-nojs-error-message">
98
+ <div class="" style=" border: 1px solid #E75066;
99
+ border-left: 3px solid #E75066;
100
+ background-color: #FEF8F9;
101
+ color: #E75066;
102
+ font-size: 14px;
103
+ padding: 18px 18px 18px 21px;
104
+ font-weight: 300;
105
+ text-align: left;">
106
+ <strong style="font-weight: 500;" id="monsterinsights-alert-message"></strong>
107
+ </div>
108
+ <p class="" style="font-size: 14px;color: #777777;padding-bottom: 15px;"><?php esc_html_e( 'Copy the error message above and paste it in a message to the MonsterInsights support team.', 'google-analytics-for-wordpress' ); ?></p>
109
+ </div>
110
+ <a href="https://www.monsterinsights.com/docs/fix-javascript-error" target="_blank" style="margin-left: auto;background-color: #54A0E0;border-color: #3380BC;border-bottom-width: 2px;color: #fff;border-radius: 3px;font-weight: 500;transition: all 0.1s ease-in-out;transition-duration: 0.2s;padding: 14px 35px;font-size: 16px;margin-top: 10px;margin-bottom: 20px; text-decoration: none; display: inline-block;">
111
+ <?php esc_html_e( 'Resolve This Issue', 'google-analytics-for-wordpress' ); ?>
112
+ </a>
113
+ </div>
114
+ <div id="monsterinsights-error-browser" style="display: none">
115
+ <h3 class="" style="font-size: 20px;color: #434343;font-weight: 500;"><?php esc_html_e( 'Your browser version is not supported', 'google-analytics-for-wordpress' ); ?></h3>
116
+ <p class="info" style="line-height: 1.5;margin: 1em 0;font-size: 16px;color: #434343;padding: 5px 20px 20px;"><?php esc_html_e( 'You are using a browser which is no longer supported by MonsterInsights. Please update or use another browser in order to access the plugin settings.', 'google-analytics-for-wordpress' ); ?></p>
117
+ <a href="https://www.monsterinsights.com/docs/browser-support-policy/" target="_blank" style="margin-left: auto;background-color: #54A0E0;border-color: #3380BC;border-bottom-width: 2px;color: #fff;border-radius: 3px;font-weight: 500;transition: all 0.1s ease-in-out;transition-duration: 0.2s;padding: 14px 35px;font-size: 16px;margin-top: 10px;margin-bottom: 20px; text-decoration: none; display: inline-block;">
118
+ <?php esc_html_e( 'View supported browsers', 'google-analytics-for-wordpress' ); ?>
119
+ </a>
120
+ </div>
121
+ </div>
122
+ </div>
123
+ <div style="text-align: center;">
124
+ <?php echo wp_kses_post( $footer ); ?>
125
+ </div>
126
+ </div>
127
+ </div>
128
+ <?php
129
+ }
includes/admin/pages/tools.php CHANGED
@@ -1,44 +1,44 @@
1
- <?php
2
- // Exit if accessed directly
3
- if ( ! defined( 'ABSPATH' ) ) {
4
- exit;
5
- }
6
-
7
- /**
8
- * MonsterInsights settings export.
9
- *
10
- * @since 6.0.0
11
- * @access public
12
- *
13
- * @return void
14
- */
15
- function monsterinsights_process_export_settings() {
16
- if ( ! isset( $_POST['monsterinsights_action'] ) || empty( $_POST['monsterinsights_action'] ) ) {
17
- return;
18
- }
19
-
20
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
21
- return;
22
- }
23
-
24
- if ( 'monsterinsights_export_settings' !== $_POST['monsterinsights_action'] ) {
25
- return;
26
- }
27
-
28
- if ( empty( $_POST['monsterinsights_export_settings'] ) || ! wp_verify_nonce( $_POST['monsterinsights_export_settings'], 'mi-admin-nonce' ) ) {
29
- return;
30
- }
31
-
32
- $settings = monsterinsights_export_settings();
33
- ignore_user_abort( true );
34
-
35
- nocache_headers();
36
- header( 'Content-Type: application/json; charset=utf-8' );
37
- header( 'Content-Disposition: attachment; filename=monsterinsights-settings-export-' . date( 'm-d-Y' ) . '.json' );
38
- header( "Expires: 0" );
39
-
40
- echo $settings;
41
- exit;
42
- }
43
-
44
- add_action( 'admin_init', 'monsterinsights_process_export_settings' );
1
+ <?php
2
+ // Exit if accessed directly
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ /**
8
+ * MonsterInsights settings export.
9
+ *
10
+ * @since 6.0.0
11
+ * @access public
12
+ *
13
+ * @return void
14
+ */
15
+ function monsterinsights_process_export_settings() {
16
+ if ( ! isset( $_POST['monsterinsights_action'] ) || empty( $_POST['monsterinsights_action'] ) ) {
17
+ return;
18
+ }
19
+
20
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
21
+ return;
22
+ }
23
+
24
+ if ( 'monsterinsights_export_settings' !== $_POST['monsterinsights_action'] ) {
25
+ return;
26
+ }
27
+
28
+ if ( empty( $_POST['monsterinsights_export_settings'] ) || ! wp_verify_nonce( $_POST['monsterinsights_export_settings'], 'mi-admin-nonce' ) ) {
29
+ return;
30
+ }
31
+
32
+ $settings = monsterinsights_export_settings();
33
+ ignore_user_abort( true );
34
+
35
+ nocache_headers();
36
+ header( 'Content-Type: application/json; charset=utf-8' );
37
+ header( 'Content-Disposition: attachment; filename=monsterinsights-settings-export-' . date( 'm-d-Y' ) . '.json' );
38
+ header( "Expires: 0" );
39
+
40
+ echo $settings;
41
+ exit;
42
+ }
43
+
44
+ add_action( 'admin_init', 'monsterinsights_process_export_settings' );
includes/admin/reporting.php CHANGED
@@ -1,68 +1,68 @@
1
- <?php
2
- /**
3
- * MonsterInsights Reporting.
4
- *
5
- * Handles aggregating data.
6
- *
7
- * @since 7.0.0
8
- *
9
- * @package MonsterInsights
10
- * @subpackage GA Reporting
11
- * @author Chris Christoff
12
- */
13
-
14
- // Exit if accessed directly
15
- if ( ! defined( 'ABSPATH' ) ) {
16
- exit;
17
- }
18
-
19
- final class MonsterInsights_Reporting {
20
-
21
- public $reports = array();
22
-
23
- public function __construct( ) {
24
-
25
- }
26
-
27
- public function add_report( $report = false ){
28
- if ( empty( $report ) || ! is_object( $report ) ) {
29
- return;
30
- }
31
-
32
- if ( version_compare( $report->version, '1.0.0', '<' ) ) {
33
- return;
34
- }
35
-
36
- $this->reports[] = $report;
37
- }
38
-
39
- public function get_aggregate_data() {
40
- if ( ! empty( $this->reports ) ) {
41
- foreach ( $this->reports as $report ) {
42
- $report->get_data( array( 'default' => true ) );
43
- }
44
- }
45
- }
46
-
47
- // $where possible values: auto, site, network, both
48
- public function delete_aggregate_data( $where = 'site' ) {
49
- if ( ! empty( $this->reports ) ) {
50
- foreach ( $this->reports as $report ) {
51
- $report->delete_cache( $where );
52
- }
53
- }
54
- }
55
-
56
- public function get_report( $name = '' ) {
57
- if ( empty( $name ) || empty( $this->reports ) ) {
58
- return false;
59
- }
60
-
61
- foreach ( $this->reports as $report ) {
62
- if ( $name === $report->name ) {
63
- return $report;
64
- }
65
- }
66
- return false;
67
- }
68
  }
1
+ <?php
2
+ /**
3
+ * MonsterInsights Reporting.
4
+ *
5
+ * Handles aggregating data.
6
+ *
7
+ * @since 7.0.0
8
+ *
9
+ * @package MonsterInsights
10
+ * @subpackage GA Reporting
11
+ * @author Chris Christoff
12
+ */
13
+
14
+ // Exit if accessed directly
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit;
17
+ }
18
+
19
+ final class MonsterInsights_Reporting {
20
+
21
+ public $reports = array();
22
+
23
+ public function __construct( ) {
24
+
25
+ }
26
+
27
+ public function add_report( $report = false ){
28
+ if ( empty( $report ) || ! is_object( $report ) ) {
29
+ return;
30
+ }
31
+
32
+ if ( version_compare( $report->version, '1.0.0', '<' ) ) {
33
+ return;
34
+ }
35
+
36
+ $this->reports[] = $report;
37
+ }
38
+
39
+ public function get_aggregate_data() {
40
+ if ( ! empty( $this->reports ) ) {
41
+ foreach ( $this->reports as $report ) {
42
+ $report->get_data( array( 'default' => true ) );
43
+ }
44
+ }
45
+ }
46
+
47
+ // $where possible values: auto, site, network, both
48
+ public function delete_aggregate_data( $where = 'site' ) {
49
+ if ( ! empty( $this->reports ) ) {
50
+ foreach ( $this->reports as $report ) {
51
+ $report->delete_cache( $where );
52
+ }
53
+ }
54
+ }
55
+
56
+ public function get_report( $name = '' ) {
57
+ if ( empty( $name ) || empty( $this->reports ) ) {
58
+ return false;
59
+ }
60
+
61
+ foreach ( $this->reports as $report ) {
62
+ if ( $name === $report->name ) {
63
+ return $report;
64
+ }
65
+ }
66
+ return false;
67
+ }
68
  }
includes/admin/reports/abstract-report.php CHANGED
@@ -1,439 +1,456 @@
1
- <?php
2
- /**
3
- * Report Abstract
4
- *
5
- * Ensures all of the reports have a uniform class with helper functions.
6
- *
7
- * @since 6.0.0
8
- *
9
- * @package MonsterInsights
10
- * @subpackage Reports
11
- * @author Chris Christoff
12
- */
13
-
14
- // Exit if accessed directly
15
- if ( ! defined( 'ABSPATH' ) ) {
16
- exit;
17
- }
18
-
19
- class MonsterInsights_Report {
20
-
21
- public $title;
22
- public $class;
23
- public $name;
24
- public $version = '1.0.0';
25
-
26
- /**
27
- * Primary class constructor.
28
- *
29
- * @access public
30
- * @since 6.0.0
31
- */
32
- public function __construct() {
33
- add_filter( 'monsterinsights_reports_abstract_get_data_pre_cache', array( $this, 'requirements' ), 10, 3 );
34
- }
35
-
36
- // Let's get the HTML to output for a particular report. This is not the AJAX endpoint. Args can hold things (generally start/end date range)
37
- protected function get_report_html( $args = array() ) {
38
- /* Defined in the report class */
39
- // For ajax, args start, end, and data will be set with the data to use. Else call $this->get_data( array( 'default' => true ) )
40
- return '';
41
- }
42
-
43
- public function additional_data() {
44
- return array();
45
- }
46
-
47
- public function requirements( $error = false, $args = array(), $name = '' ) {
48
- return $error;
49
- }
50
-
51
- public function show_report( $args = array() ) {
52
-
53
- if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) {
54
- return monsterinsights_get_message( 'error', esc_html__( 'Access denied', 'google-analytics-for-wordpress' ) );
55
- }
56
-
57
- if ( monsterinsights_get_option( 'dashboard_disabled', false ) ) {
58
- if ( current_user_can( 'monsterinsights_save_settings' ) ) {
59
- $url = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_settings' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
60
-
61
- return monsterinsights_get_message( 'error',
62
- sprintf(
63
- esc_html__( 'Please %1$senable the dashboard%2$s to see report data.', 'google-analytics-for-wordpress' ),
64
- '<a href="' . $url . '">',
65
- '</a>'
66
- )
67
- );
68
- } else {
69
- return monsterinsights_get_message( 'error', esc_html__( 'The dashboard is disabled.', 'google-analytics-for-wordpress' ) );
70
- }
71
- }
72
-
73
- if ( monsterinsights_is_pro_version() ) {
74
- if ( ! MonsterInsights()->license->has_license() ) {
75
- $url = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_settings' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
76
-
77
- return monsterinsights_get_message( 'error', esc_html__( 'You do not have an active license. Please %1$scheck your license configuration.%2$s', 'google-analytics-for-wordpress' ), '<a href="' . $url . '">', '</a>' );
78
- } else if ( MonsterInsights()->license->license_has_error() ) {
79
- return monsterinsights_get_message( 'error', $this->get_license_error() );
80
- }
81
- }
82
-
83
- if ( ! ( MonsterInsights()->auth->is_authed() || MonsterInsights()->auth->is_network_authed() ) ) {
84
- if ( current_user_can( 'monsterinsights_save_settings' ) ) {
85
- $url = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_settings' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
86
-
87
- return monsterinsights_get_message( 'error',
88
- sprintf(
89
- esc_html__( 'Please %1$sauthenticate %2$swith Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ),
90
- '<a href="' . $url . '">',
91
- '</a>'
92
- )
93
- );
94
- } else {
95
- return monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) );
96
- }
97
- }
98
-
99
- if ( monsterinsights_is_pro_version() ) {
100
- if ( ! MonsterInsights()->license->license_can( $this->level ) ) {
101
- return $this->get_upsell_notice();
102
- }
103
- }
104
-
105
- $error = $this->requirements( false, array(), $this->name );
106
-
107
- if ( ! empty( $error ) ) {
108
- return monsterinsights_get_message( 'error', $error );
109
- }
110
-
111
- if ( ! empty( $args['error'] ) ) {
112
- return monsterinsights_get_message( 'error', $args['error'] );
113
- }
114
-
115
- if ( empty( $args['data'] ) || ! is_array( $args['data'] ) ) {
116
- if ( monsterinsights_is_pro_version() ) {
117
- return '';
118
- } else {
119
- // Try to get default data.
120
- $args = $this->get_data( array( 'default' => true ) );
121
- if ( empty( $args['data'] ) || is_array( $args['data'] ) ) {
122
- return monsterinsights_get_message( 'error', __( 'No data found', 'google-analytics-for-wordpress' ) );
123
- }
124
-
125
- if ( ! empty( $args['error'] ) ) {
126
- return monsterinsights_get_message( 'error', $args['error'] );
127
- }
128
- }
129
- }
130
-
131
- return $this->get_report_html( $args['data'] );
132
- }
133
-
134
- // Deletes the report data from the cache
135
- public function delete_cache( $where = 'site' ) {
136
-
137
- if ( $where === 'site' || $where === 'both' ) {
138
- delete_option( 'monsterinsights_report_data_' . $this->name );
139
- }
140
-
141
- if ( $where === 'network' || $where === 'both' ) {
142
- delete_option( 'monsterinsights_network_report_data_' . $this->name );
143
- }
144
- }
145
-
146
- // Get report data
147
- public function get_data( $args = array() ) {
148
-
149
- if ( ! empty( $args['default'] ) ) {
150
- $args['start'] = $this->default_start_date();
151
- $args['end'] = $this->default_end_date();
152
- }
153
-
154
- $start = ! empty( $args['start'] ) && $this->is_valid_date( $args['start'] ) ? $args['start'] : '';
155
- $end = ! empty( $args['end'] ) && $this->is_valid_date( $args['end'] ) ? $args['end'] : '';
156
-
157
- if ( monsterinsights_is_pro_version() && ! MonsterInsights()->license->license_can( $this->level ) ) {
158
- return array(
159
- 'success' => true,
160
- 'upgrade' => true,
161
- 'data' => array(),
162
- );
163
- }
164
-
165
- if ( ! $this->is_valid_date_range( $start, $end ) ) {
166
- return array(
167
- 'success' => false,
168
- 'error' => __( 'Invalid date range.', 'google-analytics-for-wordpress' ),
169
- 'data' => array(),
170
- );
171
- }
172
-
173
- if ( ( $start !== $this->default_start_date() || $end !== $this->default_end_date() ) && ! monsterinsights_is_pro_version() ) {
174
- $start = $this->default_start_date();
175
- $end = $this->default_end_date();
176
- // return array(
177
- // 'success' => false,
178
- // 'error' => __( 'Please upgrade to MonsterInsights Pro to use custom date ranges.', 'google-analytics-for-wordpress' ),
179
- // 'data' => array(),
180
- // );
181
- }
182
-
183
- $error = apply_filters( 'monsterinsights_reports_abstract_get_data_pre_cache', false, $args, $this->name );
184
- if ( $error ) {
185
- return apply_filters( 'monsterinsights_reports_handle_error_message', array(
186
- 'success' => false,
187
- 'error' => $error,
188
- 'data' => array(),
189
- ) );
190
- }
191
-
192
- $check_cache = ( $start === $this->default_start_date() && $end === $this->default_end_date() ) || apply_filters( 'monsterinsights_report_use_cache', false, $this->name );
193
- $site_auth = MonsterInsights()->auth->get_viewname();
194
- $ms_auth = is_multisite() && MonsterInsights()->auth->get_network_viewname();
195
- $transient = 'monsterinsights_report_' . $this->name . '_' . $start . '_' . $end;
196
- // Set to same time as MI cache. MI caches same day to 15 and others to 1 day, so there's no point pinging MI before then.
197
- $expiration = $end === date( 'Y-m-d' ) ? apply_filters( 'monsterinsights_report_transient_expiration', 15 * MINUTE_IN_SECONDS, $this->name ) : DAY_IN_SECONDS;
198
-
199
- // Default date range, check
200
- if ( $site_auth || $ms_auth ) {
201
- // Single site or MS with auth at subsite
202
- $option_name = $site_auth ? 'monsterinsights_report_data_' . $this->name : 'monsterinsights_network_report_data_' . $this->name;
203
- $p = $site_auth ? MonsterInsights()->auth->get_viewid() : MonsterInsights()->auth->get_network_viewid();
204
-
205
- $data = array();
206
- if ( $check_cache ) {
207
- $data = ! $site_auth && $ms_auth ? get_site_option( $option_name, array() ) : get_option( $option_name, array() );
208
- } else {
209
- $data = ! $site_auth && $ms_auth ? get_site_transient( $transient ) : get_transient( $transient );
210
- }
211
-
212
- if ( ! empty( $data ) &&
213
- ! empty( $data['expires'] ) &&
214
- $data['expires'] >= time() &&
215
- ! empty( $data['data'] ) &&
216
- ! empty( $data['p'] ) &&
217
- $data['p'] === $p
218
- ) {
219
- return array(
220
- 'success' => true,
221
- 'data' => $data['data'],
222
- );
223
- }
224
-
225
- // Nothing in cache, either not saved before, expired or mismatch. Let's grab from API
226
- $api_options = array( 'start' => $start, 'end' => $end );
227
- if ( ! $site_auth && $ms_auth ) {
228
- $api_options['network'] = true;
229
- }
230
-
231
- $api = new MonsterInsights_API_Request( 'analytics/reports/' . $this->name . '/', $api_options, 'GET' );
232
-
233
- $additional_data = $this->additional_data();
234
-
235
- if ( ! empty( $additional_data ) ) {
236
- $api->set_additional_data( $additional_data );
237
- }
238
-
239
- $ret = $api->request();
240
-
241
- if ( is_wp_error( $ret ) ) {
242
- return array(
243
- 'success' => false,
244
- 'error' => $ret->get_error_message(),
245
- 'data' => array(),
246
- );
247
- } else {
248
- // Success
249
- $data = array(
250
- 'expires' => $expiration,
251
- 'p' => $p,
252
- 'data' => $ret['data'],
253
- );
254
-
255
- if ( $check_cache ) {
256
- ! $site_auth && $ms_auth ? update_site_option( $option_name, $data ) : update_option( $option_name, $data );
257
- } else {
258
- ! $site_auth && $ms_auth ? set_site_transient( $option_name, $data, $expiration ) : set_transient( $option_name, $data, $expiration );
259
- }
260
-
261
- return $this->prepare_report_data( array(
262
- 'success' => true,
263
- 'data' => $ret['data'],
264
- ) );
265
- }
266
-
267
- } else {
268
- return array(
269
- 'success' => false,
270
- 'error' => __( 'You must authenticate with MonsterInsights to use reports.', 'google-analytics-for-wordpress' ),
271
- 'data' => array(),
272
- );
273
- }
274
- }
275
-
276
- public function default_start_date() {
277
- return date( 'Y-m-d', strtotime( '-30 days' ) );
278
- }
279
-
280
- public function default_end_date() {
281
- return date( 'Y-m-d', strtotime( '-1 day' ) );
282
- }
283
-
284
- // Checks to see if date range is valid. Should be 30-yesterday always for lite & any valid date range to today for Pro.
285
- public function is_valid_date_range( $start, $end ) {
286
- $start = strtotime( $start );
287
- $end = strtotime( $end );
288
-
289
- if ( $start > strtotime( 'now' ) || $end > strtotime( 'now' ) || $start < strtotime( '01 January 2005' ) || $end < strtotime( '01 January 2005' ) ) {
290
- return false;
291
- }
292
-
293
- // return false if the start date is after the end date
294
- return ( $start > $end ) ? false : true;
295
- }
296
-
297
- // Is a valid date value
298
- public function is_valid_date( $date = '' ) {
299
- $d = MonsterInsightsDateTime::createFromFormat( 'Y-m-d', $date );
300
-
301
- return $d && $d->format( 'Y-m-d' ) === $date;
302
- }
303
-
304
- /**
305
- * Do not use the functions below this. They are unused and are just here so people
306
- * with out of date MonsterInsights addons won't get fatal errors.
307
- */
308
- protected function get_api_max_limit() {
309
- return 300;
310
- }
311
-
312
- protected function get_date_range() {
313
- return array();
314
- }
315
-
316
- public function get_upsell_notice() {
317
- $has_level = monsterinsights_is_pro_version() ? MonsterInsights()->license->get_license_type() : false;
318
- $has_level = $has_level ? $has_level : 'lite';
319
- $message = sprintf( __( 'You currently have a %s level license, but this report requires at least a %s level license to view the %s. Please upgrade to view this report.', 'google-analytics-for-wordpress' ), $has_level, $this->level, $this->title );
320
- ob_start(); ?>
321
- <div class="monsterinsights-upsell-report-container monsterinsights-upsell-report-<?php echo $this->name; ?>-bg">
322
- <div class="monsterinsights-upsell-container">
323
- <div class="row justify-content-center">
324
- <div class="col-lg-10 col-lg-offset-1 align-self-center">
325
- <div class="monsterinsights-upsell-card">
326
- <img class="monsterinsights-upgrade-mascot"
327
- src="<?php echo trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ); ?>assets/css/images/mascot.png"
328
- srcset="<?php echo trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ); ?>assets/css/images/mascot@2x.png 2x"
329
- alt="">
330
- <div class="monsterinsights-upsell-card-card-content">
331
- <span class="monsterinsights-upsell-card-title"><?php esc_html_e( 'Ready to Get Analytics Super-Powers?', 'google-analytics-for-wordpress' ); ?></span>
332
- <p class="monsterinsights-upsell-card-subtitle">
333
- <strong><?php esc_html_e( '(And Crush Your Competition?)', 'google-analytics-for-wordpress' ); ?></strong>
334
- </p> &nbsp;
335
- <?php if ( monsterinsights_is_pro_version() ) { ?>
336
- <p><?php echo sprintf( esc_html__( "Hey there! It looks like you've got the %s license installed on your site.
337
- That's awesome! %s", 'google-analytics-for-wordpress' ), $has_level, '<span class="dashicons dashicons-smiley"></span>' ); ?></p>
338
- &nbsp;
339
- <p><?php echo sprintf( esc_html__( "Do you want to access to %s reporting right now%s in your WordPress Dashboard? That comes with the %s level%s of our paid packages. You'll need to upgrade your license to get instant access.", 'google-analytics-for-wordpress' ), '<strong>' . $this->title, '</strong>', '<strong><a href="' . monsterinsights_get_url( 'reports-page', $this->name . '-report-upsell-license-link', 'https://monsterinsights.com/my-account/' ) . '">' . $this->level, '</a></strong>' ); ?></p>
340
- &nbsp;
341
- <p><?php echo sprintf( esc_html__( "It's easy! To upgrade, navigate to %sMy Account%s on MonsterInsights.com, go to the licenses tab, and click upgrade. We also have a %sstep by step guide%s with pictures of this process.", 'google-analytics-for-wordpress' ), '<a href="' . monsterinsights_get_url( 'reports-page', $this->name . '-report-upsell-license-link', 'https://monsterinsights.com/my-account/' ) . '"><strong>', '</strong></a>', '<a href="' . monsterinsights_get_url( 'reports-page', $this->name . '-report-upsell-license-link', 'https://www.monsterinsights.com/docs/upgrade-monsterinsights-license/' ) . '" style="text-decoration:underline !important">', '</a>' ); ?></p>
342
- &nbsp;
343
- <p><?php esc_html_e( "If you have any questions, don't hesitate to reach out. We're here to help.", 'google-analytics-for-wordpress' ); ?></p>
344
- <?php } else { ?>
345
- <p><?php echo sprintf( esc_html__( "Hey there! %s It looks like you've got the free version of MonsterInsights installed on your site.
346
- That's awesome!", 'google-analytics-for-wordpress' ), '<span class="dashicons dashicons-smiley"></span>' ); ?></p>
347
- &nbsp;
348
- <p><?php echo sprintf( esc_html__( "Do you you want to access to %s reporting right now%s in your WordPress Dashboard? That comes with %s level%s of our paid packages. To get instant access, you'll want to buy a MonsterInsights license, which also gives you access to powerful addons, expanded reporting (including the ability to use custom date ranges), comprehensive tracking features (like UserID tracking) and access to our world-class support team.", 'google-analytics-for-wordpress' ), '<strong>' . $this->title, '</strong>', '<a href="' . monsterinsights_get_upgrade_link( 'reports-page', $this->name . '-report-upsell-license-link' ) . '">' . $this->level, '</a>' ); ?></p>
349
- &nbsp;
350
- <p><?php echo sprintf( esc_html__( "Upgrading is easy! To upgrade, navigate to %sour pricing page%s, purchase the required license, and then follow the %sinstructions in the email receipt%s to upgrade. It only takes a few minutes to unlock the most powerful, yet easy to use analytics tracking system for WordPress.", 'google-analytics-for-wordpress' ), '<a href="' . monsterinsights_get_upgrade_link( 'reports-page', $this->name . '-report-upsell-license-link' ) . '"><strong>', '</strong></a>', '<a style="text-decoration:underline !important" href="' . monsterinsights_get_url( 'reports-page', $this->name . '-report-go-lite-pro-link', 'https://www.monsterinsights.com/docs/go-lite-pro/' ) . '">', '</a>' ); ?></p>
351
- &nbsp;
352
- <p><?php esc_html_e( "If you have any questions, don't hesitate to reach out. We're here to help.", 'google-analytics-for-wordpress' ); ?></p>
353
- <?php } ?>
354
- </div>
355
- <div class="monsterinsights-upsell-card-action">
356
- <?php if ( monsterinsights_is_pro_version() ) { ?>
357
- <a href="<?php echo monsterinsights_get_upgrade_link( 'reports-page', $this->name . '-report-upsell-license-link' ); ?>"
358
- class="monsterinsights-upsell-card-button"><?php esc_html_e( 'Upgrade Now', 'google-analytics-for-wordpress' ); ?></a>
359
- <?php } else { ?>
360
- <a href="<?php echo monsterinsights_get_url( 'reports-page', $this->name . '-report-upsell-license-link', 'https://www.monsterinsights.com/docs/upgrade-monsterinsights-license/' ); ?>"
361
- class="monsterinsights-upsell-card-button"><?php esc_html_e( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ); ?></a>
362
- <?php } ?>
363
- </div>
364
- </div>
365
- </div>
366
- </div>
367
- </div>
368
- </div>
369
- </div>
370
- <?php
371
- return ob_get_clean();
372
- }
373
-
374
- function get_ga_report_range( $data = array() ) {
375
- if ( empty( $data['reportcurrentrange'] ) || empty( $data['reportcurrentrange']['startDate'] ) || empty( $data['reportcurrentrange']['endDate'] ) ) {
376
- return '';
377
- } else {
378
- if ( ! empty( $data['reportprevrange'] ) && ! empty( $data['reportprevrange']['startDate'] ) && ! empty( $data['reportprevrange']['endDate'] ) ) {
379
- return urlencode( '_u.date00=' . str_replace( '-', '', $data['reportcurrentrange']['startDate'] ) . '&_u.date01=' . str_replace( '-', '', $data['reportcurrentrange']['endDate'] ) . '&_u.date10=' . str_replace( '-', '', $data['reportprevrange']['startDate'] ) . '&_u.date11=' . str_replace( '-', '', $data['reportprevrange']['endDate'] ) );
380
- } else {
381
- return urlencode( '_u.date00=' . str_replace( '-', '', $data['reportcurrentrange']['startDate'] ) . '&_u.date01=' . str_replace( '-', '', $data['reportcurrentrange']['endDate'] ) );
382
- }
383
- }
384
- }
385
-
386
- /**
387
- * Grab the link to the addons page used in each report's error message.
388
- *
389
- * @return string
390
- */
391
- public function get_addons_page_link() {
392
- if ( current_user_can( 'install_plugins' ) ) {
393
- $addons_link = 'install_addon';
394
- } else {
395
- $addons_link = esc_html__( 'Please ask your webmaster to enable this addon.', 'google-analytics-for-wordpress' );
396
- }
397
-
398
- return $addons_link;
399
- }
400
-
401
- /**
402
- * When called will add the footer link to be displayed in the error popup.
403
- *
404
- * @param array $data The data sent as error response to the ajax call.
405
- *
406
- * @return array
407
- */
408
- public function add_error_addon_link( $data ) {
409
- $data['data']['footer'] = $this->get_addons_page_link();
410
-
411
- return $data;
412
- }
413
-
414
- /**
415
- * Added to allow individual reports to alter data when outputting for Vue reports.
416
- *
417
- * @param $data
418
- *
419
- * @return mixed
420
- */
421
- public function prepare_report_data( $data ) {
422
- return $data;
423
- }
424
- }
425
-
426
- if ( ! class_exists( 'MonsterInsightsDateTime' ) ) {
427
- class MonsterInsightsDateTime extends DateTime {
428
- public static function createFromFormat( $format, $time, $timezone = null ) {
429
- if ( ! $timezone ) {
430
- $timezone = new DateTimeZone( date_default_timezone_get() );
431
- }
432
- if ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
433
- return parent::createFromFormat( $format, $time, $timezone );
434
- }
435
-
436
- return new DateTime( date( $format, strtotime( $time ) ), $timezone );
437
- }
438
- }
439
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Report Abstract
4
+ *
5
+ * Ensures all of the reports have a uniform class with helper functions.
6
+ *
7
+ * @since 6.0.0
8
+ *
9
+ * @package MonsterInsights
10
+ * @subpackage Reports
11
+ * @author Chris Christoff
12
+ */
13
+
14
+ // Exit if accessed directly
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit;
17
+ }
18
+
19
+ class MonsterInsights_Report {
20
+
21
+ public $title;
22
+ public $class;
23
+ public $name;
24
+ public $version = '1.0.0';
25
+
26
+ /**
27
+ * Primary class constructor.
28
+ *
29
+ * @access public
30
+ * @since 6.0.0
31
+ */
32
+ public function __construct() {
33
+ add_filter( 'monsterinsights_reports_abstract_get_data_pre_cache', array( $this, 'requirements' ), 10, 3 );
34
+ }
35
+
36
+ // Let's get the HTML to output for a particular report. This is not the AJAX endpoint. Args can hold things (generally start/end date range)
37
+ protected function get_report_html( $args = array() ) {
38
+ /* Defined in the report class */
39
+ // For ajax, args start, end, and data will be set with the data to use. Else call $this->get_data( array( 'default' => true ) )
40
+ return '';
41
+ }
42
+
43
+ public function additional_data() {
44
+ return array();
45
+ }
46
+
47
+ public function requirements( $error = false, $args = array(), $name = '' ) {
48
+ return $error;
49
+ }
50
+
51
+ public function show_report( $args = array() ) {
52
+
53
+ if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) {
54
+ return monsterinsights_get_message( 'error', esc_html__( 'Access denied', 'google-analytics-for-wordpress' ) );
55
+ }
56
+
57
+ if ( monsterinsights_get_option( 'dashboard_disabled', false ) ) {
58
+ if ( current_user_can( 'monsterinsights_save_settings' ) ) {
59
+ $url = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_settings' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
60
+ // Translators: Placeholders add a link to the settings panel.
61
+ return monsterinsights_get_message( 'error', sprintf( esc_html__( 'Please %1$senable the dashboard%2$s to see report data.', 'google-analytics-for-wordpress' ), '<a href="' . $url . '">', '</a>' ) );
62
+ } else {
63
+ return monsterinsights_get_message( 'error', esc_html__( 'The dashboard is disabled.', 'google-analytics-for-wordpress' ) );
64
+ }
65
+ }
66
+
67
+ if ( monsterinsights_is_pro_version() ) {
68
+ if ( ! MonsterInsights()->license->has_license() ) {
69
+ $url = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_settings' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
70
+ // Translators: Placeholders add a link to the settings panel.
71
+ return monsterinsights_get_message( 'error', esc_html__( 'You do not have an active license. Please %1$scheck your license configuration.%2$s', 'google-analytics-for-wordpress' ), '<a href="' . $url . '">', '</a>' );
72
+ } else if ( MonsterInsights()->license->license_has_error() ) {
73
+ return monsterinsights_get_message( 'error', $this->get_license_error() );
74
+ }
75
+ }
76
+
77
+ if ( ! ( MonsterInsights()->auth->is_authed() || MonsterInsights()->auth->is_network_authed() ) ) {
78
+ if ( current_user_can( 'monsterinsights_save_settings' ) ) {
79
+ $url = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_settings' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
80
+ // Translators: Placeholders add a link to the settings panel.
81
+ return monsterinsights_get_message( 'error', sprintf( esc_html__( 'Please %1$sauthenticate %2$swith Google Analytics to allow the plugin to fetch data.', 'google-analytics-for-wordpress' ), '<a href="' . $url . '">', '</a>' ) );
82
+ } else {
83
+ return monsterinsights_get_message( 'error', esc_html__( 'The Google oAuth authentication needs to be re-authenticated to view data.', 'google-analytics-for-wordpress' ) );
84
+ }
85
+ }
86
+
87
+ if ( monsterinsights_is_pro_version() ) {
88
+ if ( ! MonsterInsights()->license->license_can( $this->level ) ) {
89
+ return $this->get_upsell_notice();
90
+ }
91
+ }
92
+
93
+ $error = $this->requirements( false, array(), $this->name );
94
+
95
+ if ( ! empty( $error ) ) {
96
+ return monsterinsights_get_message( 'error', $error );
97
+ }
98
+
99
+ if ( ! empty( $args['error'] ) ) {
100
+ return monsterinsights_get_message( 'error', $args['error'] );
101
+ }
102
+
103
+ if ( empty( $args['data'] ) || ! is_array( $args['data'] ) ) {
104
+ if ( monsterinsights_is_pro_version() ) {
105
+ return '';
106
+ } else {
107
+ // Try to get default data.
108
+ $args = $this->get_data( array( 'default' => true ) );
109
+ if ( empty( $args['data'] ) || is_array( $args['data'] ) ) {
110
+ return monsterinsights_get_message( 'error', __( 'No data found', 'google-analytics-for-wordpress' ) );
111
+ }
112
+
113
+ if ( ! empty( $args['error'] ) ) {
114
+ return monsterinsights_get_message( 'error', $args['error'] );
115
+ }
116
+ }
117
+ }
118
+
119
+ return $this->get_report_html( $args['data'] );
120
+ }
121
+
122
+ // Deletes the report data from the cache
123
+ public function delete_cache( $where = 'site' ) {
124
+
125
+ if ( $where === 'site' || $where === 'both' ) {
126
+ delete_option( 'monsterinsights_report_data_' . $this->name );
127
+ }
128
+
129
+ if ( $where === 'network' || $where === 'both' ) {
130
+ delete_option( 'monsterinsights_network_report_data_' . $this->name );
131
+ }
132
+ }
133
+
134
+ // Get report data
135
+ public function get_data( $args = array() ) {
136
+
137
+ if ( ! empty( $args['default'] ) ) {
138
+ $args['start'] = $this->default_start_date();
139
+ $args['end'] = $this->default_end_date();
140
+ }
141
+
142
+ $start = ! empty( $args['start'] ) && $this->is_valid_date( $args['start'] ) ? $args['start'] : '';
143
+ $end = ! empty( $args['end'] ) && $this->is_valid_date( $args['end'] ) ? $args['end'] : '';
144
+
145
+ if ( monsterinsights_is_pro_version() && ! MonsterInsights()->license->license_can( $this->level ) ) {
146
+ return array(
147
+ 'success' => true,
148
+ 'upgrade' => true,
149
+ 'data' => array(),
150
+ );
151
+ }
152
+
153
+ if ( ! $this->is_valid_date_range( $start, $end ) ) {
154
+ return array(
155
+ 'success' => false,
156
+ 'error' => __( 'Invalid date range.', 'google-analytics-for-wordpress' ),
157
+ 'data' => array(),
158
+ );
159
+ }
160
+
161
+ if ( ( $start !== $this->default_start_date() || $end !== $this->default_end_date() ) && ! monsterinsights_is_pro_version() ) {
162
+ $start = $this->default_start_date();
163
+ $end = $this->default_end_date();
164
+ // return array(
165
+ // 'success' => false,
166
+ // 'error' => __( 'Please upgrade to MonsterInsights Pro to use custom date ranges.', 'google-analytics-for-wordpress' ),
167
+ // 'data' => array(),
168
+ // );
169
+ }
170
+
171
+ $error = apply_filters( 'monsterinsights_reports_abstract_get_data_pre_cache', false, $args, $this->name );
172
+ if ( $error ) {
173
+ return apply_filters( 'monsterinsights_reports_handle_error_message', array(
174
+ 'success' => false,
175
+ 'error' => $error,
176
+ 'data' => array(),
177
+ ) );
178
+ }
179
+
180
+ $check_cache = ( $start === $this->default_start_date() && $end === $this->default_end_date() ) || apply_filters( 'monsterinsights_report_use_cache', false, $this->name );
181
+ $site_auth = MonsterInsights()->auth->get_viewname();
182
+ $ms_auth = is_multisite() && MonsterInsights()->auth->get_network_viewname();
183
+ $transient = 'monsterinsights_report_' . $this->name . '_' . $start . '_' . $end;
184
+ // Set to same time as MI cache. MI caches same day to 15 and others to 1 day, so there's no point pinging MI before then.
185
+ $expiration = date( 'Y-m-d' ) === $end ? apply_filters( 'monsterinsights_report_transient_expiration', 15 * MINUTE_IN_SECONDS, $this->name ) : HOUR_IN_SECONDS;
186
+
187
+ // Default date range, check.
188
+ if ( $site_auth || $ms_auth ) {
189
+ // Single site or MS with auth at subsite
190
+ $option_name = $site_auth ? 'monsterinsights_report_data_' . $this->name : 'monsterinsights_network_report_data_' . $this->name;
191
+ $p = $site_auth ? MonsterInsights()->auth->get_viewid() : MonsterInsights()->auth->get_network_viewid();
192
+
193
+ $data = array();
194
+ if ( $check_cache ) {
195
+ $data = ! $site_auth && $ms_auth ? get_site_option( $option_name, array() ) : get_option( $option_name, array() );
196
+ } else {
197
+ $data = ! $site_auth && $ms_auth ? get_site_transient( $transient ) : get_transient( $transient );
198
+ }
199
+
200
+ if ( ! empty( $data ) &&
201
+ ! empty( $data['expires'] ) &&
202
+ $data['expires'] >= time() &&
203
+ ! empty( $data['data'] ) &&
204
+ ! empty( $data['p'] ) &&
205
+ $data['p'] === $p
206
+ ) {
207
+ return $this->prepare_report_data( array(
208
+ 'success' => true,
209
+ 'data' => $data['data'],
210
+ ) );
211
+ }
212
+
213
+ // Nothing in cache, either not saved before, expired or mismatch. Let's grab from API
214
+ $api_options = array( 'start' => $start, 'end' => $end );
215
+ if ( ! $site_auth && $ms_auth ) {
216
+ $api_options['network'] = true;
217
+ }
218
+
219
+ $api = new MonsterInsights_API_Request( 'analytics/reports/' . $this->name . '/', $api_options, 'GET' );
220
+
221
+ $additional_data = $this->additional_data();
222
+
223
+ if ( ! empty( $additional_data ) ) {
224
+ $api->set_additional_data( $additional_data );
225
+ }
226
+
227
+ $ret = $api->request();
228
+
229
+ if ( is_wp_error( $ret ) ) {
230
+ return array(
231
+ 'success' => false,
232
+ 'error' => $ret->get_error_message(),
233
+ 'data' => array(),
234
+ );
235
+ } else {
236
+ // Success
237
+ $data = array(
238
+ 'expires' => time() + $expiration,
239
+ 'p' => $p,
240
+ 'data' => $ret['data'],
241
+ );
242
+
243
+ if ( $check_cache ) {
244
+ ! $site_auth && $ms_auth ? update_site_option( $option_name, $data ) : update_option( $option_name, $data );
245
+ } else {
246
+ ! $site_auth && $ms_auth ? set_site_transient( $transient, $data, $expiration ) : set_transient( $transient, $data, $expiration );
247
+ }
248
+
249
+ return $this->prepare_report_data( array(
250
+ 'success' => true,
251
+ 'data' => $ret['data'],
252
+ ) );
253
+ }
254
+
255
+ } else {
256
+ return array(
257
+ 'success' => false,
258
+ 'error' => __( 'You must authenticate with MonsterInsights to use reports.', 'google-analytics-for-wordpress' ),
259
+ 'data' => array(),
260
+ );
261
+ }
262
+ }
263
+
264
+ public function default_start_date() {
265
+ return date( 'Y-m-d', strtotime( '-30 days' ) );
266
+ }
267
+
268
+ public function default_end_date() {
269
+ return date( 'Y-m-d', strtotime( '-1 day' ) );
270
+ }
271
+
272
+ // Checks to see if date range is valid. Should be 30-yesterday always for lite & any valid date range to today for Pro.
273
+ public function is_valid_date_range( $start, $end ) {
274
+ $start = strtotime( $start );
275
+ $end = strtotime( $end );
276
+
277
+ if ( $start > strtotime( 'now' ) || $end > strtotime( 'now' ) || $start < strtotime( '01 January 2005' ) || $end < strtotime( '01 January 2005' ) ) {
278
+ return false;
279
+ }
280
+
281
+ // return false if the start date is after the end date
282
+ return ( $start > $end ) ? false : true;
283
+ }
284
+
285
+ // Is a valid date value
286
+ public function is_valid_date( $date = '' ) {
287
+ $d = MonsterInsightsDateTime::createFromFormat( 'Y-m-d', $date );
288
+
289
+ return $d && $d->format( 'Y-m-d' ) === $date;
290
+ }
291
+
292
+ /**
293
+ * Do not use the functions below this. They are unused and are just here so people
294
+ * with out of date MonsterInsights addons won't get fatal errors.
295
+ */
296
+ protected function get_api_max_limit() {
297
+ return 300;
298
+ }
299
+
300
+ protected function get_date_range() {
301
+ return array();
302
+ }
303
+
304
+ public function get_upsell_notice() {
305
+ $has_level = monsterinsights_is_pro_version() ? MonsterInsights()->license->get_license_type() : false;
306
+ $has_level = $has_level ? $has_level : 'lite';
307
+ // Translators: Placeholders add the license level and the report title.
308
+ $message = sprintf( __( 'You currently have a %1$s level license, but this report requires at least a %2$s level license to view the %3$s. Please upgrade to view this report.', 'google-analytics-for-wordpress' ), $has_level, $this->level, $this->title );
309
+ ob_start(); ?>
310
+ <div class="monsterinsights-upsell-report-container monsterinsights-upsell-report-<?php echo $this->name; ?>-bg">
311
+ <div class="monsterinsights-upsell-container">
312
+ <div class="row justify-content-center">
313
+ <div class="col-lg-10 col-lg-offset-1 align-self-center">
314
+ <div class="monsterinsights-upsell-card">
315
+ <img class="monsterinsights-upgrade-mascot"
316
+ src="<?php echo trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ); ?>assets/css/images/mascot.png"
317
+ srcset="<?php echo trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ); ?>assets/css/images/mascot@2x.png 2x"
318
+ alt="">
319
+ <div class="monsterinsights-upsell-card-card-content">
320
+ <span class="monsterinsights-upsell-card-title"><?php esc_html_e( 'Ready to Get Analytics Super-Powers?', 'google-analytics-for-wordpress' ); ?></span>
321
+ <p class="monsterinsights-upsell-card-subtitle">
322
+ <strong><?php esc_html_e( '(And Crush Your Competition?)', 'google-analytics-for-wordpress' ); ?></strong>
323
+ </p> &nbsp;
324
+ <?php if ( monsterinsights_is_pro_version() ) { ?>
325
+ <p>
326
+ <?php
327
+ // Translators: License level and smiley.
328
+ echo sprintf( esc_html__( 'Hey there! It looks like you\'ve got the %1$s license installed on your site. That\'s awesome! %s', 'google-analytics-for-wordpress' ), $has_level, '<span class="dashicons dashicons-smiley"></span>' );
329
+ ?>
330
+ </p>
331
+ &nbsp;
332
+ <p>
333
+ <?php
334
+ // Translators: Placeholders add the report title and license level.
335
+ echo sprintf( esc_html__( 'Do you want to access to %1$s reporting right now%2$s in your WordPress Dashboard? That comes with the %3$s level%4$s of our paid packages. You\'ll need to upgrade your license to get instant access.', 'google-analytics-for-wordpress' ), '<strong>' . $this->title, '</strong>', '<strong><a href="' . monsterinsights_get_url( 'reports-page', $this->name . '-report-upsell-license-link', 'https://monsterinsights.com/my-account/' ) . '">' . $this->level, '</a></strong>' );
336
+ ?>
337
+ </p>
338
+ &nbsp;
339
+ <p>
340
+ <?php
341
+ // Translators: Placeholdes add links to the account area and a guide.
342
+ echo sprintf( esc_html__( 'It\'s easy! To upgrade, navigate to %1$sMy Account%2$s on MonsterInsights.com, go to the licenses tab, and click upgrade. We also have a %3$sstep by step guide%4$s with pictures of this process.', 'google-analytics-for-wordpress' ), '<a href="' . monsterinsights_get_url( 'reports-page', $this->name . '-report-upsell-license-link', 'https://monsterinsights.com/my-account/' ) . '"><strong>', '</strong></a>', '<a href="' . monsterinsights_get_url( 'reports-page', $this->name . '-report-upsell-license-link', 'https://www.monsterinsights.com/docs/upgrade-monsterinsights-license/' ) . '" style="text-decoration:underline !important">', '</a>' );
343
+ ?>
344
+ </p>
345
+ &nbsp;
346
+ <p><?php esc_html_e( 'If you have any questions, don\'t hesitate to reach out. We\'re here to help.', 'google-analytics-for-wordpress' ); ?></p>
347
+ <?php } else { ?>
348
+ <p>
349
+ <?php
350
+ // Translators: Placeholder adds a smiley face.
351
+ echo sprintf( esc_html__( 'Hey there! %s It looks like you\'ve got the free version of MonsterInsights installed on your site. That\'s awesome!', 'google-analytics-for-wordpress' ), '<span class="dashicons dashicons-smiley"></span>' );
352
+ ?>
353
+ </p>
354
+ &nbsp;
355
+ <p>
356
+ <?php
357
+ // Translators: Placeholders make the text bold, add the license level and add a link to upgrade.
358
+ echo sprintf( esc_html__( 'Do you you want to access to %1$s reporting right now%2$s in your WordPress Dashboard? That comes with %3$s level%4$s of our paid packages. To get instant access, you\'ll want to buy a MonsterInsights license, which also gives you access to powerful addons, expanded reporting (including the ability to use custom date ranges), comprehensive tracking features (like UserID tracking) and access to our world-class support team.', 'google-analytics-for-wordpress' ), '<strong>' . $this->title, '</strong>', '<a href="' . monsterinsights_get_upgrade_link( 'reports-page', $this->name . '-report-upsell-license-link' ) . '">' . $this->level, '</a>' );
359
+ ?>
360
+ </p>
361
+ &nbsp;
362
+ <p>
363
+ <?php
364
+ // Translators: Placeholders make the text bold, add the license level and add a link to upgrade.
365
+ echo sprintf( esc_html__( 'Upgrading is easy! To upgrade, navigate to %1$ssour pricing page%2$s, purchase the required license, and then follow the %3$sinstructions in the email receipt%4$s to upgrade. It only takes a few minutes to unlock the most powerful, yet easy to use analytics tracking system for WordPress.', 'google-analytics-for-wordpress' ), '<a href="' . monsterinsights_get_upgrade_link( 'reports-page', $this->name . '-report-upsell-license-link' ) . '"><strong>', '</strong></a>', '<a style="text-decoration:underline !important" href="' . monsterinsights_get_url( 'reports-page', $this->name . '-report-go-lite-pro-link', 'https://www.monsterinsights.com/docs/go-lite-pro/' ) . '">', '</a>' );
366
+ ?>
367
+ </p>
368
+ &nbsp;
369
+ <p><?php esc_html_e( 'If you have any questions, don\'t hesitate to reach out. We\'re here to help.', 'google-analytics-for-wordpress' ); ?></p>
370
+ <?php } ?>
371
+ </div>
372
+ <div class="monsterinsights-upsell-card-action">
373
+ <?php if ( monsterinsights_is_pro_version() ) { ?>
374
+ <a href="<?php echo monsterinsights_get_upgrade_link( 'reports-page', $this->name . '-report-upsell-license-link' ); ?>"
375
+ class="monsterinsights-upsell-card-button"><?php esc_html_e( 'Upgrade Now', 'google-analytics-for-wordpress' ); ?></a>
376
+ <?php } else { ?>
377
+ <a href="<?php echo monsterinsights_get_url( 'reports-page', $this->name . '-report-upsell-license-link', 'https://www.monsterinsights.com/docs/upgrade-monsterinsights-license/' ); ?>"
378
+ class="monsterinsights-upsell-card-button"><?php esc_html_e( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ); ?></a>
379
+ <?php } ?>
380
+ </div>
381
+ </div>
382
+ </div>
383
+ </div>
384
+ </div>
385
+ </div>
386
+ </div>
387
+ <?php
388
+ return ob_get_clean();
389
+ }
390
+
391
+ function get_ga_report_range( $data = array() ) {
392
+ if ( empty( $data['reportcurrentrange'] ) || empty( $data['reportcurrentrange']['startDate'] ) || empty( $data['reportcurrentrange']['endDate'] ) ) {
393
+ return '';
394
+ } else {
395
+ if ( ! empty( $data['reportprevrange'] ) && ! empty( $data['reportprevrange']['startDate'] ) && ! empty( $data['reportprevrange']['endDate'] ) ) {
396
+ return urlencode( '_u.date00=' . str_replace( '-', '', $data['reportcurrentrange']['startDate'] ) . '&_u.date01=' . str_replace( '-', '', $data['reportcurrentrange']['endDate'] ) . '&_u.date10=' . str_replace( '-', '', $data['reportprevrange']['startDate'] ) . '&_u.date11=' . str_replace( '-', '', $data['reportprevrange']['endDate'] ) );
397
+ } else {
398
+ return urlencode( '_u.date00=' . str_replace( '-', '', $data['reportcurrentrange']['startDate'] ) . '&_u.date01=' . str_replace( '-', '', $data['reportcurrentrange']['endDate'] ) );
399
+ }
400
+ }
401
+ }
402
+
403
+ /**
404
+ * Grab the link to the addons page used in each report's error message.
405
+ *
406
+ * @return string
407
+ */
408
+ public function get_addons_page_link() {
409
+ if ( current_user_can( 'install_plugins' ) ) {
410
+ $addons_link = 'install_addon';
411
+ } else {
412
+ $addons_link = esc_html__( 'Please ask your webmaster to enable this addon.', 'google-analytics-for-wordpress' );
413
+ }
414
+
415
+ return $addons_link;
416
+ }
417
+
418
+ /**
419
+ * When called will add the footer link to be displayed in the error popup.
420
+ *
421
+ * @param array $data The data sent as error response to the ajax call.
422
+ *
423
+ * @return array
424
+ */
425
+ public function add_error_addon_link( $data ) {
426
+ $data['data']['footer'] = $this->get_addons_page_link();
427
+
428
+ return $data;
429
+ }
430
+
431
+ /**
432
+ * Added to allow individual reports to alter data when outputting for Vue reports.
433
+ *
434
+ * @param $data
435
+ *
436
+ * @return mixed
437
+ */
438
+ public function prepare_report_data( $data ) {
439
+ return $data;
440
+ }
441
+ }
442
+
443
+ if ( ! class_exists( 'MonsterInsightsDateTime' ) ) {
444
+ class MonsterInsightsDateTime extends DateTime {
445
+ public static function createFromFormat( $format, $time, $timezone = null ) {
446
+ if ( ! $timezone ) {
447
+ $timezone = new DateTimeZone( date_default_timezone_get() );
448
+ }
449
+ if ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
450
+ return parent::createFromFormat( $format, $time, $timezone );
451
+ }
452
+
453
+ return new DateTime( date( $format, strtotime( $time ) ), $timezone );
454
+ }
455
+ }
456
+ }
includes/admin/reports/index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- //Nothing to see here
3
-
4
  header( 'HTTP/1.0 403 Forbidden' );
1
+ <?php
2
+ //Nothing to see here
3
+
4
  header( 'HTTP/1.0 403 Forbidden' );
includes/admin/reports/overview.php CHANGED
@@ -1,80 +1,80 @@
1
- <?php
2
- /**
3
- * Overview Report
4
- *
5
- * Ensures all of the reports have a uniform class with helper functions.
6
- *
7
- * @since 6.0.0
8
- *
9
- * @package MonsterInsights
10
- * @subpackage Reports
11
- * @author Chris Christoff
12
- */
13
-
14
- // Exit if accessed directly
15
- if ( ! defined( 'ABSPATH' ) ) {
16
- exit;
17
- }
18
-
19
- final class MonsterInsights_Report_Overview extends MonsterInsights_Report {
20
-
21
- public $title;
22
- public $class = 'MonsterInsights_Report_Overview';
23
- public $name = 'overview';
24
- public $version = '1.0.0';
25
- public $level = 'lite';
26
-
27
- /**
28
- * Primary class constructor.
29
- *
30
- * @access public
31
- * @since 6.0.0
32
- */
33
- public function __construct() {
34
- $this->title = __( 'Overview', 'google-analytics-for-wordpress' );
35
- parent::__construct();
36
- }
37
-
38
- /**
39
- * Prepare report-specific data for output.
40
- *
41
- * @param array $data The data from the report before it gets sent to the frontend.
42
- *
43
- * @return mixed
44
- */
45
- public function prepare_report_data( $data ) {
46
- // Add flags to the countries report.
47
- if ( ! empty( $data['data']['countries'] ) ) {
48
- $country_names = monsterinsights_get_country_list( true );
49
- foreach ( $data['data']['countries'] as $key => $country ) {
50
- $data['data']['countries'][ $key ]['name'] = isset( $country_names[ $country['iso'] ] ) ? $country_names[ $country['iso'] ] : $country['iso'];
51
- }
52
- }
53
-
54
- // Escape urls for the top pages report.
55
- if ( ! empty( $data['data']['toppages'] ) ) {
56
- foreach ( $data['data']['toppages'] as $key => $page ) {
57
- $title = $data['data']['toppages'][ $key ]['title'];
58
- $url = '(not set)' === $title ? '' : esc_url( $data['data']['toppages'][ $key ]['hostname'] );
59
-
60
- $data['data']['toppages'][ $key ]['hostname'] = $url;
61
- }
62
- }
63
-
64
- // Bounce rate add symbol.
65
- if ( ! empty( $data['data']['infobox']['bounce']['value'] ) ) {
66
- $data['data']['infobox']['bounce']['value'] .= '%';
67
- }
68
-
69
- // Add GA links.
70
- if ( ! empty( $data['data'] ) ) {
71
- $data['data']['galinks'] = array(
72
- 'countries' => 'https://analytics.google.com/analytics/web/#report/visitors-geo/' . MonsterInsights()->auth->get_referral_url() . $this->get_ga_report_range( $data['data'] ),
73
- 'referrals' => 'https://analytics.google.com/analytics/web/#report/trafficsources-referrals/' . MonsterInsights()->auth->get_referral_url() . $this->get_ga_report_range( $data['data'] ),
74
- 'topposts' => 'https://analytics.google.com/analytics/web/#/report/content-pages/' . MonsterInsights()->auth->get_referral_url() . $this->get_ga_report_range( $data['data'] ),
75
- );
76
- }
77
-
78
- return $data;
79
- }
80
- }
1
+ <?php
2
+ /**
3
+ * Overview Report
4
+ *
5
+ * Ensures all of the reports have a uniform class with helper functions.
6
+ *
7
+ * @since 6.0.0
8
+ *
9
+ * @package MonsterInsights
10
+ * @subpackage Reports
11
+ * @author Chris Christoff
12
+ */
13
+
14
+ // Exit if accessed directly
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit;
17
+ }
18
+
19
+ final class MonsterInsights_Report_Overview extends MonsterInsights_Report {
20
+
21
+ public $title;
22
+ public $class = 'MonsterInsights_Report_Overview';
23
+ public $name = 'overview';
24
+ public $version = '1.0.0';
25
+ public $level = 'lite';
26
+
27
+ /**
28
+ * Primary class constructor.
29
+ *
30
+ * @access public
31
+ * @since 6.0.0
32
+ */
33
+ public function __construct() {
34
+ $this->title = __( 'Overview', 'google-analytics-for-wordpress' );
35
+ parent::__construct();
36
+ }
37
+
38
+ /**
39
+ * Prepare report-specific data for output.
40
+ *
41
+ * @param array $data The data from the report before it gets sent to the frontend.
42
+ *
43
+ * @return mixed
44
+ */
45
+ public function prepare_report_data( $data ) {
46
+ // Add flags to the countries report.
47
+ if ( ! empty( $data['data']['countries'] ) ) {
48
+ $country_names = monsterinsights_get_country_list( true );
49
+ foreach ( $data['data']['countries'] as $key => $country ) {
50
+ $data['data']['countries'][ $key ]['name'] = isset( $country_names[ $country['iso'] ] ) ? $country_names[ $country['iso'] ] : $country['iso'];
51
+ }
52
+ }
53
+
54
+ // Escape urls for the top pages report.
55
+ if ( ! empty( $data['data']['toppages'] ) ) {
56
+ foreach ( $data['data']['toppages'] as $key => $page ) {
57
+ $title = $data['data']['toppages'][ $key ]['title'];
58
+ $url = '(not set)' === $title ? '' : esc_url( $data['data']['toppages'][ $key ]['hostname'] );
59
+
60
+ $data['data']['toppages'][ $key ]['hostname'] = $url;
61
+ }
62
+ }
63
+
64
+ // Bounce rate add symbol.
65
+ if ( ! empty( $data['data']['infobox']['bounce']['value'] ) ) {
66
+ $data['data']['infobox']['bounce']['value'] .= '%';
67
+ }
68
+
69
+ // Add GA links.
70
+ if ( ! empty( $data['data'] ) ) {
71
+ $data['data']['galinks'] = array(
72
+ 'countries' => 'https://analytics.google.com/analytics/web/#report/visitors-geo/' . MonsterInsights()->auth->get_referral_url() . $this->get_ga_report_range( $data['data'] ),
73
+ 'referrals' => 'https://analytics.google.com/analytics/web/#report/trafficsources-referrals/' . MonsterInsights()->auth->get_referral_url() . $this->get_ga_report_range( $data['data'] ),
74
+ 'topposts' => 'https://analytics.google.com/analytics/web/#/report/content-pages/' . MonsterInsights()->auth->get_referral_url() . $this->get_ga_report_range( $data['data'] ),
75
+ );
76
+ }
77
+
78
+ return $data;
79
+ }
80
+ }
includes/admin/review.php CHANGED
@@ -1,192 +1,196 @@
1
- <?php
2
- /**
3
- * Ask for some love.
4
- *
5
- * @package MonsterInsights
6
- * @author MonsterInsights
7
- * @since 7.0.7
8
- * @license GPL-2.0+
9
- * @copyright Copyright (c) 2018, MonsterInsights LLC
10
- */
11
- class MonsterInsights_Review {
12
- /**
13
- * Primary class constructor.
14
- *
15
- * @since 7.0.7
16
- */
17
- public function __construct() {
18
- // Admin notice requesting review.
19
- add_action( 'admin_notices', array( $this, 'review_request' ) );
20
- add_action( 'wp_ajax_monsterinsights_review_dismiss', array( $this, 'review_dismiss' ) );
21
- }
22
- /**
23
- * Add admin notices as needed for reviews.
24
- *
25
- * @since 7.0.7
26
- */
27
- public function review_request() {
28
- // Only consider showing the review request to admin users.
29
- if ( ! is_super_admin() ) {
30
- return;
31
- }
32
-
33
- // If the user has opted out of product annoucement notifications, don't
34
- // display the review request.
35
- if ( monsterinsights_get_option( 'hide_am_notices', false ) || monsterinsights_get_option( 'network_hide_am_notices', false ) ) {
36
- return;
37
- }
38
- // Verify that we can do a check for reviews.
39
- $review = get_option( 'monsterinsights_review' );
40
- $time = time();
41
- $load = false;
42
-
43
- if ( ! $review ) {
44
- $review = array(
45
- 'time' => $time,
46
- 'dismissed' => false,
47
- );
48
- update_option( 'monsterinsights_review', $review );
49
- } else {
50
- // Check if it has been dismissed or not.
51
- if ( ( isset( $review['dismissed'] ) && ! $review['dismissed'] ) && ( isset( $review['time'] ) && ( ( $review['time'] + DAY_IN_SECONDS ) <= $time ) ) ) {
52
- $load = true;
53
- }
54
- }
55
-
56
- // If we cannot load, return early.
57
- if ( ! $load ) {
58
- return;
59
- }
60
-
61
- $this->review();
62
- }
63
-
64
- /**
65
- * Maybe show review request.
66
- *
67
- * @since 7.0.7
68
- */
69
- public function review() {
70
- // Fetch when plugin was initially installed.
71
- $activated = get_option( 'monsterinsights_over_time', array() );
72
- $ua_code = monsterinsights_get_ua();
73
-
74
- if ( ! empty( $activated['connected_date'] ) ) {
75
- // Only continue if plugin has been tracking for at least 14 days.
76
- if ( ( $activated['connected_date'] + ( DAY_IN_SECONDS * 14 ) ) > time() ) {
77
- return;
78
- }
79
- } else {
80
- if ( empty( $activated ) ) {
81
- $data = array(
82
- 'installed_version' => MONSTERINSIGHTS_VERSION,
83
- 'installed_date' => time(),
84
- 'installed_pro' => monsterinsights_is_pro_version(),
85
- );
86
- } else {
87
- $data = $activated;
88
- }
89
- // If already has a UA code mark as connected now.
90
- if ( ! empty( $ua_code ) ) {
91
- $data['connected_date'] = time();
92
- }
93
-
94
- update_option( 'monsterinsights_over_time', $data );
95
- return;
96
- }
97
-
98
- // Only proceed with displaying if the user is tracking.
99
- if ( empty( $ua_code ) ) {
100
- return;
101
- }
102
-
103
- $feedback_url = add_query_arg( array(
104
- 'wpf192157_24' => untrailingslashit( home_url() ),
105
- 'wpf192157_26' => monsterinsights_get_license_key(),
106
- 'wpf192157_27' => monsterinsights_is_pro_version() ? 'pro' : 'lite',
107
- 'wpf192157_28' => MONSTERINSIGHTS_VERSION,
108
- ), 'https://www.monsterinsights.com/plugin-feedback/' );
109
- $feedback_url = monsterinsights_get_url( 'review-notice', 'feedback', $feedback_url );
110
- // We have a candidate! Output a review message.
111
- ?>
112
- <div class="notice notice-info is-dismissible monsterinsights-review-notice">
113
- <div class="monsterinsights-review-step monsterinsights-review-step-1">
114
- <p><?php esc_html_e( 'Are you enjoying MonsterInsights?', 'google-analytics-for-wordpress' ); ?></p>
115
- <p>
116
- <a href="#" class="monsterinsights-review-switch-step" data-step="3"><?php esc_html_e( 'Yes', 'google-analytics-for-wordpress' ); ?></a><br />
117
- <a href="#" class="monsterinsights-review-switch-step" data-step="2"><?php esc_html_e( 'Not Really', 'google-analytics-for-wordpress' ); ?></a>
118
- </p>
119
- </div>
120
- <div class="monsterinsights-review-step monsterinsights-review-step-2" style="display: none">
121
- <p><?php esc_html_e( 'We\'re sorry to hear you aren\'t enjoying MonsterInsights. We would love a chance to improve. Could you take a minute and let us know what we can do better?', 'google-analytics-for-wordpress' ); ?></p>
122
- <p>
123
- <a href="<?php echo esc_url( $feedback_url ); ?>" class="monsterinsights-dismiss-review-notice monsterinsights-review-out"><?php esc_html_e( 'Give Feedback', 'google-analytics-for-wordpress' ); ?></a><br>
124
- <a href="#" class="monsterinsights-dismiss-review-notice" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'No thanks', 'google-analytics-for-wordpress' ); ?></a>
125
- </p>
126
- </div>
127
- <div class="monsterinsights-review-step monsterinsights-review-step-3" style="display: none">
128
- <p><?php esc_html_e( 'That’s awesome! Could you please do me a BIG favor and give it a 5-star rating on WordPress to help us spread the word and boost our motivation?', 'google-analytics-for-wordpress' ); ?></p>
129
- <p><strong><?php echo wp_kses( __( '~ Syed Balkhi<br>Co-Founder of MonsterInsights', 'google-analytics-for-wordpress' ), array( 'br' => array() ) ); ?></strong></p>
130
- <p>
131
- <a href="https://wordpress.org/support/plugin/google-analytics-for-wordpress/reviews/?filter=5#new-post" class="monsterinsights-dismiss-review-notice monsterinsights-review-out" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Ok, you deserve it', 'google-analytics-for-wordpress' ); ?></a><br>
132
- <a href="#" class="monsterinsights-dismiss-review-notice" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Nope, maybe later', 'google-analytics-for-wordpress' ); ?></a><br>
133
- <a href="#" class="monsterinsights-dismiss-review-notice" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'I already did', 'google-analytics-for-wordpress' ); ?></a>
134
- </p>
135
- </div>
136
- </div>
137
- <script type="text/javascript">
138
- jQuery( document ).ready( function ( $ ) {
139
- $( document ).on( 'click', '.monsterinsights-dismiss-review-notice, .monsterinsights-review-notice button', function ( event ) {
140
- if ( ! $( this ).hasClass( 'monsterinsights-review-out' ) ) {
141
- event.preventDefault();
142
- }
143
- $.post( ajaxurl, {
144
- action: 'monsterinsights_review_dismiss'
145
- } );
146
- $( '.monsterinsights-review-notice' ).remove();
147
- } );
148
-
149
- $( document ).on( 'click', '.monsterinsights-review-switch-step', function ( e ) {
150
- e.preventDefault();
151
- var target = $( this ).attr( 'data-step' );
152
- if ( target ) {
153
- var notice = $( this ).closest( '.monsterinsights-review-notice' );
154
- var review_step = notice.find( '.monsterinsights-review-step-' + target );
155
- if ( review_step.length > 0 ) {
156
- notice.find( '.monsterinsights-review-step:visible').fadeOut( function ( ) {
157
- review_step.fadeIn();
158
- });
159
- }
160
- }
161
- })
162
- } );
163
- </script>
164
- <?php
165
- }
166
- /**
167
- * Dismiss the review admin notice
168
- *
169
- * @since 7.0.7
170
- */
171
- public function review_dismiss() {
172
- $review = get_option( 'monsterinsights_review', array() );
173
- $review['time'] = time();
174
- $review['dismissed'] = true;
175
- update_option( 'monsterinsights_review', $review );
176
-
177
- if ( is_super_admin() && is_multisite() ) {
178
- $site_list = get_sites();
179
- foreach ( (array) $site_list as $site ) {
180
- switch_to_blog( $site->blog_id );
181
-
182
- update_option( 'monsterinsights_review', $review );
183
-
184
- restore_current_blog();
185
- }
186
- }
187
-
188
- die;
189
- }
190
- }
191
-
192
- new MonsterInsights_Review();
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ask for some love.
4
+ *
5
+ * @package MonsterInsights
6
+ * @author MonsterInsights
7
+ * @since 7.0.7
8
+ * @license GPL-2.0+
9
+ * @copyright Copyright (c) 2018, MonsterInsights LLC
10
+ */
11
+ class MonsterInsights_Review {
12
+ /**
13
+ * Primary class constructor.
14
+ *
15
+ * @since 7.0.7
16
+ */
17
+ public function __construct() {
18
+ // Admin notice requesting review.
19
+ add_action( 'admin_notices', array( $this, 'review_request' ) );
20
+ add_action( 'wp_ajax_monsterinsights_review_dismiss', array( $this, 'review_dismiss' ) );
21
+ }
22
+ /**
23
+ * Add admin notices as needed for reviews.
24
+ *
25
+ * @since 7.0.7
26
+ */
27
+ public function review_request() {
28
+ // Only consider showing the review request to admin users.
29
+ if ( ! is_super_admin() ) {
30
+ return;
31
+ }
32
+
33
+ // If the user has opted out of product annoucement notifications, don't
34
+ // display the review request.
35
+ if ( monsterinsights_get_option( 'hide_am_notices', false ) || monsterinsights_get_option( 'network_hide_am_notices', false ) ) {
36
+ return;
37
+ }
38
+ // Verify that we can do a check for reviews.
39
+ $review = get_option( 'monsterinsights_review' );
40
+ $time = time();
41
+ $load = false;
42
+
43
+ if ( ! $review ) {
44
+ $review = array(
45
+ 'time' => $time,
46
+ 'dismissed' => false,
47
+ );
48
+ update_option( 'monsterinsights_review', $review );
49
+ } else {
50
+ // Check if it has been dismissed or not.
51
+ if ( ( isset( $review['dismissed'] ) && ! $review['dismissed'] ) && ( isset( $review['time'] ) && ( ( $review['time'] + DAY_IN_SECONDS ) <= $time ) ) ) {
52
+ $load = true;
53
+ }
54
+ }
55
+
56
+ // If we cannot load, return early.
57
+ if ( ! $load ) {
58
+ return;
59
+ }
60
+
61
+ $this->review();
62
+ }
63
+
64
+ /**
65
+ * Maybe show review request.
66
+ *
67
+ * @since 7.0.7
68
+ */
69
+ public function review() {
70
+ // Fetch when plugin was initially installed.
71
+ $activated = get_option( 'monsterinsights_over_time', array() );
72
+ $ua_code = monsterinsights_get_ua();
73
+
74
+ if ( ! empty( $activated['connected_date'] ) ) {
75
+ // Only continue if plugin has been tracking for at least 14 days.
76
+ $days = 14;
77
+ if ( monsterinsights_get_option( 'gadwp_migrated', 0 ) > 0 ) {
78
+ $days = 21;
79
+ }
80
+ if ( ( $activated['connected_date'] + ( DAY_IN_SECONDS * $days ) ) > time() ) {
81
+ return;
82
+ }
83
+ } else {
84
+ if ( empty( $activated ) ) {
85
+ $data = array(
86
+ 'installed_version' => MONSTERINSIGHTS_VERSION,
87
+ 'installed_date' => time(),
88
+ 'installed_pro' => monsterinsights_is_pro_version(),
89
+ );
90
+ } else {
91
+ $data = $activated;
92
+ }
93
+ // If already has a UA code mark as connected now.
94
+ if ( ! empty( $ua_code ) ) {
95
+ $data['connected_date'] = time();
96
+ }
97
+
98
+ update_option( 'monsterinsights_over_time', $data );
99
+ return;
100
+ }
101
+
102
+ // Only proceed with displaying if the user is tracking.
103
+ if ( empty( $ua_code ) ) {
104
+ return;
105
+ }
106
+
107
+ $feedback_url = add_query_arg( array(
108
+ 'wpf192157_24' => untrailingslashit( home_url() ),
109
+ 'wpf192157_26' => monsterinsights_get_license_key(),
110
+ 'wpf192157_27' => monsterinsights_is_pro_version() ? 'pro' : 'lite',
111
+ 'wpf192157_28' => MONSTERINSIGHTS_VERSION,
112
+ ), 'https://www.monsterinsights.com/plugin-feedback/' );
113
+ $feedback_url = monsterinsights_get_url( 'review-notice', 'feedback', $feedback_url );
114
+ // We have a candidate! Output a review message.
115
+ ?>
116
+ <div class="notice notice-info is-dismissible monsterinsights-review-notice">
117
+ <div class="monsterinsights-review-step monsterinsights-review-step-1">
118
+ <p><?php esc_html_e( 'Are you enjoying MonsterInsights?', 'google-analytics-for-wordpress' ); ?></p>
119
+ <p>
120
+ <a href="#" class="monsterinsights-review-switch-step" data-step="3"><?php esc_html_e( 'Yes', 'google-analytics-for-wordpress' ); ?></a><br />
121
+ <a href="#" class="monsterinsights-review-switch-step" data-step="2"><?php esc_html_e( 'Not Really', 'google-analytics-for-wordpress' ); ?></a>
122
+ </p>
123
+ </div>
124
+ <div class="monsterinsights-review-step monsterinsights-review-step-2" style="display: none">
125
+ <p><?php esc_html_e( 'We\'re sorry to hear you aren\'t enjoying MonsterInsights. We would love a chance to improve. Could you take a minute and let us know what we can do better?', 'google-analytics-for-wordpress' ); ?></p>
126
+ <p>
127
+ <a href="<?php echo esc_url( $feedback_url ); ?>" class="monsterinsights-dismiss-review-notice monsterinsights-review-out"><?php esc_html_e( 'Give Feedback', 'google-analytics-for-wordpress' ); ?></a><br>
128
+ <a href="#" class="monsterinsights-dismiss-review-notice" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'No thanks', 'google-analytics-for-wordpress' ); ?></a>
129
+ </p>
130
+ </div>
131
+ <div class="monsterinsights-review-step monsterinsights-review-step-3" style="display: none">
132
+ <p><?php esc_html_e( 'That’s awesome! Could you please do me a BIG favor and give it a 5-star rating on WordPress to help us spread the word and boost our motivation?', 'google-analytics-for-wordpress' ); ?></p>
133
+ <p><strong><?php echo wp_kses( __( '~ Syed Balkhi<br>Co-Founder of MonsterInsights', 'google-analytics-for-wordpress' ), array( 'br' => array() ) ); ?></strong></p>
134
+ <p>
135
+ <a href="https://wordpress.org/support/plugin/google-analytics-for-wordpress/reviews/?filter=5#new-post" class="monsterinsights-dismiss-review-notice monsterinsights-review-out" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Ok, you deserve it', 'google-analytics-for-wordpress' ); ?></a><br>
136
+ <a href="#" class="monsterinsights-dismiss-review-notice" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Nope, maybe later', 'google-analytics-for-wordpress' ); ?></a><br>
137
+ <a href="#" class="monsterinsights-dismiss-review-notice" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'I already did', 'google-analytics-for-wordpress' ); ?></a>
138
+ </p>
139
+ </div>
140
+ </div>
141
+ <script type="text/javascript">
142
+ jQuery( document ).ready( function ( $ ) {
143
+ $( document ).on( 'click', '.monsterinsights-dismiss-review-notice, .monsterinsights-review-notice button', function ( event ) {
144
+ if ( ! $( this ).hasClass( 'monsterinsights-review-out' ) ) {
145
+ event.preventDefault();
146
+ }
147
+ $.post( ajaxurl, {
148
+ action: 'monsterinsights_review_dismiss'
149
+ } );
150
+ $( '.monsterinsights-review-notice' ).remove();
151
+ } );
152
+
153
+ $( document ).on( 'click', '.monsterinsights-review-switch-step', function ( e ) {
154
+ e.preventDefault();
155
+ var target = $( this ).attr( 'data-step' );
156
+ if ( target ) {
157
+ var notice = $( this ).closest( '.monsterinsights-review-notice' );
158
+ var review_step = notice.find( '.monsterinsights-review-step-' + target );
159
+ if ( review_step.length > 0 ) {
160
+ notice.find( '.monsterinsights-review-step:visible').fadeOut( function ( ) {
161
+ review_step.fadeIn();
162
+ });
163
+ }
164
+ }
165
+ })
166
+ } );
167
+ </script>
168
+ <?php
169
+ }
170
+ /**
171
+ * Dismiss the review admin notice
172
+ *
173
+ * @since 7.0.7
174
+ */
175
+ public function review_dismiss() {
176
+ $review = get_option( 'monsterinsights_review', array() );
177
+ $review['time'] = time();
178
+ $review['dismissed'] = true;
179
+ update_option( 'monsterinsights_review', $review );
180
+
181
+ if ( is_super_admin() && is_multisite() ) {
182
+ $site_list = get_sites();
183
+ foreach ( (array) $site_list as $site ) {
184
+ switch_to_blog( $site->blog_id );
185
+
186
+ update_option( 'monsterinsights_review', $review );
187
+
188
+ restore_current_blog();
189
+ }
190
+ }
191
+
192
+ die;
193
+ }
194
+ }
195
+
196
+ new MonsterInsights_Review();
includes/admin/routes.php CHANGED
@@ -1,707 +1,789 @@
1
- <?php
2
- /**
3
- * Routes for VUE are registered here.
4
- *
5
- * @package monsterinsights
6
- */
7
-
8
- /**
9
- * Class MonsterInsights_Rest_Routes
10
- */
11
- class MonsterInsights_Rest_Routes {
12
-
13
- /**
14
- * MonsterInsights_Rest_Routes constructor.
15
- */
16
- public function __construct() {
17
-
18
- add_action( 'wp_ajax_monsterinsights_vue_get_license', array( $this, 'get_license' ) );
19
- add_action( 'wp_ajax_monsterinsights_vue_get_profile', array( $this, 'get_profile' ) );
20
- add_action( 'wp_ajax_monsterinsights_vue_get_settings', array( $this, 'get_settings' ) );
21
- add_action( 'wp_ajax_monsterinsights_vue_update_settings', array( $this, 'update_settings' ) );
22
- add_action( 'wp_ajax_monsterinsights_vue_get_addons', array( $this, 'get_addons' ) );
23
- add_action( 'wp_ajax_monsterinsights_update_manual_ua', array( $this, 'update_manual_ua' ) );
24
- add_action( 'wp_ajax_monsterinsights_vue_get_report_data', array( $this, 'get_report_data' ) );
25
- add_action( 'wp_ajax_monsterinsights_vue_install_plugin', array( $this, 'install_plugin' ) );
26
-
27
- add_action( 'wp_ajax_monsterinsights_handle_settings_import', array( $this, 'handle_settings_import' ) );
28
-
29
- add_action( 'admin_notices', array( $this, 'hide_old_notices' ), 0 );
30
-
31
- add_action( 'wp_ajax_monsterinsights_vue_dismiss_first_time_notice', array( $this, 'dismiss_first_time_notice' ) );
32
- }
33
-
34
- /**
35
- * Ajax handler for grabbing the license
36
- */
37
- public function get_license() {
38
-
39
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
40
-
41
- if ( ! current_user_can( 'monsterinsights_view_dashboard' ) || ! monsterinsights_is_pro_version() ) {
42
- return;
43
- }
44
-
45
- $site_license = array(
46
- 'key' => MonsterInsights()->license->get_site_license_key(),
47
- 'type' => MonsterInsights()->license->get_site_license_type(),
48
- 'is_disabled' => MonsterInsights()->license->site_license_disabled(),
49
- 'is_expired' => MonsterInsights()->license->site_license_expired(),
50
- 'is_invalid' => MonsterInsights()->license->site_license_invalid(),
51
- );
52
- $network_license = array(
53
- 'key' => MonsterInsights()->license->get_network_license_key(),
54
- 'type' => MonsterInsights()->license->get_network_license_type(),
55
- 'is_disabled' => MonsterInsights()->license->network_license_disabled(),
56
- 'is_expired' => MonsterInsights()->license->network_license_expired(),
57
- 'is_invalid' => MonsterInsights()->license->network_license_disabled(),
58
- );
59
-
60
- wp_send_json( array(
61
- 'site' => $site_license,
62
- 'network' => $network_license,
63
- ) );
64
-
65
- }
66
-
67
- /**
68
- * Ajax handler for grabbing the current authenticated profile.
69
- */
70
- public function get_profile() {
71
-
72
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
73
-
74
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
75
- return;
76
- }
77
-
78
- wp_send_json( array(
79
- 'ua' => MonsterInsights()->auth->get_ua(),
80
- 'viewname' => MonsterInsights()->auth->get_viewname(),
81
- 'manual_ua' => MonsterInsights()->auth->get_manual_ua(),
82
- 'network_ua' => MonsterInsights()->auth->get_network_ua(),
83
- 'network_viewname' => MonsterInsights()->auth->get_network_viewname(),
84
- 'network_manual_ua' => MonsterInsights()->auth->get_network_manual_ua(),
85
- ) );
86
-
87
- }
88
-
89
- /**
90
- * Ajax handler for grabbing the settings.
91
- */
92
- public function get_settings() {
93
-
94
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
95
-
96
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
97
- return;
98
- }
99
-
100
- $options = monsterinsights_get_options();
101
-
102
- // Array fields are needed even if empty.
103
- $array_fields = array( 'view_reports', 'save_settings', 'ignore_users' );
104
- foreach ( $array_fields as $array_field ) {
105
- if ( ! isset( $options[ $array_field ] ) ) {
106
- $options[ $array_field ] = array();
107
- }
108
- }
109
- if ( isset( $options['custom_code'] ) ) {
110
- $options['custom_code'] = stripslashes( $options['custom_code'] );
111
- }
112
-
113
- wp_send_json( $options );
114
-
115
- }
116
-
117
- /**
118
- * Ajax handler for updating the settings.
119
- */
120
- public function update_settings() {
121
-
122
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
123
-
124
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
125
- return;
126
- }
127
-
128
- if ( isset( $_POST['setting'] ) ) {
129
- $setting = sanitize_text_field( wp_unslash( $_POST['setting'] ) );
130
- if ( isset( $_POST['value'] ) ) {
131
- $value = $this->handle_sanitization( $setting, $_POST['value'] );
132
- monsterinsights_update_option( $setting, $value );
133
- } else {
134
- monsterinsights_update_option( $setting, false );
135
- }
136
- }
137
-
138
- wp_send_json_success();
139
-
140
- }
141
-
142
- /**
143
- * Sanitization specific to each field.
144
- *
145
- * @param string $field The key of the field to sanitize.
146
- * @param string $value The value of the field to sanitize.
147
- *
148
- * @return mixed The sanitized input.
149
- */
150
- private function handle_sanitization( $field, $value ) {
151
-
152
- $value = wp_unslash( $value );
153
-
154
- // Textarea fields.
155
- $textarea_fields = array(
156
- 'custom_code',
157
- );
158
-
159
- if ( in_array( $field, $textarea_fields, true ) ) {
160
- if ( function_exists( 'sanitize_textarea_field' ) ) {
161
- return sanitize_textarea_field( $value );
162
- } else {
163
- return wp_kses( $value, array() );
164
- }
165
- }
166
-
167
- $array_value = json_decode( $value, true );
168
- if ( is_array( $array_value ) ) {
169
- $value = $array_value;
170
- // Don't save empty values.
171
- foreach ( $value as $key => $item ) {
172
- if ( is_array( $item ) ) {
173
- $empty = true;
174
- foreach ( $item as $item_value ) {
175
- if ( ! empty( $item_value ) ) {
176
- $empty = false;
177
- }
178
- }
179
- if ( $empty ) {
180
- unset( $value[ $key ] );
181
- }
182
- }
183
- }
184
-
185
- // Reset array keys because JavaScript can't handle arrays with non-sequential keys.
186
- $value = array_values( $value );
187
-
188
- return $value;
189
- }
190
-
191
- return sanitize_text_field( $value );
192
-
193
- }
194
-
195
- /**
196
- * Return the state of the addons ( installed, activated )
197
- */
198
- public function get_addons() {
199
-
200
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
201
-
202
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
203
- return;
204
- }
205
-
206
- if ( isset( $_POST['network'] ) && intval( $_POST['network'] ) > 0 ) {
207
- define( 'WP_NETWORK_ADMIN', true );
208
- }
209
-
210
- $addons_data = monsterinsights_get_addons();
211
- $parsed_addons = array();
212
- $installed_plugins = get_plugins();
213
-
214
- if ( ! is_array( $addons_data ) ) {
215
- $addons_data = array();
216
- }
217
-
218
- foreach ( $addons_data as $addons_type => $addons ) {
219
- foreach ( $addons as $addon ) {
220
- $slug = 'monsterinsights-' . $addon->slug;
221
- if ( 'monsterinsights-ecommerce' === $slug ) {
222
- $addon = $this->get_addon( $installed_plugins, $addons_type, $addon, $slug );
223
- if ( empty( $addon->installed ) ) {
224
- $slug = 'ga-ecommerce';
225
- $addon = $this->get_addon( $installed_plugins, $addons_type, $addon, $slug );
226
- }
227
- } else {
228
- $addon = $this->get_addon( $installed_plugins, $addons_type, $addon, $slug );
229
- }
230
- $parsed_addons[ $addon->slug ] = $addon;
231
- }
232
- }
233
-
234
- // Include data about the plugins needed by some addons ( WooCommerce, EDD, Google AMP, CookieBot, etc ).
235
- // WooCommerce.
236
- $parsed_addons['woocommerce'] = array(
237
- 'active' => class_exists( 'WooCommerce' ),
238
- );
239
- // Edd.
240
- $parsed_addons['easy_digital_downloads'] = array(
241
- 'active' => class_exists( 'Easy_Digital_Downloads' ),
242
- );
243
- // MemberPress.
244
- $parsed_addons['memberpress'] = array(
245
- 'active' => defined( 'MEPR_VERSION' ) && version_compare( MEPR_VERSION, '1.3.43', '>' ),
246
- );
247
- // LifterLMS.
248
- $parsed_addons['lifterlms'] = array(
249
- 'active' => function_exists( 'LLMS' ) && version_compare( LLMS()->version, '3.32.0', '>=' ),
250
- );
251
- // Cookiebot.
252
- $parsed_addons['cookiebot'] = array(
253
- 'active' => function_exists( 'cookiebot_active' ) && cookiebot_active(),
254
- );
255
- // Cookie Notice.
256
- $parsed_addons['cookie_notice'] = array(
257
- 'active' => class_exists( 'Cookie_Notice' ),
258
- );
259
- // Fb Instant Articles.
260
- $parsed_addons['instant_articles'] = array(
261
- 'active' => defined( 'IA_PLUGIN_VERSION' ) && version_compare( IA_PLUGIN_VERSION, '3.3.4', '>' ),
262
- );
263
- // Google AMP.
264
- $parsed_addons['google_amp'] = array(
265
- 'active' => defined( 'AMP__FILE__' ),
266
- );
267
- // WPForms.
268
- $parsed_addons['wpforms'] = array(
269
- 'active' => function_exists( 'wpforms' ),
270
- 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugin-wpforms.png',
271
- 'title' => 'WPForms',
272
- 'excerpt' => __( 'The most beginner friendly drag & drop WordPress forms plugin allowing you to create beautiful contact forms, subscription forms, payment forms, and more in minutes, not hours!', 'google-analytics-for-wordpress' ),
273
- 'installed' => array_key_exists( 'wpforms-lite/wpforms.php', $installed_plugins ),
274
- 'slug' => 'wpforms-lite',
275
- );
276
- // OptinMonster.
277
- $parsed_addons['optinmonster'] = array(
278
- 'active' => class_exists( 'OMAPI' ),
279
- 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugin-om.png',
280
- 'title' => 'OptinMonster',
281
- 'excerpt' => __( 'Our high-converting optin forms like Exit-Intent® popups, Fullscreen Welcome Mats, and Scroll boxes help you dramatically boost conversions and get more email subscribers.', 'google-analytics-for-wordpress' ),
282
- 'installed' => array_key_exists( 'optinmonster/optin-monster-wp-api.php', $installed_plugins ),
283
- 'basename' => 'optinmonster/optin-monster-wp-api.php',
284
- 'slug' => 'optinmonster',
285
- );
286
- // OptinMonster.
287
- $parsed_addons['wp-mail-smtp'] = array(
288
- 'active' => function_exists( 'wp_mail_smtp' ),
289
- 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugin-smtp.png',
290
- 'title' => 'WP Mail SMTP',
291
- 'excerpt' => __( 'SMTP (Simple Mail Transfer Protocol) is an industry standard for sending emails. SMTP helps increase email deliverability by using proper authentication', 'google-analytics-for-wordpress' ),
292
- 'installed' => array_key_exists( 'wp-mail-smtp/wp_mail_smtp.php', $installed_plugins ),
293
- 'basename' => 'wp-mail-smtp/wp_mail_smtp.php',
294
- 'slug' => 'wp-mail-smtp',
295
- );
296
- // SeedProd.
297
- $parsed_addons['coming-soon'] = array(
298
- 'active' => function_exists( 'seed_csp4_activation' ),
299
- 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/seedprod.png',
300
- 'title' => 'SeedProd',
301
- 'excerpt' => __( 'Better Coming Soon & Maintenance Mode Pages', 'google-analytics-for-wordpress' ),
302
- 'installed' => array_key_exists( 'coming-soon/coming-soon.php', $installed_plugins ),
303
- 'basename' => 'coming-soon/coming-soon.php',
304
- 'slug' => 'coming-soon',
305
- );
306
- $parsed_addons['rafflepress'] = array(
307
- 'active' => function_exists( 'rafflepress_lite_activation' ),
308
- 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/rafflepress.png',
309
- 'title' => 'RafflePress',
310
- 'excerpt' => __( 'Get More Traffic with Viral Giveaways', 'google-analytics-for-wordpress' ),
311
- 'installed' => array_key_exists( 'rafflepress/rafflepress.php', $installed_plugins ),
312
- 'basename' => 'rafflepress/rafflepress.php',
313
- 'slug' => 'rafflepress',
314
- );
315
- $parsed_addons['trustpulse-api'] = array(
316
- 'active' => class_exists( 'TPAPI' ),
317
- 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/trustpulse.png',
318
- 'title' => 'TrustPulse',
319
- 'excerpt' => __( 'Social Proof Notifications that Boost Sales', 'google-analytics-for-wordpress' ),
320
- 'installed' => array_key_exists( 'trustpulse-api/trustpulse.php', $installed_plugins ),
321
- 'basename' => 'trustpulse-api/trustpulse.php',
322
- 'slug' => 'trustpulse-api',
323
- );
324
- // Gravity Forms.
325
- $parsed_addons['gravity_forms'] = array(
326
- 'active' => class_exists( 'GFCommon' ),
327
- );
328
- // Formidable Forms.
329
- $parsed_addons['formidable_forms'] = array(
330
- 'active' => class_exists( 'FrmHooksController' ),
331
- );
332
- // Manual UA Addon.
333
- if ( ! isset( $parsed_addons['manual_ua'] ) ) {
334
- $parsed_addons['manual_ua'] = array(
335
- 'active' => class_exists( 'MonsterInsights_Manual_UA' ),
336
- );
337
- }
338
-
339
- wp_send_json( $parsed_addons );
340
- }
341
-
342
- public function get_addon( $installed_plugins, $addons_type, $addon, $slug ) {
343
- $active = false;
344
- $installed = false;
345
- $plugin_basename = monsterinsights_get_plugin_basename_from_slug( $slug );
346
-
347
- if ( isset( $installed_plugins[ $plugin_basename ] ) ) {
348
- $installed = true;
349
-
350
- if ( is_multisite() && is_network_admin() ) {
351
- $active = is_plugin_active_for_network( $plugin_basename );
352
- } else {
353
- $active = is_plugin_active( $plugin_basename );
354
- }
355
- }
356
- if ( empty( $addon->url ) ) {
357
- $addon->url = '';
358
- }
359
-
360
- $addon->type = $addons_type;
361
- $addon->installed = $installed;
362
- $addon->active = $active;
363
- $addon->basename = $plugin_basename;
364
-
365
- return $addon;
366
- }
367
-
368
- /**
369
- * Use custom notices in the Vue app on the Settings screen.
370
- */
371
- public function hide_old_notices() {
372
-
373
- global $wp_version;
374
- if ( version_compare( $wp_version, '4.6', '<' ) ) {
375
- // remove_all_actions triggers an infinite loop on older versions.
376
- return;
377
- }
378
-
379
- $screen = get_current_screen();
380
- // Bail if we're not on a MonsterInsights screen.
381
- if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
382
- return;
383
- }
384
-
385
- // Hide admin notices on the settings screen.
386
- if ( monsterinsights_is_settings_page() ) {
387
- remove_all_actions( 'admin_notices' );
388
- }
389
-
390
- }
391
-
392
- /**
393
- * Update manual ua.
394
- */
395
- public function update_manual_ua() {
396
-
397
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
398
-
399
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
400
- return;
401
- }
402
-
403
- $manual_ua_code = isset( $_POST['manual_ua_code'] ) ? sanitize_text_field( wp_unslash( $_POST['manual_ua_code'] ) ) : '';
404
- $manual_ua_code = monsterinsights_is_valid_ua( $manual_ua_code ); // Also sanitizes the string.
405
- if ( ! empty( $_REQUEST['isnetwork'] ) && sanitize_text_field( wp_unslash( $_REQUEST['isnetwork'] ) ) ) {
406
- define( 'WP_NETWORK_ADMIN', true );
407
- }
408
- $manual_ua_code_old = is_network_admin() ? MonsterInsights()->auth->get_network_manual_ua() : MonsterInsights()->auth->get_manual_ua();
409
-
410
- if ( $manual_ua_code && $manual_ua_code_old && $manual_ua_code_old === $manual_ua_code ) {
411
- // Same code we had before
412
- // Do nothing.
413
- wp_send_json_success();
414
- } else if ( $manual_ua_code && $manual_ua_code_old && $manual_ua_code_old !== $manual_ua_code ) {
415
- // Different UA code.
416
- if ( is_network_admin() ) {
417
- MonsterInsights()->auth->set_network_manual_ua( $manual_ua_code );
418
- } else {
419
- MonsterInsights()->auth->set_manual_ua( $manual_ua_code );
420
- }
421
- } else if ( $manual_ua_code && empty( $manual_ua_code_old ) ) {
422
- // Move to manual.
423
- if ( is_network_admin() ) {
424
- MonsterInsights()->auth->set_network_manual_ua( $manual_ua_code );
425
- } else {
426
- MonsterInsights()->auth->set_manual_ua( $manual_ua_code );
427
- }
428
- } else if ( empty( $manual_ua_code ) && $manual_ua_code_old ) {
429
- // Deleted manual.
430
- if ( is_network_admin() ) {
431
- MonsterInsights()->auth->delete_network_manual_ua();
432
- } else {
433
- MonsterInsights()->auth->delete_manual_ua();
434
- }
435
- } else if ( isset( $_POST['manual_ua_code'] ) && empty( $manual_ua_code ) ) {
436
- wp_send_json_error( array(
437
- 'error' => __( 'Invalid UA code', 'google-analytics-for-wordpress' ),
438
- ) );
439
- }
440
-
441
- wp_send_json_success();
442
- }
443
-
444
- /**
445
- *
446
- */
447
- public function handle_settings_import() {
448
-
449
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
450
-
451
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
452
- return;
453
- }
454
-
455
- if ( ! isset( $_FILES['import_file'] ) ) {
456
- return;
457
- }
458
-
459
- $extension = explode( '.', sanitize_text_field( wp_unslash( $_FILES['import_file']['name'] ) ) );
460
- $extension = end( $extension );
461
-
462
- if ( 'json' !== $extension ) {
463
- wp_send_json_error( array(
464
- 'message' => esc_html__( 'Please upload a valid .json file', 'google-analytics-for-wordpress' ),
465
- ) );
466
- }
467
-
468
- $import_file = sanitize_text_field( wp_unslash( $_FILES['import_file']['tmp_name'] ) );
469
-
470
- $file = file_get_contents( $import_file );
471
- if ( empty( $file ) ) {
472
- wp_send_json_error( array(
473
- 'message' => esc_html__( 'Please upload a file to import', 'google-analytics-for-wordpress' ),
474
- ) );
475
- }
476
-
477
- // Retrieve the settings from the file and convert the json object to an array.
478
- $new_settings = json_decode( wp_json_encode( json_decode( $file ) ), true );
479
- $settings = monsterinsights_get_options();
480
- $exclude = array(
481
- 'analytics_profile',
482
- 'analytics_profile_code',
483
- 'analytics_profile_name',
484
- 'oauth_version',
485
- 'cron_last_run',
486
- 'monsterinsights_oauth_status',
487
- );
488
-
489
- foreach ( $exclude as $e ) {
490
- if ( ! empty( $new_settings[ $e ] ) ) {
491
- unset( $new_settings[ $e ] );
492
- }
493
- }
494
-
495
- if ( ! is_super_admin() ) {
496
- if ( ! empty( $new_settings['custom_code'] ) ) {
497
- unset( $new_settings['custom_code'] );
498
- }
499
- }
500
-
501
- foreach ( $exclude as $e ) {
502
- if ( ! empty( $settings[ $e ] ) ) {
503
- $new_settings = $settings[ $e ];
504
- }
505
- }
506
-
507
- global $monsterinsights_settings;
508
- $monsterinsights_settings = $new_settings;
509
-
510
- update_option( monsterinsights_get_option_name(), $new_settings );
511
-
512
- wp_send_json_success( $new_settings );
513
-
514
- }
515
-
516
- /**
517
- * Generic Ajax handler for grabbing report data in JSON.
518
- */
519
- public function get_report_data() {
520
-
521
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
522
-
523
- if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) {
524
- wp_send_json_error( array( 'message' => __( "You don't have permission to view MonsterInsights reports.", 'google-analytics-for-wordpress' ) ) );
525
- }
526
-
527
- if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
528
- define( 'WP_NETWORK_ADMIN', true );
529
- }
530
- $settings_page = admin_url( 'admin.php?page=monsterinsights_settings' );
531
-
532
- // Only for Pro users, require a license key to be entered first so we can link to things.
533
- if ( monsterinsights_is_pro_version() ) {
534
- if ( ! MonsterInsights()->license->is_site_licensed() && ! MonsterInsights()->license->is_network_licensed() ) {
535
- wp_send_json_error( array(
536
- 'message' => __( "You can't view MonsterInsights reports because you are not licensed.", 'google-analytics-for-wordpress' ),
537
- 'footer' => '<a href="' . $settings_page . '">' . __( 'Add your license', 'google-analytics-for-wordpress' ) . '</a>',
538
- ) );
539
- } else if ( MonsterInsights()->license->is_site_licensed() && ! MonsterInsights()->license->site_license_has_error() ) {
540
- // Good to go: site licensed.
541
- } else if ( MonsterInsights()->license->is_network_licensed() && ! MonsterInsights()->license->network_license_has_error() ) {
542
- // Good to go: network licensed.
543
- } else {
544
- wp_send_json_error( array( 'message' => __( "You can't view MonsterInsights reports due to license key errors.", 'google-analytics-for-wordpress' ) ) );
545
- }
546
- }
547
-
548
- // We do not have a current auth.
549
- $site_auth = MonsterInsights()->auth->get_viewname();
550
- $ms_auth = is_multisite() && MonsterInsights()->auth->get_network_viewname();
551
- if ( ! $site_auth && ! $ms_auth ) {
552
- wp_send_json_error( array( 'message' => __( 'You must authenticate with MonsterInsights before you can view reports.', 'google-analytics-for-wordpress' ) ) );
553
- }
554
-
555
- $report_name = isset( $_POST['report'] ) ? sanitize_text_field( wp_unslash( $_POST['report'] ) ) : '';
556
-
557
- if ( empty( $report_name ) ) {
558
- wp_send_json_error( array( 'message' => __( 'Unknown report. Try refreshing and retrying. Contact support if this issue persists.', 'google-analytics-for-wordpress' ) ) );
559
- }
560
-
561
- $report = MonsterInsights()->reporting->get_report( $report_name );
562
-
563
- $isnetwork = ! empty( $_REQUEST['isnetwork'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['isnetwork'] ) ) : '';
564
- $start = ! empty( $_POST['start'] ) ? sanitize_text_field( wp_unslash( $_POST['start'] ) ) : date( 'Y-m-d', strtotime( '-30 days' ) );
565
- $end = ! empty( $_POST['end'] ) ? sanitize_text_field( wp_unslash( $_POST['end'] ) ) : date( 'Y-m-d', strtotime( '-1 day' ) );
566
-
567
- $args = array(
568
- 'start' => $start,
569
- 'end' => $end,
570
- );
571
-
572
- if ( $isnetwork ) {
573
- $args['network'] = true;
574
- }
575
-
576
- if ( monsterinsights_is_pro_version() && ! MonsterInsights()->license->license_can( $report->level ) ) {
577
- $data = array(
578
- 'success' => false,
579
- 'error' => 'license_level',
580
- );
581
- } else {
582
- $data = apply_filters( 'monsterinsights_vue_reports_data', $report->get_data( $args ), $report_name, $report );
583
- }
584
-
585
- if ( ! empty( $data['success'] ) && ! empty( $data['data'] ) ) {
586
- wp_send_json_success( $data['data'] );
587
- } else if ( isset( $data['success'] ) && false === $data['success'] && ! empty( $data['error'] ) ) {
588
- // Use a custom handler for invalid_grant errors.
589
- if ( strpos( $data['error'], 'invalid_grant' ) > 0 ) {
590
- wp_send_json_error(
591
- array(
592
- 'message' => 'invalid_grant',
593
- 'footer' => '',
594
- )
595
- );
596
- }
597
-
598
- wp_send_json_error(
599
- array(
600
- 'message' => $data['error'],
601
- 'footer' => isset( $data['data']['footer'] ) ? $data['data']['footer'] : '',
602
- )
603
- );
604
- }
605
-
606
- wp_send_json_error( array( 'message' => __( 'We encountered an error when fetching the report data.', 'google-analytics-for-wordpress' ) ) );
607
-
608
- }
609
-
610
- /**
611
- * Install plugins which are not addons.
612
- */
613
- public function install_plugin() {
614
- check_ajax_referer( 'mi-admin-nonce', 'nonce' );
615
-
616
- if ( ! current_user_can( 'install_plugins' ) ) {
617
- wp_send_json( array(
618
- 'message' => esc_html__( 'You are not allowed to install plugins', 'ga-premium' ),
619
- ) );
620
- }
621
-
622
- $slug = isset( $_POST['slug'] ) ? sanitize_text_field( wp_unslash( $_POST['slug'] ) ) : false;
623
-
624
- if ( ! $slug ) {
625
- wp_send_json( array(
626
- 'message' => esc_html__( 'Missing plugin name.', 'ga-premium' ),
627
- ) );
628
- }
629
-
630
- include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
631
-
632
- $api = plugins_api( 'plugin_information', array(
633
- 'slug' => $slug,
634
- 'fields' => array(
635
- 'short_description' => false,
636
- 'sections' => false,
637
- 'requires' => false,
638
- 'rating' => false,
639
- 'ratings' => false,
640
- 'downloaded' => false,
641
- 'last_updated' => false,
642
- 'added' => false,
643
- 'tags' => false,
644
- 'compatibility' => false,
645
- 'homepage' => false,
646
- 'donate_link' => false,
647
- ),
648
- ) );
649
-
650
- if ( is_wp_error( $api ) ) {
651
- return $api->get_error_message();
652
- }
653
-
654
- $download_url = $api->download_link;
655
-
656
- $method = '';
657
- $url = add_query_arg(
658
- array(
659
- 'page' => 'monsterinsights-settings',
660
- ),
661
- admin_url( 'admin.php' )
662
- );
663
- $url = esc_url( $url );
664
-
665
- ob_start();
666
- if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) {
667
- $form = ob_get_clean();
668
-
669
- wp_send_json( array( 'form' => $form ) );
670
- }
671
-
672
- // If we are not authenticated, make it happen now.
673
- if ( ! WP_Filesystem( $creds ) ) {
674
- ob_start();
675
- request_filesystem_credentials( $url, $method, true, false, null );
676
- $form = ob_get_clean();
677
-
678
- wp_send_json( array( 'form' => $form ) );
679
-
680
- }
681
-
682
- // We do not need any extra credentials if we have gotten this far, so let's install the plugin.
683
- require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
684
- $base = MonsterInsights();
685
- require_once plugin_dir_path( $base->file ) . '/includes/admin/licensing/skin.php';
686
-
687
- // Create the plugin upgrader with our custom skin.
688
- $installer = new Plugin_Upgrader( new MonsterInsights_Skin() );
689
- $installer->install( $download_url );
690
-
691
- // Flush the cache and return the newly installed plugin basename.
692
- wp_cache_flush();
693
- wp_send_json_success();
694
-
695
- wp_die();
696
- }
697
-
698
- /**
699
- * Store that the first run notice has been dismissed so it doesn't show up again.
700
- */
701
- public function dismiss_first_time_notice() {
702
-
703
- monsterinsights_update_option( 'monsterinsights_first_run_notice', true );
704
-
705
- wp_send_json_success();
706
- }
707
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Routes for VUE are registered here.
4
+ *
5
+ * @package monsterinsights
6
+ */
7
+
8
+ /**
9
+ * Class MonsterInsights_Rest_Routes
10
+ */
11
+ class MonsterInsights_Rest_Routes {
12
+
13
+ /**
14
+ * MonsterInsights_Rest_Routes constructor.
15
+ */
16
+ public function __construct() {
17
+
18
+ add_action( 'wp_ajax_monsterinsights_vue_get_license', array( $this, 'get_license' ) );
19
+ add_action( 'wp_ajax_monsterinsights_vue_get_profile', array( $this, 'get_profile' ) );
20
+ add_action( 'wp_ajax_monsterinsights_vue_get_settings', array( $this, 'get_settings' ) );
21
+ add_action( 'wp_ajax_monsterinsights_vue_update_settings', array( $this, 'update_settings' ) );
22
+ add_action( 'wp_ajax_monsterinsights_vue_get_addons', array( $this, 'get_addons' ) );
23
+ add_action( 'wp_ajax_monsterinsights_update_manual_ua', array( $this, 'update_manual_ua' ) );
24
+ add_action( 'wp_ajax_monsterinsights_vue_get_report_data', array( $this, 'get_report_data' ) );
25
+ add_action( 'wp_ajax_monsterinsights_vue_install_plugin', array( $this, 'install_plugin' ) );
26
+ add_action( 'wp_ajax_monsterinsights_vue_notice_status', array( $this, 'get_notice_status' ) );
27
+ add_action( 'wp_ajax_monsterinsights_vue_notice_dismiss', array( $this, 'dismiss_notice' ) );
28
+
29
+ add_action( 'wp_ajax_monsterinsights_handle_settings_import', array( $this, 'handle_settings_import' ) );
30
+
31
+ add_action( 'admin_notices', array( $this, 'hide_old_notices' ), 0 );
32
+
33
+ add_action( 'wp_ajax_monsterinsights_vue_dismiss_first_time_notice', array( $this, 'dismiss_first_time_notice' ) );
34
+ }
35
+
36
+ /**
37
+ * Ajax handler for grabbing the license
38
+ */
39
+ public function get_license() {
40
+
41
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
42
+
43
+ if ( ! current_user_can( 'monsterinsights_view_dashboard' ) || ! monsterinsights_is_pro_version() ) {
44
+ return;
45
+ }
46
+
47
+ $site_license = array(
48
+ 'key' => MonsterInsights()->license->get_site_license_key(),
49
+ 'type' => MonsterInsights()->license->get_site_license_type(),
50
+ 'is_disabled' => MonsterInsights()->license->site_license_disabled(),
51
+ 'is_expired' => MonsterInsights()->license->site_license_expired(),
52
+ 'is_invalid' => MonsterInsights()->license->site_license_invalid(),
53
+ );
54
+ $network_license = array(
55
+ 'key' => MonsterInsights()->license->get_network_license_key(),
56
+ 'type' => MonsterInsights()->license->get_network_license_type(),
57
+ 'is_disabled' => MonsterInsights()->license->network_license_disabled(),
58
+ 'is_expired' => MonsterInsights()->license->network_license_expired(),
59
+ 'is_invalid' => MonsterInsights()->license->network_license_disabled(),
60
+ );
61
+
62
+ wp_send_json( array(
63
+ 'site' => $site_license,
64
+ 'network' => $network_license,
65
+ ) );
66
+
67
+ }
68
+
69
+ /**
70
+ * Ajax handler for grabbing the current authenticated profile.
71
+ */
72
+ public function get_profile() {
73
+
74
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
75
+
76
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
77
+ return;
78
+ }
79
+
80
+ wp_send_json( array(
81
+ 'ua' => MonsterInsights()->auth->get_ua(),
82
+ 'viewname' => MonsterInsights()->auth->get_viewname(),
83
+ 'manual_ua' => MonsterInsights()->auth->get_manual_ua(),
84
+ 'network_ua' => MonsterInsights()->auth->get_network_ua(),
85
+ 'network_viewname' => MonsterInsights()->auth->get_network_viewname(),
86
+ 'network_manual_ua' => MonsterInsights()->auth->get_network_manual_ua(),
87
+ ) );
88
+
89
+ }
90
+
91
+ /**
92
+ * Ajax handler for grabbing the settings.
93
+ */
94
+ public function get_settings() {
95
+
96
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
97
+
98
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
99
+ return;
100
+ }
101
+
102
+ $options = monsterinsights_get_options();
103
+
104
+ // Array fields are needed even if empty.
105
+ $array_fields = array( 'view_reports', 'save_settings', 'ignore_users' );
106
+ foreach ( $array_fields as $array_field ) {
107
+ if ( ! isset( $options[ $array_field ] ) ) {
108
+ $options[ $array_field ] = array();
109
+ }
110
+ }
111
+ if ( isset( $options['custom_code'] ) ) {
112
+ $options['custom_code'] = stripslashes( $options['custom_code'] );
113
+ }
114
+
115
+ //add email summaries options
116
+ if ( monsterinsights_is_pro_version() ) {
117
+ $default_email = array(
118
+ 'email' => get_option( 'admin_email' ),
119
+ );
120
+
121
+ if ( ! isset( $options['email_summaries'] ) ) {
122
+ $options['email_summaries'] = 'on';
123
+ }
124
+
125
+ if ( ! isset( $options['summaries_email_addresses'] ) ) {
126
+ $options['summaries_email_addresses'] = array(
127
+ $default_email,
128
+ );
129
+ }
130
+
131
+ if ( ! isset( $options['summaries_html_template'] ) ) {
132
+ $options['summaries_html_template'] = 'yes';
133
+ }
134
+
135
+
136
+ if ( ! isset( $options['summaries_carbon_copy'] ) ) {
137
+ $options['summaries_carbon_copy'] = 'no';
138
+ }
139
+
140
+
141
+ if ( ! isset( $options['summaries_header_image'] ) ) {
142
+ $options['summaries_header_image'] = '';
143
+ }
144
+ }
145
+
146
+ wp_send_json( $options );
147
+
148
+ }
149
+
150
+ /**
151
+ * Ajax handler for updating the settings.
152
+ */
153
+ public function update_settings() {
154
+
155
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
156
+
157
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
158
+ return;
159
+ }
160
+
161
+ if ( isset( $_POST['setting'] ) ) {
162
+ $setting = sanitize_text_field( wp_unslash( $_POST['setting'] ) );
163
+ if ( isset( $_POST['value'] ) ) {
164
+ $value = $this->handle_sanitization( $setting, $_POST['value'] );
165
+ monsterinsights_update_option( $setting, $value );
166
+ do_action( 'monsterinsights_after_update_settings', $setting, $value );
167
+ } else {
168
+ monsterinsights_update_option( $setting, false );
169
+ do_action( 'monsterinsights_after_update_settings', $setting, false );
170
+ }
171
+ }
172
+
173
+ wp_send_json_success();
174
+
175
+ }
176
+
177
+ /**
178
+ * Sanitization specific to each field.
179
+ *
180
+ * @param string $field The key of the field to sanitize.
181
+ * @param string $value The value of the field to sanitize.
182
+ *
183
+ * @return mixed The sanitized input.
184
+ */
185
+ private function handle_sanitization( $field, $value ) {
186
+
187
+ $value = wp_unslash( $value );
188
+
189
+ // Textarea fields.
190
+ $textarea_fields = array(
191
+ 'custom_code',
192
+ );
193
+
194
+ if ( in_array( $field, $textarea_fields, true ) ) {
195
+ if ( function_exists( 'sanitize_textarea_field' ) ) {
196
+ return sanitize_textarea_field( $value );
197
+ } else {
198
+ return wp_kses( $value, array() );
199
+ }
200
+ }
201
+
202
+ $array_value = json_decode( $value, true );
203
+ if ( is_array( $array_value ) ) {
204
+ $value = $array_value;
205
+ // Don't save empty values.
206
+ foreach ( $value as $key => $item ) {
207
+ if ( is_array( $item ) ) {
208
+ $empty = true;
209
+ foreach ( $item as $item_value ) {
210
+ if ( ! empty( $item_value ) ) {
211
+ $empty = false;
212
+ }
213
+ }
214
+ if ( $empty ) {
215
+ unset( $value[ $key ] );
216
+ }
217
+ }
218
+ }
219
+
220
+ // Reset array keys because JavaScript can't handle arrays with non-sequential keys.
221
+ $value = array_values( $value );
222
+
223
+ return $value;
224
+ }
225
+
226
+ return sanitize_text_field( $value );
227
+
228
+ }
229
+
230
+ /**
231
+ * Return the state of the addons ( installed, activated )
232
+ */
233
+ public function get_addons() {
234
+
235
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
236
+
237
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
238
+ return;
239
+ }
240
+
241
+ if ( isset( $_POST['network'] ) && intval( $_POST['network'] ) > 0 ) {
242
+ define( 'WP_NETWORK_ADMIN', true );
243
+ }
244
+
245
+ $addons_data = monsterinsights_get_addons();
246
+ $parsed_addons = array();
247
+ $installed_plugins = get_plugins();
248
+
249
+ if ( ! is_array( $addons_data ) ) {
250
+ $addons_data = array();
251
+ }
252
+
253
+ foreach ( $addons_data as $addons_type => $addons ) {
254
+ foreach ( $addons as $addon ) {
255
+ $slug = 'monsterinsights-' . $addon->slug;
256
+ if ( 'monsterinsights-ecommerce' === $slug ) {
257
+ $addon = $this->get_addon( $installed_plugins, $addons_type, $addon, $slug );
258
+ if ( empty( $addon->installed ) ) {
259
+ $slug = 'ga-ecommerce';
260
+ $addon = $this->get_addon( $installed_plugins, $addons_type, $addon, $slug );
261
+ }
262
+ } else {
263
+ $addon = $this->get_addon( $installed_plugins, $addons_type, $addon, $slug );
264
+ }
265
+ $parsed_addons[ $addon->slug ] = $addon;
266
+ }
267
+ }
268
+
269
+ // Include data about the plugins needed by some addons ( WooCommerce, EDD, Google AMP, CookieBot, etc ).
270
+ // WooCommerce.
271
+ $parsed_addons['woocommerce'] = array(
272
+ 'active' => class_exists( 'WooCommerce' ),
273
+ );
274
+ // Edd.
275
+ $parsed_addons['easy_digital_downloads'] = array(
276
+ 'active' => class_exists( 'Easy_Digital_Downloads' ),
277
+ );
278
+ // MemberPress.
279
+ $parsed_addons['memberpress'] = array(
280
+ 'active' => defined( 'MEPR_VERSION' ) && version_compare( MEPR_VERSION, '1.3.43', '>' ),
281
+ );
282
+ // LifterLMS.
283
+ $parsed_addons['lifterlms'] = array(
284
+ 'active' => function_exists( 'LLMS' ) && version_compare( LLMS()->version, '3.32.0', '>=' ),
285
+ );
286
+ // Cookiebot.
287
+ $parsed_addons['cookiebot'] = array(
288
+ 'active' => function_exists( 'cookiebot_active' ) && cookiebot_active(),
289
+ );
290
+ // Cookie Notice.
291
+ $parsed_addons['cookie_notice'] = array(
292
+ 'active' => class_exists( 'Cookie_Notice' ),
293
+ );
294
+ // Fb Instant Articles.
295
+ $parsed_addons['instant_articles'] = array(
296
+ 'active' => defined( 'IA_PLUGIN_VERSION' ) && version_compare( IA_PLUGIN_VERSION, '3.3.4', '>' ),
297
+ );
298
+ // Google AMP.
299
+ $parsed_addons['google_amp'] = array(
300
+ 'active' => defined( 'AMP__FILE__' ),
301
+ );
302
+ // WPForms.
303
+ $parsed_addons['wpforms-lite'] = array(
304
+ 'active' => function_exists( 'wpforms' ),
305
+ 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugin-wpforms.png',
306
+ 'title' => 'WPForms',
307
+ 'excerpt' => __( 'The most beginner friendly drag & drop WordPress forms plugin allowing you to create beautiful contact forms, subscription forms, payment forms, and more in minutes, not hours!', 'google-analytics-for-wordpress' ),
308
+ 'installed' => array_key_exists( 'wpforms-lite/wpforms.php', $installed_plugins ),
309
+ 'basename' => 'wpforms-lite/wpforms.php',
310
+ 'slug' => 'wpforms-lite',
311
+ );
312
+ // OptinMonster.
313
+ $parsed_addons['optinmonster'] = array(
314
+ 'active' => class_exists( 'OMAPI' ),
315
+ 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugin-om.png',
316
+ 'title' => 'OptinMonster',
317
+ 'excerpt' => __( 'Our high-converting optin forms like Exit-Intent® popups, Fullscreen Welcome Mats, and Scroll boxes help you dramatically boost conversions and get more email subscribers.', 'google-analytics-for-wordpress' ),
318
+ 'installed' => array_key_exists( 'optinmonster/optin-monster-wp-api.php', $installed_plugins ),
319
+ 'basename' => 'optinmonster/optin-monster-wp-api.php',
320
+ 'slug' => 'optinmonster',
321
+ );
322
+ // WP Mail Smtp.
323
+ $parsed_addons['wp-mail-smtp'] = array(
324
+ 'active' => function_exists( 'wp_mail_smtp' ),
325
+ 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/plugin-smtp.png',
326
+ 'title' => 'WP Mail SMTP',
327
+ 'excerpt' => __( 'SMTP (Simple Mail Transfer Protocol) is an industry standard for sending emails. SMTP helps increase email deliverability by using proper authentication.', 'google-analytics-for-wordpress' ),
328
+ 'installed' => array_key_exists( 'wp-mail-smtp/wp_mail_smtp.php', $installed_plugins ),
329
+ 'basename' => 'wp-mail-smtp/wp_mail_smtp.php',
330
+ 'slug' => 'wp-mail-smtp',
331
+ );
332
+ // Pretty Links
333
+ $parsed_addons['pretty-link'] = array(
334
+ 'active' => class_exists( 'PrliBaseController' ),
335
+ 'icon' => '',
336
+ 'title' => 'Pretty Links',
337
+ 'excerpt' => __( 'Pretty Links helps you shrink, beautify, track, manage and share any URL on or off of your WordPress website. Create links that look how you want using your own domain name!', 'google-analytics-for-wordpress' ),
338
+ 'installed' => array_key_exists( 'pretty-link/pretty-link.php', $installed_plugins ),
339
+ 'basename' => 'pretty-link/pretty-link.php',
340
+ 'slug' => 'pretty-link',
341
+ );
342
+ // SeedProd.
343
+ $parsed_addons['coming-soon'] = array(
344
+ 'active' => function_exists( 'seed_csp4_activation' ),
345
+ 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/seedprod.png',
346
+ 'title' => 'SeedProd',
347
+ 'excerpt' => __( 'Better Coming Soon & Maintenance Mode Pages', 'google-analytics-for-wordpress' ),
348
+ 'installed' => array_key_exists( 'coming-soon/coming-soon.php', $installed_plugins ),
349
+ 'basename' => 'coming-soon/coming-soon.php',
350
+ 'slug' => 'coming-soon',
351
+ );
352
+ $parsed_addons['rafflepress'] = array(
353
+ 'active' => function_exists( 'rafflepress_lite_activation' ),
354
+ 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/rafflepress.png',
355
+ 'title' => 'RafflePress',
356
+ 'excerpt' => __( 'Get More Traffic with Viral Giveaways', 'google-analytics-for-wordpress' ),
357
+ 'installed' => array_key_exists( 'rafflepress/rafflepress.php', $installed_plugins ),
358
+ 'basename' => 'rafflepress/rafflepress.php',
359
+ 'slug' => 'rafflepress',
360
+ );
361
+ $parsed_addons['trustpulse-api'] = array(
362
+ 'active' => class_exists( 'TPAPI' ),
363
+ 'icon' => plugin_dir_url( MONSTERINSIGHTS_PLUGIN_FILE ) . 'assets/images/trustpulse.png',
364
+ 'title' => 'TrustPulse',
365
+ 'excerpt' => __( 'Social Proof Notifications that Boost Sales', 'google-analytics-for-wordpress' ),
366
+ 'installed' => array_key_exists( 'trustpulse-api/trustpulse.php', $installed_plugins ),
367
+ 'basename' => 'trustpulse-api/trustpulse.php',
368
+ 'slug' => 'trustpulse-api',
369
+ );
370
+ // Gravity Forms.
371
+ $parsed_addons['gravity_forms'] = array(
372
+ 'active' => class_exists( 'GFCommon' ),
373
+ );
374
+ // Formidable Forms.
375
+ $parsed_addons['formidable_forms'] = array(
376
+ 'active' => class_exists( 'FrmHooksController' ),
377
+ );
378
+ // Manual UA Addon.
379
+ if ( ! isset( $parsed_addons['manual_ua'] ) ) {
380
+ $parsed_addons['manual_ua'] = array(
381
+ 'active' => class_exists( 'MonsterInsights_Manual_UA' ),
382
+ );
383
+ }
384
+
385
+ wp_send_json( $parsed_addons );
386
+ }
387
+
388
+ public function get_addon( $installed_plugins, $addons_type, $addon, $slug ) {
389
+ $active = false;
390
+ $installed = false;
391
+ $plugin_basename = monsterinsights_get_plugin_basename_from_slug( $slug );
392
+
393
+ if ( isset( $installed_plugins[ $plugin_basename ] ) ) {
394
+ $installed = true;
395
+
396
+ if ( is_multisite() && is_network_admin() ) {
397
+ $active = is_plugin_active_for_network( $plugin_basename );
398
+ } else {
399
+ $active = is_plugin_active( $plugin_basename );
400
+ }
401
+ }
402
+ if ( empty( $addon->url ) ) {
403
+ $addon->url = '';
404
+ }
405
+
406
+ $addon->type = $addons_type;
407
+ $addon->installed = $installed;
408
+ $addon->active = $active;
409
+ $addon->basename = $plugin_basename;
410
+
411
+ return $addon;
412
+ }
413
+
414
+ /**
415
+ * Use custom notices in the Vue app on the Settings screen.
416
+ */
417
+ public function hide_old_notices() {
418
+
419
+ global $wp_version;
420
+ if ( version_compare( $wp_version, '4.6', '<' ) ) {
421
+ // remove_all_actions triggers an infinite loop on older versions.
422
+ return;
423
+ }
424
+
425
+ $screen = get_current_screen();
426
+ // Bail if we're not on a MonsterInsights screen.
427
+ if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
428
+ return;
429
+ }
430
+
431
+ // Hide admin notices on the settings screen.
432
+ if ( monsterinsights_is_settings_page() ) {
433
+ remove_all_actions( 'admin_notices' );
434
+ }
435
+
436
+ }
437
+
438
+ /**
439
+ * Update manual ua.
440
+ */
441
+ public function update_manual_ua() {
442
+
443
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
444
+
445
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
446
+ return;
447
+ }
448
+
449
+ $manual_ua_code = isset( $_POST['manual_ua_code'] ) ? sanitize_text_field( wp_unslash( $_POST['manual_ua_code'] ) ) : '';
450
+ $manual_ua_code = monsterinsights_is_valid_ua( $manual_ua_code ); // Also sanitizes the string.
451
+ if ( ! empty( $_REQUEST['isnetwork'] ) && sanitize_text_field( wp_unslash( $_REQUEST['isnetwork'] ) ) ) {
452
+ define( 'WP_NETWORK_ADMIN', true );
453
+ }
454
+ $manual_ua_code_old = is_network_admin() ? MonsterInsights()->auth->get_network_manual_ua() : MonsterInsights()->auth->get_manual_ua();
455
+
456
+ if ( $manual_ua_code && $manual_ua_code_old && $manual_ua_code_old === $manual_ua_code ) {
457
+ // Same code we had before
458
+ // Do nothing.
459
+ wp_send_json_success();
460
+ } else if ( $manual_ua_code && $manual_ua_code_old && $manual_ua_code_old !== $manual_ua_code ) {
461
+ // Different UA code.
462
+ if ( is_network_admin() ) {
463
+ MonsterInsights()->auth->set_network_manual_ua( $manual_ua_code );
464
+ } else {
465
+ MonsterInsights()->auth->set_manual_ua( $manual_ua_code );
466
+ }
467
+ } else if ( $manual_ua_code && empty( $manual_ua_code_old ) ) {
468
+ // Move to manual.
469
+ if ( is_network_admin() ) {
470
+ MonsterInsights()->auth->set_network_manual_ua( $manual_ua_code );
471
+ } else {
472
+ MonsterInsights()->auth->set_manual_ua( $manual_ua_code );
473
+ }
474
+ } else if ( empty( $manual_ua_code ) && $manual_ua_code_old ) {
475
+ // Deleted manual.
476
+ if ( is_network_admin() ) {
477
+ MonsterInsights()->auth->delete_network_manual_ua();
478
+ } else {
479
+ MonsterInsights()->auth->delete_manual_ua();
480
+ }
481
+ } else if ( isset( $_POST['manual_ua_code'] ) && empty( $manual_ua_code ) ) {
482
+ wp_send_json_error( array(
483
+ 'error' => __( 'Invalid UA code', 'google-analytics-for-wordpress' ),
484
+ ) );
485
+ }
486
+
487
+ wp_send_json_success();
488
+ }
489
+
490
+ /**
491
+ *
492
+ */
493
+ public function handle_settings_import() {
494
+
495
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
496
+
497
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
498
+ return;
499
+ }
500
+
501
+ if ( ! isset( $_FILES['import_file'] ) ) {
502
+ return;
503
+ }
504
+
505
+ $extension = explode( '.', sanitize_text_field( wp_unslash( $_FILES['import_file']['name'] ) ) );
506
+ $extension = end( $extension );
507
+
508
+ if ( 'json' !== $extension ) {
509
+ wp_send_json_error( array(
510
+ 'message' => esc_html__( 'Please upload a valid .json file', 'google-analytics-for-wordpress' ),
511
+ ) );
512
+ }
513
+
514
+ $import_file = sanitize_text_field( wp_unslash( $_FILES['import_file']['tmp_name'] ) );
515
+
516
+ $file = file_get_contents( $import_file );
517
+ if ( empty( $file ) ) {
518
+ wp_send_json_error( array(
519
+ 'message' => esc_html__( 'Please upload a file to import', 'google-analytics-for-wordpress' ),
520
+ ) );
521
+ }
522
+
523
+ // Retrieve the settings from the file and convert the json object to an array.
524
+ $new_settings = json_decode( wp_json_encode( json_decode( $file ) ), true );
525
+ $settings = monsterinsights_get_options();
526
+ $exclude = array(
527
+ 'analytics_profile',
528
+ 'analytics_profile_code',
529
+ 'analytics_profile_name',
530
+ 'oauth_version',
531
+ 'cron_last_run',
532
+ 'monsterinsights_oauth_status',
533
+ );
534
+
535
+ foreach ( $exclude as $e ) {
536
+ if ( ! empty( $new_settings[ $e ] ) ) {
537
+ unset( $new_settings[ $e ] );
538
+ }
539
+ }
540
+
541
+ if ( ! is_super_admin() ) {
542
+ if ( ! empty( $new_settings['custom_code'] ) ) {
543
+ unset( $new_settings['custom_code'] );
544
+ }
545
+ }
546
+
547
+ foreach ( $exclude as $e ) {
548
+ if ( ! empty( $settings[ $e ] ) ) {
549
+ $new_settings = $settings[ $e ];
550
+ }
551
+ }
552
+
553
+ global $monsterinsights_settings;
554
+ $monsterinsights_settings = $new_settings;
555
+
556
+ update_option( monsterinsights_get_option_name(), $new_settings );
557
+
558
+ wp_send_json_success( $new_settings );
559
+
560
+ }
561
+
562
+ /**
563
+ * Generic Ajax handler for grabbing report data in JSON.
564
+ */
565
+ public function get_report_data() {
566
+
567
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
568
+
569
+ if ( ! current_user_can( 'monsterinsights_view_dashboard' ) ) {
570
+ wp_send_json_error( array( 'message' => __( "You don't have permission to view MonsterInsights reports.", 'google-analytics-for-wordpress' ) ) );
571
+ }
572
+
573
+ if ( ! empty( $_REQUEST['isnetwork'] ) && $_REQUEST['isnetwork'] ) {
574
+ define( 'WP_NETWORK_ADMIN', true );
575
+ }
576
+ $settings_page = admin_url( 'admin.php?page=monsterinsights_settings' );
577
+
578
+ // Only for Pro users, require a license key to be entered first so we can link to things.
579
+ if ( monsterinsights_is_pro_version() ) {
580
+ if ( ! MonsterInsights()->license->is_site_licensed() && ! MonsterInsights()->license->is_network_licensed() ) {
581
+ wp_send_json_error( array(
582
+ 'message' => __( "You can't view MonsterInsights reports because you are not licensed.", 'google-analytics-for-wordpress' ),
583
+ 'footer' => '<a href="' . $settings_page . '">' . __( 'Add your license', 'google-analytics-for-wordpress' ) . '</a>',
584
+ ) );
585
+ } else if ( MonsterInsights()->license->is_site_licensed() && ! MonsterInsights()->license->site_license_has_error() ) {
586
+ // Good to go: site licensed.
587
+ } else if ( MonsterInsights()->license->is_network_licensed() && ! MonsterInsights()->license->network_license_has_error() ) {
588
+ // Good to go: network licensed.
589
+ } else {
590
+ wp_send_json_error( array( 'message' => __( "You can't view MonsterInsights reports due to license key errors.", 'google-analytics-for-wordpress' ) ) );
591
+ }
592
+ }
593
+
594
+ // We do not have a current auth.
595
+ $site_auth = MonsterInsights()->auth->get_viewname();
596
+ $ms_auth = is_multisite() && MonsterInsights()->auth->get_network_viewname();
597
+ if ( ! $site_auth && ! $ms_auth ) {
598
+ wp_send_json_error( array( 'message' => __( 'You must authenticate with MonsterInsights before you can view reports.', 'google-analytics-for-wordpress' ) ) );
599
+ }
600
+
601
+ $report_name = isset( $_POST['report'] ) ? sanitize_text_field( wp_unslash( $_POST['report'] ) ) : '';
602
+
603
+ if ( empty( $report_name ) ) {
604
+ wp_send_json_error( array( 'message' => __( 'Unknown report. Try refreshing and retrying. Contact support if this issue persists.', 'google-analytics-for-wordpress' ) ) );
605
+ }
606
+
607
+ $report = MonsterInsights()->reporting->get_report( $report_name );
608
+
609
+ $isnetwork = ! empty( $_REQUEST['isnetwork'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['isnetwork'] ) ) : '';
610
+ $start = ! empty( $_POST['start'] ) ? sanitize_text_field( wp_unslash( $_POST['start'] ) ) : $report->default_start_date();
611
+ $end = ! empty( $_POST['end'] ) ? sanitize_text_field( wp_unslash( $_POST['end'] ) ) : $report->default_end_date();
612
+
613
+ $args = array(
614
+ 'start' => $start,
615
+ 'end' => $end,
616
+ );
617
+
618
+ if ( $isnetwork ) {
619
+ $args['network'] = true;
620
+ }
621
+
622
+ if ( monsterinsights_is_pro_version() && ! MonsterInsights()->license->license_can( $report->level ) ) {
623
+ $data = array(
624
+ 'success' => false,
625
+ 'error' => 'license_level',
626
+ );
627
+ } else {
628
+ $data = apply_filters( 'monsterinsights_vue_reports_data', $report->get_data( $args ), $report_name, $report );
629
+ }
630
+
631
+ if ( ! empty( $data['success'] ) && ! empty( $data['data'] ) ) {
632
+ wp_send_json_success( $data['data'] );
633
+ } else if ( isset( $data['success'] ) && false === $data['success'] && ! empty( $data['error'] ) ) {
634
+ // Use a custom handler for invalid_grant errors.
635
+ if ( strpos( $data['error'], 'invalid_grant' ) > 0 ) {
636
+ wp_send_json_error(
637
+ array(
638
+ 'message' => 'invalid_grant',
639
+ 'footer' => '',
640
+ )
641
+ );
642
+ }
643
+
644
+ wp_send_json_error(
645
+ array(
646
+ 'message' => $data['error'],
647
+ 'footer' => isset( $data['data']['footer'] ) ? $data['data']['footer'] : '',
648
+ )
649
+ );
650
+ }
651
+
652
+ wp_send_json_error( array( 'message' => __( 'We encountered an error when fetching the report data.', 'google-analytics-for-wordpress' ) ) );
653
+
654
+ }
655
+
656
+ /**
657
+ * Install plugins which are not addons.
658
+ */
659
+ public function install_plugin() {
660
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
661
+
662
+ if ( ! current_user_can( 'install_plugins' ) ) {
663
+ wp_send_json( array(
664
+ 'message' => esc_html__( 'You are not allowed to install plugins', 'ga-premium' ),
665
+ ) );
666
+ }
667
+
668
+ $slug = isset( $_POST['slug'] ) ? sanitize_text_field( wp_unslash( $_POST['slug'] ) ) : false;
669
+
670
+ if ( ! $slug ) {
671
+ wp_send_json( array(
672
+ 'message' => esc_html__( 'Missing plugin name.', 'ga-premium' ),
673
+ ) );
674
+ }
675
+
676
+ include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
677
+
678
+ $api = plugins_api( 'plugin_information', array(
679
+ 'slug' => $slug,
680
+ 'fields' => array(
681
+ 'short_description' => false,
682
+ 'sections' => false,
683
+ 'requires' => false,
684
+ 'rating' => false,
685
+ 'ratings' => false,
686
+ 'downloaded' => false,
687
+ 'last_updated' => false,
688
+ 'added' => false,
689
+ 'tags' => false,
690
+ 'compatibility' => false,
691
+ 'homepage' => false,
692
+ 'donate_link' => false,
693
+ ),
694
+ ) );
695
+
696
+ if ( is_wp_error( $api ) ) {
697
+ return $api->get_error_message();
698
+ }
699
+
700
+ $download_url = $api->download_link;
701
+
702
+ $method = '';
703
+ $url = add_query_arg(
704
+ array(
705
+ 'page' => 'monsterinsights-settings',
706
+ ),
707
+ admin_url( 'admin.php' )
708
+ );
709
+ $url = esc_url( $url );
710
+
711
+ ob_start();
712
+ if ( false === ( $creds = request_filesystem_credentials( $url, $method, false, false, null ) ) ) {
713
+ $form = ob_get_clean();
714
+
715
+ wp_send_json( array( 'form' => $form ) );
716
+ }
717
+
718
+ // If we are not authenticated, make it happen now.
719
+ if ( ! WP_Filesystem( $creds ) ) {
720
+ ob_start();
721
+ request_filesystem_credentials( $url, $method, true, false, null );
722
+ $form = ob_get_clean();
723
+
724
+ wp_send_json( array( 'form' => $form ) );
725
+
726
+ }
727
+
728
+ // We do not need any extra credentials if we have gotten this far, so let's install the plugin.
729
+ $base = MonsterInsights();
730
+ require_once plugin_dir_path( $base->file ) . '/includes/admin/licensing/plugin-upgrader.php';
731
+ require_once plugin_dir_path( $base->file ) . '/includes/admin/licensing/skin.php';
732
+
733
+ // Prevent language upgrade in ajax calls.
734
+ remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
735
+ // Create the plugin upgrader with our custom skin.
736
+ $installer = new MonsterInsights_Plugin_Upgrader( new MonsterInsights_Skin() );
737
+ $installer->install( $download_url );
738
+
739
+ // Flush the cache and return the newly installed plugin basename.
740
+ wp_cache_flush();
741
+ wp_send_json_success();
742
+
743
+ wp_die();
744
+ }
745
+
746
+ /**
747
+ * Store that the first run notice has been dismissed so it doesn't show up again.
748
+ */
749
+ public function dismiss_first_time_notice() {
750
+
751
+ monsterinsights_update_option( 'monsterinsights_first_run_notice', true );
752
+
753
+ wp_send_json_success();
754
+ }
755
+
756
+ /**
757
+ * Get the notice status by id.
758
+ */
759
+ public function get_notice_status() {
760
+
761
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
762
+
763
+ $notice_id = empty( $_POST['notice'] ) ? false : sanitize_text_field( wp_unslash( $_POST['notice'] ) );
764
+ if ( ! $notice_id ) {
765
+ wp_send_json_error();
766
+ }
767
+ $is_dismissed = MonsterInsights()->notices->is_dismissed( $notice_id );
768
+
769
+ wp_send_json_success( array(
770
+ 'dismissed' => $is_dismissed,
771
+ ) );
772
+ }
773
+
774
+ /**
775
+ * Dismiss notices by id.
776
+ */
777
+ public function dismiss_notice() {
778
+
779
+ check_ajax_referer( 'mi-admin-nonce', 'nonce' );
780
+
781
+ $notice_id = empty( $_POST['notice'] ) ? false : sanitize_text_field( wp_unslash( $_POST['notice'] ) );
782
+ if ( ! $notice_id ) {
783
+ wp_send_json_error();
784
+ }
785
+ MonsterInsights()->notices->dismiss( $notice_id );
786
+
787
+ wp_send_json_success();
788
+ }
789
+ }
includes/admin/tracking.php CHANGED
@@ -1,247 +1,247 @@
1
- <?php
2
- /**
3
- * Tracking functions for reporting plugin usage to the MonsterInsights site for users that have opted in
4
- *
5
- * @package MonsterInsights
6
- * @subpackage Admin
7
- * @copyright Copyright (c) 2018, Chris Christoff
8
- * @since 7.0.0
9
- */
10
-
11
- // Exit if accessed directly
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit;
14
- }
15
-
16
- /**
17
- * Usage tracking
18
- *
19
- * @access public
20
- * @since 7.0.0
21
- * @return void
22
- */
23
- class MonsterInsights_Tracking {
24
-
25
- public function __construct() {
26
- add_action( 'init', array( $this, 'schedule_send' ) );
27
- add_action( 'monsterinsights_settings_save_general_end', array( $this, 'check_for_settings_optin' ) );
28
- add_action( 'admin_head', array( $this, 'check_for_optin' ) );
29
- add_action( 'admin_head', array( $this, 'check_for_optout' ) );
30
- add_filter( 'cron_schedules', array( $this, 'add_schedules' ) );
31
- add_action( 'monsterinsights_usage_tracking_cron', array( $this, 'send_checkin' ) );
32
- }
33
-
34
- private function get_data() {
35
- $data = array();
36
-
37
- // Retrieve current theme info
38
- $theme_data = wp_get_theme();
39
- $tracking_mode = monsterinsights_get_option( 'tracking_mode', 'analytics' );
40
- $events_mode = monsterinsights_get_option( 'events_mode', 'none' );
41
- $update_mode = monsterinsights_get_option( 'automatic_updates', false );
42
-
43
- if ( $tracking_mode === false ) {
44
- $tracking_mode = 'analytics';
45
- }
46
- if ( $events_mode === false ) {
47
- $events_mode = 'none';
48
- }
49
-
50
- if ( $update_mode === false ) {
51
- $update_mode = 'none';
52
- }
53
-
54
- $count_b = 1;
55
- if ( is_multisite() ) {
56
- if ( function_exists( 'get_blog_count' ) ) {
57
- $count_b = get_blog_count();
58
- } else {
59
- $count_b = 'Not Set';
60
- }
61
- }
62
-
63
- $usesauth = 'No';
64
- $local = MonsterInsights()->auth->is_authed();
65
- $network = MonsterInsights()->auth->is_network_authed();
66
-
67
- if ( $local && $network ) {
68
- $usesauth = 'Both';
69
- } else if ( $local ) {
70
- $usesauth = 'Local';
71
- } else if ( $network ) {
72
- $usesauth = 'Network';
73
- }
74
-
75
- $data['php_version'] = phpversion();
76
- $data['mi_version'] = MONSTERINSIGHTS_VERSION;
77
- $data['wp_version'] = get_bloginfo( 'version' );
78
- $data['server'] = isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '';
79
- $data['over_time'] = get_option( 'monsterinsights_over_time', array() );
80
- $data['multisite'] = is_multisite();
81
- $data['url'] = home_url();
82
- $data['themename'] = $theme_data->Name;
83
- $data['themeversion'] = $theme_data->Version;
84
- $data['email'] = get_bloginfo( 'admin_email' );
85
- $data['key'] = monsterinsights_get_license_key();
86
- $data['sas'] = monsterinsights_get_shareasale_id();
87
- $data['settings'] = monsterinsights_get_options();
88
- $data['tracking_mode'] = $tracking_mode;
89
- $data['events_mode'] = $events_mode;
90
- $data['autoupdate'] = $update_mode;
91
- $data['pro'] = (int) monsterinsights_is_pro_version();
92
- $data['sites'] = $count_b;
93
- $data['usagetracking'] = get_option( 'monsterinsights_usage_tracking_config', false );
94
- $data['usercount'] = function_exists( 'get_user_count' ) ? get_user_count() : 'Not Set';
95
- $data['usesauth'] = $usesauth;
96
- $data['timezoneoffset']= date('P');
97
- $data['installed_lite']= get_option( 'monsterinsights_installed_lite', array() );
98
- $data['installed_pro'] = get_option( 'monsterinsights_installed_pro', array() );
99
-
100
-
101
-
102
- // Retrieve current plugin information
103
- if( ! function_exists( 'get_plugins' ) ) {
104
- include ABSPATH . '/wp-admin/includes/plugin.php';
105
- }
106
-
107
- $plugins = array_keys( get_plugins() );
108
- $active_plugins = get_option( 'active_plugins', array() );
109
-
110
- foreach ( $plugins as $key => $plugin ) {
111
- if ( in_array( $plugin, $active_plugins ) ) {
112
- // Remove active plugins from list so we can show active and inactive separately
113
- unset( $plugins[ $key ] );
114
- }
115
- }
116
-
117
- $data['active_plugins'] = $active_plugins;
118
- $data['inactive_plugins'] = $plugins;
119
- $data['locale'] = get_locale();
120
-
121
- return $data;
122
- }
123
-
124
- public function send_checkin( $override = false, $ignore_last_checkin = false ) {
125
-
126
- $home_url = trailingslashit( home_url() );
127
- if ( strpos( $home_url, 'monsterinsights.com' ) !== false ) {
128
- return false;
129
- }
130
-
131
- if( ! $this->tracking_allowed() && ! $override ) {
132
- return false;
133
- }
134
-
135
- // Send a maximum of once per week
136
- $last_send = get_option( 'monsterinsights_usage_tracking_last_checkin' );
137
- if ( is_numeric( $last_send ) && $last_send > strtotime( '-1 week' ) && ! $ignore_last_checkin ) {
138
- return false;
139
- }
140
-
141
- $request = wp_remote_post( 'https://miusage.com/v1/checkin/', array(
142
- 'method' => 'POST',
143
- 'timeout' => 5,
144
- 'redirection' => 5,
145
- 'httpversion' => '1.1',
146
- 'blocking' => false,
147
- 'body' => $this->get_data(),
148
- 'user-agent' => 'MI/' . MONSTERINSIGHTS_VERSION . '; ' . get_bloginfo( 'url' )
149
- ) );
150
-
151
- // If we have completed successfully, recheck in 1 week
152
- update_option( 'monsterinsights_usage_tracking_last_checkin', time() );
153
- return true;
154
- }
155
-
156
- private function tracking_allowed() {
157
- return (bool) monsterinsights_get_option( 'anonymous_data', false ) || monsterinsights_is_pro_version();
158
- }
159
-
160
- public function schedule_send() {
161
- if ( ! wp_next_scheduled( 'monsterinsights_usage_tracking_cron' ) ) {
162
- $tracking = array();
163
- $tracking['day'] = rand( 0, 6 );
164
- $tracking['hour'] = rand( 0, 23 );
165
- $tracking['minute'] = rand( 0, 59 );
166
- $tracking['second'] = rand( 0, 59 );
167
- $tracking['offset'] = ( $tracking['day'] * DAY_IN_SECONDS ) +
168
- ( $tracking['hour'] * HOUR_IN_SECONDS ) +
169
- ( $tracking['minute'] * MINUTE_IN_SECONDS ) +
170
- $tracking['second'];
171
- $tracking['initsend'] = strtotime("next sunday") + $tracking['offset'];
172
-
173
- wp_schedule_event( $tracking['initsend'], 'weekly', 'monsterinsights_usage_tracking_cron' );
174
- update_option( 'monsterinsights_usage_tracking_config', $tracking );
175
- }
176
- }
177
-
178
- public function check_for_settings_optin() {
179
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
180
- return;
181
- }
182
-
183
- if ( monsterinsights_is_pro_version() ) {
184
- return;
185
- }
186
-
187
- // Send an intial check in on settings save
188
- $anonymous_data = isset( $_POST['anonymous_data'] ) ? 1 : 0;
189
- if ( $anonymous_data ) {
190
- $this->send_checkin( true, true );
191
- }
192
-
193
- }
194
-
195
- public function check_for_optin() {
196
- if ( ! ( ! empty( $_REQUEST['mi_action'] ) && 'opt_into_tracking' === $_REQUEST['mi_action'] ) ) {
197
- return;
198
- }
199
-
200
- if ( monsterinsights_get_option( 'anonymous_data', false ) ) {
201
- return;
202
- }
203
-
204
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
205
- return;
206
- }
207
-
208
- if ( monsterinsights_is_pro_version() ) {
209
- return;
210
- }
211
-
212
- monsterinsights_update_option( 'anonymous_data', 1 );
213
- $this->send_checkin( true, true );
214
- update_option( 'monsterinsights_tracking_notice', 1 );
215
- }
216
-
217
- public function check_for_optout() {
218
- if ( ! ( ! empty( $_REQUEST['mi_action'] ) && 'opt_out_of_tracking' === $_REQUEST['mi_action'] ) ) {
219
- return;
220
- }
221
-
222
- if ( monsterinsights_get_option( 'anonymous_data', false ) ) {
223
- return;
224
- }
225
-
226
- if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
227
- return;
228
- }
229
-
230
- if ( monsterinsights_is_pro_version() ) {
231
- return;
232
- }
233
-
234
- monsterinsights_update_option( 'anonymous_data', 0 );
235
- update_option( 'monsterinsights_tracking_notice', 1 );
236
- }
237
-
238
- public function add_schedules( $schedules = array() ) {
239
- // Adds once weekly to the existing schedules.
240
- $schedules['weekly'] = array(
241
- 'interval' => 604800,
242
- 'display' => __( 'Once Weekly', 'google-analytics-for-wordpress' )
243
- );
244
- return $schedules;
245
- }
246
- }
247
  new MonsterInsights_Tracking();
1
+ <?php
2
+ /**
3
+ * Tracking functions for reporting plugin usage to the MonsterInsights site for users that have opted in
4
+ *
5
+ * @package MonsterInsights
6
+ * @subpackage Admin
7
+ * @copyright Copyright (c) 2018, Chris Christoff
8
+ * @since 7.0.0
9
+ */
10
+
11
+ // Exit if accessed directly
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+
16
+ /**
17
+ * Usage tracking
18
+ *
19
+ * @access public
20
+ * @since 7.0.0
21
+ * @return void
22
+ */
23
+ class MonsterInsights_Tracking {
24
+
25
+ public function __construct() {
26
+ add_action( 'init', array( $this, 'schedule_send' ) );
27
+ add_action( 'monsterinsights_settings_save_general_end', array( $this, 'check_for_settings_optin' ) );
28
+ add_action( 'admin_head', array( $this, 'check_for_optin' ) );
29
+ add_action( 'admin_head', array( $this, 'check_for_optout' ) );
30
+ add_filter( 'cron_schedules', array( $this, 'add_schedules' ) );
31
+ add_action( 'monsterinsights_usage_tracking_cron', array( $this, 'send_checkin' ) );
32
+ }
33
+
34
+ private function get_data() {
35
+ $data = array();
36
+
37
+ // Retrieve current theme info
38
+ $theme_data = wp_get_theme();
39
+ $tracking_mode = monsterinsights_get_option( 'tracking_mode', 'analytics' );
40
+ $events_mode = monsterinsights_get_option( 'events_mode', 'none' );
41
+ $update_mode = monsterinsights_get_option( 'automatic_updates', false );
42
+
43
+ if ( $tracking_mode === false ) {
44
+ $tracking_mode = 'analytics';
45
+ }
46
+ if ( $events_mode === false ) {
47
+ $events_mode = 'none';
48
+ }
49
+
50
+ if ( $update_mode === false ) {
51
+ $update_mode = 'none';
52
+ }
53
+
54
+ $count_b = 1;
55
+ if ( is_multisite() ) {
56
+ if ( function_exists( 'get_blog_count' ) ) {
57
+ $count_b = get_blog_count();
58
+ } else {
59
+ $count_b = 'Not Set';
60
+ }
61
+ }
62
+
63
+ $usesauth = 'No';
64
+ $local = MonsterInsights()->auth->is_authed();
65
+ $network = MonsterInsights()->auth->is_network_authed();
66
+
67
+ if ( $local && $network ) {
68
+ $usesauth = 'Both';
69
+ } else if ( $local ) {
70
+ $usesauth = 'Local';
71
+ } else if ( $network ) {
72
+ $usesauth = 'Network';
73
+ }
74
+
75
+ $data['php_version'] = phpversion();
76
+ $data['mi_version'] = MONSTERINSIGHTS_VERSION;
77
+ $data['wp_version'] = get_bloginfo( 'version' );
78
+ $data['server'] = isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '';
79
+ $data['over_time'] = get_option( 'monsterinsights_over_time', array() );
80
+ $data['multisite'] = is_multisite();
81
+ $data['url'] = home_url();
82
+ $data['themename'] = $theme_data->Name;
83
+ $data['themeversion'] = $theme_data->Version;
84
+ $data['email'] = get_bloginfo( 'admin_email' );
85
+ $data['key'] = monsterinsights_get_license_key();
86
+ $data['sas'] = monsterinsights_get_shareasale_id();
87
+ $data['settings'] = monsterinsights_get_options();
88
+ $data['tracking_mode'] = $tracking_mode;
89
+ $data['events_mode'] = $events_mode;
90
+ $data['autoupdate'] = $update_mode;
91
+ $data['pro'] = (int) monsterinsights_is_pro_version();
92
+ $data['sites'] = $count_b;
93
+ $data['usagetracking'] = get_option( 'monsterinsights_usage_tracking_config', false );
94
+ $data['usercount'] = function_exists( 'get_user_count' ) ? get_user_count() : 'Not Set';
95
+ $data['usesauth'] = $usesauth;
96
+ $data['timezoneoffset']= date('P');
97
+ $data['installed_lite']= get_option( 'monsterinsights_installed_lite', array() );
98
+ $data['installed_pro'] = get_option( 'monsterinsights_installed_pro', array() );
99
+
100
+
101
+
102
+ // Retrieve current plugin information
103
+ if( ! function_exists( 'get_plugins' ) ) {
104
+ include ABSPATH . '/wp-admin/includes/plugin.php';
105
+ }
106
+
107
+ $plugins = array_keys( get_plugins() );
108
+ $active_plugins = get_option( 'active_plugins', array() );
109
+
110
+ foreach ( $plugins as $key => $plugin ) {
111
+ if ( in_array( $plugin, $active_plugins ) ) {
112
+ // Remove active plugins from list so we can show active and inactive separately
113
+ unset( $plugins[ $key ] );
114
+ }
115
+ }
116
+
117
+ $data['active_plugins'] = $active_plugins;
118
+ $data['inactive_plugins'] = $plugins;
119
+ $data['locale'] = get_locale();
120
+
121
+ return $data;
122
+ }
123
+
124
+ public function send_checkin( $override = false, $ignore_last_checkin = false ) {
125
+
126
+ $home_url = trailingslashit( home_url() );
127
+ if ( strpos( $home_url, 'monsterinsights.com' ) !== false ) {
128
+ return false;
129
+ }
130
+
131
+ if( ! $this->tracking_allowed() && ! $override ) {
132
+ return false;
133
+ }
134
+
135
+ // Send a maximum of once per week
136
+ $last_send = get_option( 'monsterinsights_usage_tracking_last_checkin' );
137
+ if ( is_numeric( $last_send ) && $last_send > strtotime( '-1 week' ) && ! $ignore_last_checkin ) {
138
+ return false;
139
+ }
140
+
141
+ $request = wp_remote_post( 'https://miusage.com/v1/checkin/', array(
142
+ 'method' => 'POST',
143
+ 'timeout' => 5,
144
+ 'redirection' => 5,
145
+ 'httpversion' => '1.1',
146
+ 'blocking' => false,
147
+ 'body' => $this->get_data(),
148
+ 'user-agent' => 'MI/' . MONSTERINSIGHTS_VERSION . '; ' . get_bloginfo( 'url' )
149
+ ) );
150
+
151
+ // If we have completed successfully, recheck in 1 week
152
+ update_option( 'monsterinsights_usage_tracking_last_checkin', time() );
153
+ return true;
154
+ }
155
+
156
+ private function tracking_allowed() {
157
+ return (bool) monsterinsights_get_option( 'anonymous_data', false ) || monsterinsights_is_pro_version();
158
+ }
159
+
160
+ public function schedule_send() {
161
+ if ( ! wp_next_scheduled( 'monsterinsights_usage_tracking_cron' ) ) {
162
+ $tracking = array();
163
+ $tracking['day'] = rand( 0, 6 );
164
+ $tracking['hour'] = rand( 0, 23 );
165
+ $tracking['minute'] = rand( 0, 59 );
166
+ $tracking['second'] = rand( 0, 59 );
167
+ $tracking['offset'] = ( $tracking['day'] * DAY_IN_SECONDS ) +
168
+ ( $tracking['hour'] * HOUR_IN_SECONDS ) +
169
+ ( $tracking['minute'] * MINUTE_IN_SECONDS ) +
170
+ $tracking['second'];
171
+ $tracking['initsend'] = strtotime("next sunday") + $tracking['offset'];
172
+
173
+ wp_schedule_event( $tracking['initsend'], 'weekly', 'monsterinsights_usage_tracking_cron' );
174
+ update_option( 'monsterinsights_usage_tracking_config', $tracking );
175
+ }
176
+ }
177
+
178
+ public function check_for_settings_optin() {
179
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
180
+ return;
181
+ }
182
+
183
+ if ( monsterinsights_is_pro_version() ) {
184
+ return;
185
+ }
186
+
187
+ // Send an intial check in on settings save
188
+ $anonymous_data = isset( $_POST['anonymous_data'] ) ? 1 : 0;
189
+ if ( $anonymous_data ) {
190
+ $this->send_checkin( true, true );
191
+ }
192
+
193
+ }
194
+
195
+ public function check_for_optin() {
196
+ if ( ! ( ! empty( $_REQUEST['mi_action'] ) && 'opt_into_tracking' === $_REQUEST['mi_action'] ) ) {
197
+ return;
198
+ }
199
+
200
+ if ( monsterinsights_get_option( 'anonymous_data', false ) ) {
201
+ return;
202
+ }
203
+
204
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
205
+ return;
206
+ }
207
+
208
+ if ( monsterinsights_is_pro_version() ) {
209
+ return;
210
+ }
211
+
212
+ monsterinsights_update_option( 'anonymous_data', 1 );
213
+ $this->send_checkin( true, true );
214
+ update_option( 'monsterinsights_tracking_notice', 1 );
215
+ }
216
+
217
+ public function check_for_optout() {
218
+ if ( ! ( ! empty( $_REQUEST['mi_action'] ) && 'opt_out_of_tracking' === $_REQUEST['mi_action'] ) ) {
219
+ return;
220
+ }
221
+
222
+ if ( monsterinsights_get_option( 'anonymous_data', false ) ) {
223
+ return;
224
+ }
225
+
226
+ if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
227
+ return;
228
+ }
229
+
230
+ if ( monsterinsights_is_pro_version() ) {
231
+ return;
232
+ }
233
+
234
+ monsterinsights_update_option( 'anonymous_data', 0 );
235
+ update_option( 'monsterinsights_tracking_notice', 1 );
236
+ }
237
+
238
+ public function add_schedules( $schedules = array() ) {
239
+ // Adds once weekly to the existing schedules.
240
+ $schedules['weekly'] = array(
241
+ 'interval' => 604800,
242
+ 'display' => __( 'Once Weekly', 'google-analytics-for-wordpress' )
243
+ );
244
+ return $schedules;
245
+ }
246
+ }
247
  new MonsterInsights_Tracking();
includes/api-request.php CHANGED
@@ -1,439 +1,443 @@
1
- <?php
2
- /**
3
- * API Request class.
4
- *
5
- * @since 7.0.0
6
- *
7
- * @package MonsterInsights
8
- * @author Chris Christoff
9
- */
10
- final class MonsterInsights_API_Request {
11
-
12
- /**
13
- * Base API route.
14
- *
15
- * @since 7.0.0
16
- *
17
- * @var string
18
- */
19
- public $base = 'api.monsterinsights.com/v2/';
20
-
21
- /**
22
- * Current API route.
23
- *
24
- * @since 7.0.0
25
- *
26
- * @var bool|string
27
- */
28
- public $route = false;
29
-
30
- /**
31
- * Full API URL endpoint.
32
- *
33
- * @since 7.0.0
34
- *
35
- * @var bool|string
36
- */
37
- public $url = false;
38
-
39
- /**
40
- * Current API method.
41
- *
42
- * @since 7.0.0
43
- *
44
- * @var bool|string
45
- */
46
- public $method = false;
47
-
48
- /**
49
- * Is a network request.
50
- *
51
- * @since 7.2.0
52
- *
53
- * @var bool
54
- */
55
- public $network = false;
56
-
57
- /**
58
- * API token.
59
- *
60
- * @since 7.0.0
61
- *
62
- * @var bool|string
63
- */
64
- public $token = false;
65
-
66
- /**
67
- * API Key.
68
- *
69
- * @since 7.0.0
70
- *
71
- * @var bool|string
72
- */
73
- public $key = false;
74
-
75
- /**
76
- * API tt.
77
- *
78
- * @since 7.0.0
79
- *
80
- * @var bool|string
81
- */
82
- public $tt = false;
83
-
84
- /**
85
- * API return.
86
- *
87
- * @since 7.0.0
88
- *
89
- * @var bool|string
90
- */
91
- public $return = false;
92
-
93
- /**
94
- * Start date.
95
- *
96
- * @since 7.0.0
97
- *
98
- * @var string
99
- */
100
- public $start = '';
101
-
102
- /**
103
- * End Date.
104
- *
105
- * @since 7.0.0
106
- *
107
- * @var string
108
- */
109
- public $end = '';
110
-
111
- /**
112
- * Plugin slug.
113
- *
114
- * @since 7.0.0
115
- *
116
- * @var bool|string
117
- */
118
- public $plugin = false;
119
-
120
- /**
121
- * URL to test connection with.
122
- *
123
- * @since 7.3.2
124
- *
125
- * @var string
126
- */
127
- public $testurl = '';
128
-
129
- /**
130
- * Additional data to add to request body
131
- *
132
- * @since 7.0.0
133
- *
134
- * @var array
135
- */
136
- protected $additional_data = array();
137
-
138
- /**
139
- * Primary class constructor.
140
- *
141
- * @since 7.0.0
142
- *
143
- * @param string $route The API route to target.
144
- * @param array $args Array of API credentials.
145
- * @param string $method The API method.
146
- */
147
- public function __construct( $route, $args, $method = 'POST' ) {
148
-
149
- // Set class properties.
150
- $this->base = trailingslashit( monsterinsights_get_api_url() );
151
- $this->route = $route;
152
- $this->protocol = 'https://';
153
- $this->url = trailingslashit( $this->protocol . $this->base . $this->route );
154
- $this->method = $method;
155
- $this->network = is_network_admin() || ! empty( $args['network'] );
156
-
157
- $default_token = $this->network ? MonsterInsights()->auth->get_network_token() : MonsterInsights()->auth->get_token();
158
- $default_key = $this->network ? MonsterInsights()->auth->get_network_key() : MonsterInsights()->auth->get_key();
159
-
160
- $this->token = ! empty( $args['token'] ) ? $args['token'] : $default_token;
161
- $this->key = ! empty( $args['key'] ) ? $args['key'] : $default_key;
162
- $this->tt = ! empty( $args['tt'] ) ? $args['tt'] : '';
163
- $this->return = ! empty( $args['return'] ) ? $args['return'] : '';
164
- $this->start = ! empty( $args['start'] ) ? $args['start'] : '';
165
- $this->end = ! empty( $args['end'] ) ? $args['end'] : '';
166
-
167
- // We need to do this hack so that the network panel + the site_url of the main site are distinct
168
- $this->site_url = is_network_admin() ? network_admin_url() : site_url();
169
-
170
- if ( monsterinsights_is_pro_version() ) {
171
- $this->license = $this->network ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key();
172
- }
173
- $this->plugin = MonsterInsights()->plugin_slug;
174
- $this->miversion = MONSTERINSIGHTS_VERSION;
175
- $this->sitei = ! empty( $args['sitei'] ) ? $args['sitei'] : '';
176
- $this->testurl = ! empty( $args['testurl'] ) ? $args['testurl'] : '';
177
- }
178
-
179
- /**
180
- * Processes the API request.
181
- *
182
- * @since 7.0.0
183
- *
184
- * @return mixed $value The response to the API call.
185
- */
186
- public function request() {
187
- // Make sure we're not blocked
188
- $blocked = $this->is_blocked( $this->url );
189
- if ( $blocked || is_wp_error( $blocked ) ) {
190
- if ( is_wp_error( $blocked ) ) {
191
- return new WP_Error( 'api-error', sprintf( __( 'The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue. %s', 'google-analytics-for-wordpress' ), $blocked->get_error_message() ) );
192
- } else {
193
- return new WP_Error( 'api-error', __( 'The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue.', 'google-analytics-for-wordpress' ) );
194
- }
195
- }
196
-
197
- // Build the body of the request.
198
- $body = array();
199
-
200
- if ( ! empty( $this->token ) ) {
201
- $body['token'] = $this->token;
202
- }
203
-
204
- if ( ! empty( $this->key ) ) {
205
- $body['key'] = $this->key;
206
- }
207
-
208
- if ( ! empty( $this->tt ) ) {
209
- $body['tt'] = $this->tt;
210
- }
211
-
212
- if ( ! empty( $this->return ) ) {
213
- $body['return'] = $this->return;
214
- }
215
-
216
- if ( monsterinsights_is_pro_version() && ! empty( $this->license ) ) {
217
- $body['license'] = $this->license;
218
- }
219
-
220
- if ( ! empty( $this->start ) ) {
221
- $body['start'] = $this->start;
222
- }
223
-
224
- if ( ! empty( $this->end ) ) {
225
- $body['end'] = $this->end;
226
- }
227
-
228
- if ( ! empty( $this->sitei ) ) {
229
- $body['sitei'] = $this->sitei;
230
- }
231
-
232
- $body['siteurl'] = $this->site_url;
233
- $body['miversion'] = $this->miversion;
234
-
235
- // If a plugin API request, add the data.
236
- if ( 'info' == $this->route || 'update' == $this->route ) {
237
- $body['miapi-plugin'] = $this->plugin;
238
- }
239
-
240
- // Add in additional data if needed.
241
- if ( ! empty( $this->additional_data ) ) {
242
- $body['miapi-data'] = maybe_serialize( $this->additional_data );
243
- }
244
-
245
- if ( 'GET' == $this->method ) {
246
- $body['time'] = time(); // just to avoid caching
247
- }
248
-
249
- $body['timezone'] = date('e');
250
-
251
- $body['network'] = $this->network ? 'network' : 'site';
252
-
253
- $body['ip'] = ! empty( $_SERVER['SERVER_ADDR'] ) ? $_SERVER['SERVER_ADDR'] : '';
254
-
255
- // This filter will be removed in the future.
256
- $body = apply_filters( 'monsterinsights_api_request_body', $body );
257
-
258
- $string = http_build_query( $body, '', '&' );
259
-
260
- // Build the headers of the request.
261
- $headers = array(
262
- 'Content-Type' => 'application/x-www-form-urlencoded',
263
- 'Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0',
264
- 'Pragma' => 'no-cache',
265
- 'Expires' => 0,
266
- 'MIAPI-Referer' => is_network_admin() ? network_admin_url() : site_url(),
267
- 'MIAPI-Sender' => 'WordPress',
268
- );
269
-
270
- //if ( $this->apikey ) {
271
- // $headers['X-MonsterInsights-ApiKey'] = $this->apikey;
272
- //}
273
-
274
- // Setup data to be sent to the API.
275
- $data = array(
276
- 'headers' => $headers,
277
- 'body' => $body,
278
- 'timeout' => 3000,
279
- 'user-agent' => 'MI/' . MONSTERINSIGHTS_VERSION . '; ' . $this->site_url,
280
- 'sslverify' => false
281
- );
282
-
283
- // Perform the query and retrieve the response.
284
- $response = 'GET' == $this->method ? wp_remote_get( esc_url_raw( $this->url ) . '?' . $string, $data ) : wp_remote_post( esc_url_raw( $this->url ), $data );
285
-
286
- //return new WP_Error( 'debug', '<pre>' . var_export( $response, true ) . '</pre>' );
287
-
288
- if ( is_wp_error( $response ) ) {
289
- return $response;
290
- }
291
-
292
- $response_code = wp_remote_retrieve_response_code( $response );
293
- $response_body = json_decode( wp_remote_retrieve_body( $response ), true );
294
- //return new WP_Error( 'debug', '<pre>' . var_export( $response_body, true ) . '</pre>' );
295
- //var_dump( $response_body );
296
- // Bail out early if there are any errors.
297
- if ( is_wp_error( $response_body ) ) {
298
- return $response_body;
299
- }
300
-
301
- // If not a 200 status header, send back error.
302
- if ( 200 != $response_code ) {
303
- $type = ! empty( $response_body['type'] ) ? $response_body['type'] : 'api-error';
304
-
305
- if ( empty( $response_code ) ) {
306
- return new WP_Error( $type, __( 'The API was unreachable.', 'google-analytics-for-wordpress' ) );
307
- }
308
-
309
- if ( empty( $response_body ) || ( empty( $response_body['message'] ) && empty( $response_body['error'] ) ) ) {
310
- return new WP_Error( $type, sprintf( __( 'The API returned a <strong>%s</strong> response', 'google-analytics-for-wordpress' ), $response_code ) );
311
- }
312
-
313
- if ( ! empty( $response_body['message'] ) ) {
314
- return new WP_Error( $type, sprintf( __( 'The API returned a <strong>%d</strong> response with this message: <strong>%s</strong>', 'google-analytics-for-wordpress' ), $response_code, stripslashes( $response_body['message'] ) ) );
315
- }
316
-
317
- if ( ! empty( $response_body['error'] ) ) {
318
- return new WP_Error( $type, sprintf( __( 'The API returned a <strong>%d</strong> response with this message: <strong>%s</strong>', 'google-analytics-for-wordpress' ), $response_code, stripslashes( $response_body['error'] ) ) );
319
- }
320
- }
321
-
322
- // If TT required
323
- if ( ! empty( $this->tt ) ) {
324
- if ( empty( $response_body['tt'] ) || ! hash_equals( $this->tt, $response_body['tt'] ) ) {
325
- // TT isn't set on return or doesn't match
326
- return new WP_Error( 'validation-error', sprintf( __( 'Improper API request.', 'google-analytics-for-wordpress' ) ) );
327
- }
328
- }
329
-
330
- // Return the json decoded content.
331
- return $response_body;
332
- }
333
-
334
- /**
335
- * Sets a class property.
336
- *
337
- * @since 7.0.0
338
- *
339
- * @param string $key The property to set.
340
- * @param string $val The value to set for the property.
341
- * @return mixed $value The response to the API call.
342
- */
343
- public function set( $key, $val ) {
344
- $this->{$key} = $val;
345
- }
346
-
347
- /**
348
- * Allow additional data to be passed in the request
349
- *
350
- * @since 7.0.0
351
- *
352
- * @param array $data
353
- * return void
354
- */
355
- public function set_additional_data( array $data ) {
356
- $this->additional_data = array_merge( $this->additional_data, $data );
357
- }
358
-
359
- /**
360
- * Checks for SSL for making API requests.
361
- *
362
- * @since 7.0.0
363
- *
364
- * return bool True if SSL is enabled, false otherwise.
365
- */
366
- public function is_ssl() {
367
- // Use the base is_ssl check first.
368
- if ( is_ssl() ) {
369
- return true;
370
- } else if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
371
- // Also catch proxies and load balancers.
372
- return true;
373
- } else if ( defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ) {
374
- return true;
375
- }
376
-
377
- // Otherwise, return false.
378
- return false;
379
- }
380
-
381
- private function is_blocked( $url = '' ) {
382
- global $Airplane_Mode_Core;
383
- if ( defined( 'AIRMDE_VER' ) && ! empty( $Airplane_Mode_Core ) && $Airplane_Mode_Core->enabled() ) {
384
- return new WP_Error( 'api-error', __( 'Reason: The API was unreachable because the Airplane Mode plugin is active.', 'google-analytics-for-wordpress' ) );
385
- }
386
-
387
- // The below page is a testing empty content HTML page used for firewall/router login detection
388
- // and for image linking purposes in Google Images. We use it to test outbound connections since it is run on google.com
389
- // and is only a few bytes large. Plus on Google's main CDN so it loads in most places in 0.07 seconds or less. Perfect for our
390
- // use case of quickly testing outbound connections.
391
- $testurl = ! empty( $this->testurl ) ? $this->testurl :'http://www.google.com/blank.html';
392
- if ( defined( 'WP_HTTP_BLOCK_EXTERNAL' ) && WP_HTTP_BLOCK_EXTERNAL ) {
393
- if ( defined( 'WP_ACCESSIBLE_HOSTS' ) ) {
394
- $wp_http = new WP_Http();
395
- $on_blacklist = $wp_http->block_request( $url );
396
- if ( $on_blacklist ) {
397
- return new WP_Error( 'api-error', __( 'Reason: The API was unreachable because the API url is on the WP HTTP blocklist.', 'google-analytics-for-wordpress' ) );
398
- } else {
399
- $params = array(
400
- 'sslverify' => false,
401
- 'timeout' => 2,
402
- 'user-agent' => 'MonsterInsights/' . MONSTERINSIGHTS_VERSION,
403
- 'body' => ''
404
- );
405
- $response = wp_remote_get( $testurl, $params );
406
- if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
407
- return false;
408
- } else {
409
- if ( is_wp_error( $response ) ) {
410
- return $response;
411
- } else {
412
- return new WP_Error( 'api-error', __( 'Reason: The API was unreachable because the call to Google failed.', 'google-analytics-for-wordpress' ) );
413
- }
414
- }
415
- }
416
- } else {
417
- return new WP_Error( 'api-error', __( 'Reason: The API was unreachable because no external hosts are allowed on this site.', 'google-analytics-for-wordpress' ) );
418
- }
419
- } else {
420
- $params = array(
421
- 'sslverify' => false,
422
- 'timeout' => 2,
423
- 'user-agent' => 'MonsterInsights/' . MONSTERINSIGHTS_VERSION,
424
- 'body' => ''
425
- );
426
- $response = wp_remote_get( $testurl, $params );
427
-
428
- if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
429
- return false;
430
- } else {
431
- if ( is_wp_error( $response ) ) {
432
- return $response;
433
- } else {
434
- return new WP_Error( 'api-error', __( 'Reason: The API was unreachable because the call to Google failed.', 'google-analytics-for-wordpress' ) );
435
- }
436
- }
437
- }
438
- }
439
- }
 
 
 
 
1
+ <?php
2
+ /**
3
+ * API Request class.
4
+ *
5
+ * @since 7.0.0
6
+ *
7
+ * @package MonsterInsights
8
+ * @author Chris Christoff
9
+ */
10
+ final class MonsterInsights_API_Request {
11
+
12
+ /**
13
+ * Base API route.
14
+ *
15
+ * @since 7.0.0
16
+ *
17
+ * @var string
18
+ */
19
+ public $base = 'api.monsterinsights.com/v2/';
20
+
21
+ /**
22
+ * Current API route.
23
+ *
24
+ * @since 7.0.0
25
+ *
26
+ * @var bool|string
27
+ */
28
+ public $route = false;
29
+
30
+ /**
31
+ * Full API URL endpoint.
32
+ *
33
+ * @since 7.0.0
34
+ *
35
+ * @var bool|string
36
+ */
37
+ public $url = false;
38
+
39
+ /**
40
+ * Current API method.
41
+ *
42
+ * @since 7.0.0
43
+ *
44
+ * @var bool|string
45
+ */
46
+ public $method = false;
47
+
48
+ /**
49
+ * Is a network request.
50
+ *
51
+ * @since 7.2.0
52
+ *
53
+ * @var bool
54
+ */
55
+ public $network = false;
56
+
57
+ /**
58
+ * API token.
59
+ *
60
+ * @since 7.0.0
61
+ *
62
+ * @var bool|string
63
+ */
64
+ public $token = false;
65
+
66
+ /**
67
+ * API Key.
68
+ *
69
+ * @since 7.0.0
70
+ *
71
+ * @var bool|string
72
+ */
73
+ public $key = false;
74
+
75
+ /**
76
+ * API tt.
77
+ *
78
+ * @since 7.0.0
79
+ *
80
+ * @var bool|string
81
+ */
82
+ public $tt = false;
83
+
84
+ /**
85
+ * API return.
86
+ *
87
+ * @since 7.0.0
88
+ *
89
+ * @var bool|string
90
+ */
91
+ public $return = false;
92
+
93
+ /**
94
+ * Start date.
95
+ *
96
+ * @since 7.0.0
97
+ *
98
+ * @var string
99
+ */
100
+ public $start = '';
101
+
102
+ /**
103
+ * End Date.
104
+ *
105
+ * @since 7.0.0
106
+ *
107
+ * @var string
108
+ */
109
+ public $end = '';
110
+
111
+ /**
112
+ * Plugin slug.
113
+ *
114
+ * @since 7.0.0
115
+ *
116
+ * @var bool|string
117
+ */
118
+ public $plugin = false;
119
+
120
+ /**
121
+ * URL to test connection with.
122
+ *
123
+ * @since 7.3.2
124
+ *
125
+ * @var string
126
+ */
127
+ public $testurl = '';
128
+
129
+ /**
130
+ * Additional data to add to request body
131
+ *
132
+ * @since 7.0.0
133
+ *
134
+ * @var array
135
+ */
136
+ protected $additional_data = array();
137
+
138
+ /**
139
+ * Primary class constructor.
140
+ *
141
+ * @since 7.0.0
142
+ *
143
+ * @param string $route The API route to target.
144
+ * @param array $args Array of API credentials.
145
+ * @param string $method The API method.
146
+ */
147
+ public function __construct( $route, $args, $method = 'POST' ) {
148
+
149
+ // Set class properties.
150
+ $this->base = trailingslashit( monsterinsights_get_api_url() );
151
+ $this->route = $route;
152
+ $this->protocol = 'https://';
153
+ $this->url = trailingslashit( $this->protocol . $this->base . $this->route );
154
+ $this->method = $method;
155
+ $this->network = is_network_admin() || ! empty( $args['network'] );
156
+
157
+ $default_token = $this->network ? MonsterInsights()->auth->get_network_token() : MonsterInsights()->auth->get_token();
158
+ $default_key = $this->network ? MonsterInsights()->auth->get_network_key() : MonsterInsights()->auth->get_key();
159
+
160
+ $this->token = ! empty( $args['token'] ) ? $args['token'] : $default_token;
161
+ $this->key = ! empty( $args['key'] ) ? $args['key'] : $default_key;
162
+ $this->tt = ! empty( $args['tt'] ) ? $args['tt'] : '';
163
+ $this->return = ! empty( $args['return'] ) ? $args['return'] : '';
164
+ $this->start = ! empty( $args['start'] ) ? $args['start'] : '';
165
+ $this->end = ! empty( $args['end'] ) ? $args['end'] : '';
166
+
167
+ // We need to do this hack so that the network panel + the site_url of the main site are distinct
168
+ $this->site_url = is_network_admin() ? network_admin_url() : site_url();
169
+
170
+ if ( monsterinsights_is_pro_version() ) {
171
+ $this->license = $this->network ? MonsterInsights()->license->get_network_license_key() : MonsterInsights()->license->get_site_license_key();
172
+ }
173
+ $this->plugin = MonsterInsights()->plugin_slug;
174
+ $this->miversion = MONSTERINSIGHTS_VERSION;
175
+ $this->sitei = ! empty( $args['sitei'] ) ? $args['sitei'] : '';
176
+ $this->testurl = ! empty( $args['testurl'] ) ? $args['testurl'] : '';
177
+ }
178
+
179
+ /**
180
+ * Processes the API request.
181
+ *
182
+ * @since 7.0.0
183
+ *
184
+ * @return mixed $value The response to the API call.
185
+ */
186
+ public function request() {
187
+ // Make sure we're not blocked
188
+ $blocked = $this->is_blocked( $this->url );
189
+ if ( $blocked || is_wp_error( $blocked ) ) {
190
+ if ( is_wp_error( $blocked ) ) {
191
+ // Translators: Placeholder gets replaced with the error message.
192
+ return new WP_Error( 'api-error', sprintf( __( 'The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue. %s', 'google-analytics-for-wordpress' ), $blocked->get_error_message() ) );
193
+ } else {
194
+ return new WP_Error( 'api-error', __( 'The firewall of your server is blocking outbound calls. Please contact your hosting provider to fix this issue.', 'google-analytics-for-wordpress' ) );
195
+ }
196
+ }
197
+
198
+ // Build the body of the request.
199
+ $body = array();
200
+
201
+ if ( ! empty( $this->token ) ) {
202
+ $body['token'] = $this->token;
203
+ }
204
+
205
+ if ( ! empty( $this->key ) ) {
206
+ $body['key'] = $this->key;
207
+ }
208
+
209
+ if ( ! empty( $this->tt ) ) {
210
+ $body['tt'] = $this->tt;
211
+ }
212
+
213
+ if ( ! empty( $this->return ) ) {
214
+ $body['return'] = $this->return;
215
+ }
216
+
217
+ if ( monsterinsights_is_pro_version() && ! empty( $this->license ) ) {
218
+ $body['license'] = $this->license;
219
+ }
220
+
221
+ if ( ! empty( $this->start ) ) {
222
+ $body['start'] = $this->start;
223
+ }
224
+
225
+ if ( ! empty( $this->end ) ) {
226
+ $body['end'] = $this->end;
227
+ }
228
+
229
+ if ( ! empty( $this->sitei ) ) {
230
+ $body['sitei'] = $this->sitei;
231
+ }
232
+
233
+ $body['siteurl'] = $this->site_url;
234
+ $body['miversion'] = $this->miversion;
235
+
236
+ // If a plugin API request, add the data.
237
+ if ( 'info' == $this->route || 'update' == $this->route ) {
238
+ $body['miapi-plugin'] = $this->plugin;
239
+ }
240
+
241
+ // Add in additional data if needed.
242
+ if ( ! empty( $this->additional_data ) ) {
243
+ $body['miapi-data'] = maybe_serialize( $this->additional_data );
244
+ }
245
+
246
+ if ( 'GET' == $this->method ) {
247
+ $body['time'] = time(); // just to avoid caching
248
+ }
249
+
250
+ $body['timezone'] = date('e');
251
+
252
+ $body['network'] = $this->network ? 'network' : 'site';
253
+
254
+ $body['ip'] = ! empty( $_SERVER['SERVER_ADDR'] ) ? $_SERVER['SERVER_ADDR'] : '';
255
+
256
+ // This filter will be removed in the future.
257
+ $body = apply_filters( 'monsterinsights_api_request_body', $body );
258
+
259
+ $string = http_build_query( $body, '', '&' );
260
+
261
+ // Build the headers of the request.
262
+ $headers = array(
263
+ 'Content-Type' => 'application/x-www-form-urlencoded',
264
+ 'Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0',
265
+ 'Pragma' => 'no-cache',
266
+ 'Expires' => 0,
267
+ 'MIAPI-Referer' => is_network_admin() ? network_admin_url() : site_url(),
268
+ 'MIAPI-Sender' => 'WordPress',
269
+ );
270
+
271
+ //if ( $this->apikey ) {
272
+ // $headers['X-MonsterInsights-ApiKey'] = $this->apikey;
273
+ //}
274
+
275
+ // Setup data to be sent to the API.
276
+ $data = array(
277
+ 'headers' => $headers,
278
+ 'body' => $body,
279
+ 'timeout' => 3000,
280
+ 'user-agent' => 'MI/' . MONSTERINSIGHTS_VERSION . '; ' . $this->site_url,
281
+ 'sslverify' => false
282
+ );
283
+
284
+ // Perform the query and retrieve the response.
285
+ $response = 'GET' == $this->method ? wp_remote_get( esc_url_raw( $this->url ) . '?' . $string, $data ) : wp_remote_post( esc_url_raw( $this->url ), $data );
286
+
287
+ //return new WP_Error( 'debug', '<pre>' . var_export( $response, true ) . '</pre>' );
288
+
289
+ if ( is_wp_error( $response ) ) {
290
+ return $response;
291
+ }
292
+
293
+ $response_code = wp_remote_retrieve_response_code( $response );
294
+ $response_body = json_decode( wp_remote_retrieve_body( $response ), true );
295
+ //return new WP_Error( 'debug', '<pre>' . var_export( $response_body, true ) . '</pre>' );
296
+ //var_dump( $response_body );
297
+ // Bail out early if there are any errors.
298
+ if ( is_wp_error( $response_body ) ) {
299
+ return $response_body;
300
+ }
301
+
302
+ // If not a 200 status header, send back error.
303
+ if ( 200 != $response_code ) {
304
+ $type = ! empty( $response_body['type'] ) ? $response_body['type'] : 'api-error';
305
+
306
+ if ( empty( $response_code ) ) {
307
+ return new WP_Error( $type, __( 'The API was unreachable.', 'google-analytics-for-wordpress' ) );
308
+ }
309
+
310
+ if ( empty( $response_body ) || ( empty( $response_body['message'] ) && empty( $response_body['error'] ) ) ) {
311
+ // Translators: placeholder adds the response code.
312
+ return new WP_Error( $type, sprintf( __( 'The API returned a <strong>%s</strong> response', 'google-analytics-for-wordpress' ), $response_code ) );
313
+ }
314
+
315
+ if ( ! empty( $response_body['message'] ) ) {
316
+ // Translators: placeholder adds the response code and response message.
317
+ return new WP_Error( $type, sprintf( __( 'The API returned a <strong>%1$d</strong> response with this message: <strong>%2$s</strong>', 'google-analytics-for-wordpress' ), $response_code, stripslashes( $response_body['message'] ) ) );
318
+ }
319
+
320
+ if ( ! empty( $response_body['error'] ) ) {
321
+ // Translators: placeholder adds the response code and response message.
322
+ return new WP_Error( $type, sprintf( __( 'The API returned a <strong>%1$d</strong> response with this message: <strong>%2$s</strong>', 'google-analytics-for-wordpress' ), $response_code, stripslashes( $response_body['error'] ) ) );
323
+ }
324
+ }
325
+
326
+ // If TT required
327
+ if ( ! empty( $this->tt ) ) {
328
+ if ( empty( $response_body['tt'] ) || ! hash_equals( $this->tt, $response_body['tt'] ) ) {
329
+ // TT isn't set on return or doesn't match
330
+ return new WP_Error( 'validation-error', sprintf( __( 'Improper API request.', 'google-analytics-for-wordpress' ) ) );
331
+ }
332
+ }
333
+
334
+ // Return the json decoded content.
335
+ return $response_body;
336
+ }
337
+
338
+ /**
339
+ * Sets a class property.
340
+ *
341
+ * @since 7.0.0
342
+ *
343
+ * @param string $key The property to set.
344
+ * @param string $val The value to set for the property.
345
+ * @return mixed $value The response to the API call.
346
+ */
347
+ public function set( $key, $val ) {
348
+ $this->{$key} = $val;
349
+ }
350
+
351
+ /**
352
+ * Allow additional data to be passed in the request
353
+ *
354
+ * @since 7.0.0
355
+ *
356
+ * @param array $data
357
+ * return void
358
+ */
359
+ public function set_additional_data( array $data ) {
360
+ $this->additional_data = array_merge( $this->additional_data, $data );
361
+ }
362
+
363
+ /**
364
+ * Checks for SSL for making API requests.
365
+ *
366
+ * @since 7.0.0
367
+ *
368
+ * return bool True if SSL is enabled, false otherwise.
369
+ */
370
+ public function is_ssl() {
371
+ // Use the base is_ssl check first.
372
+ if ( is_ssl() ) {
373
+ return true;
374
+ } else if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
375
+ // Also catch proxies and load balancers.
376
+ return true;
377
+ } else if ( defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ) {
378
+ return true;
379
+ }
380
+
381
+ // Otherwise, return false.
382
+ return false;
383
+ }
384
+
385
+ private function is_blocked( $url = '' ) {
386
+ global $Airplane_Mode_Core;
387
+ if ( defined( 'AIRMDE_VER' ) && ! empty( $Airplane_Mode_Core ) && $Airplane_Mode_Core->enabled() ) {
388
+ return new WP_Error( 'api-error', __( 'Reason: The API was unreachable because the Airplane Mode plugin is active.', 'google-analytics-for-wordpress' ) );
389
+ }
390
+
391
+ // The below page is a testing empty content HTML page used for firewall/router login detection
392
+ // and for image linking purposes in Google Images. We use it to test outbound connections since it is run on google.com
393
+ // and is only a few bytes large. Plus on Google's main CDN so it loads in most places in 0.07 seconds or less. Perfect for our
394
+ // use case of quickly testing outbound connections.
395
+ $testurl = ! empty( $this->testurl ) ? $this->testurl :'http://www.google.com/blank.html';
396
+ if ( defined( 'WP_HTTP_BLOCK_EXTERNAL' ) && WP_HTTP_BLOCK_EXTERNAL ) {
397
+ if ( defined( 'WP_ACCESSIBLE_HOSTS' ) ) {
398
+ $wp_http = new WP_Http();
399
+ $on_blacklist = $wp_http->block_request( $url );
400
+ if ( $on_blacklist ) {
401
+ return new WP_Error( 'api-error', __( 'Reason: The API was unreachable because the API url is on the WP HTTP blocklist.', 'google-analytics-for-wordpress' ) );
402
+ } else {
403
+ $params = array(
404
+ 'sslverify' => false,
405
+ 'timeout' => 2,
406
+ 'user-agent' => 'MonsterInsights/' . MONSTERINSIGHTS_VERSION,
407
+ 'body' => ''
408
+ );
409
+ $response = wp_remote_get( $testurl, $params );
410
+ if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
411
+ return false;
412
+ } else {
413
+ if ( is_wp_error( $response ) ) {
414
+ return $response;
415
+ } else {
416
+ return new WP_Error( 'api-error', __( 'Reason: The API was unreachable because the call to Google failed.', 'google-analytics-for-wordpress' ) );
417
+ }
418
+ }
419
+ }
420
+ } else {
421
+ return new WP_Error( 'api-error', __( 'Reason: The API was unreachable because no external hosts are allowed on this site.', 'google-analytics-for-wordpress' ) );
422
+ }
423
+ } else {
424
+ $params = array(
425
+ 'sslverify' => false,
426
+ 'timeout' => 2,
427
+ 'user-agent' => 'MonsterInsights/' . MONSTERINSIGHTS_VERSION,
428
+ 'body' => ''
429
+ );
430
+ $response = wp_remote_get( $testurl, $params );
431
+
432
+ if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
433
+ return false;
434
+ } else {
435
+ if ( is_wp_error( $response ) ) {
436
+ return $response;
437
+ } else {
438
+ return new WP_Error( 'api-error', __( 'Reason: The API was unreachable because the call to Google failed.', 'google-analytics-for-wordpress' ) );
439
+ }
440
+ }
441
+ }
442
+ }
443
+ }
includes/auth.php CHANGED
@@ -1,250 +1,250 @@
1
- <?php
2
- /**
3
- * Auth class.
4
- *
5
- * Helper for auth.
6
- *
7
- * @since 7.0.0
8
- *
9
- * @package MonsterInsights
10
- * @subpackage Auth
11
- * @author Chris Christoff
12
- */
13
-
14
- // Exit if accessed directly
15
- if ( ! defined( 'ABSPATH' ) ) {
16
- exit;
17
- }
18
-
19
- final class MonsterInsights_Auth {
20
-
21
- private $profile = array();
22
- private $network = array();
23
-
24
- /**
25
- * Primary class constructor.
26
- *
27
- * @access public
28
- * @since 7.0.0
29
- */
30
- public function __construct() {
31
- $this->profile = $this->get_analytics_profile();
32
- $this->network = $this->get_network_analytics_profile();
33
- }
34
-
35
- public function is_manual() {
36
- return ! empty( $this->profile['manual'] );
37
- }
38
- public function is_network_manual() {
39
- return ! empty( $this->network['manual'] );
40
- }
41
-
42
- public function is_authed() {
43
- return ! empty( $this->profile['key'] );
44
- }
45
-
46
- public function is_network_authed() {
47
- return ! empty( $this->network['key'] );
48
- }
49
-
50
- public function get_analytics_profile( $force = false ) {
51
- if ( ! empty( $this->profile ) && ! $force ) {
52
- return $this->profile;
53
- } else {
54
- $profile = get_option( 'monsterinsights_site_profile', array() );
55
- $this->profile = $profile;
56
- return $profile;
57
- }
58
- }
59
-
60
- public function get_network_analytics_profile( $force = false ) {
61
- if ( ! empty( $this->network ) && ! $force ) {
62
- return $this->network;
63
- } else {
64
- $profile = get_site_option( 'monsterinsights_network_profile', array() );
65
- $this->network = $profile;
66
- return $profile;
67
- }
68
- }
69
-
70
- public function set_analytics_profile( $data = array() ){
71
- update_option( 'monsterinsights_site_profile', $data );
72
- $this->profile = $data;
73
-
74
- // If this is the first time, save the date when they connected.
75
- $over_time = get_option( 'monsterinsights_over_time', array() );
76
- if ( empty( $over_time['connected_date'] ) ) {
77
- $over_time['connected_date'] = time();
78
- update_option( 'monsterinsights_over_time', $over_time );
79
- }
80
- }
81
-
82
- public function set_network_analytics_profile( $data = array() ){
83
- update_site_option( 'monsterinsights_network_profile', $data );
84
- $this->network = $data;
85
- }
86
-
87
- public function delete_analytics_profile( $migrate = true ){
88
- if ( $migrate ) {
89
- $newdata = array();
90
- if ( isset( $this->profile['ua'] ) ) {
91
- $newdata['manual'] = $this->profile['ua'];
92
- }
93
- $this->profile = $newdata;
94
- $this->set_analytics_profile( $newdata );
95
- } else {
96
- $this->profile = array();
97
- delete_option( 'monsterinsights_site_profile' );
98
- }
99
- }
100
-
101
- public function delete_network_analytics_profile( $migrate = true ){
102
- if ( $migrate ) {
103
- $newdata = array();
104
- if ( isset( $this->network['ua'] ) ) {
105
- $newdata['manual'] = $this->network['ua'];
106
- }
107
- $this->network = $newdata;
108
- $this->set_network_analytics_profile( $newdata );
109
- } else {
110
- $this->network = array();
111
- delete_site_option( 'monsterinsights_network_profile' );
112
- }
113
- }
114
-
115
- public function set_manual_ua( $ua = '' ) {
116
- if ( empty( $ua ) ) {
117
- return;
118
- }
119
-
120
- if ( $this->is_authed() ) {
121
- MonsterInsights()->api_auth->delete_auth();
122
- }
123
-
124
- $data = array();
125
- if ( empty( $this->profile ) ) {
126
- $data['manual'] = $ua;
127
- } else {
128
- $data = $this->profile;
129
- $data['manual'] = $ua;
130
- }
131
-
132
- do_action( 'monsterinsights_reports_delete_aggregate_data' );
133
-
134
- $this->profile = $data;
135
- $this->set_analytics_profile( $data );
136
- }
137
-
138
- public function set_network_manual_ua( $ua = '' ) {
139
- if ( empty( $ua ) ) {
140
- return;
141
- }
142
-
143
- if ( $this->is_network_authed() ) {
144
- MonsterInsights()->api_auth->delete_auth();
145
- }
146
-
147
- $data = array();
148
- if ( empty( $this->network ) ) {
149
- $data['manual'] = $ua;
150
- } else {
151
- $data = $this->network;
152
- $data['manual'] = $ua;
153
- }
154
-
155
- do_action( 'monsterinsights_reports_delete_network_aggregate_data' );
156
-
157
- $this->network = $data;
158
- $this->set_network_analytics_profile( $data );
159
- }
160
-
161
- public function delete_manual_ua() {
162
- if ( ! empty( $this->profile ) && ! empty( $this->profile['manual'] ) ) {
163
- unset( $this->profile['manual'] );
164
- $this->set_analytics_profile( $this->profile );
165
- }
166
- }
167
-
168
- public function delete_network_manual_ua() {
169
- if ( ! empty( $this->network ) && ! empty( $this->network['manual'] ) ) {
170
- unset( $this->network['manual'] );
171
- $this->set_network_analytics_profile( $this->network );
172
- }
173
- }
174
-
175
- public function get_manual_ua() {
176
- return ! empty( $this->profile['manual'] ) ? monsterinsights_is_valid_ua( $this->profile['manual'] ) : '';
177
- }
178
-
179
- public function get_network_manual_ua() {
180
- return ! empty( $this->network['manual'] ) ? monsterinsights_is_valid_ua( $this->network['manual'] ) : '';
181
- }
182
-
183
- public function get_ua() {
184
- return ! empty( $this->profile['ua'] ) ? monsterinsights_is_valid_ua( $this->profile['ua'] ) : '';
185
- }
186
-
187
- public function get_network_ua() {
188
- return ! empty( $this->network['ua'] ) ? monsterinsights_is_valid_ua( $this->network['ua'] ) : '';
189
- }
190
-
191
- public function get_viewname(){
192
- return ! empty( $this->profile['viewname'] ) ? $this->profile['viewname'] : '';
193
- }
194
-
195
- public function get_network_viewname(){
196
- return ! empty( $this->network['viewname'] ) ? $this->network['viewname'] : '';
197
- }
198
-
199
- public function get_accountid(){
200
- return ! empty( $this->profile['a'] ) ? $this->profile['a'] : '';
201
- }
202
-
203
- public function get_network_accountid(){
204
- return ! empty( $this->network['a'] ) ? $this->network['a'] : '';
205
- }
206
-
207
- public function get_propertyid(){
208
- return ! empty( $this->profile['w'] ) ? $this->profile['w'] : '';
209
- }
210
-
211
- public function get_network_propertyid(){
212
- return ! empty( $this->network['w'] ) ? $this->network['w'] : '';
213
- }
214
-
215
- public function get_viewid(){ // also known as profileID
216
- return ! empty( $this->profile['p'] ) ? $this->profile['p'] : '';
217
- }
218
-
219
- public function get_network_viewid(){ // also known as profileID
220
- return ! empty( $this->network['p'] ) ? $this->network['p'] : '';
221
- }
222
-
223
- public function get_key(){
224
- return ! empty( $this->profile['key'] ) ? $this->profile['key'] : '';
225
- }
226
-
227
- public function get_network_key(){
228
- return ! empty( $this->network['key'] ) ? $this->network['key'] : '';
229
- }
230
-
231
- public function get_token(){
232
- return ! empty( $this->profile['token'] ) ? $this->profile['token'] : '';
233
- }
234
-
235
- public function get_network_token(){
236
- return ! empty( $this->network['token'] ) ? $this->network['token'] : '';
237
- }
238
-
239
- public function get_referral_url(){
240
- $url = '';
241
-
242
- if ( $this->is_authed() ) {
243
- $url .= 'a' . MonsterInsights()->auth->get_accountid() . 'w' . MonsterInsights()->auth->get_propertyid() . 'p' . MonsterInsights()->auth->get_viewid() . '/';
244
- } else if ( $this->is_network_authed() ) {
245
- $url .= 'a' . MonsterInsights()->auth->get_network_accountid() . 'w' . MonsterInsights()->auth->get_network_propertyid() . 'p' . MonsterInsights()->auth->get_network_viewid() . '/';
246
- }
247
-
248
- return $url;
249
- }
250
- }
1
+ <?php
2
+ /**
3
+ * Auth class.
4
+ *
5
+ * Helper for auth.
6
+ *
7
+ * @since 7.0.0
8
+ *
9
+ * @package MonsterInsights
10
+ * @subpackage Auth
11
+ * @author Chris Christoff
12
+ */
13
+
14
+ // Exit if accessed directly
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit;
17
+ }
18
+
19
+ final class MonsterInsights_Auth {
20
+
21
+ private $profile = array();
22
+ private $network = array();
23
+
24
+ /**
25
+ * Primary class constructor.
26
+ *
27
+ * @access public
28
+ * @since 7.0.0
29
+ */
30
+ public function __construct() {
31
+ $this->profile = $this->get_analytics_profile();
32
+ $this->network = $this->get_network_analytics_profile();
33
+ }
34
+
35
+ public function is_manual() {
36
+ return ! empty( $this->profile['manual'] );
37
+ }
38
+ public function is_network_manual() {
39
+ return ! empty( $this->network['manual'] );
40
+ }
41
+
42
+ public function is_authed() {
43
+ return ! empty( $this->profile['key'] );
44
+ }
45
+
46
+ public function is_network_authed() {
47
+ return ! empty( $this->network['key'] );
48
+ }
49
+
50
+ public function get_analytics_profile( $force = false ) {
51
+ if ( ! empty( $this->profile ) && ! $force ) {
52
+ return $this->profile;
53
+ } else {
54
+ $profile = get_option( 'monsterinsights_site_profile', array() );
55
+ $this->profile = $profile;
56
+ return $profile;
57
+ }
58
+ }
59
+
60
+ public function get_network_analytics_profile( $force = false ) {
61
+ if ( ! empty( $this->network ) && ! $force ) {
62
+ return $this->network;
63
+ } else {
64
+ $profile = get_site_option( 'monsterinsights_network_profile', array() );
65
+ $this->network = $profile;
66
+ return $profile;
67
+ }
68
+ }
69
+
70
+ public function set_analytics_profile( $data = array() ){
71
+ update_option( 'monsterinsights_site_profile', $data );
72
+ $this->profile = $data;
73
+
74
+ // If this is the first time, save the date when they connected.
75
+ $over_time = get_option( 'monsterinsights_over_time', array() );
76
+ if ( empty( $over_time['connected_date'] ) ) {
77
+ $over_time['connected_date'] = time();
78
+ update_option( 'monsterinsights_over_time', $over_time );
79
+ }
80
+ }
81
+
82
+ public function set_network_analytics_profile( $data = array() ){
83
+ update_site_option( 'monsterinsights_network_profile', $data );
84
+ $this->network = $data;
85
+ }
86
+
87
+ public function delete_analytics_profile( $migrate = true ){
88
+ if ( $migrate ) {
89
+ $newdata = array();
90
+ if ( isset( $this->profile['ua'] ) ) {
91
+ $newdata['manual'] = $this->profile['ua'];
92
+ }
93
+ $this->profile = $newdata;
94
+ $this->set_analytics_profile( $newdata );
95
+ } else {
96
+ $this->profile = array();
97
+ delete_option( 'monsterinsights_site_profile' );
98
+ }
99
+ }
100
+
101
+ public function delete_network_analytics_profile( $migrate = true ){
102
+ if ( $migrate ) {
103
+ $newdata = array();
104
+ if ( isset( $this->network['ua'] ) ) {
105
+ $newdata['manual'] = $this->network['ua'];
106
+ }
107
+ $this->network = $newdata;
108
+ $this->set_network_analytics_profile( $newdata );
109
+ } else {
110
+ $this->network = array();
111
+ delete_site_option( 'monsterinsights_network_profile' );
112
+ }
113
+ }
114
+
115
+ public function set_manual_ua( $ua = '' ) {
116
+ if ( empty( $ua ) ) {
117
+ return;
118
+ }
119
+
120
+ if ( $this->is_authed() ) {
121
+ MonsterInsights()->api_auth->delete_auth();
122
+ }
123
+
124
+ $data = array();
125
+ if ( empty( $this->profile ) ) {
126
+ $data['manual'] = $ua;
127
+ } else {
128
+ $data = $this->profile;
129
+ $data['manual'] = $ua;
130
+ }
131
+
132
+ do_action( 'monsterinsights_reports_delete_aggregate_data' );
133
+
134
+ $this->profile = $data;
135
+ $this->set_analytics_profile( $data );
136
+ }
137
+
138
+ public function set_network_manual_ua( $ua = '' ) {
139
+ if ( empty( $ua ) ) {
140
+ return;
141
+ }
142
+
143
+ if ( $this->is_network_authed() ) {
144
+ MonsterInsights()->api_auth->delete_auth();
145
+ }
146
+
147
+ $data = array();
148
+ if ( empty( $this->network ) ) {
149
+ $data['manual'] = $ua;
150
+ } else {
151
+ $data = $this->network;
152
+ $data['manual'] = $ua;
153
+ }
154
+
155
+ do_action( 'monsterinsights_reports_delete_network_aggregate_data' );
156
+
157
+ $this->network = $data;
158
+ $this->set_network_analytics_profile( $data );
159
+ }
160
+
161
+ public function delete_manual_ua() {
162
+ if ( ! empty( $this->profile ) && ! empty( $this->profile['manual'] ) ) {
163
+ unset( $this->profile['manual'] );
164
+ $this->set_analytics_profile( $this->profile );
165
+ }
166
+ }
167
+
168
+ public function delete_network_manual_ua() {
169
+ if ( ! empty( $this->network ) && ! empty( $this->network['manual'] ) ) {
170
+ unset( $this->network['manual'] );
171
+ $this->set_network_analytics_profile( $this->network );
172
+ }
173
+ }
174
+
175
+ public function get_manual_ua() {
176
+ return ! empty( $this->profile['manual'] ) ? monsterinsights_is_valid_ua( $this->profile['manual'] ) : '';
177
+ }
178
+
179
+ public function get_network_manual_ua() {
180
+ return ! empty( $this->network['manual'] ) ? monsterinsights_is_valid_ua( $this->network['manual'] ) : '';
181
+ }
182
+
183
+ public function get_ua() {
184
+ return ! empty( $this->profile['ua'] ) ? monsterinsights_is_valid_ua( $this->profile['ua'] ) : '';
185
+ }
186
+
187
+ public function get_network_ua() {
188
+ return ! empty( $this->network['ua'] ) ? monsterinsights_is_valid_ua( $this->network['ua'] ) : '';
189
+ }
190
+
191
+ public function get_viewname(){
192
+ return ! empty( $this->profile['viewname'] ) ? $this->profile['viewname'] : '';
193
+ }
194
+
195
+ public function get_network_viewname(){
196
+ return ! empty( $this->network['viewname'] ) ? $this->network['viewname'] : '';
197
+ }
198
+
199
+ public function get_accountid(){
200
+ return ! empty( $this->profile['a'] ) ? $this->profile['a'] : '';
201
+ }
202
+
203
+ public function get_network_accountid(){
204
+ return ! empty( $this->network['a'] ) ? $this->network['a'] : '';
205
+ }
206
+
207
+ public function get_propertyid(){
208
+ return ! empty( $this->profile['w'] ) ? $this->profile['w'] : '';
209
+ }
210
+
211
+ public function get_network_propertyid(){
212
+ return ! empty( $this->network['w'] ) ? $this->network['w'] : '';
213
+ }
214
+
215
+ public function get_viewid(){ // also known as profileID
216
+ return ! empty( $this->profile['p'] ) ? $this->profile['p'] : '';
217
+ }
218
+
219
+ public function get_network_viewid(){ // also known as profileID
220
+ return ! empty( $this->network['p'] ) ? $this->network['p'] : '';
221
+ }
222
+
223
+ public function get_key(){
224
+ return ! empty( $this->profile['key'] ) ? $this->profile['key'] : '';
225
+ }
226
+
227
+ public function get_network_key(){
228
+ return ! empty( $this->network['key'] ) ? $this->network['key'] : '';
229
+ }
230
+
231
+ public function get_token(){
232
+ return ! empty( $this->profile['token'] ) ? $this->profile['token'] : '';
233
+ }
234
+
235
+ public function get_network_token(){
236
+ return ! empty( $this->network['token'] ) ? $this->network['token'] : '';
237
+ }
238
+
239
+ public function get_referral_url(){
240
+ $url = '';
241
+
242
+ if ( $this->is_authed() ) {
243
+ $url .= 'a' . MonsterInsights()->auth->get_accountid() . 'w' . MonsterInsights()->auth->get_propertyid() . 'p' . MonsterInsights()->auth->get_viewid() . '/';
244
+ } else if ( $this->is_network_authed() ) {
245
+ $url .= 'a' . MonsterInsights()->auth->get_network_accountid() . 'w' . MonsterInsights()->auth->get_network_propertyid() . 'p' . MonsterInsights()->auth->get_network_viewid() . '/';
246
+ }
247
+
248
+ return $url;
249
+ }
250
+ }
includes/capabilities.php CHANGED
@@ -1,89 +1,89 @@
1
- <?php
2
- /**
3
- * Capabilities class.
4
- *
5
- * @access public
6
- * @since 6.0.0
7
- *
8
- * @package MonsterInsights
9
- * @subpackage Capabilities
10
- * @author Chris Christoff
11
- */
12
-
13
- // Exit if accessed directly
14
- if ( ! defined( 'ABSPATH' ) ) {
15
- exit;
16
- }
17
-
18
- /**
19
- * Map MonsterInsights Capabilities.
20
- *
21
- * Using meta caps, we're creating virtual capabilities that are
22
- * for backwards compatibility reasons given to users with manage_options, and to
23
- * users who have at least of the roles selected in the options on the permissions
24
- * tab of the MonsterInsights settings.
25
- *
26
- * @access public
27
- * @since 6.0.0
28
- *
29
- * @param array $caps Array of capabilities the user has.
30
- * @param string $cap The current cap being filtered.
31
- * @param int $user_id User to check permissions for.
32
- * @param array $args Extra parameters. Unused.
33
- * @return array Array of caps needed to have this meta cap. If returned array is empty, user has the capability.
34
- */
35
- function monsterinsights_add_capabilities( $caps, $cap, $user_id, $args ) {
36
-
37
- switch( $cap ) {
38
- case 'monsterinsights_view_dashboard' :
39
- $roles = monsterinsights_get_option( 'view_reports', array() );
40
-
41
- $user_can_via_settings = false;
42
- if ( ! empty( $roles ) && is_array( $roles ) ) {
43
- foreach ( $roles as $role ) {
44
- if ( is_string( $role ) ) {
45
- if ( user_can( $user_id, $role ) ) {
46
- $user_can_via_settings = true;
47
- break;
48
- }
49
- }
50
- }
51
- } else if ( ! empty( $roles ) && is_string( $roles ) ) {
52
- if ( user_can( $user_id, $roles ) ) {
53
- $user_can_via_settings = true;
54
- }
55
- }
56
-
57
- if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) {
58
- $caps = array();
59
- }
60
-
61
- break;
62
- case 'monsterinsights_save_settings' :
63
- $roles = monsterinsights_get_option( 'save_settings', array() );
64
-
65
- $user_can_via_settings = false;
66
- if ( ! empty( $roles ) && is_array( $roles ) ) {
67
- foreach ( $roles as $role ) {
68
- if ( is_string( $role ) ) {
69
- if ( user_can( $user_id, $role ) ) {
70
- $user_can_via_settings = true;
71
- break;
72
- }
73
- }
74
- }
75
- } else if ( ! empty( $roles ) && is_string( $roles ) ) {
76
- if ( user_can( $user_id, $roles ) ) {
77
- $user_can_via_settings = true;
78
- }
79
- }
80
-
81
- if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) {
82
- $caps = array();
83
- }
84
-
85
- break;
86
- }
87
- return $caps;
88
- }
89
  add_filter( 'map_meta_cap','monsterinsights_add_capabilities', 10, 4 );
1
+ <?php
2
+ /**
3
+ * Capabilities class.
4
+ *
5
+ * @access public
6
+ * @since 6.0.0
7
+ *
8
+ * @package MonsterInsights
9
+ * @subpackage Capabilities
10
+ * @author Chris Christoff
11
+ */
12
+
13
+ // Exit if accessed directly
14
+ if ( ! defined( 'ABSPATH' ) ) {
15
+ exit;
16
+ }
17
+
18
+ /**
19
+ * Map MonsterInsights Capabilities.
20
+ *
21
+ * Using meta caps, we're creating virtual capabilities that are
22
+ * for backwards compatibility reasons given to users with manage_options, and to
23
+ * users who have at least of the roles selected in the options on the permissions
24
+ * tab of the MonsterInsights settings.
25
+ *
26
+ * @access public
27
+ * @since 6.0.0
28
+ *
29
+ * @param array $caps Array of capabilities the user has.
30
+ * @param string $cap The current cap being filtered.
31
+ * @param int $user_id User to check permissions for.
32
+ * @param array $args Extra parameters. Unused.
33
+ * @return array Array of caps needed to have this meta cap. If returned array is empty, user has the capability.
34
+ */
35
+ function monsterinsights_add_capabilities( $caps, $cap, $user_id, $args ) {
36
+
37
+ switch( $cap ) {
38
+ case 'monsterinsights_view_dashboard' :
39
+ $roles = monsterinsights_get_option( 'view_reports', array() );
40
+
41
+ $user_can_via_settings = false;
42
+ if ( ! empty( $roles ) && is_array( $roles ) ) {
43
+ foreach ( $roles as $role ) {
44
+ if ( is_string( $role ) ) {
45
+ if ( user_can( $user_id, $role ) ) {
46
+ $user_can_via_settings = true;
47
+ break;
48
+ }
49
+ }
50
+ }
51
+ } else if ( ! empty( $roles ) && is_string( $roles ) ) {
52
+ if ( user_can( $user_id, $roles ) ) {
53
+ $user_can_via_settings = true;
54
+ }
55
+ }
56
+
57
+ if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) {
58
+ $caps = array();
59
+ }
60
+
61
+ break;
62
+ case 'monsterinsights_save_settings' :
63
+ $roles = monsterinsights_get_option( 'save_settings', array() );
64
+
65
+ $user_can_via_settings = false;
66
+ if ( ! empty( $roles ) && is_array( $roles ) ) {
67
+ foreach ( $roles as $role ) {
68
+ if ( is_string( $role ) ) {
69
+ if ( user_can( $user_id, $role ) ) {
70
+ $user_can_via_settings = true;
71
+ break;
72
+ }
73
+ }
74
+ }
75
+ } else if ( ! empty( $roles ) && is_string( $roles ) ) {
76
+ if ( user_can( $user_id, $roles ) ) {
77
+ $user_can_via_settings = true;
78
+ }
79
+ }
80
+
81
+ if ( user_can( $user_id, 'manage_options' ) || $user_can_via_settings ) {
82
+ $caps = array();
83
+ }
84
+
85
+ break;
86
+ }
87
+ return $caps;
88
+ }
89
  add_filter( 'map_meta_cap','monsterinsights_add_capabilities', 10, 4 );
includes/deprecated.php CHANGED
@@ -1,236 +1,238 @@
1
- <?php
2
- /**
3
- * Deprecated functions.
4
- *
5
- * Contains the functions used to deprecate functions and
6
- * hooks in MonsterInsights, as well as the deprecated functions
7
- * and hooks themselves, where possible.
8
- *
9
- * @since 6.0.0
10
- *
11
- * @package MonsterInsights
12
- * @subpackage Deprecated
13
- * @author Chris Christoff
14
- */
15
-
16
- // Exit if accessed directly
17
- if ( ! defined( 'ABSPATH' ) ) {
18
- exit;
19
- }
20
-
21
- /**
22
- * Fires functions attached to a deprecated filter hook.
23
- *
24
- * When a filter hook is deprecated, the apply_filters() call is replaced with
25
- * apply_filters_deprecated(), which triggers a deprecation notice and then fires
26
- * the original filter hook. Note, this is a copy of WordPress core's _apply_filters_deprecated
27
- * function, that we've copied into MonsterInsights so that we can use it on WordPress
28
- * versions older than 6.0.0 (when it was introduced to core). If we ever bump our
29
- * minimum WP version requirements above 6.0.0, we'll remove this function.
30
- *
31
- * @since 6.0.0
32
- * @access private
33
- *
34
- * @see _apply_filters_deprecated()
35
- *
36
- * @param string $tag The name of the filter hook.
37
- * @param array $args Array of additional function arguments to be passed to apply_filters().
38
- * @param string $version The version of WordPress that deprecated the hook.
39
- * @param string $message Optional. A message regarding the change. Default null.
40
- */
41
- function _monsterinsights_apply_filters_deprecated( $tag, $args, $version, $message = null ) {
42
- if ( ! has_filter( $tag ) ) {
43
- return $args[0];
44
- }
45
-
46
- _monsterinsights_deprecated_hook( $tag, $version, $message );
47
-
48
- return apply_filters_ref_array( $tag, $args );
49
- }
50
-
51
- /**
52
- * Fires functions attached to a deprecated action hook.
53
- *
54
- * When an action hook is deprecated, the do_action() call is replaced with
55
- * do_action_deprecated(), which triggers a deprecation notice and then fires
56
- * the original hook. Note, this is a copy of WordPress core's _do_action_deprecated
57
- * function, that we've copied into MonsterInsights so that we can use it on WordPress
58
- * versions older than 6.0.0 (when it was introduced to core). If we ever bump our
59
- * minimum WP version requirements above 6.0.0, we'll remove this function.
60
- *
61
- * @since 6.0.0
62
- * @access private
63
- *
64
- * @see _do_action_deprecated()
65
- *
66
- * @param string $tag The name of the action hook.
67
- * @param array $args Array of additional function arguments to be passed to do_action().
68
- * @param string $version The version of WordPress that deprecated the hook.
69
- * @param string $message Optional. A message regarding the change.
70
- */
71
- function _monsterinsights_do_action_deprecated( $tag, $args, $version, $message = null ) {
72
- if ( ! has_action( $tag ) ) {
73
- return;
74
- }
75
-
76
- _monsterinsights_deprecated_hook( $tag, $version, $message );
77
-
78
- do_action_ref_array( $tag, $args );
79
- }
80
-
81
- /**
82
- * Marks a deprecated action or filter hook as deprecated and throws a notice.
83
- *
84
- * Use the {@see 'deprecated_hook_run'} action to get the backtrace describing where
85
- * the deprecated hook was called.
86
- *
87
- * Default behavior is to trigger a user error if `WP_DEBUG` is true.
88
- *
89
- * This function is called by the do_action_deprecated() and apply_filters_deprecated()
90
- * functions, and so generally does not need to be called directly.
91
- *
92
- * Note, this is a copy of WordPress core's _deprecated_hook
93
- * function, that we've copied into MonsterInsights so that we can use it on WordPress
94
- * versions older than 6.0.0 (when it was introduced to core). If we ever bump our
95
- * minimum WP version requirements above 6.0.0, we'll remove this function.
96
- *
97
- * @since 6.0.0
98
- * @access private
99
- *
100
- * @param string $hook The hook that was used.
101
- * @param string $version The version of WordPress that deprecated the hook.
102
- * @param string $message Optional. A message regarding the change.
103
- */
104
- function _monsterinsights_deprecated_hook( $hook, $version, $message = null ) {
105
- /**
106
- * Fires when a deprecated hook is called.
107
- *
108
- * @since 6.0.0
109
- *
110
- * @param string $hook The hook that was called.
111
- * @param string $version The version of MonsterInsights that deprecated the hook used.
112
- * @param string $message A message regarding the change.
113
- */
114
- do_action( 'deprecated_hook_run', $hook, $version, $message );
115
-
116
- /**
117
- * Filters whether to trigger deprecated hook errors.
118
- *
119
- * @since 6.0.0
120
- *
121
- * @param bool $trigger Whether to trigger deprecated hook errors. Requires
122
- * `WP_DEBUG` to be defined true.
123
- */
124
- if ( ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) || monsterinsights_is_debug_mode() ) {
125
- $message = empty( $message ) ? '' : ' ' . $message;
126
- trigger_error( sprintf( esc_html__( '%1$s is %3$sdeprecated%4$s since MonsterInsights version %2$s!', 'google-analytics-for-wordpress' ), $hook, $version, '<strong>', '</strong>' ) . esc_html ( $message ) );
127
- }
128
- }
129
-
130
- /**
131
- * Marks a function as deprecated and informs when it has been used.
132
- *
133
- * There is a hook monsterinsights_deprecated_function_run that will be called that can be used
134
- * to get the backtrace up to what file and function called the deprecated
135
- * function. Based on the one in EDD core.
136
- *
137
- * The current behavior is to trigger a user error if WP_DEBUG is true.
138
- *
139
- * This function is to be used in every function that is deprecated.
140
- *
141
- * @since 6.0.0
142
- * @access private
143
- *
144
- * @uses do_action() Calls 'monsterinsights_deprecated_function_run' and passes the function name, what to use instead,
145
- * and the version the function was deprecated in.
146
- * @uses apply_filters() Calls 'monsterinsights_deprecated_function_trigger_error' and expects boolean value of true to do
147
- * trigger or false to not trigger error.
148
- *
149
- * @param string $function The function that was called
150
- * @param string $version The version of WordPress that deprecated the function
151
- * @param array $backtrace Optional. Contains stack backtrace of deprecated function
152
- * @return void
153
- */
154
- function _monsterinsights_deprecated_function( $function, $version, $backtrace = null ) {
155
-
156
- /**
157
- * Deprecated Function Action.
158
- *
159
- * Allow plugin run an action on the use of a
160
- * deprecated function. This could be used to
161
- * feed into an error logging program or file.
162
- *
163
- * @since 6.0.0
164
- *
165
- * @param string $function The function that was called.
166
- * @param string $version The version of WordPress that deprecated the function.
167
- * @param array $backtrace Optional. Contains stack backtrace of deprecated function.
168
- */
169
- do_action( 'deprecated_function_run', $function, $version, $backtrace );
170
-
171
- /**
172
- * Filters whether to trigger an error for deprecated functions.
173
- *
174
- * @since 6.0.0
175
- *
176
- * @param bool $trigger Whether to trigger the error for deprecated functions. Default true.
177
- */
178
- if ( ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) || monsterinsights_is_debug_mode() ) {
179
- trigger_error( sprintf( esc_html__( '%1$s is %3$sdeprecated%4$s since MonsterInsights version %2$s.', 'google-analytics-for-wordpress' ), $function, $version, '<strong>', '</strong>' ) );
180
- trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
181
- // Alternatively we could dump this to a file.
182
- }
183
- }
184
-
185
- /**
186
- * Marks something as deprecated.
187
- *
188
- * The current behavior is to trigger a user error if WP_DEBUG is true.
189
- *
190
- * @since 6.0.0
191
- * @access private
192
- *
193
- * @uses apply_filters() Calls 'monsterinsights_deprecated_trigger_error' and expects boolean value of true to do
194
- * trigger or false to not trigger error.
195
- *
196
- * @param string $message Deprecation message shown.
197
- * @return void
198
- */
199
- function _monsterinsights_deprecated( $message ) {
200
-
201
- /**
202
- * Deprecated Message Filter.
203
- *
204
- * Allow plugin to filter the deprecated message.
205
- *
206
- * @since 6.0.0
207
- *
208
- * @param string $message Error message.
209
- */
210
- do_action( 'monsterinsights_deprecated_run', $message );
211
-
212
- $show_errors = current_user_can( 'manage_options' );
213
-
214
- /**
215
- * Deprecated Error Trigger.
216
- *
217
- * Allow plugin to filter the output error trigger.
218
- *
219
- * @since 6.0.0
220
- *
221
- * @param bool $show_errors Whether to show errors.
222
- */
223
- $show_errors = apply_filters( 'monsterinsights_deprecated_trigger_error', $show_errors );
224
- if ( ( WP_DEBUG && $show_errors ) || monsterinsights_is_debug_mode() ) {
225
- trigger_error( esc_html( $message ) );
226
- }
227
- }
228
-
229
-
230
- /**
231
- * Start Deprecated Actions & Filters.
232
- *
233
- * These backwards compatibility fixes may be removed at any time.
234
- * Users/Developers are encouraged to update their code as soon as possible.
235
- */
236
-
 
 
1
+ <?php
2
+ /**
3
+ * Deprecated functions.
4
+ *
5
+ * Contains the functions used to deprecate functions and
6
+ * hooks in MonsterInsights, as well as the deprecated functions
7
+ * and hooks themselves, where possible.
8
+ *
9
+ * @since 6.0.0
10
+ *
11
+ * @package MonsterInsights
12
+ * @subpackage Deprecated
13
+ * @author Chris Christoff
14
+ */
15
+
16
+ // Exit if accessed directly
17
+ if ( ! defined( 'ABSPATH' ) ) {
18
+ exit;
19
+ }
20
+
21
+ /**
22
+ * Fires functions attached to a deprecated filter hook.
23
+ *
24
+ * When a filter hook is deprecated, the apply_filters() call is replaced with
25
+ * apply_filters_deprecated(), which triggers a deprecation notice and then fires
26
+ * the original filter hook. Note, this is a copy of WordPress core's _apply_filters_deprecated
27
+ * function, that we've copied into MonsterInsights so that we can use it on WordPress
28
+ * versions older than 6.0.0 (when it was introduced to core). If we ever bump our
29
+ * minimum WP version requirements above 6.0.0, we'll remove this function.
30
+ *
31
+ * @since 6.0.0
32
+ * @access private
33
+ *
34
+ * @see _apply_filters_deprecated()
35
+ *
36
+ * @param string $tag The name of the filter hook.
37
+ * @param array $args Array of additional function arguments to be passed to apply_filters().
38
+ * @param string $version The version of WordPress that deprecated the hook.
39
+ * @param string $message Optional. A message regarding the change. Default null.
40
+ */
41
+ function _monsterinsights_apply_filters_deprecated( $tag, $args, $version, $message = null ) {
42
+ if ( ! has_filter( $tag ) ) {
43
+ return $args[0];
44
+ }
45
+
46
+ _monsterinsights_deprecated_hook( $tag, $version, $message );
47
+
48
+ return apply_filters_ref_array( $tag, $args );
49
+ }
50
+
51
+ /**
52
+ * Fires functions attached to a deprecated action hook.
53
+ *
54
+ * When an action hook is deprecated, the do_action() call is replaced with
55
+ * do_action_deprecated(), which triggers a deprecation notice and then fires
56
+ * the original hook. Note, this is a copy of WordPress core's _do_action_deprecated
57
+ * function, that we've copied into MonsterInsights so that we can use it on WordPress
58
+ * versions older than 6.0.0 (when it was introduced to core). If we ever bump our
59
+ * minimum WP version requirements above 6.0.0, we'll remove this function.
60
+ *
61
+ * @since 6.0.0
62
+ * @access private
63
+ *
64
+ * @see _do_action_deprecated()
65
+ *
66
+ * @param string $tag The name of the action hook.
67
+ * @param array $args Array of additional function arguments to be passed to do_action().
68
+ * @param string $version The version of WordPress that deprecated the hook.
69
+ * @param string $message Optional. A message regarding the change.
70
+ */
71
+ function _monsterinsights_do_action_deprecated( $tag, $args, $version, $message = null ) {
72
+ if ( ! has_action( $tag ) ) {
73
+ return;
74
+ }
75
+
76
+ _monsterinsights_deprecated_hook( $tag, $version, $message );
77
+
78
+ do_action_ref_array( $tag, $args );
79
+ }
80
+
81
+ /**
82
+ * Marks a deprecated action or filter hook as deprecated and throws a notice.
83
+ *
84
+ * Use the {@see 'deprecated_hook_run'} action to get the backtrace describing where
85
+ * the deprecated hook was called.
86
+ *
87
+ * Default behavior is to trigger a user error if `WP_DEBUG` is true.
88
+ *
89
+ * This function is called by the do_action_deprecated() and apply_filters_deprecated()
90
+ * functions, and so generally does not need to be called directly.
91
+ *
92
+ * Note, this is a copy of WordPress core's _deprecated_hook
93
+ * function, that we've copied into MonsterInsights so that we can use it on WordPress
94
+ * versions older than 6.0.0 (when it was introduced to core). If we ever bump our
95
+ * minimum WP version requirements above 6.0.0, we'll remove this function.
96
+ *
97
+ * @since 6.0.0
98
+ * @access private
99
+ *
100
+ * @param string $hook The hook that was used.
101
+ * @param string $version The version of WordPress that deprecated the hook.
102
+ * @param string $message Optional. A message regarding the change.
103
+ */
104
+ function _monsterinsights_deprecated_hook( $hook, $version, $message = null ) {
105
+ /**
106
+ * Fires when a deprecated hook is called.
107
+ *
108
+ * @since 6.0.0
109
+ *
110
+ * @param string $hook The hook that was called.
111
+ * @param string $version The version of MonsterInsights that deprecated the hook used.
112
+ * @param string $message A message regarding the change.
113
+ */
114
+ do_action( 'deprecated_hook_run', $hook, $version, $message );
115
+
116
+ /**
117
+ * Filters whether to trigger deprecated hook errors.
118
+ *
119
+ * @since 6.0.0
120
+ *
121
+ * @param bool $trigger Whether to trigger deprecated hook errors. Requires
122
+ * `WP_DEBUG` to be defined true.
123
+ */
124
+ if ( ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) || monsterinsights_is_debug_mode() ) {
125
+ $message = empty( $message ) ? '' : ' ' . $message;
126
+ // Translators: Placeholders add the hook name, plugin version and bold text.
127
+ trigger_error( sprintf( esc_html__( '%1$s is %3$sdeprecated%4$s since MonsterInsights version %2$s!', 'google-analytics-for-wordpress' ), $hook, $version, '<strong>', '</strong>' ) . esc_html ( $message ) );
128
+ }
129
+ }
130
+
131
+ /**
132
+ * Marks a function as deprecated and informs when it has been used.
133
+ *
134
+ * There is a hook monsterinsights_deprecated_function_run that will be called that can be used
135
+ * to get the backtrace up to what file and function called the deprecated
136
+ * function. Based on the one in EDD core.
137
+ *
138
+ * The current behavior is to trigger a user error if WP_DEBUG is true.
139
+ *
140
+ * This function is to be used in every function that is deprecated.
141
+ *
142
+ * @since 6.0.0
143
+ * @access private
144
+ *
145
+ * @uses do_action() Calls 'monsterinsights_deprecated_function_run' and passes the function name, what to use instead,
146
+ * and the version the function was deprecated in.
147
+ * @uses apply_filters() Calls 'monsterinsights_deprecated_function_trigger_error' and expects boolean value of true to do
148
+ * trigger or false to not trigger error.
149
+ *
150
+ * @param string $function The function that was called
151
+ * @param string $version The version of WordPress that deprecated the function
152
+ * @param array $backtrace Optional. Contains stack backtrace of deprecated function
153
+ * @return void
154
+ */
155
+ function _monsterinsights_deprecated_function( $function, $version, $backtrace = null ) {
156
+
157
+ /**
158
+ * Deprecated Function Action.
159
+ *
160
+ * Allow plugin run an action on the use of a
161
+ * deprecated function. This could be used to
162
+ * feed into an error logging program or file.
163
+ *
164
+ * @since 6.0.0
165
+ *
166
+ * @param string $function The function that was called.
167
+ * @param string $version The version of WordPress that deprecated the function.
168
+ * @param array $backtrace Optional. Contains stack backtrace of deprecated function.
169
+ */
170
+ do_action( 'deprecated_function_run', $function, $version, $backtrace );
171
+
172
+ /**
173
+ * Filters whether to trigger an error for deprecated functions.
174
+ *
175
+ * @since 6.0.0
176
+ *
177
+ * @param bool $trigger Whether to trigger the error for deprecated functions. Default true.
178
+ */
179
+ if ( ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) || monsterinsights_is_debug_mode() ) {
180
+ // Translators: Placeholders add the hook name, plugin version and bold text.
181
+ trigger_error( sprintf( esc_html__( '%1$s is %3$sdeprecated%4$s since MonsterInsights version %2$s.', 'google-analytics-for-wordpress' ), $function, $version, '<strong>', '</strong>' ) );
182
+ trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
183
+ // Alternatively we could dump this to a file.
184
+ }
185
+ }
186
+
187
+ /**
188
+ * Marks something as deprecated.
189
+ *
190
+ * The current behavior is to trigger a user error if WP_DEBUG is true.
191
+ *
192
+ * @since 6.0.0
193
+ * @access private
194
+ *
195
+ * @uses apply_filters() Calls 'monsterinsights_deprecated_trigger_error' and expects boolean value of true to do
196
+ * trigger or false to not trigger error.
197
+ *
198
+ * @param string $message Deprecation message shown.
199
+ * @return void
200
+ */
201
+ function _monsterinsights_deprecated( $message ) {
202
+
203
+ /**
204
+ * Deprecated Message Filter.
205
+ *
206
+ * Allow plugin to filter the deprecated message.
207
+ *
208
+ * @since 6.0.0
209
+ *
210
+ * @param string $message Error message.
211
+ */
212
+ do_action( 'monsterinsights_deprecated_run', $message );
213
+
214
+ $show_errors = current_user_can( 'manage_options' );
215
+
216
+ /**
217
+ * Deprecated Error Trigger.
218
+ *
219
+ * Allow plugin to filter the output error trigger.
220
+ *
221
+ * @since 6.0.0
222
+ *
223
+ * @param bool $show_errors Whether to show errors.
224
+ */
225
+ $show_errors = apply_filters( 'monsterinsights_deprecated_trigger_error', $show_errors );
226
+ if ( ( WP_DEBUG && $show_errors ) || monsterinsights_is_debug_mode() ) {
227
+ trigger_error( esc_html( $message ) );
228
+ }
229
+ }
230
+
231
+
232
+ /**
233
+ * Start Deprecated Actions & Filters.
234
+ *
235
+ * These backwards compatibility fixes may be removed at any time.
236
+ * Users/Developers are encouraged to update their code as soon as possible.
237
+ */
238
+
includes/emails/class-emails.php ADDED
@@ -0,0 +1,664 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Emails.
5
+ *
6
+ * This class handles all (notification) emails sent by MonsterInsights.
7
+ *
8
+ * Heavily influenced by the AffiliateWP plugin by Pippin Williamson.
9
+ * https://github.com/AffiliateWP/AffiliateWP/blob/master/includes/emails/class-affwp-emails.php
10
+ *
11
+ * @since 7.10.5
12
+ */
13
+ class MonsterInsights_WP_Emails {
14
+
15
+ /**
16
+ * Holds the from address.
17
+ *
18
+ * @since 7.10.5
19
+ *
20
+ * @var string
21
+ */
22
+ private $from_address;
23
+
24
+ /**
25
+ * Holds the from name.
26
+ *
27
+ * @since 7.10.5
28
+ *
29
+ * @var string
30
+ */
31
+ private $from_name;
32
+
33
+ /**
34
+ * Holds the reply-to address.
35
+ *
36
+ * @since 7.10.5
37
+ *
38
+ * @var string
39
+ */
40
+ private $reply_to = false;
41
+
42
+ /**
43
+ * Holds the carbon copy addresses.
44
+ *
45
+ * @since 7.10.5
46
+ *
47
+ * @var string
48
+ */
49
+ private $cc = false;
50
+
51
+ /**
52
+ * Holds the email content type.
53
+ *
54
+ * @since 7.10.5
55
+ *
56
+ * @var string
57
+ */
58
+ private $content_type;
59
+
60
+ /**
61
+ * Holds the email headers.
62
+ *
63
+ * @since 7.10.5
64
+ *
65
+ * @var string
66
+ */
67
+ private $headers;
68
+
69
+ /**
70
+ * Whether to send email in HTML.
71
+ *
72
+ * @since 7.10.5
73
+ *
74
+ * @var bool
75
+ */
76
+ private $html = true;
77
+
78
+ /**
79
+ * The email template to use.
80
+ *
81
+ * @since 7.10.5
82
+ *
83
+ * @var string
84
+ */
85
+ private $template;
86
+
87
+ /**
88
+ * Header/footer/body arguments.
89
+ *
90
+ * @since 7.10.5
91
+ *
92
+ * @var array
93
+ */
94
+ protected $args;
95
+
96
+ /**
97
+ * Get things going.
98
+ *
99
+ * @since 7.10.5
100
+ */
101
+ public function __construct( $template ) {
102
+ $this->template = $template;
103
+
104
+ $this->set_initial_args();
105
+
106
+ add_action( 'monsterinsights_email_send_before', array( $this, 'send_before' ) );
107
+ add_action( 'monsterinsights_email_send_after', array( $this, 'send_after' ) );
108
+ }
109
+
110
+ /**
111
+ * Set a property.
112
+ *
113
+ * @since 7.10.5
114
+ *
115
+ * @param string $key Object property key.
116
+ * @param mixed $value Object property value.
117
+ */
118
+ public function __set( $key, $value ) {
119
+ $this->$key = $value;
120
+ }
121
+
122
+ /**
123
+ * Get the email from name.
124
+ *
125
+ * @since 7.10.5
126
+ *
127
+ * @return string The email from name
128
+ */
129
+ public function get_from_name() {
130
+
131
+ if ( ! empty( $this->from_name ) ) {
132
+ $this->from_name = $this->process_tag( $this->from_name );
133
+ } else {
134
+ $this->from_name = get_bloginfo( 'name' );
135
+ }
136
+
137
+ return apply_filters( 'monsterinsights_email_from_name', monsterinsights_decode_string( $this->from_name ), $this );
138
+ }
139
+
140
+ /**
141
+ * Get the email from address.
142
+ *
143
+ * @since 7.10.5
144
+ *
145
+ * @return string The email from address.
146
+ */
147
+ public function get_from_address() {
148
+
149
+ if ( ! empty( $this->from_address ) ) {
150
+ $this->from_address = $this->process_tag( $this->from_address );
151
+ } else {
152
+ $this->from_address = get_option( 'admin_email' );
153
+ }
154
+
155
+ return apply_filters( 'monsterinsights_email_from_address', $this->from_address, $this );
156
+ }
157
+
158
+ /**
159
+ * Get the email reply-to.
160
+ *
161
+ * @since 7.10.5
162
+ *
163
+ * @return string The email reply-to address.
164
+ */
165
+ public function get_reply_to() {
166
+
167
+ if ( ! empty( $this->reply_to ) ) {
168
+
169
+ $this->reply_to = $this->process_tag( $this->reply_to );
170
+
171
+ if ( ! is_email( $this->reply_to ) ) {
172
+ $this->reply_to = false;
173
+ }
174
+ }
175
+
176
+ return apply_filters( 'monsterinsights_email_reply_to', $this->reply_to, $this );
177
+ }
178
+
179
+ /**
180
+ * Get the email carbon copy addresses.
181
+ *
182
+ * @since 7.10.5
183
+ *
184
+ * @return string The email reply-to address.
185
+ */
186
+ public function get_cc() {
187
+
188
+ if ( ! empty( $this->cc ) ) {
189
+
190
+ $this->cc = $this->process_tag( $this->cc );
191
+
192
+ $addresses = array_map( 'trim', explode( ',', $this->cc ) );
193
+
194
+ foreach ( $addresses as $key => $address ) {
195
+ if ( ! is_email( $address ) ) {
196
+ unset( $addresses[ $key ] );
197
+ }
198
+ }
199
+
200
+ $this->cc = implode( ',', $addresses );
201
+ }
202
+
203
+ return apply_filters( 'monsterinsights_email_cc', $this->cc, $this );
204
+ }
205
+
206
+ /**
207
+ * Get the email content type.
208
+ *
209
+ * @since 7.10.5
210
+ *
211
+ * @return string The email content type.
212
+ */
213
+ public function get_content_type() {
214
+
215
+ if ( ! $this->content_type && $this->html ) {
216
+ $this->content_type = apply_filters( 'monsterinsights_email_default_content_type', 'text/html', $this );
217
+ } elseif ( ! $this->html ) {
218
+ $this->content_type = 'text/plain';
219
+ }
220
+
221
+ return apply_filters( 'monsterinsights_email_content_type', $this->content_type, $this );
222
+ }
223
+
224
+ /**
225
+ * Get the email headers.
226
+ *
227
+ * @since 7.10.5
228
+ *
229
+ * @return string The email headers.
230
+ */
231
+ public function get_headers() {
232
+
233
+ if ( ! $this->headers ) {
234
+ $this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n";
235
+ if ( $this->get_reply_to() ) {
236
+ $this->headers .= "Reply-To: {$this->get_reply_to()}\r\n";
237
+ }
238
+ if ( $this->get_cc() ) {
239
+ $this->headers .= "Cc: {$this->get_cc()}\r\n";
240
+ }
241
+ $this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n";
242
+ }
243
+
244
+ return apply_filters( 'monsterinsights_email_headers', $this->headers, $this );
245
+ }
246
+
247
+ /**
248
+ * Set initial arguments to use in a template.
249
+ *
250
+ * @since 7.10.5
251
+ */
252
+ public function set_initial_args() {
253
+ $header_args = array(
254
+ 'title' => esc_html__( 'MonsterInsights', 'google-analytics-for-wordpress' ),
255
+ );
256
+
257
+ $args = array(
258
+ 'header' => array(),
259
+ 'body' => array(),
260
+ 'footer' => array(),
261
+ );
262
+
263
+ $from_address = $this->get_from_address();
264
+ if ( ! empty( $from_address ) ) {
265
+ $args['footer']['from_address'] = $from_address;
266
+ }
267
+
268
+ $args = apply_filters( 'monsterinsights_emails_templates_set_initial_args', $args, $this );
269
+
270
+ $this->set_args( $args );
271
+ }
272
+
273
+ /**
274
+ * Set header/footer/body/style arguments to use in a template.
275
+ *
276
+ * @since 7.10.5
277
+ *
278
+ * @param array $args Arguments to set.
279
+ * @param bool $merge Merge the arguments with existing once or replace.
280
+ *
281
+ * @return MI_WP_Emails
282
+ */
283
+ public function set_args( $args, $merge = true ) {
284
+
285
+ $args = apply_filters( 'monsterinsights_emails_templates_set_args', $args, $this );
286
+
287
+ if ( empty( $args ) || ! is_array( $args ) ) {
288
+ return $this;
289
+ }
290
+
291
+ foreach ( $args as $type => $value ) {
292
+
293
+ if ( ! is_array( $value ) ) {
294
+ continue;
295
+ }
296
+
297
+ if ( ! isset( $this->args[ $type ] ) || ! is_array( $this->args[ $type ] ) ) {
298
+ $this->args[ $type ] = array();
299
+ }
300
+
301
+ $this->args[ $type ] = $merge ? array_merge( $this->args[ $type ], $value ) : $value;
302
+ }
303
+
304
+ return $this;
305
+ }
306
+
307
+ /**
308
+ * Get header/footer/body arguments
309
+ *
310
+ * @since 7.10.5
311
+ *
312
+ * @param string $type Header/footer/body.
313
+ *
314
+ * @return array
315
+ */
316
+ public function get_args( $type ) {
317
+ if ( ! empty( $type ) ) {
318
+ return isset( $this->args[ $type ] ) ? apply_filters( 'monsterinsights_emails_templates_get_args_' . $type, $this->args[ $type ], $this ) : array();
319
+ }
320
+
321
+ return apply_filters( 'monsterinsights_emails_templates_get_args', $this->args, $this );
322
+ }
323
+
324
+ /**
325
+ * Build the email.
326
+ *
327
+ * @since 7.10.5
328
+ *
329
+ * @param string $message The email message.
330
+ *
331
+ * @return string
332
+ */
333
+ public function build_email( $message=null ) {
334
+ // process plain text email
335
+ if ( false === $this->html ) {
336
+ $body = $this->get_template_part( 'body', $this->get_template(), true );
337
+ $body = wp_strip_all_tags( $body );
338
+ $message = str_replace( '{email}', $message, $body );
339
+
340
+ return apply_filters( 'monsterinsights_email_message', $message, $this );
341
+ }
342
+
343
+ // process html email template
344
+ $email_parts = array();
345
+ $email_parts['header'] = $this->get_template_part( 'header', $this->get_template(), true );
346
+
347
+ // Hooks into the email header.
348
+ do_action( 'monsterinsights_email_header', $email_parts['header'] );
349
+
350
+ $email_parts['body'] = $this->get_template_part( 'body', $this->get_template(), true );
351
+
352
+ // Hooks into the email body.
353
+ do_action( 'monsterinsights_email_body', $email_parts['body'] );
354
+
355
+ $email_parts['footer'] = $this->get_template_part( 'footer', $this->get_template(), true );
356
+
357
+ // Hooks into the email footer.
358
+ do_action( 'monsterinsights_email_footer', $email_parts['footer'] );
359
+
360
+
361
+ $body = implode( $email_parts );
362
+ $message = $this->process_tag( $message, false );
363
+ $message = nl2br( $message );
364
+ $message = str_replace( '{email}', $message, $body );
365
+ //$message = make_clickable( $message );
366
+
367
+ return apply_filters( 'monsterinsights_email_message', $message, $this );
368
+ }
369
+
370
+ /**
371
+ * Send the email.
372
+ *
373
+ * @since 7.10.5
374
+ *
375
+ * @param string $to The To address.
376
+ * @param string $subject The subject line of the email.
377
+ * @param string $message The body of the email.
378
+ * @param array $attachments Attachments to the email.
379
+ *
380
+ * @return bool
381
+ */
382
+ public function send( $to, $subject, $message=null, $attachments = array() ) {
383
+
384
+ if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) {
385
+ _doing_it_wrong( __FUNCTION__, esc_html__( 'You cannot send emails with MI_WP_Emails() until init/admin_init has been reached.', 'google-analytics-for-wordpress' ), null );
386
+
387
+ return false;
388
+ }
389
+
390
+ // Don't send anything if emails have been disabled.
391
+ if ( $this->is_email_disabled() ) {
392
+ return false;
393
+ }
394
+
395
+ // Don't send if email address is invalid.
396
+ if ( ! is_email( $to ) ) {
397
+ return false;
398
+ }
399
+
400
+ // Hooks before email is sent.
401
+ do_action( 'monsterinsights_email_send_before', $this );
402
+
403
+ /*
404
+ * Allow to filter data on per-email basis,
405
+ * useful for localizations based on recipient email address, form settings,
406
+ * or for specific notifications - whatever available in MI_WP_Emails class.
407
+ */
408
+ $data = apply_filters(
409
+ 'monsterinsights_emails_send_email_data',
410
+ array(
411
+ 'to' => $to,
412
+ 'subject' => $subject,
413
+ 'message' => $message,
414
+ 'headers' => $this->get_headers(),
415
+ 'attachments' => $attachments,
416
+ ),
417
+ $this
418
+ );
419
+
420
+ // Let's do this.
421
+ $sent = wp_mail(
422
+ $data['to'],
423
+ monsterinsights_decode_string( $this->process_tag( $data['subject'] ) ),
424
+ $this->build_email( $data['message'] ),
425
+ $data['headers'],
426
+ $data['attachments']
427
+ );
428
+
429
+ // Hooks after the email is sent.
430
+ do_action( 'monsterinsights_email_send_after', $this );
431
+
432
+ return $sent;
433
+ }
434
+
435
+ /**
436
+ * Add filters/actions before the email is sent.
437
+ *
438
+ * @since 7.10.5
439
+ */
440
+ public function send_before() {
441
+
442
+ add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
443
+ add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
444
+ add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
445
+ }
446
+
447
+ /**
448
+ * Remove filters/actions after the email is sent.
449
+ *
450
+ * @since 7.10.5
451
+ */
452
+ public function send_after() {
453
+
454
+ remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
455
+ remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
456
+ remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
457
+ }
458
+
459
+ /**
460
+ * Process a smart tag.
461
+ *
462
+ * @since 7.10.5
463
+ *
464
+ * @param string $string String that may contain tags.
465
+ * @param bool $sanitize Toggle to maybe sanitize.
466
+ * @param bool $linebreaks Toggle to process linebreaks.
467
+ *
468
+ * @return string
469
+ */
470
+ public function process_tag( $string = '', $sanitize = true, $linebreaks = false ) {
471
+
472
+ $tag = apply_filters( 'monsterinsights_process_smart_tags', $string );
473
+
474
+ $tag = monsterinsights_decode_string( $tag );
475
+
476
+ if ( $sanitize ) {
477
+ if ( $linebreaks ) {
478
+ $tag = monsterinsights_sanitize_textarea_field( $tag );
479
+ } else {
480
+ $tag = sanitize_text_field( $tag );
481
+ }
482
+ }
483
+
484
+ return $tag;
485
+ }
486
+
487
+ /**
488
+ * Email kill switch if needed.
489
+ *
490
+ * @since 7.10.5
491
+ *
492
+ * @return bool
493
+ */
494
+ public function is_email_disabled() {
495
+ return (bool) apply_filters( 'monsterinsights_disable_all_emails', false, $this );
496
+ }
497
+
498
+ /**
499
+ * Get the enabled email template.
500
+ *
501
+ * @since 7.10.5
502
+ *
503
+ * @return string When filtering return 'default' to switch to text/plain email.
504
+ */
505
+ public function get_template() {
506
+
507
+ if ( ! empty( $this->template ) ) {
508
+ $this->template = $this->process_tag( $this->template );
509
+ } else {
510
+ $this->template = 'default';
511
+ }
512
+
513
+ return apply_filters( 'monsterinsights_email_template', $this->template);
514
+ }
515
+
516
+ /**
517
+ * Retrieves a template content.
518
+ *
519
+ * @since 7.10.5
520
+ *
521
+ * @param string $slug Template file slug.
522
+ * @param string $name Optional. Default null.
523
+ * @param bool $load Maybe load.
524
+ *
525
+ * @return string
526
+ */
527
+ public function get_template_part( $slug, $name = null, $load = true ) {
528
+
529
+ if ( false === $this->html ) {
530
+ $name .= '-plain';
531
+ }
532
+
533
+ if ( isset( $name ) ) {
534
+ $template = $slug . '-' . $name;
535
+
536
+ $html = $this->get_html(
537
+ $template,
538
+ $this->get_args( $slug ),
539
+ true
540
+ );
541
+
542
+ return apply_filters( 'monsterinsights_emails_templates_get_content_part', $html, $template, $this );
543
+ }
544
+
545
+ }
546
+
547
+ /**
548
+ * Like $this->include_html, but returns the HTML instead of including.
549
+ *
550
+ * @since 7.10.5
551
+ *
552
+ * @param string $template_name Template name.
553
+ * @param array $args Arguments.
554
+ * @param bool $extract Extract arguments.
555
+ *
556
+ * @return string
557
+ */
558
+ public static function get_html( $template_name, $args = array(), $extract = false ) {
559
+ ob_start();
560
+ self::include_html( $template_name, $args, $extract );
561
+ return ob_get_clean();
562
+ }
563
+
564
+ /**
565
+ * Include a template.
566
+ * Uses 'require' if $args are passed or 'load_template' if not.
567
+ *
568
+ * @since 7.10.5
569
+ *
570
+ * @param string $template_name Template name.
571
+ * @param array $args Arguments.
572
+ * @param bool $extract Extract arguments.
573
+ *
574
+ * @throws \RuntimeException If extract() tries to modify the scope.
575
+ */
576
+ public static function include_html( $template_name, $args = array(), $extract = false ) {
577
+
578
+ $template_name .= '.php';
579
+
580
+ // Allow 3rd party plugins to filter template file from their plugin.
581
+ $located = apply_filters( 'monsterinsights_helpers_templates_include_html_located', self::locate_template( $template_name ), $template_name, $args, $extract );
582
+ $args = apply_filters( 'monsterinsights_helpers_templates_include_html_args', $args, $template_name, $extract );
583
+
584
+ if ( empty( $located ) || ! is_readable( $located ) ) {
585
+ return;
586
+ }
587
+
588
+ // Load template WP way if no arguments were passed.
589
+ if ( empty( $args ) ) {
590
+ load_template( $located, false );
591
+ return;
592
+ }
593
+
594
+ $extract = apply_filters( 'monsterinsights_helpers_templates_include_html_extract_args', $extract, $template_name, $args );
595
+
596
+ if ( $extract && is_array( $args ) ) {
597
+
598
+ $created_vars_count = extract( $args, EXTR_SKIP ); // phpcs:ignore WordPress.PHP.DontExtract
599
+
600
+ // Protecting existing scope from modification.
601
+ if ( count( $args ) !== $created_vars_count ) {
602
+ throw new RuntimeException( 'Extraction failed: variable names are clashing with the existing ones.' );
603
+ }
604
+ }
605
+
606
+ require $located;
607
+ }
608
+
609
+ /**
610
+ * Locate a template and return the path for inclusion.
611
+ *
612
+ * @since 7.10.5
613
+ *
614
+ * @param string $template_name Template name.
615
+ *
616
+ * @return string
617
+ */
618
+ public static function locate_template( $template_name ) {
619
+
620
+ // Trim off any slashes from the template name.
621
+ $template_name = ltrim( $template_name, '/' );
622
+
623
+ if ( empty( $template_name ) ) {
624
+ return apply_filters( 'monsterinsights_helpers_templates_locate', '', $template_name );
625
+ }
626
+
627
+ $located = '';
628
+
629
+ // Try locating this template file by looping through the template paths.
630
+ foreach ( self::get_theme_template_paths() as $template_path ) {
631
+ if ( file_exists( $template_path . $template_name ) ) {
632
+ $located = $template_path . $template_name;
633
+ break;
634
+ }
635
+ }
636
+
637
+ return apply_filters( 'monsterinsights_helpers_templates_locate', $located, $template_name );
638
+ }
639
+
640
+ /**
641
+ * Return a list of paths to check for template locations
642
+ *
643
+ * @since 7.10.5
644
+ *
645
+ * @return array
646
+ */
647
+ public static function get_theme_template_paths() {
648
+
649
+ $template_dir = 'monsterinsights-email';
650
+
651
+ $file_paths = array(
652
+ 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
653
+ 10 => trailingslashit( get_template_directory() ) . $template_dir,
654
+ 100 => trailingslashit( MONSTERINSIGHTS_PLUGIN_DIR ) . 'includes/emails/templates',
655
+ );
656
+
657
+ $file_paths = apply_filters( 'monsterinsights_email_template_paths', $file_paths );
658
+
659
+ // Sort the file paths based on priority.
660
+ ksort( $file_paths, SORT_NUMERIC );
661
+
662
+ return array_map( 'trailingslashit', $file_paths );
663
+ }
664
+ }
includes/emails/templates/body-default-plain.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ echo "{email}";
includes/emails/templates/body-default.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Email Body
4
+ *
5
+ * Heavily influenced by the AffiliateWP plugin by Pippin Williamson.
6
+ * https://github.com/AffiliateWP/AffiliateWP/tree/master/templates/emails
7
+ *
8
+ * @since 7.10.5
9
+ */
10
+
11
+ // Exit if accessed directly.
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+ ?>
16
+ {email}
includes/emails/templates/footer-default.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Email Footer.
4
+ *
5
+ * @since 7.10.5
6
+ */
7
+
8
+ // Exit if accessed directly.
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ $background_color = '#e9eaec';
14
+ ?>
15
+ </td>
16
+ </tr>
17
+ </tbody>
18
+ </table>
19
+ </td>
20
+ </tr>
21
+ </tbody>
22
+ </table>
23
+ </td>
24
+ </tr>
25
+ <tr>
26
+ <td valign="top" id="templateFooter" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;background-color: <?php echo $background_color; ?>;border-top: 0;border-bottom: 0;padding-top: 12px;padding-bottom: 12px;">
27
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" class="mcnTextBlock" style="min-width: 100%;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
28
+ <tbody class="mcnTextBlockOuter">
29
+ <tr>
30
+ <td valign="top" class="mcnTextBlockInner" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
31
+ <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width: 100%;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;" class="mcnTextContentContainer">
32
+ <tbody>
33
+ <tr>
34
+ <td valign="top" class="mcnTextContent" style="padding-top: 9px;padding-right: 18px;padding-bottom: 9px;padding-left: 18px;mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;word-break: break-word;color: #aaa;font-family: Helvetica;font-size: 12px;line-height: 150%;text-align: center;">
35
+
36
+ <!-- Footer content -->
37
+ <?php
38
+ /* translators: %s - link to a site. */
39
+ $footer = sprintf( esc_html__( 'Sent from %s', 'google-analytics-for-wordpress' ), '<a href="' . esc_url( home_url() ) . '" style="color:#bbbbbb;">' . wp_specialchars_decode( get_bloginfo( 'name' ) ) . '</a>' );
40
+ echo apply_filters( 'monsterinsights_email_footer_text', $footer );
41
+ ?>
42
+
43
+ </td>
44
+ </tr>
45
+ </tbody>
46
+ </table>
47
+ </td>
48
+ </tr>
49
+ </tbody>
50
+ </table>
51
+ </td>
52
+ </tr>
53
+ </table>
54
+ <!--[if gte mso 9]>
55
+ </td>
56
+ </tr>
57
+ </table>
58
+ <![endif]-->
59
+ <!-- // END TEMPLATE -->
60
+ </td>
61
+ </tr>
62
+ </table>
63
+ </center>
64
+ </body>
65
+ </html>
includes/emails/templates/header-default.php ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Email Header
4
+ *
5
+ * @since 7.10.5
6
+ */
7
+
8
+ // Exit if accessed directly.
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ $header_image = monsterinsights_get_option( 'email_header_image', false );
14
+ $background_color = '#e9eaec';
15
+ $text_direction = is_rtl() ? 'rtl' : 'ltr';
16
+ ?>
17
+ <!doctype html>
18
+ <html dir="<?php echo $text_direction; ?>" xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
19
+ <head>
20
+ <!--[if gte mso 15]>
21
+ <xml>
22
+ <o:OfficeDocumentSettings>
23
+ <o:AllowPNG/>
24
+ <o:PixelsPerInch>96</o:PixelsPerInch>
25
+ </o:OfficeDocumentSettings>
26
+ </xml>
27
+ <![endif]-->
28
+ <meta charset="UTF-8">
29
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
30
+ <meta name="viewport" content="width=device-width, initial-scale=1">
31
+ <title><?php echo get_bloginfo( 'name' ); ?></title>
32
+ <style type="text/css">
33
+ p{
34
+ margin:10px 0;
35
+ padding:0;
36
+ }
37
+ table{
38
+ border-collapse:collapse;
39
+ }
40
+ h1,h2,h3,h4,h5,h6{
41
+ display:block;
42
+ margin:0;
43
+ padding:0;
44
+ }
45
+ img,a img{
46
+ border:0;
47
+ height:auto;
48
+ outline:none;
49
+ text-decoration:none;
50
+ }
51
+ body,#bodyTable,#bodyCell{
52
+ height:100%;
53
+ margin:0;
54
+ padding:0;
55
+ width:100%;
56
+ }
57
+ #outlook a{
58
+ padding:0;
59
+ }
60
+ img{
61
+ -ms-interpolation-mode:bicubic;
62
+ }
63
+ table{
64
+ mso-table-lspace:0pt;
65
+ mso-table-rspace:0pt;
66
+ }
67
+ .ReadMsgBody{
68
+ width:100%;
69
+ }
70
+ .ExternalClass{
71
+ width:100%;
72
+ }
73
+ p,a,li,td,blockquote{
74
+ mso-line-height-rule:exactly;
75
+ }
76
+ a[href^=tel],a[href^=sms]{
77
+ color:inherit;
78
+ cursor:default;
79
+ text-decoration:none;
80
+ }
81
+ p,a,li,td,body,table,blockquote{
82
+ -ms-text-size-adjust:100%;
83
+ -webkit-text-size-adjust:100%;
84
+ }
85
+ .ExternalClass,.ExternalClass p,.ExternalClass td,.ExternalClass div,.ExternalClass span,.ExternalClass font{
86
+ line-height:100%;
87
+ }
88
+ a[x-apple-data-detectors]{
89
+ color:inherit !important;
90
+ text-decoration:none !important;
91
+ font-size:inherit !important;
92
+ font-family:inherit !important;
93
+ font-weight:inherit !important;
94
+ line-height:inherit !important;
95
+ }
96
+ #bodyCell{
97
+ padding:50px 50px;
98
+ }
99
+ .templateContainer{
100
+ max-width:600px !important;
101
+ border:0;
102
+ }
103
+ a.mcnButton{
104
+ display:block;
105
+ }
106
+ .mcnTextContent{
107
+ word-break:break-word;
108
+ }
109
+ .mcnTextContent img{
110
+ height:auto !important;
111
+ }
112
+ .mcnDividerBlock{
113
+ table-layout:fixed !important;
114
+ }
115
+ /***** Make theme edits below if needed *****/
116
+ /* Page - Background Style */
117
+ body,#bodyTable{
118
+ background-color:<?php echo $background_color; ?>;
119
+ }
120
+ /* Page - Heading 1 */
121
+ h1{
122
+ color:#202020;
123
+ font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
124
+ font-size:26px;
125
+ font-style:normal;
126
+ font-weight:bold;
127
+ line-height:125%;
128
+ letter-spacing:normal;
129
+ }
130
+ /* Page - Heading 2 */
131
+ h2{
132
+ color:#202020;
133
+ font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
134
+ font-size:22px;
135
+ font-style:normal;
136
+ font-weight:bold;
137
+ line-height:125%;
138
+ letter-spacing:normal;
139
+ }
140
+ /* Page - Heading 3 */
141
+ h3{
142
+ color:#202020;
143
+ font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
144
+ font-size:20px;
145
+ font-style:normal;
146
+ font-weight:bold;
147
+ line-height:125%;
148
+ letter-spacing:normal;
149
+ }
150
+ /* Page - Heading 4 */
151
+ h4{
152
+ color:#202020;
153
+ font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
154
+ font-size:18px;
155
+ font-style:normal;
156
+ font-weight:bold;
157
+ line-height:125%;
158
+ letter-spacing:normal;
159
+ }
160
+ /* Header - Header Style */
161
+ #templateHeader{
162
+ border-top:0;
163
+ border-bottom:0;
164
+ padding-top:0;
165
+ padding-bottom:20px;
166
+ text-align: center;
167
+ }
168
+ /* Body - Body Style */
169
+ #templateBody{
170
+ background-color:#FFFFFF;
171
+ border-top:0;
172
+ border: 1px solid #c1c1c1;
173
+ padding-top:0;
174
+ padding-bottom:0px;
175
+ }
176
+ /* Body -Body Text */
177
+ #templateBody .mcnTextContent,
178
+ #templateBody .mcnTextContent p{
179
+ color:#555555;
180
+ font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
181
+ font-size:14px;
182
+ line-height:150%;
183
+ }
184
+ /* Body - Body Link */
185
+ #templateBody .mcnTextContent a,
186
+ #templateBody .mcnTextContent p a{
187
+ color:#ff7f50;
188
+ font-weight:normal;
189
+ text-decoration:underline;
190
+ }
191
+ /* Footer - Footer Style */
192
+ #templateFooter{
193
+ background-color:<?php echo $background_color; ?>;
194
+ border-top:0;
195
+ border-bottom:0;
196
+ padding-top:12px;
197
+ padding-bottom:12px;
198
+ }
199
+ /* Footer - Footer Text */
200
+ #templateFooter .mcnTextContent,
201
+ #templateFooter .mcnTextContent p{
202
+ color:#cccccc;
203
+ font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
204
+ font-size:12px;
205
+ line-height:150%;
206
+ text-align:center;
207
+ }
208
+ /* Footer - Footer Link */
209
+ #templateFooter .mcnTextContent a,
210
+ #templateFooter .mcnTextContent p a{
211
+ color:#cccccc;
212
+ font-weight:normal;
213
+ text-decoration:underline;
214
+ }
215
+ @media only screen and (min-width:768px){
216
+ .templateContainer{
217
+ width:600px !important;
218
+ }
219
+ }
220
+ @media only screen and (max-width: 480px){
221
+ body,table,td,p,a,li,blockquote{
222
+ -webkit-text-size-adjust:none !important;
223
+ }
224
+ }
225
+ @media only screen and (max-width: 480px){
226
+ body{
227
+ width:100% !important;
228
+ min-width:100% !important;
229
+ }
230
+ }
231
+ @media only screen and (max-width: 680px){
232
+ #bodyCell{
233
+ padding:20px 20px !important;
234
+ }
235
+ }
236
+ @media only screen and (max-width: 480px){
237
+ .mcnTextContentContainer{
238
+ max-width:100% !important;
239
+ width:100% !important;
240
+ }
241
+ }
242
+ </style>
243
+ </head>
244
+ <body style="height: 100%;margin: 0;padding: 0;width: 100%;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;background-color: <?php echo $background_color; ?>;">
245
+ <!-- Don't forget to run final template through http://templates.mailchimp.com/resources/inline-css/ -->
246
+ <center>
247
+ <table align="center" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" id="bodyTable" style="border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;height: 100%;margin: 0;padding: 0;width: 100%;background-color: <?php echo $background_color; ?>;">
248
+ <tr>
249
+ <td align="center" valign="top" id="bodyCell" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;height: 100%;margin: 0;padding: 50px 50px;width: 100%;">
250
+ <!-- BEGIN TEMPLATE // -->
251
+ <!--[if gte mso 9]>
252
+ <table align="center" border="0" cellspacing="0" cellpadding="0" width="600" style="width:600px;">
253
+ <tr>
254
+ <td align="center" valign="top" width="600" style="width:600px;">
255
+ <![endif]-->
256
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" class="templateContainer" style="border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;border: 0;max-width: 600px !important;">
257
+ <?php
258
+ if ( ! empty( $header_image ) ) {
259
+ echo '<tr><td valign="top" align="center" id="templateHeader" style="padding-bottom:20px;text-align:center;">';
260
+ echo '<img src="' . esc_url( $header_image ) . '" alt="' . esc_attr( get_bloginfo( 'name' ) ) . '" />';
261
+ echo '</td></tr>';
262
+ }
263
+ ?>
264
+ <tr>
265
+ <td valign="top" id="templateBody" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;background-color: #FFFFFF;border-top: 0;border: 1px solid #c1c1c1;padding-top: 0;padding-bottom: 0px;">
266
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" class="mcnTextBlock" style="min-width: 100%;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
267
+ <tbody class="mcnTextBlockOuter">
268
+ <tr>
269
+ <td valign="top" class="mcnTextBlockInner" style="mso-line-height-rule: exactly;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;">
270
+ <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" style="min-width: 100%;border-collapse: collapse;mso-table-lspace: 0pt;mso-table-rspace: 0pt;-ms-text-size-adjust: 100%;-webkit-text-size-adjust: 100%;" class="mcnTextContentContainer">
271
+ <tbody>
272
+ <tr>
273
+ <td valign="top" style="padding-top: 30px;padding-right: 30px;padding-bottom: 30px;padding-left: 30px;" class="mcnTextContent">
includes/frontend/class-tracking-abstract.php CHANGED
@@ -1,79 +1,79 @@
1
- <?php
2
- /**
3
- * Tracking abstract class.
4
- *
5
- * @since 6.0.0
6
- *
7
- * @package MonsterInsights
8
- * @author Chris Christoff
9
- */
10
-
11
- // Exit if accessed directly
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit;
14
- }
15
-
16
- class MonsterInsights_Tracking_Abstract {
17
-
18
- /**
19
- * Holds the name of the tracking type.
20
- *
21
- * @since 6.0.0
22
- * @access public
23
- *
24
- * @var string $name Name of the tracking type.
25
- */
26
- public $name = 'abstract';
27
-
28
- /**
29
- * Version of the tracking class.
30
- *
31
- * @since 6.0.0
32
- * @access public
33
- *
34
- * @var string $version Version of the tracking class.
35
- */
36
- public $version = '1.0.0';
37
-
38
- /**
39
- * Primary class constructor.
40
- *
41
- * @since 6.0.0
42
- * @access public
43
- */
44
- public function __construct() {
45
-
46
- }
47
-
48
- /**
49
- * Get frontend tracking options.
50
- *
51
- * This function is used to return an array of parameters
52
- * for the frontend_output() function to output. These are
53
- * generally dimensions and turned on GA features.
54
- *
55
- * @since 6.0.0
56
- * @access public
57
- *
58
- * @return array Array of the options to use.
59
- */
60
- public function frontend_tracking_options( ) {
61
- return array();
62
- }
63
-
64
- /**
65
- * Get frontend output.
66
- *
67
- * This function is used to return the Javascript
68
- * to output in the head of the page for the given
69
- * tracking method.
70
- *
71
- * @since 6.0.0
72
- * @access public
73
- *
74
- * @return string Javascript to output.
75
- */
76
- public function frontend_output( ) {
77
- return "<!-- MonsterInsights Abstract Tracking class -->";
78
- }
79
  }
1
+ <?php
2
+ /**
3
+ * Tracking abstract class.
4
+ *
5
+ * @since 6.0.0
6
+ *
7
+ * @package MonsterInsights
8
+ * @author Chris Christoff
9
+ */
10
+
11
+ // Exit if accessed directly
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+
16
+ class MonsterInsights_Tracking_Abstract {
17
+
18
+ /**
19
+ * Holds the name of the tracking type.
20
+ *
21
+ * @since 6.0.0
22
+ * @access public
23
+ *
24
+ * @var string $name Name of the tracking type.
25
+ */
26
+ public $name = 'abstract';
27
+
28
+ /**
29
+ * Version of the tracking class.
30
+ *
31
+ * @since 6.0.0
32
+ * @access public
33
+ *
34
+ * @var string $version Version of the tracking class.
35
+ */
36
+ public $version = '1.0.0';
37
+
38
+ /**
39
+ * Primary class constructor.
40
+ *
41
+ * @since 6.0.0
42
+ * @access public
43
+ */
44
+ public function __construct() {
45
+
46
+ }
47
+
48
+ /**
49
+ * Get frontend tracking options.
50
+ *
51
+ * This function is used to return an array of parameters
52
+ * for the frontend_output() function to output. These are
53
+ * generally dimensions and turned on GA features.
54
+ *
55
+ * @since 6.0.0
56
+ * @access public
57
+ *
58
+ * @return array Array of the options to use.
59
+ */
60
+ public function frontend_tracking_options( ) {
61
+ return array();
62
+ }
63
+
64
+ /**
65
+ * Get frontend output.
66
+ *
67
+ * This function is used to return the Javascript
68
+ * to output in the head of the page for the given
69
+ * tracking method.
70
+ *
71
+ * @since 6.0.0
72
+ * @access public
73
+ *
74
+ * @return string Javascript to output.
75
+ */
76
+ public function frontend_output( ) {
77
+ return "<!-- MonsterInsights Abstract Tracking class -->";
78
+ }
79
  }
includes/frontend/events/class-analytics-events.php CHANGED
@@ -1,116 +1,116 @@
1
- <?php
2
- /**
3
- * Events JS class.
4
- *
5
- * @since 6.0.0
6
- *
7
- * @package MonsterInsights
8
- * @subpackage Events
9
- * @author Chris Christoff
10
- */
11
-
12
- // Exit if accessed directly
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
-
17
- class MonsterInsights_Analytics_Events {
18
-
19
- /**
20
- * Holds the name of the events type.
21
- *
22
- * @since 6.0.0
23
- * @access public
24
- *
25
- * @var string $name Name of the events type.
26
- */
27
- public $name = 'js';
28
-
29
- /**
30
- * Version of the events class.
31
- *
32
- * @since 6.0.0
33
- * @access public
34
- *
35
- * @var string $version Version of the events class.
36
- */
37
- public $version = '1.0.0';
38
-
39
- /**
40
- * Primary class constructor.
41
- *
42
- * @since 6.0.0
43
- * @access public
44
- */
45
- public function __construct() {
46
- add_action( 'wp_enqueue_scripts', array( $this, 'output_javascript' ), 9 );
47
- //add_action( 'login_head', array( $this, 'output_javascript' ), 9 );
48
- }
49
-
50
- /**
51
- * Outputs the Javascript for JS tracking on the page.
52
- *
53
- * @since 6.0.0
54
- * @access public
55
- *
56
- * @return string
57
- */
58
- public function output_javascript() {
59
- // Affiliate Links
60
- $inbound_paths = monsterinsights_get_option( 'affiliate_links', array() );
61
- if ( ! is_array( $inbound_paths ) ) {
62
- $inbound_paths = array();
63
- } else {
64
- foreach( $inbound_paths as $index => $pair ) {
65
- // if empty pair, unset and continue
66
- if ( empty( $pair['path'] ) ) {
67
- unset( $inbound_paths[$index] );
68
- continue;
69
- }
70
-
71
- // if path does not start with a /, start it with that
72
- $path = ! empty( $pair['path'] ) ? $pair['path'] : 'aff';
73
- $inbound_paths[$index]['path'] = trim( $path );
74
-
75
- // js escape the link label
76
- $label = ! empty( $pair['label'] ) ? $pair['label'] : 'aff';
77
- $inbound_paths[$index]['label'] = esc_js( trim( $label ) );
78
- }
79
- }
80
-
81
- $inbound_paths = wp_json_encode( $inbound_paths );
82
-
83
- // Get download extensions to track
84
- $download_extensions = monsterinsights_get_option( 'extensions_of_files', '' );
85
- $download_extensions = explode( ',', str_replace( '.', '', $download_extensions ) );
86
- if ( ! is_array( $download_extensions ) ) {
87
- $download_extensions = array( $download_extensions );
88
- }
89
- $i = 0;
90
- foreach( $download_extensions as $extension ){
91
- $download_extensions[ $i ] = esc_js( trim( $extension ) );
92
- $i++;
93
- }
94
-
95
- $download_extensions = implode( ",", $download_extensions );
96
-
97
- $hash_tracking = monsterinsights_get_option( 'hash_tracking', false ) ? 'true' : 'false';
98
-
99
- $suffix = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
100
- if ( ! file_exists( MONSTERINSIGHTS_PLUGIN_DIR . 'assets/js/frontend.min.js' ) ) {
101
- $suffix = '';
102
- }
103
- wp_enqueue_script( 'monsterinsights-frontend-script', plugins_url( 'assets/js/frontend' . $suffix . '.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), false );
104
- wp_localize_script(
105
- 'monsterinsights-frontend-script',
106
- 'monsterinsights_frontend',
107
- array(
108
- 'js_events_tracking' => 'true',
109
- 'download_extensions' => $download_extensions, /* Let's get the extensions to track */
110
- 'inbound_paths' => $inbound_paths, /* Let's get the internal paths to track */
111
- 'home_url' => home_url(), /* Let's get the url to compare for external/internal use */
112
- 'hash_tracking' => $hash_tracking, /* Should hash track */
113
- )
114
- );
115
- }
116
  }
1
+ <?php
2
+ /**
3
+ * Events JS class.
4
+ *
5
+ * @since 6.0.0
6
+ *
7
+ * @package MonsterInsights
8
+ * @subpackage Events
9
+ * @author Chris Christoff
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ class MonsterInsights_Analytics_Events {
18
+
19
+ /**
20
+ * Holds the name of the events type.
21
+ *
22
+ * @since 6.0.0
23
+ * @access public
24
+ *
25
+ * @var string $name Name of the events type.
26
+ */
27
+ public $name = 'js';
28
+
29
+ /**
30
+ * Version of the events class.
31
+ *
32
+ * @since 6.0.0
33
+ * @access public
34
+ *
35
+ * @var string $version Version of the events class.
36
+ */
37
+ public $version = '1.0.0';
38
+
39
+ /**
40
+ * Primary class constructor.
41
+ *
42
+ * @since 6.0.0
43
+ * @access public
44
+ */
45
+ public function __construct() {
46
+ add_action( 'wp_enqueue_scripts', array( $this, 'output_javascript' ), 9 );
47
+ //add_action( 'login_head', array( $this, 'output_javascript' ), 9 );
48
+ }
49
+
50
+ /**
51
+ * Outputs the Javascript for JS tracking on the page.
52
+ *
53
+ * @since 6.0.0
54
+ * @access public
55
+ *
56
+ * @return string
57
+ */
58
+ public function output_javascript() {
59
+ // Affiliate Links
60
+ $inbound_paths = monsterinsights_get_option( 'affiliate_links', array() );
61
+ if ( ! is_array( $inbound_paths ) ) {
62
+ $inbound_paths = array();
63
+ } else {
64
+ foreach( $inbound_paths as $index => $pair ) {
65
+ // if empty pair, unset and continue
66
+ if ( empty( $pair['path'] ) ) {
67
+ unset( $inbound_paths[$index] );
68
+ continue;
69
+ }
70
+
71
+ // if path does not start with a /, start it with that
72
+ $path = ! empty( $pair['path'] ) ? $pair['path'] : 'aff';
73
+ $inbound_paths[$index]['path'] = trim( $path );
74
+
75
+ // js escape the link label
76
+ $label = ! empty( $pair['label'] ) ? $pair['label'] : 'aff';
77
+ $inbound_paths[$index]['label'] = esc_js( trim( $label ) );
78
+ }
79
+ }
80
+
81
+ $inbound_paths = wp_json_encode( $inbound_paths );
82
+
83
+ // Get download extensions to track
84
+ $download_extensions = monsterinsights_get_option( 'extensions_of_files', '' );
85
+ $download_extensions = explode( ',', str_replace( '.', '', $download_extensions ) );
86
+ if ( ! is_array( $download_extensions ) ) {
87
+ $download_extensions = array( $download_extensions );
88
+ }
89
+ $i = 0;
90
+ foreach( $download_extensions as $extension ){
91
+ $download_extensions[ $i ] = esc_js( trim( $extension ) );
92
+ $i++;
93
+ }
94
+
95
+ $download_extensions = implode( ",", $download_extensions );
96
+
97
+ $hash_tracking = monsterinsights_get_option( 'hash_tracking', false ) ? 'true' : 'false';
98
+
99
+ $suffix = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) || ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
100
+ if ( ! file_exists( MONSTERINSIGHTS_PLUGIN_DIR . 'assets/js/frontend.min.js' ) ) {
101
+ $suffix = '';
102
+ }
103
+ wp_enqueue_script( 'monsterinsights-frontend-script', plugins_url( 'assets/js/frontend' . $suffix . '.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), false );
104
+ wp_localize_script(
105
+ 'monsterinsights-frontend-script',
106
+ 'monsterinsights_frontend',
107
+ array(
108
+ 'js_events_tracking' => 'true',
109
+ 'download_extensions' => $download_extensions, /* Let's get the extensions to track */
110
+ 'inbound_paths' => $inbound_paths, /* Let's get the internal paths to track */
111
+ 'home_url' => home_url(), /* Let's get the url to compare for external/internal use */
112
+ 'hash_tracking' => $hash_tracking, /* Should hash track */
113
+ )
114
+ );
115
+ }
116
  }
includes/frontend/events/index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- //Nothing to see here
3
-
4
  header( 'HTTP/1.0 403 Forbidden' );
1
+ <?php
2
+ //Nothing to see here
3
+
4
  header( 'HTTP/1.0 403 Forbidden' );
includes/frontend/frontend.php CHANGED
@@ -1,383 +1,400 @@
1
- <?php
2
- /**
3
- * Frontend events tracking.
4
- *
5
- * @since 6.0.0
6
- *
7
- * @package MonsterInsights
8
- * @author Chris Christoff
9
- */
10
-
11
- // Exit if accessed directly
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit;
14
- }
15
-
16
-
17
- /**
18
- * Get frontend tracking options.
19
- *
20
- * This function is used to return an array of parameters
21
- * for the frontend_output() function to output. These are
22
- * generally dimensions and turned on GA features.
23
- *
24
- * @since 7.0.0
25
- * @access public
26
- *
27
- * @return array Array of the options to use.
28
- */
29
- function monsterinsights_tracking_script( ) {
30
- require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/class-tracking-abstract.php';
31
-
32
- $mode = is_preview() ? 'preview' : 'analytics';
33
-
34
- do_action( 'monsterinsights_tracking_before_' . $mode );
35
- do_action( 'monsterinsights_tracking_before', $mode );
36
- if ( $mode === 'preview' ) {
37
- require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-preview.php';
38
- $tracking = new MonsterInsights_Tracking_Preview();
39
- echo $tracking->frontend_output();
40
- } else {
41
- require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-analytics.php';
42
- $tracking = new MonsterInsights_Tracking_Analytics();
43
- echo $tracking->frontend_output();
44
- }
45
-
46
- do_action( 'monsterinsights_tracking_after_' . $mode );
47
- do_action( 'monsterinsights_tracking_after', $mode );
48
- }
49
- add_action( 'wp_head', 'monsterinsights_tracking_script', 6 );
50
- //add_action( 'login_head', 'monsterinsights_tracking_script', 6 );
51
-
52
- /**
53
- * Get frontend tracking options.
54
- *
55
- * This function is used to return an array of parameters
56
- * for the frontend_output() function to output. These are
57
- * generally dimensions and turned on GA features.
58
- *
59
- * @since 6.0.0
60
- * @access public
61
- *
62
- * @return array Array of the options to use.
63
- */
64
- function monsterinsights_events_tracking( ) {
65
- $track_user = monsterinsights_track_user();
66
-
67
- if ( $track_user ) {
68
- require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-analytics-events.php';
69
- new MonsterInsights_Analytics_Events();
70
- } else {
71
- // User is in the disabled group or events mode is off
72
- }
73
- }
74
- add_action( 'template_redirect', 'monsterinsights_events_tracking', 9 );
75
-
76
- /**
77
- * Add the UTM source parameters in the RSS feeds to track traffic.
78
- *
79
- * @since 6.0.0
80
- * @access public
81
- *
82
- * @param string $guid The link for the RSS feed.
83
- *
84
- * @return string The new link for the RSS feed.
85
- */
86
- function monsterinsights_rss_link_tagger( $guid ) {
87
- global $post;
88
-
89
- if ( monsterinsights_get_option( 'tag_links_in_rss', false ) ){
90
- if ( is_feed() ) {
91
- if ( monsterinsights_get_option( 'allow_anchor', false ) ) {
92
- $delimiter = '#';
93
- } else {
94
- $delimiter = '?';
95
- if ( strpos( $guid, $delimiter ) > 0 ) {
96
- $delimiter = '&amp;';
97
- }
98
- }
99
- return $guid . $delimiter . 'utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=' . urlencode( $post->post_name );
100
- }
101
- }
102
- return $guid;
103
- }
104
- add_filter( 'the_permalink_rss', 'monsterinsights_rss_link_tagger', 99 );
105
-
106
-
107
- /**
108
- * Checks used for loading the frontend scripts/admin bar button.
109
- */
110
- function monsterinsights_prevent_loading_frontend_reports() {
111
- return ! current_user_can( 'monsterinsights_view_dashboard' ) || monsterinsights_get_option( 'hide_admin_bar_reports' ) || function_exists( 'monsterinsights_is_reports_page' ) && monsterinsights_is_reports_page();
112
- }
113
-
114
- /**
115
- * Add an admin bar menu item on the frontend.
116
- *
117
- * @since 7.5.0
118
- *
119
- * @return void
120
- */
121
- function monsterinsights_add_admin_bar_menu() {
122
- if ( monsterinsights_prevent_loading_frontend_reports() ) {
123
- return;
124
- }
125
-
126
- global $wp_admin_bar;
127
-
128
- $args = array(
129
- 'id' => 'monsterinsights_frontend_button',
130
- 'title' => '<span class="ab-icon dashicons-before dashicons-chart-bar"></span> Insights', // Maybe allow translation?
131
- 'href' => '#',
132
- );
133
-
134
- if ( method_exists( $wp_admin_bar, 'add_menu' ) ) {
135
- $wp_admin_bar->add_menu( $args );
136
- }
137
- }
138
-
139
- add_action( 'admin_bar_menu', 'monsterinsights_add_admin_bar_menu', 999 );
140
-
141
- /**
142
- * Load the scripts needed for the admin bar.
143
- *
144
- * @since 7.5.0
145
- *
146
- * @return void
147
- */
148
- function monsterinsights_frontend_admin_bar_scripts() {
149
- if ( monsterinsights_prevent_loading_frontend_reports() ) {
150
- return;
151
- }
152
-
153
- $version_path = monsterinsights_is_pro_version() ? 'pro' : 'lite';
154
- $rtl = is_rtl() ? '.rtl' : '';
155
- $frontend_js_url = defined( 'MONSTERINSIGHTS_LOCAL_FRONTEND_JS_URL' ) && MONSTERINSIGHTS_LOCAL_FRONTEND_JS_URL ? MONSTERINSIGHTS_LOCAL_FRONTEND_JS_URL : plugins_url( $version_path . '/assets/vue/js/frontend.js', MONSTERINSIGHTS_PLUGIN_FILE );
156
-
157
- if ( ! defined( 'MONSTERINSIGHTS_LOCAL_FRONTEND_JS_URL' ) ) {
158
- wp_enqueue_style( 'monsterinsights-vue-frontend-style', plugins_url( $version_path . '/assets/vue/css/frontend' . $rtl . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
159
- wp_enqueue_script( 'monsterinsights-vue-vendors', plugins_url( $version_path . '/assets/vue/js/chunk-frontend-vendors.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true );
160
- wp_enqueue_script( 'monsterinsights-vue-common', plugins_url( $version_path . '/assets/vue/js/chunk-common.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true );
161
- } else {
162
- wp_enqueue_script( 'monsterinsights-vue-vendors', MONSTERINSIGHTS_LOCAL_VENDORS_JS_URL, array(), monsterinsights_get_asset_version(), true );
163
- wp_enqueue_script( 'monsterinsights-vue-common', MONSTERINSIGHTS_LOCAL_COMMON_JS_URL, array(), monsterinsights_get_asset_version(), true );
164
- }
165
-
166
- wp_register_script( 'monsterinsights-vue-frontend', $frontend_js_url, array(), monsterinsights_get_asset_version(), true );
167
- wp_enqueue_script( 'monsterinsights-vue-frontend' );
168
-
169
- $page_title = is_singular() ? get_the_title() : monsterinsights_get_page_title();
170
- // We do not have a current auth.
171
- $site_auth = MonsterInsights()->auth->get_viewname();
172
- $ms_auth = is_multisite() && MonsterInsights()->auth->get_network_viewname();
173
-
174
- // Check if any of the other admin scripts are enqueued, if so, use their object.
175
- if ( ! wp_script_is( 'monsterinsights-vue-script' ) && ! wp_script_is( 'monsterinsights-vue-reports' ) && ! wp_script_is( 'monsterinsights-vue-widget' ) ) {
176
- wp_localize_script(
177
- 'monsterinsights-vue-frontend',
178
- 'monsterinsights',
179
- array(
180
- 'ajax' => admin_url( 'admin-ajax.php' ),
181
- 'nonce' => wp_create_nonce( 'mi-admin-nonce' ),
182
- 'network' => is_network_admin(),
183
- 'translations' => wp_get_jed_locale_data( monsterinsights_is_pro_version() ? 'ga-premium' : 'google-analytics-for-wordpress' ),
184
- 'assets' => plugins_url( $version_path . '/assets/vue', MONSTERINSIGHTS_PLUGIN_FILE ),
185
- 'addons_url' => is_multisite() ? network_admin_url( 'admin.php?page=monsterinsights_network#/addons' ) : admin_url( 'admin.php?page=monsterinsights_settings#/addons' ),
186
- 'page_id' => is_singular() ? get_the_ID() : false,
187
- 'page_title' => $page_title,
188
- 'plugin_version' => MONSTERINSIGHTS_VERSION,
189
- 'shareasale_id' => monsterinsights_get_shareasale_id(),
190
- 'shareasale_url' => monsterinsights_get_shareasale_url( monsterinsights_get_shareasale_id(), '' ),
191
- 'is_admin' => is_admin(),
192
- 'reports_url' => add_query_arg( 'page', 'monsterinsights_reports', admin_url( 'admin.php' ) ),
193
- 'authed' => $site_auth || $ms_auth,
194
- 'getting_started_url' => is_multisite() ? network_admin_url( 'admin.php?page=monsterinsights_network#/about/getting-started' ) : admin_url( 'admin.php?page=monsterinsights_settings#/about/getting-started' ),
195
- 'wizard_url' => admin_url( 'index.php?page=monsterinsights-onboarding' ),
196
- )
197
- );
198
- }
199
- }
200
-
201
- add_action( 'wp_enqueue_scripts', 'monsterinsights_frontend_admin_bar_scripts' );
202
- add_action( 'admin_enqueue_scripts', 'monsterinsights_frontend_admin_bar_scripts', 1005 );
203
-
204
-
205
- /**
206
- * Load the tracking notice for logged in users.
207
- */
208
- function monsterinsights_administrator_tracking_notice() {
209
- // Don't do anything for guests.
210
- if ( ! is_user_logged_in() ) {
211
- return;
212
- }
213
-
214
- // Only show this to users who are not tracked.
215
- if ( monsterinsights_track_user() ) {
216
- return;
217
- }
218
-
219
- // Only show when tracking.
220
- $ua = monsterinsights_get_ua();
221
- if ( empty( $ua ) ) {
222
- return;
223
- }
224
-
225
- // Don't show if already dismissed.
226
- if ( get_option( 'monsterinsights_frontend_tracking_notice_viewed', false ) ) {
227
- return;
228
- }
229
-
230
- ?>
231
- <div class="monsterinsights-tracking-notice monsterinsights-tracking-notice-hide">
232
- <div class="monsterinsights-tracking-notice-icon">
233
- <img src="<?php echo esc_url( plugins_url( 'assets/images/mascot.png', MONSTERINSIGHTS_PLUGIN_FILE ) ); ?>" width="40" alt="MonsterInsights Mascot" />
234
- </div>
235
- <div class="monsterinsights-tracking-notice-text">
236
- <h3><?php esc_html_e( 'Tracking is Disabled for Administrators', 'ga-premium' ); ?></h3>
237
- <p>
238
- <?php
239
- $doc_url = 'https://monsterinsights.com/docs/tracking-disabled-administrators-editors';
240
- $doc_url = add_query_arg( array(
241
- 'utm_source' => monsterinsights_is_pro_version() ? 'proplugin' : 'liteplugin',
242
- 'utm_medium' => 'frontend-notice',
243
- 'utm_campaign' => 'admin-tracking-doc',
244
- ), $doc_url );
245
- // Translators: %s is the link to the article where more details about tracking are listed.
246
- printf( esc_html__( 'To keep stats accurate, we do not load Google Analytics scripts for admin users. %1$sLearn More &raquo;%2$s', 'ga-premium' ), '<a href="' . esc_url( $doc_url ) . '" target="_blank">', '</a>' );
247
- ?>
248
- </p>
249
- </div>
250
- <div class="monsterinsights-tracking-notice-close">&times;</div>
251
- </div>
252
- <style type="text/css">
253
- .monsterinsights-tracking-notice {
254
- position: fixed;
255
- bottom: 20px;
256
- right: 15px;
257
- font-family: Arial, Helvetica, "Trebuchet MS", sans-serif;
258
- background: #fff;
259
- box-shadow: 0 0 10px 0 #dedede;
260
- padding: 6px 5px;
261
- display: flex;
262
- align-items: center;
263
- justify-content: center;
264
- width: 380px;
265
- max-width: calc( 100% - 30px );
266
- border-radius: 6px;
267
- transition: bottom 700ms ease;
268
- z-index: 10000;
269
- }
270
-
271
- .monsterinsights-tracking-notice h3 {
272
- font-size: 13px;
273
- color: #222;
274
- font-weight: 700;
275
- margin: 0 0 8px;
276
- padding: 0;
277
- line-height: 1;
278
- border: none;
279
- }
280
-
281
- .monsterinsights-tracking-notice p {
282
- font-size: 13px;
283
- color: #7f7f7f;
284
- font-weight: 400;
285
- margin: 0;
286
- padding: 0;
287
- line-height: 1.2;
288
- border: none;
289
- }
290
-
291
- .monsterinsights-tracking-notice p a {
292
- color: #7f7f7f;
293
- font-size: 13px;
294
- line-height: 1.2;
295
- margin: 0;
296
- padding: 0;
297
- text-decoration: underline;
298
- font-weight: 400;
299
- }
300
-
301
- .monsterinsights-tracking-notice p a:hover {
302
- color: #7f7f7f;
303
- text-decoration: none;
304
- }
305
-
306
- .monsterinsights-tracking-notice-icon img {
307
- height: auto;
308
- display: block;
309
- margin: 0;
310
- }
311
-
312
- .monsterinsights-tracking-notice-icon {
313
- padding: 14px;
314
- background-color: #f2f6ff;
315
- border-radius: 6px;
316
- flex-grow: 0;
317
- flex-shrink: 0;
318
- margin-right: 12px;
319
- }
320
-
321
- .monsterinsights-tracking-notice-close {
322
- padding: 0;
323
- margin: 0 3px 0 0;
324
- border: none;
325
- box-shadow: none;
326
- border-radius: 0;
327
- color: #7f7f7f;
328
- background: transparent;
329
- line-height: 1;
330
- align-self: flex-start;
331
- cursor: pointer;
332
- font-weight: 400;
333
- }
334
-
335
- .monsterinsights-tracking-notice.monsterinsights-tracking-notice-hide {
336
- bottom: -200px;
337
- }
338
- </style>
339
- <?php
340
-
341
- if ( ! wp_script_is( 'jquery', 'queue' ) ) {
342
- wp_enqueue_script( 'jquery' );
343
- }
344
- ?>
345
- <script>
346
- if ( 'undefined' !== typeof jQuery ) {
347
- jQuery( document ).ready( function ( $ ) {
348
- /* Don't show the notice if we don't have a way to hide it (no js, no jQuery). */
349
- $( document.querySelector( '.monsterinsights-tracking-notice' ) ).removeClass( 'monsterinsights-tracking-notice-hide' );
350
- $( document.querySelector( '.monsterinsights-tracking-notice-close' ) ).on( 'click', function ( e ) {
351
- e.preventDefault();
352
- $( this ).closest( '.monsterinsights-tracking-notice' ).addClass( 'monsterinsights-tracking-notice-hide' );
353
- $.ajax( {
354
- url: '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>',
355
- method: 'POST',
356
- data: {
357
- action: 'monsterinsights_dismiss_tracking_notice',
358
- nonce: '<?php echo esc_js( wp_create_nonce( 'monsterinsights-tracking-notice' ) ); ?>',
359
- }
360
- } );
361
- } );
362
- } );
363
- }
364
- </script>
365
- <?php
366
- }
367
-
368
- add_action( 'wp_footer', 'monsterinsights_administrator_tracking_notice', 300 );
369
-
370
- /**
371
- * Ajax handler to hide the tracking notice.
372
- */
373
- function monsterinsights_dismiss_tracking_notice() {
374
-
375
- check_ajax_referer( 'monsterinsights-tracking-notice', 'nonce' );
376
-
377
- update_option( 'monsterinsights_frontend_tracking_notice_viewed', 1 );
378
-
379
- wp_die();
380
-
381
- }
382
-
383
- add_action( 'wp_ajax_monsterinsights_dismiss_tracking_notice', 'monsterinsights_dismiss_tracking_notice' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Frontend events tracking.
4
+ *
5
+ * @since 6.0.0
6
+ *
7
+ * @package MonsterInsights
8
+ * @author Chris Christoff
9
+ */
10
+
11
+ // Exit if accessed directly
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+
16
+
17
+ /**
18
+ * Get frontend tracking options.
19
+ *
20
+ * This function is used to return an array of parameters
21
+ * for the frontend_output() function to output. These are
22
+ * generally dimensions and turned on GA features.
23
+ *
24
+ * @since 7.0.0
25
+ * @access public
26
+ *
27
+ * @return array Array of the options to use.
28
+ */
29
+ function monsterinsights_tracking_script( ) {
30
+ require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/class-tracking-abstract.php';
31
+
32
+ $mode = is_preview() ? 'preview' : 'analytics';
33
+
34
+ do_action( 'monsterinsights_tracking_before_' . $mode );
35
+ do_action( 'monsterinsights_tracking_before', $mode );
36
+ if ( $mode === 'preview' ) {
37
+ require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-preview.php';
38
+ $tracking = new MonsterInsights_Tracking_Preview();
39
+ echo $tracking->frontend_output();
40
+ } else {
41
+ require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-analytics.php';
42
+ $tracking = new MonsterInsights_Tracking_Analytics();
43
+ echo $tracking->frontend_output();
44
+ }
45
+
46
+ do_action( 'monsterinsights_tracking_after_' . $mode );
47
+ do_action( 'monsterinsights_tracking_after', $mode );
48
+ }
49
+ add_action( 'wp_head', 'monsterinsights_tracking_script', 6 );
50
+ //add_action( 'login_head', 'monsterinsights_tracking_script', 6 );
51
+
52
+ /**
53
+ * Get frontend tracking options.
54
+ *
55
+ * This function is used to return an array of parameters
56
+ * for the frontend_output() function to output. These are
57
+ * generally dimensions and turned on GA features.
58
+ *
59
+ * @since 6.0.0
60
+ * @access public
61
+ *
62
+ * @return array Array of the options to use.
63
+ */
64
+ function monsterinsights_events_tracking( ) {
65
+ $track_user = monsterinsights_track_user();
66
+
67
+ if ( $track_user ) {
68
+ require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-analytics-events.php';
69
+ new MonsterInsights_Analytics_Events();
70
+ } else {
71
+ // User is in the disabled group or events mode is off
72
+ }
73
+ }
74
+ add_action( 'template_redirect', 'monsterinsights_events_tracking', 9 );
75
+
76
+ /**
77
+ * Add the UTM source parameters in the RSS feeds to track traffic.
78
+ *
79
+ * @since 6.0.0
80
+ * @access public
81
+ *
82
+ * @param string $guid The link for the RSS feed.
83
+ *
84
+ * @return string The new link for the RSS feed.
85
+ */
86
+ function monsterinsights_rss_link_tagger( $guid ) {
87
+ global $post;
88
+
89
+ if ( monsterinsights_get_option( 'tag_links_in_rss', false ) ){
90
+ if ( is_feed() ) {
91
+ if ( monsterinsights_get_option( 'allow_anchor', false ) ) {
92
+ $delimiter = '#';
93
+ } else {
94
+ $delimiter = '?';
95
+ if ( strpos( $guid, $delimiter ) > 0 ) {
96
+ $delimiter = '&amp;';
97
+ }
98
+ }
99
+ return $guid . $delimiter . 'utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=' . urlencode( $post->post_name );
100
+ }
101
+ }
102
+ return $guid;
103
+ }
104
+ add_filter( 'the_permalink_rss', 'monsterinsights_rss_link_tagger', 99 );
105
+
106
+
107
+ /**
108
+ * Checks used for loading the frontend scripts/admin bar button.
109
+ */
110
+ function monsterinsights_prevent_loading_frontend_reports() {
111
+ return ! current_user_can( 'monsterinsights_view_dashboard' ) || monsterinsights_get_option( 'hide_admin_bar_reports' ) || function_exists( 'monsterinsights_is_reports_page' ) && monsterinsights_is_reports_page() || function_exists( 'monsterinsights_is_settings_page' ) && monsterinsights_is_settings_page();
112
+ }
113
+
114
+ /**
115
+ * Add an admin bar menu item on the frontend.
116
+ *
117
+ * @since 7.5.0
118
+ *
119
+ * @return void
120
+ */
121
+ function monsterinsights_add_admin_bar_menu() {
122
+ if ( monsterinsights_prevent_loading_frontend_reports() ) {
123
+ return;
124
+ }
125
+
126
+ global $wp_admin_bar;
127
+
128
+ $args = array(
129
+ 'id' => 'monsterinsights_frontend_button',
130
+ 'title' => '<span class="ab-icon dashicons-before dashicons-chart-bar"></span> Insights', // Maybe allow translation?
131
+ 'href' => '#',
132
+ );
133
+
134
+ if ( method_exists( $wp_admin_bar, 'add_menu' ) ) {
135
+ $wp_admin_bar->add_menu( $args );
136
+ }
137
+ }
138
+
139
+ add_action( 'admin_bar_menu', 'monsterinsights_add_admin_bar_menu', 999 );
140
+
141
+ /**
142
+ * Load the scripts needed for the admin bar.
143
+ *
144
+ * @since 7.5.0
145
+ *
146
+ * @return void
147
+ */
148
+ function monsterinsights_frontend_admin_bar_scripts() {
149
+ if ( monsterinsights_prevent_loading_frontend_reports() ) {
150
+ return;
151
+ }
152
+
153
+ $version_path = monsterinsights_is_pro_version() ? 'pro' : 'lite';
154
+ $rtl = is_rtl() ? '.rtl' : '';
155
+ $frontend_js_url = defined( 'MONSTERINSIGHTS_LOCAL_FRONTEND_JS_URL' ) && MONSTERINSIGHTS_LOCAL_FRONTEND_JS_URL ? MONSTERINSIGHTS_LOCAL_FRONTEND_JS_URL : plugins_url( $version_path . '/assets/vue/js/frontend.js', MONSTERINSIGHTS_PLUGIN_FILE );
156
+
157
+ if ( ! defined( 'MONSTERINSIGHTS_LOCAL_FRONTEND_JS_URL' ) ) {
158
+ wp_enqueue_style( 'monsterinsights-vue-frontend-style', plugins_url( $version_path . '/assets/vue/css/frontend' . $rtl . '.css', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version() );
159
+ wp_enqueue_script( 'monsterinsights-vue-vendors', plugins_url( $version_path . '/assets/vue/js/chunk-frontend-vendors.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true );
160
+ wp_enqueue_script( 'monsterinsights-vue-common', plugins_url( $version_path . '/assets/vue/js/chunk-common.js', MONSTERINSIGHTS_PLUGIN_FILE ), array(), monsterinsights_get_asset_version(), true );
161
+ } else {
162
+ wp_enqueue_script( 'monsterinsights-vue-vendors', MONSTERINSIGHTS_LOCAL_VENDORS_JS_URL, array(), monsterinsights_get_asset_version(), true );
163
+ wp_enqueue_script( 'monsterinsights-vue-common', MONSTERINSIGHTS_LOCAL_COMMON_JS_URL, array(), monsterinsights_get_asset_version(), true );
164
+ }
165
+
166
+ wp_register_script( 'monsterinsights-vue-frontend', $frontend_js_url, array(), monsterinsights_get_asset_version(), true );
167
+ wp_enqueue_script( 'monsterinsights-vue-frontend' );
168
+
169
+ $page_title = is_singular() ? get_the_title() : monsterinsights_get_page_title();
170
+ // We do not have a current auth.
171
+ $site_auth = MonsterInsights()->auth->get_viewname();
172
+ $ms_auth = is_multisite() && MonsterInsights()->auth->get_network_viewname();
173
+
174
+ // Check if any of the other admin scripts are enqueued, if so, use their object.
175
+ if ( ! wp_script_is( 'monsterinsights-vue-script' ) && ! wp_script_is( 'monsterinsights-vue-reports' ) && ! wp_script_is( 'monsterinsights-vue-widget' ) ) {
176
+ $reports_url = is_network_admin() ? add_query_arg( 'page', 'monsterinsights_reports', network_admin_url( 'admin.php' ) ) : add_query_arg( 'page', 'monsterinsights_reports', admin_url( 'admin.php' ) );
177
+ wp_localize_script(
178
+ 'monsterinsights-vue-frontend',
179
+ 'monsterinsights',
180
+ array(
181
+ 'ajax' => admin_url( 'admin-ajax.php' ),
182
+ 'nonce' => wp_create_nonce( 'mi-admin-nonce' ),
183
+ 'network' => is_network_admin(),
184
+ 'translations' => wp_get_jed_locale_data( monsterinsights_is_pro_version() ? 'ga-premium' : 'google-analytics-for-wordpress' ),
185
+ 'assets' => plugins_url( $version_path . '/assets/vue', MONSTERINSIGHTS_PLUGIN_FILE ),
186
+ 'addons_url' => is_multisite() ? network_admin_url( 'admin.php?page=monsterinsights_network#/addons' ) : admin_url( 'admin.php?page=monsterinsights_settings#/addons' ),
187
+ 'page_id' => is_singular() ? get_the_ID() : false,
188
+ 'page_title' => $page_title,
189
+ 'plugin_version' => MONSTERINSIGHTS_VERSION,
190
+ 'shareasale_id' => monsterinsights_get_shareasale_id(),
191
+ 'shareasale_url' => monsterinsights_get_shareasale_url( monsterinsights_get_shareasale_id(), '' ),
192
+ 'is_admin' => is_admin(),
193
+ 'reports_url' => $reports_url,
194
+ 'authed' => $site_auth || $ms_auth,
195
+ 'getting_started_url' => is_multisite() ? network_admin_url( 'admin.php?page=monsterinsights_network#/about/getting-started' ) : admin_url( 'admin.php?page=monsterinsights_settings#/about/getting-started' ),
196
+ 'wizard_url' => is_network_admin() ? network_admin_url( 'index.php?page=monsterinsights-onboarding' ) : admin_url( 'index.php?page=monsterinsights-onboarding' ),
197
+ )
198
+ );
199
+ }
200
+ }
201
+
202
+ add_action( 'wp_enqueue_scripts', 'monsterinsights_frontend_admin_bar_scripts' );
203
+ add_action( 'admin_enqueue_scripts', 'monsterinsights_frontend_admin_bar_scripts', 1005 );
204
+
205
+
206
+ /**
207
+ * Load the tracking notice for logged in users.
208
+ */
209
+ function monsterinsights_administrator_tracking_notice() {
210
+ // Don't do anything for guests.
211
+ if ( ! is_user_logged_in() ) {
212
+ return;
213
+ }
214
+
215
+ // Only show this to users who are not tracked.
216
+ if ( monsterinsights_track_user() ) {
217
+ return;
218
+ }
219
+
220
+ // Only show when tracking.
221
+ $ua = monsterinsights_get_ua();
222
+ if ( empty( $ua ) ) {
223
+ return;
224
+ }
225
+
226
+ // Don't show if already dismissed.
227
+ if ( get_option( 'monsterinsights_frontend_tracking_notice_viewed', false ) ) {
228
+ return;
229
+ }
230
+
231
+ // Automatically dismiss when loaded.
232
+ update_option( 'monsterinsights_frontend_tracking_notice_viewed', 1 );
233
+
234
+ ?>
235
+ <div class="monsterinsights-tracking-notice monsterinsights-tracking-notice-hide">
236
+ <div class="monsterinsights-tracking-notice-icon">
237
+ <img src="<?php echo esc_url( plugins_url( 'assets/images/mascot.png', MONSTERINSIGHTS_PLUGIN_FILE ) ); ?>" width="40" alt="MonsterInsights Mascot" />
238
+ </div>
239
+ <div class="monsterinsights-tracking-notice-text">
240
+ <h3><?php esc_html_e( 'Tracking is Disabled for Administrators', 'ga-premium' ); ?></h3>
241
+ <p>
242
+ <?php
243
+ $doc_url = 'https://monsterinsights.com/docs/tracking-disabled-administrators-editors';
244
+ $doc_url = add_query_arg( array(
245
+ 'utm_source' => monsterinsights_is_pro_version() ? 'proplugin' : 'liteplugin',
246
+ 'utm_medium' => 'frontend-notice',
247
+ 'utm_campaign' => 'admin-tracking-doc',
248
+ ), $doc_url );
249
+ // Translators: %s is the link to the article where more details about tracking are listed.
250
+ printf( esc_html__( 'To keep stats accurate, we do not load Google Analytics scripts for admin users. %1$sLearn More &raquo;%2$s', 'ga-premium' ), '<a href="' . esc_url( $doc_url ) . '" target="_blank">', '</a>' );
251
+ ?>
252
+ </p>
253
+ </div>
254
+ <div class="monsterinsights-tracking-notice-close">&times;</div>
255
+ </div>
256
+ <style type="text/css">
257
+ .monsterinsights-tracking-notice {
258
+ position: fixed;
259
+ bottom: 20px;
260
+ right: 15px;
261
+ font-family: Arial, Helvetica, "Trebuchet MS", sans-serif;
262
+ background: #fff;
263
+ box-shadow: 0 0 10px 0 #dedede;
264
+ padding: 6px 5px;
265
+ display: flex;
266
+ align-items: center;
267
+ justify-content: center;
268
+ width: 380px;
269
+ max-width: calc( 100% - 30px );
270
+ border-radius: 6px;
271
+ transition: bottom 700ms ease;
272
+ z-index: 10000;
273
+ }
274
+
275
+ .monsterinsights-tracking-notice h3 {
276
+ font-size: 13px;
277
+ color: #222;
278
+ font-weight: 700;
279
+ margin: 0 0 8px;
280
+ padding: 0;
281
+ line-height: 1;
282
+ border: none;
283
+ }
284
+
285
+ .monsterinsights-tracking-notice p {
286
+ font-size: 13px;
287
+ color: #7f7f7f;
288
+ font-weight: 400;
289
+ margin: 0;
290
+ padding: 0;
291
+ line-height: 1.2;
292
+ border: none;
293
+ }
294
+
295
+ .monsterinsights-tracking-notice p a {
296
+ color: #7f7f7f;
297
+ font-size: 13px;
298
+ line-height: 1.2;
299
+ margin: 0;
300
+ padding: 0;
301
+ text-decoration: underline;
302
+ font-weight: 400;
303
+ }
304
+
305
+ .monsterinsights-tracking-notice p a:hover {
306
+ color: #7f7f7f;
307
+ text-decoration: none;
308
+ }
309
+
310
+ .monsterinsights-tracking-notice-icon img {
311
+ height: auto;
312
+ display: block;
313
+ margin: 0;
314
+ }
315
+
316
+ .monsterinsights-tracking-notice-icon {
317
+ padding: 14px;
318
+ background-color: #f2f6ff;
319
+ border-radius: 6px;
320
+ flex-grow: 0;
321
+ flex-shrink: 0;
322
+ margin-right: 12px;
323
+ }
324
+
325
+ .monsterinsights-tracking-notice-close {
326
+ padding: 0;
327
+ margin: 0 3px 0 0;
328
+ border: none;
329
+ box-shadow: none;
330
+ border-radius: 0;
331
+ color: #7f7f7f;
332
+ background: transparent;
333
+ line-height: 1;
334
+ align-self: flex-start;
335
+ cursor: pointer;
336
+ font-weight: 400;
337
+ }
338
+
339
+ .monsterinsights-tracking-notice.monsterinsights-tracking-notice-hide {
340
+ bottom: -200px;
341
+ }
342
+ </style>
343
+ <?php
344
+
345
+ if ( ! wp_script_is( 'jquery', 'queue' ) ) {
346
+ wp_enqueue_script( 'jquery' );
347
+ }
348
+ ?>
349
+ <script>
350
+ if ( 'undefined' !== typeof jQuery ) {
351
+ jQuery( document ).ready( function ( $ ) {
352
+ /* Don't show the notice if we don't have a way to hide it (no js, no jQuery). */
353
+ $( document.querySelector( '.monsterinsights-tracking-notice' ) ).removeClass( 'monsterinsights-tracking-notice-hide' );
354
+ $( document.querySelector( '.monsterinsights-tracking-notice-close' ) ).on( 'click', function ( e ) {
355
+ e.preventDefault();
356
+ $( this ).closest( '.monsterinsights-tracking-notice' ).addClass( 'monsterinsights-tracking-notice-hide' );
357
+ $.ajax( {
358
+ url: '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>',
359
+ method: 'POST',
360
+ data: {
361
+ action: 'monsterinsights_dismiss_tracking_notice',
362
+ nonce: '<?php echo esc_js( wp_create_nonce( 'monsterinsights-tracking-notice' ) ); ?>',
363
+ }
364
+ } );
365
+ } );
366
+ } );
367
+ }
368
+ </script>
369
+ <?php
370
+ }
371
+
372
+ add_action( 'wp_footer', 'monsterinsights_administrator_tracking_notice', 300 );
373
+
374
+ /**
375
+ * Ajax handler to hide the tracking notice.
376
+ */
377
+ function monsterinsights_dismiss_tracking_notice() {
378
+
379
+ check_ajax_referer( 'monsterinsights-tracking-notice', 'nonce' );
380
+
381
+ update_option( 'monsterinsights_frontend_tracking_notice_viewed', 1 );
382
+
383
+ wp_die();
384
+
385
+ }
386
+
387
+ add_action( 'wp_ajax_monsterinsights_dismiss_tracking_notice', 'monsterinsights_dismiss_tracking_notice' );
388
+
389
+ /**
390
+ * If the legacy shortcodes are not registered, make sure they don't output.
391
+ */
392
+ function monsterinsights_maybe_handle_legacy_shortcodes() {
393
+
394
+ if ( ! shortcode_exists( 'gadwp_useroptout' ) ) {
395
+ add_shortcode( 'gadwp_useroptout', '__return_empty_string' );
396
+ }
397
+
398
+ }
399
+
400
+ add_action( 'init', 'monsterinsights_maybe_handle_legacy_shortcodes', 1000 );
includes/frontend/index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- //Nothing to see here
3
-
4
  header( 'HTTP/1.0 403 Forbidden' );
1
+ <?php
2
+ //Nothing to see here
3
+
4
  header( 'HTTP/1.0 403 Forbidden' );
includes/frontend/seedprod.php CHANGED
@@ -1,45 +1,45 @@
1
- <?php
2
- /**
3
- * SeedProd Tracking for 404 and Coming Soon.
4
- *
5
- * @since 7.3.0
6
- *
7
- * @package MonsterInsights
8
- * @author Chris Christoff
9
- */
10
-
11
- // Exit if accessed directly
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit;
14
- }
15
-
16
- // 1. Disable SeedProd settings (done in seedprod)
17
- // 2. Output tracking code, if settings is not set to use wp_head() (done in seedprod and below)
18
- // 3. Disable ga_tracking in their setting (done in seedprod)
19
- function monsterinsights_seedprod_tracking( $settings ) {
20
- require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/class-tracking-abstract.php';
21
-
22
-
23
- do_action( 'monsterinsights_tracking_before_analytics' );
24
- do_action( 'monsterinsights_tracking_before', 'analytics' );
25
-
26
- require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-analytics.php';
27
- $tracking = new MonsterInsights_Tracking_Analytics();
28
- echo $tracking->frontend_output();
29
-
30
- do_action( 'monsterinsights_tracking_after_analytics' );
31
- do_action( 'monsterinsights_tracking_after', 'analytics' );
32
-
33
- $track_user = monsterinsights_track_user();
34
-
35
- if ( $track_user ) {
36
- require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-analytics-events.php';
37
- new MonsterInsights_Analytics_Events();
38
-
39
- // Let's run form tracking if we find it
40
- if ( function_exists( 'monsterinsights_forms_output_after_script' ) ) {
41
- monsterinsights_forms_output_after_script( array() );
42
- }
43
- }
44
- }
45
  add_action( 'seedprod_monsterinsights_output_tracking', 'monsterinsights_seedprod_tracking', 6, 1 );
1
+ <?php
2
+ /**
3
+ * SeedProd Tracking for 404 and Coming Soon.
4
+ *
5
+ * @since 7.3.0
6
+ *
7
+ * @package MonsterInsights
8
+ * @author Chris Christoff
9
+ */
10
+
11
+ // Exit if accessed directly
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+
16
+ // 1. Disable SeedProd settings (done in seedprod)
17
+ // 2. Output tracking code, if settings is not set to use wp_head() (done in seedprod and below)
18
+ // 3. Disable ga_tracking in their setting (done in seedprod)
19
+ function monsterinsights_seedprod_tracking( $settings ) {
20
+ require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/class-tracking-abstract.php';
21
+
22
+
23
+ do_action( 'monsterinsights_tracking_before_analytics' );
24
+ do_action( 'monsterinsights_tracking_before', 'analytics' );
25
+
26
+ require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/tracking/class-tracking-analytics.php';
27
+ $tracking = new MonsterInsights_Tracking_Analytics();
28
+ echo $tracking->frontend_output();
29
+
30
+ do_action( 'monsterinsights_tracking_after_analytics' );
31
+ do_action( 'monsterinsights_tracking_after', 'analytics' );
32
+
33
+ $track_user = monsterinsights_track_user();
34
+
35
+ if ( $track_user ) {
36
+ require_once plugin_dir_path( MONSTERINSIGHTS_PLUGIN_FILE ) . 'includes/frontend/events/class-analytics-events.php';
37
+ new MonsterInsights_Analytics_Events();
38
+
39
+ // Let's run form tracking if we find it
40
+ if ( function_exists( 'monsterinsights_forms_output_after_script' ) ) {
41
+ monsterinsights_forms_output_after_script( array() );
42
+ }
43
+ }
44
+ }
45
  add_action( 'seedprod_monsterinsights_output_tracking', 'monsterinsights_seedprod_tracking', 6, 1 );
includes/frontend/tracking/class-tracking-analytics.php CHANGED
@@ -1,340 +1,346 @@
1
- <?php
2
- /**
3
- * Tracking analytics.js class.
4
- *
5
- * @since 6.0.0
6
- *
7
- * @package MonsterInsights
8
- * @author Chris Christoff
9
- */
10
-
11
- // Exit if accessed directly
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit;
14
- }
15
-
16
- class MonsterInsights_Tracking_Analytics extends MonsterInsights_Tracking_Abstract {
17
-
18
- /**
19
- * Holds the name of the tracking type.
20
- *
21
- * @since 6.0.0
22
- * @access public
23
- *
24
- * @var string $name Name of the tracking type.
25
- */
26
- public $name = 'analytics';
27
-
28
- /**
29
- * Version of the tracking class.
30
- *
31
- * @since 6.0.0
32
- * @access public
33
- *
34
- * @var string $version Version of the tracking class.
35
- */
36
- public $version = '1.0.0';
37
-
38
- /**
39
- * Primary class constructor.
40
- *
41
- * @since 6.0.0
42
- * @access public
43
- */
44
- public function __construct() {
45
-
46
- }
47
-
48
- /**
49
- * Get frontend tracking options.
50
- *
51
- * This function is used to return an array of parameters
52
- * for the frontend_output() function to output. These are
53
- * generally dimensions and turned on GA features.
54
- *
55
- * @since 6.0.0
56
- * @access public
57
- *
58
- * @return array Array of the options to use.
59
- */
60
- public function frontend_tracking_options( ) {
61
- global $wp_query;
62
- $options = array();
63
-
64
- $ua_code = monsterinsights_get_ua_to_output();
65
- if ( empty( $ua_code ) ) {
66
- return $options;
67
- }
68
-
69
- $track_user = monsterinsights_track_user();
70
-
71
- if ( ! $track_user ) {
72
- $options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( 'auto' ) . "'";
73
- $options['forceSSL'] = "'set', 'forceSSL', true";
74
- $options['send'] = "'send','pageview'";
75
- return $options;
76
- }
77
-
78
- $domain = esc_attr( monsterinsights_get_option( 'subdomain_tracking', 'auto' ) );
79
-
80
- $cross_domains = monsterinsights_get_option( 'cross_domains', array() );
81
- $allow_anchor = monsterinsights_get_option( 'allow_anchor', false );
82
-
83
-
84
- $create = array();
85
- if ( $allow_anchor ) {
86
- $create['allowAnchor'] = true;
87
- }
88
-
89
- if ( is_array( $cross_domains ) && ! empty( $cross_domains ) ) {
90
- $create['allowLinker'] = true;
91
- }
92
-
93
- if ( class_exists( 'MonsterInsights_AMP' ) ) {
94
- $create['useAmpClientId'] = true;
95
- }
96
-
97
- $create = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_create', $create );
98
-
99
- if ( $create && ! empty( $create ) && is_array( $create ) ) {
100
- $create = json_encode( $create );
101
- $create = str_replace( '"', "'", $create );
102
- $options['create'] = "'create', '" . esc_js( $ua_code ). "', '" . esc_js( $domain ) . "', " . $create;
103
- } else {
104
- $options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( $domain ) . "'";
105
- }
106
-
107
- $options['forceSSL'] = "'set', 'forceSSL', true";
108
-
109
- $code = monsterinsights_get_option( 'custom_code', false );
110
- if ( ! empty( $code ) ) {
111
- // Add custom code to the view
112
- $options['custom_code'] = array(
113
- 'type' => 'custom_code',
114
- 'value' => stripslashes( $code ),
115
- );
116
- }
117
-
118
- // Anonymous data
119
- if ( monsterinsights_get_option( 'anonymize_ips', false ) ) {
120
- $options['anonymize_ips'] = "'set', 'anonymizeIp', true";
121
- }
122
-
123
- $options = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_before_scripts', $options );
124
-
125
- // add demographics
126
- if ( monsterinsights_get_option( 'demographics', false ) ) {
127
- $options['demographics'] = "'require', 'displayfeatures'";
128
- }
129
-
130
- // Add Enhanced link attribution.
131
- if ( monsterinsights_get_option( 'enhanced_link_attribution', false ) ) {
132
- $options['enhanced_link_attribution'] = "'require', 'linkid', 'linkid.js'";
133
- }
134
-
135
- // Add cross-domain tracking.
136
- if ( is_array( $cross_domains ) && ! empty( $cross_domains ) ) {
137
- $options['cross_domain_tracking'] = "'require', 'linker'";
138
- $cross_domains_strings = array();
139
- foreach ( $cross_domains as $cross_domain ) {
140
- if ( ! isset( $cross_domain['domain'] ) ) {
141
- continue;
142
- }
143
- $cross_domains_strings[] = '\'' . $cross_domain['domain'] . '\'';
144
- }
145
- if ( ! empty( $cross_domains_strings ) ) {
146
- $cross_domains_strings = implode( ',', $cross_domains_strings );
147
- $options['cross_domains'] = "'linker:autoLink', [$cross_domains_strings]";
148
- }
149
- }
150
-
151
- $options = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_before_pageview', $options );
152
- $options = apply_filters( 'monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version );
153
-
154
- if ( is_404() ) {
155
- if ( monsterinsights_get_option( 'hash_tracking', false ) ) {
156
- $options['send'] = "'send','pageview','/404.html?page=' + document.location.pathname + document.location.search + location.hash + '&from=' + document.referrer";
157
- } else {
158
- $options['send'] = "'send','pageview','/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer";
159
- }
160
- } else if ( $wp_query->is_search ) {
161
- $pushstr = "'send','pageview','/?s=";
162
- if ( (int) $wp_query->found_posts === 0 ) {
163
- $options['send'] = $pushstr . 'no-results:' . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=no-results'";
164
- } else if ( (int) $wp_query->found_posts === 1 ) {
165
- $options['send'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=1-result'";
166
- } else if ( $wp_query->found_posts > 1 && $wp_query->found_posts < 6 ) {
167
- $options['send'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=2-5-results'";
168
- } else {
169
- $options['send'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=plus-5-results'";
170
- }
171
- } else if ( monsterinsights_get_option( 'hash_tracking', false ) ) {
172
- $options['send'] = "'send','pageview', location.pathname + location.search + location.hash";
173
- } else {
174
- $options['send'] = "'send','pageview'";
175
- }
176
-
177
- $options = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_end', $options );
178
- return $options;
179
- }
180
-
181
- /**
182
- * Get frontend output.
183
- *
184
- * This function is used to return the Javascript
185
- * to output in the head of the page for the given
186
- * tracking method.
187
- *
188
- * @since 6.0.0
189
- * @access public
190
- *
191
- * @return string Javascript to output.
192
- */
193
- public function frontend_output( ) {
194
- $options = $this->frontend_tracking_options();
195
- $src = apply_filters( 'monsterinsights_frontend_output_analytics_src', '//www.google-analytics.com/analytics.js' );
196
- $compat_mode = monsterinsights_get_option( 'gatracker_compatibility_mode', false );
197
- $compat = $compat_mode ? 'window.ga = __gaTracker;' : '';
198
- $track_user = monsterinsights_track_user();
199
- $ua = monsterinsights_get_ua();
200
- $output = '';
201
- $reason = '';
202
- $attributes = apply_filters( 'monsterinsights_tracking_analytics_script_attributes', array( 'type' => "text/javascript", 'data-cfasync' => 'false' ) );
203
- $attr_string = '';
204
- if ( ! empty( $attributes ) ) {
205
- foreach( $attributes as $attr_name => $attr_value ) {
206
- if ( ! empty( $attr_name ) ) {
207
- $attr_string .= ' ' . sanitize_key( $attr_name ) . '="' . esc_attr( $attr_value ) . '"';
208
- } else {
209
- $attr_string .= ' ' . sanitize_key( $attr_value );
210
- }
211
- }
212
- }
213
- ob_start();
214
- ?>
215
- <!-- This site uses the Google Analytics by MonsterInsights plugin v<?php echo MONSTERINSIGHTS_VERSION; ?> - Using Analytics tracking - https://www.monsterinsights.com/ -->
216
- <?php if ( ! $track_user ) {
217
- if ( empty( $ua ) ) {
218
- $reason = __( 'Note: MonsterInsights is not currently configured on this site. The site owner needs to authenticate with Google Analytics in the MonsterInsights settings panel.', 'google-analytics-for-wordpress' );
219
- $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
220
- } else if ( current_user_can( 'monsterinsights_save_settings' ) ) {
221
- $reason = __( 'Note: MonsterInsights does not track you as a logged-in site administrator to prevent site owners from accidentally skewing their own Google Analytics data.'. PHP_EOL . 'If you are testing Google Analytics code, please do so either logged out or in the private browsing/incognito mode of your web browser.', 'google-analytics-for-wordpress' );
222
- $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
223
- } else {
224
- $reason = __( 'Note: The site owner has disabled Google Analytics tracking for your user role.', 'google-analytics-for-wordpress' );
225
- $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
226
- }
227
- echo $output;
228
- } ?>
229
- <?php if ( $ua ) { ?>
230
- <script<?php echo $attr_string;?>>
231
- var mi_version = '<?php echo MONSTERINSIGHTS_VERSION; ?>';
232
- var mi_track_user = <?php echo ( $track_user ? 'true' : 'false' ); ?>;
233
- var mi_no_track_reason = <?php echo ( $reason ? "'" . esc_js( $reason) . "'": "''" ); ?>;
234
- <?php do_action( 'monsterinsights_tracking_analytics_frontend_output_after_mi_track_user' ); ?>
235
-
236
- <?php if ( $this->should_do_optout() ) { ?>
237
- var disableStr = 'ga-disable-<?php echo monsterinsights_get_ua(); ?>';
238
-
239
- /* Function to detect opted out users */
240
- function __gaTrackerIsOptedOut() {
241
- return document.cookie.indexOf(disableStr + '=true') > -1;
242
- }
243
-
244
- /* Disable tracking if the opt-out cookie exists. */
245
- if ( __gaTrackerIsOptedOut() ) {
246
- window[disableStr] = true;
247
- }
248
-
249
- /* Opt-out function */
250
- function __gaTrackerOptout() {
251
- document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
252
- window[disableStr] = true;
253
- }
254
- <?php } ?>
255
-
256
- if ( mi_track_user ) {
257
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
258
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
259
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
260
- })(window,document,'script','<?php echo $src; ?>','__gaTracker');
261
-
262
- <?php
263
- echo $compat;
264
-
265
- if ( count( $options ) >= 1 ) {
266
- foreach ( $options as $item ) {
267
- if ( ! is_array( $item ) ) {
268
- echo ' __gaTracker(' . $item . ");\n";
269
- } else if ( ! empty ( $item['value'] ) ) {
270
- echo ' ' . $item['value'] . "\n";
271
- }
272
- }
273
- }
274
- if ( $compat_mode ) {
275
- // Ensure that GA is fully loaded and assign to ga.
276
- echo " __gaTracker( function() { window.ga = __gaTracker; } );\n";
277
- }
278
- ?>
279
- } else {
280
- <?php if ( $this->should_do_optout() ) { ?>
281
- console.log( "<?php echo esc_js( $reason );?>" );
282
- (function() {
283
- /* https://developers.google.com/analytics/devguides/collection/analyticsjs/ */
284
- var noopfn = function() {
285
- return null;
286
- };
287
- var noopnullfn = function() {
288
- return null;
289
- };
290
- var Tracker = function() {
291
- return null;
292
- };
293
- var p = Tracker.prototype;
294
- p.get = noopfn;
295
- p.set = noopfn;
296
- p.send = noopfn;
297
- var __gaTracker = function() {
298
- var len = arguments.length;
299
- if ( len === 0 ) {
300
- return;
301
- }
302
- var f = arguments[len-1];
303
- if ( typeof f !== 'object' || f === null || typeof f.hitCallback !== 'function' ) {
304
- console.log( '<?php echo esc_js( __("Not running function", "google-analytics-for-wordpress" ) );?> __gaTracker(' + arguments[0] + " ....) <?php echo esc_js( __( "because you are not being tracked.", 'google-analytics-for-wordpress' ) );?> " + mi_no_track_reason );
305
- return;
306
- }
307
- try {
308
- f.hitCallback();
309
- } catch (ex) {
310
-
311
- }
312
- };
313
- __gaTracker.create = function() {
314
- return new Tracker();
315
- };
316
- __gaTracker.getByName = noopnullfn;
317
- __gaTracker.getAll = function() {
318
- return [];
319
- };
320
- __gaTracker.remove = noopfn;
321
- window['__gaTracker'] = __gaTracker;
322
- <?php echo $compat; ?>
323
- })();
324
- <?php } ?>
325
- }
326
- </script>
327
- <?php } else { ?>
328
- <!-- No UA code set -->
329
- <?php } ?>
330
- <!-- / Google Analytics by MonsterInsights -->
331
- <?php
332
- $output = ob_get_contents();
333
- ob_end_clean();
334
- return $output;
335
- }
336
-
337
- public function should_do_optout() {
338
- return ! ( defined( 'MI_NO_TRACKING_OPTOUT' ) && MI_NO_TRACKING_OPTOUT );
339
- }
340
- }
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Tracking analytics.js class.
4
+ *
5
+ * @since 6.0.0
6
+ *
7
+ * @package MonsterInsights
8
+ * @author Chris Christoff
9
+ */
10
+
11
+ // Exit if accessed directly
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+
16
+ class MonsterInsights_Tracking_Analytics extends MonsterInsights_Tracking_Abstract {
17
+
18
+ /**
19
+ * Holds the name of the tracking type.
20
+ *
21
+ * @since 6.0.0
22
+ * @access public
23
+ *
24
+ * @var string $name Name of the tracking type.
25
+ */
26
+ public $name = 'analytics';
27
+
28
+ /**
29
+ * Version of the tracking class.
30
+ *
31
+ * @since 6.0.0
32
+ * @access public
33
+ *
34
+ * @var string $version Version of the tracking class.
35
+ */
36
+ public $version = '1.0.0';
37
+
38
+ /**
39
+ * Primary class constructor.
40
+ *
41
+ * @since 6.0.0
42
+ * @access public
43
+ */
44
+ public function __construct() {
45
+
46
+ }
47
+
48
+ /**
49
+ * Get frontend tracking options.
50
+ *
51
+ * This function is used to return an array of parameters
52
+ * for the frontend_output() function to output. These are
53
+ * generally dimensions and turned on GA features.
54
+ *
55
+ * @since 6.0.0
56
+ * @access public
57
+ *
58
+ * @return array Array of the options to use.
59
+ */
60
+ public function frontend_tracking_options( ) {
61
+ global $wp_query;
62
+ $options = array();
63
+
64
+ $ua_code = monsterinsights_get_ua_to_output();
65
+ if ( empty( $ua_code ) ) {
66
+ return $options;
67
+ }
68
+
69
+ $track_user = monsterinsights_track_user();
70
+
71
+ if ( ! $track_user ) {
72
+ $options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( 'auto' ) . "'";
73
+ $options['forceSSL'] = "'set', 'forceSSL', true";
74
+ $options['send'] = "'send','pageview'";
75
+ return $options;
76
+ }
77
+
78
+ $domain = esc_attr( monsterinsights_get_option( 'subdomain_tracking', 'auto' ) );
79
+
80
+ $cross_domains = monsterinsights_get_option( 'cross_domains', array() );
81
+ $allow_anchor = monsterinsights_get_option( 'allow_anchor', false );
82
+
83
+
84
+ $create = array();
85
+ if ( $allow_anchor ) {
86
+ $create['allowAnchor'] = true;
87
+ }
88
+
89
+ if ( is_array( $cross_domains ) && ! empty( $cross_domains ) ) {
90
+ $create['allowLinker'] = true;
91
+ }
92
+
93
+ if ( class_exists( 'MonsterInsights_AMP' ) ) {
94
+ $create['useAmpClientId'] = true;
95
+ }
96
+
97
+ $create = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_create', $create );
98
+
99
+ if ( $create && ! empty( $create ) && is_array( $create ) ) {
100
+ $create = json_encode( $create );
101
+ $create = str_replace( '"', "'", $create );
102
+ $options['create'] = "'create', '" . esc_js( $ua_code ). "', '" . esc_js( $domain ) . "', " . $create;
103
+ } else {
104
+ $options['create'] = "'create', '" . esc_js( $ua_code ) . "', '" . esc_js( $domain ) . "'";
105
+ }
106
+
107
+ $options['forceSSL'] = "'set', 'forceSSL', true";
108
+
109
+ $code = monsterinsights_get_option( 'custom_code', false );
110
+ if ( ! empty( $code ) ) {
111
+ // Add custom code to the view
112
+ $options['custom_code'] = array(
113
+ 'type' => 'custom_code',
114
+ 'value' => stripslashes( $code ),
115
+ );
116
+ }
117
+
118
+ // Anonymous data
119
+ if ( monsterinsights_get_option( 'anonymize_ips', false ) ) {
120
+ $options['anonymize_ips'] = "'set', 'anonymizeIp', true";
121
+ }
122
+
123
+ $options = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_before_scripts', $options );
124
+
125
+ // add demographics
126
+ if ( monsterinsights_get_option( 'demographics', false ) ) {
127
+ $options['demographics'] = "'require', 'displayfeatures'";
128
+ }
129
+
130
+ // Add Enhanced link attribution.
131
+ if ( monsterinsights_get_option( 'link_attribution', false ) ) {
132
+ $options['enhanced_link_attribution'] = "'require', 'linkid', 'linkid.js'";
133
+ }
134
+
135
+ // Add cross-domain tracking.
136
+ if ( is_array( $cross_domains ) && ! empty( $cross_domains ) ) {
137
+ $options['cross_domain_tracking'] = "'require', 'linker'";
138
+ $cross_domains_strings = array();
139
+ foreach ( $cross_domains as $cross_domain ) {
140
+ if ( ! isset( $cross_domain['domain'] ) ) {
141
+ continue;
142
+ }
143
+ $cross_domains_strings[] = '\'' . $cross_domain['domain'] . '\'';
144
+ }
145
+ if ( ! empty( $cross_domains_strings ) ) {
146
+ $cross_domains_strings = implode( ',', $cross_domains_strings );
147
+ $options['cross_domains'] = "'linker:autoLink', [$cross_domains_strings]";
148
+ }
149
+ }
150
+
151
+ $options = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_before_pageview', $options );
152
+ $options = apply_filters( 'monsterinsights_frontend_tracking_options_before_pageview', $options, $this->name, $this->version );
153
+
154
+ if ( is_404() ) {
155
+ if ( monsterinsights_get_option( 'hash_tracking', false ) ) {
156
+ $options['send'] = "'send','pageview','/404.html?page=' + document.location.pathname + document.location.search + location.hash + '&from=' + document.referrer";
157
+ } else {
158
+ $options['send'] = "'send','pageview','/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer";
159
+ }
160
+ } else if ( $wp_query->is_search ) {
161
+ $pushstr = "'send','pageview','/?s=";
162
+ if ( (int) $wp_query->found_posts === 0 ) {
163
+ $options['send'] = $pushstr . 'no-results:' . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=no-results'";
164
+ } else if ( (int) $wp_query->found_posts === 1 ) {
165
+ $options['send'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=1-result'";
166
+ } else if ( $wp_query->found_posts > 1 && $wp_query->found_posts < 6 ) {
167
+ $options['send'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=2-5-results'";
168
+ } else {
169
+ $options['send'] = $pushstr . rawurlencode( $wp_query->query_vars['s'] ) . "&cat=plus-5-results'";
170
+ }
171
+ } else if ( monsterinsights_get_option( 'hash_tracking', false ) ) {
172
+ $options['send'] = "'send','pageview', location.pathname + location.search + location.hash";
173
+ } else {
174
+ $options['send'] = "'send','pageview'";
175
+ }
176
+
177
+ $options = apply_filters( 'monsterinsights_frontend_tracking_options_analytics_end', $options );
178
+ return $options;
179
+ }
180
+
181
+ /**
182
+ * Get frontend output.
183
+ *
184
+ * This function is used to return the Javascript
185
+ * to output in the head of the page for the given
186
+ * tracking method.
187
+ *
188
+ * @since 6.0.0
189
+ * @access public
190
+ *
191
+ * @return string Javascript to output.
192
+ */
193
+ public function frontend_output( ) {
194
+ $options = $this->frontend_tracking_options();
195
+ $src = apply_filters( 'monsterinsights_frontend_output_analytics_src', '//www.google-analytics.com/analytics.js' );
196
+ $compat_mode = monsterinsights_get_option( 'gatracker_compatibility_mode', false );
197
+ $compat = $compat_mode ? 'window.ga = __gaTracker;' : '';
198
+ $track_user = monsterinsights_track_user();
199
+ $ua = monsterinsights_get_ua();
200
+ $output = '';
201
+ $reason = '';
202
+ $attributes = apply_filters( 'monsterinsights_tracking_analytics_script_attributes', array( 'type' => "text/javascript", 'data-cfasync' => 'false' ) );
203
+ $attr_string = '';
204
+ if ( ! empty( $attributes ) ) {
205
+ foreach( $attributes as $attr_name => $attr_value ) {
206
+ if ( ! empty( $attr_name ) ) {
207
+ $attr_string .= ' ' . sanitize_key( $attr_name ) . '="' . esc_attr( $attr_value ) . '"';
208
+ } else {
209
+ $attr_string .= ' ' . sanitize_key( $attr_value );
210
+ }
211
+ }
212
+ }
213
+ ob_start();
214
+ ?>
215
+ <!-- This site uses the Google Analytics by MonsterInsights plugin v<?php echo MONSTERINSIGHTS_VERSION; ?> - Using Analytics tracking - https://www.monsterinsights.com/ -->
216
+ <?php if ( ! $track_user ) {
217
+ if ( empty( $ua ) ) {
218
+ $reason = __( 'Note: MonsterInsights is not currently configured on this site. The site owner needs to authenticate with Google Analytics in the MonsterInsights settings panel.', 'google-analytics-for-wordpress' );
219
+ $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
220
+ } else if ( current_user_can( 'monsterinsights_save_settings' ) ) {
221
+ $reason = __( 'Note: MonsterInsights does not track you as a logged-in site administrator to prevent site owners from accidentally skewing their own Google Analytics data.'. PHP_EOL . 'If you are testing Google Analytics code, please do so either logged out or in the private browsing/incognito mode of your web browser.', 'google-analytics-for-wordpress' );
222
+ $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
223
+ } else {
224
+ $reason = __( 'Note: The site owner has disabled Google Analytics tracking for your user role.', 'google-analytics-for-wordpress' );
225
+ $output .= '<!-- ' . esc_html( $reason ) . ' -->' . PHP_EOL;
226
+ }
227
+ echo $output;
228
+ } ?>
229
+ <?php if ( $ua ) { ?>
230
+ <script<?php echo $attr_string;?>>
231
+ var mi_version = '<?php echo MONSTERINSIGHTS_VERSION; ?>';
232
+ var mi_track_user = <?php echo ( $track_user ? 'true' : 'false' ); ?>;
233
+ var mi_no_track_reason = <?php echo ( $reason ? "'" . esc_js( $reason) . "'": "''" ); ?>;
234
+ <?php do_action( 'monsterinsights_tracking_analytics_frontend_output_after_mi_track_user' ); ?>
235
+
236
+ <?php if ( $this->should_do_optout() ) { ?>
237
+ var disableStr = 'ga-disable-<?php echo monsterinsights_get_ua(); ?>';
238
+
239
+ /* Function to detect opted out users */
240
+ function __gaTrackerIsOptedOut() {
241
+ return document.cookie.indexOf(disableStr + '=true') > -1;
242
+ }
243
+
244
+ /* Disable tracking if the opt-out cookie exists. */
245
+ if ( __gaTrackerIsOptedOut() ) {
246
+ window[disableStr] = true;
247
+ }
248
+
249
+ /* Opt-out function */
250
+ function __gaTrackerOptout() {
251
+ document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
252
+ window[disableStr] = true;
253
+ }
254
+
255
+ if ( 'undefined' === typeof gaOptout ) {
256
+ function gaOptout() {
257
+ __gaTrackerOptout();
258
+ }
259
+ }
260
+ <?php } ?>
261
+
262
+ if ( mi_track_user ) {
263
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
264
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
265
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
266
+ })(window,document,'script','<?php echo $src; ?>','__gaTracker');
267
+
268
+ <?php
269
+ echo $compat;
270
+
271
+ if ( count( $options ) >= 1 ) {
272
+ foreach ( $options as $item ) {
273
+ if ( ! is_array( $item ) ) {
274
+ echo ' __gaTracker(' . $item . ");\n";
275
+ } else if ( ! empty ( $item['value'] ) ) {
276
+ echo ' ' . $item['value'] . "\n";
277
+ }
278
+ }
279
+ }
280
+ if ( $compat_mode ) {
281
+ // Ensure that GA is fully loaded and assign to ga.
282
+ echo " __gaTracker( function() { window.ga = __gaTracker; } );\n";
283
+ }
284
+ ?>
285
+ } else {
286
+ <?php if ( $this->should_do_optout() ) { ?>
287
+ console.log( "<?php echo esc_js( $reason );?>" );
288
+ (function() {
289
+ /* https://developers.google.com/analytics/devguides/collection/analyticsjs/ */
290
+ var noopfn = function() {
291
+ return null;
292
+ };
293
+ var noopnullfn = function() {
294
+ return null;
295
+ };
296
+ var Tracker = function() {
297
+ return null;
298
+ };
299
+ var p = Tracker.prototype;
300
+ p.get = noopfn;
301
+ p.set = noopfn;
302
+ p.send = noopfn;
303
+ var __gaTracker = function() {
304
+ var len = arguments.length;
305
+ if ( len === 0 ) {
306
+ return;
307
+ }
308
+ var f = arguments[len-1];
309
+ if ( typeof f !== 'object' || f === null || typeof f.hitCallback !== 'function' ) {
310
+ console.log( '<?php echo esc_js( __("Not running function", "google-analytics-for-wordpress" ) );?> __gaTracker(' + arguments[0] + " ....) <?php echo esc_js( __( "because you are not being tracked.", 'google-analytics-for-wordpress' ) );?> " + mi_no_track_reason );
311
+ return;
312
+ }
313
+ try {
314
+ f.hitCallback();
315
+ } catch (ex) {
316
+
317
+ }
318
+ };
319
+ __gaTracker.create = function() {
320
+ return new Tracker();
321
+ };
322
+ __gaTracker.getByName = noopnullfn;
323
+ __gaTracker.getAll = function() {
324
+ return [];
325
+ };
326
+ __gaTracker.remove = noopfn;
327
+ window['__gaTracker'] = __gaTracker;
328
+ <?php echo $compat; ?>
329
+ })();
330
+ <?php } ?>
331
+ }
332
+ </script>
333
+ <?php } else { ?>
334
+ <!-- No UA code set -->
335
+ <?php } ?>
336
+ <!-- / Google Analytics by MonsterInsights -->
337
+ <?php
338
+ $output = ob_get_contents();
339
+ ob_end_clean();
340
+ return $output;
341
+ }
342
+
343
+ public function should_do_optout() {
344
+ return ! ( defined( 'MI_NO_TRACKING_OPTOUT' ) && MI_NO_TRACKING_OPTOUT );
345
+ }
346
+ }
includes/frontend/tracking/class-tracking-preview.php CHANGED
@@ -1,81 +1,81 @@
1
- <?php
2
- /**
3
- * Tracking debug class.
4
- *
5
- * @since 6.0.0
6
- *
7
- * @package MonsterInsights
8
- * @author Chris Christoff
9
- */
10
-
11
- // Exit if accessed directly
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit;
14
- }
15
-
16
- class MonsterInsights_Tracking_Preview extends MonsterInsights_Tracking_Abstract {
17
- /**
18
- * Holds the name of the tracking type.
19
- *
20
- * @since 6.0.0
21
- * @access public
22
- *
23
- * @var string $name Name of the tracking type.
24
- */
25
- public $name = 'preview';
26
-
27
- /**
28
- * Version of the tracking class.
29
- *
30
- * @since 6.0.0
31
- * @access public
32
- *
33
- * @var string $version Version of the tracking class.
34
- */
35
- public $version = '1.0.0';
36
-
37
- /**
38
- * Primary class constructor.
39
- *
40
- * @since 6.0.0
41
- * @access public
42
- */
43
- public function __construct() {
44
-
45
- }
46
-
47
- /**
48
- * Get frontend tracking options.
49
- *
50
- * This function is used to return an array of parameters
51
- * for the frontend_output() function to output. These are
52
- * generally dimensions and turned on GA features.
53
- *
54
- * @since 6.0.0
55
- * @access public
56
- *
57
- * @return array Array of the options to use.
58
- */
59
- public function frontend_tracking_options( ) {
60
- return array();
61
- }
62
-
63
- /**
64
- * Get frontend output.
65
- *
66
- * This function is used to return the Javascript
67
- * to output in the head of the page for the given
68
- * tracking method.
69
- *
70
- * @since 6.0.0
71
- * @access public
72
- *
73
- * @return string Javascript to output.
74
- */
75
- public function frontend_output( ) {
76
- $output = '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION .' - https://www.monsterinsights.com/ -->';
77
- $output .= '<!-- ' . esc_html__( "You are currently in a preview window. MonsterInsights doesn't track preview window traffic to avoid false visit reports.", 'google-analytics-for-wordpress' ) . ' -->';
78
- $output .= '<!-- / Google Analytics by MonsterInsights -->';
79
- return $output;
80
- }
81
  }
1
+ <?php
2
+ /**
3
+ * Tracking debug class.
4
+ *
5
+ * @since 6.0.0
6
+ *
7
+ * @package MonsterInsights
8
+ * @author Chris Christoff
9
+ */
10
+
11
+ // Exit if accessed directly
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+
16
+ class MonsterInsights_Tracking_Preview extends MonsterInsights_Tracking_Abstract {
17
+ /**
18
+ * Holds the name of the tracking type.
19
+ *
20
+ * @since 6.0.0
21
+ * @access public
22
+ *
23
+ * @var string $name Name of the tracking type.
24
+ */
25
+ public $name = 'preview';
26
+
27
+ /**
28
+ * Version of the tracking class.
29
+ *
30
+ * @since 6.0.0
31
+ * @access public
32
+ *
33
+ * @var string $version Version of the tracking class.
34
+ */
35
+ public $version = '1.0.0';
36
+
37
+ /**
38
+ * Primary class constructor.
39
+ *
40
+ * @since 6.0.0
41
+ * @access public
42
+ */
43
+ public function __construct() {
44
+
45
+ }
46
+
47
+ /**
48
+ * Get frontend tracking options.
49
+ *
50
+ * This function is used to return an array of parameters
51
+ * for the frontend_output() function to output. These are
52
+ * generally dimensions and turned on GA features.
53
+ *
54
+ * @since 6.0.0
55
+ * @access public
56
+ *
57
+ * @return array Array of the options to use.
58
+ */
59
+ public function frontend_tracking_options( ) {
60
+ return array();
61
+ }
62
+
63
+ /**
64
+ * Get frontend output.
65
+ *
66
+ * This function is used to return the Javascript
67
+ * to output in the head of the page for the given
68
+ * tracking method.
69
+ *
70
+ * @since 6.0.0
71
+ * @access public
72
+ *
73
+ * @return string Javascript to output.
74
+ */
75
+ public function frontend_output( ) {
76
+ $output = '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION .' - https://www.monsterinsights.com/ -->';
77
+ $output .= '<!-- ' . esc_html__( "You are currently in a preview window. MonsterInsights doesn't track preview window traffic to avoid false visit reports.", 'google-analytics-for-wordpress' ) . ' -->';
78
+ $output .= '<!-- / Google Analytics by MonsterInsights -->';
79
+ return $output;
80
+ }
81
  }
includes/frontend/tracking/index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- //Nothing to see here
3
-
4
  header( 'HTTP/1.0 403 Forbidden' );
1
+ <?php
2
+ //Nothing to see here
3
+
4
  header( 'HTTP/1.0 403 Forbidden' );
includes/helpers.php CHANGED
@@ -1,1297 +1,1500 @@
1
- <?php
2
- /**
3
- * Helper functions.
4
- *
5
- * @since 6.0.0
6
- *
7
- * @package MonsterInsights
8
- * @subpackage Helper
9
- * @author Chris Christoff
10
- */
11
-
12
- // Exit if accessed directly
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
-
17
- function monsterinsights_is_page_reload() {
18
- // Can't be a refresh without having a referrer
19
- if ( ! isset( $_SERVER['HTTP_REFERER'] ) ) {
20
- return false;
21
- }
22
-
23
- // IF the referrer is identical to the current page request, then it's a refresh
24
- return ( parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_PATH ) === parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) );
25
- }
26
-
27
-
28
- function monsterinsights_track_user( $user_id = -1 ) {
29
- if ( $user_id === -1 ) {
30
- $user = wp_get_current_user();
31
- } else {
32
- $user = new WP_User( $user_id );
33
- }
34
-
35
- $track_user = true;
36
- $roles = monsterinsights_get_option( 'ignore_users', array() );
37
-
38
- if ( ! empty( $roles ) && is_array( $roles ) ) {
39
- foreach ( $roles as $role ) {
40
- if ( is_string( $role ) ) {
41
- if ( user_can( $user, $role ) ) {
42
- $track_user = false;
43
- break;
44
- }
45
- }
46
- }
47
- }
48
-
49
- $track_super_admin = apply_filters( 'monsterinsights_track_super_admins', false );
50
- if ( $track_super_admin === false && is_multisite() && is_super_admin() ) {
51
- $track_user = false;
52
- }
53
-
54
- // or if UA code is not entered
55
- $ua_code = monsterinsights_get_ua();
56
- if ( empty( $ua_code ) ) {
57
- $track_user = false;
58
- }
59
-
60
- return apply_filters( 'monsterinsights_track_user', $track_user, $user );
61
- }
62
-
63
- function monsterinsights_get_client_id( $payment_id = false ) {
64
- if ( is_object( $payment_id ) ) {
65
- $payment_id = $payment_id->ID;
66
- }
67
- $user_cid = monsterinsights_get_uuid();
68
- $saved_cid = ! empty( $payment_id ) ? get_post_meta( $payment_id, '_yoast_gau_uuid', true ) : false;
69
-
70
- if ( ! empty( $payment_id ) && ! empty( $saved_cid ) ) {
71
- return $saved_cid;
72
- } else if ( ! empty( $user_cid ) ) {
73
- return $user_cid;
74
- } else {
75
- return monsterinsights_generate_uuid();
76
- }
77
- }
78
-
79
- /**
80
- * Returns the Google Analytics clientId to store for later use
81
- *
82
- * @since 6.0.0
83
- *
84
- * @link https://developers.google.com/analytics/devguides/collection/analyticsjs/domains#getClientId
85
- *
86
- * @return bool|string False if cookie isn't set, GA UUID otherwise
87
- */
88
- function monsterinsights_get_uuid() {
89
- if ( empty( $_COOKIE['_ga'] ) ) {
90
- return false;
91
- }
92
-
93
- /**
94
- * Example cookie formats:
95
- *
96
- * GA1.2.XXXXXXX.YYYYY
97
- * _ga=1.2.XXXXXXX.YYYYYY -- We want the XXXXXXX.YYYYYY part
98
- *
99
- */
100
-
101
- $ga_cookie = $_COOKIE['_ga'];
102
- $cookie_parts = explode('.', $ga_cookie );
103
- if ( is_array( $cookie_parts ) && ! empty( $cookie_parts[2] ) && ! empty( $cookie_parts[3] ) ) {
104
- $uuid = (string) $cookie_parts[2] . '.' . (string) $cookie_parts[3];
105
- if ( is_string( $uuid ) ) {
106
- return $uuid;
107
- } else {
108
- return false;
109
- }
110
- } else {
111
- return false;
112
- }
113
- }
114
-
115
-
116
- /**
117
- * Generate UUID v4 function - needed to generate a CID when one isn't available
118
- *
119
- * @link http://www.stumiller.me/implementing-google-analytics-measurement-protocol-in-php-and-wordpress/
120
- *
121
- * @since 6.1.8
122
- * @return string
123
- */
124
- function monsterinsights_generate_uuid() {
125
-
126
- return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
127
-
128
- // 32 bits for "time_low"
129
- mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
130
-
131
- // 16 bits for "time_mid"
132
- mt_rand( 0, 0xffff ),
133
-
134
- // 16 bits for "time_hi_and_version",
135
- // four most significant bits holds version number 4
136
- mt_rand( 0, 0x0fff ) | 0x4000,
137
-
138
- // 16 bits, 8 bits for "clk_seq_hi_res",
139
- // 8 bits for "clk_seq_low",
140
- // two most significant bits holds zero and one for variant DCE1.1
141
- mt_rand( 0, 0x3fff ) | 0x8000,
142
-
143
- // 48 bits for "node"
144
- mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
145
- );
146
- }
147
-
148
- /**
149
- * Returns the Google Analytics clientId to store for later use
150
- *
151
- * @since 6.0.0
152
- *
153
- * @return GA UUID or error code.
154
- */
155
- function monsterinsights_get_cookie( $debug = false ) {
156
- if ( empty( $_COOKIE['_ga'] ) ) {
157
- return ( $debug ) ? 'FCE' : false;
158
- }
159
-
160
- $ga_cookie = $_COOKIE['_ga'];
161
- $cookie_parts = explode('.', $ga_cookie );
162
- if ( is_array( $cookie_parts ) && ! empty( $cookie_parts[2] ) && ! empty( $cookie_parts[3] ) ) {
163
- $uuid = (string) $cookie_parts[2] . '.' . (string) $cookie_parts[3];
164
- if ( is_string( $uuid ) ) {
165
- return $ga_cookie;
166
- } else {
167
- return ( $debug ) ? 'FA' : false;
168
- }
169
- } else {
170
- return ( $debug ) ? 'FAE' : false;
171
- }
172
- }
173
-
174
-
175
- function monsterinsights_generate_ga_client_id() {
176
- return rand(100000000,999999999) . '.' . time();
177
- }
178
-
179
-
180
- /**
181
- * Hours between two timestamps.
182
- *
183
- * @access public
184
- * @since 6.0.0
185
- *
186
- * @param string $start Timestamp of start time (in seconds since Unix).
187
- * @param string $stop Timestamp of stop time (in seconds since Unix). Optional. If not used, current_time (in UTC 0 / GMT ) is used.
188
- *
189
- * @return int Hours between the two timestamps, rounded.
190
- */
191
- function monsterinsights_hours_between( $start, $stop = false ) {
192
- if ( $stop === false ) {
193
- $stop = time();
194
- }
195
-
196
- $diff = (int) abs( $stop - $start );
197
- $hours = round( $diff / HOUR_IN_SECONDS );
198
- return $hours;
199
- }
200
-
201
- /**
202
- * Is This MonsterInsights Pro?
203
- *
204
- * We use this function monsterinsights_to determine if the install is a pro version or a lite version install of MonsterInsights.
205
- * If the install is a lite version we disable the install from admin functionality[1] for addons as WordPress.org requires us to,
206
- * we change the links for where to get support (wp.org forum for free; our site for pro), we use this determine what class to load as
207
- * the base class in addons (to avoid fatal errors) and we use this on the system info page to know what constants to display values for
208
- * as the lite and pro versions of our plugin have different constants (and names for those constants) you can declare and use.
209
- *
210
- * [1] Note: This is not "feature-locking" under GPL guidelines but rather something WordPress.org requires us to do to stay
211
- * in compliance with their rules. We wish we didn't have to do this, as in our oppinion this diminishes the user experience
212
- * of users installing our free and premium addons, and we'd love to turn this on for non-Pro installs, but we're not allowed to.
213
- * If WordPress.org ever changes their mind on this subject, we'd totally turn on that feature for Lite installs in a heartbeat.
214
- *
215
- * @todo Are we allowed to turn on admin installing if the user has to manually declare a PHP constant (and thus would not be on
216
- * either by default or via any sort of user interface)? If so, we could add a constant for forcing Pro version so that users can see
217
- * for themselves that we're not feature locking anything inside the plugin + it would make it easier for our team to test stuff (both via
218
- * Travis-CI but also when installing addons to test with the Lite version). Also this would allow for a better user experience for users
219
- * who want that feature.
220
- *
221
- * @since 6.0.0
222
- * @access public
223
- *
224
- * @return bool True if pro version.
225
- */
226
- function monsterinsights_is_pro_version() {
227
- if ( class_exists( 'MonsterInsights' ) ) {
228
- return true;
229
- } else {
230
- return false;
231
- }
232
- }
233
-
234
-
235
- /**
236
- * Get the user roles of this WordPress blog
237
- *
238
- * @return array
239
- */
240
- function monsterinsights_get_roles() {
241
- global $wp_roles;
242
-
243
- $all_roles = $wp_roles->roles;
244
- $roles = array();
245
-
246
- /**
247
- * Filter: 'editable_roles' - Allows filtering of the roles shown within the plugin (and elsewhere in WP as it's a WP filter)
248
- *
249
- * @api array $all_roles
250
- */
251
- $editable_roles = apply_filters( 'editable_roles', $all_roles );
252
-
253
- foreach ( $editable_roles as $id => $name ) {
254
- $roles[ $id ] = translate_user_role( $name['name'] );
255
- }
256
-
257
- return $roles;
258
- }
259
-
260
- /**
261
- * Get the user roles which can manage options. Used to prevent these roles from getting unselected in the settings.
262
- *
263
- * @return array
264
- */
265
- function monsterinsights_get_manage_options_roles() {
266
- global $wp_roles;
267
-
268
- $all_roles = $wp_roles->roles;
269
- $roles = array();
270
-
271
- /**
272
- * Filter: 'editable_roles' - Allows filtering of the roles shown within the plugin (and elsewhere in WP as it's a WP filter)
273
- *
274
- * @api array $all_roles
275
- */
276
- $editable_roles = apply_filters( 'editable_roles', $all_roles );
277
-
278
- foreach ( $editable_roles as $id => $role ) {
279
- if ( isset( $role['capabilities']['manage_options'] ) && $role['capabilities']['manage_options'] ) {
280
- $roles[ $id ] = translate_user_role( $role['name'] );
281
- }
282
- }
283
-
284
- return $roles;
285
- }
286
-
287
- /** Need to escape in advance of passing in $text. */
288
- function monsterinsights_get_message( $type = 'error', $text = '' ) {
289
- $div = '';
290
- if ( $type === 'error' || $type === 'alert' || $type === 'success' || $type === 'info' ) {
291
- $base = MonsterInsights();
292
- return $base->notices->display_inline_notice( 'monsterinsights_standard_notice', '', $text, $type, false, array( 'skip_message_escape' => true ) );
293
- } else {
294
- return '';
295
- }
296
- }
297
-
298
- function monsterinsights_is_dev_url( $url = '' ) {
299
- $is_local_url = false;
300
- // Trim it up
301
- $url = strtolower( trim( $url ) );
302
- // Need to get the host...so let's add the scheme so we can use parse_url
303
- if ( false === strpos( $url, 'http://' ) && false === strpos( $url, 'https://' ) ) {
304
- $url = 'http://' . $url;
305
- }
306
- $url_parts = parse_url( $url );
307
- $host = ! empty( $url_parts['host'] ) ? $url_parts['host'] : false;
308
- if ( ! empty( $url ) && ! empty( $host ) ) {
309
- if ( false !== ip2long( $host ) ) {
310
- if ( ! filter_var( $host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) ) {
311
- $is_local_url = true;
312
- }
313
- } else if ( 'localhost' === $host ) {
314
- $is_local_url = true;
315
- }
316
-
317
- $tlds_to_check = array( '.local', ':8888', ':8080', ':8081', '.invalid', '.example', '.test' );
318
- foreach ( $tlds_to_check as $tld ) {
319
- if ( false !== strpos( $host, $tld ) ) {
320
- $is_local_url = true;
321
- break;
322
- }
323
-
324
- }
325
- if ( substr_count( $host, '.' ) > 1 ) {
326
- $subdomains_to_check = array( 'dev.', '*.staging.', 'beta.', 'test.' );
327
- foreach ( $subdomains_to_check as $subdomain ) {
328
- $subdomain = str_replace( '.', '(.)', $subdomain );
329
- $subdomain = str_replace( array( '*', '(.)' ), '(.*)', $subdomain );
330
- if ( preg_match( '/^(' . $subdomain . ')/', $host ) ) {
331
- $is_local_url = true;
332
- break;
333
- }
334
- }
335
- }
336
- }
337
- return $is_local_url;
338
- }
339
-
340
- // Set cookie to expire in 2 years
341
- function monsterinsights_get_cookie_expiration_date( $time ) {
342
- return date('D, j F Y H:i:s', time() + $time );
343
- }
344
-
345
- function monsterinsights_string_ends_with( $string, $ending ) {
346
- $strlen = strlen($string);
347
- $endinglen = strlen($ending);
348
- if ( $endinglen > $strlen ) {
349
- return false;
350
- }
351
- return substr_compare( $string, $ending, $strlen - $endinglen, $endinglen) === 0;
352
- }
353
-
354
- function monsterinsights_string_starts_with( $string, $start ) {
355
- if ( ! is_string( $string ) || ! is_string( $start ) ) {
356
- return false;
357
- }
358
-
359
- return substr( $string, 0, strlen( $start ) ) === $start;
360
- }
361
-
362
- function monsterinsights_get_country_list( $translated = false ) {
363
- if ( $translated ) {
364
- $countries = array(
365
- '' => '',
366
- 'US' => __( 'United States', 'google-analytics-for-wordpress' ),
367
- 'CA' => __( 'Canada', 'google-analytics-for-wordpress' ),
368
- 'GB' => __( 'United Kingdom', 'google-analytics-for-wordpress' ),
369
- 'AF' => __( 'Afghanistan', 'google-analytics-for-wordpress' ),
370
- 'AX' => __( '&#197;land Islands', 'google-analytics-for-wordpress' ),
371
- 'AL' => __( 'Albania', 'google-analytics-for-wordpress' ),
372
- 'DZ' => __( 'Algeria', 'google-analytics-for-wordpress' ),
373
- 'AS' => __( 'American Samoa', 'google-analytics-for-wordpress' ),
374
- 'AD' => __( 'Andorra', 'google-analytics-for-wordpress' ),
375
- 'AO' => __( 'Angola', 'google-analytics-for-wordpress' ),
376
- 'AI' => __( 'Anguilla', 'google-analytics-for-wordpress' ),
377
- 'AQ' => __( 'Antarctica', 'google-analytics-for-wordpress' ),
378
- 'AG' => __( 'Antigua and Barbuda', 'google-analytics-for-wordpress' ),
379
- 'AR' => __( 'Argentina', 'google-analytics-for-wordpress' ),
380
- 'AM' => __( 'Armenia', 'google-analytics-for-wordpress' ),
381
- 'AW' => __( 'Aruba', 'google-analytics-for-wordpress' ),
382
- 'AU' => __( 'Australia', 'google-analytics-for-wordpress' ),
383
- 'AT' => __( 'Austria', 'google-analytics-for-wordpress' ),
384
- 'AZ' => __( 'Azerbaijan', 'google-analytics-for-wordpress' ),
385
- 'BS' => __( 'Bahamas', 'google-analytics-for-wordpress' ),
386
- 'BH' => __( 'Bahrain', 'google-analytics-for-wordpress' ),
387
- 'BD' => __( 'Bangladesh', 'google-analytics-for-wordpress' ),
388
- 'BB' => __( 'Barbados', 'google-analytics-for-wordpress' ),
389
- 'BY' => __( 'Belarus', 'google-analytics-for-wordpress' ),
390
- 'BE' => __( 'Belgium', 'google-analytics-for-wordpress' ),
391
- 'BZ' => __( 'Belize', 'google-analytics-for-wordpress' ),
392
- 'BJ' => __( 'Benin', 'google-analytics-for-wordpress' ),
393
- 'BM' => __( 'Bermuda', 'google-analytics-for-wordpress' ),
394
- 'BT' => __( 'Bhutan', 'google-analytics-for-wordpress' ),
395
- 'BO' => __( 'Bolivia', 'google-analytics-for-wordpress' ),
396
- 'BQ' => __( 'Bonaire, Saint Eustatius and Saba', 'google-analytics-for-wordpress' ),
397
- 'BA' => __( 'Bosnia and Herzegovina', 'google-analytics-for-wordpress' ),
398
- 'BW' => __( 'Botswana', 'google-analytics-for-wordpress' ),
399
- 'BV' => __( 'Bouvet Island', 'google-analytics-for-wordpress' ),
400
- 'BR' => __( 'Brazil', 'google-analytics-for-wordpress' ),
401
- 'IO' => __( 'British Indian Ocean Territory', 'google-analytics-for-wordpress' ),
402
- 'BN' => __( 'Brunei Darrussalam', 'google-analytics-for-wordpress' ),
403
- 'BG' => __( 'Bulgaria', 'google-analytics-for-wordpress' ),
404
- 'BF' => __( 'Burkina Faso', 'google-analytics-for-wordpress' ),
405
- 'BI' => __( 'Burundi', 'google-analytics-for-wordpress' ),
406
- 'KH' => __( 'Cambodia', 'google-analytics-for-wordpress' ),
407
- 'CM' => __( 'Cameroon', 'google-analytics-for-wordpress' ),
408
- 'CV' => __( 'Cape Verde', 'google-analytics-for-wordpress' ),
409
- 'KY' => __( 'Cayman Islands', 'google-analytics-for-wordpress' ),
410
- 'CF' => __( 'Central African Republic', 'google-analytics-for-wordpress' ),
411
- 'TD' => __( 'Chad', 'google-analytics-for-wordpress' ),
412
- 'CL' => __( 'Chile', 'google-analytics-for-wordpress' ),
413
- 'CN' => __( 'China', 'google-analytics-for-wordpress' ),
414
- 'CX' => __( 'Christmas Island', 'google-analytics-for-wordpress' ),
415
- 'CC' => __( 'Cocos Islands', 'google-analytics-for-wordpress' ),
416
- 'CO' => __( 'Colombia', 'google-analytics-for-wordpress' ),
417
- 'KM' => __( 'Comoros', 'google-analytics-for-wordpress' ),
418
- 'CD' => __( 'Congo, Democratic People\'s Republic', 'google-analytics-for-wordpress' ),
419
- 'CG' => __( 'Congo, Republic of', 'google-analytics-for-wordpress' ),
420
- 'CK' => __( 'Cook Islands', 'google-analytics-for-wordpress' ),
421
- 'CR' => __( 'Costa Rica', 'google-analytics-for-wordpress' ),
422
- 'CI' => __( 'Cote d\'Ivoire', 'google-analytics-for-wordpress' ),
423
- 'HR' => __( 'Croatia/Hrvatska', 'google-analytics-for-wordpress' ),
424
- 'CU' => __( 'Cuba', 'google-analytics-for-wordpress' ),
425
- 'CW' => __( 'Cura&Ccedil;ao', 'google-analytics-for-wordpress' ),
426
- 'CY' => __( 'Cyprus', 'google-analytics-for-wordpress' ),
427
- 'CZ' => __( 'Czechia', 'google-analytics-for-wordpress' ),
428
- 'DK' => __( 'Denmark', 'google-analytics-for-wordpress' ),
429
- 'DJ' => __( 'Djibouti', 'google-analytics-for-wordpress' ),
430
- 'DM' => __( 'Dominica', 'google-analytics-for-wordpress' ),
431
- 'DO' => __( 'Dominican Republic', 'google-analytics-for-wordpress' ),
432
- 'TP' => __( 'East Timor', 'google-analytics-for-wordpress' ),
433
- 'EC' => __( 'Ecuador', 'google-analytics-for-wordpress' ),
434
- 'EG' => __( 'Egypt', 'google-analytics-for-wordpress' ),
435
- 'GQ' => __( 'Equatorial Guinea', 'google-analytics-for-wordpress' ),
436
- 'SV' => __( 'El Salvador', 'google-analytics-for-wordpress' ),
437
- 'ER' => __( 'Eritrea', 'google-analytics-for-wordpress' ),
438
- 'EE' => __( 'Estonia', 'google-analytics-for-wordpress' ),
439
- 'ET' => __( 'Ethiopia', 'google-analytics-for-wordpress' ),
440
- 'FK' => __( 'Falkland Islands', 'google-analytics-for-wordpress' ),
441
- 'FO' => __( 'Faroe Islands', 'google-analytics-for-wordpress' ),
442
- 'FJ' => __( 'Fiji', 'google-analytics-for-wordpress' ),
443
- 'FI' => __( 'Finland', 'google-analytics-for-wordpress' ),
444
- 'FR' => __( 'France', 'google-analytics-for-wordpress' ),
445
- 'GF' => __( 'French Guiana', 'google-analytics-for-wordpress' ),
446
- 'PF' => __( 'French Polynesia', 'google-analytics-for-wordpress' ),
447
- 'TF' => __( 'French Southern Territories', 'google-analytics-for-wordpress' ),
448
- 'GA' => __( 'Gabon', 'google-analytics-for-wordpress' ),
449
- 'GM' => __( 'Gambia', 'google-analytics-for-wordpress' ),
450
- 'GE' => __( 'Georgia', 'google-analytics-for-wordpress' ),
451
- 'DE' => __( 'Germany', 'google-analytics-for-wordpress' ),
452
- 'GR' => __( 'Greece', 'google-analytics-for-wordpress' ),
453
- 'GH' => __( 'Ghana', 'google-analytics-for-wordpress' ),
454
- 'GI' => __( 'Gibraltar', 'google-analytics-for-wordpress' ),
455
- 'GL' => __( 'Greenland', 'google-analytics-for-wordpress' ),
456
- 'GD' => __( 'Grenada', 'google-analytics-for-wordpress' ),
457
- 'GP' => __( 'Guadeloupe', 'google-analytics-for-wordpress' ),
458
- 'GU' => __( 'Guam', 'google-analytics-for-wordpress' ),
459
- 'GT' => __( 'Guatemala', 'google-analytics-for-wordpress' ),
460
- 'GG' => __( 'Guernsey', 'google-analytics-for-wordpress' ),
461
- 'GN' => __( 'Guinea', 'google-analytics-for-wordpress' ),
462
- 'GW' => __( 'Guinea-Bissau', 'google-analytics-for-wordpress' ),
463
- 'GY' => __( 'Guyana', 'google-analytics-for-wordpress' ),
464
- 'HT' => __( 'Haiti', 'google-analytics-for-wordpress' ),
465
- 'HM' => __( 'Heard and McDonald Islands', 'google-analytics-for-wordpress' ),
466
- 'VA' => __( 'Holy See (City Vatican State)', 'google-analytics-for-wordpress' ),
467
- 'HN' => __( 'Honduras', 'google-analytics-for-wordpress' ),
468
- 'HK' => __( 'Hong Kong', 'google-analytics-for-wordpress' ),
469
- 'HU' => __( 'Hungary', 'google-analytics-for-wordpress' ),
470
- 'IS' => __( 'Iceland', 'google-analytics-for-wordpress' ),
471
- 'IN' => __( 'India', 'google-analytics-for-wordpress' ),
472
- 'ID' => __( 'Indonesia', 'google-analytics-for-wordpress' ),
473
- 'IR' => __( 'Iran', 'google-analytics-for-wordpress' ),
474
- 'IQ' => __( 'Iraq', 'google-analytics-for-wordpress' ),
475
- 'IE' => __( 'Ireland', 'google-analytics-for-wordpress' ),
476
- 'IM' => __( 'Isle of Man', 'google-analytics-for-wordpress' ),
477
- 'IL' => __( 'Israel', 'google-analytics-for-wordpress' ),
478
- 'IT' => __( 'Italy', 'google-analytics-for-wordpress' ),
479
- 'JM' => __( 'Jamaica', 'google-analytics-for-wordpress' ),
480
- 'JP' => __( 'Japan', 'google-analytics-for-wordpress' ),
481
- 'JE' => __( 'Jersey', 'google-analytics-for-wordpress' ),
482
- 'JO' => __( 'Jordan', 'google-analytics-for-wordpress' ),
483
- 'KZ' => __( 'Kazakhstan', 'google-analytics-for-wordpress' ),
484
- 'KE' => __( 'Kenya', 'google-analytics-for-wordpress' ),
485
- 'KI' => __( 'Kiribati', 'google-analytics-for-wordpress' ),
486
- 'KW' => __( 'Kuwait', 'google-analytics-for-wordpress' ),
487
- 'KG' => __( 'Kyrgyzstan', 'google-analytics-for-wordpress' ),
488
- 'LA' => __( 'Lao People\'s Democratic Republic', 'google-analytics-for-wordpress' ),
489
- 'LV' => __( 'Latvia', 'google-analytics-for-wordpress' ),
490
- 'LB' => __( 'Lebanon', 'google-analytics-for-wordpress' ),
491
- 'LS' => __( 'Lesotho', 'google-analytics-for-wordpress' ),
492
- 'LR' => __( 'Liberia', 'google-analytics-for-wordpress' ),
493
- 'LY' => __( 'Libyan Arab Jamahiriya', 'google-analytics-for-wordpress' ),
494
- 'LI' => __( 'Liechtenstein', 'google-analytics-for-wordpress' ),
495
- 'LT' => __( 'Lithuania', 'google-analytics-for-wordpress' ),
496
- 'LU' => __( 'Luxembourg', 'google-analytics-for-wordpress' ),
497
- 'MO' => __( 'Macau', 'google-analytics-for-wordpress' ),
498
- 'MK' => __( 'Macedonia (FYROM)', 'google-analytics-for-wordpress' ),
499
- 'MG' => __( 'Madagascar', 'google-analytics-for-wordpress' ),
500
- 'MW' => __( 'Malawi', 'google-analytics-for-wordpress' ),
501
- 'MY' => __( 'Malaysia', 'google-analytics-for-wordpress' ),
502
- 'MV' => __( 'Maldives', 'google-analytics-for-wordpress' ),
503
- 'ML' => __( 'Mali', 'google-analytics-for-wordpress' ),
504
- 'MT' => __( 'Malta', 'google-analytics-for-wordpress' ),
505
- 'MH' => __( 'Marshall Islands', 'google-analytics-for-wordpress' ),
506
- 'MQ' => __( 'Martinique', 'google-analytics-for-wordpress' ),
507
- 'MR' => __( 'Mauritania', 'google-analytics-for-wordpress' ),
508
- 'MU' => __( 'Mauritius', 'google-analytics-for-wordpress' ),
509
- 'YT' => __( 'Mayotte', 'google-analytics-for-wordpress' ),
510
- 'MX' => __( 'Mexico', 'google-analytics-for-wordpress' ),
511
- 'FM' => __( 'Micronesia', 'google-analytics-for-wordpress' ),
512
- 'MD' => __( 'Moldova, Republic of', 'google-analytics-for-wordpress' ),
513
- 'MC' => __( 'Monaco', 'google-analytics-for-wordpress' ),
514
- 'MN' => __( 'Mongolia', 'google-analytics-for-wordpress' ),
515
- 'ME' => __( 'Montenegro', 'google-analytics-for-wordpress' ),
516
- 'MS' => __( 'Montserrat', 'google-analytics-for-wordpress' ),
517
- 'MA' => __( 'Morocco', 'google-analytics-for-wordpress' ),
518
- 'MZ' => __( 'Mozambique', 'google-analytics-for-wordpress' ),
519
- 'MM' => __( 'Myanmar', 'google-analytics-for-wordpress' ),
520
- 'NA' => __( 'Namibia', 'google-analytics-for-wordpress' ),
521
- 'NR' => __( 'Nauru', 'google-analytics-for-wordpress' ),
522
- 'NP' => __( 'Nepal', 'google-analytics-for-wordpress' ),
523
- 'NL' => __( 'Netherlands', 'google-analytics-for-wordpress' ),
524
- 'AN' => __( 'Netherlands Antilles', 'google-analytics-for-wordpress' ),
525
- 'NC' => __( 'New Caledonia', 'google-analytics-for-wordpress' ),
526
- 'NZ' => __( 'New Zealand', 'google-analytics-for-wordpress' ),
527
- 'NI' => __( 'Nicaragua', 'google-analytics-for-wordpress' ),
528
- 'NE' => __( 'Niger', 'google-analytics-for-wordpress' ),
529
- 'NG' => __( 'Nigeria', 'google-analytics-for-wordpress' ),
530
- 'NU' => __( 'Niue', 'google-analytics-for-wordpress' ),
531
- 'NF' => __( 'Norfolk Island', 'google-analytics-for-wordpress' ),
532
- 'KP' => __( 'North Korea', 'google-analytics-for-wordpress' ),
533
- 'MP' => __( 'Northern Mariana Islands', 'google-analytics-for-wordpress' ),
534
- 'NO' => __( 'Norway', 'google-analytics-for-wordpress' ),
535
- 'OM' => __( 'Oman', 'google-analytics-for-wordpress' ),
536
- 'PK' => __( 'Pakistan', 'google-analytics-for-wordpress' ),
537
- 'PW' => __( 'Palau', 'google-analytics-for-wordpress' ),
538
- 'PS' => __( 'Palestinian Territories', 'google-analytics-for-wordpress' ),
539
- 'PA' => __( 'Panama', 'google-analytics-for-wordpress' ),
540
- 'PG' => __( 'Papua New Guinea', 'google-analytics-for-wordpress' ),
541
- 'PY' => __( 'Paraguay', 'google-analytics-for-wordpress' ),
542
- 'PE' => __( 'Peru', 'google-analytics-for-wordpress' ),
543
- 'PH' => __( 'Philippines', 'google-analytics-for-wordpress' ),
544
- 'PN' => __( 'Pitcairn Island', 'google-analytics-for-wordpress' ),
545
- 'PL' => __( 'Poland', 'google-analytics-for-wordpress' ),
546
- 'PT' => __( 'Portugal', 'google-analytics-for-wordpress' ),
547
- 'PR' => __( 'Puerto Rico', 'google-analytics-for-wordpress' ),
548
- 'QA' => __( 'Qatar', 'google-analytics-for-wordpress' ),
549
- 'XK' => __( 'Republic of Kosovo', 'google-analytics-for-wordpress' ),
550
- 'RE' => __( 'Reunion Island', 'google-analytics-for-wordpress' ),
551
- 'RO' => __( 'Romania', 'google-analytics-for-wordpress' ),
552
- 'RU' => __( 'Russian Federation', 'google-analytics-for-wordpress' ),
553
- 'RW' => __( 'Rwanda', 'google-analytics-for-wordpress' ),
554
- 'BL' => __( 'Saint Barth&eacute;lemy', 'google-analytics-for-wordpress' ),
555
- 'SH' => __( 'Saint Helena', 'google-analytics-for-wordpress' ),
556
- 'KN' => __( 'Saint Kitts and Nevis', 'google-analytics-for-wordpress' ),
557
- 'LC' => __( 'Saint Lucia', 'google-analytics-for-wordpress' ),
558
- 'MF' => __( 'Saint Martin (French)', 'google-analytics-for-wordpress' ),
559
- 'SX' => __( 'Saint Martin (Dutch)', 'google-analytics-for-wordpress' ),
560
- 'PM' => __( 'Saint Pierre and Miquelon', 'google-analytics-for-wordpress' ),
561
- 'VC' => __( 'Saint Vincent and the Grenadines', 'google-analytics-for-wordpress' ),
562
- 'SM' => __( 'San Marino', 'google-analytics-for-wordpress' ),
563
- 'ST' => __( 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe', 'google-analytics-for-wordpress' ),
564
- 'SA' => __( 'Saudi Arabia', 'google-analytics-for-wordpress' ),
565
- 'SN' => __( 'Senegal', 'google-analytics-for-wordpress' ),
566
- 'RS' => __( 'Serbia', 'google-analytics-for-wordpress' ),
567
- 'SC' => __( 'Seychelles', 'google-analytics-for-wordpress' ),
568
- 'SL' => __( 'Sierra Leone', 'google-analytics-for-wordpress' ),
569
- 'SG' => __( 'Singapore', 'google-analytics-for-wordpress' ),
570
- 'SK' => __( 'Slovak Republic', 'google-analytics-for-wordpress' ),
571
- 'SI' => __( 'Slovenia', 'google-analytics-for-wordpress' ),
572
- 'SB' => __( 'Solomon Islands', 'google-analytics-for-wordpress' ),
573
- 'SO' => __( 'Somalia', 'google-analytics-for-wordpress' ),
574
- 'ZA' => __( 'South Africa', 'google-analytics-for-wordpress' ),
575
- 'GS' => __( 'South Georgia', 'google-analytics-for-wordpress' ),
576
- 'KR' => __( 'South Korea', 'google-analytics-for-wordpress' ),
577
- 'SS' => __( 'South Sudan', 'google-analytics-for-wordpress' ),
578
- 'ES' => __( 'Spain', 'google-analytics-for-wordpress' ),
579
- 'LK' => __( 'Sri Lanka', 'google-analytics-for-wordpress' ),
580
- 'SD' => __( 'Sudan', 'google-analytics-for-wordpress' ),
581
- 'SR' => __( 'Suriname', 'google-analytics-for-wordpress' ),
582
- 'SJ' => __( 'Svalbard and Jan Mayen Islands', 'google-analytics-for-wordpress' ),
583
- 'SZ' => __( 'Swaziland', 'google-analytics-for-wordpress' ),
584
- 'SE' => __( 'Sweden', 'google-analytics-for-wordpress' ),
585
- 'CH' => __( 'Switzerland', 'google-analytics-for-wordpress' ),
586
- 'SY' => __( 'Syrian Arab Republic', 'google-analytics-for-wordpress' ),
587
- 'TW' => __( 'Taiwan', 'google-analytics-for-wordpress' ),
588
- 'TJ' => __( 'Tajikistan', 'google-analytics-for-wordpress' ),
589
- 'TZ' => __( 'Tanzania', 'google-analytics-for-wordpress' ),
590
- 'TH' => __( 'Thailand', 'google-analytics-for-wordpress' ),
591
- 'TL' => __( 'Timor-Leste', 'google-analytics-for-wordpress' ),
592
- 'TG' => __( 'Togo', 'google-analytics-for-wordpress' ),
593
- 'TK' => __( 'Tokelau', 'google-analytics-for-wordpress' ),
594
- 'TO' => __( 'Tonga', 'google-analytics-for-wordpress' ),
595
- 'TT' => __( 'Trinidad and Tobago', 'google-analytics-for-wordpress' ),
596
- 'TN' => __( 'Tunisia', 'google-analytics-for-wordpress' ),
597
- 'TR' => __( 'Turkey', 'google-analytics-for-wordpress' ),
598
- 'TM' => __( 'Turkmenistan', 'google-analytics-for-wordpress' ),
599
- 'TC' => __( 'Turks and Caicos Islands', 'google-analytics-for-wordpress' ),
600
- 'TV' => __( 'Tuvalu', 'google-analytics-for-wordpress' ),
601
- 'UG' => __( 'Uganda', 'google-analytics-for-wordpress' ),
602
- 'UA' => __( 'Ukraine', 'google-analytics-for-wordpress' ),
603
- 'AE' => __( 'United Arab Emirates', 'google-analytics-for-wordpress' ),
604
- 'UY' => __( 'Uruguay', 'google-analytics-for-wordpress' ),
605
- 'UM' => __( 'US Minor Outlying Islands', 'google-analytics-for-wordpress' ),
606
- 'UZ' => __( 'Uzbekistan', 'google-analytics-for-wordpress' ),
607
- 'VU' => __( 'Vanuatu', 'google-analytics-for-wordpress' ),
608
- 'VE' => __( 'Venezuela', 'google-analytics-for-wordpress' ),
609
- 'VN' => __( 'Vietnam', 'google-analytics-for-wordpress' ),
610
- 'VG' => __( 'Virgin Islands (British)', 'google-analytics-for-wordpress' ),
611
- 'VI' => __( 'Virgin Islands (USA)', 'google-analytics-for-wordpress' ),
612
- 'WF' => __( 'Wallis and Futuna Islands', 'google-analytics-for-wordpress' ),
613
- 'EH' => __( 'Western Sahara', 'google-analytics-for-wordpress' ),
614
- 'WS' => __( 'Western Samoa', 'google-analytics-for-wordpress' ),
615
- 'YE' => __( 'Yemen', 'google-analytics-for-wordpress' ),
616
- 'ZM' => __( 'Zambia', 'google-analytics-for-wordpress' ),
617
- 'ZW' => __( 'Zimbabwe', 'google-analytics-for-wordpress' ),
618
- );
619
- } else {
620
- $countries = array(
621
- '' => '',
622
- 'US' => 'United States',
623
- 'CA' => 'Canada',
624
- 'GB' => 'United Kingdom',
625
- 'AF' => 'Afghanistan',
626
- 'AX' => '&#197;land Islands',
627
- 'AL' => 'Albania',
628
- 'DZ' => 'Algeria',
629
- 'AS' => 'American Samoa',
630
- 'AD' => 'Andorra',
631
- 'AO' => 'Angola',
632
- 'AI' => 'Anguilla',
633
- 'AQ' => 'Antarctica',
634
- 'AG' => 'Antigua and Barbuda',
635
- 'AR' => 'Argentina',
636
- 'AM' => 'Armenia',
637
- 'AW' => 'Aruba',
638
- 'AU' => 'Australia',
639
- 'AT' => 'Austria',
640
- 'AZ' => 'Azerbaijan',
641
- 'BS' => 'Bahamas',
642
- 'BH' => 'Bahrain',
643
- 'BD' => 'Bangladesh',
644
- 'BB' => 'Barbados',
645
- 'BY' => 'Belarus',
646
- 'BE' => 'Belgium',
647
- 'BZ' => 'Belize',
648
- 'BJ' => 'Benin',
649
- 'BM' => 'Bermuda',
650
- 'BT' => 'Bhutan',
651
- 'BO' => 'Bolivia',
652
- 'BQ' => 'Bonaire, Saint Eustatius and Saba',
653
- 'BA' => 'Bosnia and Herzegovina',
654
- 'BW' => 'Botswana',
655
- 'BV' => 'Bouvet Island',
656
- 'BR' => 'Brazil',
657
- 'IO' => 'British Indian Ocean Territory',
658
- 'BN' => 'Brunei Darrussalam',
659
- 'BG' => 'Bulgaria',
660
- 'BF' => 'Burkina Faso',
661
- 'BI' => 'Burundi',
662
- 'KH' => 'Cambodia',
663
- 'CM' => 'Cameroon',
664
- 'CV' => 'Cape Verde',
665
- 'KY' => 'Cayman Islands',
666
- 'CF' => 'Central African Republic',
667
- 'TD' => 'Chad',
668
- 'CL' => 'Chile',
669
- 'CN' => 'China',
670
- 'CX' => 'Christmas Island',
671
- 'CC' => 'Cocos Islands',
672
- 'CO' => 'Colombia',
673
- 'KM' => 'Comoros',
674
- 'CD' => 'Congo, Democratic People\'s Republic',
675
- 'CG' => 'Congo, Republic of',
676
- 'CK' => 'Cook Islands',
677
- 'CR' => 'Costa Rica',
678
- 'CI' => 'Cote d\'Ivoire',
679
- 'HR' => 'Croatia/Hrvatska',
680
- 'CU' => 'Cuba',
681
- 'CW' => 'Cura&Ccedil;ao',
682
- 'CY' => 'Cyprus',
683
- 'CZ' => 'Czechia',
684
- 'DK' => 'Denmark',
685
- 'DJ' => 'Djibouti',
686
- 'DM' => 'Dominica',
687
- 'DO' => 'Dominican Republic',
688
- 'TP' => 'East Timor',
689
- 'EC' => 'Ecuador',
690
- 'EG' => 'Egypt',
691
- 'GQ' => 'Equatorial Guinea',
692
- 'SV' => 'El Salvador',
693
- 'ER' => 'Eritrea',
694
- 'EE' => 'Estonia',
695
- 'ET' => 'Ethiopia',
696
- 'FK' => 'Falkland Islands',
697
- 'FO' => 'Faroe Islands',
698
- 'FJ' => 'Fiji',
699
- 'FI' => 'Finland',
700
- 'FR' => 'France',
701
- 'GF' => 'French Guiana',
702
- 'PF' => 'French Polynesia',
703
- 'TF' => 'French Southern Territories',
704
- 'GA' => 'Gabon',
705
- 'GM' => 'Gambia',
706
- 'GE' => 'Georgia',
707
- 'DE' => 'Germany',
708
- 'GR' => 'Greece',
709
- 'GH' => 'Ghana',
710
- 'GI' => 'Gibraltar',
711
- 'GL' => 'Greenland',
712
- 'GD' => 'Grenada',
713
- 'GP' => 'Guadeloupe',
714
- 'GU' => 'Guam',
715
- 'GT' => 'Guatemala',
716
- 'GG' => 'Guernsey',
717
- 'GN' => 'Guinea',
718
- 'GW' => 'Guinea-Bissau',
719
- 'GY' => 'Guyana',
720
- 'HT' => 'Haiti',
721
- 'HM' => 'Heard and McDonald Islands',
722
- 'VA' => 'Holy See (City Vatican State)',
723
- 'HN' => 'Honduras',
724
- 'HK' => 'Hong Kong',
725
- 'HU' => 'Hungary',
726
- 'IS' => 'Iceland',
727
- 'IN' => 'India',
728
- 'ID' => 'Indonesia',
729
- 'IR' => 'Iran',
730
- 'IQ' => 'Iraq',
731
- 'IE' => 'Ireland',
732
- 'IM' => 'Isle of Man',
733
- 'IL' => 'Israel',
734
- 'IT' => 'Italy',
735
- 'JM' => 'Jamaica',
736
- 'JP' => 'Japan',
737
- 'JE' => 'Jersey',
738
- 'JO' => 'Jordan',
739
- 'KZ' => 'Kazakhstan',
740
- 'KE' => 'Kenya',
741
- 'KI' => 'Kiribati',
742
- 'KW' => 'Kuwait',
743
- 'KG' => 'Kyrgyzstan',
744
- 'LA' => 'Lao People\'s Democratic Republic',
745
- 'LV' => 'Latvia',
746
- 'LB' => 'Lebanon',
747
- 'LS' => 'Lesotho',
748
- 'LR' => 'Liberia',
749
- 'LY' => 'Libyan Arab Jamahiriya',
750
- 'LI' => 'Liechtenstein',
751
- 'LT' => 'Lithuania',
752
- 'LU' => 'Luxembourg',
753
- 'MO' => 'Macau',
754
- 'MK' => 'Macedonia',
755
- 'MG' => 'Madagascar',
756
- 'MW' => 'Malawi',
757
- 'MY' => 'Malaysia',
758
- 'MV' => 'Maldives',
759
- 'ML' => 'Mali',
760
- 'MT' => 'Malta',
761
- 'MH' => 'Marshall Islands',
762
- 'MQ' => 'Martinique',
763
- 'MR' => 'Mauritania',
764
- 'MU' => 'Mauritius',
765
- 'YT' => 'Mayotte',
766
- 'MX' => 'Mexico',
767
- 'FM' => 'Micronesia',
768
- 'MD' => 'Moldova, Republic of',
769
- 'MC' => 'Monaco',
770
- 'MN' => 'Mongolia',
771
- 'ME' => 'Montenegro',
772
- 'MS' => 'Montserrat',
773
- 'MA' => 'Morocco',
774
- 'MZ' => 'Mozambique',
775
- 'MM' => 'Myanmar (Burma)',
776
- 'NA' => 'Namibia',
777
- 'NR' => 'Nauru',
778
- 'NP' => 'Nepal',
779
- 'NL' => 'Netherlands',
780
- 'AN' => 'Netherlands Antilles',
781
- 'NC' => 'New Caledonia',
782
- 'NZ' => 'New Zealand',
783
- 'NI' => 'Nicaragua',
784
- 'NE' => 'Niger',
785
- 'NG' => 'Nigeria',
786
- 'NU' => 'Niue',
787
- 'NF' => 'Norfolk Island',
788
- 'KP' => 'North Korea',
789
- 'MP' => 'Northern Mariana Islands',
790
- 'NO' => 'Norway',
791
- 'OM' => 'Oman',
792
- 'PK' => 'Pakistan',
793
- 'PW' => 'Palau',
794
- 'PS' => 'Palestinian Territories',
795
- 'PA' => 'Panama',
796
- 'PG' => 'Papua New Guinea',
797
- 'PY' => 'Paraguay',
798
- 'PE' => 'Peru',
799
- 'PH' => 'Philippines',
800
- 'PN' => 'Pitcairn Island',
801
- 'PL' => 'Poland',
802
- 'PT' => 'Portugal',
803
- 'PR' => 'Puerto Rico',
804
- 'QA' => 'Qatar',
805
- 'XK' => 'Republic of Kosovo',
806
- 'RE' => 'Reunion Island',
807
- 'RO' => 'Romania',
808
- 'RU' => 'Russia',
809
- 'RW' => 'Rwanda',
810
- 'BL' => 'Saint Barth&eacute;lemy',
811
- 'SH' => 'Saint Helena',
812
- 'KN' => 'Saint Kitts and Nevis',
813
- 'LC' => 'Saint Lucia',
814
- 'MF' => 'Saint Martin (French)',
815
- 'SX' => 'Saint Martin (Dutch)',
816
- 'PM' => 'Saint Pierre and Miquelon',
817
- 'VC' => 'Saint Vincent and the Grenadines',
818
- 'SM' => 'San Marino',
819
- 'ST' => 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe',
820
- 'SA' => 'Saudi Arabia',
821
- 'SN' => 'Senegal',
822
- 'RS' => 'Serbia',
823
- 'SC' => 'Seychelles',
824
- 'SL' => 'Sierra Leone',
825
- 'SG' => 'Singapore',
826
- 'SK' => 'Slovak Republic',
827
- 'SI' => 'Slovenia',
828
- 'SB' => 'Solomon Islands',
829
- 'SO' => 'Somalia',
830
- 'ZA' => 'South Africa',
831
- 'GS' => 'South Georgia',
832
- 'KR' => 'South Korea',
833
- 'SS' => 'South Sudan',
834
- 'ES' => 'Spain',
835
- 'LK' => 'Sri Lanka',
836
- 'SD' => 'Sudan',
837
- 'SR' => 'Suriname',
838
- 'SJ' => 'Svalbard and Jan Mayen Islands',
839
- 'SZ' => 'Swaziland',
840
- 'SE' => 'Sweden',
841
- 'CH' => 'Switzerland',
842
- 'SY' => 'Syrian Arab Republic',
843
- 'TW' => 'Taiwan',
844
- 'TJ' => 'Tajikistan',
845
- 'TZ' => 'Tanzania',
846
- 'TH' => 'Thailand',
847
- 'TL' => 'Timor-Leste',
848
- 'TG' => 'Togo',
849
- 'TK' => 'Tokelau',
850
- 'TO' => 'Tonga',
851
- 'TT' => 'Trinidad and Tobago',
852
- 'TN' => 'Tunisia',
853
- 'TR' => 'Turkey',
854
- 'TM' => 'Turkmenistan',
855
- 'TC' => 'Turks and Caicos Islands',
856
- 'TV' => 'Tuvalu',
857
- 'UG' => 'Uganda',
858
- 'UA' => 'Ukraine',
859
- 'AE' => 'United Arab Emirates',
860
- 'UY' => 'Uruguay',
861
- 'UM' => 'US Minor Outlying Islands',
862
- 'UZ' => 'Uzbekistan',
863
- 'VU' => 'Vanuatu',
864
- 'VE' => 'Venezuela',
865
- 'VN' => 'Vietnam',
866
- 'VG' => 'Virgin Islands (British)',
867
- 'VI' => 'Virgin Islands (USA)',
868
- 'WF' => 'Wallis and Futuna Islands',
869
- 'EH' => 'Western Sahara',
870
- 'WS' => 'Western Samoa',
871
- 'YE' => 'Yemen',
872
- 'ZM' => 'Zambia',
873
- 'ZW' => 'Zimbabwe',
874
- );
875
- }
876
- return $countries;
877
- }
878
-
879
- function monsterinsights_get_api_url(){
880
- return apply_filters( 'monsterinsights_get_api_url', 'api.monsterinsights.com/v2/' );
881
- }
882
-
883
- function monsterinsights_get_licensing_url(){
884
- return apply_filters( 'monsterinsights_get_licensing_url', 'https://www.monsterinsights.com' );
885
- }
886
-
887
- function monsterinsights_is_wp_seo_active( ) {
888
- $wp_seo_active = false; // @todo: improve this check. This is from old Yoast code.
889
-
890
- // Makes sure is_plugin_active is available when called from front end
891
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
892
- if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) {
893
- $wp_seo_active = true;
894
- }
895
- return $wp_seo_active;
896
- }
897
-
898
- function monsterinsights_get_asset_version() {
899
- if ( monsterinsights_is_debug_mode() || ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ) {
900
- return time();
901
- } else {
902
- return MONSTERINSIGHTS_VERSION;
903
- }
904
- }
905
-
906
- function monsterinsights_is_debug_mode() {
907
- $debug_mode = false;
908
- if ( defined( 'MONSTERINSIGHTS_DEBUG_MODE' ) && MONSTERINSIGHTS_DEBUG_MODE ) {
909
- $debug_mode = true;
910
- }
911
-
912
- return apply_filters( 'monsterinsights_is_debug_mode', $debug_mode );
913
- }
914
-
915
- function monsterinsights_is_network_active() {
916
- if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
917
- require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
918
- }
919
-
920
- if ( is_multisite() && is_plugin_active_for_network( plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ) ) ) {
921
- return true;
922
- } else {
923
- return false;
924
- }
925
- }
926
-
927
- if ( ! function_exists ( 'remove_class_filter' ) ) {
928
- /**
929
- * Remove Class Filter Without Access to Class Object
930
- *
931
- * In order to use the core WordPress remove_filter() on a filter added with the callback
932
- * to a class, you either have to have access to that class object, or it has to be a call
933
- * to a static method. This method allows you to remove filters with a callback to a class
934
- * you don't have access to.
935
- *
936
- * Works with WordPress 1.2 - 4.7+
937
- *
938
- * @param string $tag Filter to remove
939
- * @param string $class_name Class name for the filter's callback
940
- * @param string $method_name Method name for the filter's callback
941
- * @param int $priority Priority of the filter (default 10)
942
- *
943
- * @return bool Whether the function is removed.
944
- */
945
- function remove_class_filter( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
946
- global $wp_filter;
947
- // Check that filter actually exists first
948
- if ( ! isset( $wp_filter[ $tag ] ) ) return FALSE;
949
- /**
950
- * If filter config is an object, means we're using WordPress 4.7+ and the config is no longer
951
- * a simple array, rather it is an object that implements the ArrayAccess interface.
952
- *
953
- * To be backwards compatible, we set $callbacks equal to the correct array as a reference (so $wp_filter is updated)
954
- *
955
- * @see https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/
956
- */
957
- if ( is_object( $wp_filter[ $tag ] ) && isset( $wp_filter[ $tag ]->callbacks ) ) {
958
- $callbacks = &$wp_filter[ $tag ]->callbacks;
959
- } else {
960
- $callbacks = &$wp_filter[ $tag ];
961
- }
962
- // Exit if there aren't any callbacks for specified priority
963
- if ( ! isset( $callbacks[ $priority ] ) || empty( $callbacks[ $priority ] ) ) return FALSE;
964
- // Loop through each filter for the specified priority, looking for our class & method
965
- foreach( (array) $callbacks[ $priority ] as $filter_id => $filter ) {
966
- // Filter should always be an array - array( $this, 'method' ), if not goto next
967
- if ( ! isset( $filter[ 'function' ] ) || ! is_array( $filter[ 'function' ] ) ) continue;
968
- // If first value in array is not an object, it can't be a class
969
- if ( ! is_object( $filter[ 'function' ][ 0 ] ) ) continue;
970
- // Method doesn't match the one we're looking for, goto next
971
- if ( $filter[ 'function' ][ 1 ] !== $method_name ) continue;
972
- // Method matched, now let's check the Class
973
- if ( get_class( $filter[ 'function' ][ 0 ] ) === $class_name ) {
974
- // Now let's remove it from the array
975
- unset( $callbacks[ $priority ][ $filter_id ] );
976
- // and if it was the only filter in that priority, unset that priority
977
- if ( empty( $callbacks[ $priority ] ) ) unset( $callbacks[ $priority ] );
978
- // and if the only filter for that tag, set the tag to an empty array
979
- if ( empty( $callbacks ) ) $callbacks = array();
980
- // If using WordPress older than 4.7
981
- if ( ! is_object( $wp_filter[ $tag ] ) ) {
982
- // Remove this filter from merged_filters, which specifies if filters have been sorted
983
- unset( $GLOBALS[ 'merged_filters' ][ $tag ] );
984
- }
985
- return TRUE;
986
- }
987
- }
988
- return FALSE;
989
- }
990
- } // End function exists
991
-
992
- if ( ! function_exists ( 'remove_class_action' ) ) {
993
- /**
994
- * Remove Class Action Without Access to Class Object
995
- *
996
- * In order to use the core WordPress remove_action() on an action added with the callback
997
- * to a class, you either have to have access to that class object, or it has to be a call
998
- * to a static method. This method allows you to remove actions with a callback to a class
999
- * you don't have access to.
1000
- *
1001
- * Works with WordPress 1.2 - 4.7+
1002
- *
1003
- * @param string $tag Action to remove
1004
- * @param string $class_name Class name for the action's callback
1005
- * @param string $method_name Method name for the action's callback
1006
- * @param int $priority Priority of the action (default 10)
1007
- *
1008
- * @return bool Whether the function is removed.
1009
- */
1010
- function remove_class_action( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
1011
- remove_class_filter( $tag, $class_name, $method_name, $priority );
1012
- }
1013
- } // End function exists
1014
-
1015
- /**
1016
- * Format a big number, instead of 1000000 you get 1.0M, works with billions also.
1017
- *
1018
- * @param int $number
1019
- * @param int $precision
1020
- *
1021
- * @return string
1022
- */
1023
- function monsterinsights_round_number( $number, $precision = 2 ) {
1024
-
1025
- if ( $number < 1000000 ) {
1026
- // Anything less than a million
1027
- $number = number_format_i18n( $number );
1028
- } else if ( $number < 1000000000 ) {
1029
- // Anything less than a billion
1030
- $number = number_format_i18n( $number / 1000000, $precision ) . 'M';
1031
- } else {
1032
- // At least a billion
1033
- $number = number_format_i18n( $number / 1000000000, $precision ) . 'B';
1034
- }
1035
-
1036
- return $number;
1037
- }
1038
-
1039
- if ( ! function_exists( 'wp_get_jed_locale_data' ) ) {
1040
- /**
1041
- * Returns Jed-formatted localization data. Added for backwards-compatibility.
1042
- *
1043
- * @param string $domain Translation domain.
1044
- *
1045
- * @return array
1046
- */
1047
- function wp_get_jed_locale_data( $domain ) {
1048
- $translations = get_translations_for_domain( $domain );
1049
-
1050
- $locale = array(
1051
- '' => array(
1052
- 'domain' => $domain,
1053
- 'lang' => is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(),
1054
- ),
1055
- );
1056
-
1057
- if ( ! empty( $translations->headers['Plural-Forms'] ) ) {
1058
- $locale['']['plural_forms'] = $translations->headers['Plural-Forms'];
1059
- }
1060
-
1061
- foreach ( $translations->entries as $msgid => $entry ) {
1062
- $locale[ $msgid ] = $entry->translations;
1063
- }
1064
-
1065
- return $locale;
1066
- }
1067
- }
1068
-
1069
- function monsterinsights_get_inline_menu_icon() {
1070
- $scheme = get_user_option( 'admin_color', get_current_user_id() );
1071
- $use_dark_scheme = $scheme === 'light';
1072
- if ( $use_dark_scheme ) {
1073
- return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAFQUlEQVRYha2Yb2hXZRTHP+c3nc6pm07NF0KWWUtSo0wqzBdiZRItTKMaEZXSi0zRNAsqTBKKSFOa0B8Jigqz2lSwLMtqRURgRuCCLLNmselyZups2+/04pzbnt3de3eTDlzufc5znvN8n+ec55zzXFFV8pKITANOqmpTP3JTgIKq7sutPCJVzfUABeAb4DSwMENuKdABNObV3Wv8fwB0C6DAUX8/67sQ9Q8ANsVk5v5vgIDKWHsvcAgYCWzzCbc6kFJgh/PqgVHAb8DnWTpzA3LzHARmeXuqT/Zo0L/eeZuAV/x7fbRrwJPOu9Dbc4EDgJwNoMmurAt4Bljt7cmBjACvOl+BzTEdVzj/EWAj0O3tC84G0AIf3BRMeDz0GZcbBvzqKy+L9Q30A6AxXTdmARqQcPAAyv29CBjjO1RU1SKAiIwGFgLX+MrbgBnAh5ECVe0UkUMO6nHgFLA70J1McacD5gHbfTXzg77qwBeOBysPn830PnnVwXety7wL1AAV/ZoM+MIHdQCfAdfF+s8H/koBEz0rU9xgLtAInHG5j/KYrNWf8ap6OmFD7w+2/Cugwd/NmOkqgbIUS+wEdorIEOAwFqv6UBKgihQwANNc0b2quh1ARIZi/nUqZUycOrDDcCSps5AAaJBPkkStwNVAs4i8JiLHgBPASRFpFZEGEZktIpIBqBIoIWWH4nZegtl3fIofjAKeoyemfAe8hZnu64D/NjAsRcdEl1mcx6lvc+HLU6L3O97/JXBlgszF9KSVvXhswkxUC6wLdKzIA2iWC1+fMNlK72sASlMjrQHf4LIvAw8B7fScwmNAZ7DDs7MARSmjNsYf7oqak0wBjAXuBlb5Lo9wE0Yg6rHAOdjlR2KB9Qc384o0QOe4giUx/u3OX5oA5gEsCoexqBnYAxTTfMXHlvuOF4F5SYBKHPGaGH+jTzQxxefSnnVpYAIdg9x0PwEDkwSOAHUx3hafoDzGP5AB5gQ56h/XU+NjauJxCCxRjo7xOvw9ImKISBUwIWF8RLtVtT2jP6SdWBKe1QuQiCwDLsKcNKSoqJ8e8BJTREAHc4JBVTuBn4Gx/wISkflYndyNOXdI2/29OOAd7mfSIXkBOZUDxTACt2A78SLQnmDnBszOiwLeraT70Ld5/Mf1jPMxqyLGWqxcnYoFMqVvBTgOK9y7gOVAifMfdF4SqJk5Aa3FLFMNduxagQbvvJOUfIb51/f0lKSrsROyHCtlIyDtrrMJqOoHzAysRvrA28wmSBfAtd7uk6u8vwwr/JOqxm4sl01wvZ3AfhJyo+taAPyJhYi/gekCPIXdNitV9YyIXIIFqptVdVsf13MSkVJgJlZF4rvSqKq/BzJzgNexcPEp8LFPXAHcAFzqoKcAddjR5z2Cay/m4Arcl9cp+zFJFfA0dslMOwB1wD1AewGrTw4Ei2/zVcSP/lmRqrap6irs8gAwid7xDOAuzNwlgmXxF1T14ahXRPZjtU1k3+g5Tk8pkUUFzCwVWC003N/DgGVYIXheIF/EfmQcFczDW4DnsVtBCxbUtmIOPAAzY6MPLgMG+/dlDrIADHWlYL4QpZuZWLjYgp3SOb7QMbFFFLF6LDNB7sGcri7FP7qwWmcX9t8oSWaDA6zCqomXUuZ6U1UpYDXxH5jfgKWET/y7zXfolIgkJeJMEpES/xwMXKWq3aq6CLu9PAH8Eog/Fn2UYnlkDWa2c719E3Y/f8NX0AL8GHuianAXtuXx/lZ6brR9/npgcWgHcEfEkyg6ZqyyBrt1ptE+X9SkDJl6VX0/cyKnfwBb6gwNaZ8ExgAAAABJRU5ErkJggg';
1074
- } else {
1075
- return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4AoEBjcfBsDvpwAABQBJREFUWMO1mGmollUQgJ9z79Vc01LLH0GLWRqlUhYV5o+LbRIVbVQSUSn9qJTKsqDCoqCINKUbtBEUFbbeDGyz1SIiaCHIINu18KZ1bbkuV+/Tj+arw8v7fvdVcuDjvGdmzsycM3Nm5nywE6BOVSfW4JukTmF3gtqifqJuVmc34ZunblFX7W6DzvYf2BDjPWpLRm9T7y/wzPw/DRhZmH+sfq/urb4YCp8JQwaqLwXuBXW0+pP6XjOZO+ueb9X2mE8OZTdl9MWBu199NL4XN05NvT1wh8R8prpGTbti0BEhbLt6t7ow5kdkPEl9zP/gkYKMowN/o7pU3RHzg3fFoHNj8epM4aY8ZoJvuPpj7HxwgTYgLoAFWac1091WgR8a4xxgH2Ah0JdS6gtlY4DZwAnADmAjMA14vSEgpdSrfg9sBm4BeoCVmex6gayepS6P3ZyT0SZksbDJcnikcPMmZN+zgud59Qx1RB2D3o9FW9R31ZMK9IPUP20O11XInqmuUrcG3xt1XNYVvwNSSptL+K/IjvxDoDPGteG6kcDgMkUppRXACnUIsA7YUNegERXGAEwNQZellJbHzodFfPXUjIwtwHDglzJiS4lBe4SSMugCjgfWqo+rvwF/AH+pXWqnOqOfXDMSaK06oaKf54Z/D6igj1bvzXLK5+rTYchHGf5ZdXiFjPHBc2Udg84P5qMqsvdzQf9APbaEZ2JWVj5u5KbIV7PURZmM+XUMag/mk0to1wWtUx3YT9lZErwPq9er3dkt/E3tzU54Rp2SMauA3zMErS1zhTpWvURdEKe8V7jQrOBOUwcF/97qbPWrcPP8KoP2DQFzC/gLAj+vZM1Vak8hF61V31L7msWKOjROvE89q4yhNSy+rYBfGorGV8RcFSyqESZ7hOu+UQeUMfyidhRwy0LB0AJ+TRNj/qjb/0QpUT2jpYS+ERhTkswA9sqEjALGNdGzMqXUXTNZrogi3F5sJ64GDgXGFhasjvGYDDe4HyXf1i3qKaVe4DtgbF6ZzwHuiZq0b2HN8hjzAF3Xj9IhO9mGDQX68gy8PpqoB9XuEj93hp/nZLjzmsTQZzvR9uwXaxY0EHdEuzo5EpklHeB+0bhvV69RWwN/beDKYHpNg+6I2z2hce261M4gXlRVz9RD1S+zlnRh3JBropVtQHfIXB3B38yYadEjvdZAzMjLhXpizI+tEDA4Gv+yrnFH1LJxIbdX/aKsNma9+++RIrapxyT1TmAeMDKltFU9HPgcODOl9GKTnQ0EpgMHBaobWJVS+jnjOQV4ItLFO8CbwDZgBHAqMAXoBSYBHcBm1JfzZ28EuOrl/9ODc5R6Vzwyq6BDvVTtbgHGA2sKiXFbydXfJUgpbUwpLQAateqwQj4DuDjSTWuKru+BlNIN2a6+ACYCv0dH2PhtCtfYjx0t4ZYR0a7uGeNw4GpgLnBgxt8HfAJsSOpWYD1wH7AqvocAz0Q2bgNGB62RoQfF95FhZAswLIQSZaBRbqYDPwHLogqcEhvdp7CJPqC9vwL5VtyUjor42B69zqvqXxU8S+IFOyq6iYcqdD3VONqngV8jbhol4e0sntqAnuIzumZAt8bnIOC4lNKOlNKceL3cCvyQsd/87/WNRuk29T51/5ifHu/zJ2MH69WvCz+zE+oroXdlL9pUkYdeUi/89xLU6VWAZn88fQoMjNtTBS+klF6pc6p/A2ye4OCYzm1lAAAAAElFTkSuQmCC';
1076
- }
1077
- }
1078
-
1079
-
1080
- function monsterinsights_get_shareasale_id() {
1081
- // Check if there's a constant.
1082
- $shareasale_id = '';
1083
- if ( defined( 'MONSTERINSIGHTS_SHAREASALE_ID' ) ) {
1084
- $shareasale_id = MONSTERINSIGHTS_SHAREASALE_ID;
1085
- }
1086
-
1087
- // If there's no constant, check if there's an option.
1088
- if ( empty( $shareasale_id ) ) {
1089
- $shareasale_id = get_option( 'monsterinsights_shareasale_id', '' );
1090
- }
1091
-
1092
- // Whether we have an ID or not, filter the ID.
1093
- $shareasale_id = apply_filters( 'monsterinsights_shareasale_id', $shareasale_id );
1094
-
1095
- // Ensure it's a number
1096
- $shareasale_id = absint( $shareasale_id );
1097
-
1098
- return $shareasale_id;
1099
- }
1100
-
1101
- // Passed in with mandatory default redirect and shareasaleid from monsterinsights_get_upgrade_link
1102
- function monsterinsights_get_shareasale_url( $shareasale_id, $shareasale_redirect ) {
1103
- // Check if there's a constant.
1104
- $custom = false;
1105
- if ( defined( 'MONSTERINSIGHTS_SHAREASALE_REDIRECT_URL' ) ) {
1106
- $shareasale_redirect = MONSTERINSIGHTS_SHAREASALE_REDIRECT_URL;
1107
- $custom = true;
1108
- }
1109
-
1110
- // If there's no constant, check if there's an option.
1111
- if ( empty( $custom ) ) {
1112
- $shareasale_redirect = get_option( 'monsterinsights_shareasale_redirect_url', '' );
1113
- $custom = true;
1114
- }
1115
-
1116
- // Whether we have an ID or not, filter the ID.
1117
- $shareasale_redirect = apply_filters( 'monsterinsights_shareasale_redirect_url', $shareasale_redirect, $custom );
1118
- $shareasale_url = sprintf( 'https://www.shareasale.com/r.cfm?B=971799&U=%s&M=69975&urllink=%s', $shareasale_id, $shareasale_redirect );
1119
- $shareasale_url = apply_filters( 'monsterinsights_shareasale_redirect_entire_url', $shareasale_url, $shareasale_id, $shareasale_redirect );
1120
- return $shareasale_url;
1121
- }
1122
-
1123
- /**
1124
- * Get a clean page title for archives.
1125
- */
1126
- function monsterinsights_get_page_title() {
1127
-
1128
- $title = __( 'Archives' );
1129
-
1130
- if ( is_category() ) {
1131
- /* translators: Category archive title. %s: Category name */
1132
- $title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
1133
- } elseif ( is_tag() ) {
1134
- /* translators: Tag archive title. %s: Tag name */
1135
- $title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
1136
- } elseif ( is_author() ) {
1137
- /* translators: Author archive title. %s: Author name */
1138
- $title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
1139
- } elseif ( is_year() ) {
1140
- /* translators: Yearly archive title. %s: Year */
1141
- $title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
1142
- } elseif ( is_month() ) {
1143
- /* translators: Monthly archive title. %s: Month name and year */
1144
- $title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) );
1145
- } elseif ( is_day() ) {
1146
- /* translators: Daily archive title. %s: Date */
1147
- $title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) );
1148
- } elseif ( is_tax( 'post_format' ) ) {
1149
- if ( is_tax( 'post_format', 'post-format-aside' ) ) {
1150
- $title = _x( 'Asides', 'post format archive title' );
1151
- } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
1152
- $title = _x( 'Galleries', 'post format archive title' );
1153
- } elseif ( is_tax( 'post_format', 'post-format-image' ) ) {
1154
- $title = _x( 'Images', 'post format archive title' );
1155
- } elseif ( is_tax( 'post_format', 'post-format-video' ) ) {
1156
- $title = _x( 'Videos', 'post format archive title' );
1157
- } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) {
1158
- $title = _x( 'Quotes', 'post format archive title' );
1159
- } elseif ( is_tax( 'post_format', 'post-format-link' ) ) {
1160
- $title = _x( 'Links', 'post format archive title' );
1161
- } elseif ( is_tax( 'post_format', 'post-format-status' ) ) {
1162
- $title = _x( 'Statuses', 'post format archive title' );
1163
- } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) {
1164
- $title = _x( 'Audio', 'post format archive title' );
1165
- } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
1166
- $title = _x( 'Chats', 'post format archive title' );
1167
- }
1168
- } elseif ( is_post_type_archive() ) {
1169
- /* translators: Post type archive title. %s: Post type name */
1170
- $title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
1171
- } elseif ( is_tax() ) {
1172
- $tax = get_taxonomy( get_queried_object()->taxonomy );
1173
- /* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */
1174
- $title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
1175
- }
1176
-
1177
- return $title;
1178
-
1179
- }
1180
-
1181
- /**
1182
- * Make a request to the front page and check if the tracking code is present. Moved here from onboarding wizard
1183
- * to be used in the site health check.
1184
- *
1185
- * @return array
1186
- */
1187
- function monsterinsights_is_code_installed_frontend() {
1188
- // Grab the front page html.
1189
- $request = wp_remote_request( home_url(), array(
1190
- 'sslverify' => false,
1191
- ) );
1192
- $errors = array();
1193
-
1194
- if ( 200 === wp_remote_retrieve_response_code( $request ) ) {
1195
-
1196
- $body = wp_remote_retrieve_body( $request );
1197
- $current_ua_code = monsterinsights_get_ua_to_output();
1198
- $ua_limit = 2;
1199
- // If the ads addon is installed another UA is added to the page.
1200
- if ( class_exists( 'MonsterInsights_Ads' ) ) {
1201
- $ua_limit = 3;
1202
- }
1203
- // Translators: The placeholders are for making the "We noticed you're using a caching plugin" text bold.
1204
- $cache_error = sprintf( esc_html__( '%1$sWe noticed you\'re using a caching plugin or caching from your hosting provider.%2$s Be sure to clear the cache to ensure the tracking appears on all pages and posts. %3$s(See this guide on how to clear cache)%4$s.', 'google-analytics-for-wordpress' ), '<b>', '</b>', ' <a href="https://www.wpbeginner.com/beginners-guide/how-to-clear-your-cache-in-wordpress/" target="_blank">', '</a>' );
1205
- // Translators: The placeholders are for making the "We have detected multiple tracking codes" text bold & adding a link to support.
1206
- $multiple_ua_error = sprintf( esc_html__( '%1$sWe have detected multiple tracking codes%2$s! You should remove non-MonsterInsights ones. If you need help finding them please %3$sread this article%4$s.', 'google-analytics-for-wordpress' ), '<b>', '</b>', '<a href="https://www.monsterinsights.com/docs/how-to-find-duplicate-google-analytics-tracking-codes-in-wordpress/" target="_blank">', '</a>' );
1207
-
1208
- // First, check if the tracking frontend code is present.
1209
- if ( false === strpos( $body, '__gaTracker' ) ) {
1210
- $errors[] = $cache_error;
1211
- } else {
1212
- // Check if the current UA code is actually present.
1213
- if ( $current_ua_code && false === strpos( $body, $current_ua_code ) ) {
1214
- // We have the tracking code but using another UA, so it's cached.
1215
- $errors[] = $cache_error;
1216
- }
1217
- // Grab all the UA codes from the page.
1218
- $pattern = '/UA-[0-9]+/m';
1219
- preg_match_all( $pattern, $body, $matches );
1220
- // If more than twice ( because MI has a ga-disable-UA also ), let them know to remove the others.
1221
- if ( ! empty( $matches[0] ) && is_array( $matches[0] ) && count( $matches[0] ) > $ua_limit ) {
1222
- $errors[] = $multiple_ua_error;
1223
- }
1224
- }
1225
- }
1226
-
1227
- return $errors;
1228
- }
1229
-
1230
- /**
1231
- * Returns a HEX color to highlight menu items based on the admin color scheme.
1232
- */
1233
- function monsterinsights_menu_highlight_color() {
1234
-
1235
- $color_scheme = get_user_option( 'admin_color' );
1236
- $color = '#7cc048';
1237
- if ( 'light' === $color_scheme || 'blue' === $color_scheme ) {
1238
- $color = '#5f3ea7';
1239
- }
1240
-
1241
- return $color;
1242
- }
1243
-
1244
- /**
1245
- * Track Pretty Links redirects with MonsterInsights.
1246
- *
1247
- * @param string $url The url to which users get redirected.
1248
- */
1249
- function monsterinsights_custom_track_pretty_links_redirect( $url ) {
1250
- if ( ! function_exists( 'monsterinsights_mp_track_event_call' ) ) {
1251
- return;
1252
- }
1253
- // Try to determine if click originated on the same site.
1254
- $referer = ! empty( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '';
1255
- if ( ! empty( $referer ) ) {
1256
- $current_site_url = get_bloginfo( 'url' );
1257
- $current_site_parsed = wp_parse_url( $current_site_url );
1258
- $parsed_referer = wp_parse_url( $referer );
1259
- if ( ! empty( $parsed_referer['host'] ) && ! empty( $current_site_parsed['host'] ) && $current_site_parsed['host'] === $parsed_referer['host'] ) {
1260
- // Don't track clicks originating from same site as those are tracked with JS.
1261
- return;
1262
- }
1263
- }
1264
- // Check if this is an affiliate link and use the appropriate category.
1265
- $ec = 'outbound-link';
1266
- $inbound_paths = monsterinsights_get_option( 'affiliate_links', array() );
1267
- $path = empty( $_SERVER['REQUEST_URI'] ) ? '' : $_SERVER['REQUEST_URI'];
1268
- if ( ! empty( $inbound_paths ) && is_array( $inbound_paths ) && ! empty( $path ) ) {
1269
- $found = false;
1270
- foreach ( $inbound_paths as $inbound_path ) {
1271
- if ( empty( $inbound_path['path'] ) ) {
1272
- continue;
1273
- }
1274
- if ( 0 === strpos( $path, trim( $inbound_path['path'] ) ) ) {
1275
- $label = ! empty( $inbound_path['label'] ) ? trim( $inbound_path['label'] ) : 'aff';
1276
- $ec .= '-' . $label;
1277
- $found = true;
1278
- break;
1279
- }
1280
- }
1281
- if ( ! $found ) {
1282
- return;
1283
- }
1284
- } else {
1285
- // no paths setup in MonsterInsights settings
1286
- return;
1287
- }
1288
-
1289
- $track_args = array(
1290
- 't' => 'event',
1291
- 'ec' => $ec,
1292
- 'ea' => $url,
1293
- 'el' => 'external-redirect',
1294
- );
1295
- monsterinsights_mp_track_event_call( $track_args );
1296
- }
1297
- add_action( 'prli_before_redirect', 'monsterinsights_custom_track_pretty_links_redirect' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Helper functions.
4
+ *
5
+ * @since 6.0.0
6
+ *
7
+ * @package MonsterInsights
8
+ * @subpackage Helper
9
+ * @author Chris Christoff
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ function monsterinsights_is_page_reload() {
18
+ // Can't be a refresh without having a referrer
19
+ if ( ! isset( $_SERVER['HTTP_REFERER'] ) ) {
20
+ return false;
21
+ }
22
+
23
+ // IF the referrer is identical to the current page request, then it's a refresh
24
+ return ( parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_PATH ) === parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ) );
25
+ }
26
+
27
+
28
+ function monsterinsights_track_user( $user_id = -1 ) {
29
+ if ( $user_id === -1 ) {
30
+ $user = wp_get_current_user();
31
+ } else {
32
+ $user = new WP_User( $user_id );
33
+ }
34
+
35
+ $track_user = true;
36
+ $roles = monsterinsights_get_option( 'ignore_users', array() );
37
+
38
+ if ( ! empty( $roles ) && is_array( $roles ) ) {
39
+ foreach ( $roles as $role ) {
40
+ if ( is_string( $role ) ) {
41
+ if ( user_can( $user, $role ) ) {
42
+ $track_user = false;
43
+ break;
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+ $track_super_admin = apply_filters( 'monsterinsights_track_super_admins', false );
50
+ if ( $track_super_admin === false && is_multisite() && is_super_admin() ) {
51
+ $track_user = false;
52
+ }
53
+
54
+ // or if UA code is not entered
55
+ $ua_code = monsterinsights_get_ua();
56
+ if ( empty( $ua_code ) ) {
57
+ $track_user = false;
58
+ }
59
+
60
+ return apply_filters( 'monsterinsights_track_user', $track_user, $user );
61
+ }
62
+
63
+ function monsterinsights_get_client_id( $payment_id = false ) {
64
+ if ( is_object( $payment_id ) ) {
65
+ $payment_id = $payment_id->ID;
66
+ }
67
+ $user_cid = monsterinsights_get_uuid();
68
+ $saved_cid = ! empty( $payment_id ) ? get_post_meta( $payment_id, '_yoast_gau_uuid', true ) : false;
69
+
70
+ if ( ! empty( $payment_id ) && ! empty( $saved_cid ) ) {
71
+ return $saved_cid;
72
+ } else if ( ! empty( $user_cid ) ) {
73
+ return $user_cid;
74
+ } else {
75
+ return monsterinsights_generate_uuid();
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Returns the Google Analytics clientId to store for later use
81
+ *
82
+ * @since 6.0.0
83
+ *
84
+ * @link https://developers.google.com/analytics/devguides/collection/analyticsjs/domains#getClientId
85
+ *
86
+ * @return bool|string False if cookie isn't set, GA UUID otherwise
87
+ */
88
+ function monsterinsights_get_uuid() {
89
+ if ( empty( $_COOKIE['_ga'] ) ) {
90
+ return false;
91
+ }
92
+
93
+ /**
94
+ * Example cookie formats:
95
+ *
96
+ * GA1.2.XXXXXXX.YYYYY
97
+ * _ga=1.2.XXXXXXX.YYYYYY -- We want the XXXXXXX.YYYYYY part
98
+ *
99
+ */
100
+
101
+ $ga_cookie = $_COOKIE['_ga'];
102
+ $cookie_parts = explode('.', $ga_cookie );
103
+ if ( is_array( $cookie_parts ) && ! empty( $cookie_parts[2] ) && ! empty( $cookie_parts[3] ) ) {
104
+ $uuid = (string) $cookie_parts[2] . '.' . (string) $cookie_parts[3];
105
+ if ( is_string( $uuid ) ) {
106
+ return $uuid;
107
+ } else {
108
+ return false;
109
+ }
110
+ } else {
111
+ return false;
112
+ }
113
+ }
114
+
115
+
116
+ /**
117
+ * Generate UUID v4 function - needed to generate a CID when one isn't available
118
+ *
119
+ * @link http://www.stumiller.me/implementing-google-analytics-measurement-protocol-in-php-and-wordpress/
120
+ *
121
+ * @since 6.1.8
122
+ * @return string
123
+ */
124
+ function monsterinsights_generate_uuid() {
125
+
126
+ return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
127
+
128
+ // 32 bits for "time_low"
129
+ mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
130
+
131
+ // 16 bits for "time_mid"
132
+ mt_rand( 0, 0xffff ),
133
+
134
+ // 16 bits for "time_hi_and_version",
135
+ // four most significant bits holds version number 4
136
+ mt_rand( 0, 0x0fff ) | 0x4000,
137
+
138
+ // 16 bits, 8 bits for "clk_seq_hi_res",
139
+ // 8 bits for "clk_seq_low",
140
+ // two most significant bits holds zero and one for variant DCE1.1
141
+ mt_rand( 0, 0x3fff ) | 0x8000,
142
+
143
+ // 48 bits for "node"
144
+ mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
145
+ );
146
+ }
147
+
148
+ /**
149
+ * Returns the Google Analytics clientId to store for later use
150
+ *
151
+ * @since 6.0.0
152
+ *
153
+ * @return GA UUID or error code.
154
+ */
155
+ function monsterinsights_get_cookie( $debug = false ) {
156
+ if ( empty( $_COOKIE['_ga'] ) ) {
157
+ return ( $debug ) ? 'FCE' : false;
158
+ }
159
+
160
+ $ga_cookie = $_COOKIE['_ga'];
161
+ $cookie_parts = explode('.', $ga_cookie );
162
+ if ( is_array( $cookie_parts ) && ! empty( $cookie_parts[2] ) && ! empty( $cookie_parts[3] ) ) {
163
+ $uuid = (string) $cookie_parts[2] . '.' . (string) $cookie_parts[3];
164
+ if ( is_string( $uuid ) ) {
165
+ return $ga_cookie;
166
+ } else {
167
+ return ( $debug ) ? 'FA' : false;
168
+ }
169
+ } else {
170
+ return ( $debug ) ? 'FAE' : false;
171
+ }
172
+ }
173
+
174
+
175
+ function monsterinsights_generate_ga_client_id() {
176
+ return rand(100000000,999999999) . '.' . time();
177
+ }
178
+
179
+
180
+ /**
181
+ * Hours between two timestamps.
182
+ *
183
+ * @access public
184
+ * @since 6.0.0
185
+ *
186
+ * @param string $start Timestamp of start time (in seconds since Unix).
187
+ * @param string $stop Timestamp of stop time (in seconds since Unix). Optional. If not used, current_time (in UTC 0 / GMT ) is used.
188
+ *
189
+ * @return int Hours between the two timestamps, rounded.
190
+ */
191
+ function monsterinsights_hours_between( $start, $stop = false ) {
192
+ if ( $stop === false ) {
193
+ $stop = time();
194
+ }
195
+
196
+ $diff = (int) abs( $stop - $start );
197
+ $hours = round( $diff / HOUR_IN_SECONDS );
198
+ return $hours;
199
+ }
200
+
201
+ /**
202
+ * Is This MonsterInsights Pro?
203
+ *
204
+ * We use this function monsterinsights_to determine if the install is a pro version or a lite version install of MonsterInsights.
205
+ * If the install is a lite version we disable the install from admin functionality[1] for addons as WordPress.org requires us to,
206
+ * we change the links for where to get support (wp.org forum for free; our site for pro), we use this determine what class to load as
207
+ * the base class in addons (to avoid fatal errors) and we use this on the system info page to know what constants to display values for
208
+ * as the lite and pro versions of our plugin have different constants (and names for those constants) you can declare and use.
209
+ *
210
+ * [1] Note: This is not "feature-locking" under GPL guidelines but rather something WordPress.org requires us to do to stay
211
+ * in compliance with their rules. We wish we didn't have to do this, as in our oppinion this diminishes the user experience
212
+ * of users installing our free and premium addons, and we'd love to turn this on for non-Pro installs, but we're not allowed to.
213
+ * If WordPress.org ever changes their mind on this subject, we'd totally turn on that feature for Lite installs in a heartbeat.
214
+ *
215
+ * @todo Are we allowed to turn on admin installing if the user has to manually declare a PHP constant (and thus would not be on
216
+ * either by default or via any sort of user interface)? If so, we could add a constant for forcing Pro version so that users can see
217
+ * for themselves that we're not feature locking anything inside the plugin + it would make it easier for our team to test stuff (both via
218
+ * Travis-CI but also when installing addons to test with the Lite version). Also this would allow for a better user experience for users
219
+ * who want that feature.
220
+ *
221
+ * @since 6.0.0
222
+ * @access public
223
+ *
224
+ * @return bool True if pro version.
225
+ */
226
+ function monsterinsights_is_pro_version() {
227
+ if ( class_exists( 'MonsterInsights' ) ) {
228
+ return true;
229
+ } else {
230
+ return false;
231
+ }
232
+ }
233
+
234
+
235
+ /**
236
+ * Get the user roles of this WordPress blog
237
+ *
238
+ * @return array
239
+ */
240
+ function monsterinsights_get_roles() {
241
+ global $wp_roles;
242
+
243
+ $all_roles = $wp_roles->roles;
244
+ $roles = array();
245
+
246
+ /**
247
+ * Filter: 'editable_roles' - Allows filtering of the roles shown within the plugin (and elsewhere in WP as it's a WP filter)
248
+ *
249
+ * @api array $all_roles
250
+ */
251
+ $editable_roles = apply_filters( 'editable_roles', $all_roles );
252
+
253
+ foreach ( $editable_roles as $id => $name ) {
254
+ $roles[ $id ] = translate_user_role( $name['name'] );
255
+ }
256
+
257
+ return $roles;
258
+ }
259
+
260
+ /**
261
+ * Get the user roles which can manage options. Used to prevent these roles from getting unselected in the settings.
262
+ *
263
+ * @return array
264
+ */
265
+ function monsterinsights_get_manage_options_roles() {
266
+ global $wp_roles;
267
+
268
+ $all_roles = $wp_roles->roles;
269
+ $roles = array();
270
+
271
+ /**
272
+ * Filter: 'editable_roles' - Allows filtering of the roles shown within the plugin (and elsewhere in WP as it's a WP filter)
273
+ *
274
+ * @api array $all_roles
275
+ */
276
+ $editable_roles = apply_filters( 'editable_roles', $all_roles );
277
+
278
+ foreach ( $editable_roles as $id => $role ) {
279
+ if ( isset( $role['capabilities']['manage_options'] ) && $role['capabilities']['manage_options'] ) {
280
+ $roles[ $id ] = translate_user_role( $role['name'] );
281
+ }
282
+ }
283
+
284
+ return $roles;
285
+ }
286
+
287
+ /** Need to escape in advance of passing in $text. */
288
+ function monsterinsights_get_message( $type = 'error', $text = '' ) {
289
+ $div = '';
290
+ if ( $type === 'error' || $type === 'alert' || $type === 'success' || $type === 'info' ) {
291
+ $base = MonsterInsights();
292
+ return $base->notices->display_inline_notice( 'monsterinsights_standard_notice', '', $text, $type, false, array( 'skip_message_escape' => true ) );
293
+ } else {
294
+ return '';
295
+ }
296
+ }
297
+
298
+ function monsterinsights_is_dev_url( $url = '' ) {
299
+ $is_local_url = false;
300
+ // Trim it up
301
+ $url = strtolower( trim( $url ) );
302
+ // Need to get the host...so let's add the scheme so we can use parse_url
303
+ if ( false === strpos( $url, 'http://' ) && false === strpos( $url, 'https://' ) ) {
304
+ $url = 'http://' . $url;
305
+ }
306
+ $url_parts = parse_url( $url );
307
+ $host = ! empty( $url_parts['host'] ) ? $url_parts['host'] : false;
308
+ if ( ! empty( $url ) && ! empty( $host ) ) {
309
+ if ( false !== ip2long( $host ) ) {
310
+ if ( ! filter_var( $host, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) ) {
311
+ $is_local_url = true;
312
+ }
313
+ } else if ( 'localhost' === $host ) {
314
+ $is_local_url = true;
315
+ }
316
+
317
+ $tlds_to_check = array( '.local', ':8888', ':8080', ':8081', '.invalid', '.example', '.test' );
318
+ foreach ( $tlds_to_check as $tld ) {
319
+ if ( false !== strpos( $host, $tld ) ) {
320
+ $is_local_url = true;
321
+ break;
322
+ }
323
+
324
+ }
325
+ if ( substr_count( $host, '.' ) > 1 ) {
326
+ $subdomains_to_check = array( 'dev.', '*.staging.', 'beta.', 'test.' );
327
+ foreach ( $subdomains_to_check as $subdomain ) {
328
+ $subdomain = str_replace( '.', '(.)', $subdomain );
329
+ $subdomain = str_replace( array( '*', '(.)' ), '(.*)', $subdomain );
330
+ if ( preg_match( '/^(' . $subdomain . ')/', $host ) ) {
331
+ $is_local_url = true;
332
+ break;
333
+ }
334
+ }
335
+ }
336
+ }
337
+ return $is_local_url;
338
+ }
339
+
340
+ // Set cookie to expire in 2 years
341
+ function monsterinsights_get_cookie_expiration_date( $time ) {
342
+ return date('D, j F Y H:i:s', time() + $time );
343
+ }
344
+
345
+ function monsterinsights_string_ends_with( $string, $ending ) {
346
+ $strlen = strlen($string);
347
+ $endinglen = strlen($ending);
348
+ if ( $endinglen > $strlen ) {
349
+ return false;
350
+ }
351
+ return substr_compare( $string, $ending, $strlen - $endinglen, $endinglen) === 0;
352
+ }
353
+
354
+ function monsterinsights_string_starts_with( $string, $start ) {
355
+ if ( ! is_string( $string ) || ! is_string( $start ) ) {
356
+ return false;
357
+ }
358
+
359
+ return substr( $string, 0, strlen( $start ) ) === $start;
360
+ }
361
+
362
+ function monsterinsights_get_country_list( $translated = false ) {
363
+ if ( $translated ) {
364
+ $countries = array(
365
+ '' => '',
366
+ 'US' => __( 'United States', 'google-analytics-for-wordpress' ),
367
+ 'CA' => __( 'Canada', 'google-analytics-for-wordpress' ),
368
+ 'GB' => __( 'United Kingdom', 'google-analytics-for-wordpress' ),
369
+ 'AF' => __( 'Afghanistan', 'google-analytics-for-wordpress' ),
370
+ 'AX' => __( '&#197;land Islands', 'google-analytics-for-wordpress' ),
371
+ 'AL' => __( 'Albania', 'google-analytics-for-wordpress' ),
372
+ 'DZ' => __( 'Algeria', 'google-analytics-for-wordpress' ),
373
+ 'AS' => __( 'American Samoa', 'google-analytics-for-wordpress' ),
374
+ 'AD' => __( 'Andorra', 'google-analytics-for-wordpress' ),
375
+ 'AO' => __( 'Angola', 'google-analytics-for-wordpress' ),
376
+ 'AI' => __( 'Anguilla', 'google-analytics-for-wordpress' ),
377
+ 'AQ' => __( 'Antarctica', 'google-analytics-for-wordpress' ),
378
+ 'AG' => __( 'Antigua and Barbuda', 'google-analytics-for-wordpress' ),
379
+ 'AR' => __( 'Argentina', 'google-analytics-for-wordpress' ),
380
+ 'AM' => __( 'Armenia', 'google-analytics-for-wordpress' ),
381
+ 'AW' => __( 'Aruba', 'google-analytics-for-wordpress' ),
382
+ 'AU' => __( 'Australia', 'google-analytics-for-wordpress' ),
383
+ 'AT' => __( 'Austria', 'google-analytics-for-wordpress' ),
384
+ 'AZ' => __( 'Azerbaijan', 'google-analytics-for-wordpress' ),
385
+ 'BS' => __( 'Bahamas', 'google-analytics-for-wordpress' ),
386
+ 'BH' => __( 'Bahrain', 'google-analytics-for-wordpress' ),
387
+ 'BD' => __( 'Bangladesh', 'google-analytics-for-wordpress' ),
388
+ 'BB' => __( 'Barbados', 'google-analytics-for-wordpress' ),
389
+ 'BY' => __( 'Belarus', 'google-analytics-for-wordpress' ),
390
+ 'BE' => __( 'Belgium', 'google-analytics-for-wordpress' ),
391
+ 'BZ' => __( 'Belize', 'google-analytics-for-wordpress' ),
392
+ 'BJ' => __( 'Benin', 'google-analytics-for-wordpress' ),
393
+ 'BM' => __( 'Bermuda', 'google-analytics-for-wordpress' ),
394
+ 'BT' => __( 'Bhutan', 'google-analytics-for-wordpress' ),
395
+ 'BO' => __( 'Bolivia', 'google-analytics-for-wordpress' ),
396
+ 'BQ' => __( 'Bonaire, Saint Eustatius and Saba', 'google-analytics-for-wordpress' ),
397
+ 'BA' => __( 'Bosnia and Herzegovina', 'google-analytics-for-wordpress' ),
398
+ 'BW' => __( 'Botswana', 'google-analytics-for-wordpress' ),
399
+ 'BV' => __( 'Bouvet Island', 'google-analytics-for-wordpress' ),
400
+ 'BR' => __( 'Brazil', 'google-analytics-for-wordpress' ),
401
+ 'IO' => __( 'British Indian Ocean Territory', 'google-analytics-for-wordpress' ),
402
+ 'BN' => __( 'Brunei Darrussalam', 'google-analytics-for-wordpress' ),
403
+ 'BG' => __( 'Bulgaria', 'google-analytics-for-wordpress' ),
404
+ 'BF' => __( 'Burkina Faso', 'google-analytics-for-wordpress' ),
405
+ 'BI' => __( 'Burundi', 'google-analytics-for-wordpress' ),
406
+ 'KH' => __( 'Cambodia', 'google-analytics-for-wordpress' ),
407
+ 'CM' => __( 'Cameroon', 'google-analytics-for-wordpress' ),
408
+ 'CV' => __( 'Cape Verde', 'google-analytics-for-wordpress' ),
409
+ 'KY' => __( 'Cayman Islands', 'google-analytics-for-wordpress' ),
410
+ 'CF' => __( 'Central African Republic', 'google-analytics-for-wordpress' ),
411
+ 'TD' => __( 'Chad', 'google-analytics-for-wordpress' ),
412
+ 'CL' => __( 'Chile', 'google-analytics-for-wordpress' ),
413
+ 'CN' => __( 'China', 'google-analytics-for-wordpress' ),
414
+ 'CX' => __( 'Christmas Island', 'google-analytics-for-wordpress' ),
415
+ 'CC' => __( 'Cocos Islands', 'google-analytics-for-wordpress' ),
416
+ 'CO' => __( 'Colombia', 'google-analytics-for-wordpress' ),
417
+ 'KM' => __( 'Comoros', 'google-analytics-for-wordpress' ),
418
+ 'CD' => __( 'Congo, Democratic People\'s Republic', 'google-analytics-for-wordpress' ),
419
+ 'CG' => __( 'Congo, Republic of', 'google-analytics-for-wordpress' ),
420
+ 'CK' => __( 'Cook Islands', 'google-analytics-for-wordpress' ),
421
+ 'CR' => __( 'Costa Rica', 'google-analytics-for-wordpress' ),
422
+ 'CI' => __( 'Cote d\'Ivoire', 'google-analytics-for-wordpress' ),
423
+ 'HR' => __( 'Croatia/Hrvatska', 'google-analytics-for-wordpress' ),
424
+ 'CU' => __( 'Cuba', 'google-analytics-for-wordpress' ),
425
+ 'CW' => __( 'Cura&Ccedil;ao', 'google-analytics-for-wordpress' ),
426
+ 'CY' => __( 'Cyprus', 'google-analytics-for-wordpress' ),
427
+ 'CZ' => __( 'Czechia', 'google-analytics-for-wordpress' ),
428
+ 'DK' => __( 'Denmark', 'google-analytics-for-wordpress' ),
429
+ 'DJ' => __( 'Djibouti', 'google-analytics-for-wordpress' ),
430
+ 'DM' => __( 'Dominica', 'google-analytics-for-wordpress' ),
431
+ 'DO' => __( 'Dominican Republic', 'google-analytics-for-wordpress' ),
432
+ 'TP' => __( 'East Timor', 'google-analytics-for-wordpress' ),
433
+ 'EC' => __( 'Ecuador', 'google-analytics-for-wordpress' ),
434
+ 'EG' => __( 'Egypt', 'google-analytics-for-wordpress' ),
435
+ 'GQ' => __( 'Equatorial Guinea', 'google-analytics-for-wordpress' ),
436
+ 'SV' => __( 'El Salvador', 'google-analytics-for-wordpress' ),
437
+ 'ER' => __( 'Eritrea', 'google-analytics-for-wordpress' ),
438
+ 'EE' => __( 'Estonia', 'google-analytics-for-wordpress' ),
439
+ 'ET' => __( 'Ethiopia', 'google-analytics-for-wordpress' ),
440
+ 'FK' => __( 'Falkland Islands', 'google-analytics-for-wordpress' ),
441
+ 'FO' => __( 'Faroe Islands', 'google-analytics-for-wordpress' ),
442
+ 'FJ' => __( 'Fiji', 'google-analytics-for-wordpress' ),
443
+ 'FI' => __( 'Finland', 'google-analytics-for-wordpress' ),
444
+ 'FR' => __( 'France', 'google-analytics-for-wordpress' ),
445
+ 'GF' => __( 'French Guiana', 'google-analytics-for-wordpress' ),
446
+ 'PF' => __( 'French Polynesia', 'google-analytics-for-wordpress' ),
447
+ 'TF' => __( 'French Southern Territories', 'google-analytics-for-wordpress' ),
448
+ 'GA' => __( 'Gabon', 'google-analytics-for-wordpress' ),
449
+ 'GM' => __( 'Gambia', 'google-analytics-for-wordpress' ),
450
+ 'GE' => __( 'Georgia', 'google-analytics-for-wordpress' ),
451
+ 'DE' => __( 'Germany', 'google-analytics-for-wordpress' ),
452
+ 'GR' => __( 'Greece', 'google-analytics-for-wordpress' ),
453
+ 'GH' => __( 'Ghana', 'google-analytics-for-wordpress' ),
454
+ 'GI' => __( 'Gibraltar', 'google-analytics-for-wordpress' ),
455
+ 'GL' => __( 'Greenland', 'google-analytics-for-wordpress' ),
456
+ 'GD' => __( 'Grenada', 'google-analytics-for-wordpress' ),
457
+ 'GP' => __( 'Guadeloupe', 'google-analytics-for-wordpress' ),
458
+ 'GU' => __( 'Guam', 'google-analytics-for-wordpress' ),
459
+ 'GT' => __( 'Guatemala', 'google-analytics-for-wordpress' ),
460
+ 'GG' => __( 'Guernsey', 'google-analytics-for-wordpress' ),
461
+ 'GN' => __( 'Guinea', 'google-analytics-for-wordpress' ),
462
+ 'GW' => __( 'Guinea-Bissau', 'google-analytics-for-wordpress' ),
463
+ 'GY' => __( 'Guyana', 'google-analytics-for-wordpress' ),
464
+ 'HT' => __( 'Haiti', 'google-analytics-for-wordpress' ),
465
+ 'HM' => __( 'Heard and McDonald Islands', 'google-analytics-for-wordpress' ),
466
+ 'VA' => __( 'Holy See (City Vatican State)', 'google-analytics-for-wordpress' ),
467
+ 'HN' => __( 'Honduras', 'google-analytics-for-wordpress' ),
468
+ 'HK' => __( 'Hong Kong', 'google-analytics-for-wordpress' ),
469
+ 'HU' => __( 'Hungary', 'google-analytics-for-wordpress' ),
470
+ 'IS' => __( 'Iceland', 'google-analytics-for-wordpress' ),
471
+ 'IN' => __( 'India', 'google-analytics-for-wordpress' ),
472
+ 'ID' => __( 'Indonesia', 'google-analytics-for-wordpress' ),
473
+ 'IR' => __( 'Iran', 'google-analytics-for-wordpress' ),
474
+ 'IQ' => __( 'Iraq', 'google-analytics-for-wordpress' ),
475
+ 'IE' => __( 'Ireland', 'google-analytics-for-wordpress' ),
476
+ 'IM' => __( 'Isle of Man', 'google-analytics-for-wordpress' ),
477
+ 'IL' => __( 'Israel', 'google-analytics-for-wordpress' ),
478
+ 'IT' => __( 'Italy', 'google-analytics-for-wordpress' ),
479
+ 'JM' => __( 'Jamaica', 'google-analytics-for-wordpress' ),
480
+ 'JP' => __( 'Japan', 'google-analytics-for-wordpress' ),
481
+ 'JE' => __( 'Jersey', 'google-analytics-for-wordpress' ),
482
+ 'JO' => __( 'Jordan', 'google-analytics-for-wordpress' ),
483
+ 'KZ' => __( 'Kazakhstan', 'google-analytics-for-wordpress' ),
484
+ 'KE' => __( 'Kenya', 'google-analytics-for-wordpress' ),
485
+ 'KI' => __( 'Kiribati', 'google-analytics-for-wordpress' ),
486
+ 'KW' => __( 'Kuwait', 'google-analytics-for-wordpress' ),
487
+ 'KG' => __( 'Kyrgyzstan', 'google-analytics-for-wordpress' ),
488
+ 'LA' => __( 'Lao People\'s Democratic Republic', 'google-analytics-for-wordpress' ),
489
+ 'LV' => __( 'Latvia', 'google-analytics-for-wordpress' ),
490
+ 'LB' => __( 'Lebanon', 'google-analytics-for-wordpress' ),
491
+ 'LS' => __( 'Lesotho', 'google-analytics-for-wordpress' ),
492
+ 'LR' => __( 'Liberia', 'google-analytics-for-wordpress' ),
493
+ 'LY' => __( 'Libyan Arab Jamahiriya', 'google-analytics-for-wordpress' ),
494
+ 'LI' => __( 'Liechtenstein', 'google-analytics-for-wordpress' ),
495
+ 'LT' => __( 'Lithuania', 'google-analytics-for-wordpress' ),
496
+ 'LU' => __( 'Luxembourg', 'google-analytics-for-wordpress' ),
497
+ 'MO' => __( 'Macau', 'google-analytics-for-wordpress' ),
498
+ 'MK' => __( 'Macedonia (FYROM)', 'google-analytics-for-wordpress' ),
499
+ 'MG' => __( 'Madagascar', 'google-analytics-for-wordpress' ),
500
+ 'MW' => __( 'Malawi', 'google-analytics-for-wordpress' ),
501
+ 'MY' => __( 'Malaysia', 'google-analytics-for-wordpress' ),
502
+ 'MV' => __( 'Maldives', 'google-analytics-for-wordpress' ),
503
+ 'ML' => __( 'Mali', 'google-analytics-for-wordpress' ),
504
+ 'MT' => __( 'Malta', 'google-analytics-for-wordpress' ),
505
+ 'MH' => __( 'Marshall Islands', 'google-analytics-for-wordpress' ),
506
+ 'MQ' => __( 'Martinique', 'google-analytics-for-wordpress' ),
507
+ 'MR' => __( 'Mauritania', 'google-analytics-for-wordpress' ),
508
+ 'MU' => __( 'Mauritius', 'google-analytics-for-wordpress' ),
509
+ 'YT' => __( 'Mayotte', 'google-analytics-for-wordpress' ),
510
+ 'MX' => __( 'Mexico', 'google-analytics-for-wordpress' ),
511
+ 'FM' => __( 'Micronesia', 'google-analytics-for-wordpress' ),
512
+ 'MD' => __( 'Moldova, Republic of', 'google-analytics-for-wordpress' ),
513
+ 'MC' => __( 'Monaco', 'google-analytics-for-wordpress' ),
514
+ 'MN' => __( 'Mongolia', 'google-analytics-for-wordpress' ),
515
+ 'ME' => __( 'Montenegro', 'google-analytics-for-wordpress' ),
516
+ 'MS' => __( 'Montserrat', 'google-analytics-for-wordpress' ),
517
+ 'MA' => __( 'Morocco', 'google-analytics-for-wordpress' ),
518
+ 'MZ' => __( 'Mozambique', 'google-analytics-for-wordpress' ),
519
+ 'MM' => __( 'Myanmar', 'google-analytics-for-wordpress' ),
520
+ 'NA' => __( 'Namibia', 'google-analytics-for-wordpress' ),
521
+ 'NR' => __( 'Nauru', 'google-analytics-for-wordpress' ),
522
+ 'NP' => __( 'Nepal', 'google-analytics-for-wordpress' ),
523
+ 'NL' => __( 'Netherlands', 'google-analytics-for-wordpress' ),
524
+ 'AN' => __( 'Netherlands Antilles', 'google-analytics-for-wordpress' ),
525
+ 'NC' => __( 'New Caledonia', 'google-analytics-for-wordpress' ),
526
+ 'NZ' => __( 'New Zealand', 'google-analytics-for-wordpress' ),
527
+ 'NI' => __( 'Nicaragua', 'google-analytics-for-wordpress' ),
528
+ 'NE' => __( 'Niger', 'google-analytics-for-wordpress' ),
529
+ 'NG' => __( 'Nigeria', 'google-analytics-for-wordpress' ),
530
+ 'NU' => __( 'Niue', 'google-analytics-for-wordpress' ),
531
+ 'NF' => __( 'Norfolk Island', 'google-analytics-for-wordpress' ),
532
+ 'KP' => __( 'North Korea', 'google-analytics-for-wordpress' ),
533
+ 'MP' => __( 'Northern Mariana Islands', 'google-analytics-for-wordpress' ),
534
+ 'NO' => __( 'Norway', 'google-analytics-for-wordpress' ),
535
+ 'OM' => __( 'Oman', 'google-analytics-for-wordpress' ),
536
+ 'PK' => __( 'Pakistan', 'google-analytics-for-wordpress' ),
537
+ 'PW' => __( 'Palau', 'google-analytics-for-wordpress' ),
538
+ 'PS' => __( 'Palestinian Territories', 'google-analytics-for-wordpress' ),
539
+ 'PA' => __( 'Panama', 'google-analytics-for-wordpress' ),
540
+ 'PG' => __( 'Papua New Guinea', 'google-analytics-for-wordpress' ),
541
+ 'PY' => __( 'Paraguay', 'google-analytics-for-wordpress' ),
542
+ 'PE' => __( 'Peru', 'google-analytics-for-wordpress' ),
543
+ 'PH' => __( 'Philippines', 'google-analytics-for-wordpress' ),
544
+ 'PN' => __( 'Pitcairn Island', 'google-analytics-for-wordpress' ),
545
+ 'PL' => __( 'Poland', 'google-analytics-for-wordpress' ),
546
+ 'PT' => __( 'Portugal', 'google-analytics-for-wordpress' ),
547
+ 'PR' => __( 'Puerto Rico', 'google-analytics-for-wordpress' ),
548
+ 'QA' => __( 'Qatar', 'google-analytics-for-wordpress' ),
549
+ 'XK' => __( 'Republic of Kosovo', 'google-analytics-for-wordpress' ),
550
+ 'RE' => __( 'Reunion Island', 'google-analytics-for-wordpress' ),
551
+ 'RO' => __( 'Romania', 'google-analytics-for-wordpress' ),
552
+ 'RU' => __( 'Russian Federation', 'google-analytics-for-wordpress' ),
553
+ 'RW' => __( 'Rwanda', 'google-analytics-for-wordpress' ),
554
+ 'BL' => __( 'Saint Barth&eacute;lemy', 'google-analytics-for-wordpress' ),
555
+ 'SH' => __( 'Saint Helena', 'google-analytics-for-wordpress' ),
556
+ 'KN' => __( 'Saint Kitts and Nevis', 'google-analytics-for-wordpress' ),
557
+ 'LC' => __( 'Saint Lucia', 'google-analytics-for-wordpress' ),
558
+ 'MF' => __( 'Saint Martin (French)', 'google-analytics-for-wordpress' ),
559
+ 'SX' => __( 'Saint Martin (Dutch)', 'google-analytics-for-wordpress' ),
560
+ 'PM' => __( 'Saint Pierre and Miquelon', 'google-analytics-for-wordpress' ),
561
+ 'VC' => __( 'Saint Vincent and the Grenadines', 'google-analytics-for-wordpress' ),
562
+ 'SM' => __( 'San Marino', 'google-analytics-for-wordpress' ),
563
+ 'ST' => __( 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe', 'google-analytics-for-wordpress' ),
564
+ 'SA' => __( 'Saudi Arabia', 'google-analytics-for-wordpress' ),
565
+ 'SN' => __( 'Senegal', 'google-analytics-for-wordpress' ),
566
+ 'RS' => __( 'Serbia', 'google-analytics-for-wordpress' ),
567
+ 'SC' => __( 'Seychelles', 'google-analytics-for-wordpress' ),
568
+ 'SL' => __( 'Sierra Leone', 'google-analytics-for-wordpress' ),
569
+ 'SG' => __( 'Singapore', 'google-analytics-for-wordpress' ),
570
+ 'SK' => __( 'Slovak Republic', 'google-analytics-for-wordpress' ),
571
+ 'SI' => __( 'Slovenia', 'google-analytics-for-wordpress' ),
572
+ 'SB' => __( 'Solomon Islands', 'google-analytics-for-wordpress' ),
573
+ 'SO' => __( 'Somalia', 'google-analytics-for-wordpress' ),
574
+ 'ZA' => __( 'South Africa', 'google-analytics-for-wordpress' ),
575
+ 'GS' => __( 'South Georgia', 'google-analytics-for-wordpress' ),
576
+ 'KR' => __( 'South Korea', 'google-analytics-for-wordpress' ),
577
+ 'SS' => __( 'South Sudan', 'google-analytics-for-wordpress' ),
578
+ 'ES' => __( 'Spain', 'google-analytics-for-wordpress' ),
579
+ 'LK' => __( 'Sri Lanka', 'google-analytics-for-wordpress' ),
580
+ 'SD' => __( 'Sudan', 'google-analytics-for-wordpress' ),
581
+ 'SR' => __( 'Suriname', 'google-analytics-for-wordpress' ),
582
+ 'SJ' => __( 'Svalbard and Jan Mayen Islands', 'google-analytics-for-wordpress' ),
583
+ 'SZ' => __( 'Swaziland', 'google-analytics-for-wordpress' ),
584
+ 'SE' => __( 'Sweden', 'google-analytics-for-wordpress' ),
585
+ 'CH' => __( 'Switzerland', 'google-analytics-for-wordpress' ),
586
+ 'SY' => __( 'Syrian Arab Republic', 'google-analytics-for-wordpress' ),
587
+ 'TW' => __( 'Taiwan', 'google-analytics-for-wordpress' ),
588
+ 'TJ' => __( 'Tajikistan', 'google-analytics-for-wordpress' ),
589
+ 'TZ' => __( 'Tanzania', 'google-analytics-for-wordpress' ),
590
+ 'TH' => __( 'Thailand', 'google-analytics-for-wordpress' ),
591
+ 'TL' => __( 'Timor-Leste', 'google-analytics-for-wordpress' ),
592
+ 'TG' => __( 'Togo', 'google-analytics-for-wordpress' ),
593
+ 'TK' => __( 'Tokelau', 'google-analytics-for-wordpress' ),
594
+ 'TO' => __( 'Tonga', 'google-analytics-for-wordpress' ),
595
+ 'TT' => __( 'Trinidad and Tobago', 'google-analytics-for-wordpress' ),
596
+ 'TN' => __( 'Tunisia', 'google-analytics-for-wordpress' ),
597
+ 'TR' => __( 'Turkey', 'google-analytics-for-wordpress' ),
598
+ 'TM' => __( 'Turkmenistan', 'google-analytics-for-wordpress' ),
599
+ 'TC' => __( 'Turks and Caicos Islands', 'google-analytics-for-wordpress' ),
600
+ 'TV' => __( 'Tuvalu', 'google-analytics-for-wordpress' ),
601
+ 'UG' => __( 'Uganda', 'google-analytics-for-wordpress' ),
602
+ 'UA' => __( 'Ukraine', 'google-analytics-for-wordpress' ),
603
+ 'AE' => __( 'United Arab Emirates', 'google-analytics-for-wordpress' ),
604
+ 'UY' => __( 'Uruguay', 'google-analytics-for-wordpress' ),
605
+ 'UM' => __( 'US Minor Outlying Islands', 'google-analytics-for-wordpress' ),
606
+ 'UZ' => __( 'Uzbekistan', 'google-analytics-for-wordpress' ),
607
+ 'VU' => __( 'Vanuatu', 'google-analytics-for-wordpress' ),
608
+ 'VE' => __( 'Venezuela', 'google-analytics-for-wordpress' ),
609
+ 'VN' => __( 'Vietnam', 'google-analytics-for-wordpress' ),
610
+ 'VG' => __( 'Virgin Islands (British)', 'google-analytics-for-wordpress' ),
611
+ 'VI' => __( 'Virgin Islands (USA)', 'google-analytics-for-wordpress' ),
612
+ 'WF' => __( 'Wallis and Futuna Islands', 'google-analytics-for-wordpress' ),
613
+ 'EH' => __( 'Western Sahara', 'google-analytics-for-wordpress' ),
614
+ 'WS' => __( 'Western Samoa', 'google-analytics-for-wordpress' ),
615
+ 'YE' => __( 'Yemen', 'google-analytics-for-wordpress' ),
616
+ 'ZM' => __( 'Zambia', 'google-analytics-for-wordpress' ),
617
+ 'ZW' => __( 'Zimbabwe', 'google-analytics-for-wordpress' ),
618
+ 'ZZ' => __( 'Unknown Country', 'google-analytics-for-wordpress' ),
619
+ );
620
+ } else {
621
+ $countries = array(
622
+ '' => '',
623
+ 'US' => 'United States',
624
+ 'CA' => 'Canada',
625
+ 'GB' => 'United Kingdom',
626
+ 'AF' => 'Afghanistan',
627
+ 'AX' => '&#197;land Islands',
628
+ 'AL' => 'Albania',
629
+ 'DZ' => 'Algeria',
630
+ 'AS' => 'American Samoa',
631
+ 'AD' => 'Andorra',
632
+ 'AO' => 'Angola',
633
+ 'AI' => 'Anguilla',
634
+ 'AQ' => 'Antarctica',
635
+ 'AG' => 'Antigua and Barbuda',
636
+ 'AR' => 'Argentina',
637
+ 'AM' => 'Armenia',
638
+ 'AW' => 'Aruba',
639
+ 'AU' => 'Australia',
640
+ 'AT' => 'Austria',
641
+ 'AZ' => 'Azerbaijan',
642
+ 'BS' => 'Bahamas',
643
+ 'BH' => 'Bahrain',
644
+ 'BD' => 'Bangladesh',
645
+ 'BB' => 'Barbados',
646
+ 'BY' => 'Belarus',
647
+ 'BE' => 'Belgium',
648
+ 'BZ' => 'Belize',
649
+ 'BJ' => 'Benin',
650
+ 'BM' => 'Bermuda',
651
+ 'BT' => 'Bhutan',
652
+ 'BO' => 'Bolivia',
653
+ 'BQ' => 'Bonaire, Saint Eustatius and Saba',
654
+ 'BA' => 'Bosnia and Herzegovina',
655
+ 'BW' => 'Botswana',
656
+ 'BV' => 'Bouvet Island',
657
+ 'BR' => 'Brazil',
658
+ 'IO' => 'British Indian Ocean Territory',
659
+ 'BN' => 'Brunei Darrussalam',
660
+ 'BG' => 'Bulgaria',
661
+ 'BF' => 'Burkina Faso',
662
+ 'BI' => 'Burundi',
663
+ 'KH' => 'Cambodia',
664
+ 'CM' => 'Cameroon',
665
+ 'CV' => 'Cape Verde',
666
+ 'KY' => 'Cayman Islands',
667
+ 'CF' => 'Central African Republic',
668
+ 'TD' => 'Chad',
669
+ 'CL' => 'Chile',
670
+ 'CN' => 'China',
671
+ 'CX' => 'Christmas Island',
672
+ 'CC' => 'Cocos Islands',
673
+ 'CO' => 'Colombia',
674
+ 'KM' => 'Comoros',
675
+ 'CD' => 'Congo, Democratic People\'s Republic',
676
+ 'CG' => 'Congo, Republic of',
677
+ 'CK' => 'Cook Islands',
678
+ 'CR' => 'Costa Rica',
679
+ 'CI' => 'Cote d\'Ivoire',
680
+ 'HR' => 'Croatia/Hrvatska',
681
+ 'CU' => 'Cuba',
682
+ 'CW' => 'Cura&Ccedil;ao',
683
+ 'CY' => 'Cyprus',
684
+ 'CZ' => 'Czechia',
685
+ 'DK' => 'Denmark',
686
+ 'DJ' => 'Djibouti',
687
+ 'DM' => 'Dominica',
688
+ 'DO' => 'Dominican Republic',
689
+ 'TP' => 'East Timor',
690
+ 'EC' => 'Ecuador',
691
+ 'EG' => 'Egypt',
692
+ 'GQ' => 'Equatorial Guinea',
693
+ 'SV' => 'El Salvador',
694
+ 'ER' => 'Eritrea',
695
+ 'EE' => 'Estonia',
696
+ 'ET' => 'Ethiopia',
697
+ 'FK' => 'Falkland Islands',
698
+ 'FO' => 'Faroe Islands',
699
+ 'FJ' => 'Fiji',
700
+ 'FI' => 'Finland',
701
+ 'FR' => 'France',
702
+ 'GF' => 'French Guiana',
703
+ 'PF' => 'French Polynesia',
704
+ 'TF' => 'French Southern Territories',
705
+ 'GA' => 'Gabon',
706
+ 'GM' => 'Gambia',
707
+ 'GE' => 'Georgia',
708
+ 'DE' => 'Germany',
709
+ 'GR' => 'Greece',
710
+ 'GH' => 'Ghana',
711
+ 'GI' => 'Gibraltar',
712
+ 'GL' => 'Greenland',
713
+ 'GD' => 'Grenada',
714
+ 'GP' => 'Guadeloupe',
715
+ 'GU' => 'Guam',
716
+ 'GT' => 'Guatemala',
717
+ 'GG' => 'Guernsey',
718
+ 'GN' => 'Guinea',
719
+ 'GW' => 'Guinea-Bissau',
720
+ 'GY' => 'Guyana',
721
+ 'HT' => 'Haiti',
722
+ 'HM' => 'Heard and McDonald Islands',
723
+ 'VA' => 'Holy See (City Vatican State)',
724
+ 'HN' => 'Honduras',
725
+ 'HK' => 'Hong Kong',
726
+ 'HU' => 'Hungary',
727
+ 'IS' => 'Iceland',
728
+ 'IN' => 'India',
729
+ 'ID' => 'Indonesia',
730
+ 'IR' => 'Iran',
731
+ 'IQ' => 'Iraq',
732
+ 'IE' => 'Ireland',
733
+ 'IM' => 'Isle of Man',
734
+ 'IL' => 'Israel',
735
+ 'IT' => 'Italy',
736
+ 'JM' => 'Jamaica',
737
+ 'JP' => 'Japan',
738
+ 'JE' => 'Jersey',
739
+ 'JO' => 'Jordan',
740
+ 'KZ' => 'Kazakhstan',
741
+ 'KE' => 'Kenya',
742
+ 'KI' => 'Kiribati',
743
+ 'KW' => 'Kuwait',
744
+ 'KG' => 'Kyrgyzstan',
745
+ 'LA' => 'Lao People\'s Democratic Republic',
746
+ 'LV' => 'Latvia',
747
+ 'LB' => 'Lebanon',
748
+ 'LS' => 'Lesotho',
749
+ 'LR' => 'Liberia',
750
+ 'LY' => 'Libyan Arab Jamahiriya',
751
+ 'LI' => 'Liechtenstein',
752
+ 'LT' => 'Lithuania',
753
+ 'LU' => 'Luxembourg',
754
+ 'MO' => 'Macau',
755
+ 'MK' => 'Macedonia',
756
+ 'MG' => 'Madagascar',
757
+ 'MW' => 'Malawi',
758
+ 'MY' => 'Malaysia',
759
+ 'MV' => 'Maldives',
760
+ 'ML' => 'Mali',
761
+ 'MT' => 'Malta',
762
+ 'MH' => 'Marshall Islands',
763
+ 'MQ' => 'Martinique',
764
+ 'MR' => 'Mauritania',
765
+ 'MU' => 'Mauritius',
766
+ 'YT' => 'Mayotte',
767
+ 'MX' => 'Mexico',
768
+ 'FM' => 'Micronesia',
769
+ 'MD' => 'Moldova, Republic of',
770
+ 'MC' => 'Monaco',
771
+ 'MN' => 'Mongolia',
772
+ 'ME' => 'Montenegro',
773
+ 'MS' => 'Montserrat',
774
+ 'MA' => 'Morocco',
775
+ 'MZ' => 'Mozambique',
776
+ 'MM' => 'Myanmar (Burma)',
777
+ 'NA' => 'Namibia',
778
+ 'NR' => 'Nauru',
779
+ 'NP' => 'Nepal',
780
+ 'NL' => 'Netherlands',
781
+ 'AN' => 'Netherlands Antilles',
782
+ 'NC' => 'New Caledonia',
783
+ 'NZ' => 'New Zealand',
784
+ 'NI' => 'Nicaragua',
785
+ 'NE' => 'Niger',
786
+ 'NG' => 'Nigeria',
787
+ 'NU' => 'Niue',
788
+ 'NF' => 'Norfolk Island',
789
+ 'KP' => 'North Korea',
790
+ 'MP' => 'Northern Mariana Islands',
791
+ 'NO' => 'Norway',
792
+ 'OM' => 'Oman',
793
+ 'PK' => 'Pakistan',
794
+ 'PW' => 'Palau',
795
+ 'PS' => 'Palestinian Territories',
796
+ 'PA' => 'Panama',
797
+ 'PG' => 'Papua New Guinea',
798
+ 'PY' => 'Paraguay',
799
+ 'PE' => 'Peru',
800
+ 'PH' => 'Philippines',
801
+ 'PN' => 'Pitcairn Island',
802
+ 'PL' => 'Poland',
803
+ 'PT' => 'Portugal',
804
+ 'PR' => 'Puerto Rico',
805
+ 'QA' => 'Qatar',
806
+ 'XK' => 'Republic of Kosovo',
807
+ 'RE' => 'Reunion Island',
808
+ 'RO' => 'Romania',
809
+ 'RU' => 'Russia',
810
+ 'RW' => 'Rwanda',
811
+ 'BL' => 'Saint Barth&eacute;lemy',
812
+ 'SH' => 'Saint Helena',
813
+ 'KN' => 'Saint Kitts and Nevis',
814
+ 'LC' => 'Saint Lucia',
815
+ 'MF' => 'Saint Martin (French)',
816
+ 'SX' => 'Saint Martin (Dutch)',
817
+ 'PM' => 'Saint Pierre and Miquelon',
818
+ 'VC' => 'Saint Vincent and the Grenadines',
819
+ 'SM' => 'San Marino',
820
+ 'ST' => 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe',
821
+ 'SA' => 'Saudi Arabia',
822
+ 'SN' => 'Senegal',
823
+ 'RS' => 'Serbia',
824
+ 'SC' => 'Seychelles',
825
+ 'SL' => 'Sierra Leone',
826
+ 'SG' => 'Singapore',
827
+ 'SK' => 'Slovak Republic',
828
+ 'SI' => 'Slovenia',
829
+ 'SB' => 'Solomon Islands',
830
+ 'SO' => 'Somalia',
831
+ 'ZA' => 'South Africa',
832
+ 'GS' => 'South Georgia',
833
+ 'KR' => 'South Korea',
834
+ 'SS' => 'South Sudan',
835
+ 'ES' => 'Spain',
836
+ 'LK' => 'Sri Lanka',
837
+ 'SD' => 'Sudan',
838
+ 'SR' => 'Suriname',
839
+ 'SJ' => 'Svalbard and Jan Mayen Islands',
840
+ 'SZ' => 'Swaziland',
841
+ 'SE' => 'Sweden',
842
+ 'CH' => 'Switzerland',
843
+ 'SY' => 'Syrian Arab Republic',
844
+ 'TW' => 'Taiwan',
845
+ 'TJ' => 'Tajikistan',
846
+ 'TZ' => 'Tanzania',
847
+ 'TH' => 'Thailand',
848
+ 'TL' => 'Timor-Leste',
849
+ 'TG' => 'Togo',
850
+ 'TK' => 'Tokelau',
851
+ 'TO' => 'Tonga',
852
+ 'TT' => 'Trinidad and Tobago',
853
+ 'TN' => 'Tunisia',
854
+ 'TR' => 'Turkey',
855
+ 'TM' => 'Turkmenistan',
856
+ 'TC' => 'Turks and Caicos Islands',
857
+ 'TV' => 'Tuvalu',
858
+ 'UG' => 'Uganda',
859
+ 'UA' => 'Ukraine',
860
+ 'AE' => 'United Arab Emirates',
861
+ 'UY' => 'Uruguay',
862
+ 'UM' => 'US Minor Outlying Islands',
863
+ 'UZ' => 'Uzbekistan',
864
+ 'VU' => 'Vanuatu',
865
+ 'VE' => 'Venezuela',
866
+ 'VN' => 'Vietnam',
867
+ 'VG' => 'Virgin Islands (British)',
868
+ 'VI' => 'Virgin Islands (USA)',
869
+ 'WF' => 'Wallis and Futuna Islands',
870
+ 'EH' => 'Western Sahara',
871
+ 'WS' => 'Western Samoa',
872
+ 'YE' => 'Yemen',
873
+ 'ZM' => 'Zambia',
874
+ 'ZW' => 'Zimbabwe',
875
+ 'ZZ' => 'Unknown Country',
876
+ );
877
+ }
878
+ return $countries;
879
+ }
880
+
881
+ function monsterinsights_get_api_url(){
882
+ return apply_filters( 'monsterinsights_get_api_url', 'api.monsterinsights.com/v2/' );
883
+ }
884
+
885
+ function monsterinsights_get_licensing_url(){
886
+ return apply_filters( 'monsterinsights_get_licensing_url', 'https://www.monsterinsights.com' );
887
+ }
888
+
889
+ function monsterinsights_is_wp_seo_active( ) {
890
+ $wp_seo_active = false; // @todo: improve this check. This is from old Yoast code.
891
+
892
+ // Makes sure is_plugin_active is available when called from front end
893
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
894
+ if ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) {
895
+ $wp_seo_active = true;
896
+ }
897
+ return $wp_seo_active;
898
+ }
899
+
900
+ function monsterinsights_get_asset_version() {
901
+ if ( monsterinsights_is_debug_mode() || ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ) {
902
+ return time();
903
+ } else {
904
+ return MONSTERINSIGHTS_VERSION;
905
+ }
906
+ }
907
+
908
+ function monsterinsights_is_debug_mode() {
909
+ $debug_mode = false;
910
+ if ( defined( 'MONSTERINSIGHTS_DEBUG_MODE' ) && MONSTERINSIGHTS_DEBUG_MODE ) {
911
+ $debug_mode = true;
912
+ }
913
+
914
+ return apply_filters( 'monsterinsights_is_debug_mode', $debug_mode );
915
+ }
916
+
917
+ function monsterinsights_is_network_active() {
918
+ if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
919
+ require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
920
+ }
921
+
922
+ if ( is_multisite() && is_plugin_active_for_network( plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ) ) ) {
923
+ return true;
924
+ } else {
925
+ return false;
926
+ }
927
+ }
928
+
929
+ if ( ! function_exists ( 'remove_class_filter' ) ) {
930
+ /**
931
+ * Remove Class Filter Without Access to Class Object
932
+ *
933
+ * In order to use the core WordPress remove_filter() on a filter added with the callback
934
+ * to a class, you either have to have access to that class object, or it has to be a call
935
+ * to a static method. This method allows you to remove filters with a callback to a class
936
+ * you don't have access to.
937
+ *
938
+ * Works with WordPress 1.2 - 4.7+
939
+ *
940
+ * @param string $tag Filter to remove
941
+ * @param string $class_name Class name for the filter's callback
942
+ * @param string $method_name Method name for the filter's callback
943
+ * @param int $priority Priority of the filter (default 10)
944
+ *
945
+ * @return bool Whether the function is removed.
946
+ */
947
+ function remove_class_filter( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
948
+ global $wp_filter;
949
+ // Check that filter actually exists first
950
+ if ( ! isset( $wp_filter[ $tag ] ) ) return FALSE;
951
+ /**
952
+ * If filter config is an object, means we're using WordPress 4.7+ and the config is no longer
953
+ * a simple array, rather it is an object that implements the ArrayAccess interface.
954
+ *
955
+ * To be backwards compatible, we set $callbacks equal to the correct array as a reference (so $wp_filter is updated)
956
+ *
957
+ * @see https://make.wordpress.org/core/2016/09/08/wp_hook-next-generation-actions-and-filters/
958
+ */
959
+ if ( is_object( $wp_filter[ $tag ] ) && isset( $wp_filter[ $tag ]->callbacks ) ) {
960
+ $callbacks = &$wp_filter[ $tag ]->callbacks;
961
+ } else {
962
+ $callbacks = &$wp_filter[ $tag ];
963
+ }
964
+ // Exit if there aren't any callbacks for specified priority
965
+ if ( ! isset( $callbacks[ $priority ] ) || empty( $callbacks[ $priority ] ) ) return FALSE;
966
+ // Loop through each filter for the specified priority, looking for our class & method
967
+ foreach( (array) $callbacks[ $priority ] as $filter_id => $filter ) {
968
+ // Filter should always be an array - array( $this, 'method' ), if not goto next
969
+ if ( ! isset( $filter[ 'function' ] ) || ! is_array( $filter[ 'function' ] ) ) continue;
970
+ // If first value in array is not an object, it can't be a class
971
+ if ( ! is_object( $filter[ 'function' ][ 0 ] ) ) continue;
972
+ // Method doesn't match the one we're looking for, goto next
973
+ if ( $filter[ 'function' ][ 1 ] !== $method_name ) continue;
974
+ // Method matched, now let's check the Class
975
+ if ( get_class( $filter[ 'function' ][ 0 ] ) === $class_name ) {
976
+ // Now let's remove it from the array
977
+ unset( $callbacks[ $priority ][ $filter_id ] );
978
+ // and if it was the only filter in that priority, unset that priority
979
+ if ( empty( $callbacks[ $priority ] ) ) unset( $callbacks[ $priority ] );
980
+ // and if the only filter for that tag, set the tag to an empty array
981
+ if ( empty( $callbacks ) ) $callbacks = array();
982
+ // If using WordPress older than 4.7
983
+ if ( ! is_object( $wp_filter[ $tag ] ) ) {
984
+ // Remove this filter from merged_filters, which specifies if filters have been sorted
985
+ unset( $GLOBALS[ 'merged_filters' ][ $tag ] );
986
+ }
987
+ return TRUE;
988
+ }
989
+ }
990
+ return FALSE;
991
+ }
992
+ } // End function exists
993
+
994
+ if ( ! function_exists ( 'remove_class_action' ) ) {
995
+ /**
996
+ * Remove Class Action Without Access to Class Object
997
+ *
998
+ * In order to use the core WordPress remove_action() on an action added with the callback
999
+ * to a class, you either have to have access to that class object, or it has to be a call
1000
+ * to a static method. This method allows you to remove actions with a callback to a class
1001
+ * you don't have access to.
1002
+ *
1003
+ * Works with WordPress 1.2 - 4.7+
1004
+ *
1005
+ * @param string $tag Action to remove
1006
+ * @param string $class_name Class name for the action's callback
1007
+ * @param string $method_name Method name for the action's callback
1008
+ * @param int $priority Priority of the action (default 10)
1009
+ *
1010
+ * @return bool Whether the function is removed.
1011
+ */
1012
+ function remove_class_action( $tag, $class_name = '', $method_name = '', $priority = 10 ) {
1013
+ remove_class_filter( $tag, $class_name, $method_name, $priority );
1014
+ }
1015
+ } // End function exists
1016
+
1017
+ /**
1018
+ * Format a big number, instead of 1000000 you get 1.0M, works with billions also.
1019
+ *
1020
+ * @param int $number
1021
+ * @param int $precision
1022
+ *
1023
+ * @return string
1024
+ */
1025
+ function monsterinsights_round_number( $number, $precision = 2 ) {
1026
+
1027
+ if ( $number < 1000000 ) {
1028
+ // Anything less than a million
1029
+ $number = number_format_i18n( $number );
1030
+ } else if ( $number < 1000000000 ) {
1031
+ // Anything less than a billion
1032
+ $number = number_format_i18n( $number / 1000000, $precision ) . 'M';
1033
+ } else {
1034
+ // At least a billion
1035
+ $number = number_format_i18n( $number / 1000000000, $precision ) . 'B';
1036
+ }
1037
+
1038
+ return $number;
1039
+ }
1040
+
1041
+ if ( ! function_exists( 'wp_get_jed_locale_data' ) ) {
1042
+ /**
1043
+ * Returns Jed-formatted localization data. Added for backwards-compatibility.
1044
+ *
1045
+ * @param string $domain Translation domain.
1046
+ *
1047
+ * @return array
1048
+ */
1049
+ function wp_get_jed_locale_data( $domain ) {
1050
+ $translations = get_translations_for_domain( $domain );
1051
+
1052
+ $locale = array(
1053
+ '' => array(
1054
+ 'domain' => $domain,
1055
+ 'lang' => is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(),
1056
+ ),
1057
+ );
1058
+
1059
+ if ( ! empty( $translations->headers['Plural-Forms'] ) ) {
1060
+ $locale['']['plural_forms'] = $translations->headers['Plural-Forms'];
1061
+ }
1062
+
1063
+ foreach ( $translations->entries as $msgid => $entry ) {
1064
+ $locale[ $msgid ] = $entry->translations;
1065
+ }
1066
+
1067
+ return $locale;
1068
+ }
1069
+ }
1070
+
1071
+ function monsterinsights_get_inline_menu_icon() {
1072
+ $scheme = get_user_option( 'admin_color', get_current_user_id() );
1073
+ $use_dark_scheme = $scheme === 'light';
1074
+ if ( $use_dark_scheme ) {
1075
+ return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAFQUlEQVRYha2Yb2hXZRTHP+c3nc6pm07NF0KWWUtSo0wqzBdiZRItTKMaEZXSi0zRNAsqTBKKSFOa0B8Jigqz2lSwLMtqRURgRuCCLLNmselyZups2+/04pzbnt3de3eTDlzufc5znvN8n+ec55zzXFFV8pKITANOqmpTP3JTgIKq7sutPCJVzfUABeAb4DSwMENuKdABNObV3Wv8fwB0C6DAUX8/67sQ9Q8ANsVk5v5vgIDKWHsvcAgYCWzzCbc6kFJgh/PqgVHAb8DnWTpzA3LzHARmeXuqT/Zo0L/eeZuAV/x7fbRrwJPOu9Dbc4EDgJwNoMmurAt4Bljt7cmBjACvOl+BzTEdVzj/EWAj0O3tC84G0AIf3BRMeDz0GZcbBvzqKy+L9Q30A6AxXTdmARqQcPAAyv29CBjjO1RU1SKAiIwGFgLX+MrbgBnAh5ECVe0UkUMO6nHgFLA70J1McacD5gHbfTXzg77qwBeOBysPn830PnnVwXety7wL1AAV/ZoM+MIHdQCfAdfF+s8H/koBEz0rU9xgLtAInHG5j/KYrNWf8ap6OmFD7w+2/Cugwd/NmOkqgbIUS+wEdorIEOAwFqv6UBKgihQwANNc0b2quh1ARIZi/nUqZUycOrDDcCSps5AAaJBPkkStwNVAs4i8JiLHgBPASRFpFZEGEZktIpIBqBIoIWWH4nZegtl3fIofjAKeoyemfAe8hZnu64D/NjAsRcdEl1mcx6lvc+HLU6L3O97/JXBlgszF9KSVvXhswkxUC6wLdKzIA2iWC1+fMNlK72sASlMjrQHf4LIvAw8B7fScwmNAZ7DDs7MARSmjNsYf7oqak0wBjAXuBlb5Lo9wE0Yg6rHAOdjlR2KB9Qc384o0QOe4giUx/u3OX5oA5gEsCoexqBnYAxTTfMXHlvuOF4F5SYBKHPGaGH+jTzQxxefSnnVpYAIdg9x0PwEDkwSOAHUx3hafoDzGP5AB5gQ56h/XU+NjauJxCCxRjo7xOvw9ImKISBUwIWF8RLtVtT2jP6SdWBKe1QuQiCwDLsKcNKSoqJ8e8BJTREAHc4JBVTuBn4Gx/wISkflYndyNOXdI2/29OOAd7mfSIXkBOZUDxTACt2A78SLQnmDnBszOiwLeraT70Ld5/Mf1jPMxqyLGWqxcnYoFMqVvBTgOK9y7gOVAifMfdF4SqJk5Aa3FLFMNduxagQbvvJOUfIb51/f0lKSrsROyHCtlIyDtrrMJqOoHzAysRvrA28wmSBfAtd7uk6u8vwwr/JOqxm4sl01wvZ3AfhJyo+taAPyJhYi/gekCPIXdNitV9YyIXIIFqptVdVsf13MSkVJgJlZF4rvSqKq/BzJzgNexcPEp8LFPXAHcAFzqoKcAddjR5z2Cay/m4Arcl9cp+zFJFfA0dslMOwB1wD1AewGrTw4Ei2/zVcSP/lmRqrap6irs8gAwid7xDOAuzNwlgmXxF1T14ahXRPZjtU1k3+g5Tk8pkUUFzCwVWC003N/DgGVYIXheIF/EfmQcFczDW4DnsVtBCxbUtmIOPAAzY6MPLgMG+/dlDrIADHWlYL4QpZuZWLjYgp3SOb7QMbFFFLF6LDNB7sGcri7FP7qwWmcX9t8oSWaDA6zCqomXUuZ6U1UpYDXxH5jfgKWET/y7zXfolIgkJeJMEpES/xwMXKWq3aq6CLu9PAH8Eog/Fn2UYnlkDWa2c719E3Y/f8NX0AL8GHuianAXtuXx/lZ6brR9/npgcWgHcEfEkyg6ZqyyBrt1ptE+X9SkDJl6VX0/cyKnfwBb6gwNaZ8ExgAAAABJRU5ErkJggg';
1076
+ } else {
1077
+ return 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4AoEBjcfBsDvpwAABQBJREFUWMO1mGmollUQgJ9z79Vc01LLH0GLWRqlUhYV5o+LbRIVbVQSUSn9qJTKsqDCoqCINKUbtBEUFbbeDGyz1SIiaCHIINu18KZ1bbkuV+/Tj+arw8v7fvdVcuDjvGdmzsycM3Nm5nywE6BOVSfW4JukTmF3gtqifqJuVmc34ZunblFX7W6DzvYf2BDjPWpLRm9T7y/wzPw/DRhZmH+sfq/urb4YCp8JQwaqLwXuBXW0+pP6XjOZO+ueb9X2mE8OZTdl9MWBu199NL4XN05NvT1wh8R8prpGTbti0BEhbLt6t7ow5kdkPEl9zP/gkYKMowN/o7pU3RHzg3fFoHNj8epM4aY8ZoJvuPpj7HxwgTYgLoAFWac1091WgR8a4xxgH2Ah0JdS6gtlY4DZwAnADmAjMA14vSEgpdSrfg9sBm4BeoCVmex6gayepS6P3ZyT0SZksbDJcnikcPMmZN+zgud59Qx1RB2D3o9FW9R31ZMK9IPUP20O11XInqmuUrcG3xt1XNYVvwNSSptL+K/IjvxDoDPGteG6kcDgMkUppRXACnUIsA7YUNegERXGAEwNQZellJbHzodFfPXUjIwtwHDglzJiS4lBe4SSMugCjgfWqo+rvwF/AH+pXWqnOqOfXDMSaK06oaKf54Z/D6igj1bvzXLK5+rTYchHGf5ZdXiFjPHBc2Udg84P5qMqsvdzQf9APbaEZ2JWVj5u5KbIV7PURZmM+XUMag/mk0to1wWtUx3YT9lZErwPq9er3dkt/E3tzU54Rp2SMauA3zMErS1zhTpWvURdEKe8V7jQrOBOUwcF/97qbPWrcPP8KoP2DQFzC/gLAj+vZM1Vak8hF61V31L7msWKOjROvE89q4yhNSy+rYBfGorGV8RcFSyqESZ7hOu+UQeUMfyidhRwy0LB0AJ+TRNj/qjb/0QpUT2jpYS+ERhTkswA9sqEjALGNdGzMqXUXTNZrogi3F5sJ64GDgXGFhasjvGYDDe4HyXf1i3qKaVe4DtgbF6ZzwHuiZq0b2HN8hjzAF3Xj9IhO9mGDQX68gy8PpqoB9XuEj93hp/nZLjzmsTQZzvR9uwXaxY0EHdEuzo5EpklHeB+0bhvV69RWwN/beDKYHpNg+6I2z2hce261M4gXlRVz9RD1S+zlnRh3JBropVtQHfIXB3B38yYadEjvdZAzMjLhXpizI+tEDA4Gv+yrnFH1LJxIbdX/aKsNma9+++RIrapxyT1TmAeMDKltFU9HPgcODOl9GKTnQ0EpgMHBaobWJVS+jnjOQV4ItLFO8CbwDZgBHAqMAXoBSYBHcBm1JfzZ28EuOrl/9ODc5R6Vzwyq6BDvVTtbgHGA2sKiXFbydXfJUgpbUwpLQAateqwQj4DuDjSTWuKru+BlNIN2a6+ACYCv0dH2PhtCtfYjx0t4ZYR0a7uGeNw4GpgLnBgxt8HfAJsSOpWYD1wH7AqvocAz0Q2bgNGB62RoQfF95FhZAswLIQSZaBRbqYDPwHLogqcEhvdp7CJPqC9vwL5VtyUjor42B69zqvqXxU8S+IFOyq6iYcqdD3VONqngV8jbhol4e0sntqAnuIzumZAt8bnIOC4lNKOlNKceL3cCvyQsd/87/WNRuk29T51/5ifHu/zJ2MH69WvCz+zE+oroXdlL9pUkYdeUi/89xLU6VWAZn88fQoMjNtTBS+klF6pc6p/A2ye4OCYzm1lAAAAAElFTkSuQmCC';
1078
+ }
1079
+ }
1080
+
1081
+
1082
+ function monsterinsights_get_shareasale_id() {
1083
+ // Check if there's a constant.
1084
+ $shareasale_id = '';
1085
+ if ( defined( 'MONSTERINSIGHTS_SHAREASALE_ID' ) ) {
1086
+ $shareasale_id = MONSTERINSIGHTS_SHAREASALE_ID;
1087
+ }
1088
+
1089
+ // If there's no constant, check if there's an option.
1090
+ if ( empty( $shareasale_id ) ) {
1091
+ $shareasale_id = get_option( 'monsterinsights_shareasale_id', '' );
1092
+ }
1093
+
1094
+ // Whether we have an ID or not, filter the ID.
1095
+ $shareasale_id = apply_filters( 'monsterinsights_shareasale_id', $shareasale_id );
1096
+
1097
+ // Ensure it's a number
1098
+ $shareasale_id = absint( $shareasale_id );
1099
+
1100
+ return $shareasale_id;
1101
+ }
1102
+
1103
+ // Passed in with mandatory default redirect and shareasaleid from monsterinsights_get_upgrade_link
1104
+ function monsterinsights_get_shareasale_url( $shareasale_id, $shareasale_redirect ) {
1105
+ // Check if there's a constant.
1106
+ $custom = false;
1107
+ if ( defined( 'MONSTERINSIGHTS_SHAREASALE_REDIRECT_URL' ) ) {
1108
+ $shareasale_redirect = MONSTERINSIGHTS_SHAREASALE_REDIRECT_URL;
1109
+ $custom = true;
1110
+ }
1111
+
1112
+ // If there's no constant, check if there's an option.
1113
+ if ( empty( $custom ) ) {
1114
+ $shareasale_redirect = get_option( 'monsterinsights_shareasale_redirect_url', '' );
1115
+ $custom = true;
1116
+ }
1117
+
1118
+ // Whether we have an ID or not, filter the ID.
1119
+ $shareasale_redirect = apply_filters( 'monsterinsights_shareasale_redirect_url', $shareasale_redirect, $custom );
1120
+ $shareasale_url = sprintf( 'https://www.shareasale.com/r.cfm?B=971799&U=%s&M=69975&urllink=%s', $shareasale_id, $shareasale_redirect );
1121
+ $shareasale_url = apply_filters( 'monsterinsights_shareasale_redirect_entire_url', $shareasale_url, $shareasale_id, $shareasale_redirect );
1122
+ return $shareasale_url;
1123
+ }
1124
+
1125
+ /**
1126
+ * Get a clean page title for archives.
1127
+ */
1128
+ function monsterinsights_get_page_title() {
1129
+
1130
+ $title = __( 'Archives' );
1131
+
1132
+ if ( is_category() ) {
1133
+ /* translators: Category archive title. %s: Category name */
1134
+ $title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
1135
+ } elseif ( is_tag() ) {
1136
+ /* translators: Tag archive title. %s: Tag name */
1137
+ $title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
1138
+ } elseif ( is_author() ) {
1139
+ /* translators: Author archive title. %s: Author name */
1140
+ $title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
1141
+ } elseif ( is_year() ) {
1142
+ /* translators: Yearly archive title. %s: Year */
1143
+ $title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
1144
+ } elseif ( is_month() ) {
1145
+ /* translators: Monthly archive title. %s: Month name and year */
1146
+ $title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) );
1147
+ } elseif ( is_day() ) {
1148
+ /* translators: Daily archive title. %s: Date */
1149
+ $title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) );
1150
+ } elseif ( is_tax( 'post_format' ) ) {
1151
+ if ( is_tax( 'post_format', 'post-format-aside' ) ) {
1152
+ $title = _x( 'Asides', 'post format archive title' );
1153
+ } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
1154
+ $title = _x( 'Galleries', 'post format archive title' );
1155
+ } elseif ( is_tax( 'post_format', 'post-format-image' ) ) {
1156
+ $title = _x( 'Images', 'post format archive title' );
1157
+ } elseif ( is_tax( 'post_format', 'post-format-video' ) ) {
1158
+ $title = _x( 'Videos', 'post format archive title' );
1159
+ } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) {
1160
+ $title = _x( 'Quotes', 'post format archive title' );
1161
+ } elseif ( is_tax( 'post_format', 'post-format-link' ) ) {
1162
+ $title = _x( 'Links', 'post format archive title' );
1163
+ } elseif ( is_tax( 'post_format', 'post-format-status' ) ) {
1164
+ $title = _x( 'Statuses', 'post format archive title' );
1165
+ } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) {
1166
+ $title = _x( 'Audio', 'post format archive title' );
1167
+ } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
1168
+ $title = _x( 'Chats', 'post format archive title' );
1169
+ }
1170
+ } elseif ( is_post_type_archive() ) {
1171
+ /* translators: Post type archive title. %s: Post type name */
1172
+ $title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
1173
+ } elseif ( is_tax() ) {
1174
+ $tax = get_taxonomy( get_queried_object()->taxonomy );
1175
+ /* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */
1176
+ $title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
1177
+ }
1178
+
1179
+ return $title;
1180
+
1181
+ }
1182
+
1183
+ /**
1184
+ * Make a request to the front page and check if the tracking code is present. Moved here from onboarding wizard
1185
+ * to be used in the site health check.
1186
+ *
1187
+ * @return array
1188
+ */
1189
+ function monsterinsights_is_code_installed_frontend() {
1190
+ // Grab the front page html.
1191
+ $request = wp_remote_request( home_url(), array(
1192
+ 'sslverify' => false,
1193
+ ) );
1194
+ $errors = array();
1195
+
1196
+ $accepted_http_codes = array(
1197
+ 200,
1198
+ 503
1199
+ );
1200
+
1201
+ $response_code = wp_remote_retrieve_response_code( $request );
1202
+
1203
+ if ( in_array( $response_code, $accepted_http_codes, true ) ) {
1204
+
1205
+ $body = wp_remote_retrieve_body( $request );
1206
+ $current_ua_code = monsterinsights_get_ua_to_output();
1207
+ $ua_limit = 2;
1208
+ // If the ads addon is installed another UA is added to the page.
1209
+ if ( class_exists( 'MonsterInsights_Ads' ) ) {
1210
+ $ua_limit = 3;
1211
+ }
1212
+ // Translators: The placeholders are for making the "We noticed you're using a caching plugin" text bold.
1213
+ $cache_error = sprintf( esc_html__( '%1$sWe noticed you\'re using a caching plugin or caching from your hosting provider.%2$s Be sure to clear the cache to ensure the tracking appears on all pages and posts. %3$s(See this guide on how to clear cache)%4$s.', 'google-analytics-for-wordpress' ), '<b>', '</b>', ' <a href="https://www.wpbeginner.com/beginners-guide/how-to-clear-your-cache-in-wordpress/" target="_blank">', '</a>' );
1214
+
1215
+ // Translators: The placeholders are for making the "We have detected multiple tracking codes" text bold & adding a link to support.
1216
+ $message = esc_html__( '%1$sWe have detected multiple tracking codes%2$s! You should remove non-MonsterInsights ones. If you need help finding them please %3$sread this article%4$s.', 'google-analytics-for-wordpress' );
1217
+ $url = monsterinsights_get_url( 'site-health', 'comingsoon', 'https://www.monsterinsights.com/docs/how-to-find-duplicate-google-analytics-tracking-codes-in-wordpress/' );
1218
+ $multiple_ua_error = sprintf(
1219
+ $message,
1220
+ '<b>',
1221
+ '</b>',
1222
+ '<a href="' . $url . '" target="_blank">',
1223
+ '</a>'
1224
+ );
1225
+
1226
+ // First, check if the tracking frontend code is present.
1227
+ if ( false === strpos( $body, '__gaTracker' ) ) {
1228
+ $errors[] = $cache_error;
1229
+ } else {
1230
+ // Check if the current UA code is actually present.
1231
+ if ( $current_ua_code && false === strpos( $body, $current_ua_code ) ) {
1232
+ // We have the tracking code but using another UA, so it's cached.
1233
+ $errors[] = $cache_error;
1234
+ }
1235
+
1236
+ // Grab all potential google site verification tags
1237
+ $pattern = '/content="UA-[0-9-]+"/';
1238
+ if ( preg_match_all( $pattern, $body, $matches ) ) {
1239
+ // Raise the number of UA limits
1240
+ $ua_limit += count( $matches[0] );
1241
+ }
1242
+
1243
+ // Grab all the UA codes from the page.
1244
+ $pattern = '/UA-[0-9]+/m';
1245
+ preg_match_all( $pattern, $body, $matches );
1246
+ // If more than twice ( because MI has a ga-disable-UA also ), let them know to remove the others.
1247
+ if ( ! empty( $matches[0] ) && is_array( $matches[0] ) && count( $matches[0] ) > $ua_limit ) {
1248
+ $errors[] = $multiple_ua_error;
1249
+ }
1250
+ }
1251
+ }
1252
+
1253
+ return $errors;
1254
+ }
1255
+
1256
+ /**
1257
+ * Returns a HEX color to highlight menu items based on the admin color scheme.
1258
+ */
1259
+ function monsterinsights_menu_highlight_color() {
1260
+
1261
+ $color_scheme = get_user_option( 'admin_color' );
1262
+ $color = '#7cc048';
1263
+ if ( 'light' === $color_scheme || 'blue' === $color_scheme ) {
1264
+ $color = '#5f3ea7';
1265
+ }
1266
+
1267
+ return $color;
1268
+ }
1269
+
1270
+ /**
1271
+ * Track Pretty Links redirects with MonsterInsights.
1272
+ *
1273
+ * @param string $url The url to which users get redirected.
1274
+ */
1275
+ function monsterinsights_custom_track_pretty_links_redirect( $url ) {
1276
+ if ( ! function_exists( 'monsterinsights_mp_track_event_call' ) ) {
1277
+ return;
1278
+ }
1279
+ // Try to determine if click originated on the same site.
1280
+ $referer = ! empty( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '';
1281
+ if ( ! empty( $referer ) ) {
1282
+ $current_site_url = get_bloginfo( 'url' );
1283
+ $current_site_parsed = wp_parse_url( $current_site_url );
1284
+ $parsed_referer = wp_parse_url( $referer );
1285
+ if ( ! empty( $parsed_referer['host'] ) && ! empty( $current_site_parsed['host'] ) && $current_site_parsed['host'] === $parsed_referer['host'] ) {
1286
+ // Don't track clicks originating from same site as those are tracked with JS.
1287
+ return;
1288
+ }
1289
+ }
1290
+ // Check if this is an affiliate link and use the appropriate category.
1291
+ $ec = 'outbound-link';
1292
+ $inbound_paths = monsterinsights_get_option( 'affiliate_links', array() );
1293
+ $path = empty( $_SERVER['REQUEST_URI'] ) ? '' : $_SERVER['REQUEST_URI'];
1294
+ if ( ! empty( $inbound_paths ) && is_array( $inbound_paths ) && ! empty( $path ) ) {
1295
+ $found = false;
1296
+ foreach ( $inbound_paths as $inbound_path ) {
1297
+ if ( empty( $inbound_path['path'] ) ) {
1298
+ continue;
1299
+ }
1300
+ if ( 0 === strpos( $path, trim( $inbound_path['path'] ) ) ) {
1301
+ $label = ! empty( $inbound_path['label'] ) ? trim( $inbound_path['label'] ) : 'aff';
1302
+ $ec .= '-' . $label;
1303
+ $found = true;
1304
+ break;
1305
+ }
1306
+ }
1307
+ if ( ! $found ) {
1308
+ return;
1309
+ }
1310
+ } else {
1311
+ // no paths setup in MonsterInsights settings
1312
+ return;
1313
+ }
1314
+
1315
+ $track_args = array(
1316
+ 't' => 'event',
1317
+ 'ec' => $ec,
1318
+ 'ea' => $url,
1319
+ 'el' => 'external-redirect',
1320
+ );
1321
+ monsterinsights_mp_track_event_call( $track_args );
1322
+ }
1323
+ add_action( 'prli_before_redirect', 'monsterinsights_custom_track_pretty_links_redirect' );
1324
+
1325
+ /**
1326
+ * Decode special characters, both alpha- (<) and numeric-based (').
1327
+ *
1328
+ * @since 7.10.5
1329
+ *
1330
+ * @param string $string Raw string to decode.
1331
+ *
1332
+ * @return string
1333
+ */
1334
+ function monsterinsights_decode_string( $string ) {
1335
+
1336
+ if ( ! is_string( $string ) ) {
1337
+ return $string;
1338
+ }
1339
+
1340
+ return wp_kses_decode_entities( html_entity_decode( $string, ENT_QUOTES ) );
1341
+ }
1342
+
1343
+ add_filter( 'monsterinsights_email_message', 'monsterinsights_decode_string' );
1344
+
1345
+ /**
1346
+ * Sanitize a string, that can be a multiline.
1347
+ * If WP core `sanitize_textarea_field()` exists (after 4.7.0) - use it.
1348
+ * Otherwise - split onto separate lines, sanitize each one, merge again.
1349
+ *
1350
+ * @since 7.10.5
1351
+ *
1352
+ * @param string $string
1353
+ *
1354
+ * @return string If empty var is passed, or not a string - return unmodified. Otherwise - sanitize.
1355
+ */
1356
+ function monsterinsights_sanitize_textarea_field( $string ) {
1357
+
1358
+ if ( empty( $string ) || ! is_string( $string ) ) {
1359
+ return $string;
1360
+ }
1361
+
1362
+ if ( function_exists( 'sanitize_textarea_field' ) ) {
1363
+ $string = sanitize_textarea_field( $string );
1364
+ } else {
1365
+ $string = implode( "\n", array_map( 'sanitize_text_field', explode( "\n", $string ) ) );
1366
+ }
1367
+
1368
+ return $string;
1369
+ }
1370
+
1371
+ /**
1372
+ * Trim a sentence
1373
+ *
1374
+ * @since 7.10.5
1375
+ *
1376
+ * @param string $string
1377
+ * @param int $count
1378
+ *
1379
+ * @return trimed sentence
1380
+ */
1381
+ function monsterinsights_trim_text( $text, $count ){
1382
+ $text = str_replace(" ", " ", $text);
1383
+ $string = explode(" ", $text);
1384
+ $trimed = "";
1385
+
1386
+ for ( $wordCounter = 0; $wordCounter <= $count; $wordCounter++ ) {
1387
+ $trimed .= isset( $string[$wordCounter] ) ? $string[$wordCounter] : '';
1388
+
1389
+ if ( $wordCounter < $count ){
1390
+ $trimed .= " ";
1391
+ } else {
1392
+ $trimed .= "...";
1393
+ }
1394
+ }
1395
+
1396
+ $trimed = trim($trimed);
1397
+
1398
+ return $trimed;
1399
+ }
1400
+
1401
+ /**
1402
+ * Add newly generated builder URL to PrettyLinks &
1403
+ * Clear localStorage key(MonsterInsightsURL) after saving PrettyLink
1404
+ */
1405
+ function monsterinsights_tools_copy_url_to_prettylinks() {
1406
+ global $pagenow;
1407
+
1408
+ $post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : '';
1409
+ $monsterinsights_reference = isset( $_GET['monsterinsights_reference'] ) ? $_GET['monsterinsights_reference'] : '';
1410
+
1411
+ if ( 'post-new.php' === $pagenow && 'pretty-link' === $post_type && 'url_builder' === $monsterinsights_reference ) { ?>
1412
+ <script>
1413
+ let targetTitleField = document.querySelector("input[name='post_title']");
1414
+ let targetUrlField = document.querySelector("textarea[name='prli_url']");
1415
+ let monsterInsightsUrl = JSON.parse(localStorage.getItem('MonsterInsightsURL'));
1416
+ if ( 'undefined' !== typeof targetUrlField && 'undefined' !== typeof monsterInsightsUrl ) {
1417
+ let url = monsterInsightsUrl.value;
1418
+ let postTitle = '';
1419
+ let pathArray = url.split('?');
1420
+ if ( pathArray.length <= 1 ) {
1421
+ pathArray = url.split('#');
1422
+ }
1423
+ let urlParams = new URLSearchParams(pathArray[1]);
1424
+ if (urlParams.has('utm_campaign')) {
1425
+ let campaign_name = urlParams.get('utm_campaign');
1426
+ postTitle += campaign_name;
1427
+ }
1428
+ if (urlParams.has('utm_medium')) {
1429
+ let campaign_medium = urlParams.get('utm_medium');
1430
+ postTitle += ` ${campaign_medium}`;
1431
+ }
1432
+ if (urlParams.has('utm_source')) {
1433
+ let campaign_source = urlParams.get('utm_source');
1434
+ postTitle += ` on ${campaign_source}`;
1435
+ }
1436
+ if (urlParams.has('utm_term')) {
1437
+ let campaign_term = urlParams.get('utm_term');
1438
+ postTitle += ` for ${campaign_term}`;
1439
+ }
1440
+ if (urlParams.has('utm_content')) {
1441
+ let campaign_content = urlParams.get('utm_content');
1442
+ postTitle += ` - ${campaign_content}`;
1443
+ }
1444
+ if ( 'undefined' !== typeof targetTitleField && postTitle ) {
1445
+ targetTitleField.value = postTitle;
1446
+ }
1447
+ if( url ) {
1448
+ targetUrlField.value = url;
1449
+ }
1450
+ }
1451
+ let form = document.getElementById('post');
1452
+ form.addEventListener('submit', function(){
1453
+ localStorage.removeItem('MonsterInsightsURL');
1454
+ });
1455
+ </script>
1456
+ <?php }
1457
+ }
1458
+ add_action( 'admin_footer', 'monsterinsights_tools_copy_url_to_prettylinks' );
1459
+
1460
+ /**
1461
+ * When click on 'Create New Pretty Link" button(on tools/prettylinks-flow page) after installing & activating prettylinks plugin
1462
+ * it redirects to PrettyLinks welcome scree page instead of prettylinks add new page.
1463
+ * This function will skip that welcome screen
1464
+ */
1465
+ function monsterinsights_skip_prettylinks_welcome_screen() {
1466
+ global $pagenow;
1467
+
1468
+ $post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : '';
1469
+ $monsterinsights_reference = isset( $_GET['monsterinsights_reference'] ) ? $_GET['monsterinsights_reference'] : '';
1470
+
1471
+ if ( 'post-new.php' === $pagenow && 'pretty-link' === $post_type && 'url_builder' === $monsterinsights_reference ) {
1472
+ $onboard = get_option( 'prli_onboard' );
1473
+
1474
+ if ( $onboard == 'welcome' || $onboard == 'update' ) {
1475
+ update_option( 'monsterinsights_backup_prli_onboard_value', $onboard );
1476
+ delete_option( 'prli_onboard' );
1477
+ }
1478
+ }
1479
+ }
1480
+ add_action( 'wp_loaded', 'monsterinsights_skip_prettylinks_welcome_screen', 9 );
1481
+
1482
+ /**
1483
+ * Restore the `prli_onboard` value after creating a prettylinks with monsterinsights prettylinks flow
1484
+ * users will see the prettylinks welcome screen after fresh installation & creating prettylinks with monsterinsights prettylinks flow
1485
+ */
1486
+ function monsterinsights_restore_prettylinks_onboard_value() {
1487
+ global $pagenow;
1488
+
1489
+ $post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : '';
1490
+
1491
+ if ( 'edit.php' === $pagenow && 'pretty-link' === $post_type ) {
1492
+ $onboard = get_option( 'monsterinsights_backup_prli_onboard_value' );
1493
+
1494
+ if ( class_exists( 'PrliBaseController' ) && ( $onboard == 'welcome' || $onboard == 'update' ) ) {
1495
+ update_option( 'prli_onboard', $onboard );
1496
+ delete_option( 'monsterinsights_backup_prli_onboard_value' );
1497
+ }
1498
+ }
1499
+ }
1500
+ add_action( 'wp_loaded', 'monsterinsights_restore_prettylinks_onboard_value', 15 );
includes/index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- //Nothing to see here
3
-
4
  header( 'HTTP/1.0 403 Forbidden' );
1
+ <?php
2
+ //Nothing to see here
3
+
4
  header( 'HTTP/1.0 403 Forbidden' );
includes/install.php CHANGED
@@ -1,673 +1,705 @@
1
- <?php
2
- /**
3
- * MonsterInsights Installation and Automatic Upgrades.
4
- *
5
- * This file handles setting up new
6
- * MonsterInsights installs as well as performing
7
- * behind the scene upgrades between
8
- * MonsterInsights versions.
9
- *
10
- * @package MonsterInsights
11
- * @subpackage Install/Upgrade
12
- * @since 6.0.0
13
- */
14
-
15
- // Exit if accessed directly
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- exit;
18
- }
19
-
20
- /**
21
- * MonsterInsights Install.
22
- *
23
- * This class handles a new MI install
24
- * as well as automatic (non-user initiated)
25
- * upgrade routines.
26
- *
27
- * @since 6.0.0
28
- * @access public
29
- */
30
- class MonsterInsights_Install {
31
-
32
- /**
33
- * MI Settings.
34
- *
35
- * @since 6.0.0
36
- * @access public
37
- * @var array $new_settings When the init() function starts, initially
38
- * contains the original settings. At the end
39
- * of init() contains the settings to save.
40
- */
41
- public $new_settings = array();
42
-
43
- /**
44
- * Install/Upgrade routine.
45
- *
46
- * This function is what is called to actually install MI data on new installs and to do
47
- * behind the scenes upgrades on MI upgrades. If this function contains a bug, the results
48
- * can be catastrophic. This function gets the highest priority in all of MI for unit tests.
49
- *
50
- * @since 6.0.0
51
- * @access public
52
- *
53
- * @return void
54
- */
55
- public function init() {
56
-
57
- // Get a copy of the current MI settings.
58
- $this->new_settings = get_option( monsterinsights_get_option_name() );
59
-
60
- $version = get_option( 'monsterinsights_current_version', false );
61
- $cachec = false; // have we forced an object cache to be cleared already (so we don't clear it unnecessarily)
62
-
63
- // if new install or Yoast Era instal
64
- if ( ! $version ) {
65
- // See if from Yoast
66
- $yoast = get_option( 'yst_ga', false );
67
-
68
- // In case from Yoast, start from scratch
69
- delete_option( 'yoast-ga-access_token' );
70
- delete_option( 'yoast-ga-refresh_token' );
71
- delete_option( 'yst_ga' );
72
- delete_option( 'yst_ga_api' );
73
-
74
- $this->new_install();
75
-
76
- // set db version (Do not increment! See below large comment)
77
- update_option( 'monsterinsights_db_version', '7.4.0' );
78
-
79
- // Remove Yoast hook if present
80
- if ( wp_next_scheduled( 'yst_ga_aggregate_data' ) ) {
81
- wp_clear_scheduled_hook( 'yst_ga_aggregate_data' );
82
- }
83
-
84
- // Clear cache since coming from Yoast
85
- if ( ! $cachec && ! empty( $yoast ) ) {
86
- wp_cache_flush();
87
- $cachec = true;
88
- }
89
- } else { // if existing install
90
- if ( version_compare( $version, '6.0.11', '<' ) ) {
91
- if ( ! $cachec ) {
92
- wp_cache_flush();
93
- $cachec = true;
94
- }
95
- }
96
-
97
- if ( version_compare( $version, '7.0.0', '<' ) ) {
98
- $this->v700_upgrades();
99
- }
100
-
101
- if ( version_compare( $version, '7.4.0', '<' ) ) {
102
- $this->v740_upgrades();
103
- // Do not increment! See below large comment
104
- update_option( 'monsterinsights_db_version', '7.4.0' );
105
- }
106
-
107
- if ( version_compare( $version, '7.5.0', '<' ) ) {
108
- $this->v750_upgrades();
109
- }
110
-
111
- if ( version_compare( $version, '7.6.0', '<' ) ) {
112
- $this->v760_upgrades();
113
- }
114
-
115
- if ( version_compare( $version, '7.7.1', '<' ) ) {
116
- $this->v771_upgrades();
117
- }
118
-
119
- if ( version_compare( $version, '7.8.0', '<' ) ) {
120
- $this->v780_upgrades();
121
- }
122
-
123
- if ( version_compare( $version, '7.9.0', '<' ) ) {
124
- $this->v790_upgrades();
125
- }
126
-
127
- if ( version_compare( $version, '7.10.0', '<' ) ) {
128
- $this->v7100_upgrades();
129
- }
130
-
131
- // Do not use. See monsterinsights_after_install_routine comment below.
132
- do_action( 'monsterinsights_after_existing_upgrade_routine', $version );
133
- $version = get_option( 'monsterinsights_current_version', $version );
134
- update_option( 'monsterinsights_version_upgraded_from', $version );
135
- }
136
-
137
- // This hook is used primarily by the Pro version to run some Pro
138
- // specific install stuff. Please do not use this hook. It is not
139
- // considered a public hook by MI's dev team and can/will be removed,
140
- // relocated, and/or altered without warning at any time. You've been warned.
141
- // As this hook is not for public use, we've intentionally not docbloc'd this
142
- // hook to avoid developers seeing it future public dev docs.
143
- do_action( 'monsterinsights_after_install_routine', $version );
144
-
145
- // This is the version of MI installed
146
- update_option( 'monsterinsights_current_version', MONSTERINSIGHTS_VERSION );
147
-
148
- // This is where we save MI settings
149
- update_option( monsterinsights_get_option_name(), $this->new_settings );
150
-
151
- // There's no code for this function below this. Just an explanation
152
- // of the MI core options.
153
-
154
- /**
155
- * Explanation of MonsterInsights core options
156
- *
157
- * By now your head is probably spinning trying to figure
158
- * out what all of these version options are for. Note, I've abbreviated
159
- * "monsterinsights" to "mi" in the options names to make this table easier
160
- * to read.
161
- *
162
- * Here's a basic rundown:
163
- *
164
- * mi_current_version: This starts with the actual version MI was
165
- * installed on. We use this version to
166
- * determine whether or not a site needs
167
- * to run one of the behind the scenes
168
- * MI upgrade routines. This version is updated
169
- * every time a minor or major background upgrade
170
- * routine is run. Generally lags behind the
171
- * MONSTERINSIGHTS_VERSION constant by at most a couple minor
172
- * versions. Never lags behind by 1 major version
173
- * or more generally.
174
- *
175
- * mi_db_version: This is different from mi_current_version.
176
- * Unlike the former, this is used to determine
177
- * if a site needs to run a *user* initiated
178
- * upgrade routine (incremented in MI_Upgrade class). This
179
- * value is only update when a user initiated
180
- * upgrade routine is done. Because we do very
181
- * few user initiated upgrades compared to
182
- * automatic ones, this version can lag behind by
183
- * 2 or even 3 major versions. Generally contains
184
- * the current major version.
185
- *
186
- * mi_settings: Returned by monsterinsights_get_option_name(), this
187
- * is actually "monsterinsights_settings" for both pro
188
- * and lite version. However we use a helper function to
189
- * retrieve the option name in case we ever decide down the
190
- * road to maintain seperate options for the Lite and Pro versions.
191
- * If you need to access MI's settings directly, (as opposed to our
192
- * monsterinsights_get_option helper which uses the option name helper
193
- * automatically), you should use this function to get the
194
- * name of the option to retrieve.
195
- *
196
- * Therefore you should never increment mi_db_version in this file and always increment mi_current_version.
197
- */
198
- }
199
-
200
-
201
- /**
202
- * New MonsterInsights Install routine.
203
- *
204
- * This function installs all of the default
205
- * things on new MI installs. Flight 5476 with
206
- * non-stop service to a whole world of
207
- * possibilities is now boarding.
208
- *
209
- * @since 6.0.0
210
- * @access public
211
- *
212
- * @return void
213
- */
214
- public function new_install() {
215
-
216
- // Add default settings values
217
- $this->new_settings = $this->get_monsterinsights_default_values();
218
-
219
- $this->maybe_import_thirstyaffiliates_options();
220
-
221
- $data = array(
222
- 'installed_version' => MONSTERINSIGHTS_VERSION,
223
- 'installed_date' => time(),
224
- 'installed_pro' => monsterinsights_is_pro_version(),
225
- );
226
-
227
- update_option( 'monsterinsights_over_time', $data );
228
-
229
- // Let addons + MI Pro/Lite hook in here. @todo: doc as nonpublic
230
- do_action( 'monsterinsights_after_new_install_routine', MONSTERINSIGHTS_VERSION );
231
- }
232
-
233
- public function get_monsterinsights_default_values() {
234
- return array(
235
- 'enable_affiliate_links' => true,
236
- 'affiliate_links' => array(
237
- array(
238
- 'path' => '/go/',
239
- 'label' => 'affiliate',
240
- ),
241
- array(
242
- 'path' => '/recommend/',
243
- 'label' => 'affiliate',
244
- )
245
- ),
246
- 'demographics' => 1,
247
- 'ignore_users' => array( 'administrator', 'editor' ),
248
- 'dashboards_disabled' => 0,
249
- 'anonymize_ips' => 0,
250
- 'extensions_of_files' => 'doc,pdf,ppt,zip,xls,docx,pptx,xlsx',
251
- 'subdomain_tracking' => '',
252
- 'link_attribution' => true,
253
- 'tag_links_in_rss' => true,
254
- 'allow_anchor' => 0,
255
- 'add_allow_linker' => 0,
256
- 'custom_code' => '',
257
- 'save_settings' => array( 'administrator' ),
258
- 'view_reports' => array( 'administrator', 'editor' ),
259
- 'events_mode' => 'js',
260
- 'tracking_mode' => 'analytics',
261
- );
262
- }
263
-
264
- /**
265
- * Check if ThirstyAffiliates plugin is installed and use the link prefix value in the affiliate settings.
266
- *
267
- * @return void
268
- */
269
- public function maybe_import_thirstyaffiliates_options() {
270
-
271
- // Check if ThirstyAffiliates is installed.
272
- if ( ! function_exists( 'ThirstyAffiliates' ) ) {
273
- return;
274
- }
275
-
276
- $link_prefix = get_option( 'ta_link_prefix', 'recommends' );
277
-
278
- if ( $link_prefix === 'custom' ) {
279
- $link_prefix = get_option( 'ta_link_prefix_custom', 'recommends' );
280
- }
281
-
282
- if ( ! empty( $link_prefix ) ) {
283
-
284
- // Check if prefix exists.
285
- $prefix_set = false;
286
- foreach ( $this->new_settings['affiliate_links'] as $affiliate_link ) {
287
- if ( $link_prefix === trim( $affiliate_link['path'], '/' ) ) {
288
- $prefix_set = true;
289
- break;
290
- }
291
- }
292
-
293
- if ( ! $prefix_set ) {
294
- $this->new_settings['affiliate_links'][] = array(
295
- 'path' => '/' . $link_prefix . '/',
296
- 'label' => 'affiliate',
297
- );
298
- }
299
- }
300
- }
301
-
302
- /**
303
- * MonsterInsights Version 7.0 upgrades.
304
- *
305
- * This function does the
306
- * upgrade routine from MonsterInsights 6.2->7.0.
307
- *
308
- * @since 7.0.0
309
- * @access public
310
- *
311
- * @return void
312
- */
313
- public function v700_upgrades() {
314
- // 1. Default all event tracking and tracking to GA + JS respectively
315
- // 3a Set tracking_mode to use analytics.js
316
- $this->new_settings['tracking_mode' ] = 'analytics';
317
-
318
-
319
- // 3b Set events mode to use JS if the events mode is not set explicitly to none
320
- if ( empty( $this->new_settings['events_mode' ] ) || $this->new_settings['events_mode' ] !== 'none' ) {
321
- $this->new_settings['events_mode' ] = 'js';
322
- }
323
-
324
- // 2. Migrate manual UA codes
325
- // 2a Manual UA has the lowest priority
326
- if ( ! empty( $this->new_settings['manual_ua_code' ] ) ) {
327
- // Set as manual UA code
328
- is_network_admin() ? update_site_option( 'monsterinsights_network_profile', array( 'manual' => $this->new_settings['manual_ua_code' ] ) ) : update_option( 'monsterinsights_site_profile', array( 'manual' => $this->new_settings['manual_ua_code' ] ) );
329
- }
330
-
331
- // 2b Then try the oAuth UA code
332
- if ( ! empty( $this->new_settings['analytics_profile_code' ] ) ) {
333
- // Set as manual UA code
334
- is_network_admin() ? update_site_option( 'monsterinsights_network_profile', array( 'manual' => $this->new_settings['analytics_profile_code' ] ) ) : update_option( 'monsterinsights_site_profile', array( 'manual' => $this->new_settings['analytics_profile_code' ] ) );
335
- }
336
-
337
- // 3. Migrate License keys
338
- if ( is_multisite() ) {
339
- $ms_license = get_site_option( 'monsterinsights_license', '' );
340
- if ( $ms_license ) {
341
- update_site_option( 'monsterinsights_network_license_updates', get_site_option( 'monsterinsights_license_updates', '' ) );
342
- update_site_option( 'monsterinsights_network_license', $ms_license );
343
- }
344
- }
345
- }
346
-
347
- /**
348
- * Upgrade routine for the new settings panel, onboarding wizard, and the internal-as-outbound v2 settings system.
349
- */
350
- public function v740_upgrades() {
351
-
352
- // 1. Settings Conversions:
353
- // Convert affiliate field to repeater format
354
- if ( ! empty( $this->new_settings['track_internal_as_outbound'] ) ) {
355
- $affiliate_old_paths = $this->new_settings['track_internal_as_outbound'];
356
- $affiliate_old_label = isset( $this->new_settings['track_internal_as_label'] ) ? $this->new_settings['track_internal_as_label'] : '';
357
-
358
- $new_paths = explode( ',', $affiliate_old_paths );
359
-
360
- $this->new_settings['affiliate_links'] = array();
361
- if ( ! empty( $new_paths ) ) {
362
- $this->new_settings['enable_affiliate_links'] = true;
363
- foreach ( $new_paths as $new_path ) {
364
- $this->new_settings['affiliate_links'][] = array(
365
- 'path' => $new_path,
366
- 'label' => $affiliate_old_label,
367
- );
368
- }
369
- }
370
-
371
- $settings = array(
372
- 'track_internal_as_outbound',
373
- 'track_internal_as_label',
374
- );
375
- foreach ( $settings as $setting ) {
376
- if ( ! empty( $this->new_settings[ $setting ] ) ) {
377
- unset( $this->new_settings[ $setting ] );
378
- }
379
- }
380
- }
381
-
382
- // Update option to disable just reports or also the dashboard widget.
383
- if ( isset( $this->new_settings['dashboards_disabled'] ) && $this->new_settings['dashboards_disabled'] ) {
384
- $this->new_settings['dashboards_disabled'] = 'disabled';
385
- }
386
-
387
- $this->new_settings['tracking_mode'] = 'analytics';
388
- $this->new_settings['events_mode'] = 'js';
389
-
390
- // If opted in during allow_tracking era, move that over
391
- if ( ! empty( $this->new_settings['allow_tracking'] ) ) {
392
- $this->new_settings['anonymous_data'] = 1;
393
- }
394
-
395
- // 2. Remove Yoast stuff
396
- delete_option( 'yoast-ga-access_token' );
397
- delete_option( 'yoast-ga-refresh_token' );
398
- delete_option( 'yst_ga' );
399
- delete_option( 'yst_ga_api' );
400
-
401
-
402
- // 3. Remove fake settings from other plugins using our key for some reason and old settings of ours
403
- $settings = array(
404
- 'debug_mode',
405
- 'track_download_as',
406
- 'analytics_profile',
407
- 'analytics_profile_code',
408
- 'analytics_profile_name',
409
- 'manual_ua_code',
410
- 'track_outbound',
411
- 'track_download_as',
412
- 'enhanced_link_attribution',
413
- 'oauth_version',
414
- 'monsterinsights_oauth_status',
415
- 'firebug_lite',
416
- 'google_auth_code',
417
- 'allow_tracking',
418
- );
419
-
420
- foreach ( $settings as $setting ) {
421
- if ( ! empty( $this->new_settings[ $setting ] ) ) {
422
- unset( $this->new_settings[ $setting ] );
423
- }
424
- }
425
-
426
- $settings = array(
427
- '_repeated',
428
- 'ajax',
429
- 'asmselect0',
430
- 'bawac_force_nonce',
431
- 'icl_post_language',
432
- 'saved_values',
433
- 'mlcf_email',
434
- 'mlcf_name',
435
- 'cron_failed',
436
- 'undefined',
437
- 'cf_email',
438
- 'cf_message',
439
- 'cf_name',
440
- 'cf_number',
441
- 'cf_phone',
442
- 'cf_subject',
443
- 'content',
444
- 'credentials',
445
- 'cron_failed',
446
- 'cron_last_run',
447
- 'global-css',
448
- 'grids',
449
- 'page',
450
- 'punch-fonts',
451
- 'return_tab',
452
- 'skins',
453
- 'navigation-skins',
454
- 'title',
455
- 'type',
456
- 'wpcf_email',
457
- 'wpcf_your_name',
458
- );
459
-
460
- foreach ( $settings as $setting ) {
461
- if ( ! empty( $this->new_settings[ $setting ] ) ) {
462
- unset( $this->new_settings[ $setting ] );
463
- }
464
- }
465
-
466
- // 4. Remove old crons
467
- if ( wp_next_scheduled( 'monsterinsights_daily_cron' ) ) {
468
- wp_clear_scheduled_hook( 'monsterinsights_daily_cron' );
469
- }
470
- if ( wp_next_scheduled( 'monsterinsights_send_tracking_data' ) ) {
471
- wp_clear_scheduled_hook( 'monsterinsights_send_tracking_data' );
472
- }
473
-
474
- if ( wp_next_scheduled( 'monsterinsights_send_tracking_checkin' ) ) {
475
- wp_clear_scheduled_hook( 'monsterinsights_send_tracking_checkin' );
476
- }
477
-
478
- if ( wp_next_scheduled( 'monsterinsights_weekly_cron' ) ) {
479
- wp_clear_scheduled_hook( 'monsterinsights_weekly_cron' );
480
- }
481
-
482
- if ( wp_next_scheduled( 'yst_ga_aggregate_data' ) ) {
483
- wp_clear_scheduled_hook( 'yst_ga_aggregate_data' );
484
- }
485
-
486
- delete_option( 'monsterinsights_tracking_last_send' );
487
- delete_option( 'mi_tracking_last_send' );
488
-
489
- // 5. Remove old option
490
- delete_option( 'monsterinsights_settings_version' );
491
- }
492
-
493
-
494
- /**
495
- * Upgrade routine
496
- */
497
- public function v750_upgrades() {
498
- // 1. One time re-prompt for anonymous data (due to migration bug now fixed)
499
- // if ( ! monsterinsights_is_pro_version() ) {
500
- // if ( empty( $this->new_settings[ 'anonymous_data' ] ) ) {
501
- // update_option( 'monsterinsights_tracking_notice', 0 );
502
- // }
503
- // }
504
- //
505
- // 2. Clear old settings ( 'tracking_mode','events_mode',)
506
-
507
-
508
- // 3. Attempt to extract the cross-domain settings from the Custom Code area and use in the new option.
509
- $custom_code = isset( $this->new_settings['custom_code'] ) ? $this->new_settings['custom_code'] : '';
510
- if ( ! empty( $custom_code ) ) {
511
- $pattern = '/(?:\'linker:autoLink\', )(?:\[)(.*)(?:\])/m';
512
- preg_match_all( $pattern, $custom_code, $matches, PREG_SET_ORDER, 0 );
513
- if ( ! empty( $matches ) && isset( $matches[0] ) && isset( $matches[0][1] ) ) {
514
- $cross_domains = array();
515
- $domains = explode( ',', $matches[0][1] );
516
- foreach ( $domains as $key => $domain ) {
517
- $domain = trim( $domain );
518
- $cross_domains[] = array(
519
- 'domain' => trim( $domain, '\'\"' ),
520
- );
521
- }
522
- $this->new_settings['add_allow_linker'] = true;
523
- $this->new_settings['cross_domains'] = $cross_domains;
524
-
525
- $notices = get_option( 'monsterinsights_notices' );
526
- if ( ! is_array( $notices ) ) {
527
- $notices = array();
528
- }
529
- $notices['monsterinsights_cross_domains_extracted'] = false;
530
- update_option( 'monsterinsights_notices', $notices );
531
- }
532
- }
533
- }
534
-
535
- /**
536
- * Upgrade routine for version 7.6.0
537
- */
538
- public function v760_upgrades() {
539
-
540
- $cross_domains = isset( $this->new_settings['cross_domains'] ) ? $this->new_settings['cross_domains'] : array();
541
-
542
- if ( ! empty( $cross_domains ) && is_array( $cross_domains ) ) {
543
- $current_domain = wp_parse_url( home_url() );
544
- $current_domain = isset( $current_domain['host'] ) ? $current_domain['host'] : '';
545
- if ( ! empty( $current_domain ) ) {
546
- $regex = '/^(?:' . $current_domain . '|(?:.+)\.' . $current_domain . ')$/m';
547
- foreach ( $cross_domains as $key => $cross_domain ) {
548
- if ( ! isset( $cross_domain['domain'] ) ) {
549
- continue;
550
- }
551
- preg_match( $regex, $cross_domain['domain'], $matches );
552
- if ( count( $matches ) > 0 ) {
553
- unset( $this->new_settings['cross_domains'][ $key ] );
554
- }
555
- }
556
- }
557
- }
558
-
559
- }
560
-
561
- /**
562
- * Upgrade routine for version 7.7.1
563
- */
564
- public function v771_upgrades() {
565
-
566
- if ( ! monsterinsights_is_pro_version() ) {
567
- // We only need to run this for the Pro version.
568
- return;
569
- }
570
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
571
-
572
- $plugin = 'wp-scroll-depth/wp-scroll-depth.php';
573
- // Check if wp-scroll-depth is active and deactivate to avoid conflicts with the pro scroll tracking feature.
574
- if ( is_plugin_active( $plugin ) ) {
575
- deactivate_plugins( $plugin );
576
- }
577
-
578
- }
579
-
580
- /**
581
- * Upgrade routine for version 7.8.0
582
- */
583
- public function v780_upgrades() {
584
-
585
- if ( monsterinsights_get_ua() ) {
586
- // If we have a UA, don't show the first run notice.
587
- monsterinsights_update_option( 'monsterinsights_first_run_notice', true );
588
-
589
- // If they are already tracking when they upgrade, mark connected time as now.
590
- $over_time = get_option( 'monsterinsights_over_time', array() );
591
- if ( empty( $over_time['connected_date'] ) ) {
592
- $over_time['connected_date'] = time();
593
- update_option( 'monsterinsights_over_time', $over_time );
594
- }
595
- }
596
-
597
- }
598
-
599
- /**
600
- * Upgrade routine for version 7.9.0
601
- */
602
- public function v790_upgrades() {
603
-
604
- // If they are already tracking, don't show the notice.
605
- if ( monsterinsights_get_ua() ) {
606
- update_option( 'monsterinsights_frontend_tracking_notice_viewed', true );
607
-
608
- // If they are already tracking when they upgrade & not already marked mark connected time as now.
609
- // Adding this here again as 7.8.0 upgrade didn't run for all users.
610
- $over_time = get_option( 'monsterinsights_over_time', array() );
611
- if ( empty( $over_time['connected_date'] ) ) {
612
- $over_time['connected_date'] = time();
613
- update_option( 'monsterinsights_over_time', $over_time );
614
- }
615
- }
616
-
617
- }
618
-
619
- /**
620
- * Upgrade routine for version 8.0.0
621
- */
622
- public function v7100_upgrades() {
623
-
624
- // Remove exe js and tgz from file downloads tracking.
625
- $current_downloads = isset( $this->new_settings['extensions_of_files'] ) ? $this->new_settings['extensions_of_files'] : array();
626
-
627
- if ( ! empty( $current_downloads ) ) {
628
- $extensions_to_remove = array(
629
- 'exe',
630
- 'js',
631
- 'tgz'
632
- );
633
- $extensions_to_add = array(
634
- 'docx',
635
- 'pptx',
636
- 'xlsx',
637
- );
638
-
639
- $extensions = explode( ',', $current_downloads );
640
- $updated_extensions = array();
641
-
642
- if ( ! empty( $extensions ) && is_array( $extensions ) ) {
643
- foreach ( $extensions as $extension ) {
644
- if ( ! in_array( $extension, $extensions_to_remove ) ) {
645
- $updated_extensions[] = $extension;
646
- }
647
- }
648
- }
649
-
650
- foreach ( $extensions_to_add as $extension_to_add ) {
651
- if ( ! in_array( $extension_to_add, $updated_extensions ) ) {
652
- $updated_extensions[] = $extension_to_add;
653
- }
654
- }
655
- } else {
656
- $updated_extensions = array(
657
- 'pdf',
658
- 'doc',
659
- 'ppt',
660
- 'xls',
661
- 'zip',
662
- 'docx',
663
- 'pptx',
664
- 'xlsx',
665
- );
666
- }
667
-
668
- $updated_extensions = implode( ',', $updated_extensions );
669
-
670
- $this->new_settings['extensions_of_files'] = $updated_extensions;
671
-
672
- }
673
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MonsterInsights Installation and Automatic Upgrades.
4
+ *
5
+ * This file handles setting up new
6
+ * MonsterInsights installs as well as performing
7
+ * behind the scene upgrades between
8
+ * MonsterInsights versions.
9
+ *
10
+ * @package MonsterInsights
11
+ * @subpackage Install/Upgrade
12
+ * @since 6.0.0
13
+ */
14
+
15
+ // Exit if accessed directly
16
+ if ( ! defined( 'ABSPATH' ) ) {
17
+ exit;
18
+ }
19
+
20
+ /**
21
+ * MonsterInsights Install.
22
+ *
23
+ * This class handles a new MI install
24
+ * as well as automatic (non-user initiated)
25
+ * upgrade routines.
26
+ *
27
+ * @since 6.0.0
28
+ * @access public
29
+ */
30
+ class MonsterInsights_Install {
31
+
32
+ /**
33
+ * MI Settings.
34
+ *
35
+ * @since 6.0.0
36
+ * @access public
37
+ * @var array $new_settings When the init() function starts, initially
38
+ * contains the original settings. At the end
39
+ * of init() contains the settings to save.
40
+ */
41
+ public $new_settings = array();
42
+
43
+ /**
44
+ * Install/Upgrade routine.
45
+ *
46
+ * This function is what is called to actually install MI data on new installs and to do
47
+ * behind the scenes upgrades on MI upgrades. If this function contains a bug, the results
48
+ * can be catastrophic. This function gets the highest priority in all of MI for unit tests.
49
+ *
50
+ * @since 6.0.0
51
+ * @access public
52
+ *
53
+ * @return void
54
+ */
55
+ public function init() {
56
+
57
+ // Get a copy of the current MI settings.
58
+ $this->new_settings = get_option( monsterinsights_get_option_name() );
59
+
60
+ $version = get_option( 'monsterinsights_current_version', false );
61
+ $cachec = false; // have we forced an object cache to be cleared already (so we don't clear it unnecessarily)
62
+
63
+ // if new install or Yoast Era instal
64
+ if ( ! $version ) {
65
+ // See if from Yoast
66
+ $yoast = get_option( 'yst_ga', false );
67
+
68
+ // In case from Yoast, start from scratch
69
+ delete_option( 'yoast-ga-access_token' );
70
+ delete_option( 'yoast-ga-refresh_token' );
71
+ delete_option( 'yst_ga' );
72
+ delete_option( 'yst_ga_api' );
73
+
74
+ $this->new_install();
75
+
76
+ // set db version (Do not increment! See below large comment)
77
+ update_option( 'monsterinsights_db_version', '7.4.0' );
78
+
79
+ // Remove Yoast hook if present
80
+ if ( wp_next_scheduled( 'yst_ga_aggregate_data' ) ) {
81
+ wp_clear_scheduled_hook( 'yst_ga_aggregate_data' );
82
+ }
83
+
84
+ // Clear cache since coming from Yoast
85
+ if ( ! $cachec && ! empty( $yoast ) ) {
86
+ wp_cache_flush();
87
+ $cachec = true;
88
+ }
89
+ } else { // if existing install
90
+ if ( version_compare( $version, '6.0.11', '<' ) ) {
91
+ if ( ! $cachec ) {
92
+ wp_cache_flush();
93
+ $cachec = true;
94
+ }
95
+ }
96
+
97
+ if ( version_compare( $version, '7.0.0', '<' ) ) {
98
+ $this->v700_upgrades();
99
+ }
100
+
101
+ if ( version_compare( $version, '7.4.0', '<' ) ) {
102
+ $this->v740_upgrades();
103
+ // Do not increment! See below large comment
104
+ update_option( 'monsterinsights_db_version', '7.4.0' );
105
+ }
106
+
107
+ if ( version_compare( $version, '7.5.0', '<' ) ) {
108
+ $this->v750_upgrades();
109
+ }
110
+
111
+ if ( version_compare( $version, '7.6.0', '<' ) ) {
112
+ $this->v760_upgrades();
113
+ }
114
+
115
+ if ( version_compare( $version, '7.7.1', '<' ) ) {
116
+ $this->v771_upgrades();
117
+ }
118
+
119
+ if ( version_compare( $version, '7.8.0', '<' ) ) {
120
+ $this->v780_upgrades();
121
+ }
122
+
123
+ if ( version_compare( $version, '7.9.0', '<' ) ) {
124
+ $this->v790_upgrades();
125
+ }
126
+
127
+ if ( version_compare( $version, '7.10.0', '<' ) ) {
128
+ $this->v7100_upgrades();
129
+ }
130
+
131
+ if ( version_compare( $version, '7.11.0', '<' ) ) {
132
+ $this->v7110_upgrades();
133
+ }
134
+
135
+ // Do not use. See monsterinsights_after_install_routine comment below.
136
+ do_action( 'monsterinsights_after_existing_upgrade_routine', $version );
137
+ $version = get_option( 'monsterinsights_current_version', $version );
138
+ update_option( 'monsterinsights_version_upgraded_from', $version );
139
+ }
140
+
141
+ // This hook is used primarily by the Pro version to run some Pro
142
+ // specific install stuff. Please do not use this hook. It is not
143
+ // considered a public hook by MI's dev team and can/will be removed,
144
+ // relocated, and/or altered without warning at any time. You've been warned.
145
+ // As this hook is not for public use, we've intentionally not docbloc'd this
146
+ // hook to avoid developers seeing it future public dev docs.
147
+ do_action( 'monsterinsights_after_install_routine', $version );
148
+
149
+ // This is the version of MI installed
150
+ update_option( 'monsterinsights_current_version', MONSTERINSIGHTS_VERSION );
151
+
152
+ // This is where we save MI settings
153
+ update_option( monsterinsights_get_option_name(), $this->new_settings );
154
+
155
+ // There's no code for this function below this. Just an explanation
156
+ // of the MI core options.
157
+
158
+ /**
159
+ * Explanation of MonsterInsights core options
160
+ *
161
+ * By now your head is probably spinning trying to figure
162
+ * out what all of these version options are for. Note, I've abbreviated
163
+ * "monsterinsights" to "mi" in the options names to make this table easier
164
+ * to read.
165
+ *
166
+ * Here's a basic rundown:
167
+ *
168
+ * mi_current_version: This starts with the actual version MI was
169
+ * installed on. We use this version to
170
+ * determine whether or not a site needs
171
+ * to run one of the behind the scenes
172
+ * MI upgrade routines. This version is updated
173
+ * every time a minor or major background upgrade
174
+ * routine is run. Generally lags behind the
175
+ * MONSTERINSIGHTS_VERSION constant by at most a couple minor
176
+ * versions. Never lags behind by 1 major version
177
+ * or more generally.
178
+ *
179
+ * mi_db_version: This is different from mi_current_version.
180
+ * Unlike the former, this is used to determine
181
+ * if a site needs to run a *user* initiated
182
+ * upgrade routine (incremented in MI_Upgrade class). This
183
+ * value is only update when a user initiated
184
+ * upgrade routine is done. Because we do very
185
+ * few user initiated upgrades compared to
186
+ * automatic ones, this version can lag behind by
187
+ * 2 or even 3 major versions. Generally contains
188
+ * the current major version.
189
+ *
190
+ * mi_settings: Returned by monsterinsights_get_option_name(), this
191
+ * is actually "monsterinsights_settings" for both pro
192
+ * and lite version. However we use a helper function to
193
+ * retrieve the option name in case we ever decide down the
194
+ * road to maintain seperate options for the Lite and Pro versions.
195
+ * If you need to access MI's settings directly, (as opposed to our
196
+ * monsterinsights_get_option helper which uses the option name helper
197
+ * automatically), you should use this function to get the
198
+ * name of the option to retrieve.
199
+ *
200
+ * Therefore you should never increment mi_db_version in this file and always increment mi_current_version.
201
+ */
202
+ }
203
+
204
+
205
+ /**
206
+ * New MonsterInsights Install routine.
207
+ *
208
+ * This function installs all of the default
209
+ * things on new MI installs. Flight 5476 with
210
+ * non-stop service to a whole world of
211
+ * possibilities is now boarding.
212
+ *
213
+ * @since 6.0.0
214
+ * @access public
215
+ *
216
+ * @return void
217
+ */
218
+ public function new_install() {
219
+ $this->new_settings = $this->get_monsterinsights_default_values();
220
+
221
+ $this->maybe_import_thirstyaffiliates_options();
222
+
223
+ $data = array(
224
+ 'installed_version' => MONSTERINSIGHTS_VERSION,
225
+ 'installed_date' => time(),
226
+ 'installed_pro' => monsterinsights_is_pro_version(),
227
+ );
228
+
229
+ update_option( 'monsterinsights_over_time', $data );
230
+
231
+ // Let addons + MI Pro/Lite hook in here. @todo: doc as nonpublic
232
+ do_action( 'monsterinsights_after_new_install_routine', MONSTERINSIGHTS_VERSION );
233
+ }
234
+
235
+ public function get_monsterinsights_default_values() {
236
+
237
+ $admin_email = get_option( 'admin_email' );
238
+ $admin_email_array = array(
239
+ array(
240
+ 'email' => $admin_email,
241
+ ),
242
+ );
243
+
244
+ return array(
245
+ 'enable_affiliate_links' => true,
246
+ 'affiliate_links' => array(
247
+ array(
248
+ 'path' => '/go/',
249
+ 'label' => 'affiliate',
250
+ ),
251
+ array(
252
+ 'path' => '/recommend/',
253
+ 'label' => 'affiliate',
254
+ )
255
+ ),
256
+ 'demographics' => 1,
257
+ 'ignore_users' => array( 'administrator', 'editor' ),
258
+ 'dashboards_disabled' => 0,
259
+ 'anonymize_ips' => 0,
260
+ 'extensions_of_files' => 'doc,pdf,ppt,zip,xls,docx,pptx,xlsx',
261
+ 'subdomain_tracking' => '',
262
+ 'link_attribution' => true,
263
+ 'tag_links_in_rss' => true,
264
+ 'allow_anchor' => 0,
265
+ 'add_allow_linker' => 0,
266
+ 'custom_code' => '',
267
+ 'save_settings' => array( 'administrator' ),
268
+ 'view_reports' => array( 'administrator', 'editor' ),
269
+ 'events_mode' => 'js',
270
+ 'tracking_mode' => 'analytics',
271
+ 'email_summaries' => 'on',
272
+ 'summaries_html_template' => 'yes',
273
+ 'summaries_email_addresses' => $admin_email_array,
274
+ );
275
+ }
276
+
277
+ /**
278
+ * Check if ThirstyAffiliates plugin is installed and use the link prefix value in the affiliate settings.
279
+ *
280
+ * @return void
281
+ */
282
+ public function maybe_import_thirstyaffiliates_options() {
283
+
284
+ // Check if ThirstyAffiliates is installed.
285
+ if ( ! function_exists( 'ThirstyAffiliates' ) ) {
286
+ return;
287
+ }
288
+
289
+ $link_prefix = get_option( 'ta_link_prefix', 'recommends' );
290
+
291
+ if ( $link_prefix === 'custom' ) {
292
+ $link_prefix = get_option( 'ta_link_prefix_custom', 'recommends' );
293
+ }
294
+
295
+ if ( ! empty( $link_prefix ) ) {
296
+
297
+ // Check if prefix exists.
298
+ $prefix_set = false;
299
+ foreach ( $this->new_settings['affiliate_links'] as $affiliate_link ) {
300
+ if ( $link_prefix === trim( $affiliate_link['path'], '/' ) ) {
301
+ $prefix_set = true;
302
+ break;
303
+ }
304
+ }
305
+
306
+ if ( ! $prefix_set ) {
307
+ $this->new_settings['affiliate_links'][] = array(
308
+ 'path' => '/' . $link_prefix . '/',
309
+ 'label' => 'affiliate',
310
+ );
311
+ }
312
+ }
313
+ }
314
+
315
+ /**
316
+ * MonsterInsights Version 7.0 upgrades.
317
+ *
318
+ * This function does the
319
+ * upgrade routine from MonsterInsights 6.2->7.0.
320
+ *
321
+ * @since 7.0.0
322
+ * @access public
323
+ *
324
+ * @return void
325
+ */
326
+ public function v700_upgrades() {
327
+ // 1. Default all event tracking and tracking to GA + JS respectively
328
+ // 3a Set tracking_mode to use analytics.js
329
+ $this->new_settings['tracking_mode' ] = 'analytics';
330
+
331
+
332
+ // 3b Set events mode to use JS if the events mode is not set explicitly to none
333
+ if ( empty( $this->new_settings['events_mode' ] ) || $this->new_settings['events_mode' ] !== 'none' ) {
334
+ $this->new_settings['events_mode' ] = 'js';
335
+ }
336
+
337
+ // 2. Migrate manual UA codes
338
+ // 2a Manual UA has the lowest priority
339
+ if ( ! empty( $this->new_settings['manual_ua_code' ] ) ) {
340
+ // Set as manual UA code
341
+ is_network_admin() ? update_site_option( 'monsterinsights_network_profile', array( 'manual' => $this->new_settings['manual_ua_code' ] ) ) : update_option( 'monsterinsights_site_profile', array( 'manual' => $this->new_settings['manual_ua_code' ] ) );
342
+ }
343
+
344
+ // 2b Then try the oAuth UA code
345
+ if ( ! empty( $this->new_settings['analytics_profile_code' ] ) ) {
346
+ // Set as manual UA code
347
+ is_network_admin() ? update_site_option( 'monsterinsights_network_profile', array( 'manual' => $this->new_settings['analytics_profile_code' ] ) ) : update_option( 'monsterinsights_site_profile', array( 'manual' => $this->new_settings['analytics_profile_code' ] ) );
348
+ }
349
+
350
+ // 3. Migrate License keys
351
+ if ( is_multisite() ) {
352
+ $ms_license = get_site_option( 'monsterinsights_license', '' );
353
+ if ( $ms_license ) {
354
+ update_site_option( 'monsterinsights_network_license_updates', get_site_option( 'monsterinsights_license_updates', '' ) );
355
+ update_site_option( 'monsterinsights_network_license', $ms_license );
356
+ }
357
+ }
358
+ }
359
+
360
+ /**
361
+ * Upgrade routine for the new settings panel, onboarding wizard, and the internal-as-outbound v2 settings system.
362
+ */
363
+ public function v740_upgrades() {
364
+
365
+ // 1. Settings Conversions:
366
+ // Convert affiliate field to repeater format
367
+ if ( ! empty( $this->new_settings['track_internal_as_outbound'] ) ) {
368
+ $affiliate_old_paths = $this->new_settings['track_internal_as_outbound'];
369
+ $affiliate_old_label = isset( $this->new_settings['track_internal_as_label'] ) ? $this->new_settings['track_internal_as_label'] : '';
370
+
371
+ $new_paths = explode( ',', $affiliate_old_paths );
372
+
373
+ $this->new_settings['affiliate_links'] = array();
374
+ if ( ! empty( $new_paths ) ) {
375
+ $this->new_settings['enable_affiliate_links'] = true;
376
+ foreach ( $new_paths as $new_path ) {
377
+ $this->new_settings['affiliate_links'][] = array(
378
+ 'path' => $new_path,
379
+ 'label' => $affiliate_old_label,
380
+ );
381
+ }
382
+ }
383
+
384
+ $settings = array(
385
+ 'track_internal_as_outbound',
386
+ 'track_internal_as_label',
387
+ );
388
+ foreach ( $settings as $setting ) {
389
+ if ( ! empty( $this->new_settings[ $setting ] ) ) {
390
+ unset( $this->new_settings[ $setting ] );
391
+ }
392
+ }
393
+ }
394
+
395
+ // Update option to disable just reports or also the dashboard widget.
396
+ if ( isset( $this->new_settings['dashboards_disabled'] ) && $this->new_settings['dashboards_disabled'] ) {
397
+ $this->new_settings['dashboards_disabled'] = 'disabled';
398
+ }
399
+
400
+ $this->new_settings['tracking_mode'] = 'analytics';
401
+ $this->new_settings['events_mode'] = 'js';
402
+
403
+ // If opted in during allow_tracking era, move that over
404
+ if ( ! empty( $this->new_settings['allow_tracking'] ) ) {
405
+ $this->new_settings['anonymous_data'] = 1;
406
+ }
407
+
408
+ // 2. Remove Yoast stuff
409
+ delete_option( 'yoast-ga-access_token' );
410
+ delete_option( 'yoast-ga-refresh_token' );
411
+ delete_option( 'yst_ga' );
412
+ delete_option( 'yst_ga_api' );
413
+
414
+
415
+ // 3. Remove fake settings from other plugins using our key for some reason and old settings of ours
416
+ $settings = array(
417
+ 'debug_mode',
418
+ 'track_download_as',
419
+ 'analytics_profile',
420
+ 'analytics_profile_code',
421
+ 'analytics_profile_name',
422
+ 'manual_ua_code',
423
+ 'track_outbound',
424
+ 'track_download_as',
425
+ 'enhanced_link_attribution',
426
+ 'oauth_version',
427
+ 'monsterinsights_oauth_status',
428
+ 'firebug_lite',
429
+ 'google_auth_code',
430
+ 'allow_tracking',
431
+ );
432
+
433
+ foreach ( $settings as $setting ) {
434
+ if ( ! empty( $this->new_settings[ $setting ] ) ) {
435
+ unset( $this->new_settings[ $setting ] );
436
+ }
437
+ }
438
+
439
+ $settings = array(
440
+ '_repeated',
441
+ 'ajax',
442
+ 'asmselect0',
443
+ 'bawac_force_nonce',
444
+ 'icl_post_language',
445
+ 'saved_values',
446
+ 'mlcf_email',
447
+ 'mlcf_name',
448
+ 'cron_failed',
449
+ 'undefined',
450
+ 'cf_email',
451
+ 'cf_message',
452
+ 'cf_name',
453
+ 'cf_number',
454
+ 'cf_phone',
455
+ 'cf_subject',
456
+ 'content',
457
+ 'credentials',
458
+ 'cron_failed',
459
+ 'cron_last_run',
460
+ 'global-css',
461
+ 'grids',
462
+ 'page',
463
+ 'punch-fonts',
464
+ 'return_tab',
465
+ 'skins',
466
+ 'navigation-skins',
467
+ 'title',
468
+ 'type',
469
+ 'wpcf_email',
470
+ 'wpcf_your_name',
471
+ );
472
+
473
+ foreach ( $settings as $setting ) {
474
+ if ( ! empty( $this->new_settings[ $setting ] ) ) {
475
+ unset( $this->new_settings[ $setting ] );
476
+ }
477
+ }
478
+
479
+ // 4. Remove old crons
480
+ if ( wp_next_scheduled( 'monsterinsights_daily_cron' ) ) {
481
+ wp_clear_scheduled_hook( 'monsterinsights_daily_cron' );
482
+ }
483
+ if ( wp_next_scheduled( 'monsterinsights_send_tracking_data' ) ) {
484
+ wp_clear_scheduled_hook( 'monsterinsights_send_tracking_data' );
485
+ }
486
+
487
+ if ( wp_next_scheduled( 'monsterinsights_send_tracking_checkin' ) ) {
488
+ wp_clear_scheduled_hook( 'monsterinsights_send_tracking_checkin' );
489
+ }
490
+
491
+ if ( wp_next_scheduled( 'monsterinsights_weekly_cron' ) ) {
492
+ wp_clear_scheduled_hook( 'monsterinsights_weekly_cron' );
493
+ }
494
+
495
+ if ( wp_next_scheduled( 'yst_ga_aggregate_data' ) ) {
496
+ wp_clear_scheduled_hook( 'yst_ga_aggregate_data' );
497
+ }
498
+
499
+ delete_option( 'monsterinsights_tracking_last_send' );
500
+ delete_option( 'mi_tracking_last_send' );
501
+
502
+ // 5. Remove old option
503
+ delete_option( 'monsterinsights_settings_version' );
504
+ }
505
+
506
+
507
+ /**
508
+ * Upgrade routine
509
+ */
510
+ public function v750_upgrades() {
511
+ // 1. One time re-prompt for anonymous data (due to migration bug now fixed)
512
+ // if ( ! monsterinsights_is_pro_version() ) {
513
+ // if ( empty( $this->new_settings[ 'anonymous_data' ] ) ) {
514
+ // update_option( 'monsterinsights_tracking_notice', 0 );
515
+ // }
516
+ // }
517
+ //
518
+ // 2. Clear old settings ( 'tracking_mode','events_mode',)
519
+
520
+
521
+ // 3. Attempt to extract the cross-domain settings from the Custom Code area and use in the new option.
522
+ $custom_code = isset( $this->new_settings['custom_code'] ) ? $this->new_settings['custom_code'] : '';
523
+ if ( ! empty( $custom_code ) ) {
524
+ $pattern = '/(?:\'linker:autoLink\', )(?:\[)(.*)(?:\])/m';
525
+ preg_match_all( $pattern, $custom_code, $matches, PREG_SET_ORDER, 0 );
526
+ if ( ! empty( $matches ) && isset( $matches[0] ) && isset( $matches[0][1] ) ) {
527
+ $cross_domains = array();
528
+ $domains = explode( ',', $matches[0][1] );
529
+ foreach ( $domains as $key => $domain ) {
530
+ $domain = trim( $domain );
531
+ $cross_domains[] = array(
532
+ 'domain' => trim( $domain, '\'\"' ),
533
+ );
534
+ }
535
+ $this->new_settings['add_allow_linker'] = true;
536
+ $this->new_settings['cross_domains'] = $cross_domains;
537
+
538
+ $notices = get_option( 'monsterinsights_notices' );
539
+ if ( ! is_array( $notices ) ) {
540
+ $notices = array();
541
+ }
542
+ $notices['monsterinsights_cross_domains_extracted'] = false;
543
+ update_option( 'monsterinsights_notices', $notices );
544
+ }
545
+ }
546
+ }
547
+
548
+ /**
549
+ * Upgrade routine for version 7.6.0
550
+ */
551
+ public function v760_upgrades() {
552
+
553
+ $cross_domains = isset( $this->new_settings['cross_domains'] ) ? $this->new_settings['cross_domains'] : array();
554
+
555
+ if ( ! empty( $cross_domains ) && is_array( $cross_domains ) ) {
556
+ $current_domain = wp_parse_url( home_url() );
557
+ $current_domain = isset( $current_domain['host'] ) ? $current_domain['host'] : '';
558
+ if ( ! empty( $current_domain ) ) {
559
+ $regex = '/^(?:' . $current_domain . '|(?:.+)\.' . $current_domain . ')$/m';
560
+ foreach ( $cross_domains as $key => $cross_domain ) {
561
+ if ( ! isset( $cross_domain['domain'] ) ) {
562
+ continue;
563
+ }
564
+ preg_match( $regex, $cross_domain['domain'], $matches );
565
+ if ( count( $matches ) > 0 ) {
566
+ unset( $this->new_settings['cross_domains'][ $key ] );
567
+ }
568
+ }
569
+ }
570
+ }
571
+
572
+ }
573
+
574
+ /**
575
+ * Upgrade routine for version 7.7.1
576
+ */
577
+ public function v771_upgrades() {
578
+
579
+ if ( ! monsterinsights_is_pro_version() ) {
580
+ // We only need to run this for the Pro version.
581
+ return;
582
+ }
583
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
584
+
585
+ $plugin = 'wp-scroll-depth/wp-scroll-depth.php';
586
+ // Check if wp-scroll-depth is active and deactivate to avoid conflicts with the pro scroll tracking feature.
587
+ if ( is_plugin_active( $plugin ) ) {
588
+ deactivate_plugins( $plugin );
589
+ }
590
+
591
+ }
592
+
593
+ /**
594
+ * Upgrade routine for version 7.8.0
595
+ */
596
+ public function v780_upgrades() {
597
+
598
+ if ( monsterinsights_get_ua() ) {
599
+ // If we have a UA, don't show the first run notice.
600
+ monsterinsights_update_option( 'monsterinsights_first_run_notice', true );
601
+
602
+ // If they are already tracking when they upgrade, mark connected time as now.
603
+ $over_time = get_option( 'monsterinsights_over_time', array() );
604
+ if ( empty( $over_time['connected_date'] ) ) {
605
+ $over_time['connected_date'] = time();
606
+ update_option( 'monsterinsights_over_time', $over_time );
607
+ }
608
+ }
609
+
610
+ }
611
+
612
+ /**
613
+ * Upgrade routine for version 7.9.0
614
+ */
615
+ public function v790_upgrades() {
616
+
617
+ // If they are already tracking, don't show the notice.
618
+ if ( monsterinsights_get_ua() ) {
619
+ update_option( 'monsterinsights_frontend_tracking_notice_viewed', true );
620
+
621
+ // If they are already tracking when they upgrade & not already marked mark connected time as now.
622
+ // Adding this here again as 7.8.0 upgrade didn't run for all users.
623
+ $over_time = get_option( 'monsterinsights_over_time', array() );
624
+ if ( empty( $over_time['connected_date'] ) ) {
625
+ $over_time['connected_date'] = time();
626
+ update_option( 'monsterinsights_over_time', $over_time );
627
+ }
628
+ }
629
+
630
+ }
631
+
632
+ /**
633
+ * Upgrade routine for version 8.0.0
634
+ */
635
+ public function v7100_upgrades() {
636
+
637
+ // Remove exe js and tgz from file downloads tracking.
638
+ $current_downloads = isset( $this->new_settings['extensions_of_files'] ) ? $this->new_settings['extensions_of_files'] : array();
639
+
640
+ if ( ! empty( $current_downloads ) ) {
641
+ $extensions_to_remove = array(
642
+ 'exe',
643
+ 'js',
644
+ 'tgz'
645
+ );
646
+ $extensions_to_add = array(
647
+ 'docx',
648
+ 'pptx',
649
+ 'xlsx',
650
+ );
651
+
652
+ $extensions = explode( ',', $current_downloads );
653
+ $updated_extensions = array();
654
+
655
+ if ( ! empty( $extensions ) && is_array( $extensions ) ) {
656
+ foreach ( $extensions as $extension ) {
657
+ if ( ! in_array( $extension, $extensions_to_remove ) ) {
658
+ $updated_extensions[] = $extension;
659
+ }
660
+ }
661
+ }
662
+
663
+ foreach ( $extensions_to_add as $extension_to_add ) {
664
+ if ( ! in_array( $extension_to_add, $updated_extensions ) ) {
665
+ $updated_extensions[] = $extension_to_add;
666
+ }
667
+ }
668
+ } else {
669
+ $updated_extensions = array(
670
+ 'pdf',
671
+ 'doc',
672
+ 'ppt',
673
+ 'xls',
674
+ 'zip',
675
+ 'docx',
676
+ 'pptx',
677
+ 'xlsx',
678
+ );
679
+ }
680
+
681
+ $updated_extensions = implode( ',', $updated_extensions );
682
+
683
+ $this->new_settings['extensions_of_files'] = $updated_extensions;
684
+
685
+ }
686
+
687
+ /**
688
+ * Upgrade routine for version 7.11.0
689
+ */
690
+ public function v7110_upgrades() {
691
+
692
+ if ( empty( $this->new_settings['email_summaries'] ) ) {
693
+ $admin_email = get_option( 'admin_email' );
694
+ $admin_email_array = array(
695
+ array(
696
+ 'email' => $admin_email,
697
+ ),
698
+ );
699
+ $this->new_settings['email_summaries'] = 'on';
700
+ $this->new_settings['summaries_html_template'] = 'yes';
701
+ $this->new_settings['summaries_email_addresses'] = $admin_email_array; // Not using wp_json_encode for backwards compatibility.
702
+ }
703
+
704
+ }
705
+ }
includes/measurement-protocol.php CHANGED
@@ -1,142 +1,142 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) {
3
- exit; // Exit if accessed directly
4
- }
5
-
6
- function monsterinsights_get_mp_api_url( ) {
7
- return 'https://www.google-analytics.com/collect';
8
- }
9
-
10
- function monsterinsights_mp_api_call( $args = array() ) {
11
- $user_agent = '';
12
- if ( ! empty( $args['user-agent'] ) ) {
13
- $user_agent = $args['user-agent'];
14
- unset( $args['user-agent'] );
15
- }
16
-
17
- $payment_id = 0;
18
- if ( ! empty( $args['payment_id'] ) ) {
19
- $payment_id = $args['payment_id'];
20
- unset( $args['payment_id'] );
21
- }
22
-
23
- $defaults = array(
24
- 't' => 'event', // Required: Hit type
25
- 'ec' => '', // Optional: Event category
26
- 'ea' => '', // Optional: Event Action
27
- 'el' => '', // Optional: Event Label
28
- 'ev' => null, // Optional: Event Value
29
- );
30
-
31
- $body = array_merge( $defaults , $args );
32
-
33
- // We want to get the user's IP address when possible
34
- $ip = '';
35
- if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) && ! filter_var( $_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP ) === false ) {
36
- $ip = $_SERVER['HTTP_CLIENT_IP'];
37
- } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) && ! filter_var( $_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP ) === false ) {
38
- $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
39
- } else {
40
- $ip = $_SERVER['REMOTE_ADDR'];
41
- }
42
-
43
- $ip = apply_filters( 'monsterinsights_mp_api_call_ip', $ip );
44
-
45
- // If possible, let's get the user's language
46
- $user_language = isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ? explode( ',', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) : array();
47
- $user_language = reset( $user_language );
48
- $user_language = sanitize_text_field( $user_language );
49
-
50
- $default_body = array(
51
- // Required: Version
52
- 'v' => '1',
53
-
54
- // Required: UA code
55
- 'tid' => monsterinsights_get_ua_to_output( array( 'ecommerce' => $args ) ),
56
-
57
- // Required: User visitor ID
58
- 'cid' => monsterinsights_get_client_id( $payment_id ),
59
-
60
- // Required: Type of hit (either pageview or event)
61
- 't' => 'pageview', // Required - Hit type
62
-
63
- // Optional: Was the event a non-interaction event (for bounce purposes)
64
- 'ni' => true,
65
-
66
- // Optional: Document Host Name
67
- 'dh' => str_replace( array( 'http://', 'https://' ), '', site_url() ),
68
-
69
- // Optional: Requested URI
70
- 'dp' => $_SERVER['REQUEST_URI'],
71
-
72
- // Optional: Page Title
73
- 'dt' => get_the_title(),
74
-
75
- // Optional: User language
76
- 'ul' => $user_language,
77
-
78
- // Optional: User IP address
79
- 'uip' => $ip,
80
-
81
- // Optional: User Agent
82
- 'ua' => ! empty( $user_agent ) ? $user_agent : $_SERVER['HTTP_USER_AGENT'],
83
-
84
- // Optional: Time of the event
85
- 'z' => time()
86
- );
87
-
88
- $body = wp_parse_args( $body, $default_body );
89
- $body = apply_filters( 'monsterinsights_mp_api_call', $body );
90
-
91
-
92
- // Ensure that the CID is not empty
93
- if ( empty( $body['cid'] ) ) {
94
- $body['cid'] = monsterinsights_generate_uuid();
95
- }
96
-
97
- // Unset empty values to reduce request size
98
- foreach ( $body as $key => $value ) {
99
- if ( empty( $value ) ) {
100
- unset( $body[ $key ] );
101
- }
102
- }
103
-
104
- $debug_mode = monsterinsights_is_debug_mode();
105
- $args = array(
106
- 'method' => 'POST',
107
- 'timeout' => '5',
108
- 'blocking' => ( $debug_mode ) ? true : false,
109
- 'body' => $body,
110
- );
111
-
112
- if ( ! empty( $user_agent ) ) {
113
- $args['user-agent'] = $user_agent;
114
- }
115
-
116
- $response = wp_remote_post( monsterinsights_get_mp_api_url(), $args );
117
-
118
- return $response;
119
- }
120
-
121
- function monsterinsights_mp_track_event_call( $args = array() ) {
122
- $default_args = array(
123
- // Change the default type to event
124
- 't' => 'event',
125
-
126
- // Required: Event Category
127
- 'ec' => '',
128
-
129
- // Required: Event Action
130
- 'ea' => '',
131
-
132
- // Required: Event Label
133
- 'el' => '',
134
-
135
- // Optional: Event Value
136
- 'ev' => null,
137
- );
138
- $args = wp_parse_args( $args, $default_args );
139
- //$args = apply_filters( 'monsterinsights_mp_track_event_call', $args );
140
-
141
- return monsterinsights_mp_api_call( $args );
142
  }
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit; // Exit if accessed directly
4
+ }
5
+
6
+ function monsterinsights_get_mp_api_url( ) {
7
+ return 'https://www.google-analytics.com/collect';
8
+ }
9
+
10
+ function monsterinsights_mp_api_call( $args = array() ) {
11
+ $user_agent = '';
12
+ if ( ! empty( $args['user-agent'] ) ) {
13
+ $user_agent = $args['user-agent'];
14
+ unset( $args['user-agent'] );
15
+ }
16
+
17
+ $payment_id = 0;
18
+ if ( ! empty( $args['payment_id'] ) ) {
19
+ $payment_id = $args['payment_id'];
20
+ unset( $args['payment_id'] );
21
+ }
22
+
23
+ $defaults = array(
24
+ 't' => 'event', // Required: Hit type
25
+ 'ec' => '', // Optional: Event category
26
+ 'ea' => '', // Optional: Event Action
27
+ 'el' => '', // Optional: Event Label
28
+ 'ev' => null, // Optional: Event Value
29
+ );
30
+
31
+ $body = array_merge( $defaults , $args );
32
+
33
+ // We want to get the user's IP address when possible
34
+ $ip = '';
35
+ if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) && ! filter_var( $_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP ) === false ) {
36
+ $ip = $_SERVER['HTTP_CLIENT_IP'];
37
+ } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) && ! filter_var( $_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP ) === false ) {
38
+ $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
39
+ } else {
40
+ $ip = $_SERVER['REMOTE_ADDR'];
41
+ }
42
+
43
+ $ip = apply_filters( 'monsterinsights_mp_api_call_ip', $ip );
44
+
45
+ // If possible, let's get the user's language
46
+ $user_language = isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ? explode( ',', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) : array();
47
+ $user_language = reset( $user_language );
48
+ $user_language = sanitize_text_field( $user_language );
49
+
50
+ $default_body = array(
51
+ // Required: Version
52
+ 'v' => '1',
53
+
54
+ // Required: UA code
55
+ 'tid' => monsterinsights_get_ua_to_output( array( 'ecommerce' => $args ) ),
56
+
57
+ // Required: User visitor ID
58
+ 'cid' => monsterinsights_get_client_id( $payment_id ),
59
+
60
+ // Required: Type of hit (either pageview or event)
61
+ 't' => 'pageview', // Required - Hit type
62
+
63
+ // Optional: Was the event a non-interaction event (for bounce purposes)
64
+ 'ni' => true,
65
+
66
+ // Optional: Document Host Name
67
+ 'dh' => str_replace( array( 'http://', 'https://' ), '', site_url() ),
68
+
69
+ // Optional: Requested URI
70
+ 'dp' => $_SERVER['REQUEST_URI'],
71
+
72
+ // Optional: Page Title
73
+ 'dt' => get_the_title(),
74
+
75
+ // Optional: User language
76
+ 'ul' => $user_language,
77
+
78
+ // Optional: User IP address
79
+ 'uip' => $ip,
80
+
81
+ // Optional: User Agent
82
+ 'ua' => ! empty( $user_agent ) ? $user_agent : $_SERVER['HTTP_USER_AGENT'],
83
+
84
+ // Optional: Time of the event
85
+ 'z' => time()
86
+ );
87
+
88
+ $body = wp_parse_args( $body, $default_body );
89
+ $body = apply_filters( 'monsterinsights_mp_api_call', $body );
90
+
91
+
92
+ // Ensure that the CID is not empty
93
+ if ( empty( $body['cid'] ) ) {
94
+ $body['cid'] = monsterinsights_generate_uuid();
95
+ }
96
+
97
+ // Unset empty values to reduce request size
98
+ foreach ( $body as $key => $value ) {
99
+ if ( empty( $value ) ) {
100
+ unset( $body[ $key ] );
101
+ }
102
+ }
103
+
104
+ $debug_mode = monsterinsights_is_debug_mode();
105
+ $args = array(
106
+ 'method' => 'POST',
107
+ 'timeout' => '5',
108
+ 'blocking' => ( $debug_mode ) ? true : false,
109
+ 'body' => $body,
110
+ );
111
+
112
+ if ( ! empty( $user_agent ) ) {
113
+ $args['user-agent'] = $user_agent;
114
+ }
115
+
116
+ $response = wp_remote_post( monsterinsights_get_mp_api_url(), $args );
117
+
118
+ return $response;
119
+ }
120
+
121
+ function monsterinsights_mp_track_event_call( $args = array() ) {
122
+ $default_args = array(
123
+ // Change the default type to event
124
+ 't' => 'event',
125
+
126
+ // Required: Event Category
127
+ 'ec' => '',
128
+
129
+ // Required: Event Action
130
+ 'ea' => '',
131
+
132
+ // Required: Event Label
133
+ 'el' => '',
134
+
135
+ // Optional: Event Value
136
+ 'ev' => null,
137
+ );
138
+ $args = wp_parse_args( $args, $default_args );
139
+ //$args = apply_filters( 'monsterinsights_mp_track_event_call', $args );
140
+
141
+ return monsterinsights_mp_api_call( $args );
142
  }
includes/options.php CHANGED
@@ -1,414 +1,419 @@
1
- <?php
2
- /**
3
- * Option functions.
4
- *
5
- * @since 6.0.0
6
- *
7
- * @package MonsterInsights
8
- * @subpackage Options
9
- * @author Chris Christoff
10
- */
11
-
12
- // Exit if accessed directly
13
- if ( ! defined( 'ABSPATH' ) ) {
14
- exit;
15
- }
16
-
17
- function monsterinsights_get_options() {
18
- $settings = array();
19
- $option_name = monsterinsights_get_option_name();
20
- //$settings = get_site_option( $option_name );
21
- //$use_network_settings = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
22
- //$is_network = is_multisite();
23
-
24
- //if ( $is_network && $use_network_settings ) {
25
- // return $settings;
26
- //} else if ( $is_network ) {
27
- $settings = get_option( $option_name );
28
- //} else {
29
- // return $settings;
30
- //}
31
- if ( empty( $settings ) || ! is_array( $settings ) ) {
32
- $settings = array();
33
- }
34
- return $settings;
35
- }
36
-
37
- /**
38
- * Helper method for getting a setting's value. Falls back to the default
39
- * setting value if none exists in the options table.
40
- *
41
- * @since 6.0.0
42
- * @access public
43
- *
44
- * @param string $key The setting key to retrieve.
45
- * @param mixed $default The default value of the setting key to retrieve.
46
- * @return string The value of the setting.
47
- */
48
- function monsterinsights_get_option( $key = '', $default = false ) {
49
- global $monsterinsights_settings;
50
- $value = ! empty( $monsterinsights_settings[ $key ] ) ? $monsterinsights_settings[ $key ] : $default;
51
- $value = apply_filters( 'monsterinsights_get_option', $value, $key, $default );
52
- return apply_filters( 'monsterinsights_get_option_' . $key, $value, $key, $default );
53
- }
54
-
55
- /**
56
- * Helper method for getting the UA string.
57
- *
58
- * @since 6.0.0
59
- * @access public
60
- *
61
- * @return string The UA to use.
62
- */
63
- function monsterinsights_get_ua() {
64
- // Try getting it from the auth UA
65
- $ua = MonsterInsights()->auth->get_ua();
66
-
67
- // If that didn't work, try the manual UA at the site level
68
- if ( empty( $ua ) ) {
69
- $ua = MonsterInsights()->auth->get_manual_ua();
70
- // If that didn't work try getting it from the network
71
- if ( empty( $ua ) ) {
72
- $ua = monsterinsights_get_network_ua();
73
- // If that didn't work, try getting it from the overall constant. If it's not there, leave it blank
74
- if ( empty( $ua ) ) {
75
- $ua = defined( 'MONSTERINSIGHTS_GA_UA' ) && MONSTERINSIGHTS_GA_UA ? monsterinsights_is_valid_ua( MONSTERINSIGHTS_GA_UA ) : '';
76
- }
77
- }
78
- }
79
-
80
- // Feed through the filter
81
- $pre_filter = $ua;
82
- $ua = apply_filters( 'monsterinsights_get_ua', $ua );
83
-
84
- // Only run through monsterinsights_is_valid_ua if it's different than pre-filter
85
- return $pre_filter === $ua ? $ua : monsterinsights_is_valid_ua( $ua );
86
- }
87
-
88
- /**
89
- * Helper method for getting the network UA string.
90
- *
91
- * @since 6.0.0
92
- * @access public
93
- *
94
- * @return string The UA to use.
95
- */
96
- function monsterinsights_get_network_ua() {
97
- if ( ! is_multisite() ) {
98
- return '';
99
- }
100
-
101
- // First try network auth UA
102
- $ua = MonsterInsights()->auth->get_network_ua();
103
- if ( ! empty( $ua ) ) {
104
- return $ua;
105
- }
106
-
107
- // Then try manual network UA
108
- $ua = MonsterInsights()->auth->get_network_manual_ua();
109
- if ( ! empty( $ua ) ) {
110
- return $ua;
111
- }
112
-
113
- // See if the constant is defined
114
- if ( defined( 'MONSTERINSIGHTS_MS_GA_UA' ) && monsterinsights_is_valid_ua( MONSTERINSIGHTS_MS_GA_UA ) ) {
115
- return MONSTERINSIGHTS_MS_GA_UA;
116
- }
117
-
118
- return '';
119
- }
120
-
121
- /**
122
- * Helper method for getting the UA string that's output on the frontend.
123
- *
124
- * @since 6.0.0
125
- * @access public
126
- *
127
- * @param array $args Allow calling functions to give args to use in future applications.
128
- * @return string The UA to use on frontend.
129
- */
130
- function monsterinsights_get_ua_to_output( $args = array() ) {
131
- $ua = monsterinsights_get_ua();
132
- $ua = apply_filters( 'monsterinsights_get_ua_to_output', $ua, $args );
133
- return monsterinsights_is_valid_ua( $ua );
134
- }
135
-
136
- /**
137
- * Helper method for updating a setting's value.
138
- *
139
- * @since 6.0.0
140
- * @access public
141
- *
142
- * @param string $key The setting key.
143
- * @param string $value The value to set for the key.
144
- * @return boolean True if updated, false if not.
145
- */
146
- function monsterinsights_update_option( $key = '', $value = false ) {
147
-
148
- // If no key, exit
149
- if ( empty( $key ) ){
150
- return false;
151
- }
152
-
153
- if ( empty( $value ) ) {
154
- $remove_option = monsterinsights_delete_option( $key );
155
- return $remove_option;
156
- }
157
-
158
- $option_name = monsterinsights_get_option_name();
159
-
160
- // First let's grab the current settings
161
-
162
- // if on network panel or if on single site using network settings
163
- //$settings = get_site_option( $option_name );
164
- //$use_network_settings = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
165
- //$is_network = is_multisite();
166
- //$update_network_option = true;
167
- //if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
168
- $settings = get_option( $option_name );
169
- // $update_network_option = false;
170
- //}
171
-
172
- if ( ! is_array( $settings ) ) {
173
- $settings = array();
174
- }
175
-
176
- // Let's let devs alter that value coming in
177
- $value = apply_filters( 'monsterinsights_update_option', $value, $key );
178
-
179
- // Next let's try to update the value
180
- $settings[ $key ] = $value;
181
- $did_update = false;
182
- //if ( $update_network_option ) {
183
- // $did_update = update_site_option( $option_name, $settings );
184
- //} else {
185
- $did_update = update_option( $option_name, $settings );
186
- //}
187
-
188
- // If it updated, let's update the global variable
189
- if ( $did_update ){
190
- global $monsterinsights_settings;
191
- $monsterinsights_settings[ $key ] = $value;
192
- }
193
-
194
- return $did_update;
195
- }
196
-
197
- /**
198
- * Helper method for deleting a setting's value.
199
- *
200
- * @since 6.0.0
201
- * @access public
202
- *
203
- * @param string $key The setting key.
204
- * @return boolean True if removed, false if not.
205
- */
206
- function monsterinsights_delete_option( $key = '' ) {
207
- // If no key, exit
208
- if ( empty( $key ) ){
209
- return false;
210
- }
211
-
212
- $option_name = monsterinsights_get_option_name();
213
-
214
- // First let's grab the current settings
215
-
216
- // if on network panel or if on single site using network settings
217
- //$settings = get_site_option( $option_name );
218
- //$use_network_settings = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
219
- //$is_network = is_multisite();
220
- //$update_network_option = true;
221
- //if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
222
- $settings = get_option( $option_name );
223
- // $update_network_option = false;
224
- //}
225
-
226
- // Next let's try to remove the key
227
- if( isset( $settings[ $key ] ) ) {
228
- unset( $settings[ $key ] );
229
- }
230
-
231
- $did_update = false;
232
- //if ( $update_network_option ) {
233
- // $did_update = update_site_option( 'monsterinsights_settings', $settings );
234
- //} else {
235
- $did_update = update_option( $option_name, $settings );
236
- //}
237
-
238
- // If it updated, let's update the global variable
239
- if ( $did_update ){
240
- global $monsterinsights_settings;
241
- $monsterinsights_settings = $settings;
242
- }
243
-
244
- return $did_update;
245
- }
246
-
247
- /**
248
- * Helper method for deleting multiple settings value.
249
- *
250
- * @since 6.0.0
251
- * @access public
252
- *
253
- * @param string $key The setting key.
254
- * @return boolean True if removed, false if not.
255
- */
256
- function monsterinsights_delete_options( $keys = array() ) {
257
- // If no keys, exit
258
- if ( empty( $keys ) || ! is_array( $keys ) ){
259
- return false;
260
- }
261
-
262
- $option_name = monsterinsights_get_option_name();
263
-
264
- // First let's grab the current settings
265
-
266
- // if on network panel or if on single site using network settings
267
- //$settings = get_site_option( $option_name );
268
- //$use_network_settings = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
269
- //$is_network = is_multisite();
270
- //$update_network_option = true;
271
- //if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
272
- $settings = get_option( $option_name );
273
- // $update_network_option = false;
274
- //}
275
-
276
- // Next let's try to remove the keys
277
- foreach ( $keys as $key ) {
278
- if( isset( $settings[ $key ] ) ) {
279
- unset( $settings[ $key ] );
280
- }
281
- }
282
-
283
- $did_update = false;
284
- //if ( $update_network_option ) {
285
- // $did_update = update_site_option( 'monsterinsights_settings', $settings );
286
- //} else {
287
- $did_update = update_option( $option_name, $settings );
288
- //}
289
-
290
- // If it updated, let's update the global variable
291
- if ( $did_update ){
292
- global $monsterinsights_settings;
293
- $monsterinsights_settings = $settings;
294
- }
295
-
296
- return $did_update;
297
- }
298
-
299
- /**
300
- * Is valid ua code.
301
- *
302
- * @access public
303
- * @since 6.0.0
304
- *
305
- * @param string $ua_code UA code to check validity for.
306
- *
307
- * @return string|false Return cleaned ua string if valid, else returns false.
308
- */
309
- function monsterinsights_is_valid_ua( $ua_code = '' ) {
310
- $ua_code = (string) $ua_code; // Rare case, but let's make sure it never happens.
311
- $ua_code = trim( $ua_code );
312
-
313
- if ( empty( $ua_code ) ) {
314
- return '';
315
- }
316
-
317
- // Replace all type of dashes (n-dash, m-dash, minus) with normal dashes.
318
- $ua_code = str_replace( array( '–', '—', '−' ), '-', $ua_code );
319
-
320
- if ( preg_match( "/^(UA|YT|MO)-\d{4,}-\d+$/", strval( $ua_code ) ) ) {
321
- return $ua_code;
322
- } else {
323
- return '';
324
- }
325
- }
326
-
327
- /**
328
- * Helper method for getting the license information.
329
- *
330
- * @since 6.0.0
331
- * @access public
332
- *
333
- * @param string $key The setting key to retrieve.
334
- * @param mixed $default_value The default value of the setting key to retrieve.
335
- * @return string The value of the setting.
336
- */
337
- function monsterinsights_get_license() {
338
- $license = MonsterInsights()->license->get_site_license();
339
- $license = $license ? $license : MonsterInsights()->license->get_network_license();
340
- $default = MonsterInsights()->license->get_default_license_key();
341
- if ( empty( $license ) && ! empty( $default ) ) {
342
- $license = array();
343
- $license['key'] = MonsterInsights()->license->get_default_license_key();
344
- }
345
- return $license;
346
- }
347
-
348
- /**
349
- * Helper method for getting the license key.
350
- *
351
- * @since 6.0.0
352
- * @access public
353
- *
354
- * @param string $key The setting key to retrieve.
355
- * @param mixed $default_value The default value of the setting key to retrieve.
356
- * @return string The value of the setting.
357
- */
358
- function monsterinsights_get_license_key() {
359
- if ( monsterinsights_is_pro_version() ) {
360
- return MonsterInsights()->license->get_license_key();
361
- }
362
- return '';
363
- }
364
-
365
- function monsterinsights_get_option_name() {
366
- //if ( monsterinsights_is_pro_version() ) {
367
- return 'monsterinsights_settings';
368
- //} else {
369
- // return 'monsterinsights_settings';
370
- //}
371
- }
372
-
373
- function monsterinsights_export_settings() {
374
- $settings = monsterinsights_get_options();
375
- $exclude = array(
376
- 'analytics_profile',
377
- 'analytics_profile_code',
378
- 'analytics_profile_name',
379
- 'oauth_version',
380
- 'cron_last_run',
381
- 'monsterinsights_oauth_status',
382
- );
383
-
384
- foreach ( $exclude as $e ) {
385
- if ( ! empty( $settings[ $e ] ) ) {
386
- unset( $settings[ $e ] );
387
- }
388
- }
389
- return wp_json_encode( $settings );
390
- }
391
-
392
- /**
393
- * Always return 'analytics' when grabbing the tracking mode.
394
- *
395
- * @param string $value The value to override.
396
- *
397
- * @return string
398
- */
399
- function monsterinsights_force_tracking_mode( $value ) {
400
- return 'analytics';
401
- }
402
- add_filter( 'monsterinsights_get_option_tracking_mode', 'monsterinsights_force_tracking_mode' );
403
-
404
- /**
405
- * Always return 'js' when grabbing the events mode.
406
- *
407
- * @param string $value The value to override.
408
- *
409
- * @return string
410
- */
411
- function monsterinsights_force_events_mode( $value ) {
412
- return 'js';
413
- }
414
- add_filter( 'monsterinsights_get_option_events_mode', 'monsterinsights_force_events_mode' );
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Option functions.
4
+ *
5
+ * @since 6.0.0
6
+ *
7
+ * @package MonsterInsights
8
+ * @subpackage Options
9
+ * @author Chris Christoff
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+
17
+ function monsterinsights_get_options() {
18
+ $settings = array();
19
+ $option_name = monsterinsights_get_option_name();
20
+ //$settings = get_site_option( $option_name );
21
+ //$use_network_settings = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
22
+ //$is_network = is_multisite();
23
+
24
+ //if ( $is_network && $use_network_settings ) {
25
+ // return $settings;
26
+ //} else if ( $is_network ) {
27
+ $settings = get_option( $option_name );
28
+ //} else {
29
+ // return $settings;
30
+ //}
31
+ if ( empty( $settings ) || ! is_array( $settings ) ) {
32
+ $settings = array();
33
+ }
34
+ return $settings;
35
+ }
36
+
37
+ /**
38
+ * Helper method for getting a setting's value. Falls back to the default
39
+ * setting value if none exists in the options table.
40
+ *
41
+ * @since 6.0.0
42
+ * @access public
43
+ *
44
+ * @param string $key The setting key to retrieve.
45
+ * @param mixed $default The default value of the setting key to retrieve.
46
+ * @return string The value of the setting.
47
+ */
48
+ function monsterinsights_get_option( $key = '', $default = false ) {
49
+ global $monsterinsights_settings;
50
+ $value = ! empty( $monsterinsights_settings[ $key ] ) ? $monsterinsights_settings[ $key ] : $default;
51
+ $value = apply_filters( 'monsterinsights_get_option', $value, $key, $default );
52
+ return apply_filters( 'monsterinsights_get_option_' . $key, $value, $key, $default );
53
+ }
54
+
55
+ /**
56
+ * Helper method for getting the UA string.
57
+ *
58
+ * @since 6.0.0
59
+ * @access public
60
+ *
61
+ * @return string The UA to use.
62
+ */
63
+ function monsterinsights_get_ua() {
64
+ // Allow short circuiting (for staging sites)
65
+ if ( defined( 'MONSTERINSIGHTS_DISABLE_TRACKING' ) && MONSTERINSIGHTS_DISABLE_TRACKING ) {
66
+ return '';
67
+ }
68
+
69
+ // Try getting it from the auth UA
70
+ $ua = MonsterInsights()->auth->get_ua();
71
+
72
+ // If that didn't work, try the manual UA at the site level
73
+ if ( empty( $ua ) ) {
74
+ $ua = MonsterInsights()->auth->get_manual_ua();
75
+ // If that didn't work try getting it from the network
76
+ if ( empty( $ua ) ) {
77
+ $ua = monsterinsights_get_network_ua();
78
+ // If that didn't work, try getting it from the overall constant. If it's not there, leave it blank
79
+ if ( empty( $ua ) ) {
80
+ $ua = defined( 'MONSTERINSIGHTS_GA_UA' ) && MONSTERINSIGHTS_GA_UA ? monsterinsights_is_valid_ua( MONSTERINSIGHTS_GA_UA ) : '';
81
+ }
82
+ }
83
+ }
84
+
85
+ // Feed through the filter
86
+ $pre_filter = $ua;
87
+ $ua = apply_filters( 'monsterinsights_get_ua', $ua );
88
+
89
+ // Only run through monsterinsights_is_valid_ua if it's different than pre-filter
90
+ return $pre_filter === $ua ? $ua : monsterinsights_is_valid_ua( $ua );
91
+ }
92
+
93
+ /**
94
+ * Helper method for getting the network UA string.
95
+ *
96
+ * @since 6.0.0
97
+ * @access public
98
+ *
99
+ * @return string The UA to use.
100
+ */
101
+ function monsterinsights_get_network_ua() {
102
+ if ( ! is_multisite() ) {
103
+ return '';
104
+ }
105
+
106
+ // First try network auth UA
107
+ $ua = MonsterInsights()->auth->get_network_ua();
108
+ if ( ! empty( $ua ) ) {
109
+ return $ua;
110
+ }
111
+
112
+ // Then try manual network UA
113
+ $ua = MonsterInsights()->auth->get_network_manual_ua();
114
+ if ( ! empty( $ua ) ) {
115
+ return $ua;
116
+ }
117
+
118
+ // See if the constant is defined
119
+ if ( defined( 'MONSTERINSIGHTS_MS_GA_UA' ) && monsterinsights_is_valid_ua( MONSTERINSIGHTS_MS_GA_UA ) ) {
120
+ return MONSTERINSIGHTS_MS_GA_UA;
121
+ }
122
+
123
+ return '';
124
+ }
125
+
126
+ /**
127
+ * Helper method for getting the UA string that's output on the frontend.
128
+ *
129
+ * @since 6.0.0
130
+ * @access public
131
+ *
132
+ * @param array $args Allow calling functions to give args to use in future applications.
133
+ * @return string The UA to use on frontend.
134
+ */
135
+ function monsterinsights_get_ua_to_output( $args = array() ) {
136
+ $ua = monsterinsights_get_ua();
137
+ $ua = apply_filters( 'monsterinsights_get_ua_to_output', $ua, $args );
138
+ return monsterinsights_is_valid_ua( $ua );
139
+ }
140
+
141
+ /**
142
+ * Helper method for updating a setting's value.
143
+ *
144
+ * @since 6.0.0
145
+ * @access public
146
+ *
147
+ * @param string $key The setting key.
148
+ * @param string $value The value to set for the key.
149
+ * @return boolean True if updated, false if not.
150
+ */
151
+ function monsterinsights_update_option( $key = '', $value = false ) {
152
+
153
+ // If no key, exit
154
+ if ( empty( $key ) ){
155
+ return false;
156
+ }
157
+
158
+ if ( empty( $value ) ) {
159
+ $remove_option = monsterinsights_delete_option( $key );
160
+ return $remove_option;
161
+ }
162
+
163
+ $option_name = monsterinsights_get_option_name();
164
+
165
+ // First let's grab the current settings
166
+
167
+ // if on network panel or if on single site using network settings
168
+ //$settings = get_site_option( $option_name );
169
+ //$use_network_settings = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
170
+ //$is_network = is_multisite();
171
+ //$update_network_option = true;
172
+ //if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
173
+ $settings = get_option( $option_name );
174
+ // $update_network_option = false;
175
+ //}
176
+
177
+ if ( ! is_array( $settings ) ) {
178
+ $settings = array();
179
+ }
180
+
181
+ // Let's let devs alter that value coming in
182
+ $value = apply_filters( 'monsterinsights_update_option', $value, $key );
183
+
184
+ // Next let's try to update the value
185
+ $settings[ $key ] = $value;
186
+ $did_update = false;
187
+ //if ( $update_network_option ) {
188
+ // $did_update = update_site_option( $option_name, $settings );
189
+ //} else {
190
+ $did_update = update_option( $option_name, $settings );
191
+ //}
192
+
193
+ // If it updated, let's update the global variable
194
+ if ( $did_update ){
195
+ global $monsterinsights_settings;
196
+ $monsterinsights_settings[ $key ] = $value;
197
+ }
198
+
199
+ return $did_update;
200
+ }
201
+
202
+ /**
203
+ * Helper method for deleting a setting's value.
204
+ *
205
+ * @since 6.0.0
206
+ * @access public
207
+ *
208
+ * @param string $key The setting key.
209
+ * @return boolean True if removed, false if not.
210
+ */
211
+ function monsterinsights_delete_option( $key = '' ) {
212
+ // If no key, exit
213
+ if ( empty( $key ) ){
214
+ return false;
215
+ }
216
+
217
+ $option_name = monsterinsights_get_option_name();
218
+
219
+ // First let's grab the current settings
220
+
221
+ // if on network panel or if on single site using network settings
222
+ //$settings = get_site_option( $option_name );
223
+ //$use_network_settings = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
224
+ //$is_network = is_multisite();
225
+ //$update_network_option = true;
226
+ //if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
227
+ $settings = get_option( $option_name );
228
+ // $update_network_option = false;
229
+ //}
230
+
231
+ // Next let's try to remove the key
232
+ if( isset( $settings[ $key ] ) ) {
233
+ unset( $settings[ $key ] );
234
+ }
235
+
236
+ $did_update = false;
237
+ //if ( $update_network_option ) {
238
+ // $did_update = update_site_option( 'monsterinsights_settings', $settings );
239
+ //} else {
240
+ $did_update = update_option( $option_name, $settings );
241
+ //}
242
+
243
+ // If it updated, let's update the global variable
244
+ if ( $did_update ){
245
+ global $monsterinsights_settings;
246
+ $monsterinsights_settings = $settings;
247
+ }
248
+
249
+ return $did_update;
250
+ }
251
+
252
+ /**
253
+ * Helper method for deleting multiple settings value.
254
+ *
255
+ * @since 6.0.0
256
+ * @access public
257
+ *
258
+ * @param string $key The setting key.
259
+ * @return boolean True if removed, false if not.
260
+ */
261
+ function monsterinsights_delete_options( $keys = array() ) {
262
+ // If no keys, exit
263
+ if ( empty( $keys ) || ! is_array( $keys ) ){
264
+ return false;
265
+ }
266
+
267
+ $option_name = monsterinsights_get_option_name();
268
+
269
+ // First let's grab the current settings
270
+
271
+ // if on network panel or if on single site using network settings
272
+ //$settings = get_site_option( $option_name );
273
+ //$use_network_settings = ! empty( $use_network_settings['use_network_settings'] ) ? true : false;
274
+ //$is_network = is_multisite();
275
+ //$update_network_option = true;
276
+ //if ( ! is_network_admin() && ! ( $is_network && $use_network_settings ) ) {
277
+ $settings = get_option( $option_name );
278
+ // $update_network_option = false;
279
+ //}
280
+
281
+ // Next let's try to remove the keys
282
+ foreach ( $keys as $key ) {
283
+ if( isset( $settings[ $key ] ) ) {
284
+ unset( $settings[ $key ] );
285
+ }
286
+ }
287
+
288
+ $did_update = false;
289
+ //if ( $update_network_option ) {
290
+ // $did_update = update_site_option( 'monsterinsights_settings', $settings );
291
+ //} else {
292
+ $did_update = update_option( $option_name, $settings );
293
+ //}
294
+
295
+ // If it updated, let's update the global variable
296
+ if ( $did_update ){
297
+ global $monsterinsights_settings;
298
+ $monsterinsights_settings = $settings;
299
+ }
300
+
301
+ return $did_update;
302
+ }
303
+
304
+ /**
305
+ * Is valid ua code.
306
+ *
307
+ * @access public
308
+ * @since 6.0.0
309
+ *
310
+ * @param string $ua_code UA code to check validity for.
311
+ *
312
+ * @return string|false Return cleaned ua string if valid, else returns false.
313
+ */
314
+ function monsterinsights_is_valid_ua( $ua_code = '' ) {
315
+ $ua_code = (string) $ua_code; // Rare case, but let's make sure it never happens.
316
+ $ua_code = trim( $ua_code );
317
+
318
+ if ( empty( $ua_code ) ) {
319
+ return '';
320
+ }
321
+
322
+ // Replace all type of dashes (n-dash, m-dash, minus) with normal dashes.
323
+ $ua_code = str_replace( array( '', '—', '−' ), '-', $ua_code );
324
+
325
+ if ( preg_match( "/^(UA|YT|MO)-\d{4,}-\d+$/", strval( $ua_code ) ) ) {
326
+ return $ua_code;
327
+ } else {
328
+ return '';
329
+ }
330
+ }
331
+
332
+ /**
333
+ * Helper method for getting the license information.
334
+ *
335
+ * @since 6.0.0
336
+ * @access public
337
+ *
338
+ * @param string $key The setting key to retrieve.
339
+ * @param mixed $default_value The default value of the setting key to retrieve.
340
+ * @return string The value of the setting.
341
+ */
342
+ function monsterinsights_get_license() {
343
+ $license = MonsterInsights()->license->get_site_license();
344
+ $license = $license ? $license : MonsterInsights()->license->get_network_license();
345
+ $default = MonsterInsights()->license->get_default_license_key();
346
+ if ( empty( $license ) && ! empty( $default ) ) {
347
+ $license = array();
348
+ $license['key'] = MonsterInsights()->license->get_default_license_key();
349
+ }
350
+ return $license;
351
+ }
352
+
353
+ /**
354
+ * Helper method for getting the license key.
355
+ *
356
+ * @since 6.0.0
357
+ * @access public
358
+ *
359
+ * @param string $key The setting key to retrieve.
360
+ * @param mixed $default_value The default value of the setting key to retrieve.
361
+ * @return string The value of the setting.
362
+ */
363
+ function monsterinsights_get_license_key() {
364
+ if ( monsterinsights_is_pro_version() ) {
365
+ return MonsterInsights()->license->get_license_key();
366
+ }
367
+ return '';
368
+ }
369
+
370
+ function monsterinsights_get_option_name() {
371
+ //if ( monsterinsights_is_pro_version() ) {
372
+ return 'monsterinsights_settings';
373
+ //} else {
374
+ // return 'monsterinsights_settings';
375
+ //}
376
+ }
377
+
378
+ function monsterinsights_export_settings() {
379
+ $settings = monsterinsights_get_options();
380
+ $exclude = array(
381
+ 'analytics_profile',
382
+ 'analytics_profile_code',
383
+ 'analytics_profile_name',
384
+ 'oauth_version',
385
+ 'cron_last_run',
386
+ 'monsterinsights_oauth_status',
387
+ );
388
+
389
+ foreach ( $exclude as $e ) {
390
+ if ( ! empty( $settings[ $e ] ) ) {
391
+ unset( $settings[ $e ] );
392
+ }
393
+ }
394
+ return wp_json_encode( $settings );
395
+ }
396
+
397
+ /**
398
+ * Always return 'analytics' when grabbing the tracking mode.
399
+ *
400
+ * @param string $value The value to override.
401
+ *
402
+ * @return string
403
+ */
404
+ function monsterinsights_force_tracking_mode( $value ) {
405
+ return 'analytics';
406
+ }
407
+ add_filter( 'monsterinsights_get_option_tracking_mode', 'monsterinsights_force_tracking_mode' );
408
+
409
+ /**
410
+ * Always return 'js' when grabbing the events mode.
411
+ *
412
+ * @param string $value The value to override.
413
+ *
414
+ * @return string
415
+ */
416
+ function monsterinsights_force_events_mode( $value ) {
417
+ return 'js';
418
+ }
419
+ add_filter( 'monsterinsights_get_option_events_mode', 'monsterinsights_force_events_mode' );
index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- //Nothing to see here
3
-
4
  header( 'HTTP/1.0 403 Forbidden' );
1
+ <?php
2
+ //Nothing to see here
3
+
4
  header( 'HTTP/1.0 403 Forbidden' );
languages/index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- //Nothing to see here
3
-
4
  header( 'HTTP/1.0 403 Forbidden' );
1
+ <?php
2
+ //Nothing to see here
3
+
4
  header( 'HTTP/1.0 403 Forbidden' );
languages/vue.php CHANGED
@@ -1,1965 +1,1949 @@
1
  <?php
2
  /* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */
3
  $generated_i18n_strings = array(
4
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:187
5
- __( 'Refreshing Report', 'google-analytics-for-wordpress' ),
6
 
7
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:188
8
- __( 'Loading new report data...', 'google-analytics-for-wordpress' ),
 
 
 
9
 
10
- // Reference: src/modules/settings/components/input/tab-general/SettingsInputLicense-Lite.vue:67
11
- // Reference: src/modules/wizard-onboarding/components/inputs/OnboardingAuthenticate-Lite.vue:120
12
- // Reference: src/plugins/monsterinsights-widget-helper-plugin.js:14
13
  __( 'Error', 'google-analytics-for-wordpress' ),
14
 
15
- // Reference: src/plugins/monsterinsights-widget-helper-plugin.js:15
16
  __( 'Please try again.', 'google-analytics-for-wordpress' ),
17
 
18
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:229
 
 
 
 
 
 
 
 
 
 
19
  __( 'Unlock the Publishers Report and Focus on the Content that Matters', 'google-analytics-for-wordpress' ),
20
 
21
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:230
22
  __( 'Stop guessing about what content your visitors are interested in. MonsterInsights Publisher Report shows you exactly which content gets the most visits, so you can analyze and optimize it for higher conversions.', 'google-analytics-for-wordpress' ),
23
 
24
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:241
25
  __( 'Unlock the Publishers Report and Focus on the Content That Matters', 'google-analytics-for-wordpress' ),
26
 
27
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:242
28
  __( 'Stop guessing about what content your visitors are interested in. The Publisher Report shows you exactly which content gets the most traffic, so you can analyze and optimize it for higher conversions.', 'google-analytics-for-wordpress' ),
29
 
30
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:244
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  __( 'See Your Top Landing Pages to Improve Enagement', 'google-analytics-for-wordpress' ),
32
 
33
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:245
34
  __( 'See Your Top Exit Pages to Reduce Abandonment', 'google-analytics-for-wordpress' ),
35
 
36
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:246
37
  __( 'See Your Top Outbound Links to Find New Revenue Opportunities', 'google-analytics-for-wordpress' ),
38
 
39
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:247
40
  __( 'See Your Top Affiliate Links and Focus on what\'s working', 'google-analytics-for-wordpress' ),
41
 
42
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:248
43
  __( 'See Your Top Downloads and Improve Conversions', 'google-analytics-for-wordpress' ),
44
 
45
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:249
46
  __( 'See Audience Demographic Report ( Age / Gender / Interests )', 'google-analytics-for-wordpress' ),
47
 
48
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:253
49
- __( 'Unlock the eCommerce Report and See Your Important Store Metrics', 'google-analytics-for-wordpress' ),
50
-
51
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:254
52
- __( 'Increase your sales & revenue with insights. MonsterInsights answers all your top eCommerce questions using metrics like total revenue, conversion rate, average order value, top products, top referral sources and more.', 'google-analytics-for-wordpress' ),
53
-
54
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:256
55
  __( 'See Your Conversion Rate to Improve Funnel', 'google-analytics-for-wordpress' ),
56
 
57
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:257
58
- __( 'See The Number of Transactions and make data-driven decisions', 'google-analytics-for-wordpress' ),
59
 
60
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:258
61
  __( 'See The Total Revenue to Track Growth', 'google-analytics-for-wordpress' ),
62
 
63
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:259
64
  __( 'See Average Order Value to Find Offer Opportunities', 'google-analytics-for-wordpress' ),
65
 
66
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:260
67
  __( 'See Your Top Products to See Individual Performance', 'google-analytics-for-wordpress' ),
68
 
69
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:261
70
  __( 'See Your Top Conversion Sources and Focus on what\'s working', 'google-analytics-for-wordpress' ),
71
 
72
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:262
73
  __( 'See The Time it takes for Customers to Purchase', 'google-analytics-for-wordpress' ),
74
 
75
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:263
76
  __( 'See How Many Sessions are needed for a Purchase', 'google-analytics-for-wordpress' ),
77
 
78
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:267
79
- __( 'Unlock the Dimensions Report and Track Your Own Custom Data', 'google-analytics-for-wordpress' ),
80
-
81
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:268
82
- __( 'Decide what data is important using your own custom tracking parameters. The Dimensions report allows you to easily see what\'s working right inside your WordPress dashboard.', 'google-analytics-for-wordpress' ),
83
-
84
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:270
85
  __( 'See Which Authors Generate the Most Traffic', 'google-analytics-for-wordpress' ),
86
 
87
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:271
88
  __( 'See Which Post Types Perform Better', 'google-analytics-for-wordpress' ),
89
 
90
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:272
91
  __( 'See Which Categories are the Most Popular', 'google-analytics-for-wordpress' ),
92
 
93
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:273
94
- __( 'See Your Blog\'s most populare SEO Scores', 'google-analytics-for-wordpress' ),
95
 
96
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:274
97
  __( 'See Which Focus Keyword is Performing Better in Search Engines', 'google-analytics-for-wordpress' ),
98
 
99
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:278
100
- __( 'Unlock the Forms Report and Improve Conversions', 'google-analytics-for-wordpress' ),
101
-
102
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:279
103
- __( 'Easily track your form views and conversions. The Forms Report allows you to see which forms are performing better and which forms have lower conversion rates so you can optimize using real data.', 'google-analytics-for-wordpress' ),
104
-
105
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:281
106
  __( 'See Reports for Any Contact Form Plugin or Sign-up Form', 'google-analytics-for-wordpress' ),
107
 
108
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:282
109
  __( 'See Your Top Converting Forms and Optimize', 'google-analytics-for-wordpress' ),
110
 
111
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:283
112
  __( 'See Your Forms Impressions Count to Find the Best Placement', 'google-analytics-for-wordpress' ),
113
 
114
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:287
115
- __( 'Unlock the Search Console Report and See How People Find Your Website', 'google-analytics-for-wordpress' ),
116
-
117
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:288
118
- __( 'See exactly how people find your website, which keywords they searched for, how many times the results were viewed, and more.', 'google-analytics-for-wordpress' ),
119
-
120
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:290
121
  __( 'See Your Top Google Search Terms and Optimize Content', 'google-analytics-for-wordpress' ),
122
 
123
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:291
124
  __( 'See The Number of Clicks and Track Interests', 'google-analytics-for-wordpress' ),
125
 
126
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:292
127
  __( 'See The Click-Through-Ratio and Improve SEO', 'google-analytics-for-wordpress' ),
128
 
129
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:293
130
  __( 'See The Average Results Position and Focus on what works', 'google-analytics-for-wordpress' ),
131
 
132
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:297
133
- __( 'Unlock the Real-Time Report and Track the Visitors on Your Site in Real-Time', 'google-analytics-for-wordpress' ),
134
-
135
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:298
136
- __( 'Track the results of your marketing efforts and product launches as-it-happens right from your WordPress site. The Real-Time report allows you to view your traffic sources and visitors activity when you need it.', 'google-analytics-for-wordpress' ),
137
-
138
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:300
139
  __( 'See Your Active Visitors and Track Their Behaviour to Optimize', 'google-analytics-for-wordpress' ),
140
 
141
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:301
142
  __( 'See Your Top Pages Immediately After Making Changes', 'google-analytics-for-wordpress' ),
143
 
144
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:302
145
  __( 'See Your Top Referral Sources and Adapt Faster', 'google-analytics-for-wordpress' ),
146
 
147
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:303
148
  __( 'See Your Traffic Demographics and ', 'google-analytics-for-wordpress' ),
149
 
150
- // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:304
151
  __( 'Get Fresh Reports Data Every 60 Seconds', 'google-analytics-for-wordpress' ),
152
 
153
- // Reference: src/modules/reports/routes/index.js:24
 
 
 
 
154
  __( 'Overview Report', 'google-analytics-for-wordpress' ),
155
 
156
- // Reference: src/plugins/monsterinsights-settings-helper-plugin.js:106
157
- __( 'Loading Settings', 'google-analytics-for-wordpress' ),
158
 
159
- // Reference: src/plugins/monsterinsights-settings-helper-plugin.js:18
160
- __( 'Saving Changes...', 'google-analytics-for-wordpress' ),
161
 
162
- // Reference: src/plugins/monsterinsights-settings-helper-plugin.js:47
163
- __( 'Settings Updated', 'google-analytics-for-wordpress' ),
164
 
165
- // Reference: src/plugins/monsterinsights-settings-helper-plugin.js:81
166
- __( 'Could Not Save Changes', 'google-analytics-for-wordpress' ),
167
 
168
- // Reference: src/modules/frontend/frontend.vue:30
169
- __( 'Insights', 'google-analytics-for-wordpress' ),
170
 
171
- // Reference: src/modules/settings/site.vue:78
172
- __( 'Congratulations! ', 'google-analytics-for-wordpress' ),
173
 
174
- // Reference: src/modules/settings/site.vue:79
175
- __( 'You Successfully Unlocked the most powerful Analytics plugin', 'google-analytics-for-wordpress' ),
176
 
177
- // Reference: src/modules/reports/routes/index.js:32
178
- __( 'Publishers Report', 'google-analytics-for-wordpress' ),
179
 
180
- // Reference: src/modules/reports/routes/index.js:40
181
- __( 'eCommerce Report', 'google-analytics-for-wordpress' ),
182
 
183
- // Reference: src/modules/reports/routes/index.js:48
184
- __( 'Search Console Report', 'google-analytics-for-wordpress' ),
185
 
186
- // Reference: src/modules/reports/components/reports/ReportDimensions-Lite.vue:23
187
- // Reference: src/modules/reports/routes/index.js:56
188
- __( 'Dimensions Report', 'google-analytics-for-wordpress' ),
189
 
190
- // Reference: src/modules/reports/routes/index.js:64
191
- __( 'Forms Report', 'google-analytics-for-wordpress' ),
192
 
193
- // Reference: src/modules/reports/routes/index.js:72
194
- __( 'Real-Time Report', 'google-analytics-for-wordpress' ),
195
 
196
- // Reference: src/modules/widget/components/WidgetFooter.vue:18
197
- __( 'Recommended Plugin: %s', 'google-analytics-for-wordpress' ),
198
 
199
- // Reference: src/modules/widget/components/WidgetFooter.vue:19
200
- __( 'Install', 'google-analytics-for-wordpress' ),
201
 
202
- // Reference: src/modules/widget/components/WidgetFooter.vue:20
203
- __( 'Activate', 'google-analytics-for-wordpress' ),
204
 
205
- // Reference: src/modules/widget/components/WidgetFooter.vue:21
206
- __( 'Learn More', 'google-analytics-for-wordpress' ),
207
 
208
- // Reference: src/modules/widget/store/index.js:75
209
- __( 'Overview', 'google-analytics-for-wordpress' ),
210
 
211
- // Reference: src/modules/reports/components/ReportsNavigation.vue:41
212
- __( 'Publishers', 'google-analytics-for-wordpress' ),
213
 
214
- // Reference: src/modules/reports/components/ReportsNavigation.vue:42
215
- __( 'eCommerce', 'google-analytics-for-wordpress' ),
216
 
217
- // Reference: src/modules/reports/components/ReportsNavigation.vue:43
218
- __( 'Search Console', 'google-analytics-for-wordpress' ),
219
 
220
- // Reference: src/modules/reports/components/reports/ReportDimensions-Lite.vue:22
221
- __( 'Dimensions', 'google-analytics-for-wordpress' ),
222
 
223
- // Reference: src/modules/reports/components/ReportsNavigation.vue:45
224
- __( 'Forms', 'google-analytics-for-wordpress' ),
225
 
226
- // Reference: src/modules/reports/components/ReportsNavigation.vue:46
227
- __( 'Real-Time', 'google-analytics-for-wordpress' ),
228
 
229
- // Reference: src/plugins/monsterinsights-wizard-helper-plugin.js:13
230
- __( 'Loading settings', 'google-analytics-for-wordpress' ),
231
 
232
- // Reference: src/modules/about/components/AboutNavigation-Lite.vue:15
233
- // Reference: src/modules/settings/routes/site.js:109
234
- __( 'About Us', 'google-analytics-for-wordpress' ),
235
 
236
- // Reference: src/modules/about/components/AboutNavigation-Lite.vue:16
237
- // Reference: src/modules/settings/routes/site.js:117
238
- __( 'Getting Started', 'google-analytics-for-wordpress' ),
239
 
240
- // Reference: src/modules/about/components/AboutNavigation-Lite.vue:17
241
- // Reference: src/modules/settings/routes/site.js:126
242
- __( 'Lite vs Pro', 'google-analytics-for-wordpress' ),
243
 
244
- // Reference: src/modules/settings/routes/site.js:29
245
- __( 'General', 'google-analytics-for-wordpress' ),
246
 
247
- // Reference: src/modules/settings/routes/site.js:37
248
- __( 'Engagement', 'google-analytics-for-wordpress' ),
249
 
250
- // Reference: src/modules/settings/routes/site.js:53
251
- __( 'Publisher', 'google-analytics-for-wordpress' ),
252
 
253
- // Reference: src/modules/settings/routes/site.js:61
254
- __( 'Conversions', 'google-analytics-for-wordpress' ),
255
 
256
- // Reference: src/modules/settings/routes/site.js:69
257
- __( 'Advanced', 'google-analytics-for-wordpress' ),
258
 
259
- // Reference: src/modules/tools/components/ToolsNavigation.vue:15
260
- __( 'URL Builder', 'google-analytics-for-wordpress' ),
261
 
262
- // Reference: src/modules/tools/components/ToolsNavigation.vue:14
263
- __( 'Import Export', 'google-analytics-for-wordpress' ),
264
 
265
- // Reference: src/modules/widget/store/index.js:101
266
- __( 'Time to Purchase', 'google-analytics-for-wordpress' ),
267
 
268
- // Reference: src/modules/widget/store/index.js:102
269
- __( 'This list shows how many days from first visit it took users to purchase products from your site.', 'google-analytics-for-wordpress' ),
270
 
271
- // Reference: src/modules/widget/store/index.js:108
272
- __( 'Sessions to Purchase', 'google-analytics-for-wordpress' ),
 
273
 
274
- // Reference: src/modules/widget/store/index.js:109
275
- __( 'This list shows the number of sessions it took users before they purchased a product from your website.', 'google-analytics-for-wordpress' ),
276
 
277
- // Reference: src/modules/widget/store/index.js:19
278
- __( 'Top Posts/Pages', 'google-analytics-for-wordpress' ),
 
279
 
280
- // Reference: src/modules/widget/store/index.js:20
281
- __( 'This list shows the most viewed posts and pages on your website.', 'google-analytics-for-wordpress' ),
282
 
283
- // Reference: src/modules/widget/store/index.js:26
284
- __( 'New vs. Returning Visitors', 'google-analytics-for-wordpress' ),
285
 
286
- // Reference: src/modules/widget/store/index.js:27
287
- __( 'This graph shows what percent of your user sessions come from new versus repeat visitors.', 'google-analytics-for-wordpress' ),
 
288
 
289
- // Reference: src/modules/widget/store/index.js:33
290
- __( 'Device Breakdown', 'google-analytics-for-wordpress' ),
291
 
292
- // Reference: src/modules/widget/store/index.js:34
293
- __( 'This graph shows what percent of your visitor sessions are done using a traditional computer or laptop, tablet or mobile device to view your site.', 'google-analytics-for-wordpress' ),
 
294
 
295
- // Reference: src/modules/widget/store/index.js:40
296
- __( 'Top Landing Pages', 'google-analytics-for-wordpress' ),
 
297
 
298
- // Reference: src/modules/widget/store/index.js:41
299
- __( 'This list shows the top pages users first land on when visiting your website.', 'google-analytics-for-wordpress' ),
300
 
301
- // Reference: src/modules/widget/store/index.js:47
302
- __( 'Top Exit Pages', 'google-analytics-for-wordpress' ),
303
 
304
- // Reference: src/modules/widget/store/index.js:48
305
- __( 'This list shows the top pages users exit your website from.', 'google-analytics-for-wordpress' ),
306
 
307
- // Reference: src/modules/widget/store/index.js:54
308
- __( 'Top Outbound Links', 'google-analytics-for-wordpress' ),
 
309
 
310
- // Reference: src/modules/widget/store/index.js:55
311
- __( 'This list shows the top links clicked on your website that go to another website.', 'google-analytics-for-wordpress' ),
312
 
313
- // Reference: src/modules/widget/store/index.js:61
314
- __( 'Top Affiliate Links', 'google-analytics-for-wordpress' ),
 
315
 
316
- // Reference: src/modules/widget/store/index.js:62
317
- __( 'This list shows the top affiliate links your visitors clicked on.', 'google-analytics-for-wordpress' ),
318
 
319
- // Reference: src/modules/widget/store/index.js:68
320
- __( 'Top Download Links', 'google-analytics-for-wordpress' ),
321
 
322
- // Reference: src/modules/widget/store/index.js:69
323
- __( 'This list shows the download links your visitors clicked the most.', 'google-analytics-for-wordpress' ),
324
 
325
- // Reference: src/modules/widget/store/index.js:81
326
- __( 'Top Products', 'google-analytics-for-wordpress' ),
327
 
328
- // Reference: src/modules/widget/store/index.js:82
329
- __( 'This list shows the top selling products on your website.', 'google-analytics-for-wordpress' ),
330
 
331
- // Reference: src/modules/widget/store/index.js:88
332
- __( 'Top Conversion Sources', 'google-analytics-for-wordpress' ),
333
 
334
- // Reference: src/modules/widget/store/index.js:89
335
- __( 'This list shows the top referral websites in terms of product revenue.', 'google-analytics-for-wordpress' ),
336
 
337
- // Reference: src/modules/widget/store/index.js:95
338
- __( 'Total Add/Remove', 'google-analytics-for-wordpress' ),
339
 
340
- // Reference: src/modules/wizard-onboarding/components/TheWizardHeader.vue:24
341
- __( 'Exit Setup', 'google-analytics-for-wordpress' ),
342
 
343
- // Reference: src/plugins/monsterinsights-compatibility-plugin.js:37
344
- __( 'Yikes! PHP Update Required', 'google-analytics-for-wordpress' ),
345
 
346
- // Reference: src/plugins/monsterinsights-compatibility-plugin.js:12
347
- __( 'MonsterInsights has detected that your site is running an outdated, insecure version of PHP (%s), which could be putting your site at risk for being hacked. WordPress itself will stop supporting your PHP version in April, 2019. Updating to the recommended version (PHP %s) only takes a few minutes and will make your website significantly faster and more secure.', 'google-analytics-for-wordpress' ),
348
 
349
- // Reference: src/plugins/monsterinsights-compatibility-plugin.js:42
350
- __( 'Learn more about updating PHP', 'google-analytics-for-wordpress' ),
351
 
352
- // Reference: src/plugins/monsterinsights-compatibility-plugin.js:50
353
- __( 'Yikes! WordPress Update Required', 'google-analytics-for-wordpress' ),
354
 
355
- // Reference: src/plugins/monsterinsights-compatibility-plugin.js:25
356
- __( 'MonsterInsights has detected that your site is running an outdated version of WordPress (%s). MonsterInsights will stop supporting WordPress versions lower than 4.6 in April, 2019. Updating WordPress takes just a few minutes and will also solve many bugs that exist in your WordPress install.', 'google-analytics-for-wordpress' ),
357
 
358
- // Reference: src/plugins/monsterinsights-compatibility-plugin.js:55
359
- __( 'Learn more about updating WordPress', 'google-analytics-for-wordpress' ),
 
 
 
 
 
 
 
360
 
361
  // Reference: src/modules/frontend/components/FrontendPoweredBy.vue:12
362
  __( 'Powered by MonsterInsights', 'google-analytics-for-wordpress' ),
363
 
364
- // Reference: src/modules/settings/components/SettingsButtonSave.vue:46
365
- __( 'Save Changes', 'google-analytics-for-wordpress' ),
366
 
367
- // Reference: src/modules/reports/components/reports/ReportOverview.vue:147
368
- __( 'New', 'google-analytics-for-wordpress' ),
 
369
 
370
- // Reference: src/modules/reports/components/reports/ReportOverview.vue:148
371
- __( 'Returning', 'google-analytics-for-wordpress' ),
372
 
373
- // Reference: src/modules/reports/components/reports/ReportOverview.vue:178
374
- // Reference: src/modules/reports/components/reports/YearInReview-Lite.vue:496
375
- __( 'Desktop', 'google-analytics-for-wordpress' ),
376
 
377
- // Reference: src/modules/reports/components/reports/ReportOverview.vue:179
378
- // Reference: src/modules/reports/components/reports/YearInReview-Lite.vue:497
379
- __( 'Tablet', 'google-analytics-for-wordpress' ),
380
 
381
- // Reference: src/modules/reports/components/reports/ReportOverview.vue:180
382
- // Reference: src/modules/reports/components/reports/YearInReview-Lite.vue:498
383
- __( 'Mobile', 'google-analytics-for-wordpress' ),
384
 
385
- // Reference: src/modules/frontend/components/FrontendStatsGeneral.vue:26
386
- __( 'Sessions', 'google-analytics-for-wordpress' ),
387
 
388
- // Reference: src/modules/widget/components/reports/WidgetReportOverview-Lite.vue:63
389
- __( 'Unique %s Sessions', 'google-analytics-for-wordpress' ),
390
 
391
- // Reference: src/modules/frontend/components/FrontendStatsGeneral.vue:27
392
- __( 'Pageviews', 'google-analytics-for-wordpress' ),
393
 
394
- // Reference: src/modules/widget/components/reports/WidgetReportOverview-Lite.vue:65
395
- __( 'Unique %s Pageviews', 'google-analytics-for-wordpress' ),
396
 
397
- // Reference: src/modules/widget/components/reports/WidgetReportOverview-Lite.vue:70
398
- __( 'Avg. Session Duration', 'google-analytics-for-wordpress' ),
399
 
400
- // Reference: src/modules/frontend/components/FrontendStatsGeneral.vue:29
401
- __( 'Bounce Rate', 'google-analytics-for-wordpress' ),
402
 
403
- // Reference: src/modules/reports/components/reports/ReportOverview.vue:245
404
- __( 'Top 10 Countries', 'google-analytics-for-wordpress' ),
 
405
 
406
- // Reference: src/modules/reports/components/reports/ReportOverview.vue:246
407
- __( 'View Countries Report', 'google-analytics-for-wordpress' ),
408
 
409
- // Reference: src/modules/reports/components/reports/ReportOverview.vue:247
410
- __( 'Top 10 Referrals', 'google-analytics-for-wordpress' ),
411
 
412
- // Reference: src/modules/reports/components/reports/ReportOverview.vue:248
413
- __( 'View All Referral Sources', 'google-analytics-for-wordpress' ),
414
 
415
- // Reference: src/modules/reports/components/reports/ReportOverview.vue:250
416
- __( 'View Full Posts/Pages Report', 'google-analytics-for-wordpress' ),
417
 
418
- // Reference: src/modules/widget/components/reports/WidgetReportOverview-Lite.vue:66
419
- __( 'A session is the browsing session of a single user to your site.', 'google-analytics-for-wordpress' ),
420
 
421
- // Reference: src/modules/widget/components/reports/WidgetReportOverview-Lite.vue:67
422
- __( 'A pageview is defined as a view of a page on your site that is being tracked by the Analytics tracking code. Each refresh of a page is also a new pageview.', 'google-analytics-for-wordpress' ),
423
 
424
- // Reference: src/modules/widget/components/reports/WidgetReportOverview-Lite.vue:68
425
- __( 'Total duration of all sessions (in seconds) / number of sessions.', 'google-analytics-for-wordpress' ),
426
 
427
- // Reference: src/modules/reports/components/reports/ReportOverview.vue:255
428
- __( 'Percentage of single-page visits (or web sessions). It is the number of visits in which a person leaves your website from the landing page without browsing any further.', 'google-analytics-for-wordpress' ),
429
 
430
- // Reference: src/modules/reports/components/reports/ReportOverview.vue:258
431
- __( 'This list shows the top countries your website visitors are from.', 'google-analytics-for-wordpress' ),
432
 
433
- // Reference: src/modules/reports/components/reports/ReportOverview.vue:259
434
- __( 'This list shows the top websites that send your website traffic, known as referral traffic.', 'google-analytics-for-wordpress' ),
435
 
436
- // Reference: src/modules/addons/components/AddonsNavigation.vue:18
437
- __( 'MonsterInsights Addons', 'google-analytics-for-wordpress' ),
438
 
439
- // Reference: src/modules/addons/components/AddonsNavigation.vue:19
440
- __( 'Search Addons', 'google-analytics-for-wordpress' ),
1
  <?php
2
  /* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */
3
  $generated_i18n_strings = array(
4
+ // Reference: src/modules/tools/components/monsterinsights-ToolsPrettyLinksFlow.vue:96
5
+ __( '1', 'google-analytics-for-wordpress' ),
6
 
7
+ // Reference: src/modules/tools/components/monsterinsights-ToolsPrettyLinksFlow.vue:97
8
+ __( '2', 'google-analytics-for-wordpress' ),
9
+
10
+ // Reference: src/plugins/monsterinsights-wizard-helper-plugin.js:13
11
+ __( 'Loading settings', 'google-analytics-for-wordpress' ),
12
 
13
+ // Reference: src/modules/settings/components/input/tab-general/monsterinsights-SettingsInputAuthenticate-Lite.vue:227
 
 
14
  __( 'Error', 'google-analytics-for-wordpress' ),
15
 
16
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:206
17
  __( 'Please try again.', 'google-analytics-for-wordpress' ),
18
 
19
+ // Reference: src/plugins/exactmetrics-reports-helper-plugin.js:129
20
+ __( 'Loading new report data', 'google-analytics-for-wordpress' ),
21
+
22
+ // Reference: src/modules/settings/components/input/tab-general/SettingsInputLicense-Lite.vue:55
23
+ __( 'Please wait...', 'google-analytics-for-wordpress' ),
24
+
25
+ // Reference: src/plugins/exactmetrics-reports-helper-plugin.js:143
26
+ /* Translators: Adds an arrow icon. */
27
+ __( 'Continue %s', 'google-analytics-for-wordpress' ),
28
+
29
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:236
30
  __( 'Unlock the Publishers Report and Focus on the Content that Matters', 'google-analytics-for-wordpress' ),
31
 
32
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:237
33
  __( 'Stop guessing about what content your visitors are interested in. MonsterInsights Publisher Report shows you exactly which content gets the most visits, so you can analyze and optimize it for higher conversions.', 'google-analytics-for-wordpress' ),
34
 
35
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:248
36
  __( 'Unlock the Publishers Report and Focus on the Content That Matters', 'google-analytics-for-wordpress' ),
37
 
38
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:249
39
  __( 'Stop guessing about what content your visitors are interested in. The Publisher Report shows you exactly which content gets the most traffic, so you can analyze and optimize it for higher conversions.', 'google-analytics-for-wordpress' ),
40
 
41
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:260
42
+ __( 'Unlock the eCommerce Report and See Your Important Store Metrics', 'google-analytics-for-wordpress' ),
43
+
44
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:261
45
+ __( 'Increase your sales & revenue with insights. MonsterInsights answers all your top eCommerce questions using metrics like total revenue, conversion rate, average order value, top products, top referral sources and more.', 'google-analytics-for-wordpress' ),
46
+
47
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:274
48
+ __( 'Unlock the Dimensions Report and Track Your Own Custom Data', 'google-analytics-for-wordpress' ),
49
+
50
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:275
51
+ __( 'Decide what data is important using your own custom tracking parameters. The Dimensions report allows you to easily see what\'s working right inside your WordPress dashboard.', 'google-analytics-for-wordpress' ),
52
+
53
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:285
54
+ __( 'Unlock the Forms Report and Improve Conversions', 'google-analytics-for-wordpress' ),
55
+
56
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:286
57
+ __( 'Easily track your form views and conversions. The Forms Report allows you to see which forms are performing better and which forms have lower conversion rates so you can optimize using real data.', 'google-analytics-for-wordpress' ),
58
+
59
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:294
60
+ __( 'Unlock the Search Console Report and See How People Find Your Website', 'google-analytics-for-wordpress' ),
61
+
62
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:295
63
+ __( 'See exactly how people find your website, which keywords they searched for, how many times the results were viewed, and more.', 'google-analytics-for-wordpress' ),
64
+
65
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:304
66
+ __( 'Unlock the Real-Time Report and Track the Visitors on Your Site in Real-Time', 'google-analytics-for-wordpress' ),
67
+
68
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:305
69
+ __( 'Track the results of your marketing efforts and product launches as-it-happens right from your WordPress site. The Real-Time report allows you to view your traffic sources and visitors activity when you need it.', 'google-analytics-for-wordpress' ),
70
+
71
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:188
72
+ __( 'Refreshing Report', 'google-analytics-for-wordpress' ),
73
+
74
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:189
75
+ __( 'Loading new report data...', 'google-analytics-for-wordpress' ),
76
+
77
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:251
78
  __( 'See Your Top Landing Pages to Improve Enagement', 'google-analytics-for-wordpress' ),
79
 
80
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:252
81
  __( 'See Your Top Exit Pages to Reduce Abandonment', 'google-analytics-for-wordpress' ),
82
 
83
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:253
84
  __( 'See Your Top Outbound Links to Find New Revenue Opportunities', 'google-analytics-for-wordpress' ),
85
 
86
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:254
87
  __( 'See Your Top Affiliate Links and Focus on what\'s working', 'google-analytics-for-wordpress' ),
88
 
89
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:255
90
  __( 'See Your Top Downloads and Improve Conversions', 'google-analytics-for-wordpress' ),
91
 
92
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:256
93
  __( 'See Audience Demographic Report ( Age / Gender / Interests )', 'google-analytics-for-wordpress' ),
94
 
95
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:263
 
 
 
 
 
 
96
  __( 'See Your Conversion Rate to Improve Funnel', 'google-analytics-for-wordpress' ),
97
 
98
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:264
99
+ __( 'See The Number of Transactions and Make Data-Driven Decisions', 'google-analytics-for-wordpress' ),
100
 
101
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:265
102
  __( 'See The Total Revenue to Track Growth', 'google-analytics-for-wordpress' ),
103
 
104
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:266
105
  __( 'See Average Order Value to Find Offer Opportunities', 'google-analytics-for-wordpress' ),
106
 
107
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:267
108
  __( 'See Your Top Products to See Individual Performance', 'google-analytics-for-wordpress' ),
109
 
110
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:268
111
  __( 'See Your Top Conversion Sources and Focus on what\'s working', 'google-analytics-for-wordpress' ),
112
 
113
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:269
114
  __( 'See The Time it takes for Customers to Purchase', 'google-analytics-for-wordpress' ),
115
 
116
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:270
117
  __( 'See How Many Sessions are needed for a Purchase', 'google-analytics-for-wordpress' ),
118
 
119
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:277
 
 
 
 
 
 
120
  __( 'See Which Authors Generate the Most Traffic', 'google-analytics-for-wordpress' ),
121
 
122
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:278
123
  __( 'See Which Post Types Perform Better', 'google-analytics-for-wordpress' ),
124
 
125
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:279
126
  __( 'See Which Categories are the Most Popular', 'google-analytics-for-wordpress' ),
127
 
128
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:280
129
+ __( 'See Your Blog\'s most popular SEO Scores', 'google-analytics-for-wordpress' ),
130
 
131
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:281
132
  __( 'See Which Focus Keyword is Performing Better in Search Engines', 'google-analytics-for-wordpress' ),
133
 
134
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:288
 
 
 
 
 
 
135
  __( 'See Reports for Any Contact Form Plugin or Sign-up Form', 'google-analytics-for-wordpress' ),
136
 
137
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:289
138
  __( 'See Your Top Converting Forms and Optimize', 'google-analytics-for-wordpress' ),
139
 
140
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:290
141
  __( 'See Your Forms Impressions Count to Find the Best Placement', 'google-analytics-for-wordpress' ),
142
 
143
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:297
 
 
 
 
 
 
144
  __( 'See Your Top Google Search Terms and Optimize Content', 'google-analytics-for-wordpress' ),
145
 
146
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:298
147
  __( 'See The Number of Clicks and Track Interests', 'google-analytics-for-wordpress' ),
148
 
149
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:299
150
  __( 'See The Click-Through-Ratio and Improve SEO', 'google-analytics-for-wordpress' ),
151
 
152
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:300
153
  __( 'See The Average Results Position and Focus on what works', 'google-analytics-for-wordpress' ),
154
 
155
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:307
 
 
 
 
 
 
156
  __( 'See Your Active Visitors and Track Their Behaviour to Optimize', 'google-analytics-for-wordpress' ),
157
 
158
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:308
159
  __( 'See Your Top Pages Immediately After Making Changes', 'google-analytics-for-wordpress' ),
160
 
161
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:309
162
  __( 'See Your Top Referral Sources and Adapt Faster', 'google-analytics-for-wordpress' ),
163
 
164
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:310
165
  __( 'See Your Traffic Demographics and ', 'google-analytics-for-wordpress' ),
166
 
167
+ // Reference: src/plugins/monsterinsights-reports-helper-plugin.js:311
168
  __( 'Get Fresh Reports Data Every 60 Seconds', 'google-analytics-for-wordpress' ),
169
 
170
+ // Reference: src/modules/frontend/monsterinsights-frontend.vue:36
171
+ __( 'Insights', 'google-analytics-for-wordpress' ),
172
+
173
+ // Reference: src/modules/reports/components/reports/monsterinsights-ReportOverview.vue:241
174
+ // Reference: src/modules/widget/widget.vue:25
175
  __( 'Overview Report', 'google-analytics-for-wordpress' ),
176
 
177
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:125
178
+ __( 'Welcome to MonsterInsights', 'google-analytics-for-wordpress' ),
179
 
180
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:126
181
+ __( 'Thank you for choosing MonsterInsights - The Most Powerful WordPress Analytics Plugin', 'google-analytics-for-wordpress' ),
182
 
183
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:127
184
+ __( 'MonsterInsights makes it “effortless” to setup Google Analytics in WordPress, the RIGHT Way. You can watch the video tutorial or use our 3 minute setup wizard.', 'google-analytics-for-wordpress' ),
185
 
186
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:128
187
+ __( 'Launch the Wizard!', 'google-analytics-for-wordpress' ),
188
 
189
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:129
190
+ __( 'Read the Full Guide', 'google-analytics-for-wordpress' ),
191
 
192
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:130
193
+ __( 'MonsterInsights Features & Addons', 'google-analytics-for-wordpress' ),
194
 
195
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:131
196
+ __( 'Here are the features that make MonsterInsights the most powerful and user-friendly WordPress analytics plugin in the market.', 'google-analytics-for-wordpress' ),
197
 
198
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:132
199
+ __( 'See All Features', 'google-analytics-for-wordpress' ),
200
 
201
+ // Reference: src/modules/frontend/components/FrontendUpsell-Lite.vue:11
202
+ __( 'Upgrade to PRO', 'google-analytics-for-wordpress' ),
203
 
204
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:134
205
+ __( 'per year', 'google-analytics-for-wordpress' ),
206
 
207
+ // Reference: src/modules/addons/monsterinsights-addons-Lite.vue:80
208
+ __( 'Upgrade Now', 'google-analytics-for-wordpress' ),
 
209
 
210
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:136
211
+ __( 'Testimonials', 'google-analytics-for-wordpress' ),
212
 
213
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:140
214
+ __( 'Universal Tracking', 'google-analytics-for-wordpress' ),
215
 
216
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:141
217
+ __( 'Setup universal website tracking across devices and campaigns with just a few clicks (without any code).', 'google-analytics-for-wordpress' ),
218
 
219
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:145
220
+ __( 'Google Analytics Dashboard', 'google-analytics-for-wordpress' ),
221
 
222
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:146
223
+ __( 'See your website analytics report right inside your WordPress dashboard with actionable insights.', 'google-analytics-for-wordpress' ),
224
 
225
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:150
226
+ __( 'Real-time Stats', 'google-analytics-for-wordpress' ),
227
 
228
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:151
229
+ __( 'Get real-time stats right inside WordPress to see who is online, what are they doing, and more.', 'google-analytics-for-wordpress' ),
230
 
231
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:155
232
+ __( 'Enhanced Ecommerce Tracking', 'google-analytics-for-wordpress' ),
233
 
234
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:156
235
+ __( '1-click Google Analytics Enhanced Ecommerce tracking for WooCommerce, Easy Digital Downloads & MemberPress.', 'google-analytics-for-wordpress' ),
236
 
237
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:160
238
+ __( 'Page Level Analytics', 'google-analytics-for-wordpress' ),
239
 
240
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:161
241
+ __( 'Get detailed stats for each post and page, so you can see the most popular posts, pages, and sections of your site.', 'google-analytics-for-wordpress' ),
242
 
243
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:165
244
+ __( 'Affiliate Link & Ads Tracking', 'google-analytics-for-wordpress' ),
245
 
246
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:166
247
+ __( 'Automatically track clicks on your affiliate links, banner ads, and other outbound links with our link tracking.', 'google-analytics-for-wordpress' ),
248
 
249
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:170
250
+ __( 'EU Compliance (GDPR Friendly)', 'google-analytics-for-wordpress' ),
251
 
252
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:171
253
+ __( 'Make Google Analytics compliant with GDPR and other privacy regulations automatically.', 'google-analytics-for-wordpress' ),
 
254
 
255
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:176
256
+ __( 'Setup tracking for authors, categories, tags, searches, custom post types, users, and other events with 1-click.', 'google-analytics-for-wordpress' ),
 
257
 
258
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:181
259
+ __( 'Ecommerce Report', 'google-analytics-for-wordpress' ),
 
260
 
261
+ // Reference: src/modules/settings/components/SettingsLiteUpsellLarge.vue:30
262
+ __( 'Form Conversions', 'google-analytics-for-wordpress' ),
263
 
264
+ // Reference: src/modules/settings/components/SettingsLiteUpsellLarge.vue:26
265
+ __( 'Custom Dimensions', 'google-analytics-for-wordpress' ),
266
 
267
+ // Reference: src/modules/settings/components/SettingsLiteUpsellLarge.vue:29
268
+ __( 'Author Tracking', 'google-analytics-for-wordpress' ),
269
 
270
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:185
271
+ __( 'Google Optimize', 'google-analytics-for-wordpress' ),
272
 
273
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:186
274
+ __( 'Category / Tags Tracking', 'google-analytics-for-wordpress' ),
275
 
276
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:187
277
+ __( 'WooCommerce', 'google-analytics-for-wordpress' ),
278
 
279
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:188
280
+ __( 'Easy Digital Downloads', 'google-analytics-for-wordpress' ),
281
 
282
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:189
283
+ __( 'MemberPress', 'google-analytics-for-wordpress' ),
284
 
285
+ // Reference: src/modules/wizard-onboarding/monsterinsights-welcome-Lite.vue:190
286
+ __( 'LifterLMS', 'google-analytics-for-wordpress' ),
287
 
288
+ // Reference: src/plugins/monsterinsights-compatibility-plugin.js:27
289
+ /* Translators: Current WordPress version. */
290
+ __( 'MonsterInsights has detected that your site is running an outdated version of WordPress (%s). MonsterInsights will stop supporting WordPress versions lower than 4.6 in April, 2019. Updating WordPress takes just a few minutes and will also solve many bugs that exist in your WordPress install.', 'google-analytics-for-wordpress' ),
291
 
292
+ // Reference: src/plugins/monsterinsights-compatibility-plugin.js:39
293
+ __( 'Yikes! PHP Update Required', 'google-analytics-for-wordpress' ),
294
 
295
+ // Reference: src/plugins/monsterinsights-compatibility-plugin.js:41
296
+ /* Translators: Current PHP version and recommended PHP version. */
297
+ __( 'MonsterInsights has detected that your site is running an outdated, insecure version of PHP (%1$s), which could be putting your site at risk for being hacked. WordPress stopped supporting your PHP version in April, 2019. Updating to the recommended version (PHP %2$s) only takes a few minutes and will make your website significantly faster and more secure.', 'google-analytics-for-wordpress' ),
298
 
299
+ // Reference: src/plugins/monsterinsights-compatibility-plugin.js:45
300
+ __( 'Learn more about updating PHP', 'google-analytics-for-wordpress' ),
301
 
302
+ // Reference: src/plugins/monsterinsights-compatibility-plugin.js:53
303
+ __( 'Yikes! WordPress Update Required', 'google-analytics-for-wordpress' ),
304
 
305
+ // Reference: src/plugins/monsterinsights-compatibility-plugin.js:55
306
+ /* Translators: Current WordPress version. */
307
+ __( 'MonsterInsights has detected that your site is running an outdated version of WordPress (%s). MonsterInsights will stop supporting WordPress versions lower than 4.9 in October, 2019. Updating WordPress takes just a few minutes and will also solve many bugs that exist in your WordPress install.', 'google-analytics-for-wordpress' ),
308
 
309
+ // Reference: src/plugins/monsterinsights-compatibility-plugin.js:59
310
+ __( 'Learn more about updating WordPress', 'google-analytics-for-wordpress' ),
311
 
312
+ // Reference: src/modules/widget/components/WidgetReminder.vue:33
313
+ /* Translators: Number of visitors. */
314
+ __( 'See how %s visitors found your site!', 'google-analytics-for-wordpress' ),
315
 
316
+ // Reference: src/modules/widget/components/WidgetReminder.vue:35
317
+ /* Translators: Number of visitors. */
318
+ __( 'Your website was visited by %s users in the last 30 days.', 'google-analytics-for-wordpress' ),
319
 
320
+ // Reference: src/modules/widget/components/WidgetReminder.vue:36
321
+ __( 'See the full analytics report!', 'google-analytics-for-wordpress' ),
322
 
323
+ // Reference: src/modules/settings/monsterinsights-site.vue:78
324
+ __( 'Congratulations! ', 'google-analytics-for-wordpress' ),
325
 
326
+ // Reference: src/modules/settings/monsterinsights-site.vue:79
327
+ __( 'You Successfully Unlocked the most powerful Analytics plugin', 'google-analytics-for-wordpress' ),
328
 
329
+ // Reference: src/modules/reports/api/index.js:21
330
+ /* Translators: Error status and error text. */
331
+ __( 'Can\'t load report data. Error: %1$s, %2$s', 'google-analytics-for-wordpress' ),
332
 
333
+ // Reference: src/modules/reports/api/index.js:28
334
+ __( 'Error loading report data', 'google-analytics-for-wordpress' ),
335
 
336
+ // Reference: src/modules/widget/components/WidgetFooter.vue:19
337
+ /* Translators: Placeholder is replaced with WPForms. */
338
+ __( 'Recommended Plugin: %s', 'google-analytics-for-wordpress' ),
339
 
340
+ // Reference: src/modules/addons/components/AddonButton.vue:51
341
+ __( 'Install', 'google-analytics-for-wordpress' ),
342
 
343
+ // Reference: src/modules/addons/components/AddonButton.vue:47
344
+ __( 'Activate', 'google-analytics-for-wordpress' ),
345
 
346
+ // Reference: src/modules/wizard-onboarding/components/OnboardingAddon-Lite.vue:26
347
+ __( 'Learn More', 'google-analytics-for-wordpress' ),
348
 
349
+ // Reference: src/components/TheQuickLinks.vue:31
350
+ __( 'See Quick Links', 'google-analytics-for-wordpress' ),
351
 
352
+ // Reference: src/components/TheQuickLinks.vue:58
353
+ __( 'Suggest a Feature', 'google-analytics-for-wordpress' ),
354
 
355
+ // Reference: src/components/TheQuickLinks.vue:64
356
+ __( 'Join Our Community', 'google-analytics-for-wordpress' ),
357
 
358
+ // Reference: src/components/TheQuickLinks.vue:70
359
+ __( 'Support & Docs', 'google-analytics-for-wordpress' ),
360
 
361
+ // Reference: src/components/TheQuickLinks.vue:78
362
+ __( 'Upgrade to Pro &#187;', 'google-analytics-for-wordpress' ),
363
 
364
+ // Reference: src/modules/frontend/components/FrontendNoAuth.vue:24
365
+ __( 'Please Setup Website Analytics to See Audience Insights', 'google-analytics-for-wordpress' ),
366
 
367
+ // Reference: src/modules/frontend/components/FrontendNoAuth.vue:25
368
+ __( 'MonsterInsights, WordPress analytics plugin, helps you connect your website with Google Analytics, so you can see how people find and use your website. Over 2 million website owners use MonsterInsights to see the stats that matter and grow their business.', 'google-analytics-for-wordpress' ),
369
 
370
+ // Reference: src/modules/frontend/components/FrontendNoAuth.vue:26
371
+ __( 'Connect MonsterInsights and Setup Website Analytics', 'google-analytics-for-wordpress' ),
372
 
373
+ // Reference: src/modules/reports/components/ReportReAuth.vue:19
374
+ __( 'MonsterInsights encountered an error loading your report data', 'google-analytics-for-wordpress' ),
375
 
376
+ // Reference: src/modules/reports/components/ReportReAuth.vue:20
377
+ __( 'There is an issue with your Google Account authentication. Please use the button below to fix it by re-authenticating.', 'google-analytics-for-wordpress' ),
378
 
379
+ // Reference: src/modules/settings/components/input/tab-general/monsterinsights-SettingsInputAuthenticate-Lite.vue:69
380
+ __( 'Reconnect MonsterInsights', 'google-analytics-for-wordpress' ),
381
 
382
+ // Reference: src/modules/settings/components/input/tab-general/monsterinsights-SettingsInputAuthenticate-Lite.vue:143
383
+ __( 'Re-Authenticating', 'google-analytics-for-wordpress' ),
384
+
385
+ // Reference: src/modules/settings/components/input/tab-general/monsterinsights-SettingsInputAuthenticate-Lite.vue:229
386
+ __( 'Ok', 'google-analytics-for-wordpress' ),
387
+
388
+ // Reference: src/modules/widget/components/monsterinsights-WidgetSettings-Lite.vue:19
389
+ /* Translators: Number of days in interval. */
390
+ __( 'Last %s days', 'google-analytics-for-wordpress' ),
391
 
392
  // Reference: src/modules/frontend/components/FrontendPoweredBy.vue:12
393
  __( 'Powered by MonsterInsights', 'google-analytics-for-wordpress' ),
394
 
395
+ // Reference: src/modules/reports/routes/index.js:32
396
+ __( 'Publishers Report', 'google-analytics-for-wordpress' ),
397
 
398
+ // Reference: src/modules/reports/components/reports/monsterinsights-ReportEcommerce-Lite.vue:23
399
+ // Reference: src/modules/reports/routes/index.js:40
400
+ __( 'eCommerce Report', 'google-analytics-for-wordpress' ),
401
 
402
+ // Reference: src/modules/reports/routes/index.js:48
403
+ __( 'Search Console Report', 'google-analytics-for-wordpress' ),
404
 
405
+ // Reference: src/modules/reports/components/reports/monsterinsights-ReportDimensions-Lite.vue:23
406
+ __( 'Dimensions Report', 'google-analytics-for-wordpress' ),
 
407
 
408
+ // Reference: src/modules/reports/components/reports/monsterinsights-ReportForms-Lite.vue:25
409
+ __( 'Forms Report', 'google-analytics-for-wordpress' ),
 
410
 
411
+ // Reference: src/modules/reports/components/reports/monsterinsights-ReportRealTime-Lite.vue:51
412
+ __( 'Real-Time Report', 'google-analytics-for-wordpress' ),
 
413
 
414
+ // Reference: src/modules/reports/components/monsterinsights-ReportsNavigation.vue:48
415
+ __( '2019 Year in Review', 'google-analytics-for-wordpress' ),
416
 
417
+ // Reference: src/modules/about/components/AboutNavigation-Lite.vue:15
418
+ __( 'About Us', 'google-analytics-for-wordpress' ),
419
 
420
+ // Reference: src/modules/about/components/AboutNavigation-Lite.vue:16
421
+ __( 'Getting Started', 'google-analytics-for-wordpress' ),
422
 
423
+ // Reference: src/modules/about/components/AboutNavigation-Lite.vue:17
424
+ __( 'Lite vs Pro', 'google-analytics-for-wordpress' ),
425
 
426
+ // Reference: src/modules/settings/routes/site.js:30
427
+ __( 'General', 'google-analytics-for-wordpress' ),
428
 
429
+ // Reference: src/modules/settings/routes/site.js:38
430
+ __( 'Engagement', 'google-analytics-for-wordpress' ),
431
 
432
+ // Reference: src/modules/reports/components/monsterinsights-ReportsNavigation.vue:42
433
+ // Reference: src/modules/settings/routes/site.js:46
434
+ __( 'eCommerce', 'google-analytics-for-wordpress' ),
435
 
436
+ // Reference: src/modules/settings/routes/site.js:54
437
+ __( 'Publisher', 'google-analytics-for-wordpress' ),
438
 
439
+ // Reference: src/modules/settings/routes/site.js:62
440
+ __( 'Conversions', 'google-analytics-for-wordpress' ),
441
 
442
+ // Reference: src/modules/settings/routes/site.js:70
443
+ __( 'Advanced', 'google-analytics-for-wordpress' ),
444
 
445
+ // Reference: src/modules/settings/routes/site.js:87
446
+ __( 'URL Builder', 'google-analytics-for-wordpress' ),
447
 
448
+ // Reference: src/modules/settings/routes/site.js:95
449
+ __( 'Import Export', 'google-analytics-for-wordpress' ),
450
 
451
+ // Reference: src/modules/wizard-onboarding/components/TheWizardHeader.vue:24
452
+ __( 'Exit Setup', 'google-analytics-for-wordpress' ),
453
 
454
+ // Reference: src/modules/widget/store/index.js:102
455
+ __( 'Time to Purchase', 'google-analytics-for-wordpress' ),
456
 
457
+ // Reference: src/modules/widget/store/index.js:103
458
+ __( 'This list shows how many days from first visit it took users to purchase products from your site.', 'google-analytics-for-wordpress' ),
459
 
460
+ // Reference: src/modules/widget/store/index.js:109
461
+ __( 'Sessions to Purchase', 'google-analytics-for-wordpress' ),
462
 
463
+ // Reference: src/modules/widget/store/index.js:110
464
+ __( 'This list shows the number of sessions it took users before they purchased a product from your website.', 'google-analytics-for-wordpress' ),
465
 
466
+ // Reference: src/modules/reports/components/reports/monsterinsights-ReportOverview.vue:256
467
+ __( 'Top Posts/Pages', 'google-analytics-for-wordpress' ),
468
 
469
+ // Reference: src/modules/reports/components/reports/