Skip to content

Instantly share code, notes, and snippets.

@rdimascio
Last active June 26, 2021 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdimascio/453757df8e62d52272bd8ab3e965ae2b to your computer and use it in GitHub Desktop.
Save rdimascio/453757df8e62d52272bd8ab3e965ae2b to your computer and use it in GitHub Desktop.
<?php
// Include Main Stylesheet on Login Page
function my_custom_login() {
echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('stylesheet_directory') . '/assets/css/main.min.css" />';
}
add_action('login_head', 'my_custom_login');
// Add title to Login page
function custom_login_title($origtitle) {
return get_bloginfo('name') . ' Login';
}
add_filter('login_title', 'custom_login_title', 99);
// Add message to Login page
function custom_login_message() {
$message = "<h1 class=\"login-title\">Login</h1><p class=\"login-message\">Welcome back.</p>";
return $message;
}
add_filter('login_message', 'custom_login_message');
// Remove the WP default "shake" animation from Login page
function remove_loginshake() {
remove_action('login_head', 'wp_shake_js', 12);
}
add_action('login_head', 'remove_loginshake');
// Change WP default error message on Login page
function login_error_override() {
return 'Invalid email or password';
}
add_filter('login_errors', 'login_error_override');
// Automatically check the "Remember Me" on Login page
function login_checked_remember_me() {
add_filter( 'login_footer', 'rememberme_checked' );
}
add_action( 'init', 'login_checked_remember_me' );
function rememberme_checked() {
echo "<script>document.getElementById('rememberme').checked = true;</script>";
}
// Change the Password label on Login page
function change_labels( $translated_text, $text, $domain ) {
if ( 'Password' === $text ) {
$translated_text = 'Password <a id="pw_forgot" href="/">Forgot?</a>';
}
return $translated_text;
}
function register_change_labels_filter() {
add_filter( 'gettext', 'change_labels', 20, 3 );
}
add_action( 'login_head', 'register_change_labels_filter' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment