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

View File

@@ -1,7 +1,7 @@
<?php get_header( 'en' ); ?> <?php get_header( 'en' ); ?>
<div class="content-middle articles-wrapper"> <div class="content-middle articles-wrapper">
<?php include(get_template_directory().'/partials/pinned-post-mob.php');?> <?php include(get_template_directory().'/en/pinned-post-mob-en.php');?>
<?php get_template_part('partials/rubrics-mobile'); ?> <?php get_template_part('partials/rubrics-mobile'); ?>
<div class="articles-preview"> <div class="articles-preview">
<?php <?php
@@ -12,11 +12,11 @@
'orderby' => 'date', // сортировка по дате 'orderby' => 'date', // сортировка по дате
'order' => 'DESC', // по убыванию (сначала новые) 'order' => 'DESC', // по убыванию (сначала новые)
'ignore_sticky_posts' => 1, 'ignore_sticky_posts' => 1,
'cat' => get_expression_en() 'cat' => EN_PARTS
); );
$query = new WP_Query($args); $query = new WP_Query($args);
?> ?>
<?php get_template_part('partials/post-list', null, ['large_first_image' => false, 'query' => $query]); ?> <?php get_template_part('en/post-list-en', null, ['large_first_image' => false, 'query' => $query]); ?>
</div> </div>
<button class="articles-preview__show-next">More Read</button> <button class="articles-preview__show-next">More Read</button>
</div> </div>

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>

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();
}
}
?>

View File

@@ -1,7 +1,7 @@
<?php if (!is_404() && !is_500()) : ?> <?php if (!is_404() && !is_500()) : ?>
<? if (!is_page('search') && !is_search()) : ?> <? if (!is_page('search') && !is_search()) : ?>
<div class="content-right"> <div class="content-right">
<?php get_sidebar('right'); ?> <?php get_sidebar('right-en'); ?>
</div> </div>
<? endif; ?> <? endif; ?>
</div> </div>
@@ -17,11 +17,11 @@
<img src="https://agroexpert.press/wp-content/uploads/2024/05/agroexpert_horizontally.svg" alt="agroexpert.press" width="145" /> <img src="https://agroexpert.press/wp-content/uploads/2024/05/agroexpert_horizontally.svg" alt="agroexpert.press" width="145" />
</a> </a>
<nav class="nav footer__nav"> <nav class="nav footer__nav">
<?php get_template_part('partials/mainmenu-en'); ?> <?php get_template_part('en/mainmenu-en'); ?>
</nav> </nav>
<div class="footer-top__right"> <div class="footer-top__right">
<a href="#" class="to-top"> <a href="#" class="to-top">
<span>Наверх</span> <span>Up</span>
<svg width="9" height="6" viewBox="0 0 9 6" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg width="9" height="6" viewBox="0 0 9 6" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="3.69409" y="1.05029" width="1" height="5.22423" transform="rotate(45 3.69409 1.05029)" fill="black" /> <rect x="3.69409" y="1.05029" width="1" height="5.22423" transform="rotate(45 3.69409 1.05029)" fill="black" />
<rect width="1" height="6" transform="matrix(-0.707107 0.707107 0.707107 0.707107 4.1333 0.525146)" fill="black" /> <rect width="1" height="6" transform="matrix(-0.707107 0.707107 0.707107 0.707107 4.1333 0.525146)" fill="black" />
@@ -34,14 +34,20 @@
<div class="footer-bottom"> <div class="footer-bottom">
<div class="container"> <div class="container">
<div class="footer-bottom__inner"> <div class="footer-bottom__inner">
<?php $copyright = get_field('copyright', 'option'); ?>
<div class="footer-bottom__text desktop"> <div class="footer-bottom__text desktop">
<?= sprintf('© %d %s', date('Y'), $copyright); ?> <?= sprintf('© %d %s', date('Y'), 'Agroexpert'); ?>
<!--Rating::top.agroserver.ru counter--> <!--Rating::top.agroserver.ru counter-->
</div> </div>
<?php get_template_part('partials/menu-footer-bottom'); ?> <?php
$menu_items = wp_get_nav_menu_items(774);
foreach ($menu_items as $item) {
echo '<a href="'.esc_url($item->url).'" class="footer-bottom__text footer-bottom__link" traget="_blank">'.esc_html($item->title).'</a>';
}
?>
<div class="socials footer__socials"> <div class="socials footer__socials">
<?php get_template_part('partials/menu-socials'); ?> <?php get_template_part('partials/menu-socials'); ?>
<a href="https://agroserver.ru/" target="_blank"> <a href="https://agroserver.ru/" target="_blank">

View File

@@ -1,6 +1,10 @@
<?php <?php
setlocale(LC_TIME, 'ru_RU.UTF-8'); setlocale(LC_TIME, 'ru_RU.UTF-8');
define('ENPART', 740);
define('EN_PARTS', '746,741,742,743,744,745');
require get_template_directory().'/dzenews.php'; //add support dzen require get_template_directory().'/dzenews.php'; //add support dzen
function theme_setup() function theme_setup()
@@ -150,6 +154,19 @@ function format_event_date()
return $date_text . ', ' . $time; return $date_text . ', ' . $time;
} }
function get_published_date_in_english() {
// Получение времени публикации поста
$post_time = get_the_time('H:i');
// Получение даты публикации поста на английском языке
$post_date = get_post_time('F j, Y');
// Формирование строки с датой и временем публикации
return $post_time . ', ' . $post_date;
}
/** /**
* Фильтр для изменения разметки хлебных крошек Yoast SEO. * Фильтр для изменения разметки хлебных крошек Yoast SEO.
*/ */
@@ -672,6 +689,47 @@ function last_sticky_post() {
} }
function get_latest_sticky_post_by_category($category_id) {
// Получение всех закрепленных постов
$sticky_posts = get_option('sticky_posts');
if (empty($sticky_posts)) {
return null;
}
// Получение всех постов, которые включены в закрепленные посты
$args = array(
'post__in' => $sticky_posts,
'posts_per_page' => -1, // Получаем все закрепленные посты
'ignore_sticky_posts' => 1, // Игнорируем параметры отображения закрепленных постов
);
$posts = get_posts($args);
// Получаем ID всех подрубрик рубрики
$category_ids = get_term_children($category_id, 'category');
$category_ids[] = $category_id; // Включаем основную рубрику
// Фильтрация постов по категории и её подрубрикам
$filtered_posts = array_filter($posts, function($post) use ($category_ids) {
$post_categories = wp_get_post_categories($post->ID);
return array_intersect($post_categories, $category_ids);
});
if (empty($filtered_posts)) {
return null;
}
// Сортировка постов по дате в обратном порядке
usort($filtered_posts, function($a, $b) {
return strtotime($b->post_date) - strtotime($a->post_date);
});
// Возвращаем самый последний пост
return $filtered_posts[0];
}
// отправка писем через свой почтовый сервис // отправка писем через свой почтовый сервис
function agroxpert_send_smtp_email( $phpmailer ) { function agroxpert_send_smtp_email( $phpmailer ) {
@@ -778,7 +836,7 @@ add_action('wpcf7_mail_sent', 'my_custom_mail_sent' );
//все рубрики англ версии //все рубрики англ версии
function get_expression_en() { function get_expression_en( $str = false ) {
#cache result #cache result
static $res = null; static $res = null;
@@ -834,69 +892,71 @@ function get_expression_parts() {
} }
function get_priority_category_en($post_id = null) {
//свой шаблон для категории и подкатегории
add_filter('category_template', function (){
$category = get_queried_object();
$parent_id = $category->category_parent; // ID родителя
$template = array(); //массив для поиска шаблонов
$templates[] = "category-{$category->slug}.php";
$templates[] = "category-{$category->term_id}.php";
if ($parent_id > 0){ if ($post_id === null) {
$post_id = get_the_ID();
$parent = get_category($parent_id); }
$templates[] = "category-{$parent->slug}.php";
$templates[] = "category-{$parent->term_id}.php"; // Получаем массив категорий поста
$categories = get_the_category($post_id);
if (empty($categories)) {
return null;
} }
$templates[] = 'category.php'; $en_category = null;
return locate_template($templates); // Проходим по всем категориям поста
foreach ($categories as $category) {
// Проверяем, содержит ли название категории 'en'
if (stripos($category->name, 'en') !== false) {
$en_category = $category->name;
} else {
// Если нашли категорию, не содержащую 'en', возвращаем её название
return $category->name;
}
}
// Если нет категорий, кроме 'en', возвращаем категорию 'en'
}); return $en_category;
}
// рубрики английской версии
function use_custom_template_for_en_subcategories($template) {
if (is_category()) {
$category = get_queried_object();
// Проверяем, является ли текущая категория подрубрикой "EN"
$parent_id = $category->parent;
if ($parent_id && $parent_id == get_cat_ID('EN')) {
// Устанавливаем путь к вашему новому шаблону
$new_template = locate_template('en/category-en-sub.php');
if ($new_template) {
return $new_template;
}
}
} else if (is_single()) {
$categories = get_the_category();
foreach ($categories as $category) {
// Проверяем, является ли текущая категория или ее родительская категория "EN"
if ($category->term_id == get_cat_ID('EN') || $category->parent == get_cat_ID('EN')) {
// Устанавливаем путь к вашему новому шаблону
$new_template = locate_template('single-en.php');
if ($new_template) {
return $new_template;
}
}
}
}
return $template;
}
add_filter('template_include', 'use_custom_template_for_en_subcategories');
//свой шаблон для категории и подкатегории
add_filter( 'single_template', function ( $single_template ) {
$category = (array) get_the_category();
foreach( $category as $cat ) {
if ( file_exists(TEMPLATEPATH . "/single-{$cat->term_id}.php") ){
return TEMPLATEPATH . "/single-{$cat->term_id}.php";
}
$parent_id = $cat->parent; // шаблон гл рубрики
if ($parent_id > 0){
$parent = get_category($parent_id);
if (file_exists(TEMPLATEPATH . "/single-{$parent->term_id}.php") )
return TEMPLATEPATH . "/single-{$parent->term_id}.php";
}
}
return $single_template;
}, PHP_INT_MAX, 2 );

View File

@@ -49,17 +49,15 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<body <?php body_class(); ?>> <body <?php body_class(); ?>>
<?php wp_body_open(); ?> <?php wp_body_open(); ?>
<div id="app"> <div id="app">
<header class="header"> <header class="header">
<div class="container"> <div class="container">
<div class="header__inner"> <div class="header__inner">
<?php $site_logo = get_field('site_logo', 'option'); ?> <?php $site_logo = get_field('site_logo', 'option'); ?>
<a href="<?php echo home_url(); ?>" class="logo header__logo"> <a href="<?php echo home_url(); ?>/en" class="logo header__logo">
<img src="https://agroexpert.press/wp-content/uploads/2024/05/agroexpert_horizontally.svg" alt="agroexpert.press" width="188" /> <img src="https://agroexpert.press/wp-content/uploads/2024/05/agroexpert_horizontally.svg" alt="agroexpert.press" width="188" />
</a> </a>
<nav class="nav header__nav"> <nav class="nav header__nav">
<?php get_template_part('partials/mainmenu-en'); ?> <?php get_template_part('en/mainmenu-en'); ?>
</nav> </nav>
<div class="header__right"> <div class="header__right">
<div class="header__actions"> <div class="header__actions">
@@ -104,7 +102,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
</div> </div>
<div class="header-mobile"> <div class="header-mobile">
<nav class="nav header-mobile__nav"> <nav class="nav header-mobile__nav">
<?php get_template_part('partials/menu-primary'); ?> <?php //get_template_part('partials/menu-primary'); ?>
</nav> </nav>
<div class="socials header-mobile__socials"> <div class="socials header-mobile__socials">
<?php get_template_part('partials/menu-socials'); ?> <?php get_template_part('partials/menu-socials'); ?>
@@ -119,16 +117,16 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
</div> </div>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php if (is_front_page()) : ?> <?php if ( is_category(740) && $paged <= 1 ) : ?>
<div class="hero"> <div class="hero">
<div class="container hero__container"> <div class="container hero__container">
<div class="hero__inner"> <div class="hero__inner">
<?php get_template_part('partials/pinned-post'); ?> <?php get_template_part('en/pinned-post-en'); ?>
<div class="most-read hero__most-read"> <div class="most-read hero__most-read">
<div class="most-read__inner"> <div class="most-read__inner">
<p class="most-read__title subtitle-20">Самое читаемое</p> <p class="most-read__title subtitle-20">Popular</p>
<div class="most-read__links"> <div class="most-read__links">
<?php get_template_part('partials/most-read-posts'); ?> <?php get_template_part('en/most-read-posts-en'); ?>
</div> </div>
</div> </div>
</div> </div>
@@ -138,7 +136,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<div class="menu"> <div class="menu">
<div class="container"> <div class="container">
<div class="menu__inner"> <div class="menu__inner">
<?php get_template_part('partials/category-menu'); ?> <?php get_template_part('en/category-menu-en'); ?>
</div> </div>
</div> </div>
</div> </div>
@@ -148,7 +146,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<div class="content"> <div class="content">
<? if (!is_page('search') && !is_search() && !is_404()) : ?> <? if (!is_page('search') && !is_search() && !is_404()) : ?>
<div class="content-left"> <div class="content-left">
<?php get_sidebar('left'); ?> <?php get_sidebar('left-en'); ?>
</div> </div>
<? endif; ?> <? endif; ?>
<? endif; ?> <? endif; ?>

122
page-contacts.php Normal file
View File

@@ -0,0 +1,122 @@
<?php
/*
Template Name: Шаблон страницы контакты
*/
?>
<?php get_header( 'en' ); ?>
<div class="content-middle articles-wrapper">
<?php get_template_part('partials/rubrics-mobile'); ?>
<div class="section-title border-top">
<h1 class="section-title__title"><? the_title()?></h1>
</div>
<div class="articles-single">
<div class="contacts__map-container">
<div class="contacts__map" id="contacts_map"></div>
</div>
<div class="contacts__container">
<div class="contacts__text-block">
<p class="contacts__block-title subtitle-13">Address</p>
<p class="contacts__block-subtitle text-13">Office 12, 102/31 Prospekt Mira<br>129626, Moscow</p>
</div>
<div class="contacts__text-block">
<p class="contacts__block-title subtitle-13">Telephone</p>
<p class="contacts__block-subtitle text-13"><a href="tel:74959250634"><?=get_field('phone', 'option');?></a></p>
</div>
<div class="contacts__text-block">
<p class="contacts__block-title subtitle-13">E-mail</p>
<p class="contacts__block-email text-13"><a href="mailto:<?=get_field('email', 'option');?>"><?=get_field('email', 'option');?></a></p>
</div>
<div class="contacts__text-block">
<p class="contacts__block-title subtitle-13">To inquire about advertising, contact us</p>
<p class="contacts__block-subtitle text-13"><a href="tel:79263663700">+7 (926) 366 37 00</a></p>
<p class="contacts__block-email text-13"><a href="mailto:pr@agroexpert.press">pr@agroexpert.press</a></p>
</div>
</div>
</div>
<a href="<?= home_url() ?>/en" class="articles-preview__show-next">On top</a>
<div class="articles__spacer-container">
<div class="articles__spacer"></div>
<div class="articles__spacer"></div>
</div>
</div>
<script async src="https://api-maps.yandex.ru/2.1/?lang=ru_RU&apikey=8f62a900-d60a-4059-887b-83fe5d19d0a5"
type="text/javascript"></script>
<?php
$params = get_field('yandex_params', 'option');
?>
<script type="text/javascript">
const handleInit = () => {
ymaps.ready(init);
// Функция ymaps.ready() будет вызвана, когда
// загрузятся все компоненты API, а также когда будет готово DOM-дерево.
function init() {
// Создание карты.
var myMap = new ymaps.Map("contacts_map", {
// Координаты центра карты.
// Порядок по умолчанию: «широта, долгота».
// Чтобы не определять координаты центра карты вручную,
// воспользуйтесь инструментом Определение координат.
center: [<?= $params['latitude']?>, <?= $params['longitude']?>],
// Уровень масштабирования. Допустимые значения:
// от 0 (весь мир) до 19.
zoom: 17
});
const Place = new ymaps.Placemark([<?= $params['latitude']?>, <?= $params['longitude']?>], {
hintContent: '<?= $params['name_point']?>',
balloonContent: '',
balloonHeader: '',
}, {
iconLayout: 'default#image',
iconImageHref: '<?= $params['image_point']['url']; ?>',
iconImageSize: [36, 44],
iconShape: {
type: 'Rectangle',
coordinates: [
[-30, -93],
[30, 0]
]
}
});
myMap.geoObjects.add(Place)
}
}
document.addEventListener('DOMContentLoaded', () => {
if (typeof ymaps !== 'undefined') {
handleInit();
} else {
setTimeout(() => {
handleInit();
}, 1000)
}
} );
</script>
<script>
function handleSubmit() {
let wpcfForm = document.querySelector( '.wpcf7' );
wpcfForm.addEventListener( 'wpcf7submit', function( event ) {
var inputs = event.detail.inputs;
for ( var i = 0; i < inputs.length; i++ ) {
if(inputs[i].value === '') return;
}
}, false );
}
document.addEventListener('DOMContentLoaded', () => {
const form = document.getElementById('contact__form')
form.addEventListener('submit', handleSubmit)
});
</script>
<?php get_footer( 'en' ); ?>

View File

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

View File

@@ -1,6 +1,6 @@
<?php <?php
$pinned_post = last_sticky_post(); $pinned_post = get_latest_sticky_post_by_category(19);
if ($pinned_post): if ($pinned_post):
$mainpost_id = $pinned_post->ID; $mainpost_id = $pinned_post->ID;

View File

@@ -1,6 +1,6 @@
<?php <?php
$pinned_post = last_sticky_post(); $pinned_post = get_latest_sticky_post_by_category(19);
if ($pinned_post) : if ($pinned_post) :

39
sidebar-left-en.php Normal file
View File

@@ -0,0 +1,39 @@
<?php if (!is_front_page()) : ?>
<div class="menu-vertical desktop">
<div class="menu-vertical__inner">
<?php get_template_part('en/category-menu-for-category-en'); ?>
</div>
</div>
<?php endif; ?>
<?php //if (is_active_sidebar('left-sidebar')) : ?>
<?php //dynamic_sidebar('left-sidebar'); ?>
<?php //endif; ?>
<?php //get_template_part('partials/latest-interview-post'); ?>
<?php if (is_front_page()) : ?>
<div class="most-read mobile">
<div class="most-read__inner">
<p class="most-read__title subtitle-20">Самое читаемое</p>
<div class="most-read__links">
<?php get_template_part('partials/most-read-posts'); ?>
</div>
</div>
</div>
<div class="banner-left desktop">
<?php if (function_exists('banners_conf_display')) banners_conf_display('left_sidebar_banner_desktop_1'); ?>
</div>
<div class="banner-left mobile">
<?php if (function_exists('banners_conf_display')) banners_conf_display('left_sidebar_banner_mobile_1'); ?>
</div>
<div class="banner-left desktop">
<?php if (function_exists('banners_conf_display')) banners_conf_display('left_sidebar_banner_desktop_2'); ?>
</div>
<div class="banner-left mobile">
<?php if (function_exists('banners_conf_display')) banners_conf_display('left_sidebar_banner_mobile_2'); ?>
</div>
<?php endif; ?>

27
sidebar-right-en.php Normal file
View File

@@ -0,0 +1,27 @@
<?php if (!is_category(740)) : ?>
<div class="most-read content-right__most-read">
<div class="most-read__inner">
<p class="most-read__title subtitle-20">Popular</p>
<div class="most-read__links">
<?php get_template_part('en/most-read-posts-en'); ?>
</div>
</div>
</div>
<?php endif; ?>
<?php get_template_part('en/latest-legislation-posts-en'); ?>
<div class="banner-left desktop">
<?php if (function_exists('banners_conf_display')) banners_conf_display('right_sidebar_banner_desktop_1'); ?>
</div>
<div class="banner-left mobile">
<?php if (function_exists('banners_conf_display')) banners_conf_display('right_sidebar_banner_mobile_1'); ?>
</div>
<div class="banner-left desktop">
<?php if (function_exists('banners_conf_display')) banners_conf_display('right_sidebar_banner_desktop_2'); ?>
</div>
<div class="banner-left mobile">
<?php if (function_exists('banners_conf_display')) banners_conf_display('right_sidebar_banner_mobile_2'); ?>
</div>

80
single-en.php Normal file
View File

@@ -0,0 +1,80 @@
<?php get_header('en'); ?>
<?php if (in_category('events')) : ?>
<?php get_template_part('single-events'); ?>
<? else : ?>
<div class="content-middle articles-wrapper">
<?php get_template_part('partials/rubrics-mobile'); ?>
<div class="article-single">
<div class="article-time article-single__time">
<?php if (!in_category('partners')) : ?>
<img src="<?= get_asset('/icons/time.svg'); ?>" alt="" />
<?php echo 'Published: '.get_published_date_in_english(); ?>
<? endif; ?>
</div>
<?php if (!in_category('partners')) : ?>
<div class="article-single__tag"><?=get_category_name(); ?></div>
<? endif; ?>
<h1 class="article-single__title">
<?php the_title(); ?>
</h1>
<?php
//$author = get_userdata(get_post_field('post_author'));
?>
<?php if (!in_category('partners')) : ?>
<?php if ( $author AND $author->display_name !== 'agroexpert.press') : ?>
<div class="article-author">
<div class="article-author__name">
<?= $author->display_name; ?><br>
<? if ( $author->description !== '' ):?>
<?=$author->description?>
<?endif?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
<div class="article-single__content">
<?php the_content(); ?>
</div>
</div>
<?php // get_template_part('partials/rtb-single'); ?>
<?php get_template_part('partials/featured-posts'); ?>
<?php if (!in_category('partners')) : ?>
<?php get_template_part('en/related-posts-en'); ?>
<? else : ?>
<div class="section-title">
<h2 class="section-title__title subtitle-18">Еще по теме</h2>
</div>
<div class="suggestion-container">
<?
$args = [
'category_name' => 'partners',
'post_status' => 'publish',
'order' => 'ASC',
'posts_per_page' => 4
];
$posts = get_posts($args);
$counter = 0;
foreach ($posts as $post) : ?>
<div class="suggestion-item">
<a href="<?= the_permalink() ?>">
<h3 class="subtitle-16"> <?= the_title() ?></h3>
</a>
</div>
<? endforeach; ?>
</div>
<? endif; ?>
<a href="<?= home_url(); ?>/en" class="articles-preview__show-next desktop">On Top</a>
<div class="articles__spacer-container">
<div class="articles__spacer"></div>
<div class="articles__spacer"></div>
</div>
</div>
<? endif; ?>
<?php get_footer( 'en' ); ?>