Skip to content

Instantly share code, notes, and snippets.

@bacoords
Created January 10, 2024 03:42
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 bacoords/9c58b39de36cacec5be306b66f307c12 to your computer and use it in GitHub Desktop.
Save bacoords/9c58b39de36cacec5be306b66f307c12 to your computer and use it in GitHub Desktop.
<?php
/**
* Custom login page design
*/
function custom_login_page_design() {
$colors = wp_get_global_styles( array( 'color' ) );
$variables = wp_get_global_stylesheet( array( 'variables' ) );
?>
<style type="text/css">
<?php echo esc_html( $variables ); ?>
body.login {
background-color: <?php echo esc_attr( $colors['background'] ); ?>;
color: <?php echo esc_attr( $colors['text'] ); ?>;
}
</style>
<?php
$custom_logo_id = get_theme_mod( 'custom_logo' );
if ( $custom_logo_id ) {
$image = wp_get_attachment_image_src( $custom_logo_id, 'medium' );
?>
<style type="text/css">
#login h1 a, .login h1 a {
background-image: url(<?php echo esc_attr( $image[0] ); ?>);
height:<?php echo esc_attr( $image[2] ); ?>px;
width:<?php echo esc_attr( $image[1] ); ?>px;
max-width: 100%;
background-size: contain;
background-repeat: no-repeat;
padding-bottom: 30px;
}
</style>
<?php
}
}
add_action( 'login_enqueue_scripts', 'custom_login_page_design' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment