Skip to content

Instantly share code, notes, and snippets.

@wendycholbi
Last active December 21, 2015 08:18
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 wendycholbi/6276778 to your computer and use it in GitHub Desktop.
Save wendycholbi/6276778 to your computer and use it in GitHub Desktop.
Fix for an issue with Genesis 2.0 where custom header CSS is overridden, resulting in a misaligned header. This function replaces the genesis_custom_header_style function with your own. Set your custom header CSS in line 35, then add this function to functions.php or to a plugin. This code was written by Genesis Community Forum member CyBorge, a…
/*———- MDB - CUSTOMIZE HEADER OUTPUT ————— */
remove_action( 'wp_head', 'genesis_custom_header_style' );
add_action( 'wp_head', 'mh_custom_header_style' );
function mh_custom_header_style() {
//* Do nothing if custom header not supported
if ( ! current_theme_supports( 'custom-header' ) )
return;
//* Do nothing if user specifies their own callback
if ( get_theme_support( 'custom-header', 'wp-head-callback' ) )
return;
$output = '';
$header_image = get_header_image();
$text_color = get_header_textcolor();
//* If no options set, don't waste the output. Do nothing.
if ( empty( $header_image ) && ! display_header_text() && $text_color === get_theme_support( 'custom-header', 'default-text-color' ) )
return;
$header_selector = get_theme_support( 'custom-header', 'header-selector' );
$title_selector = genesis_html5() ? '.custom-header .site-title' : '.custom-header #title';
$desc_selector = genesis_html5() ? '.custom-header .site-description' : '.custom-header #description';
//* Header selector fallback
if ( ! $header_selector )
$header_selector = genesis_html5() ? '.custom-header .site-header' : '.custom-header #header';
//* Header image CSS, if exists
if ( $header_image )
$output .= sprintf( '%s { background: url(%s) no-repeat center top !important; }', $header_selector, esc_url( $header_image ) );
//* Header text color CSS, if showing text
if ( display_header_text() && $text_color !== get_theme_support( 'custom-header', 'default-text-color' ) )
$output .= sprintf( '%2$s a, %2$s a:hover, %3$s { color: #%1$s !important; }', esc_html( $text_color ), esc_html( $title_selector ), esc_html( $desc_selector ) );
if ( $output )
printf( '<style type="text/css">%s</style>' . "\n", $output );
}
/*———— END HEADER FIX MDB ———————————-*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment