ERROR: Invalid login credentials.', '24tt-login-security-and-brander' ); } /** * Blocks frontend author archive routing which exposes usernames. * Intercepts both raw queries (?author=1) and pretty permalinks (/author/username/). */ public function block_author_enumeration() { // If it is an author archive OR someone is passing a numeric author ID in the URL... if ( is_author() || ( isset( $_GET['author'] ) && is_numeric( $_GET['author'] ) ) ) { // Silently bounce them to the homepage before the username can be leaked. wp_safe_redirect( home_url() ); exit; } } /** * Removes the /users endpoint from the REST API for non-authenticated users. * This prevents bots from scraping the API to build lists of admin usernames. * * @param array $endpoints The current REST API endpoints. * @return array The filtered REST API endpoints. */ public function block_rest_user_endpoints( $endpoints ) { // Only block if the user doesn't have the capability to list users natively (e.g., not an Admin) if ( ! current_user_can( 'list_users' ) ) { if ( isset( $endpoints['/wp/v2/users'] ) ) { unset( $endpoints['/wp/v2/users'] ); } if ( isset( $endpoints['/wp/v2/users/(?P[\d]+)'] ) ) { unset( $endpoints['/wp/v2/users/(?P[\d]+)'] ); } } return $endpoints; } }