Skip to content

Instantly share code, notes, and snippets.

@neilgee
Last active February 23, 2017 01:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilgee/83abf5affc2af26a527e to your computer and use it in GitHub Desktop.
Save neilgee/83abf5affc2af26a527e to your computer and use it in GitHub Desktop.
Change Genesis Header Structure and Markup Output
<?php
/**
* Genesis Framework.
*
* WARNING: This file is part of the core Genesis Framework. DO NOT edit this file under any circumstances.
* Please do all modifications in the form of a child theme.
*
* @package Genesis\Templates
* @author StudioPress
* @license GPL-2.0+
* @link http://my.studiopress.com/themes/genesis/
*/
do_action( 'genesis_doctype' );
do_action( 'genesis_title' );
do_action( 'genesis_meta' );
wp_head(); // We need this for plugins.
?>
</head>
<?php
genesis_markup( array(
'open' => '<body %s>',
'context' => 'body',
) );
do_action( 'genesis_before' );
genesis_markup( array(
'open' => '<div %s>',
'context' => 'site-container',
) );
do_action( 'genesis_before_header' );
do_action( 'genesis_header' );
do_action( 'genesis_after_header' );
genesis_markup( array(
'open' => '<div %s>',
'context' => 'site-inner',
) );
genesis_structural_wrap( 'site-inner' );
<?php // <- Don't add me in
// Gist updated to use code from Genesis Framework 2.4.2
//remove initial header functions
remove_action( 'genesis_header', 'genesis_header_markup_open', 5 );
remove_action( 'genesis_header', 'genesis_header_markup_close', 15 );
remove_action( 'genesis_header', 'genesis_do_header' );
//add in the new header markup - prefix the function name - here sm_ is used
add_action( 'genesis_header', 'sm_genesis_header_markup_open', 5 );
add_action( 'genesis_header', 'sm_genesis_header_markup_close', 15 );
add_action( 'genesis_header', 'sm_genesis_do_header' );
//New Header functions
function sm_genesis_header_markup_open() {
genesis_markup( array(
'html5' => '<header %s>',
'context' => 'site-header',
) );
// Added in content
echo '<div class="header-ghost"></div>';
genesis_structural_wrap( 'header' );
}
function sm_genesis_header_markup_close() {
genesis_structural_wrap( 'header', 'close' );
genesis_markup( array(
'close' => '</header>',
'context' => 'site-header',
) );
}
function sm_genesis_do_header() {
global $wp_registered_sidebars;
genesis_markup( array(
'open' => '<div %s>',
'context' => 'title-area',
) );
do_action( 'genesis_site_title' );
do_action( 'genesis_site_description' );
genesis_markup( array(
'close' => '</div>',
'context' => 'title-area',
) );
if ( ( isset( $wp_registered_sidebars['header-right'] ) && is_active_sidebar( 'header-right' ) ) || has_action( 'genesis_header_right' ) ) {
genesis_markup( array(
'open' => '<div %s>' . genesis_sidebar_title( 'header-right' ),
'context' => 'header-widget-area',
) );
do_action( 'genesis_header_right' );
add_filter( 'wp_nav_menu_args', 'genesis_header_menu_args' );
add_filter( 'wp_nav_menu', 'genesis_header_menu_wrap' );
dynamic_sidebar( 'header-right' );
remove_filter( 'wp_nav_menu_args', 'genesis_header_menu_args' );
remove_filter( 'wp_nav_menu', 'genesis_header_menu_wrap' );
genesis_markup( array(
'close' => '</div>',
'context' => 'header-widget-area',
) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment