Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lordspace
Created March 16, 2013 04:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lordspace/5175010 to your computer and use it in GitHub Desktop.
Save lordspace/5175010 to your computer and use it in GitHub Desktop.
Removes an error message shown by Limit Login Attempts WordPress plugin. NN attemmpts remaining. We don't need to give info to the attacker. Making error null solves half of the problem. There is a wrapper with a red border which we will remove with : login_error_message_hide_empty_error_container
add_filter('login_head', create_function('$a', "wp_enqueue_script('jquery');"));
add_filter('login_errors', 'login_error_message');
add_action('login_footer', 'login_error_message_hide_empty_error_container');
/**
* Removes an error message shown by Limit Login Attempts plugin.
* NN attempts remaining. We don't need to give info to the attacker.
* Making error null solves half of the problem. There is a wrapper with
* a red border which we will remove with : login_error_message_hide_empty_error_container
*
* @param string $error
* @return string
* @see http://orbisius.com
*/
function login_error_message($error) {
$error_fmt = strip_tags($error);
// what about other languages other than english ?
if (preg_match('#\d+\s+attempts?\s+remaining\.?#si', $error_fmt)) {
$error = null;
}
return $error;
}
/**
* This removes the error container if it doens't have tags in it.
*/
function login_error_message_hide_empty_error_container() {
echo <<<BUFF_EOF
<script>
try {
if (jQuery.trim(jQuery('#login_error').text()) == '') {
jQuery('#login_error').remove();
}
} catch (e) {
}
</script>
BUFF_EOF;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment