add folder EN

This commit is contained in:
argoexpert press
2024-05-24 21:37:57 +03:00
parent 4fa7a19433
commit 009f8e40c2
22 changed files with 732 additions and 80 deletions

24
en/category-en-sub.php Normal file
View File

@@ -0,0 +1,24 @@
<?php get_header( 'en' ); ?>
<div class="content-middle articles-wrapper">
<?php get_template_part('partials/rubrics-mobile'); ?>
<div class="section-title desktop">
<?php if (is_category()) : ?>
<h1 class="section-title__title"><?= get_queried_object()->name ?></h1>
<?php endif; ?>
</div>
<div class="articles-preview">
<?php
$paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1;
$args = array(
'post_type' => 'post',
'posts_per_page' => 5,
'paged' => $paged,
'category__in' => get_queried_object_id()
);
$query = new WP_Query($args);
?>
<?php get_template_part('en/post-list-en', null, ['query' => $query]); ?>
</div>
<?php custom_pagination(); ?>
</div>
<?php get_footer( 'en' ); ?>

35
en/category-menu-en.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
$categories = get_categories(array(
'include' => EN_PARTS,
'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,36 @@
<?php
$arg_cat = array(
'include' => EN_PARTS,
'taxonomy' => 'category',
'orderby' => 'ID',
'order' => 'ASC',
'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>
";
}

20
en/content-post-en.php Normal file
View File

@@ -0,0 +1,20 @@
<?php
$formatted_date = format_event_date();
$full_width = $args['full_width'] ?? false;
$class = $full_width ? 'article-item article-item--lg' : 'article-item';
?>
<div class="<?= $class; ?>">
<a href="<?php the_permalink(); ?>" class="article-item__image-container">
<?= show_post_image(); ?>
<div class="tag article-item__tag"><?=get_priority_category_en(); ?></div>
</a>
<div class="article-item__text">
<div class="article-time">
<img src="<?= get_asset('/icons/time.svg'); ?>" alt="" /><?php echo get_published_date_in_english(); ?>
</div>
<a href="<?php the_permalink(); ?>" class="subtitle-16 article-item__link"><?php the_title(); ?></a>
<? if ($full_width) : ?>
<p class="article-item__descr text-13"><?php the_excerpt(); ?></p>
<? endif; ?>
</div>
</div>

View File

@@ -0,0 +1,28 @@
<div class="law">
<h3 class="subtitle-20 right-title">Regulation</h3>
<div class="content-right__links">
<?php
$args = array(
'category_name' => 'regulation', // 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>

9
en/mainmenu-en.php Normal file
View File

@@ -0,0 +1,9 @@
<?php
$menu_id = 761;
$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 ?>

46
en/most-read-posts-en.php Normal file
View File

@@ -0,0 +1,46 @@
<?php
global $wpdb; // Глобальная переменная для работы с базой данных
$included_category_ids = array(740); // Начально включаем саму рубрику 740
$child_categories = get_term_children(740, 'category');
if (!empty($child_categories)) {
$included_category_ids = array_merge($included_category_ids, $child_categories);
}
// Формируем часть запроса для IN оператора
$included_category_ids_in = implode(',', array_map('intval', $included_category_ids));
$query = $wpdb->prepare("
SELECT DISTINCT p.ID, p.post_title, p.post_content, m.meta_value AS top_participation_position
FROM $wpdb->posts p
INNER JOIN $wpdb->postmeta m ON p.ID = m.post_id
LEFT JOIN $wpdb->term_relationships tr ON p.ID = tr.object_id
LEFT JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
WHERE p.post_type = 'post'
AND m.meta_key = 'top_participation_position'
AND m.meta_value != ''
AND tt.term_id IN ($included_category_ids_in)
ORDER BY CAST(m.meta_value AS UNSIGNED) ASC
");
$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>';
}
?>

25
en/pinned-post-en.php Normal file
View File

@@ -0,0 +1,25 @@
<?php
$pinned_post = get_latest_sticky_post_by_category(740);
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); ?>
</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_priority_category_en($pinned_post) ); ?></div>
</a>
<?php endif; ?>

25
en/pinned-post-mob-en.php Normal file
View File

@@ -0,0 +1,25 @@
<?php
$pinned_post = get_latest_sticky_post_by_category(740);
if ($pinned_post):
$mainpost_id = $pinned_post->ID;
?>
<div class="maintitle-mob">Top</div>
<div class="article-item__text article-item-mob">
<a href="<?php echo get_permalink($pinned_post->ID); ?>" class="article-item__image-container">
<?=show_post_image( $pinned_post->ID ); ?>
<div class="tag article-item__tag"><?=esc_html( get_priority_category_en($pinned_post->ID) );?></div>
</a>
<div class="article-item__text">
<a href="<?php echo get_permalink($pinned_post->ID); ?>" class="subtitle-16 article-item__link"><?php echo get_the_title($pinned_post->ID); ?></a>
<p class="article-item__descr text-13"><?php echo get_the_excerpt($pinned_post->ID); ?></p>
</div>
</div>
<?php endif; ?>

23
en/post-list-en.php Normal file
View File

@@ -0,0 +1,23 @@
<?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('en/content', 'post-en', ['full_width' => $post_count === 1 && $large_first_image]);
if ($post_count === ($large_first_image ? 5 : 4)) : ?>
<div class="banner-middle desktop">
<?php if (function_exists('banners_conf_display')) banners_conf_display('content_banner_desktop'); ?>
</div>
<div class="banner-middle mobile">
<?php if (function_exists('banners_conf_display')) banners_conf_display('content_banner_mobile'); ?>
</div>
<?php endif; ?>
<?php
}
wp_reset_postdata();
}
?>

33
en/related-posts-en.php Normal file
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">Read also:</div>';
echo '<div class="articles-preview">';
while ($related_posts_query->have_posts()) {
$related_posts_query->the_post();
get_template_part('en/content', 'post-en');
}
echo '</div>';
wp_reset_postdata();
}
}
?>