Passed
Push — master ( 8403c0...3ede7f )
by Chris
08:42
created

monsterinsights_empty_measurement_protocol_token()   B

Complexity

Conditions 7
Paths 9

Size

Total Lines 28
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 7
eloc 18
c 2
b 0
f 0
nc 9
nop 0
dl 0
loc 28
rs 8.8333
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' );
0 ignored issues
show
Bug introduced by
'100.00013467543' of type string is incompatible with the type integer expected by parameter $position of add_menu_page(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

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, /** @scrutinizer ignore-type */ '100.00013467543' );
Loading history...
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
	// Add Popular Posts menu item.
51
	add_submenu_page( $hook, __( 'Popular Posts:', 'google-analytics-for-wordpress' ), __( 'Popular Posts', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', $submenu_base . '#/popular-posts' );
52
53
    if ( function_exists( 'aioseo' ) ) {
54
        $seo_url = monsterinsights_aioseo_dashboard_url();
55
    } else {
56
        $seo_url = $submenu_base . '#/seo';
57
    }
58
    // then SEO
59
    add_submenu_page( $hook, __( 'SEO', 'google-analytics-for-wordpress' ), __( 'SEO', 'google-analytics-for-wordpress' ), 'manage_options', $seo_url );
60
61
    // then tools
62
    add_submenu_page( $hook, __( 'Tools:', 'google-analytics-for-wordpress' ), __( 'Tools', 'google-analytics-for-wordpress' ), 'manage_options', $submenu_base . '#/tools' );
63
64
    // then addons
65
    $network_key = monsterinsights_is_pro_version() ? MonsterInsights()->license->get_network_license_key() : '';
0 ignored issues
show
Bug Best Practice introduced by
The property $license is declared protected in MonsterInsights_Lite. Since you implement __get, consider adding a @property or @property-read.
Loading history...
66
    if ( ! monsterinsights_is_network_active() || ( monsterinsights_is_network_active() && empty( $network_key ) ) ) {
67
        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' );
68
    }
69
70
    // Add About us page.
71
    add_submenu_page( $hook, __( 'About Us:', 'google-analytics-for-wordpress' ), __( 'About Us', 'google-analytics-for-wordpress' ), 'manage_options', $submenu_base . '#/about' );
72
73
    if ( ! monsterinsights_is_pro_version() ) {
74
	    add_submenu_page( $hook, __( 'Upgrade to Pro:', 'google-analytics-for-wordpress' ), '<span class="monsterinsights-upgrade-submenu"> ' . __( 'Upgrade to Pro', 'google-analytics-for-wordpress' ) . '</span>', 'monsterinsights_save_settings', monsterinsights_get_upgrade_link( 'admin-menu', 'submenu', "https://www.monsterinsights.com/lite/" ) );
75
    }
76
77
}
78
add_action( 'admin_menu', 'monsterinsights_admin_menu' );
79
80
/**
81
 * Add this separately so all the Woo menu items are loaded and the position parameter works correctly.
82
 */
83
function monsterinsights_woocommerce_menu_item() {
84
	// Add "Insights" sub menu item for WooCommerce Analytics menu
85
	if ( class_exists( 'WooCommerce' ) && ! apply_filters( 'monsterinsights_disable_woo_analytics_menu', false ) ) {
86
		if ( class_exists( 'MonsterInsights_eCommerce' ) ) {
87
			add_submenu_page( 'wc-admin&path=/analytics/overview', __( 'Insights', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', admin_url( 'admin.php?page=monsterinsights_reports#/ecommerce' ), '', 2 );
88
		} else {
89
			$submenu_base = add_query_arg( 'page', 'monsterinsights_settings', admin_url( 'admin.php' ) );
90
			add_submenu_page( 'wc-admin&path=/analytics/overview', __( 'Insights', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'manage_options', $submenu_base . '#/woocommerce-insights', '', 1 );
91
		}
92
	}
93
}
94
95
add_action( 'admin_menu', 'monsterinsights_woocommerce_menu_item', 11 );
96
97
function monsterinsights_get_menu_hook() {
98
    $dashboards_disabled = monsterinsights_get_option( 'dashboards_disabled', false );
99
    if ( $dashboards_disabled || ( current_user_can( 'monsterinsights_save_settings' ) && ! current_user_can( 'monsterinsights_view_dashboard' ) ) ) {
100
        return 'monsterinsights_settings';
101
    } else {
102
        return 'monsterinsights_reports';
103
    }
104
}
105
106
function monsterinsights_network_admin_menu() {
107
    // Get the base class object.
108
    $base = MonsterInsights();
0 ignored issues
show
Unused Code introduced by
The assignment to $base is dead and can be removed.
Loading history...
109
110
    // First, let's see if this is an MS network enabled plugin. If it is, we should load the license
111
    // menu page and the updater on the network panel
112
    if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
113
        require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
114
    }
115
116
    $plugin = plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE );
117
    if ( ! is_plugin_active_for_network( $plugin ) ) {
118
        return;
119
    }
120
121
    $menu_icon_inline = monsterinsights_get_inline_menu_icon();
122
    $hook = 'monsterinsights_network';
123
    $submenu_base = add_query_arg( 'page', 'monsterinsights_network', network_admin_url( 'admin.php' ) );
124
    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' );
0 ignored issues
show
Bug introduced by
'100.00013467543' of type string is incompatible with the type integer expected by parameter $position of add_menu_page(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

124
    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, /** @scrutinizer ignore-type */ '100.00013467543' );
Loading history...
125
126
    add_submenu_page( $hook, __( 'Network Settings:', 'google-analytics-for-wordpress' ), __( 'Network Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_network', 'monsterinsights_network_page' );
127
128
    add_submenu_page( $hook, __( 'General Reports:', 'google-analytics-for-wordpress' ), __( 'Reports', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page' );
129
130
    if ( function_exists( 'aioseo' ) ) {
131
        $seo_url = monsterinsights_aioseo_dashboard_url();
132
    } else {
133
        $seo_url = $submenu_base . '#/seo';
134
    }
135
    // then seo
136
    add_submenu_page( $hook, __( 'SEO:', 'google-analytics-for-wordpress' ), __( 'SEO', 'google-analytics-for-wordpress' ), 'manage_options', $seo_url, 'monsterinsights_seo_page' );
137
138
    // then addons
139
    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' );
140
141
    $submenu_base = add_query_arg( 'page', 'monsterinsights_network', network_admin_url( 'admin.php' ) );
142
143
    // Add About us page.
144
    add_submenu_page( $hook, __( 'About Us:', 'google-analytics-for-wordpress' ), __( 'About Us', 'google-analytics-for-wordpress' ), 'manage_options', $submenu_base . '#/about' );
145
}
146
add_action( 'network_admin_menu', 'monsterinsights_network_admin_menu', 5 );
147
148
/**
149
 * Adds one or more classes to the body tag in the dashboard.
150
 *
151
 * @param  String $classes Current body classes.
152
 * @return String          Altered body classes.
153
 */
154
function monsterinsights_add_admin_body_class( $classes ) {
155
    $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
0 ignored issues
show
Bug introduced by
Are you sure the usage of get_current_screen() is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
156
    if ( empty( $screen ) || empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
157
        return $classes;
158
    }
159
160
    return "$classes monsterinsights_page ";
161
}
162
add_filter( 'admin_body_class', 'monsterinsights_add_admin_body_class', 10, 1 );
163
164
/**
165
 * Adds one or more classes to the body tag in the dashboard.
166
 *
167
 * @param  String $classes Current body classes.
168
 * @return String          Altered body classes.
169
 */
170
function monsterinsights_add_admin_body_class_tools_page( $classes ) {
171
    $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
0 ignored issues
show
Bug introduced by
Are you sure the usage of get_current_screen() is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
172
173
    if ( empty( $screen ) || empty( $screen->id ) || strpos( $screen->id, 'monsterinsights_tools' ) === false || 'insights_page_monsterinsights_tools' === $screen->id  ) {
174
        return $classes;
175
    }
176
177
    return "$classes insights_page_monsterinsights_tools ";
178
}
179
add_filter( 'admin_body_class', 'monsterinsights_add_admin_body_class_tools_page', 10, 1 );
180
181
/**
182
 * Adds one or more classes to the body tag in the dashboard.
183
 *
184
 * @param  String $classes Current body classes.
185
 * @return String          Altered body classes.
186
 */
187
function monsterinsights_add_admin_body_class_addons_page( $classes ) {
188
    $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
0 ignored issues
show
Bug introduced by
Are you sure the usage of get_current_screen() is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
189
    if ( empty( $screen ) || empty( $screen->id ) || strpos( $screen->id, 'monsterinsights_addons' ) === false || 'insights_page_monsterinsights_addons' === $screen->id  ) {
190
        return $classes;
191
    }
192
193
    return "$classes insights_page_monsterinsights_addons ";
194
}
195
add_filter( 'admin_body_class', 'monsterinsights_add_admin_body_class_addons_page', 10, 1 );
196
197
/**
198
 * Add a link to the settings page to the plugins list
199
 *
200
 * @param array $links array of links for the plugins, adapted when the current plugin is found.
201
 *
202
 * @return array $links
203
 */
204
function monsterinsights_add_action_links( $links ) {
205
    $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>';
206
    array_unshift( $links, $docs );
207
208
    // If Lite, support goes to forum. If pro, it goes to our website
209
    if ( monsterinsights_is_pro_version() ) {
210
        $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>';
211
        array_unshift( $links, $support );
212
    } else {
213
        $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>';
214
        array_unshift( $links, $support );
215
    }
216
217
	if ( is_network_admin() ) {
218
		$settings_link = '<a href="' . esc_url( network_admin_url( 'admin.php?page=monsterinsights_network' ) ) . '">' . esc_html__( 'Network Settings', 'google-analytics-for-wordpress' ) . '</a>';
219
	} else {
220
		$settings_link = '<a href="' . esc_url( admin_url( 'admin.php?page=monsterinsights_settings' ) ) . '">' . esc_html__( 'Settings', 'google-analytics-for-wordpress' ) . '</a>';
221
	}
222
223
    array_unshift( $links, $settings_link );
224
225
	// If lite, show a link where they can get pro from
226
	if ( ! monsterinsights_is_pro_version() ) {
227
		$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/lite/" ) .'" style="font-weight:700; color: #1da867;">' . esc_html__( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ) . '</a>';
228
		array_unshift( $links, $get_pro );
229
	}
230
231
    return $links;
232
}
233
add_filter( 'plugin_action_links_' . plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ), 'monsterinsights_add_action_links' );
234
add_filter( 'network_admin_plugin_action_links_' . plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ), 'monsterinsights_add_action_links' );
235
236
/**
237
 * Loads a partial view for the Administration screen
238
 *
239
 * @access public
240
 * @since 6.0.0
241
 *
242
 * @param   string  $template   PHP file at includes/admin/partials, excluding file extension
243
 * @param   array   $data       Any data to pass to the view
244
 * @return  void
245
 */
246
function monsterinsights_load_admin_partial( $template, $data = array() ) {
0 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

246
function monsterinsights_load_admin_partial( $template, /** @scrutinizer ignore-unused */ $data = array() ) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
247
248
    if ( monsterinsights_is_pro_version() ) {
249
        $dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'pro/includes/admin/partials' );
250
251
        if ( file_exists( $dir . $template . '.php' ) ) {
252
            require_once(  $dir . $template . '.php' );
253
            return true;
254
        }
255
    } else {
256
        $dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'lite/includes/admin/partials' );
257
258
        if ( file_exists( $dir . $template . '.php' ) ) {
259
            require_once(  $dir . $template . '.php' );
260
            return true;
261
        }
262
    }
263
264
    $dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'includes/admin/partials' );
265
266
    if ( file_exists( $dir . $template . '.php' ) ) {
267
        require_once(  $dir . $template . '.php' );
268
        return true;
269
    }
270
271
    return false;
272
}
273
274
/**
275
 * When user is on a MonsterInsights related admin page, display footer text
276
 * that graciously asks them to rate us.
277
 *
278
 * @since 6.0.0
279
 * @param string $text
280
 * @return string
281
 */
282
function monsterinsights_admin_footer( $text ) {
283
    global $current_screen;
284
    if ( ! empty( $current_screen->id ) && strpos( $current_screen->id, 'monsterinsights' ) !== false ) {
285
        $url  = 'https://wordpress.org/support/view/plugin-reviews/google-analytics-for-wordpress?filter=5';
286
        // Translators: Placeholders add a link to the wordpress.org repository.
287
        $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>' );
288
    }
289
    return $text;
290
}
291
add_filter( 'admin_footer_text', 'monsterinsights_admin_footer', 1, 2 );
292
293
function monsterinsights_admin_setup_notices() {
294
295
    // Don't show on MonsterInsights pages
296
    $screen = get_current_screen();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $screen is correct as get_current_screen() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
297
    if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) !== false ) {
298
        return;
299
    }
300
301
    // Make sure they have the permissions to do something
302
    if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
303
        return;
304
    }
305
306
    // Priority:
307
    // 1. Google Analytics not authenticated
308
    // 2. License key not entered for pro
309
    // 3. License key not valid/okay for pro
310
    // 4. WordPress + PHP min versions
311
    // 5. (old) Optin setting not configured
312
    // 6. Manual UA code
313
    // 7. Automatic updates not configured
314
    // 8. Woo upsell
315
    // 9. EDD upsell
