<?php
/**
 * The header for our theme
 *
 * @package Machine Repair
 */
?>
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="profile" href="https://gmpg.org/xfn/11">
    <?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<div id="page" class="site">
    <a class="skip-link screen-reader-text" href="#primary"><?php esc_html_e( 'Skip to content', 'machine-repair' ); ?></a>

    <?php
    $machine_repair_preloader_wrap = absint( get_theme_mod( 'machine_repair_enable_preloader', 0 ) );
    if ( $machine_repair_preloader_wrap === 1 ) : ?>
        <div id="loader">
            <div class="loader-container">
                <div id="preloader" class="loader-2">
                    <div class="dot"></div>
                </div>
            </div>
        </div>
    <?php endif; ?>


    <header id="masthead" class="site-header">
        <div class="headermain">
            <div class="header-info-box">
                <div class="top-head">
                    <div class="container">
                        <div class="flex-row">
                            <div class="top-left">
                            </div>
                            <div class="top-center">
                                <span class="social-media">
                                    <?php if ( get_theme_mod( 'machine_repair_facebook_link_option','#' ) ) : ?>
                                        <a href="<?php echo esc_url( get_theme_mod( 'machine_repair_facebook_link_option','#' ) ); ?>" target="_blank" rel="noopener noreferrer">
                                            <i class="fab fa-facebook-f"></i>
                                        </a>
                                    <?php endif; ?>
                                    <?php if ( get_theme_mod( 'machine_repair_twitter_link_option','#' ) ) : ?>
                                        <a href="<?php echo esc_url( get_theme_mod( 'machine_repair_twitter_link_option','#' ) ); ?>" target="_blank" rel="noopener noreferrer">
                                            <i class="fab fa-twitter"></i>
                                        </a>
                                    <?php endif; ?>
                                    <?php if ( get_theme_mod( 'machine_repair_instagram_link_option','#' ) ) : ?>
                                        <a href="<?php echo esc_url( get_theme_mod( 'machine_repair_instagram_link_option','#' ) ); ?>" target="_blank" rel="noopener noreferrer">
                                            <i class="fab fa-instagram"></i>
                                        </a>
                                    <?php endif; ?>
                                    <?php if ( get_theme_mod( 'machine_repair_linked_link_option','#' ) ) : ?>
                                        <a href="<?php echo esc_url( get_theme_mod( 'machine_repair_linked_link_option','#' ) ); ?>" target="_blank" rel="noopener noreferrer">
                                            <i class="fab fa-linkedin-in"></i>
                                        </a>
                                    <?php endif; ?>
                                    <?php if ( get_theme_mod( 'machine_repair_pinterest_link_option','#' ) ) : ?>
                                        <a href="<?php echo esc_url( get_theme_mod( 'machine_repair_pinterest_link_option','#' ) ); ?>" target="_blank" rel="noopener noreferrer">
                                            <i class="fab fa-pinterest-p"></i>
                                        </a>
                                    <?php endif; ?>
                                    <?php if ( get_theme_mod( 'machine_repair_youtube_link_option','#' ) ) : ?>
                                        <a href="<?php echo esc_url( get_theme_mod( 'machine_repair_youtube_link_option','#' ) ); ?>" target="_blank" rel="noopener noreferrer">
                                            <i class="fab fa-youtube"></i>
                                        </a>
                                    <?php endif; ?>
                                </span>
                            </div>
                            <div class="top-right">
                                <?php if (class_exists('woocommerce')): ?>
                                    <span class="main-woo-box">
                                        <span class="cart-no-box">
                                            <a href="<?php echo esc_url(wc_get_cart_url()); ?>" title="<?php esc_attr_e('Shopping Cart', 'machine-repair'); ?>">
                                                <i class="fas fa-shopping-cart"></i>
                                                <span class="screen-reader-text"><?php esc_html_e('Shopping Cart', 'machine-repair'); ?></span>
                                            </a>
                                            <span class="cart-value"><?php echo esc_html(WC()->cart->get_cart_contents_count()); ?></span>
                                        </span>
                                    </span>
                                <?php endif; ?>
                                <span class="header-button">
                                    <?php if (get_theme_mod('machine_repair_header_button_link') || get_theme_mod('machine_repair_header_button_text', 'BOOK AN APPOINTMENT')): ?>
                                        <a href="<?php echo esc_url(get_theme_mod('machine_repair_header_button_link')); ?>"><?php echo esc_html(get_theme_mod('machine_repair_header_button_text', 'BOOK AN APPOINTMENT')); ?></a>
                                    <?php endif; ?>
                                </span>
                            </div>
                        </div>
                    </div>
                </div>
                <?php 
                $machine_repair_has_header_image = has_header_image();
                $machine_repair_header_image_url = $machine_repair_has_header_image ? esc_url( get_header_image() ) : '';
                ?>
                <div class="middle-head">
                    <div class="header-menu-box <?php echo esc_attr( get_theme_mod( 'machine_repair_enable_sticky_header', false ) ? 'sticky-header' : '' ); ?>" style="background-image: url('<?php echo $machine_repair_header_image_url; ?>'); background-repeat: no-repeat; background-size: cover;">
                        <div class="container">
                            <div class="flex-row">
                                <div class="middle-left">
                                </div>
                                <div class="middle-center">
                                    <div class="nav-menu-header-right">
                                        <nav id="site-navigation" class="main-navigation">
                                            <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
                                                <span class="screen-reader-text"><?php esc_html_e( 'Primary Menu', 'machine-repair' ); ?></span>
                                                <i class="fas fa-bars"></i>
                                            </button>
                                            <?php
                                            wp_nav_menu( array(
                                                'theme_location' => 'menu-1',
                                                'menu_id'        => 'primary-menu',
                                            ) );
                                            ?>
                                        </nav>
                                    </div>
                                </div>
                                <div class="middle-right">
                                    <?php if ( get_theme_mod( 'machine_repair_header_search', true ) == 1 ) : ?>
                                            <span class="search-bar">
                                                <button type="button" class="open-search"><i class="fas fa-search"></i></button>
                                            </span>
                                    <?php endif; ?>
                                </div>
                                    <div class="search-outer">
                                        <div class="inner_searchbox">
                                            <?php get_search_form(); ?>
                                        </div>
                                        <button type="button" class="search-close"><i class="fas fa-window-close"></i></button>
                                    </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="bottom-head">
                    <div class="container">
                        <div class="flex-row">
                            <div class="bottom-left">
                                <div class="nav-menu-header-left">
                                    <div class="site-branding">
                                        <?php
                                        if ( function_exists( 'the_custom_logo' ) ) {
                                            the_custom_logo();
                                        }
                                        if ( is_front_page() && is_home() ) :
                                            if ( get_theme_mod( 'machine_repair_site_title_text', true ) ) : ?>
                                                <h1 class="site-title">
                                                    <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
                                                </h1>
                                            <?php endif;
                                        else :
                                            if ( get_theme_mod( 'machine_repair_site_title_text', true ) ) : ?>
                                                <p class="site-title">
                                                    <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
                                                </p>
                                            <?php endif;
                                        endif;

                                        $machine_repair_description = get_bloginfo( 'description', 'display' );
                                        if ( $machine_repair_description || is_customize_preview() ) :
                                            if ( get_theme_mod( 'machine_repair_site_tagline_text', false ) ) : ?>
                                                <p class="site-description"><?php echo esc_html( $machine_repair_description ); ?></p>
                                            <?php endif;
                                        endif; ?>
                                    </div>
                                </div>
                            </div>
                            <div class="bottom-center">
                                <?php if (get_theme_mod('machine_repair_location','351 Montreal Ave, Staten Island, NY 10306')) : ?>
                                    <p class="location">
                                        <i class="<?php echo esc_attr(get_theme_mod('machine_repair_header_location_icon','fas fa-map-marker-alt')); ?> px-2"></i>
                                        <?php echo esc_html(get_theme_mod('machine_repair_location','351 Montreal Ave, Staten Island, NY 10306')); ?>
                                    </p>
                                <?php endif; ?>
                            </div>
                            <div class="bottom-right">
                                <?php if ( get_theme_mod( 'machine_repair_header_info_phone','+00 123 456 7890' ) ) : ?>
                                    <span class="contact-info">
                                        <span class="main-box phone">
                                            <span class="main-head">
                                                <a href="tel:<?php echo esc_attr( get_theme_mod( 'machine_repair_header_info_phone','+00 123 456 7890' ) ); ?>">
                                                    <i class="<?php echo esc_attr(get_theme_mod('machine_repair_header_phone_icon','fas fa-phone')); ?>"></i> <?php echo esc_html( get_theme_mod( 'machine_repair_header_info_phone','+00 123 456 7890' ) ); ?>
                                                </a>
                                            </span>
                                        </span>
                                    </span>
                                <?php endif; ?>
                            </div>
                            <div class="bottom-last">
                                <?php if ( get_theme_mod( 'machine_repair_header_info_email','machinerepair@example.com' ) ) : ?>
                                    <span class="contact-info">
                                        <span class="main-box email">
                                            <span class="main-head">
                                                <a href="mailto:<?php echo esc_attr( get_theme_mod( 'machine_repair_header_info_email','machinerepair@example.com' ) ); ?>">
                                                    <i class="<?php echo esc_attr(get_theme_mod('machine_repair_header_mail_icon','fas fa-envelope-open-text')); ?>"></i> <?php echo esc_html( get_theme_mod( 'machine_repair_header_info_email','machinerepair@example.com' ) ); ?>
                                                </a>
                                            </span>
                                        </span>
                                    </span>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
    </header>
</div>
<?php wp_footer(); ?>
</body>
</html>