Created
August 3, 2020 17:55
-
-
Save diggeddy/99cb13b621aa5affca1ab84bad34e253 to your computer and use it in GitHub Desktop.
Add no-lazy class to GP logos to exclude perfmatters lazy loading
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
add_filter( 'generate_mobile_header_logo_output', function( $output ) { | |
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) { | |
return $output; | |
} | |
$settings = wp_parse_args( | |
get_option( 'generate_menu_plus_settings', array() ), | |
generate_menu_plus_get_defaults() | |
); | |
return sprintf( | |
'<div class="site-logo mobile-header-logo"> | |
<a href="%1$s" title="%2$s" rel="home"> | |
<img src="%3$s" class="no-lazy" alt="%4$s" /> | |
</a> | |
</div>', | |
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ), | |
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ), | |
esc_url( apply_filters( 'generate_mobile_header_logo', $settings['mobile_header_logo'] ) ), | |
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ) | |
); | |
} ); | |
add_filter( 'generate_logo_attributes', function( $attr ) { | |
$attr['class'] .= ' no-lazy'; | |
return $attr; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment