Passed
Push — master ( 87dd3b...54f7d9 )
by Joseph
01:58
created
classes/subway-auth-redirect.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 namespace Subway;
21 21
 
22 22
 if (! defined('ABSPATH') ) {
23
-    return;
23
+	return;
24 24
 }
25 25
 
26 26
 /**
@@ -36,183 +36,183 @@  discard block
 block discarded – undo
36 36
 final class AuthRedirect
37 37
 {
38 38
 
39
-    /**
40
-     * Handles our ajax authentication.
41
-     *
42
-     * @return void
43
-     */
44
-    public static function handleAuthentication()
45
-    {
39
+	/**
40
+	 * Handles our ajax authentication.
41
+	 *
42
+	 * @return void
43
+	 */
44
+	public static function handleAuthentication()
45
+	{
46 46
 
47
-        // Set the header type to json.
48
-        header('Content-Type: application/json');
47
+		// Set the header type to json.
48
+		header('Content-Type: application/json');
49 49
 
50
-        $log = filter_input(INPUT_POST, 'log', FILTER_SANITIZE_STRING);
50
+		$log = filter_input(INPUT_POST, 'log', FILTER_SANITIZE_STRING);
51 51
 
52
-        $pwd = filter_input(INPUT_POST, 'pwd', FILTER_SANITIZE_STRING);
52
+		$pwd = filter_input(INPUT_POST, 'pwd', FILTER_SANITIZE_STRING);
53 53
 
54
-        if (empty($log) && empty($pwd) ) {
54
+		if (empty($log) && empty($pwd) ) {
55 55
 
56
-            $response['type'] = 'error';
56
+			$response['type'] = 'error';
57 57
 
58
-            $response['message'] = esc_html__(
59
-                'Username and Password cannot be empty.',
60
-                'subway'
61
-            );
58
+			$response['message'] = esc_html__(
59
+				'Username and Password cannot be empty.',
60
+				'subway'
61
+			);
62 62
 
63
-        } else {
63
+		} else {
64 64
 
65
-            $is_signin = wp_signon();
65
+			$is_signin = wp_signon();
66 66
 
67
-            $response = array();
67
+			$response = array();
68 68
 
69
-            if (is_wp_error($is_signin) ) {
69
+			if (is_wp_error($is_signin) ) {
70 70
 
71
-                $response['type'] = 'error';
71
+				$response['type'] = 'error';
72 72
 
73
-                $response['message'] = $is_signin->get_error_message();
73
+				$response['message'] = $is_signin->get_error_message();
74 74
 
75
-            } else {
75
+			} else {
76 76
 
77
-                $response['type'] = 'success';
77
+				$response['type'] = 'success';
78 78
 
79
-                $response['message'] = esc_html__(
80
-                    'You have successfully logged-in. Redirecting you in few seconds...',
81
-                    'subway'
82
-                );
79
+				$response['message'] = esc_html__(
80
+					'You have successfully logged-in. Redirecting you in few seconds...',
81
+					'subway'
82
+				);
83 83
 
84
-            }
85
-        }
84
+			}
85
+		}
86 86
 
87
-        $subway_redirect_url = AuthRedirect::getLoginRedirectUrl('', $is_signin);
87
+		$subway_redirect_url = AuthRedirect::getLoginRedirectUrl('', $is_signin);
88 88
 
89
-        $response['redirect_url'] = apply_filters(
90
-            'subway_login_redirect',
91
-            $subway_redirect_url,
92
-            $is_signin
93
-        );
89
+		$response['redirect_url'] = apply_filters(
90
+			'subway_login_redirect',
91
+			$subway_redirect_url,
92
+			$is_signin
93
+		);
94 94
 
95
-        echo wp_json_encode($response);
95
+		echo wp_json_encode($response);
96 96
 
97
-        wp_die();
97
+		wp_die();
98 98
 
99
-    }
99
+	}
100 100
 
101
-    /**
102
-     * Returns the filtered redirect url for the current user.
103
-     *
104
-     * @param string $redirect_to The default redirect callback argument.
105
-     * @param mixed  $user        This holds the meta info of currently logged-in user.
106
-     *
107
-     * @return string             The final redirect url.
108
-     */
109
-    public static function getLoginRedirectUrl( $redirect_to, $user )
110
-    {
101
+	/**
102
+	 * Returns the filtered redirect url for the current user.
103
+	 *
104
+	 * @param string $redirect_to The default redirect callback argument.
105
+	 * @param mixed  $user        This holds the meta info of currently logged-in user.
106
+	 *
107
+	 * @return string             The final redirect url.
108
+	 */
109
+	public static function getLoginRedirectUrl( $redirect_to, $user )
110
+	{
111 111
 
112
-        $subway_redirect_type = get_option('subway_redirect_type');
112
+		$subway_redirect_type = get_option('subway_redirect_type');
113 113
 
114
-        // Redirect the user to default behaviour.
115
-        // If there are no redirect type option saved.
116
-        if (empty($subway_redirect_type) ) {
114
+		// Redirect the user to default behaviour.
115
+		// If there are no redirect type option saved.
116
+		if (empty($subway_redirect_type) ) {
117 117
 
118
-            return $redirect_to;
118
+			return $redirect_to;
119 119
 
120
-        }
120
+		}
121 121
 
122
-        if ('default' === $subway_redirect_type ) {
123
-            return $redirect_to;
124
-        }
122
+		if ('default' === $subway_redirect_type ) {
123
+			return $redirect_to;
124
+		}
125 125
 
126
-        if ('page' === $subway_redirect_type ) {
126
+		if ('page' === $subway_redirect_type ) {
127 127
 
128
-            // Get the page url of the selected page.
129
-            // If the admin selected 'Custom Page' in the redirect type settings.
130
-            $selected_redirect_page = intval(get_option('subway_redirect_page_id'));
128
+			// Get the page url of the selected page.
129
+			// If the admin selected 'Custom Page' in the redirect type settings.
130
+			$selected_redirect_page = intval(get_option('subway_redirect_page_id'));
131 131
 
132
-            // Redirect to default WordPress behaviour.
133
-            // If the user did not select page.
134
-            if (empty($selected_redirect_page) ) {
132
+			// Redirect to default WordPress behaviour.
133
+			// If the user did not select page.
134
+			if (empty($selected_redirect_page) ) {
135 135
 
136
-                return $redirect_to;
137
-            }
136
+				return $redirect_to;
137
+			}
138 138
 
139
-            // Otherwise, get the permalink of the saved page
140
-            // and let the user go into that page.
141
-            return get_permalink($selected_redirect_page);
139
+			// Otherwise, get the permalink of the saved page
140
+			// and let the user go into that page.
141
+			return get_permalink($selected_redirect_page);
142 142
 
143
-        } elseif ('custom_url' === $subway_redirect_type ) {
143
+		} elseif ('custom_url' === $subway_redirect_type ) {
144 144
 
145
-            // Get the custom url saved in the redirect type settings.
146
-            $entered_custom_url = get_option('subway_redirect_custom_url');
145
+			// Get the custom url saved in the redirect type settings.
146
+			$entered_custom_url = get_option('subway_redirect_custom_url');
147 147
 
148
-            // Redirect to default WordPress behaviour
149
-            // if the user did enter a custom url.
150
-            if (empty($entered_custom_url) ) {
148
+			// Redirect to default WordPress behaviour
149
+			// if the user did enter a custom url.
150
+			if (empty($entered_custom_url) ) {
151 151
 
152
-                return $redirect_to;
152
+				return $redirect_to;
153 153
 
154
-            }
154
+			}
155 155
 
156
-            // Otherwise, get the custom url saved
157
-            // and let the user go into that page.
158
-            if (! empty($user->ID) ) {
159
-                $entered_custom_url = str_replace(
160
-                    '%user_id%', $user->ID,
161
-                    $entered_custom_url
162
-                );
163
-            }
156
+			// Otherwise, get the custom url saved
157
+			// and let the user go into that page.
158
+			if (! empty($user->ID) ) {
159
+				$entered_custom_url = str_replace(
160
+					'%user_id%', $user->ID,
161
+					$entered_custom_url
162
+				);
163
+			}
164 164
 
165
-            if (! empty($user->user_login) ) {
166
-                $entered_custom_url = str_replace(
167
-                    '%user_name%', $user->user_login,
168
-                    $entered_custom_url
169
-                );
170
-            }
165
+			if (! empty($user->user_login) ) {
166
+				$entered_custom_url = str_replace(
167
+					'%user_name%', $user->user_login,
168
+					$entered_custom_url
169
+				);
170
+			}
171 171
 
172
-            return $entered_custom_url;
172
+			return $entered_custom_url;
173 173
 
174
-        }
174
+		}
175 175
 
176
-        // Otherwise, quit and redirect the user back to default WordPress behaviour.
177
-        return $redirect_to;
178
-    }
176
+		// Otherwise, quit and redirect the user back to default WordPress behaviour.
177
+		return $redirect_to;
178
+	}
179 179
 
180
-    /**
181
-     * Callback function for the 'login_url' filter defined in Subway.php
182
-     *
183
-     * @param string $login_url The login url.
184
-     *
185
-     * @return string            The final login url.
186
-     */
187
-    public static function loginUrl( $login_url  )
188
-    {
180
+	/**
181
+	 * Callback function for the 'login_url' filter defined in Subway.php
182
+	 *
183
+	 * @param string $login_url The login url.
184
+	 *
185
+	 * @return string            The final login url.
186
+	 */
187
+	public static function loginUrl( $login_url  )
188
+	{
189 189
 
190
-        $subway_login_page = Options::getRedirectPageUrl();
190
+		$subway_login_page = Options::getRedirectPageUrl();
191 191
 
192
-        // Return the default login url if there is no log-in page defined.
193
-        if (empty($subway_login_page) ) {
194
-            return $login_url;
195
-        }
192
+		// Return the default login url if there is no log-in page defined.
193
+		if (empty($subway_login_page) ) {
194
+			return $login_url;
195
+		}
196 196
 
197
-        // Otherwise, return the Subway login page.
198
-        return $subway_login_page;
197
+		// Otherwise, return the Subway login page.
198
+		return $subway_login_page;
199 199
 
200
-    }
200
+	}
201 201
 
202
-    /**
203
-     * The callback function for our logout filter.
204
-     *
205
-     * @return void
206
-     */
207
-    public static function logoutUrl()
208
-    {
202
+	/**
203
+	 * The callback function for our logout filter.
204
+	 *
205
+	 * @return void
206
+	 */
207
+	public static function logoutUrl()
208
+	{
209 209
 
210
-        $subway_login_page = Options::getRedirectPageUrl();
210
+		$subway_login_page = Options::getRedirectPageUrl();
211 211
 
212
-        wp_safe_redirect(esc_url($subway_login_page . '?loggedout=true'));
212
+		wp_safe_redirect(esc_url($subway_login_page . '?loggedout=true'));
213 213
 
214
-        Helpers::close();
214
+		Helpers::close();
215 215
 
216
-    }
216
+	}
217 217
 
218 218
 }
Please login to merge, or discard this patch.