Last active
July 29, 2016 19:37
-
-
Save michaeldozark/0e99184527f0ced712d7 to your computer and use it in GitHub Desktop.
Style the login screen. Make sure to read my comment below as well.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Login Functions | |
* | |
* Functions and filters that run only on the WordPress login screen. | |
* | |
* @package Slimline | |
* @subpackage Login | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) exit; // exit if accessed directly | |
add_action( 'login_head', 'slimline_login_logo' ); // replace the default login logo with the uploaded custom header | inc/login.php | |
add_filter( 'login_headertitle', 'slimline_login_headertitle' ); // replace login logo title with site name | inc/login.php | |
add_filter( 'login_headerurl', 'slimline_login_headerurl' ); // replace login logo url with home url | inc/login.php | |
/** | |
* slimline_login_headertitle function | |
* | |
* Replaces the default WordPress login logo title attribute with the site name. | |
* | |
* @return string Site name | |
* @uses get_bloginfo() to return the blog `name` property | |
* @uses esc_attr_x() to sanitize the name for inclusion in an html attribute and allow for translation | |
* @since 0.1.0 | |
*/ | |
function slimline_login_headertitle() { | |
return esc_attr_x( get_bloginfo( 'name' ), 'link title', 'slimline' ); | |
} | |
/** | |
* slimline_login_headerurl function | |
* | |
* Replaces the default WordPress login logo href attribute with the home url. | |
* | |
* @return string Home url | |
* @uses home_url() to return the root URL for the site | |
* @uses esc_url() to sanitize the url | |
* @since 0.1.0 | |
*/ | |
function slimline_login_headerurl() { | |
return esc_url( home_url( '/' ) ); | |
} | |
/** | |
* slimline_login_logo function | |
* | |
* Outputs CSS that styles the logo based on the uploaded header image. | |
* | |
* @return string CSS for styling the logo | |
* @since 0.1.0 | |
*/ | |
function slimline_login_logo() { | |
echo " | |
<style> | |
.login h1 a { | |
background-image: url( '" . trailingslashit( get_stylesheet_directory_uri() ) . "images/logo.png' ); | |
background-size: 100%; | |
height: 116px; | |
left: 50%; | |
margin-left: -137px; | |
padding-bottom: 28px; | |
position: relative; | |
top: 0; | |
width: 273px; | |
} | |
</style> | |
"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using this, pay special attention to the
slimline_login_logo
function (the last function). You will need to edit the CSS properties like so:If your theme uses a custom logo function, you can make the function use the user-selected logo. For example, if you are using the default WordPress custom header functionality, you can edit the function to read as so:
If you are using an Elegant Theme, this will probably work (make sure to replace
vertex_logo
with the correct option for the specific theme):...and so on.