Last active
April 16, 2019 14:06
-
-
Save srikat/e0f9efba51bb6beb042fab97dde31b12 to your computer and use it in GitHub Desktop.
Theme Logo in Genesis. https://sridharkatakam.com/theme-logo-genesis/
This file contains hidden or 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
add_filter( 'genesis_seo_title', 'custom_header_inline_logo', 10, 3 ); | |
/** | |
* Add an image inline in the site title element for the logo | |
* | |
* @param string $title Current markup of title. | |
* @param string $inside Markup inside the title. | |
* @param string $wrap Wrapping element for the title. | |
* | |
* @author @_AlphaBlossom | |
* @author @_neilgee | |
* @author @_JiveDig | |
* @author @_srikat | |
*/ | |
function custom_header_inline_logo( $title, $inside, $wrap ) { | |
// If the custom logo function and custom logo exist, set the logo image element inside the wrapping tags. | |
if ( function_exists( 'has_custom_logo' ) && has_custom_logo() ) { | |
$inside = sprintf( '<span class="screen-reader-text">%s</span>%s', esc_html( get_bloginfo( 'name' ) ), get_custom_logo() ); | |
} else { | |
// If no custom logo, wrap around the site name. | |
$inside = sprintf( '<a href="%s">%s</a>', trailingslashit( home_url() ), esc_html( get_bloginfo( 'name' ) ) ); | |
} | |
// Build the title. | |
$title = genesis_markup( array( | |
'open' => sprintf( "<{$wrap} %s>", genesis_attr( 'site-title' ) ), | |
'close' => "</{$wrap}>", | |
'content' => $inside, | |
'context' => 'site-title', | |
'echo' => false, | |
'params' => array( | |
'wrap' => $wrap, | |
), | |
) ); | |
return $title; | |
} | |
add_filter( 'genesis_attr_site-description', 'custom_add_site_description_class' ); | |
/** | |
* Add class for screen readers to site description. | |
* This will keep the site description markup but will not have any visual presence on the page | |
* This runs if there is a logo image set in the Customizer. | |
* | |
* @param array $attributes Current attributes. | |
* | |
* @author @_neilgee | |
* @author @_srikat | |
*/ | |
function custom_add_site_description_class( $attributes ) { | |
if ( function_exists( 'has_custom_logo' ) && has_custom_logo() ) { | |
$attributes['class'] .= ' screen-reader-text'; | |
} | |
return $attributes; | |
} |
This file contains hidden or 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
//* Add support for custom header | |
add_theme_support( 'custom-header', array( | |
'width' => 600, | |
'height' => 160, | |
'header-selector' => '.site-title a', | |
'header-text' => false, | |
'flex-height' => true, | |
) ); |
This file contains hidden or 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
// Add support for custom logo. | |
add_theme_support( 'custom-logo', array( | |
'width' => 600, | |
'height' => 160, | |
'flex-width' => true, | |
'flex-height' => true, | |
) ); |
This file contains hidden or 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
.wp-custom-logo .title-area { | |
max-width: none; | |
margin-top: 0; | |
} | |
.wp-custom-logo .site-title { | |
text-indent: 0; | |
} | |
.wp-custom-logo .site-title > a { | |
min-height: 0; | |
} | |
.custom-logo-link { | |
display: block; | |
} | |
.custom-logo { | |
vertical-align: top; | |
} |
This file contains hidden or 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
/* ## Screen Reader Text | |
--------------------------------------------- */ | |
.screen-reader-shortcut, | |
.screen-reader-text, | |
.screen-reader-text span { | |
border: 0; | |
clip: rect(0, 0, 0, 0); | |
height: 1px; | |
overflow: hidden; | |
position: absolute !important; | |
width: 1px; | |
word-wrap: normal !important; | |
} | |
.screen-reader-text:focus, | |
.screen-reader-shortcut:focus, | |
.genesis-nav-menu .search input[type="submit"]:focus, | |
.widget_search input[type="submit"]:focus { | |
background: #fff; | |
box-shadow: 0 0 2px 2px rgba(0,0,0,.6); | |
clip: auto !important; | |
color: #333; | |
display: block; | |
font-size: 1em; | |
font-weight: bold; | |
height: auto; | |
padding: 15px 23px 14px; | |
text-decoration: none; | |
width: auto; | |
z-index: 100000; /* Above WP toolbar. */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment