Astra_Ext_Sticky_Header_Markup::sticky_custom_logo( String $html, int $blog_id )

Filter the output of logo to fix Googles Error about itemprop logo.


Description


Parameters

$html

(String) (Required) HTML Markup of the logo.

$blog_id

(int) (Required) ID of the blog to get the custom logo for.


Return

(String) Custom logo HTML output


Source

File: addons/sticky-header/classes/class-astra-ext-sticky-header-markup.php

		public function sticky_custom_logo( $html, $blog_id ) {

			$header_logo = astra_get_option( 'sticky-header-logo' );

			if ( '' !== $header_logo ) {

				/* Replace sticky header logo and width */
				add_filter( 'wp_get_attachment_image_attributes', array( $this, 'sticky_replace_header_logo_attr' ), 10, 3 );

				$custom_logo_id = attachment_url_to_postid( $header_logo );

				$size = 'ast-sticky-logo-size';

				if ( is_customize_preview() ) {
					$size = 'full';
				}

				$html = sprintf(
					'<a href="%1$s" class="sticky-custom-logo" rel="home" %3$s>%2$s</a>',
					esc_url( home_url( '/' ) ),
					wp_get_attachment_image(
						$custom_logo_id,
						$size,
						false,
						array(
							'class' => 'custom-logo',
						)
					),
					astra_attr(
						'site-title-sticky-custom-logo-link',
						array(
							'class' => '',
						)
					)
				);

				remove_filter( 'wp_get_attachment_image_attributes', array( $this, 'sticky_replace_header_logo_attr' ) );
			}

			return $html;
		}

Changelog

Changelog
Version Description
1.0.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.