| @@ -284,9 +284,11 @@ | ||
| 284 | 284 | * @return bool |
| 285 | 285 | */ |
| 286 | 286 | private function is_insecure_username( $username ) { |
| 287 | 287 | $username = strtolower( trim( $username ) ); |
| 288 | - $insecure_usernames = $this->options['insecure_usernames'] ?? array(); | |
| 288 | + // Vigilante_Settings::list_or_shipped(): an empty list of a setting with | |
| 289 | + // no field on screen is a leftover, not a choice. See its docblock. | |
| 290 | + $insecure_usernames = $this->get_insecure_usernames(); | |
| 289 | 291 | |
| 290 | 292 | return in_array( $username, array_map( 'strtolower', $insecure_usernames ), true ); |
| 291 | 293 | } |
| 292 | 294 | |
| @@ -988,9 +990,14 @@ | ||
| 988 | 990 | * |
| 989 | 991 | * @return array |
| 990 | 992 | */ |
| 991 | 993 | public function get_insecure_usernames() { |
| 992 | - return $this->options['insecure_usernames'] ?? array(); | |
| 994 | + // The single reader of this list, so what blocks and what the screen | |
| 995 | + // reports can never disagree. | |
| 996 | + return Vigilante_Settings::list_or_shipped( | |
| 997 | + $this->options['insecure_usernames'] ?? array(), | |
| 998 | + array( 'user_security', 'insecure_usernames' ) | |
| 999 | + ); | |
| 993 | 1000 | } |
| 994 | 1001 | |
| 995 | 1002 | /** |
| 996 | 1003 | * Check for existing insecure admin users |
| @@ -1341,9 +1348,14 @@ | ||
| 1341 | 1348 | return; |
| 1342 | 1349 | } |
| 1343 | 1350 | |
| 1344 | 1351 | $settings = $this->options['registration_approval'] ?? array(); |
| 1345 | - $affected_roles = $settings['affected_roles'] ?? array( 'subscriber' ); | |
| 1352 | + // Vigilante_Settings::list_or_shipped(): an empty list of a setting with | |
| 1353 | + // no field on screen is a leftover, not a choice. See its docblock. | |
| 1354 | + $affected_roles = Vigilante_Settings::list_or_shipped( | |
| 1355 | + $settings['affected_roles'] ?? array(), | |
| 1356 | + array( 'user_security', 'registration_approval', 'affected_roles' ) | |
| 1357 | + ); | |
| 1346 | 1358 | |
| 1347 | 1359 | // Check if user role requires approval |
| 1348 | 1360 | $user_roles = $user->roles; |
| 1349 | 1361 | $needs_approval = array_intersect( $user_roles, $affected_roles ); |
| @@ -3232,9 +3244,9 @@ | ||
| 3232 | 3244 | |
| 3233 | 3245 | // Check if this user's role requires approval |
| 3234 | 3246 | $needs_approval = false; |
| 3235 | 3247 | if ( ! empty( $registration_approval['enabled'] ) ) { |
| 3236 | - $affected_roles = $registration_approval['affected_roles'] ?? array( 'subscriber' ); | |
| 3248 | + $affected_roles = Vigilante_Settings::list_or_shipped( $registration_approval['affected_roles'] ?? array(), array( 'user_security', 'registration_approval', 'affected_roles' ) ); | |
| 3237 | 3249 | $needs_approval = ! empty( array_intersect( $user->roles, $affected_roles ) ); |
| 3238 | 3250 | } |
| 3239 | 3251 | |
| 3240 | 3252 | // Check if email verification is enabled |
| @@ -3346,9 +3358,9 @@ | ||
| 3346 | 3358 | if ( empty( $registration_approval['enabled'] ) ) { |
| 3347 | 3359 | return false; |
| 3348 | 3360 | } |
| 3349 | 3361 | |
| 3350 | - $affected_roles = $registration_approval['affected_roles'] ?? array( 'subscriber' ); | |
| 3362 | + $affected_roles = Vigilante_Settings::list_or_shipped( $registration_approval['affected_roles'] ?? array(), array( 'user_security', 'registration_approval', 'affected_roles' ) ); | |
| 3351 | 3363 | return ! empty( array_intersect( $user->roles, $affected_roles ) ); |
| 3352 | 3364 | } |
| 3353 | 3365 | |
| 3354 | 3366 | /** |