Initial commit

This commit is contained in:
2024-03-01 17:47:03 +03:00
commit 10722da013
227 changed files with 13356 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<?php
$arg_cat = array(
'exclude' => '17, 20, 21',
'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);
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' : '';
echo "<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</a></span>
</a>
";
}

View File

@@ -0,0 +1,35 @@
<?php
$categories = get_categories(array(
'exclude' => '17, 20, 21',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => false
));
$firstElement = array_shift($categories);
array_push($categories, $firstElement);
foreach ($categories as $category) {
if ($category->slug === 'uncategorized') continue;
$icon = get_field('icon', 'category_' . $category->term_id);
$bg_image = get_field('bg_image', 'category_' . $category->term_id);
$category_link = get_category_link($category->term_id);
?>
<a href="<?php echo esc_url($category_link); ?>" class="menu-link">
<div class="menu-link__bg">
<?php if ($bg_image) : ?>
<img src="<?php echo esc_url($bg_image['url']); ?>" alt="<?php echo esc_attr($category->name); ?>" />
<?php endif; ?>
</div>
<div class="menu-link__icon">
<?php if ($icon) : ?>
<img src="<?php echo esc_url($icon); ?>" alt="<?php echo esc_attr($category->name); ?>" />
<?php endif; ?>
</div>
<span class="menu-link__text"><?php echo esc_html($category->name); ?></span>
</a>
<?php
}
?>

View File

@@ -0,0 +1,27 @@
<?php
$featured_posts = get_field('featured_posts');
if ($featured_posts) {
echo '<div class="article-section__title">Еще по теме</div><div class="articles-preview">';
foreach ($featured_posts as $post) {
setup_postdata($post);
?>
<div class="article-item article-item--no-image">
<div class="article-item__text">
<div class="article-time">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/icons/time.svg" alt="" />
Сегодня, <time><?php the_time('H:i:s'); ?></time>
</div>
<div class="tag article-item__tag"><?php echo get_the_category_list(', '); ?></div>
<a href="<?php the_permalink(); ?>" class="subtitle-16 article-item__link"><?php the_title(); ?></a>
<p class="article-item__descr text-13"><?php the_excerpt(); ?></p>
</div>
</div>
<?php
}
echo '</div>';
wp_reset_postdata();
}
?>

View File

@@ -0,0 +1,28 @@
<?php
$posts = get_post_query('post', 1, 'ASC', '', 'interviews');
if ($posts->have_posts()) :
while ($posts->have_posts()) :
$posts->the_post();
?>
<div class="content-videos">
<a href="<?= get_permalink(); ?>">
<div class="item-video">
<div class="item-video__video-wrapper">
<?= show_post_image(); ?>
<button class="item-video__button subtitle-20">
<img src="<?= get_asset('icons/play.svg'); ?>" alt="" /> Интервью
</button>
</div>
<a href="<?= get_permalink(); ?>" class="subtitle-16 item-video__name"><?= get_the_title(); ?></a>
</div>
</a>
</div>
<?php
endwhile;
wp_reset_postdata();
else : ?>
<p>Интервью не найдено.</p>
<?php
endif;
?>

View File

@@ -0,0 +1,28 @@
<div class="law">
<h3 class="subtitle-20 right-title">Законодательство</h3>
<div class="content-right__links">
<?php
$args = array(
'category_name' => 'zakonodatelstvo', // Slug категории
'posts_per_page' => 3, // Количество постов
'orderby' => 'date', // Сортировка по дате
'order' => 'DESC' // В порядке убывания (самые свежие)
);
$legislation_posts = new WP_Query($args);
if ($legislation_posts->have_posts()) {
while ($legislation_posts->have_posts()) {
$legislation_posts->the_post();
echo '<div class="doc">
<a href="' . get_permalink() . '" class="content-right__link-item link">' . get_the_title() . '</a>
</div>';
}
wp_reset_postdata();
} else {
echo '<p>Посты в категории "законодательство" не найдены.</p>';
}
?>
</div>
</div>

View File

@@ -0,0 +1,24 @@
<?php
$menu_location = 'footer-bottom';
$locations = get_nav_menu_locations();
$menu_id = $locations[$menu_location];
$menu_items = wp_get_nav_menu_items($menu_id);
$privacyPolicy = get_field('privacy_policy', 'option');
foreach ($menu_items ?? [] as $menu_item) {
if($privacyPolicy) {
if($menu_item->post_name === 'politika-konfidenczialnosti') $file = $privacyPolicy['file']['url'];
if($menu_item->post_name === 'svidetelstvo-o-registraczii-elektronnogo-smi') $file = $privacyPolicy['file_certificate']['url'];
echo "<a href='" . esc_url($file) . "' class='footer-bottom__text footer-bottom__link' target='_blank'>" . $menu_item->title . "</a>";
} else {
echo "<a href='" . esc_url($menu_item->url) . "' class='footer-bottom__text footer-bottom__link' target='_blank'>" . $menu_item->title . "</a>";
}
}

