1111 * Plugin Name: Fail2WP
1212 * Plugin URI: https://code.webbplatsen.net/wordpress/fail2wp/
1313 * Description: Security plugin for WordPress with support for Fail2ban and Cloudflare
14- * Version: 1.2.3
14+ * Version: 1.2.4
1515 * Author: WebbPlatsen, Joaquim Homrighausen <joho@webbplatsen.se>
1616 * Author URI: https://webbplatsen.se/
1717 * License: GPL-2.0+
2020 * Domain Path: /languages
2121 *
2222 * fail2wp.php
23- * Copyright (C) 2020-2024 Joaquim Homrighausen; all rights reserved.
23+ * Copyright (C) 2020-2025 Joaquim Homrighausen; all rights reserved.
2424 * Development sponsored by WebbPlatsen i Sverige AB, www.webbplatsen.se
2525 *
2626 * This file is part of Fail2WP. Fail2WP is free software.
@@ -1042,10 +1042,10 @@ public function fail2wp_rest_pre_dispatch( $result, \WP_REST_Server $rest_server
10421042 * according to our settings.
10431043 *
10441044 * @since 1.1.0
1045- * @param WP_Error $errors.
1045+ * @param \ WP_Error $errors.
10461046 * @param string $sanitized_user_login.
10471047 * @param string $user_email.
1048- * @return WP_Error With or without errors
1048+ * @return \ WP_Error With or without errors
10491049 */
10501050 public function fail2wp_admin_check_new_user ( \WP_Error $ errors , string $ user_login , string $ user_email ) {
10511051 // apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email );
@@ -1249,6 +1249,8 @@ public function fail2wp_admin_alert_new_users_admin() {
12491249 * @since 1.1.0
12501250 */
12511251 public function fail2wp_admin_alert_new_users_null () {
1252+ global $ wp ;
1253+
12521254 echo '<div class="notice notice-error"><br/> ' .
12531255 '<span class="dashicons dashicons-shield" style="font-size:24x;"></span> ' .
12541256 esc_html__ ( 'User registration is enabled, but no role has been configured ' , 'fail2wp ' ) .
@@ -1940,18 +1942,18 @@ public function fail2wp_settings() {
19401942 *
19411943 * @since 1.0.0
19421944 */
1943- public function fail2wp_setting_sanitize_site_label ( $ input ) {
1945+ public function fail2wp_setting_sanitize_site_label ( $ input ) : string {
19441946 if ( ! is_admin ( ) || ! is_user_logged_in () || ! current_user_can ( 'administrator ' ) ) {
1945- return ;
1947+ return ( '' ) ;
19461948 }
19471949 if ( $ this ->fail2wp_have_mbstring ) {
19481950 return ( mb_substr ( sanitize_text_field ( $ input ), 0 , 200 ) );
19491951 }
19501952 return ( substr ( sanitize_text_field ( $ input ), 0 , 200 ) );
19511953 }
1952- public function fail2wp_setting_sanitize_roles ( $ input ) {
1954+ public function fail2wp_setting_sanitize_roles ( $ input ) : string {
19531955 if ( ! is_admin ( ) || ! is_user_logged_in () || ! current_user_can ( 'administrator ' ) ) {
1954- return ;
1956+ return ( '' ) ;
19551957 }
19561958 $ available_roles = $ this ->fail2wp_get_wp_roles ();
19571959 $ return_val = array ();
@@ -1966,9 +1968,9 @@ public function fail2wp_setting_sanitize_roles( $input ) {
19661968 }
19671969 return ( wp_json_encode ( $ return_val ) );
19681970 }
1969- public function fail2wp_setting_sanitize_block_ns ( $ input ) {
1971+ public function fail2wp_setting_sanitize_block_ns ( $ input ) : string {
19701972 if ( ! is_admin ( ) || ! is_user_logged_in () || ! current_user_can ( 'administrator ' ) ) {
1971- return ;
1973+ return ( '' ) ;
19721974 }
19731975 $ namespaces = $ this ->fail2wp_get_rest_ns ();
19741976 $ return_val = array ();
@@ -1982,9 +1984,9 @@ public function fail2wp_setting_sanitize_block_ns( $input ) {
19821984 }
19831985 return ( wp_json_encode ( $ return_val ) );
19841986 }
1985- public function fail2wp_setting_sanitize_block_routes ( $ input ) {
1987+ public function fail2wp_setting_sanitize_block_routes ( $ input ) : string {
19861988 if ( ! is_admin ( ) || ! is_user_logged_in () || ! current_user_can ( 'administrator ' ) ) {
1987- return ;
1989+ return ( '' ) ;
19881990 }
19891991 $ return_val = array ();
19901992 if ( is_array ( $ input ) ) {
@@ -1997,18 +1999,18 @@ public function fail2wp_setting_sanitize_block_routes( $input ) {
19971999 }
19982000 return ( wp_json_encode ( $ return_val ) );
19992001 }
2000- public function fail2wp_setting_sanitize_advanced ( $ input ) {
2002+ public function fail2wp_setting_sanitize_advanced ( $ input ) : string {
20012003 if ( ! is_admin ( ) || ! is_user_logged_in () || ! current_user_can ( 'administrator ' ) ) {
2002- return ;
2004+ return ( '' ) ;
20032005 }
20042006 if ( $ this ->fail2wp_have_mbstring ) {
20052007 return ( mb_substr ( sanitize_text_field ( $ input ), 0 , 200 ) );
20062008 }
20072009 return ( substr ( sanitize_text_field ( $ input ), 0 , 200 ) );
20082010 }
2009- public function fail2wp_setting_sanitize_textarea_setting ( $ input ) {
2011+ public function fail2wp_setting_sanitize_textarea_setting ( $ input ) : string {
20102012 if ( ! is_admin ( ) || ! is_user_logged_in () || ! current_user_can ( 'administrator ' ) ) {
2011- return ;
2013+ return ( '' ) ;
20122014 }
20132015 $ output = array ();
20142016 $ original_input = sanitize_textarea_field ( $ input );
@@ -2048,9 +2050,9 @@ public function fail2wp_setting_sanitize_textarea_setting( $input ) {
20482050 $ input = @ wp_json_encode ( $ output );
20492051 return ( $ input );
20502052 }
2051- public function fail2wp_setting_sanitize_username_length ( $ input ) {
2053+ public function fail2wp_setting_sanitize_username_length ( $ input ) : string {
20522054 if ( ! is_admin ( ) || ! is_user_logged_in () || ! current_user_can ( 'administrator ' ) ) {
2053- return ;
2055+ return ( '' ) ;
20542056 }
20552057 // We really should strip everything but numbers here, but ...
20562058 $ input = (int ) sanitize_text_field ( $ input );
@@ -2061,9 +2063,9 @@ public function fail2wp_setting_sanitize_username_length( $input ) {
20612063 }
20622064 return ( $ input );
20632065 }
2064- public function fail2wp_setting_sanitize_dnscache ( $ input ) {
2066+ public function fail2wp_setting_sanitize_dnscache ( $ input ) : int {
20652067 if ( ! is_admin ( ) || ! is_user_logged_in () || ! current_user_can ( 'administrator ' ) ) {
2066- return ;
2068+ return ( 10080 ) ;
20672069 }
20682070 // We really should strip everything but numbers here, but ...
20692071 $ input = (int ) sanitize_text_field ( $ input );
@@ -2500,7 +2502,6 @@ public function fail2wp_setting_also_log_php() {
25002502 echo '</div> ' ;
25012503 }
25022504 public function fail2wp_setting_cloudflare_check () {
2503- $ option_val = $ this ->fail2wp_cloudflare_check ;
25042505 echo '<div class="fail2wp-role-option"> ' ;
25052506 echo '<label for="fail2wp-cloudflare-check"> ' ;
25062507 echo '<input type="checkbox" name="fail2wp-cloudflare-check" id="fail2wp-cloudflare-check" value="1" ' . ( checked ( $ this ->fail2wp_cloudflare_check , 1 , false ) ) . '/> ' ;
0 commit comments