Skip to content

Instantly share code, notes, and snippets.

@vfontjr
Created May 2, 2020 16:36
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 vfontjr/5a0356998fc97052d13349f376eb9b37 to your computer and use it in GitHub Desktop.
Save vfontjr/5a0356998fc97052d13349f376eb9b37 to your computer and use it in GitHub Desktop.
<?php
add_action( 'genesis_doctype', 'genesis_do_doctype' );
/**
* Echo the doctype and opening markup.
*
* If you are going to replace the doctype with a custom one, you must remember to include the opening <html> and
* <head> elements too, along with the proper attributes.
*
* It would be beneficial to also include the <meta> tag for content type.
*
* The default doctype is XHTML v1.0 Transitional, unless HTML support os present in the child theme.
*
* @since 1.3.0
*
* @uses genesis_html() Check for HTML5 support.
* @uses genesis_html5_doctype() Markup for HTML5 output.
* @uses genesis_xhtml_doctype() Markup for XHTML output.
*/
function genesis_do_doctype() {
if ( genesis_html5() )
genesis_html5_doctype();
else
genesis_xhtml_doctype();
}
/**
* XHTML 1.0 Transitional doctype markup.
*
* @since 2.0.0
*/
function genesis_xhtml_doctype() {
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes( 'xhtml' ); ?>>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php bloginfo( 'charset' ); ?>" />
<?php
}
/**
* HTML5 doctype markup.
*
* @since 2.0.0
*/
function genesis_html5_doctype() {
?><!DOCTYPE html>
<html <?php language_attributes( 'html' ); ?>>
<head <?php echo genesis_attr( 'head' ); ?>>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<?php
}
<?php
add_filter('genesis_attr_head', 'vmf_head_attributes');
function vmf_head_attributes( $attributes ) {
$attributes['itemscope'] = 'itemscope';
$attributes['itemtype'] = 'http://schema.org/WebSite';
return $attributes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment