nowa-panda/themes/panda-theme/header.php
2025-07-07 09:52:36 +02:00

143 lines
5.0 KiB
PHP

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<header class="site-header">
<div class="site-header__container">
<div class="logo">
<a href="<?php echo home_url(); ?>">
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/logo.png" alt="Logo Panda" />
</a>
</div>
<div class="site-header__utils">
<div class="site-header_navigation">
<form role="search" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>" class="site-header__search">
<button type="submit" class="site-header__search-button">
<?php
echo file_get_contents(get_template_directory() . '/assets/images/search.svg' );
?>
</button>
<input
type="search"
class="site-header__search-input"
name="s"
placeholder="Jakiego gadżetu szukasz?"
value="<?php echo get_search_query(); ?>"
required
/>
<input type="hidden" name="post_type" value="product" />
</form>
<div class="site-header__dropcat">
Kategorie produktów
</div>
<a href="<?php echo esc_url( wc_get_page_permalink('shop') ); ?>">
<div class="site-header__shop">
Sklep
</div>
</a>
</div>
<div class="site-header__info">
<a href="<?php echo get_permalink( wc_get_page_id( 'myaccount' ) ); ?>">
<div class="site-header__info-account">
<?php
echo file_get_contents(get_template_directory() . '/assets/images/user.svg' );
?>
</div>
</a>
<a href="<?php echo get_permalink( wc_get_page_id( 'cart' ) ); ?>">
<div class="site-header__info-cart">
<?php
echo file_get_contents(get_template_directory() . '/assets/images/cart.svg' );
?>
<span class="info-cart__count">
<?php echo WC()->cart->get_cart_contents_count(); ?>
</span>
</div>
</a>
</div>
</div>
</div>
<div class="dropcats">
<ul class="dropcats__categories">
<?php
$all_cats = get_terms([
'taxonomy' => 'product_cat',
'hide_empty' => false,
]);
$product_cats = array_filter( $all_cats, function( $cat ) {
return $cat->slug !== 'bez-kategorii';
});
if ( !is_wp_error( $product_cats ) && !empty( $product_cats ) ) : ?>
<?php foreach ( $product_cats as $cat ) : ?>
<li>
<a href="<?php echo esc_url( get_term_link( $cat ) ); ?>" class="">
<?php
$svg = get_template_directory() . '/assets/images/' . $cat->slug . '.svg';
echo file_exists($svg) ? file_get_contents($svg) : '';
?>
<?php echo esc_html( $cat->name ); ?>
</a>
</li>
<?php endforeach; ?>
</nav>
<?php endif; ?>
<li>
<a href="<?php echo esc_url( wc_get_page_permalink('shop') ); ?>">
<?php
echo file_get_contents(get_template_directory() . '/assets/images/task.svg' );
?>
Pokaż wszystkie kategorie
</a>
</li>
</ul>
<div class="dropcats__close">
<?php
echo file_get_contents(get_template_directory() . '/assets/images/Close.svg' );
?>
</div>
</div>
<?php
$all_cats = get_terms([
'taxonomy' => 'product_cat',
'hide_empty' => false,
]);
$product_cats = array_filter( $all_cats, function( $cat ) {
return $cat->slug !== 'bez-kategorii'
&& $cat->slug !== 'moda-i-odziez';
});
if ( !is_wp_error( $product_cats ) && !empty( $product_cats ) ) : ?>
<nav class="site-header__cats">
<ul class="site-header__cats-list">
<?php foreach ( $product_cats as $cat ) : ?>
<li class="site-header__cats-item">
<a href="<?php echo esc_url( get_term_link( $cat ) ); ?>" class="site-header__cats-link">
<?php echo esc_html( $cat->name ); ?>
</a>
</li>
<div class="site-header__cats-separator">
|
</div>
<?php endforeach; ?>
</ul>
</nav>
<?php endif; ?>
</header>