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> <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 ' <a href="' . esc_url( $optin_url ) . '" class="button-secondary">' . __( 'Allow', 'google-analytics-for-wordpress' ) . '</a>'; |
369
|
|
|
// echo ' <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' ) .'">', ' »</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' ) .'">', ' »</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 ); |
495
|
|
|
|