316
317
318
    // 1. Google Analytics not authenticated
319
	if ( ! is_network_admin() && ! monsterinsights_get_ua() && ! monsterinsights_get_v4_id() && ! defined( 'MONSTERINSIGHTS_DISABLE_TRACKING' ) ) {
320
321
        $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' ) );
322
        $title     = esc_html__( 'Please Setup Website Analytics to See Audience Insights', 'google-analytics-for-wordpress' );
323
        $primary   = esc_html__( 'Connect MonsterInsights and Setup Website Analytics', 'google-analytics-for-wordpress' );
324
        $urlone    = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights-onboarding' ) : admin_url( 'admin.php?page=monsterinsights-onboarding' );
325
        $secondary = esc_html__( 'Learn More', 'google-analytics-for-wordpress' );
326
        $urltwo    = $submenu_base . '#/about/getting-started';
327
        $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 3 million website owners use MonsterInsights to see the stats that matter and grow their business.', 'google-analytics-for-wordpress' );
328
        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>';
329
        return;
330
    }
331
332
    // 2. License key not entered for pro
333
    $key = monsterinsights_is_pro_version() ? MonsterInsights()->license->get_license_key() : '';
0 ignored issues
show
Bug Best Practice introduced by
The property $license is declared protected in MonsterInsights_Lite. Since you implement __get, consider adding a @property or @property-read.
Loading history...
334
    if ( monsterinsights_is_pro_version() && empty( $key ) ) {
335
        $page = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
336
        // Translators: Adds a link to retrieve the license.
337
        $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>' );
338
        echo '<div class="error"><p>'. $message.'</p></div>';
339
        return;
340
    }
341
342
    // 3. License key not valid/okay for pro
343
    if ( monsterinsights_is_pro_version() ) {
344
        $message = '';
345
        if ( MonsterInsights()->license->get_site_license_key() ){
346
            if ( MonsterInsights()->license->site_license_expired() ) {
347
	            // Translators: Adds a link to the license renewal.
348
                $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>' );
349
            } else if ( MonsterInsights()->license->site_license_disabled() ) {
350
                $message = esc_html__( 'Your license key for MonsterInsights has been disabled. Please use a different key.', 'google-analytics-for-wordpress' );
351
            } else if ( MonsterInsights()->license->site_license_invalid() ) {
352
                $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' );
353
            }
354
        } else if ( MonsterInsights()->license->get_network_license_key() ) {
355
            if ( MonsterInsights()->license->network_license_expired() ) {
356
            	// Translators: Adds a link to renew license.
357
                $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>' );
358
            } else if ( MonsterInsights()->license->network_license_disabled() ) {
359
                $message = esc_html__( 'Your network license key for MonsterInsights has been disabled. Please use a different key.', 'google-analytics-for-wordpress' );
360
            } else if ( MonsterInsights()->license->network_license_invalid() ) {
361
                $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' );
362
            }
363
        }
364
        if ( ! empty( $message ) ) {
365
            echo '<div class="error"><p>'. $message.'</p></div>';
366
            return;
367
        }
368
    }
369
370
    // 4. Notices for PHP/WP version deprecations
371
    if ( current_user_can( 'update_core' ) ) {
372
        global $wp_version;
373
374
	    $compatible_php_version = apply_filters( 'monsterinsights_compatible_php_version', false );
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type array expected by parameter $version of filter_compatible_php_version(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

374
	    $compatible_php_version = apply_filters( 'monsterinsights_compatible_php_version', /** @scrutinizer ignore-type */ false );
Loading history...
375
	    $compatible_wp_version  = apply_filters( 'monsterinsights_compatible_wp_version', false );
0 ignored issues
show
Unused Code introduced by
The assignment to $compatible_wp_version is dead and can be removed.
Loading history...
Bug introduced by
false of type false is incompatible with the type array expected by parameter $version of filter_compatible_wp_version(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

375
	    $compatible_wp_version  = apply_filters( 'monsterinsights_compatible_wp_version', /** @scrutinizer ignore-type */ false );
Loading history...
376
377
	    $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-php/' );
378
379
	    $message = false;
380
	    if ( version_compare( phpversion(), $compatible_php_version['required'], '<' ) ) {
381
		    // Translators: Placeholders add the PHP version, a link to the MonsterInsights blog and a line break.
382
		    $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 stopped 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>' );
383
	    } else if ( version_compare( phpversion(), $compatible_php_version['warning'], '<' ) ) {
384
		    // Translators: Placeholders add the PHP version, a link to the MonsterInsights blog and a line break.
385
		    $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 stopped supporting your PHP version in November, 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>' );
386
	    } else if ( version_compare( phpversion(), $compatible_php_version['recommended'], '<' ) ) {
387
		    // Translators: Placeholders add the PHP version, a link to the MonsterInsights blog and a line break.
388
		    $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 is working towards discontinuing support for your PHP version.%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>' );
389
	    }
390
391
	    if ( $message ) {
392
		    echo '<div class="error"><p>'. $message.'</p></div>';
393
		    return;
394
	    }
395
396
        // WordPress 4.9
397
        /* else if ( version_compare( $wp_version, '5.0', '<' ) ) {
398
            $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-wordpress/' );
399
            // Translators: Placeholders add the current WordPress version and links to the MonsterInsights blog
400
            $message = sprintf( esc_html__( 'Your site is running an outdated version of WordPress (%1$s).%4$sMonsterInsights will stop supporting WordPress versions lower than 5.0 in 2021.%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>' );
401
            echo '<div class="error"><p>'. $message.'</p></div>';
402
            return;
403
        } */
404
        // PHP 5.4/5.5
405
        // else if ( version_compare( phpversion(), '5.6', '<' ) ) {
406
        //  $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-php/' );
407
        //  $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>' );
408
        //  echo '<div class="error"><p>'. $message.'</p></div>';
409
        //  return;
410
        // }
411
        // // WordPress 4.6 - 4.8
412
        // else if ( version_compare( $wp_version, '4.9', '<' ) ) {
413
        //  $url = monsterinsights_get_url( 'global-notice', 'settings-page', 'https://www.monsterinsights.com/docs/update-wordpress/' );
414
        //  $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>' );
415
        //  echo '<div class="error"><p>'. $message.'</p></div>';
416
        //  return;
417
        // }
418
    }
419
420
    // 5. Optin setting not configured
421
    // if ( ! is_network_admin() ) {
422
    //     if ( ! get_option( 'monsterinsights_tracking_notice' ) ) {
423
    //         if ( ! monsterinsights_get_option( 'anonymous_data', false ) ) {
424
    //             if ( ! monsterinsights_is_dev_url( network_site_url( '/' ) ) ) {
425
    //                 if ( monsterinsights_is_pro_version() ) {
426
    //                     monsterinsights_update_option( 'anonymous_data', 1 );
427
    //                     return;
428
    //                 }
429
    //                 $optin_url  = add_query_arg( 'mi_action', 'opt_into_tracking' );
430
    //                 $optout_url = add_query_arg( 'mi_action', 'opt_out_of_tracking' );
431
    //                 echo '<div class="updated"><p>';
432
    //                 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' );
433
    //                 echo '&nbsp;<a href="' . esc_url( $optin_url ) . '" class="button-secondary">' . __( 'Allow', 'google-analytics-for-wordpress' ) . '</a>';
434
    //                 echo '&nbsp;<a href="' . esc_url( $optout_url ) . '" class="button-secondary">' . __( 'Do not allow', 'google-analytics-for-wordpress' ) . '</a>';
435
    //                 echo '</p></div>';
436
    //                 return;
437
    //             } else {
438
    //                 // is testing site
439
    //                  update_option( 'monsterinsights_tracking_notice', '1' );
440
    //             }
441
    //         }
442
    //     }
443
    // }
444
445
    $notices   = get_option( 'monsterinsights_notices' );
446
    if ( ! is_array( $notices ) ) {
447
        $notices = array();
448
    }
449
450
    // 6. Authenticate, not manual
451
	$authed      = MonsterInsights()->auth->is_authed() || MonsterInsights()->auth->is_network_authed();
0 ignored issues
show
Bug Best Practice introduced by
The property $auth is declared protected in MonsterInsights_Lite. Since you implement __get, consider adding a @property or @property-read.
Loading history...
452
	$url         = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
453
	$ua_code     = monsterinsights_get_ua_to_output();
454
	// Translators: Placeholders add links to the settings panel.
455
	$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>' );
456
	$migrated    = monsterinsights_get_option( 'gadwp_migrated', 0 );
457
	if ( $migrated > 0 ) {
458
		$url         = admin_url( 'admin.php?page=monsterinsights-getting-started&monsterinsights-migration=1' );
459
		// Translators: Placeholders add links to the settings panel.
460
		$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' );
461
		$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>' );
462
	}
463
464
	if ( empty( $authed ) && ! isset( $notices['monsterinsights_auth_not_manual'] ) && ! empty( $ua_code ) ) {
465
		echo '<div class="notice notice-info is-dismissible monsterinsights-notice" data-notice="monsterinsights_auth_not_manual">';
466
		echo '<p>';
467
		echo $manual_text;
468
		echo '</p>';
469
		echo '</div>';
470
471
		return;
472
	}
473
474
    // 7. Automatic updates not configured
475
    // if ( ! is_network_admin() ) {
476
    //     $updates   = monsterinsights_get_option( 'automatic_updates', false );
477
    //     $url       = admin_url( 'admin.php?page=monsterinsights_settings' );
478
479
    //     if ( empty( $updates) && ! isset( $notices['monsterinsights_automatic_updates' ] ) ) {
480
    //         echo '<div class="notice notice-info is-dismissible monsterinsights-notice" data-notice="monsterinsights_automatic_updates">';
481
    //             echo '<p>';
482
    //             echo sprintf( esc_html__( 'Important: Please %1$sconfigure the Automatic Updates Settings%2$s in MonsterInsights.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' );
483
    //             echo '</p>';
484
    //         echo '</div>';
485
    //         return;
486
    //     }
487
    // }
488
489
    // 8. WooUpsell
490
    if ( ! monsterinsights_is_pro_version() && class_exists( 'WooCommerce' ) ) {
491
        if ( ! isset( $notices['monsterinsights_woocommerce_tracking_available' ] ) ) {
492
            echo '<div class="notice notice-success is-dismissible monsterinsights-notice monsterinsights-wooedd-upsell-row" data-notice="monsterinsights_woocommerce_tracking_available">';
493
                echo '<div class="monsterinsights-wooedd-upsell-left">';
494
                    echo '<p><strong>';
495
                    echo esc_html( 'Enhanced Ecommerce Analytics for Your WooCommerce Store', 'google-analytics-for-wordpress' );
0 ignored issues
show
Unused Code introduced by
The call to esc_html() has too many arguments starting with 'google-analytics-for-wordpress'. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

495
                    echo /** @scrutinizer ignore-call */ esc_html( 'Enhanced Ecommerce Analytics for Your WooCommerce Store', 'google-analytics-for-wordpress' );

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
496
                    echo '</strong></p>';
497
                    echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-small" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
498
                    echo '<p>';
499
                    echo esc_html( 'MonsterInsights Pro gives you detailed stats and insights about your customers.', 'google-analytics-for-wordpress' );
500
                    echo '</p>';
501
                    echo '<p>';
502
                    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' );
503
                    echo '</p>';
504
                    echo '<p>';
505
                    echo esc_html( 'Pro customers also get Form Tracking, Custom Dimensions Tracking, UserID Tracking and much more.', 'google-analytics-for-wordpress' );
506
                    echo '</p>';
507
                    echo '<p>';
508
                    echo esc_html( 'Start making data-driven decisions to grow your business.', 'google-analytics-for-wordpress' );
509
                    echo '</p>';
510
                    // Translators: Placeholders add a link to the MonsterInsights website.
511
                    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>' );
512
                    echo '</p>';
513
                echo '</div><div class="monsterinsights-wooedd-upsell-right">';
514
                    echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-large" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
515
                echo '</div>';
516
            echo '</div>';
517
            echo '<style type="text/css">.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}}</style>';
518
            return;
519
        }
520
    }
521
522
    // 9. EDDUpsell
523
    if ( ! monsterinsights_is_pro_version() && class_exists( 'Easy_Digital_Downloads' ) ) {
524
        if ( ! isset( $notices['monsterinsights_edd_tracking_available' ] ) ) {
525
            echo '<div class="notice notice-success is-dismissible monsterinsights-notice monsterinsights-wooedd-upsell-row" data-notice="monsterinsights_edd_tracking_available">';
526
                echo '<div class="monsterinsights-wooedd-upsell-left">';
527
                    echo '<p><strong>';
528
                    echo esc_html( 'Enhanced Ecommerce Analytics for Your Easy Digital Downloads Store', 'google-analytics-for-wordpress' );
529
                    echo '</strong></p>';
530
                    echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-small" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
531
                    echo '<p>';
532
                    echo esc_html( 'MonsterInsights Pro gives you detailed stats and insights about your customers.', 'google-analytics-for-wordpress' );
533
                    echo '</p>';
534
                    echo '<p>';
535
                    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' );
536
                    echo '</p>';
537
                    echo '<p>';
538
                    echo esc_html( 'Pro customers also get Form Tracking, Custom Dimensions Tracking, UserID Tracking and much more.', 'google-analytics-for-wordpress' );
539
                    echo '</p>';
540
                    echo '<p>';
541
                    echo esc_html( 'Start making data-driven decisions to grow your business.', 'google-analytics-for-wordpress' );
542
                    echo '</p>';
543
                    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>' );
544
                    echo '</p>';
545
                echo '</div><div class="monsterinsights-wooedd-upsell-right">';
546
                    echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-large" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
547
                echo '</div>';
548
            echo '</div>';
549
            return;
550
        }
551
    }
552
553
    if ( isset( $notices['monsterinsights_cross_domains_extracted'] ) && false === $notices['monsterinsights_cross_domains_extracted'] ) {
554
        $page = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
555
        $page = $page . '#/advanced';
556
        // Translators: Adds a link to the settings panel.
557
        $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>' );
558
        echo '<div class="notice notice-success is-dismissible monsterinsights-notice" data-notice="monsterinsights_cross_domains_extracted"><p>'. $message.'</p></div>';
559
        return;
560
    }
561
}
562
add_action( 'admin_notices', 'monsterinsights_admin_setup_notices' );
563
add_action( 'network_admin_notices', 'monsterinsights_admin_setup_notices' );
564
565
566
// AM Notices
567
function monsterinsights_am_notice_optout( $super_admin ) {
568
    if ( monsterinsights_get_option( 'hide_am_notices', false ) || monsterinsights_get_option( 'network_hide_am_notices', false ) ) {
569
        return false;
570
    }
571
    return $super_admin;
572
}
573
add_filter( "am_notifications_display", 'monsterinsights_am_notice_optout', 10, 1 );
574
575
/**
576
 * Inline critical css for the menu to prevent breaking the layout when our scripts get blocked by browsers.
577
 */
578
function monsterinsights_admin_menu_inline_styles() {
579
	?>
580
	<style type="text/css">
581
		#toplevel_page_monsterinsights_reports .wp-menu-image img,
582
		#toplevel_page_monsterinsights_settings .wp-menu-image img,
583
		#toplevel_page_monsterinsights_network .wp-menu-image img {
584
			width: 18px;
585
			height: auto;
586
			padding-top: 7px;
587
		}
588
	</style>
589
	<?php
590
}
591
592
add_action( 'admin_head', 'monsterinsights_admin_menu_inline_styles', 300 );
593
594
/**
595
 * Display notice in admin when measurement protocol is left blank
596
 */
597
function monsterinsights_empty_measurement_protocol_token() {
598
	if ( ! class_exists( 'MonsterInsights_eCommerce' ) && ! class_exists( 'MonsterInsights_Forms' ) ) {
599
		return;
600
	}
601
602
	$page = is_network_admin()
603
		? network_admin_url( 'admin.php?page=monsterinsights_network' )
604
		: admin_url( 'admin.php?page=monsterinsights_settings' );
605
606
	$api_secret = is_network_admin()
607
		? MonsterInsights()->auth->get_network_measurement_protocol_secret()
0 ignored issues
show
Bug Best Practice introduced by
The property $auth is declared protected in MonsterInsights_Lite. Since you implement __get, consider adding a @property or @property-read.
Loading history...
608
		: MonsterInsights()->auth->get_measurement_protocol_secret();
609
610
	$current_code = monsterinsights_get_v4_id_to_output();
611
612
	if ( empty( $current_code ) || ! empty( $api_secret ) ) {
613
		return;
614
	}
615
616
	$message = sprintf(
617
		esc_html__(
618
			'Your Measurement Protocol API Secret is currently left blank, so you won\'t be able to use some of the tracking features with your GA4 property. %1$sPlease enter your Measurement Protocol API Secret here.%2$s',
619
			'google-analytics-for-wordpress'
620
		),
621
		'<a href="' . esc_url( $page ). '">',
622
		'</a>'
623
	);
624
	echo '<div class="error"><p>'. $message.'</p></div>';
625
}
626
627
add_action( 'admin_notices', 'monsterinsights_empty_measurement_protocol_token' );
628
add_action( 'network_admin_notices', 'monsterinsights_admin_setup_notices' );
629