59 lines
2.2 KiB
PHP
59 lines
2.2 KiB
PHP
|
|
<?php
|
||
|
|
$arg_cat = array(
|
||
|
|
'include' => EN_PARTS,
|
||
|
|
'order' => 'ASC',
|
||
|
|
'taxonomy' => 'category',
|
||
|
|
'hide_empty' => false
|
||
|
|
);
|
||
|
|
$categories = get_categories($arg_cat);
|
||
|
|
$current_term = get_queried_object();
|
||
|
|
|
||
|
|
// Получаем ID текущей категории или категорий поста
|
||
|
|
$current_term_ids = [];
|
||
|
|
if (is_single()) {
|
||
|
|
$current_term_ids = wp_get_post_categories($current_term->ID);
|
||
|
|
} elseif (is_category()) {
|
||
|
|
$current_term_ids[] = $current_term->term_id;
|
||
|
|
}
|
||
|
|
|
||
|
|
$firstElement = array_shift($categories);
|
||
|
|
array_push($categories, $firstElement);
|
||
|
|
?>
|
||
|
|
<div class="menu-vertical mobile">
|
||
|
|
<div class="menu-vertical__head">
|
||
|
|
<?php if (is_category(740)) : ?>
|
||
|
|
<span>Parts</span>
|
||
|
|
<?php elseif (is_category()) : ?>
|
||
|
|
<span><?= $current_term->name; ?></span>
|
||
|
|
<?php elseif (is_single()) :?>
|
||
|
|
<span><?= get_cat_name($current_term_ids[0]); ?></span>
|
||
|
|
<?php else : ?>
|
||
|
|
<span>Parts</span>
|
||
|
|
<?php endif; ?>
|
||
|
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||
|
|
<g clip-path="url(#clip0_373_15802)">
|
||
|
|
<path d="M7 10L12 15L17 10" stroke="#7C7C7C" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
|
||
|
|
</g>
|
||
|
|
<defs>
|
||
|
|
<clipPath id="clip0_373_15802">
|
||
|
|
<rect width="24" height="24" fill="white" />
|
||
|
|
</clipPath>
|
||
|
|
</defs>
|
||
|
|
</svg>
|
||
|
|
</div>
|
||
|
|
<div class="menu-vertical__inner">
|
||
|
|
<? foreach ($categories ?? [] as $cat) : ?>
|
||
|
|
<? if ($cat->slug === 'uncategorized') continue; ?>
|
||
|
|
<?
|
||
|
|
$icon = get_field('icon', 'category_' . $cat->term_id);
|
||
|
|
$bg_image = get_field('bg_image', 'category_' . $cat->term_id);
|
||
|
|
$class = in_array($cat->term_id, $current_term_ids) ? 'is-active' : '';
|
||
|
|
?>
|
||
|
|
<a href="<?= get_category_link($cat->term_id); ?>" class="menu-vertical__item <?= $class ?>" <span class="menu-vertical__item-icon">
|
||
|
|
<img src="<?= $icon ?>" alt="" />
|
||
|
|
</span>
|
||
|
|
<span class="menu-vertical__item-text"><?= $cat->name ?></span>
|
||
|
|
</a>
|
||
|
|
<? endforeach; ?>
|
||
|
|
</div>
|
||
|
|
</div>
|