Skip to content

Instantly share code, notes, and snippets.

@niklasp
Created November 28, 2017 21:20
Show Gist options
  • Save niklasp/ee13412f1d0cfda4fe1676866ebfc480 to your computer and use it in GitHub Desktop.
Save niklasp/ee13412f1d0cfda4fe1676866ebfc480 to your computer and use it in GitHub Desktop.
avada random header logo
/**
* The avada_logo_prepend hook.
*/
do_action( 'avada_logo_prepend' );
?>
<?php if ( ( Avada()->settings->get( 'logo', 'url' ) && '' !== Avada()->settings->get( 'logo', 'url' ) ) || ( Avada()->settings->get( 'logo_retina', 'url' ) && '' !== Avada()->settings->get( 'logo_retina', 'url' ) ) ) : ?>
<a class="fusion-logo-link" href="<?php echo esc_url_raw( home_url( '/' ) ); ?>">
<!-- standard logo -->
<?php
$logo_url = get_random_header_image();
$standard_logo = Avada()->images->get_logo_image_srcset( 'logo', 'logo_retina' )
?>
<img src="<?php echo esc_url_raw( $logo_url ); ?>" srcset="<?php echo esc_attr( $logo_url); ?>" width="500px" height="500px" alt="<?php bloginfo( 'name' ); ?> <?php esc_attr_e( 'Logo', 'Avada' ); ?>" retina_logo_url="<?php echo esc_url_raw( $standard_logo['is_retina'] ); ?>" class="fusion-standard-logo" />
<!-- mobile logo -->
<?php
if ( Avada()->settings->get( 'mobile_logo', 'url' ) && '' !== Avada()->settings->get( 'mobile_logo', 'url' ) ) {
$mobile_logo = Avada()->images->get_logo_image_srcset( 'mobile_logo', 'mobile_logo_retina' );
?>
<img src="<?php echo esc_url_raw( $logo_url ); ?>" srcset="<?php echo esc_attr( $logo_url ); ?>" width="300px" height="300px" alt="<?php bloginfo( 'name' ); ?> <?php esc_attr_e( 'Logo', 'Avada' ); ?>" retina_logo_url="<?php echo esc_url_raw( $mobile_logo['is_retina'] ); ?>" class="fusion-mobile-logo" />
<?php } ?>
<!-- sticky header logo -->
<?php
if ( Avada()->settings->get( 'sticky_header_logo', 'url' ) && '' !== Avada()->settings->get( 'sticky_header_logo', 'url' ) && ( in_array( Avada()->settings->get( 'header_layout' ), array( 'v1', 'v2', 'v3', 'v6', 'v7' ) ) || ( ( in_array( Avada()->settings->get( 'header_layout' ), array( 'v4', 'v5' ) ) && 'menu_and_logo' === Avada()->settings->get( 'header_sticky_type2_layout' ) ) ) ) ) {
$sticky_logo = Avada()->images->get_logo_image_srcset( 'sticky_header_logo', 'sticky_header_logo_retina' );
?>
<img src="<?php echo esc_url_raw( $sticky_logo['url'] ); ?>" srcset="<?php echo esc_attr( $sticky_logo['srcset'] ); ?>" width="<?php echo esc_attr( $sticky_logo['width'] ); ?>" height="<?php echo esc_attr( $sticky_logo['height'] ); ?>"<?php echo $sticky_logo['style']; // WPCS: XSS ok. ?> alt="<?php bloginfo( 'name' ); ?> <?php esc_attr_e( 'Logo', 'Avada' ); ?>" retina_logo_url="<?php echo esc_url_raw( $sticky_logo['is_retina'] ); ?>" class="fusion-sticky-logo" />
<?php } ?>
</a>
<?php endif; ?>
<?php
/**
* The avada_logo_append hook.
*
* @hooked avada_header_content_3 - 10.
*/
do_action( 'avada_logo_append' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment