Security
in package
This class handles various aspects related to the security of the theme.
Table of Contents
Methods
- disable_rest_api() : WP_Error|null|bool
- Disable the REST API for unauthorized users.
- hide_wp_version() : string
- Hide WordPress version number from RSS feeds.
- limit_login_attempts_by_ip() : WP_User|WP_Error
- Limit login attempts by IP address.
- register() : void
- Registers various hooks and functionalities for the security class.
- reset_failed_login_attempts_by_ip() : mixed
- Reset failed login attempts by IP address on successful login.
- should_reset_attempts_by_ip() : bool
- Determine whether to reset the login attempts for the IP address.
- static_wordpress_errors() : string
- Return a static error message for login errors.
- track_failed_login_attempts_by_ip() : mixed
- Track failed login attempts by IP address.
Methods
disable_rest_api()
Disable the REST API for unauthorized users.
public
disable_rest_api(WP_Error|null|bool $result) : WP_Error|null|bool
Parameters
- $result : WP_Error|null|bool
-
The authentication result.
Return values
WP_Error|null|bool —Return the original result if authenticated, otherwise a WP_Error.
hide_wp_version()
Hide WordPress version number from RSS feeds.
public
hide_wp_version() : string
Return values
string —An empty string.
limit_login_attempts_by_ip()
Limit login attempts by IP address.
public
limit_login_attempts_by_ip(WP_User|WP_Error $user, string $password) : WP_User|WP_Error
Parameters
- $user : WP_User|WP_Error
-
The user object or WP_Error on failed authentication.
- $password : string
-
The password provided for authentication.
Return values
WP_User|WP_Error —The original user object if authenticated, otherwise a WP_Error.
register()
Registers various hooks and functionalities for the security class.
public
register() : void
reset_failed_login_attempts_by_ip()
Reset failed login attempts by IP address on successful login.
public
reset_failed_login_attempts_by_ip(string $user_login, WP_User $user) : mixed
Parameters
- $user_login : string
-
The username of the logged-in user.
- $user : WP_User
-
The user object of the logged-in user.
should_reset_attempts_by_ip()
Determine whether to reset the login attempts for the IP address.
public
should_reset_attempts_by_ip(string $ip_address, int $reset_interval) : bool
Parameters
- $ip_address : string
-
The IP address to check.
- $reset_interval : int
-
The reset interval in seconds.
Return values
bool —True if the attempts should be reset, false otherwise.
static_wordpress_errors()
Return a static error message for login errors.
public
static_wordpress_errors(string $error_message) : string
Parameters
- $error_message : string
-
The original error message.
Return values
string —The static error message.
track_failed_login_attempts_by_ip()
Track failed login attempts by IP address.
public
track_failed_login_attempts_by_ip(string $username) : mixed
Parameters
- $username : string
-
The username of the failed login attempt.