Completed
Pull Request — develop (#1249)
by Naveen
02:52
created
src/wordlift/admin/class-key-validation-notice.php 2 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -10,78 +10,78 @@
 block discarded – undo
10 10
  */
11 11
 class Key_Validation_Notice {
12 12
 
13
-	const CACHE_KEY = 'is_key_valid';
13
+    const CACHE_KEY = 'is_key_valid';
14 14
 
15
-	/**
16
-	 * @var \Wordlift_Key_Validation_Service
17
-	 */
18
-	private $key_validation_service;
15
+    /**
16
+     * @var \Wordlift_Key_Validation_Service
17
+     */
18
+    private $key_validation_service;
19 19
 
20
-	/**
21
-	 * @var \Wordlift_Configuration_Service
22
-	 */
23
-	private $configuration_service;
24
-	/**
25
-	 * @var Ttl_Cache
26
-	 */
27
-	private $ttl_cache_service;
20
+    /**
21
+     * @var \Wordlift_Configuration_Service
22
+     */
23
+    private $configuration_service;
24
+    /**
25
+     * @var Ttl_Cache
26
+     */
27
+    private $ttl_cache_service;
28 28
 
29
-	/**
30
-	 * Key_Validation_Notice constructor.
31
-	 *
32
-	 * @param \Wordlift_Key_Validation_Service $key_validation_service
33
-	 * @param \Wordlift_Configuration_Service $configuration_service
34
-	 */
35
-	public function __construct( $key_validation_service, $configuration_service ) {
29
+    /**
30
+     * Key_Validation_Notice constructor.
31
+     *
32
+     * @param \Wordlift_Key_Validation_Service $key_validation_service
33
+     * @param \Wordlift_Configuration_Service $configuration_service
34
+     */
35
+    public function __construct( $key_validation_service, $configuration_service ) {
36 36
 
37
-		$this->key_validation_service = $key_validation_service;
37
+        $this->key_validation_service = $key_validation_service;
38 38
 
39
-		$this->configuration_service = $configuration_service;
39
+        $this->configuration_service = $configuration_service;
40 40
 
41
-		$this->ttl_cache_service = new Ttl_Cache( 'key-validation-notification', 60 * 60 * 8 );
41
+        $this->ttl_cache_service = new Ttl_Cache( 'key-validation-notification', 60 * 60 * 8 );
42 42
 
43
-		add_action( 'admin_notices', function () {
43
+        add_action( 'admin_notices', function () {
44 44
 
45
-			$key = $this->configuration_service->get_key();
45
+            $key = $this->configuration_service->get_key();
46 46
 
47
-			if ( ! $key ) {
48
-				// Dont show warning or make API call, return early.
49
-				return;
50
-			}
47
+            if ( ! $key ) {
48
+                // Dont show warning or make API call, return early.
49
+                return;
50
+            }
51 51
 
52
-			if ( $this->is_key_valid() ) {
53
-				return;
54
-			}
52
+            if ( $this->is_key_valid() ) {
53
+                return;
54
+            }
55 55
 
56
-			echo $this->get_notification_template();
56
+            echo $this->get_notification_template();
57 57
 
58
-		} );
58
+        } );
59 59
 
60
-	}
60
+    }
61 61
 
62 62
 
63
-	public function get_notification_template() {
64
-		return <<<EOF
63
+    public function get_notification_template() {
64
+        return <<<EOF
65 65
 <p></p>
66 66
 EOF;
67 67
 
68
-	}
68
+    }
69 69
 
70
-	private function is_key_valid() {
70
+    private function is_key_valid() {
71 71
 
72
-		$key = $this->configuration_service->get_key();
72
+        $key = $this->configuration_service->get_key();
73 73
 
74
-		// Check cache if the result is present, if not get the results
75
-		// save it and return the data.
76
-		if ( $this->ttl_cache_service->get( self::CACHE_KEY ) !== null ) {
77
-			return $this->ttl_cache_service->get( self::CACHE_KEY );
78
-		}
74
+        // Check cache if the result is present, if not get the results
75
+        // save it and return the data.
76
+        if ( $this->ttl_cache_service->get( self::CACHE_KEY ) !== null ) {
77
+            return $this->ttl_cache_service->get( self::CACHE_KEY );
78
+        }
79 79
 
80
-		$is_valid = $this->key_validation_service->is_key_valid( $key );
81
-		$this->ttl_cache_service->put( self::CACHE_KEY, $is_valid );
80
+        $is_valid = $this->key_validation_service->is_key_valid( $key );
81
+        $this->ttl_cache_service->put( self::CACHE_KEY, $is_valid );
82 82
 
83
-		return $is_valid;
84
-	}
83
+        return $is_valid;
84
+    }
85 85
 
86 86
 }
87 87
 
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -32,24 +32,24 @@  discard block
 block discarded – undo
32 32
 	 * @param \Wordlift_Key_Validation_Service $key_validation_service
33 33
 	 * @param \Wordlift_Configuration_Service $configuration_service
34 34
 	 */
35
-	public function __construct( $key_validation_service, $configuration_service ) {
35
+	public function __construct($key_validation_service, $configuration_service) {
36 36
 
37 37
 		$this->key_validation_service = $key_validation_service;
38 38
 
39 39
 		$this->configuration_service = $configuration_service;
40 40
 
41
-		$this->ttl_cache_service = new Ttl_Cache( 'key-validation-notification', 60 * 60 * 8 );
41
+		$this->ttl_cache_service = new Ttl_Cache('key-validation-notification', 60 * 60 * 8);
42 42
 
43
-		add_action( 'admin_notices', function () {
43
+		add_action('admin_notices', function() {
44 44
 
45 45
 			$key = $this->configuration_service->get_key();
46 46
 
47
-			if ( ! $key ) {
47
+			if ( ! $key) {
48 48
 				// Dont show warning or make API call, return early.
49 49
 				return;
50 50
 			}
51 51
 
52
-			if ( $this->is_key_valid() ) {
52
+			if ($this->is_key_valid()) {
53 53
 				return;
54 54
 			}
55 55
 
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 
74 74
 		// Check cache if the result is present, if not get the results
75 75
 		// save it and return the data.
76
-		if ( $this->ttl_cache_service->get( self::CACHE_KEY ) !== null ) {
77
-			return $this->ttl_cache_service->get( self::CACHE_KEY );
76
+		if ($this->ttl_cache_service->get(self::CACHE_KEY) !== null) {
77
+			return $this->ttl_cache_service->get(self::CACHE_KEY);
78 78
 		}
79 79
 
80
-		$is_valid = $this->key_validation_service->is_key_valid( $key );
81
-		$this->ttl_cache_service->put( self::CACHE_KEY, $is_valid );
80
+		$is_valid = $this->key_validation_service->is_key_valid($key);
81
+		$this->ttl_cache_service->put(self::CACHE_KEY, $is_valid);
82 82
 
83 83
 		return $is_valid;
84 84
 	}
Please login to merge, or discard this patch.
src/includes/class-wordlift-key-validation-service.php 2 patches
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -19,171 +19,171 @@
 block discarded – undo
19 19
  */
20 20
 class Wordlift_Key_Validation_Service {
21 21
 
22
-	/**
23
-	 * A {@link Wordlift_Log_Service} instance.
24
-	 *
25
-	 * @since  3.14.0
26
-	 * @access private
27
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
28
-	 */
29
-	private $log;
30
-
31
-	/**
32
-	 * The {@link Wordlift_Configuration_Service} instance.
33
-	 *
34
-	 * @since  3.14.0
35
-	 * @access private
36
-	 * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
37
-	 */
38
-	private $configuration_service;
39
-
40
-	/**
41
-	 * Create a {@link Wordlift_Key_Validation_Service} instance.
42
-	 *
43
-	 * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
44
-	 *
45
-	 * @since 3.14.0
46
-	 */
47
-	public function __construct( $configuration_service ) {
48
-
49
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Key_Validation_Service' );
50
-
51
-		$this->configuration_service = $configuration_service;
52
-
53
-		add_action( 'admin_init', array( $this, 'wl_load_plugin' ) );
54
-		/**
55
-		 * Filter: wl_feature__enable__notices.
56
-		 *
57
-		 * @param bool whether the notices needs to be enabled or not.
58
-		 *
59
-		 * @return bool
60
-		 * @since 3.27.6
61
-		 */
62
-		if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
63
-			add_action( 'admin_notices', array( $this, 'wl_key_update_notice' ) );
64
-		}
65
-
66
-	}
67
-
68
-	/**
69
-	 * Validate the provided key.
70
-	 *
71
-	 * @param string $key WordLift's key to validate.
72
-	 *
73
-	 * @return WP_Error|array The response or WP_Error on failure.
74
-	 * @since 3.9.0
75
-	 *
76
-	 */
77
-	public function get_account_info( $key ) {
78
-
79
-		$this->log->debug( 'Validating key...' );
80
-
81
-		return Default_Api_Service::get_instance()->get( '/accounts/info', array(
82
-			'Authorization' => "Key $key",
22
+    /**
23
+     * A {@link Wordlift_Log_Service} instance.
24
+     *
25
+     * @since  3.14.0
26
+     * @access private
27
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
28
+     */
29
+    private $log;
30
+
31
+    /**
32
+     * The {@link Wordlift_Configuration_Service} instance.
33
+     *
34
+     * @since  3.14.0
35
+     * @access private
36
+     * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
37
+     */
38
+    private $configuration_service;
39
+
40
+    /**
41
+     * Create a {@link Wordlift_Key_Validation_Service} instance.
42
+     *
43
+     * @param \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance.
44
+     *
45
+     * @since 3.14.0
46
+     */
47
+    public function __construct( $configuration_service ) {
48
+
49
+        $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Key_Validation_Service' );
50
+
51
+        $this->configuration_service = $configuration_service;
52
+
53
+        add_action( 'admin_init', array( $this, 'wl_load_plugin' ) );
54
+        /**
55
+         * Filter: wl_feature__enable__notices.
56
+         *
57
+         * @param bool whether the notices needs to be enabled or not.
58
+         *
59
+         * @return bool
60
+         * @since 3.27.6
61
+         */
62
+        if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
63
+            add_action( 'admin_notices', array( $this, 'wl_key_update_notice' ) );
64
+        }
65
+
66
+    }
67
+
68
+    /**
69
+     * Validate the provided key.
70
+     *
71
+     * @param string $key WordLift's key to validate.
72
+     *
73
+     * @return WP_Error|array The response or WP_Error on failure.
74
+     * @since 3.9.0
75
+     *
76
+     */
77
+    public function get_account_info( $key ) {
78
+
79
+        $this->log->debug( 'Validating key...' );
80
+
81
+        return Default_Api_Service::get_instance()->get( '/accounts/info', array(
82
+            'Authorization' => "Key $key",
83 83
         ) )->get_response();
84
-	}
84
+    }
85 85
 
86
-	/**
86
+    /**
87 87
      * Check if key is valid
88
-	 * @param $key string
89
-	 *
90
-	 * @return bool
91
-	 */
92
-	public function is_key_valid( $key ) {
88
+     * @param $key string
89
+     *
90
+     * @return bool
91
+     */
92
+    public function is_key_valid( $key ) {
93 93
 
94
-		$response = $this->get_account_info( $key );
94
+        $response = $this->get_account_info( $key );
95 95
 
96
-		if ( is_wp_error( $response ) || 2 !== (int) $response['response']['code'] / 100 ) {
97
-			return false;
98
-		}
99
-		$res_body = json_decode( wp_remote_retrieve_body( $response ), true );
96
+        if ( is_wp_error( $response ) || 2 !== (int) $response['response']['code'] / 100 ) {
97
+            return false;
98
+        }
99
+        $res_body = json_decode( wp_remote_retrieve_body( $response ), true );
100 100
 
101
-		$url = $res_body['url'];
101
+        $url = $res_body['url'];
102 102
 
103
-		if ( is_null( $url ) || $url === get_option( 'home' ) ) {
104
-			return true;
105
-		}
103
+        if ( is_null( $url ) || $url === get_option( 'home' ) ) {
104
+            return true;
105
+        }
106 106
         return false;
107
-	}
108
-
109
-	/**
110
-	 * This function is hooked to the `wl_validate_key` AJAX call.
111
-	 *
112
-	 * @since 3.9.0
113
-	 */
114
-	public function validate_key() {
115
-
116
-		// Ensure we don't have garbage before us.
117
-		ob_clean();
118
-
119
-		// Check if we have a key.
120
-		if ( ! isset( $_POST['key'] ) ) {
121
-			wp_send_json_error( 'The key parameter is required.' );
122
-		}
123
-
124
-		$response = $this->get_account_info( $_POST['key'] );
125
-
126
-		// If we got an error, return invalid.
127
-		if ( is_wp_error( $response ) || 2 !== (int) $response['response']['code'] / 100 ) {
128
-			wp_send_json_success( array( 'valid' => false, 'message' => '' ) );
129
-		}
130
-
131
-		$res_body = json_decode( wp_remote_retrieve_body( $response ), true );
132
-
133
-		// The URL stored in WLS. If this is the initial install the URL may be null.
134
-		$url = $res_body['url'];
135
-
136
-		// If the URL isn't set or matches, then it's valid.
137
-		if ( is_null( $url ) || $url === get_option( 'home' ) ) {
138
-			wp_send_json_success( array( 'valid' => true, 'message' => '' ) );
139
-		}
140
-
141
-		// If the URL doesn't match it means that this key has been configured elsewhere already.
142
-		if ( $url !== get_option( 'home' ) ) {
143
-			Wordlift_Configuration_Service::get_instance()->set_key( '' );
144
-			wp_send_json_success( array(
145
-				'valid'   => false,
146
-				'message' => __( 'The key is already used on another site, please contact us at [email protected] to move the key to another site.', 'wordlift' ),
147
-			) );
148
-		}
149
-
150
-		// Set a response with valid set to true or false according to the key validity with message.
151
-		wp_send_json_success( array(
152
-			'valid'   => false,
153
-			'message' => __( 'An error occurred, please contact us at [email protected]', 'wordlift' ),
154
-		) );
155
-	}
156
-
157
-	/**
158
-	 * This function is hooked `admin_init` to check _wl_blog_url.
159
-	 *
160
-	 */
161
-	public function wl_load_plugin() {
162
-
163
-		$wl_blog_url = get_option( '_wl_blog_url' );
164
-		$home_url    = defined( 'WP_HOME' ) ? WP_HOME : get_option( 'home' );
165
-
166
-		if ( ! $wl_blog_url ) {
167
-			update_option( '_wl_blog_url', $home_url, true );
168
-		} else if ( $wl_blog_url !== $home_url ) {
169
-			update_option( '_wl_blog_url', $home_url, true );
170
-			Wordlift_Configuration_Service::get_instance()->set_key( '' );
171
-			set_transient( 'wl-key-error-msg', __( "Your web site URL has changed. To avoid data corruption, WordLift's key has been removed. Please provide a new key in WordLift Settings. If you believe this to be an error, please contact us at [email protected]", 'wordlift' ), 10 );
172
-		}
173
-
174
-	}
175
-
176
-	/**
177
-	 * This function is hooked to the `admin_notices` to show admin notification.
178
-	 *
179
-	 */
180
-	public function wl_key_update_notice() {
181
-		if ( get_transient( 'wl-key-error-msg' ) ) {
182
-			?>
107
+    }
108
+
109
+    /**
110
+     * This function is hooked to the `wl_validate_key` AJAX call.
111
+     *
112
+     * @since 3.9.0
113
+     */
114
+    public function validate_key() {
115
+
116
+        // Ensure we don't have garbage before us.
117
+        ob_clean();
118
+
119
+        // Check if we have a key.
120
+        if ( ! isset( $_POST['key'] ) ) {
121
+            wp_send_json_error( 'The key parameter is required.' );
122
+        }
123
+
124
+        $response = $this->get_account_info( $_POST['key'] );
125
+
126
+        // If we got an error, return invalid.
127
+        if ( is_wp_error( $response ) || 2 !== (int) $response['response']['code'] / 100 ) {
128
+            wp_send_json_success( array( 'valid' => false, 'message' => '' ) );
129
+        }
130
+
131
+        $res_body = json_decode( wp_remote_retrieve_body( $response ), true );
132
+
133
+        // The URL stored in WLS. If this is the initial install the URL may be null.
134
+        $url = $res_body['url'];
135
+
136
+        // If the URL isn't set or matches, then it's valid.
137
+        if ( is_null( $url ) || $url === get_option( 'home' ) ) {
138
+            wp_send_json_success( array( 'valid' => true, 'message' => '' ) );
139
+        }
140
+
141
+        // If the URL doesn't match it means that this key has been configured elsewhere already.
142
+        if ( $url !== get_option( 'home' ) ) {
143
+            Wordlift_Configuration_Service::get_instance()->set_key( '' );
144
+            wp_send_json_success( array(
145
+                'valid'   => false,
146
+                'message' => __( 'The key is already used on another site, please contact us at [email protected] to move the key to another site.', 'wordlift' ),
147
+            ) );
148
+        }
149
+
150
+        // Set a response with valid set to true or false according to the key validity with message.
151
+        wp_send_json_success( array(
152
+            'valid'   => false,
153
+            'message' => __( 'An error occurred, please contact us at [email protected]', 'wordlift' ),
154
+        ) );
155
+    }
156
+
157
+    /**
158
+     * This function is hooked `admin_init` to check _wl_blog_url.
159
+     *
160
+     */
161
+    public function wl_load_plugin() {
162
+
163
+        $wl_blog_url = get_option( '_wl_blog_url' );
164
+        $home_url    = defined( 'WP_HOME' ) ? WP_HOME : get_option( 'home' );
165
+
166
+        if ( ! $wl_blog_url ) {
167
+            update_option( '_wl_blog_url', $home_url, true );
168
+        } else if ( $wl_blog_url !== $home_url ) {
169
+            update_option( '_wl_blog_url', $home_url, true );
170
+            Wordlift_Configuration_Service::get_instance()->set_key( '' );
171
+            set_transient( 'wl-key-error-msg', __( "Your web site URL has changed. To avoid data corruption, WordLift's key has been removed. Please provide a new key in WordLift Settings. If you believe this to be an error, please contact us at [email protected]", 'wordlift' ), 10 );
172
+        }
173
+
174
+    }
175
+
176
+    /**
177
+     * This function is hooked to the `admin_notices` to show admin notification.
178
+     *
179
+     */
180
+    public function wl_key_update_notice() {
181
+        if ( get_transient( 'wl-key-error-msg' ) ) {
182
+            ?>
183 183
             <div class="updated notice is-dismissible error">
184 184
                 <p><?php _e( get_transient( 'wl-key-error-msg' ), 'wordlift' ); ?></p>
185 185
             </div>
186 186
 			<?php
187
-		}
188
-	}
187
+        }
188
+    }
189 189
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	 *
45 45
 	 * @since 3.14.0
46 46
 	 */
47
-	public function __construct( $configuration_service ) {
47
+	public function __construct($configuration_service) {
48 48
 
49
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Key_Validation_Service' );
49
+		$this->log = Wordlift_Log_Service::get_logger('Wordlift_Key_Validation_Service');
50 50
 
51 51
 		$this->configuration_service = $configuration_service;
52 52
 
53
-		add_action( 'admin_init', array( $this, 'wl_load_plugin' ) );
53
+		add_action('admin_init', array($this, 'wl_load_plugin'));
54 54
 		/**
55 55
 		 * Filter: wl_feature__enable__notices.
56 56
 		 *
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 		 * @return bool
60 60
 		 * @since 3.27.6
61 61
 		 */
62
-		if ( apply_filters( 'wl_feature__enable__notices', true ) ) {
63
-			add_action( 'admin_notices', array( $this, 'wl_key_update_notice' ) );
62
+		if (apply_filters('wl_feature__enable__notices', true)) {
63
+			add_action('admin_notices', array($this, 'wl_key_update_notice'));
64 64
 		}
65 65
 
66 66
 	}
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
 	 * @since 3.9.0
75 75
 	 *
76 76
 	 */
77
-	public function get_account_info( $key ) {
77
+	public function get_account_info($key) {
78 78
 
79
-		$this->log->debug( 'Validating key...' );
79
+		$this->log->debug('Validating key...');
80 80
 
81
-		return Default_Api_Service::get_instance()->get( '/accounts/info', array(
81
+		return Default_Api_Service::get_instance()->get('/accounts/info', array(
82 82
 			'Authorization' => "Key $key",
83
-        ) )->get_response();
83
+        ))->get_response();
84 84
 	}
85 85
 
86 86
 	/**
@@ -89,18 +89,18 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @return bool
91 91
 	 */
92
-	public function is_key_valid( $key ) {
92
+	public function is_key_valid($key) {
93 93
 
94
-		$response = $this->get_account_info( $key );
94
+		$response = $this->get_account_info($key);
95 95
 
96
-		if ( is_wp_error( $response ) || 2 !== (int) $response['response']['code'] / 100 ) {
96
+		if (is_wp_error($response) || 2 !== (int) $response['response']['code'] / 100) {
97 97
 			return false;
98 98
 		}
99
-		$res_body = json_decode( wp_remote_retrieve_body( $response ), true );
99
+		$res_body = json_decode(wp_remote_retrieve_body($response), true);
100 100
 
101 101
 		$url = $res_body['url'];
102 102
 
103
-		if ( is_null( $url ) || $url === get_option( 'home' ) ) {
103
+		if (is_null($url) || $url === get_option('home')) {
104 104
 			return true;
105 105
 		}
106 106
         return false;
@@ -117,41 +117,41 @@  discard block
 block discarded – undo
117 117
 		ob_clean();
118 118
 
119 119
 		// Check if we have a key.
120
-		if ( ! isset( $_POST['key'] ) ) {
121
-			wp_send_json_error( 'The key parameter is required.' );
120
+		if ( ! isset($_POST['key'])) {
121
+			wp_send_json_error('The key parameter is required.');
122 122
 		}
123 123
 
124
-		$response = $this->get_account_info( $_POST['key'] );
124
+		$response = $this->get_account_info($_POST['key']);
125 125
 
126 126
 		// If we got an error, return invalid.
127
-		if ( is_wp_error( $response ) || 2 !== (int) $response['response']['code'] / 100 ) {
128
-			wp_send_json_success( array( 'valid' => false, 'message' => '' ) );
127
+		if (is_wp_error($response) || 2 !== (int) $response['response']['code'] / 100) {
128
+			wp_send_json_success(array('valid' => false, 'message' => ''));
129 129
 		}
130 130
 
131
-		$res_body = json_decode( wp_remote_retrieve_body( $response ), true );
131
+		$res_body = json_decode(wp_remote_retrieve_body($response), true);
132 132
 
133 133
 		// The URL stored in WLS. If this is the initial install the URL may be null.
134 134
 		$url = $res_body['url'];
135 135
 
136 136
 		// If the URL isn't set or matches, then it's valid.
137
-		if ( is_null( $url ) || $url === get_option( 'home' ) ) {
138
-			wp_send_json_success( array( 'valid' => true, 'message' => '' ) );
137
+		if (is_null($url) || $url === get_option('home')) {
138
+			wp_send_json_success(array('valid' => true, 'message' => ''));
139 139
 		}
140 140
 
141 141
 		// If the URL doesn't match it means that this key has been configured elsewhere already.
142
-		if ( $url !== get_option( 'home' ) ) {
143
-			Wordlift_Configuration_Service::get_instance()->set_key( '' );
144
-			wp_send_json_success( array(
142
+		if ($url !== get_option('home')) {
143
+			Wordlift_Configuration_Service::get_instance()->set_key('');
144
+			wp_send_json_success(array(
145 145
 				'valid'   => false,
146
-				'message' => __( 'The key is already used on another site, please contact us at [email protected] to move the key to another site.', 'wordlift' ),
147
-			) );
146
+				'message' => __('The key is already used on another site, please contact us at [email protected] to move the key to another site.', 'wordlift'),
147
+			));
148 148
 		}
149 149
 
150 150
 		// Set a response with valid set to true or false according to the key validity with message.
151
-		wp_send_json_success( array(
151
+		wp_send_json_success(array(
152 152
 			'valid'   => false,
153
-			'message' => __( 'An error occurred, please contact us at [email protected]', 'wordlift' ),
154
-		) );
153
+			'message' => __('An error occurred, please contact us at [email protected]', 'wordlift'),
154
+		));
155 155
 	}
156 156
 
157 157
 	/**
@@ -160,15 +160,15 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function wl_load_plugin() {
162 162
 
163
-		$wl_blog_url = get_option( '_wl_blog_url' );
164
-		$home_url    = defined( 'WP_HOME' ) ? WP_HOME : get_option( 'home' );
163
+		$wl_blog_url = get_option('_wl_blog_url');
164
+		$home_url    = defined('WP_HOME') ? WP_HOME : get_option('home');
165 165
 
166
-		if ( ! $wl_blog_url ) {
167
-			update_option( '_wl_blog_url', $home_url, true );
168
-		} else if ( $wl_blog_url !== $home_url ) {
169
-			update_option( '_wl_blog_url', $home_url, true );
170
-			Wordlift_Configuration_Service::get_instance()->set_key( '' );
171
-			set_transient( 'wl-key-error-msg', __( "Your web site URL has changed. To avoid data corruption, WordLift's key has been removed. Please provide a new key in WordLift Settings. If you believe this to be an error, please contact us at [email protected]", 'wordlift' ), 10 );
166
+		if ( ! $wl_blog_url) {
167
+			update_option('_wl_blog_url', $home_url, true);
168
+		} else if ($wl_blog_url !== $home_url) {
169
+			update_option('_wl_blog_url', $home_url, true);
170
+			Wordlift_Configuration_Service::get_instance()->set_key('');
171
+			set_transient('wl-key-error-msg', __("Your web site URL has changed. To avoid data corruption, WordLift's key has been removed. Please provide a new key in WordLift Settings. If you believe this to be an error, please contact us at [email protected]", 'wordlift'), 10);
172 172
 		}
173 173
 
174 174
 	}
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 	 *
179 179
 	 */
180 180
 	public function wl_key_update_notice() {
181
-		if ( get_transient( 'wl-key-error-msg' ) ) {
181
+		if (get_transient('wl-key-error-msg')) {
182 182
 			?>
183 183
             <div class="updated notice is-dismissible error">
184
-                <p><?php _e( get_transient( 'wl-key-error-msg' ), 'wordlift' ); ?></p>
184
+                <p><?php _e(get_transient('wl-key-error-msg'), 'wordlift'); ?></p>
185 185
             </div>
186 186
 			<?php
187 187
 		}
Please login to merge, or discard this patch.