12
partials/menu-primary.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
$menu_location = 'primary';
$locations = get_nav_menu_locations();
$menu_id = $locations[$menu_location];
$menu_items = wp_get_nav_menu_items($menu_id);
?>
<?php foreach ($menu_items ?: [] as $menu_item):?>
<li class="menu-item">
<a href="<?=esc_url($menu_item->url);?>"><?=$menu_item->title?></a>
</li>
<?php endforeach ?>

18
partials/menu-socials.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
$menu_location = 'socials';
$locations = get_nav_menu_locations();
$menu_id = $locations[$menu_location];
$menu_items = wp_get_nav_menu_items($menu_id);
foreach ($menu_items ?? [] as $menu_item) {
$icon = get_field('icon', $menu_item); // Получаем URL иконки из ACF
$title = $menu_item->title;
$url = $menu_item->url;
echo "<a href='" . esc_url($url) . "' class='social-link' target='_blank'>";
if (!empty($icon)) {
echo "<img src='" . esc_url($icon) . "' alt='" . esc_attr($title) . "' />";
}
echo "</a>";
}

View File

@@ -0,0 +1,32 @@
<?php
global $wpdb; // Глобальная переменная для работы с базой данных
// Запрос для получения ID топ-3 просматриваемых постов
$query = "
SELECT p.ID, p.post_title, pv.count
FROM {$wpdb->prefix}posts p
JOIN {$wpdb->prefix}post_views pv ON p.ID = pv.id AND pv.type = 4
WHERE p.post_status = 'publish' AND p.post_type = 'post'
ORDER BY pv.count DESC
LIMIT 3;
";
$top_posts = $wpdb->get_results($query);
// Вывод результатов
if (!empty($top_posts)) {
foreach ($top_posts as $post) {
$permalink = get_permalink($post->ID);
$title = get_the_title($post->ID);
?>
<div class="most-read__link">
<a href="<?php echo esc_url($permalink); ?>" class="most-read__link-inner text-13 link-icon-after">
<?php echo esc_html($title); ?>
</a>
</div>
<?php
}
} else {
echo '<p>Нет просмотренных постов.</p>';
}
?>

24
partials/pinned-post.php Normal file
View File

@@ -0,0 +1,24 @@
<?php
// Получаем объект закрепленного поста из ACF поля 'pinned_post'
$pinned_post = get_field('pinned_post', 'options');
if ($pinned_post) :
?>
<a href="<?php echo get_permalink($pinned_post->ID); ?>" class="hero-banner">
<div class="hero-banner__bg">
<?= show_post_image($pinned_post->ID, 'large'); ?>
</div>
<p class="hero-banner__main">Главное</p>
<div class="hero-banner__content">
<p class="hero-banner__title subtitle-16">
<?php echo get_the_title($pinned_post->ID); ?>
</p>
<p class="hero-banner__text text-13">
<?php echo get_the_excerpt($pinned_post->ID); ?>
</p>
</div>
<div class="tag hero-banner__tag"><?php echo esc_html(get_category_name($pinned_post)); ?></div>
</a>
<?php endif; ?>

37
partials/post-list.php Normal file
View File

@@ -0,0 +1,37 @@
<?php
global $wp_query;
$large_first_image = $args['large_first_image'] ?? true;
$post_count = 0;
$query = $args['query'] ?? $wp_query;
if ($query->have_posts()) {
while ($query->have_posts()) {
$post_count++;
$query->the_post();
get_template_part('content', 'post', ['full_width' => $post_count === 1 && $large_first_image]);
if ($post_count === ($large_first_image ? 5 : 4)) {
$banners = wp_is_mobile() ? get_field('banner_between_posts_mobile', 'option') : get_field('banner_between_posts', 'option');
if($banners){
$rand_keys = array_rand($banners, 1);
if (isset($banners[$rand_keys]) && !empty($banners[$rand_keys]['image_banner'])) {
echo '<a href="' . $banners[$rand_keys]['link'] . '"><div class="banner-middle">
<img src="' . $banners[$rand_keys]["image_banner"]["url"] . '" alt=""></a></div>';
}
}
}
}
wp_reset_postdata();
}
?>
<style>
.banner-middle img {
width: 100%;
}
.banner-middle {
overflow: hidden;
display: flex;
align-items: center;
}
</style>

View File

@@ -0,0 +1,33 @@
<?php
$current_post_id = get_the_ID();
// Получаем категории текущего поста
$categories = get_the_category($current_post_id);
if ($categories) {
$category_ids = array_map(function ($category) {
return $category->term_id;
}, $categories);
$args = array(
'category__in' => $category_ids,
'post__not_in' => array($current_post_id),
'posts_per_page' => 4,
);
$related_posts_query = new WP_Query($args);
if ($related_posts_query->have_posts()) {
echo '<div class="article-section__title">Читайте также:</div>';
echo '<div class="articles-preview">';
while ($related_posts_query->have_posts()) {
$related_posts_query->the_post();
get_template_part('content', 'post');
}
echo '</div>';
wp_reset_postdata();
}
}
?>

View File

@@ -0,0 +1,57 @@
<?php
$arg_cat = array(
'exclude' => '17, 20, 21',
'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()) : ?>
<span><?= $current_term->name; ?></span>
<?php elseif (is_single()) :?>
<span><?= get_cat_name($current_term_ids[0]); ?></span>
<?php else : ?>
<span>Рубрики</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>