custom_logo_filtered ) { $attrs = $this->add_data_hero_candidate_attribute( $attrs ); $this->custom_logo_filtered = true; } return $attrs; } /** * Filter the header image tag HTML to inject the data-hero-candidate attribute. * * @param string $html Header tag. * @return string header image tag. */ public function filter_header_image_tag( $html ) { return preg_replace( '/(?<=is_main_query() && isset( $wp_query->posts[0] ) ) { $post = $wp_query->posts[0]; } if ( $post instanceof WP_Post && $attachment instanceof WP_Post && (int) get_post_thumbnail_id( $post ) === $attachment->ID ) { $attrs = $this->add_data_hero_candidate_attribute( $attrs ); } return $attrs; } /** * Add data-hero-candidate to attributes array. * * @param array $attrs Attributes. * @return array Amended attributes. */ public function add_data_hero_candidate_attribute( $attrs ) { $attrs[ Attribute::DATA_HERO_CANDIDATE ] = ''; return $attrs; } }