Skip to content

Instantly share code, notes, and snippets.

@braddalton
Last active March 3, 2018 04:49
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 braddalton/e9740b1f9fafcc260cc62c6d82b94096 to your computer and use it in GitHub Desktop.
Save braddalton/e9740b1f9fafcc260cc62c6d82b94096 to your computer and use it in GitHub Desktop.
add_action( 'genesis_site_description', 'genesis_seo_site_description' );
/**
* Echo the site description into the header.
*
* Depending on the SEO option set by the user, this will either be wrapped in an `h1` or `p` element.
*
* Applies the `genesis_seo_description` filter before echoing.
*
* @since 1.1.0
*/
function genesis_seo_site_description() {
// Set what goes inside the wrapping tags.
$inside = esc_html( get_bloginfo( 'description' ) );
// Determine which wrapping tags to use.
$wrap = genesis_is_root_page() && 'description' === genesis_get_seo_option( 'home_h1_on' ) ? 'h1' : 'p';
// Wrap homepage site description in p tags if static front page.
$wrap = is_front_page() && ! is_home() ? 'p' : $wrap;
// And finally, $wrap in h2 if HTML5 & semantic headings enabled.
$wrap = genesis_html5() && genesis_get_seo_option( 'semantic_headings' ) ? 'h2' : $wrap;
/**
* Site description wrapping element
*
* The wrapping element for the site description.
*
* @since 2.2.3
*
* @param string $wrap The wrapping element (h1, h2, p, etc.).
*/
$wrap = apply_filters( 'genesis_site_description_wrap', $wrap );
// Build the description.
$description = genesis_markup( array(
'open' => sprintf( "<{$wrap} %s>", genesis_attr( 'site-description' ) ),
'close' => "</{$wrap}>",
'content' => $inside,
'context' => 'site-description',
'echo' => false,
'params' => array(
'wrap' => $wrap,
),
) );
// Output (filtered).
$output = $inside ? apply_filters( 'genesis_seo_description', $description, $inside, $wrap ) : '';
echo $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment