Passed
Push — master ( ad1bda...a722cd )
by Chris
02:54
created

MonsterInsights_Welcome   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A maybe_redirect() 0 20 5
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * Class MonsterInsights_Welcome
5
 */
6
class MonsterInsights_Welcome {
7
8
	/**
9
	 * MonsterInsights_Welcome constructor.
10
	 */
11
	public function __construct() {
12
13
		add_action( 'admin_init', array( $this, 'maybe_redirect' ), 9999 );
14
15
	}
16
17
	/**
18
	 * Check if we should do any redirect.
19
	 */
20
	public function maybe_redirect() {
21
22
		// Bail if no activation redirect.
23
		if ( ! get_transient( '_monsterinsights_activation_redirect' ) ) {
24
			return;
25
		}
26
27
		// Delete the redirect transient.
28
		delete_transient( '_monsterinsights_activation_redirect' );
29
30
		// Bail if activating from network, or bulk.
31
		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { // WPCS: CSRF ok, input var ok.
32
			return;
33
		}
34
35
		$upgrade = get_option( 'monsterinsights_version_upgraded_from', false );
36
		if ( apply_filters( 'monsterinsights_enable_onboarding_wizard', false === $upgrade ) ) {
37
			$redirect = admin_url( 'index.php?page=monsterinsights-onboarding' );
38
			wp_safe_redirect( $redirect );
39
			exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
40
		}
41
	}
42
}
43
44
new MonsterInsights_Welcome();
45