Created
September 20, 2019 13:27
-
-
Save premanshup/57636226befdbf71cfae729a96c83437 to your computer and use it in GitHub Desktop.
Remove all schema from Astra theme.
This file contains 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
<?php | |
add_filter( 'astra_schema_body', '__return_empty_string' ); | |
add_action( | |
'init', | |
function() { | |
remove_action( 'astra_masthead_content', 'astra_site_branding_markup', 8 ); | |
} | |
); | |
add_action( | |
'astra_masthead_content', | |
function () { | |
?> | |
<div class="site-branding"> | |
<div class="ast-site-identity"> | |
<?php astra_logo(); ?> | |
</div> | |
</div> | |
<!-- .site-branding --> | |
<?php | |
} | |
); | |
// Remove SiteNavigationElement Schema. | |
add_filter( | |
'wp_nav_menu_args', | |
function( $args ) { | |
if ( 'primary' == $args['theme_location'] ) { | |
$args[ 'items_wrap' ] = '<nav id="site-navigation" class="ast-flex-grow-1 navigation-accessibility" role="navigation" aria-label="' . esc_attr( 'Site Navigation', 'astra' ) . '">'; | |
$args[ 'items_wrap' ] .= '<div class="main-navigation">'; | |
$args[ 'items_wrap' ] .= '<ul id="%1$s" class="%2$s">%3$s</ul>'; | |
$args[ 'items_wrap' ] .= '</div>'; | |
$args[ 'items_wrap' ] .= '</nav>'; | |
} | |
return $args; | |
} | |
); | |
// Remove class `hfeed` from div#page | |
add_filter( | |
'astra_attr_site', | |
function( $attr ) { | |
$attr['class'] = str_replace( 'hfeed ', '', $attr['class'] ); | |
return $attr; | |
} | |
); | |
// Remove hentry class name from post_class. | |
add_filter( 'post_class', function ( $classes ) { | |
return array_diff( $classes, array( 'hentry' ) ); | |
} ); | |
add_filter( | |
'astra_attr_post-meta-author', | |
function( $attr ) { | |
unset( $attr['itemprop'] ); | |
unset( $attr['itemscope'] ); | |
unset( $attr['itemtype'] ); | |
$attr['class'] = 'posted-by author'; | |
return $attr; | |
} | |
); | |
add_filter( | |
'astra_attr_commen-meta-author', | |
function( $attr ) { | |
$attr['class'] = str_replace( 'vcard ', '', $attr['class'] ); | |
return $attr; | |
} | |
); | |
// Remove userinteraction schema from post comment meta. | |
add_filter( 'astra_attr_comments-interactioncounter', '__return_empty_array' ); | |
add_filter( 'astra_attr_comments-interactioncounter-interactiontype', '__return_empty_array' ); | |
add_filter( 'astra_attr_comments-interactioncounter-userinteractioncount', '__return_empty_array' ); | |
/** | |
* Remove CreativeWork schema. | |
* | |
* @param Array $attr markup HTML attributes. | |
* @return Array | |
*/ | |
function astra_child_remove_creative_work_schema( $attr ) { | |
unset( $attr['itemscope'] ); | |
unset( $attr['itemtype'] ); | |
return $attr; | |
} | |
add_filter( 'astra_attr_article-blog', 'astra_child_remove_creative_work_schema' ); | |
add_filter( 'astra_attr_article-page', 'astra_child_remove_creative_work_schema' ); | |
add_filter( 'astra_attr_article-single', 'astra_child_remove_creative_work_schema' ); | |
add_filter( 'astra_attr_article-content', 'astra_child_remove_creative_work_schema' ); | |
// Remove WPHeader Schema | |
add_filter( | |
'astra_attr_header', | |
function( $attr ) { | |
unset( $attr['itemscope'] ); | |
unset( $attr['itemtype'] ); | |
unset( $attr['role'] ); | |
return $attr; | |
} | |
); | |
// Remove WPFooter Schema | |
add_filter( | |
'astra_attr_footer', | |
function( $attr ) { | |
unset( $attr['itemscope'] ); | |
unset( $attr['itemtype'] ); | |
unset( $attr['role'] ); | |
return $attr; | |
} | |
); | |
// Remove WPSidebar Schema | |
add_filter( | |
'astra_attr_sidebar', | |
function( $attr ) { | |
unset( $attr['itemscope'] ); | |
unset( $attr['itemtype'] ); | |
unset( $attr['role'] ); | |
return $attr; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment