Last active
November 26, 2018 21:23
-
-
Save hearvox/848aa1c27d9ce150b9f23873b2bdf1e7 to your computer and use it in GitHub Desktop.
WordPress: Make CSS class name from site URL, e.g., to CSS select Stage and Dev sites
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 | |
// Make CSS class name from site URL. | |
$urlparts = parse_url( site_url() ); | |
$class_domain = 'site-' . str_replace( '.', '-', $urlparts [host] ); | |
?> | |
<body <?php body_class( $class_domain ); ?>> | |
?> | |
/* | |
Example of adding CSS badge over site logo only at Staging site: | |
.site-staging-example-com .site-logo:before { | |
content: 'Stage'; | |
position: absolute; | |
top: 1.2rem; | |
left: 5rem; | |
font-size: 1.25rem; | |
font-weight: 600; | |
background-color: rgba(3, 108, 177, 0.72); | |
padding: 0.2rem 0.5rem; | |
border-radius: 10px; | |
color: #fff; | |
transform: rotate(-12deg); | |
text-transform: uppercase; | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment