<?php
/**
 * Displays top header bar: Logo | Search | Icons
 *
 * @package Electronics Equipment
 */
?>

<div class="topbar-row">
    <div class="container">
        <div class="row align-items-center topbar-inner">
            <div class="col-lg-3 col-md-4 col-12 topbar-logo-col">
                <div class="navbar-brand topbar-brand">
                    <?php if ( has_custom_logo() ) : ?>
                        <div class="site-logo"><?php the_custom_logo(); ?></div>
                    <?php endif; ?>
                    <?php $electronics_equipment_blog_info = get_bloginfo( 'name' ); ?>
                    <?php if ( ! empty( $electronics_equipment_blog_info ) ) : ?>
                        <?php if ( is_front_page() && is_home() ) : ?>
                            <?php if ( get_theme_mod( 'electronics_equipment_logo_title_text', true ) != '' ) : ?>
                                <h1 class="site-title">
                                    <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
                                </h1>
                            <?php endif; ?>
                        <?php else : ?>
                            <?php if ( get_theme_mod( 'electronics_equipment_logo_title_text', true ) != '' ) : ?>
                                <p class="site-title">
                                    <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
                                </p>
                            <?php endif; ?>
                        <?php endif; ?>
                    <?php endif; ?>
                    <?php
                        $electronics_equipment_description = get_bloginfo( 'description', 'display' );
                        if ( ( $electronics_equipment_description || is_customize_preview() ) && get_theme_mod( 'electronics_equipment_theme_description', false ) != '' ) :
                    ?>
                        <p class="site-description"><?php echo esc_html( $electronics_equipment_description ); ?></p>
                    <?php endif; ?>
                </div>
            </div>
            <div class="col-lg-6 col-md-4 col-12 topbar-search-col order-md-2 order-3">
                <?php get_search_form(); ?>
            </div>
            <div class="col-lg-3 col-md-4 col-12 topbar-icons-col order-md-3 order-2">
                <div class="topbar-icons">

                    <!-- Wishlist -->
                    <?php
                        $electronics_equipment_wishlist_url = get_theme_mod( 'electronics_equipment_wishlist_url', '' );
                        if ( empty( $electronics_equipment_wishlist_url ) ) {
                            $electronics_equipment_wishlist_url = function_exists( 'YITH_WCWL' ) ? esc_url( YITH_WCWL()->get_wishlist_url() ) : home_url( '/wishlist/' );
                        }
                    ?>
                    <a href="<?php echo esc_url( $electronics_equipment_wishlist_url ); ?>" class="topbar-icon-btn" aria-label="<?php esc_attr_e( 'Wishlist', 'electronics-equipment' ); ?>">
                        <i class="far fa-heart" aria-hidden="true"></i>
                    </a>

                    <!-- Cart -->
                    <?php $electronics_equipment_cart_url = function_exists( 'wc_get_cart_url' ) ? wc_get_cart_url() : home_url( '/cart/' ); ?>
                    <a href="<?php echo esc_url( $electronics_equipment_cart_url ); ?>" class="topbar-icon-btn topbar-cart-btn" aria-label="<?php esc_attr_e( 'Cart', 'electronics-equipment' ); ?>">
                        <i class="fas fa-shopping-cart" aria-hidden="true"></i>
                        <?php if ( function_exists( 'WC' ) && WC()->cart ) : ?>
                            <span class="topbar-cart-count"><?php echo esc_html( WC()->cart->get_cart_contents_count() ); ?></span>
                        <?php endif; ?>
                    </a>

                    <!-- My Account -->
                    <?php
                        if ( function_exists( 'wc_get_page_id' ) && wc_get_page_id( 'myaccount' ) > 0 ) {
                            $electronics_equipment_account_url = get_permalink( wc_get_page_id( 'myaccount' ) );
                        } else {
                            $electronics_equipment_account_url = wp_login_url();
                        }
                    ?>
                    <a href="<?php echo esc_url( $electronics_equipment_account_url ); ?>" class="topbar-icon-btn" aria-label="<?php esc_attr_e( 'My Account', 'electronics-equipment' ); ?>">
                        <i class="far fa-user" aria-hidden="true"></i>
                    </a>

                </div>
            </div>
        </div>
    </div>
</div>
