@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | $configured_logging_dir = $config->get_setting( 'logging/directory', '' ); |
70 | 70 | |
71 | - if( ! empty( $configured_logging_dir ) ) { |
|
71 | + if ( ! empty( $configured_logging_dir ) ) { |
|
72 | 72 | |
73 | 73 | $logging_directory = $this->check_directory( $configured_logging_dir ); |
74 | 74 | |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | // Directory cannot be found or created. Cannot log. |
85 | - if( ! $logging_directory ) { |
|
85 | + if ( ! $logging_directory ) { |
|
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | |
89 | 89 | // Directory cannot be written to |
90 | - if( ! $this->check_directory( $logging_directory ) ) { |
|
90 | + if ( ! $this->check_directory( $logging_directory ) ) { |
|
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | $options = wp_parse_args( $settings_options, $default_options ); |
111 | 111 | |
112 | - $klogger = new Logger ( |
|
112 | + $klogger = new Logger( |
|
113 | 113 | $logging_directory, |
114 | 114 | $config->get_setting( 'logging/threshold', 'notice' ), |
115 | 115 | $options |
@@ -134,21 +134,21 @@ discard block |
||
134 | 134 | */ |
135 | 135 | private function check_directory( $dirpath ) { |
136 | 136 | |
137 | - $dirpath = (string) $dirpath; |
|
137 | + $dirpath = (string)$dirpath; |
|
138 | 138 | $file_exists = file_exists( $dirpath ); |
139 | 139 | $is_writable = wp_is_writable( $dirpath ); |
140 | 140 | |
141 | 141 | // If the configured setting path exists and is writeable, use it. |
142 | - if( $file_exists && $is_writable ) { |
|
142 | + if ( $file_exists && $is_writable ) { |
|
143 | 143 | return $dirpath; |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Otherwise, try and log default errors |
147 | - if( ! $file_exists ) { |
|
147 | + if ( ! $file_exists ) { |
|
148 | 148 | $this->log( 'The defined logging directory does not exist: ' . $dirpath, __METHOD__, 'error' ); |
149 | 149 | } |
150 | 150 | |
151 | - if( ! $is_writable ) { |
|
151 | + if ( ! $is_writable ) { |
|
152 | 152 | $this->log( 'The defined logging directory exists but could not be written to: ' . $dirpath, __METHOD__, 'error' ); |
153 | 153 | } |
154 | 154 | |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | |
167 | 167 | $upload_dir = wp_upload_dir(); |
168 | 168 | |
169 | - $log_dir = trailingslashit( $upload_dir['basedir'] ) . self::DIRECTORY_PATH; |
|
169 | + $log_dir = trailingslashit( $upload_dir[ 'basedir' ] ) . self::DIRECTORY_PATH; |
|
170 | 170 | |
171 | 171 | // Directory exists; return early |
172 | - if( file_exists( $log_dir ) ) { |
|
172 | + if ( file_exists( $log_dir ) ) { |
|
173 | 173 | |
174 | 174 | $this->prevent_directory_browsing( $log_dir ); |
175 | 175 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $folder_created = wp_mkdir_p( $log_dir ); |
181 | 181 | |
182 | 182 | // Something went wrong mapping the directory |
183 | - if( ! $folder_created ) { |
|
183 | + if ( ! $folder_created ) { |
|
184 | 184 | $this->log( 'The log directory could not be created: ' . $log_dir, __METHOD__, 'error' ); |
185 | 185 | return false; |
186 | 186 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | */ |
242 | 242 | $is_enabled = apply_filters( 'trustedlogin/' . $this->ns . '/logging/enabled', $is_enabled ); |
243 | 243 | |
244 | - return (bool) $is_enabled; |
|
244 | + return (bool)$is_enabled; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | return; |
320 | 320 | } |
321 | 321 | |
322 | - $this->klogger->{$level}( $log_message, (array) $data ); |
|
322 | + $this->klogger->{$level}( $log_message, (array)$data ); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | } |
@@ -17,6 +17,5 @@ |
||
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
20 | -class ConfigException extends \Exception |
|
21 | -{ |
|
20 | +class ConfigException extends \Exception { |
|
22 | 21 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | namespace GravityView\TrustedLogin; |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined('ABSPATH') ) { |
|
14 | +if ( ! defined( 'ABSPATH' ) ) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | namespace GravityView\TrustedLogin; |
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | -if ( ! defined('ABSPATH') ) { |
|
16 | +if ( ! defined( 'ABSPATH' ) ) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -112,51 +112,51 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function validate() { |
114 | 114 | |
115 | - if ( in_array( __NAMESPACE__, array( 'ReplaceMe', 'ReplaceMe\GravityView\GravityView\TrustedLogin' ) ) && ! defined('TL_DOING_TESTS') ) { |
|
115 | + if ( in_array( __NAMESPACE__, array( 'ReplaceMe', 'ReplaceMe\GravityView\GravityView\TrustedLogin' ) ) && ! defined( 'TL_DOING_TESTS' ) ) { |
|
116 | 116 | throw new Exception( 'Developer: make sure to change the namespace for the TrustedLogin class. See https://trustedlogin.com/configuration/ for more information.', 501 ); |
117 | 117 | } |
118 | 118 | |
119 | 119 | $errors = array(); |
120 | 120 | |
121 | - if ( ! isset( $this->settings['auth']['api_key'] ) ) { |
|
122 | - $errors[] = new WP_Error( 'missing_configuration', 'You need to set an API key. Get yours at https://app.trustedlogin.com' ); |
|
121 | + if ( ! isset( $this->settings[ 'auth' ][ 'api_key' ] ) ) { |
|
122 | + $errors[ ] = new WP_Error( 'missing_configuration', 'You need to set an API key. Get yours at https://app.trustedlogin.com' ); |
|
123 | 123 | } |
124 | 124 | |
125 | - if ( isset( $this->settings['vendor']['website'] ) && 'https://www.example.com' === $this->settings['vendor']['website'] && ! defined('TL_DOING_TESTS') ) { |
|
126 | - $errors[] = new WP_Error( 'missing_configuration', 'You need to configure the "website" URL to point to the URL where the Vendor plugin is installed.' ); |
|
125 | + if ( isset( $this->settings[ 'vendor' ][ 'website' ] ) && 'https://www.example.com' === $this->settings[ 'vendor' ][ 'website' ] && ! defined( 'TL_DOING_TESTS' ) ) { |
|
126 | + $errors[ ] = new WP_Error( 'missing_configuration', 'You need to configure the "website" URL to point to the URL where the Vendor plugin is installed.' ); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | foreach ( array( 'namespace', 'title', 'website', 'support_url', 'email' ) as $required_vendor_field ) { |
130 | - if ( ! isset( $this->settings['vendor'][ $required_vendor_field ] ) ) { |
|
131 | - $errors[] = new WP_Error( 'missing_configuration', sprintf( 'Missing required configuration: `vendor/%s`', $required_vendor_field ) ); |
|
130 | + if ( ! isset( $this->settings[ 'vendor' ][ $required_vendor_field ] ) ) { |
|
131 | + $errors[ ] = new WP_Error( 'missing_configuration', sprintf( 'Missing required configuration: `vendor/%s`', $required_vendor_field ) ); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | - if ( isset( $this->settings['decay'] ) ) { |
|
136 | - if ( ! is_int( $this->settings['decay'] ) ) { |
|
137 | - $errors[] = new WP_Error( 'invalid_configuration', 'Decay must be an integer (number of seconds).' ); |
|
138 | - } elseif ( $this->settings['decay'] > MONTH_IN_SECONDS ) { |
|
139 | - $errors[] = new WP_Error( 'invalid_configuration', 'Decay must be less than or equal to 30 days.' ); |
|
140 | - } elseif ( $this->settings['decay'] < DAY_IN_SECONDS ) { |
|
141 | - $errors[] = new WP_Error( 'invalid_configuration', 'Decay must be greater than 1 day.' ); |
|
135 | + if ( isset( $this->settings[ 'decay' ] ) ) { |
|
136 | + if ( ! is_int( $this->settings[ 'decay' ] ) ) { |
|
137 | + $errors[ ] = new WP_Error( 'invalid_configuration', 'Decay must be an integer (number of seconds).' ); |
|
138 | + } elseif ( $this->settings[ 'decay' ] > MONTH_IN_SECONDS ) { |
|
139 | + $errors[ ] = new WP_Error( 'invalid_configuration', 'Decay must be less than or equal to 30 days.' ); |
|
140 | + } elseif ( $this->settings[ 'decay' ] < DAY_IN_SECONDS ) { |
|
141 | + $errors[ ] = new WP_Error( 'invalid_configuration', 'Decay must be greater than 1 day.' ); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | - if ( isset( $this->settings['vendor']['namespace'] ) ) { |
|
145 | + if ( isset( $this->settings[ 'vendor' ][ 'namespace' ] ) ) { |
|
146 | 146 | |
147 | 147 | // This seems like a reasonable max limit on namespace length. |
148 | 148 | // @see https://developer.wordpress.org/reference/functions/set_transient/#more-information |
149 | - if ( strlen( $this->settings['vendor']['namespace'] ) > 96 ) { |
|
150 | - $errors[] = new WP_Error( 'invalid_configuration', 'Namespace length must be shorter than 96 characters.' ); |
|
149 | + if ( strlen( $this->settings[ 'vendor' ][ 'namespace' ] ) > 96 ) { |
|
150 | + $errors[ ] = new WP_Error( 'invalid_configuration', 'Namespace length must be shorter than 96 characters.' ); |
|
151 | 151 | } |
152 | 152 | |
153 | - if ( in_array( strtolower( $this->settings['vendor']['namespace'] ), self::$reserved_namespaces, true ) ) { |
|
154 | - $errors[] = new WP_Error( 'invalid_configuration', 'The defined namespace is reserved.' ); |
|
153 | + if ( in_array( strtolower( $this->settings[ 'vendor' ][ 'namespace' ] ), self::$reserved_namespaces, true ) ) { |
|
154 | + $errors[ ] = new WP_Error( 'invalid_configuration', 'The defined namespace is reserved.' ); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | - if ( isset( $this->settings['vendor'][ 'email' ] ) && ! filter_var( $this->settings['vendor'][ 'email' ], FILTER_VALIDATE_EMAIL ) ) { |
|
159 | - $errors[] = new WP_Error( 'invalid_configuration', 'An invalid `vendor/email` setting was passed to the TrustedLogin Client.' ); |
|
158 | + if ( isset( $this->settings[ 'vendor' ][ 'email' ] ) && ! filter_var( $this->settings[ 'vendor' ][ 'email' ], FILTER_VALIDATE_EMAIL ) ) { |
|
159 | + $errors[ ] = new WP_Error( 'invalid_configuration', 'An invalid `vendor/email` setting was passed to the TrustedLogin Client.' ); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | // TODO: Add namespace collision check? |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $value = $this->get_setting( $settings_key, null, $this->settings ); |
165 | 165 | $url = wp_kses_bad_protocol( $value, array( 'http', 'https' ) ); |
166 | 166 | if ( $value && ! filter_var( $url, FILTER_VALIDATE_URL ) ) { |
167 | - $errors[] = new WP_Error( |
|
167 | + $errors[ ] = new WP_Error( |
|
168 | 168 | 'invalid_configuration', |
169 | 169 | sprintf( 'An invalid `%s` setting was passed to the TrustedLogin Client: %s', |
170 | 170 | $settings_key, |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | |
179 | 179 | foreach ( SupportRole::$prevented_caps as $invalid_cap ) { |
180 | 180 | if ( array_key_exists( $invalid_cap, $added_caps ) ) { |
181 | - $errors[] = new WP_Error( 'invalid_configuration', 'TrustedLogin users cannot be allowed to: ' . $invalid_cap ); |
|
181 | + $errors[ ] = new WP_Error( 'invalid_configuration', 'TrustedLogin users cannot be allowed to: ' . $invalid_cap ); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $error_text = array(); |
187 | 187 | foreach ( $errors as $error ) { |
188 | 188 | if ( is_wp_error( $error ) ) { |
189 | - $error_text[] = $error->get_error_message(); |
|
189 | + $error_text[ ] = $error->get_error_message(); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | |
222 | 222 | $time = current_time( 'timestamp', $gmt ); |
223 | 223 | |
224 | - return $time + (int) $decay_time; |
|
224 | + return $time + (int)$decay_time; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | |
282 | 282 | $default_settings = $this->default_settings; |
283 | 283 | |
284 | - $default_settings['paths']['css'] = plugin_dir_url( __FILE__ ) . 'assets/trustedlogin.css'; |
|
285 | - $default_settings['paths']['js'] = plugin_dir_url( __FILE__ ) . 'assets/trustedlogin.js'; |
|
284 | + $default_settings[ 'paths' ][ 'css' ] = plugin_dir_url( __FILE__ ) . 'assets/trustedlogin.css'; |
|
285 | + $default_settings[ 'paths' ][ 'js' ] = plugin_dir_url( __FILE__ ) . 'assets/trustedlogin.js'; |
|
286 | 286 | |
287 | 287 | return $default_settings; |
288 | 288 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | namespace GravityView\TrustedLogin; |
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | -if ( ! defined('ABSPATH') ) { |
|
16 | +if ( ! defined( 'ABSPATH' ) ) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -72,14 +72,14 @@ discard block |
||
72 | 72 | // TODO: Support multiple roles |
73 | 73 | $role = is_array( $roles ) ? array_key_first( $roles ) : $roles; |
74 | 74 | |
75 | - return (string) $role; |
|
75 | + return (string)$role; |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @return string |
80 | 80 | */ |
81 | 81 | public function get_name() { |
82 | - return (string) $this->role_name; |
|
82 | + return (string)$this->role_name; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | $add_caps = $this->config->get_setting( 'caps/add' ); |
152 | 152 | |
153 | - foreach ( (array) $add_caps as $add_cap => $reason ) { |
|
153 | + foreach ( (array)$add_caps as $add_cap => $reason ) { |
|
154 | 154 | $capabilities[ $add_cap ] = true; |
155 | 155 | } |
156 | 156 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | $new_role = add_role( $new_role_slug, $role_display_name, $capabilities ); |
168 | 168 | |
169 | - if ( ! $new_role ){ |
|
169 | + if ( ! $new_role ) { |
|
170 | 170 | |
171 | 171 | return new WP_Error( |
172 | 172 | 'add_role_failed', |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | |
182 | 182 | $remove_caps = $this->config->get_setting( 'caps/remove' ); |
183 | 183 | |
184 | - if ( ! empty( $remove_caps ) ){ |
|
184 | + if ( ! empty( $remove_caps ) ) { |
|
185 | 185 | |
186 | - foreach ( $remove_caps as $remove_cap => $description ){ |
|
186 | + foreach ( $remove_caps as $remove_cap => $description ) { |
|
187 | 187 | $new_role->remove_cap( $remove_cap ); |
188 | - $this->logging->log( 'Capability '. $remove_cap .' removed from role.', __METHOD__, 'info' ); |
|
188 | + $this->logging->log( 'Capability ' . $remove_cap . ' removed from role.', __METHOD__, 'info' ); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | // Returns void; no way to tell if successful |
205 | 205 | remove_role( $this->get_name() ); |
206 | 206 | |
207 | - if( get_role( $this->get_name() ) ) { |
|
207 | + if ( get_role( $this->get_name() ) ) { |
|
208 | 208 | |
209 | 209 | $this->logging->log( "Role " . $this->get_name() . " was not removed successfully.", __METHOD__, 'error' ); |
210 | 210 |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | $new_role = add_role( $new_role_slug, $role_display_name, $capabilities ); |
168 | 168 | |
169 | - if ( ! $new_role ){ |
|
169 | + if ( ! $new_role ) { |
|
170 | 170 | |
171 | 171 | return new WP_Error( |
172 | 172 | 'add_role_failed', |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | |
182 | 182 | $remove_caps = $this->config->get_setting( 'caps/remove' ); |
183 | 183 | |
184 | - if ( ! empty( $remove_caps ) ){ |
|
184 | + if ( ! empty( $remove_caps ) ) { |
|
185 | 185 | |
186 | - foreach ( $remove_caps as $remove_cap => $description ){ |
|
186 | + foreach ( $remove_caps as $remove_cap => $description ) { |
|
187 | 187 | $new_role->remove_cap( $remove_cap ); |
188 | 188 | $this->logging->log( 'Capability '. $remove_cap .' removed from role.', __METHOD__, 'info' ); |
189 | 189 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | namespace GravityView\TrustedLogin; |
25 | 25 | |
26 | 26 | // Exit if accessed directly |
27 | -if ( ! defined('ABSPATH') ) { |
|
27 | +if ( ! defined( 'ABSPATH' ) ) { |
|
28 | 28 | exit; |
29 | 29 | } |
30 | 30 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $ns = $config->ns(); |
160 | 160 | |
161 | 161 | // Namespace isn't set; allow Config |
162 | - if( empty( $ns ) ) { |
|
162 | + if ( empty( $ns ) ) { |
|
163 | 163 | return true; |
164 | 164 | } |
165 | 165 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | return $created; |
344 | 344 | } |
345 | 345 | |
346 | - $return_data['timing']['remote'] = timer_stop( 0, 5 ); |
|
346 | + $return_data[ 'timing' ][ 'remote' ] = timer_stop( 0, 5 ); |
|
347 | 347 | |
348 | 348 | do_action( 'trustedlogin/' . $this->config->ns() . '/access/created', array( |
349 | 349 | 'url' => get_site_url(), |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | return $updated; |
448 | 448 | } |
449 | 449 | |
450 | - $return_data['timing']['remote'] = timer_stop( 0, 5 ); |
|
450 | + $return_data[ 'timing' ][ 'remote' ] = timer_stop( 0, 5 ); |
|
451 | 451 | |
452 | 452 | do_action( 'trustedlogin/' . $this->config->ns() . '/access/extended', array( |
453 | 453 | 'url' => get_site_url(), |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | $reference_id = self::get_reference_id(); |
544 | 544 | |
545 | 545 | if ( $reference_id ) { |
546 | - $metadata['reference_id'] = $reference_id; |
|
546 | + $metadata[ 'reference_id' ] = $reference_id; |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | return $metadata; |
@@ -558,12 +558,12 @@ discard block |
||
558 | 558 | */ |
559 | 559 | public static function get_reference_id() { |
560 | 560 | |
561 | - if ( isset( $_REQUEST['reference_id'] ) ) { |
|
562 | - return esc_html( $_REQUEST['reference_id'] ); |
|
561 | + if ( isset( $_REQUEST[ 'reference_id' ] ) ) { |
|
562 | + return esc_html( $_REQUEST[ 'reference_id' ] ); |
|
563 | 563 | } |
564 | 564 | |
565 | - if ( isset( $_REQUEST['ref'] ) ) { |
|
566 | - return esc_html( $_REQUEST['ref'] ); |
|
565 | + if ( isset( $_REQUEST[ 'ref' ] ) ) { |
|
566 | + return esc_html( $_REQUEST[ 'ref' ] ); |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | return null; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | // Before logging-in support, let's make sure the site isn't locked-down or that this request is flagged |
123 | 123 | $is_verified = $security_checks->verify( $user_identifier ); |
124 | 124 | |
125 | - if ( ! $is_verified || is_wp_error( $is_verified ) ){ |
|
125 | + if ( ! $is_verified || is_wp_error( $is_verified ) ) { |
|
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Runs after the identifier fails security checks |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | return; |
180 | 180 | } |
181 | 181 | |
182 | - if ( ! isset( $_REQUEST['_wpnonce'] ) ) { |
|
182 | + if ( ! isset( $_REQUEST[ '_wpnonce' ] ) ) { |
|
183 | 183 | return; |
184 | 184 | } |
185 | 185 | |
186 | - $verify_nonce = wp_verify_nonce( $_REQUEST['_wpnonce' ], self::REVOKE_SUPPORT_QUERY_PARAM ); |
|
186 | + $verify_nonce = wp_verify_nonce( $_REQUEST[ '_wpnonce' ], self::REVOKE_SUPPORT_QUERY_PARAM ); |
|
187 | 187 | |
188 | 188 | if ( ! $verify_nonce ) { |
189 | 189 | $this->logging->log( 'Removing user failed: Nonce expired (Nonce value: ' . $verify_nonce . ')', __METHOD__, 'error' ); |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * @return string |
269 | 269 | */ |
270 | 270 | public function get() { |
271 | - return (string) get_site_option( $this->option_name ); |
|
271 | + return (string)get_site_option( $this->option_name ); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -282,19 +282,19 @@ discard block |
||
282 | 282 | |
283 | 283 | $endpoint = $this->get(); |
284 | 284 | |
285 | - if ( ! isset( $_POST['action'], $_POST['endpoint'], $_POST['identifier'] ) ) { |
|
285 | + if ( ! isset( $_POST[ 'action' ], $_POST[ 'endpoint' ], $_POST[ 'identifier' ] ) ) { |
|
286 | 286 | return false; |
287 | 287 | } |
288 | 288 | |
289 | - if ( 'trustedlogin' !== $_POST['action'] ) { |
|
289 | + if ( 'trustedlogin' !== $_POST[ 'action' ] ) { |
|
290 | 290 | return false; |
291 | 291 | } |
292 | 292 | |
293 | - if ( $endpoint !== $_POST['endpoint'] ) { |
|
293 | + if ( $endpoint !== $_POST[ 'endpoint' ] ) { |
|
294 | 294 | return false; |
295 | 295 | } |
296 | 296 | |
297 | - return sanitize_text_field( $_POST['identifier'] ); |
|
297 | + return sanitize_text_field( $_POST[ 'identifier' ] ); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -122,7 +122,7 @@ |
||
122 | 122 | // Before logging-in support, let's make sure the site isn't locked-down or that this request is flagged |
123 | 123 | $is_verified = $security_checks->verify( $user_identifier ); |
124 | 124 | |
125 | - if ( ! $is_verified || is_wp_error( $is_verified ) ){ |
|
125 | + if ( ! $is_verified || is_wp_error( $is_verified ) ) { |
|
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Runs after the identifier fails security checks |
@@ -245,7 +245,7 @@ |
||
245 | 245 | |
246 | 246 | add_rewrite_endpoint( $endpoint, EP_ROOT ); |
247 | 247 | |
248 | - $this->logging->log( "Endpoint {$endpoint} added.", __METHOD__, 'debug' ); |
|
248 | + $this->logging->log( "endpoint {$endpoint} added.", __METHOD__, 'debug' ); |
|
249 | 249 | |
250 | 250 | if ( get_site_option( self::PERMALINK_FLUSH_OPTION_NAME ) ) { |
251 | 251 | return; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | namespace GravityView\TrustedLogin; |
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | -if ( ! defined('ABSPATH') ) { |
|
16 | +if ( ! defined( 'ABSPATH' ) ) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | |
82 | 82 | $e_keys = $this->encryption->generate_keys(); |
83 | 83 | |
84 | - if ( is_wp_error( $e_keys ) ){ |
|
84 | + if ( is_wp_error( $e_keys ) ) { |
|
85 | 85 | return $e_keys; |
86 | 86 | } |
87 | 87 | |
88 | 88 | $nonce = $this->encryption->get_nonce(); |
89 | 89 | |
90 | - if ( is_wp_error( $nonce ) ){ |
|
90 | + if ( is_wp_error( $nonce ) ) { |
|
91 | 91 | return $nonce; |
92 | 92 | } |
93 | 93 |
@@ -81,13 +81,13 @@ |
||
81 | 81 | |
82 | 82 | $e_keys = $this->encryption->generate_keys(); |
83 | 83 | |
84 | - if ( is_wp_error( $e_keys ) ){ |
|
84 | + if ( is_wp_error( $e_keys ) ) { |
|
85 | 85 | return $e_keys; |
86 | 86 | } |
87 | 87 | |
88 | 88 | $nonce = $this->encryption->get_nonce(); |
89 | 89 | |
90 | - if ( is_wp_error( $nonce ) ){ |
|
90 | + if ( is_wp_error( $nonce ) ) { |
|
91 | 91 | return $nonce; |
92 | 92 | } |
93 | 93 |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | $user_identifier = $passed_user_identifier; |
85 | 85 | |
86 | - if ( $this->in_lockdown() ){ |
|
86 | + if ( $this->in_lockdown() ) { |
|
87 | 87 | |
88 | 88 | $this->logging->log( 'Site is in lockdown mode, aborting login.', __METHOD__, 'error' ); |
89 | 89 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $approved = $this->check_approved_identifier( $secret_id ); |
112 | 112 | |
113 | 113 | // Don't lock-down the site, since there could have been errors related to remote validation |
114 | - if ( is_wp_error( $approved ) ){ |
|
114 | + if ( is_wp_error( $approved ) ) { |
|
115 | 115 | |
116 | 116 | $this->logging->log( |
117 | 117 | sprintf( |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | $notified = $this->report_lockdown(); |
304 | 304 | |
305 | - if ( is_wp_error( $notified ) ){ |
|
305 | + if ( is_wp_error( $notified ) ) { |
|
306 | 306 | $this->logging->log( sprintf( 'Could not notify TrustedLogin (%s)', $notified->get_error_message() ), __METHOD__, 'error' ); |
307 | 307 | } |
308 | 308 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return int|false Int: in lockdown. The value returned is the timestamp when lockdown ends. False: not in lockdown, or overridden by a constant. |
357 | 357 | */ |
358 | - public function in_lockdown(){ |
|
358 | + public function in_lockdown() { |
|
359 | 359 | |
360 | 360 | if ( $this->in_local_development() ) { |
361 | 361 | return false; |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | |
84 | 84 | $user_identifier = $passed_user_identifier; |
85 | 85 | |
86 | - if ( $this->in_lockdown() ){ |
|
86 | + if ( $this->in_lockdown() ) { |
|
87 | 87 | |
88 | 88 | $this->logging->log( 'Site is in lockdown mode, aborting login.', __METHOD__, 'error' ); |
89 | 89 | |
90 | - return new WP_Error( 'in-lockdown', __( 'TrustedLogin temporarily disabled.' , 'trustedlogin') ); |
|
90 | + return new WP_Error( 'in-lockdown', __( 'TrustedLogin temporarily disabled.', 'trustedlogin' ) ); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // When passed in the endpoint URL, the unique ID will be the raw value, not the hash. |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $approved = $this->check_approved_identifier( $secret_id ); |
112 | 112 | |
113 | 113 | // Don't lock-down the site, since there could have been errors related to remote validation |
114 | - if ( is_wp_error( $approved ) ){ |
|
114 | + if ( is_wp_error( $approved ) ) { |
|
115 | 115 | |
116 | 116 | $this->logging->log( |
117 | 117 | sprintf( |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | 'notice' |
153 | 153 | ); |
154 | 154 | |
155 | - return new WP_Error( 'brute-force-detected', 'Login aborted due to potential brute force detection.'); |
|
155 | + return new WP_Error( 'brute-force-detected', 'Login aborted due to potential brute force detection.' ); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | return true; |
@@ -165,12 +165,12 @@ discard block |
||
165 | 165 | */ |
166 | 166 | private function maybe_add_used_accesskey( $user_identifier = '' ) { |
167 | 167 | |
168 | - $used_accesskeys = (array) get_site_transient( $this->used_accesskey_transient ); |
|
168 | + $used_accesskeys = (array)get_site_transient( $this->used_accesskey_transient ); |
|
169 | 169 | |
170 | 170 | // This is a new access key |
171 | 171 | if ( ! in_array( $user_identifier, $used_accesskeys, true ) ) { |
172 | 172 | |
173 | - $used_accesskeys[] = $user_identifier; |
|
173 | + $used_accesskeys[ ] = $user_identifier; |
|
174 | 174 | |
175 | 175 | $transient_set = set_site_transient( $this->used_accesskey_transient, $used_accesskeys, self::ACCESSKEY_LIMIT_EXPIRY ); |
176 | 176 | |
@@ -190,19 +190,19 @@ discard block |
||
190 | 190 | */ |
191 | 191 | private function get_ip() { |
192 | 192 | |
193 | - if ( ! isset( $_SERVER['REMOTE_ADDR'] ) ) { |
|
193 | + if ( ! isset( $_SERVER[ 'REMOTE_ADDR' ] ) ) { |
|
194 | 194 | return null; |
195 | 195 | } |
196 | 196 | |
197 | - $ip = wp_unslash( $_SERVER['REMOTE_ADDR'] ); |
|
197 | + $ip = wp_unslash( $_SERVER[ 'REMOTE_ADDR' ] ); |
|
198 | 198 | |
199 | 199 | $ip = trim( $ip ); |
200 | 200 | |
201 | - if ( ! defined('TL_DOING_TESTS') ) { |
|
201 | + if ( ! defined( 'TL_DOING_TESTS' ) ) { |
|
202 | 202 | $ip = filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_NO_PRIV_RANGE ); |
203 | 203 | } |
204 | 204 | |
205 | - return (string) $ip; |
|
205 | + return (string)$ip; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | $body = array( |
228 | 228 | 'timestamp' => time(), |
229 | - 'user_agent' => isset( $_SERVER['HTTP_USER_AGENT'] ) ? substr( $_SERVER['HTTP_USER_AGENT'], 0, 255 ) : '', |
|
229 | + 'user_agent' => isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) ? substr( $_SERVER[ 'HTTP_USER_AGENT' ], 0, 255 ) : '', |
|
230 | 230 | 'user_ip' => $this->get_ip(), |
231 | 231 | 'site_url' => get_site_url(), |
232 | 232 | ); |
@@ -265,13 +265,13 @@ discard block |
||
265 | 265 | */ |
266 | 266 | $body = array( |
267 | 267 | 'timestamp' => time(), |
268 | - 'user_agent' => isset( $_SERVER['HTTP_USER_AGENT'] ) ? substr( $_SERVER['HTTP_USER_AGENT'], 0, 255 ) : '', |
|
268 | + 'user_agent' => isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) ? substr( $_SERVER[ 'HTTP_USER_AGENT' ], 0, 255 ) : '', |
|
269 | 269 | 'user_ip' => $this->get_ip(), |
270 | 270 | 'site_url' => get_site_url(), |
271 | 271 | ); |
272 | 272 | |
273 | 273 | $remote = new Remote( $this->config, $this->logging ); |
274 | - $api_response = $remote->send( self::BRUTE_FORCE_ENDPOINT , $body, 'POST' ); |
|
274 | + $api_response = $remote->send( self::BRUTE_FORCE_ENDPOINT, $body, 'POST' ); |
|
275 | 275 | |
276 | 276 | if ( is_wp_error( $api_response ) ) { |
277 | 277 | return $api_response; |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | $notified = $this->report_lockdown(); |
304 | 304 | |
305 | - if ( is_wp_error( $notified ) ){ |
|
305 | + if ( is_wp_error( $notified ) ) { |
|
306 | 306 | $this->logging->log( sprintf( 'Could not notify TrustedLogin (%s)', $notified->get_error_message() ), __METHOD__, 'error' ); |
307 | 307 | } |
308 | 308 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return int|false Int: in lockdown. The value returned is the timestamp when lockdown ends. False: not in lockdown, or overridden by a constant. |
357 | 357 | */ |
358 | - public function in_lockdown(){ |
|
358 | + public function in_lockdown() { |
|
359 | 359 | |
360 | 360 | if ( $this->in_local_development() ) { |
361 | 361 | return false; |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | namespace GravityView\TrustedLogin; |
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | -if ( ! defined('ABSPATH') ) { |
|
16 | +if ( ! defined( 'ABSPATH' ) ) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | $user_ids = get_users( $args ); |
131 | 131 | |
132 | - return empty( $user_ids ) ? false : (int) $user_ids[0]; |
|
132 | + return empty( $user_ids ) ? false : (int)$user_ids[ 0 ]; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | |
219 | 219 | $i = 1; |
220 | 220 | $new_username = $username; |
221 | - while( username_exists( $new_username ) ) { |
|
221 | + while ( username_exists( $new_username ) ) { |
|
222 | 222 | $new_username = sprintf( '%s %d', $username, $i + 1 ); |
223 | 223 | } |
224 | 224 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | $expires = $this->get_expiration( $support_user, false, true ); |
275 | 275 | |
276 | 276 | // This user has expired, but the cron didn't run... |
277 | - if ( $expires && time() > (int) $expires ) { |
|
277 | + if ( $expires && time() > (int)$expires ) { |
|
278 | 278 | |
279 | 279 | $this->logging->log( 'The user was supposed to expire on ' . $expires . '; revoking now.', __METHOD__, 'warning' ); |
280 | 280 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | |
350 | 350 | $user = get_users( $args ); |
351 | 351 | |
352 | - return empty( $user ) ? null : $user[0]; |
|
352 | + return empty( $user ) ? null : $user[ 0 ]; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
@@ -406,8 +406,8 @@ discard block |
||
406 | 406 | public function get_first() { |
407 | 407 | $support_users = $this->get_all(); |
408 | 408 | |
409 | - if( $support_users ) { |
|
410 | - return $support_users[0]; |
|
409 | + if ( $support_users ) { |
|
410 | + return $support_users[ 0 ]; |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | return null; |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | 'number' => 1, |
490 | 490 | ) ); |
491 | 491 | |
492 | - $reassign_id = empty( $admins ) ? null : $admins[0]->ID; |
|
492 | + $reassign_id = empty( $admins ) ? null : $admins[ 0 ]->ID; |
|
493 | 493 | |
494 | 494 | $this->logging->log( 'Reassign user ID: ' . var_export( $reassign_id, true ), __METHOD__, 'info' ); |
495 | 495 |