81 lines
3.4 KiB
PHP
81 lines
3.4 KiB
PHP
<?php
|
|
/**
|
|
* Site Header — branding, primary nav, mobile nav, search, WC hooks.
|
|
* Used by header.php. Future Header Builder will extend, not replace.
|
|
*
|
|
* @package XShop
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
$branding = xshop_get_branding_fallback();
|
|
$hasLogo = has_custom_logo();
|
|
?>
|
|
<div class="xshop-header__inner xshop-container">
|
|
<div class="xshop-header__branding">
|
|
<?php if ($hasLogo): ?>
|
|
<div class="xshop-header__logo"><?php the_custom_logo(); ?></div>
|
|
<?php endif; ?>
|
|
<div>
|
|
<p class="xshop-header__title"><a href="<?php echo esc_url(home_url('/')); ?>" rel="home"><?php echo esc_html($branding['name']); ?></a></p>
|
|
<?php if ($branding['desc'] !== ''): ?>
|
|
<p class="xshop-header__tagline"><?php echo esc_html($branding['desc']); ?></p>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<nav class="xshop-header__nav xshop-nav xshop-nav--desktop" aria-label="<?php esc_attr_e('Primary', 'xshop'); ?>">
|
|
<?php
|
|
wp_nav_menu([
|
|
'theme_location' => 'xshop-primary',
|
|
'container' => false,
|
|
'menu_class' => 'xshop-nav__list',
|
|
'fallback_cb' => static function (): void {
|
|
echo '<ul class="xshop-nav__list"><li><a href="' . esc_url(home_url('/')) . '">' . esc_html__('Home', 'xshop') . '</a></li></ul>';
|
|
},
|
|
'depth' => 2,
|
|
]);
|
|
?>
|
|
</nav>
|
|
|
|
<div class="xshop-header__actions">
|
|
<div class="xshop-header__search xshop-header__search--desktop">
|
|
<?php get_template_part('template-parts/components/ajax-search', null, ['placeholder' => esc_html__('Search products…', 'xshop')]); ?>
|
|
</div>
|
|
|
|
<?php if (xshop_has_woocommerce()): ?>
|
|
<a class="xshop-header__action-btn" href="<?php echo esc_url(function_exists('wc_get_page_permalink') ? wc_get_page_permalink('myaccount') : wp_login_url()); ?>" aria-label="<?php esc_attr_e('My Account', 'xshop'); ?>">
|
|
<span aria-hidden="true">◉</span><span class="xshop-sr-only"><?php esc_html_e('My Account', 'xshop'); ?></span>
|
|
</a>
|
|
<?php if (function_exists('wc_get_cart_url')): ?>
|
|
<a class="xshop-header__action-btn" href="<?php echo esc_url(wc_get_cart_url()); ?>" aria-label="<?php esc_attr_e('Cart', 'xshop'); ?>">
|
|
<span aria-hidden="true">🛒</span><span class="xshop-sr-only"><?php esc_html_e('Cart', 'xshop'); ?></span>
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
|
|
<button type="button" class="xshop-mobile-toggle" data-xshop-mobile-toggle aria-expanded="false" aria-controls="xshop-mobile-nav" aria-label="<?php esc_attr_e('Toggle menu', 'xshop'); ?>">
|
|
<span aria-hidden="true">☰</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<nav id="xshop-mobile-nav" class="xshop-mobile-nav xshop-container" aria-label="<?php esc_attr_e('Mobile', 'xshop'); ?>" hidden>
|
|
<?php
|
|
wp_nav_menu([
|
|
'theme_location' => 'xshop-primary',
|
|
'container' => false,
|
|
'menu_class' => 'xshop-mobile-nav__list',
|
|
'fallback_cb' => static function (): void {
|
|
echo '<ul class="xshop-mobile-nav__list"><li><a href="' . esc_url(home_url('/')) . '">' . esc_html__('Home', 'xshop') . '</a></li></ul>';
|
|
},
|
|
'depth' => 2,
|
|
]);
|
|
?>
|
|
<div style="margin-block-start:var(--xshop-space-4)">
|
|
<?php get_template_part('template-parts/components/ajax-search', null, ['placeholder' => esc_html__('Search products…', 'xshop'), 'id' => 'xshop-ajax-search-mobile-' . wp_unique_id()]); ?>
|
|
</div>
|
|
</nav>
|