correct logic rfo
This commit is contained in:
@@ -49,6 +49,6 @@ if ($current_category->name !== 'РФО') {
|
||||
?>
|
||||
<?php get_template_part('rfo/post-list', null, ['query' => $query]); ?>
|
||||
</div>
|
||||
<?php custom_pagination(); ?>
|
||||
<?php custom_pagination( null, 'pagination pagination__rfo' ); ?>
|
||||
</div>
|
||||
<?php get_footer( 'rfo' ); ?>
|
||||
@@ -17,7 +17,7 @@ $full_width = $args['full_width'] ?? false;
|
||||
<? endif; ?>
|
||||
</div>
|
||||
<div class="article-rfo-details">
|
||||
<div class="article-rfo-details-text">Подробнее</div><div class="article-rfo-details-icon"><svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<div class="article-rfo-details-text"><a href="<?php the_permalink();?>">Подробнее</a></div><div class="article-rfo-details-icon"><svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M8.57157 16.4283H16.4287M16.4287 16.4283V8.5712M16.4287 16.4283L8.57157 8.5712" stroke="#006842" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
|
||||
</svg></div></div>
|
||||
</div>
|
||||
|
||||
@@ -18,7 +18,7 @@ $class = $full_width ? 'article-item-main__rfo' : 'article-item-rfo';
|
||||
<? endif; ?>
|
||||
</div>
|
||||
<div class="article-rfo-details">
|
||||
<div class="article-rfo-details-text">Подробнее</div><div class="article-rfo-details-icon"><svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<div class="article-rfo-details-text"><a href="<?php the_permalink();?>">Подробнее</a></div><div class="article-rfo-details-icon"><svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M8.57157 16.4283H16.4287M16.4287 16.4283V8.5712M16.4287 16.4283L8.57157 8.5712" stroke="#006842" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
|
||||
</svg></div></div>
|
||||
</div>
|
||||
|
||||
@@ -1,35 +1,10 @@
|
||||
version: '3'
|
||||
services:
|
||||
|
||||
mkcert:
|
||||
build:
|
||||
context: ./mkcert
|
||||
dockerfile: Dockerfile
|
||||
environment:
|
||||
CERT_IP: 194.87.253.43 # Заменить на нужный IP
|
||||
volumes:
|
||||
- ./certs:/certs # Важно: volume монтируем относительно docker-compose.yml
|
||||
dev:
|
||||
#build: .
|
||||
image: agro_front
|
||||
app:
|
||||
build: .
|
||||
volumes:
|
||||
- ./dist:/app/dist
|
||||
- ./src:/app/src
|
||||
- ./public:/app/public
|
||||
command: ["dev"]
|
||||
environment:
|
||||
- NODE_ENV=development
|
||||
ports:
|
||||
- 5173:5173
|
||||
container_name: agro_front
|
||||
|
||||
build:
|
||||
#build: .
|
||||
image: agro_front
|
||||
volumes:
|
||||
- ./dist:/app/dist
|
||||
- ./src:/app/src
|
||||
- ./public:/app/public
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
command: ["build"]
|
||||
|
||||
@@ -124,6 +124,10 @@
|
||||
|
||||
}
|
||||
|
||||
.pagination__rfo {
|
||||
border-top: none!important;
|
||||
}
|
||||
|
||||
/* Мобильные (1 в ряд) */
|
||||
@media (max-width: 768px) {
|
||||
|
||||
|
||||
119
functions.php
119
functions.php
@@ -219,7 +219,7 @@ function custom_wpseo_breadcrumb_output($output)
|
||||
|
||||
|
||||
|
||||
function custom_pagination($query = null)
|
||||
function custom_pagination($query = null, $class = "pagination")
|
||||
{
|
||||
global $wp_query;
|
||||
$query = $query ?: $wp_query;
|
||||
@@ -241,7 +241,7 @@ function custom_pagination($query = null)
|
||||
$txt['next'] = 'Далее';
|
||||
}
|
||||
|
||||
echo '<div class="pagination"><div class="pagination__list">';
|
||||
echo '<div class="'.$class.'"><div class="pagination__list">';
|
||||
|
||||
// Кнопка "Назад"
|
||||
if ($current_page > 1) {
|
||||
@@ -601,6 +601,41 @@ function get_category_name($post = null)
|
||||
return $category_name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Получает полный URL категории (с учётом иерархии)
|
||||
*
|
||||
* @param int|WP_Post|null $post ID поста, объект или null (текущий пост)
|
||||
* @return string Полный URL категории (включая родительские) или URL архива по умолчанию
|
||||
*/
|
||||
function get_category_url($post = null) {
|
||||
// Получаем все категории поста
|
||||
$categories = get_the_category($post);
|
||||
|
||||
if (empty($categories) || is_wp_error($categories)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Фильтруем категории, исключая слаг 'all-events'
|
||||
$filtered_categories = array_filter($categories, function ($category) {
|
||||
return $category instanceof WP_Term && $category->slug !== 'all-events';
|
||||
});
|
||||
|
||||
if (!empty($filtered_categories)) {
|
||||
// Берём первую подходящую категорию
|
||||
$first_category = reset($filtered_categories);
|
||||
|
||||
// Получаем ссылку по всем правилам WordPress
|
||||
$category_url = get_category_link($first_category->term_id);
|
||||
|
||||
// Возвращаем безопасный URL
|
||||
return esc_url($category_url);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
function get_category_name_en($post = null)
|
||||
{
|
||||
$categories = get_the_category($post);
|
||||
@@ -1273,6 +1308,37 @@ function replace_first_figure_in_content($content) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
function delete_first_figure_in_content($content) {
|
||||
|
||||
global $post;
|
||||
|
||||
if (!isset($post->ID)) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
$startPos = strpos($content, '<figure');
|
||||
if ($startPos === false) {
|
||||
return $content; // Если <figure> не найдено, возвращаем исходный контент
|
||||
}
|
||||
|
||||
$endPos = strpos($content, '</figure>', $startPos);
|
||||
if ($endPos === false) {
|
||||
return $content; // Если </figure> не найдено, возвращаем исходный контент
|
||||
}
|
||||
|
||||
// Рассчитываем длину части, которую нужно заменить
|
||||
$endPos += strlen('</figure>'); // Двигаем указатель на конец тега </figure>
|
||||
$figureHtml = substr($content, $startPos, $endPos - $startPos);
|
||||
|
||||
// Заменяем найденный кусок на новый HTML
|
||||
$newContent = substr_replace($content, '', $startPos, $endPos - $startPos);
|
||||
|
||||
|
||||
return $newContent;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function add_cookie_consent() {
|
||||
if (!isset($_COOKIE['cookie_consent_accepted'])) {
|
||||
@@ -1303,6 +1369,55 @@ add_filter('rest_category_query', function($args, $request) {
|
||||
}, 10, 2);
|
||||
|
||||
|
||||
/**
|
||||
* Рассчитывает время чтения поста (в минутах) со склонением слова "минута"
|
||||
*
|
||||
* @param int|null $post_id ID поста. Если null, используется текущий пост в цикле.
|
||||
* @param bool $include_text Нужно ли добавлять "мин." или полный текст (по умолчанию true)
|
||||
* @return string Пример: "5 минут" или "1 минута"
|
||||
*/
|
||||
function calculate_reading_time($post_id = null, $include_text = true) {
|
||||
// Если ID поста не передан, пытаемся определить текущий пост
|
||||
if ($post_id === null) {
|
||||
global $post;
|
||||
|
||||
if (!isset($post) || !is_a($post, 'WP_Post')) {
|
||||
return $include_text ? '0 минут' : '0';
|
||||
}
|
||||
|
||||
$post_id = $post->ID;
|
||||
}
|
||||
|
||||
$content = get_post_field('post_content', $post_id);
|
||||
|
||||
if (empty($content)) {
|
||||
return $include_text ? '0 минут' : '0';
|
||||
}
|
||||
|
||||
$word_count = str_word_count(strip_tags($content));
|
||||
//$reading_speed = apply_filters('reading_time_speed', 200); // Фильтр для изменения скорости
|
||||
$reading_speed = 200;
|
||||
$reading_time = ceil($word_count / $reading_speed);
|
||||
$reading_time = max(1, $reading_time); // Минимум 1 минута
|
||||
|
||||
// Склонение слова "минута"
|
||||
$minutes_text = 'минут';
|
||||
$last_digit = $reading_time % 10;
|
||||
$last_two_digits = $reading_time % 100;
|
||||
|
||||
if ($last_digit == 1 && $last_two_digits != 11) {
|
||||
$minutes_text = 'минута';
|
||||
} elseif (($last_digit >= 2 && $last_digit <= 4) && !($last_two_digits >= 12 && $last_two_digits <= 14)) {
|
||||
$minutes_text = 'минуты';
|
||||
}
|
||||
|
||||
return $include_text
|
||||
? sprintf('%d %s', $reading_time, $minutes_text)
|
||||
: $reading_time;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ add_filter('single_template', function($template) {
|
||||
: $category;
|
||||
|
||||
// Если рубрика в списке целевых
|
||||
if (in_array($parent_category->slug, $target_parent_slugs)) {
|
||||
if (in_array($parent_category->slug, $target_parent_slugs)) {
|
||||
// Ищем шаблон single-{родительская-рубрика}.php
|
||||
$new_template = locate_template("single-{$parent_category->slug}.php");
|
||||
if ($new_template) return $new_template;
|
||||
|
||||
@@ -13,5 +13,5 @@
|
||||
</svg>
|
||||
</span>
|
||||
</li>
|
||||
<li><a href="<?=$category_url?>"><?=get_category_name();?></a></li>
|
||||
<li><a href="<?=get_category_url();?>"><?=get_category_name();?></a></li>
|
||||
</ul>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="header-rfo-logoline">
|
||||
<img src="https://agroexpert.press/wp-content/themes/agroexpert/frontend/img/rfo-logo.svg" >
|
||||
<a href="<?=home_url();?>/rfo/"><img src="https://agroexpert.press/wp-content/uploads/2025/06/rfo-logo.svg" alt="Республиканский фумигационный отряд">
|
||||
<div class="agroexpess-logo">
|
||||
<?php $site_logo = get_field('site_logo', 'option');?>
|
||||
<a href="<?php echo home_url(); ?>" class="logo header__logo">
|
||||
|
||||
140
single-rfo.php
Normal file
140
single-rfo.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php get_header( 'rfo' ); ?>
|
||||
|
||||
<div class="content-rfo">
|
||||
|
||||
<?php get_template_part('rfo/breadcrumbs-rfo'); ?>
|
||||
|
||||
<div class="rfo__rubric"><?=get_category_name(); ?></div>
|
||||
|
||||
<div class="article-single">
|
||||
|
||||
|
||||
<div class="featured-post">
|
||||
<?if ( has_post_thumbnail() ) :?>
|
||||
<div class="featured-image-wrapper">
|
||||
<div class="featured-image">
|
||||
<!--<img src="https://agroexpert.press/wp-content/uploads/2024/06/korma-proizvodstvo.jpg" />-->
|
||||
<?php the_post_thumbnail(); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="photo-credit-tag">
|
||||
<span><?the_post_thumbnail_caption()?></span>
|
||||
</div>
|
||||
<? endif; ?>
|
||||
|
||||
<div class="post-overlay">
|
||||
<div class="post-title__rfo desktop"><?php the_title(); ?></div>
|
||||
<div class="post-excerpt__rfo desktop"><?php the_excerpt(); ?></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<h1 class="post-title__rfo mobile"><?php the_title(); ?></h1>
|
||||
<div class="post-excerpt__rfo mobile"><?php the_excerpt(); ?></div>
|
||||
|
||||
|
||||
<div class="article-single--rfo">
|
||||
|
||||
|
||||
|
||||
<div class="article-info--rfo">
|
||||
|
||||
<div class="article-info-element--rfo">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M4 4H20V18C20 19.1046 19.1046 20 18 20H6C4.89543 20 4 19.1046 4 18V4Z" stroke="#006842" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
|
||||
<path d="M4 8H20" stroke="#006842" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
|
||||
<path d="M16 3V5" stroke="#006842" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
|
||||
<path d="M8 3V5" stroke="#006842" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
|
||||
</svg>
|
||||
<div class="article-date--rfo">
|
||||
<?php $formatted_date = format_event_date();
|
||||
echo $formatted_date;?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="article-info-element--rfo">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_362_2372)">
|
||||
<circle cx="12" cy="12" r="9" stroke="#006842" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
|
||||
<path d="M12 8V13.3333H16.3333" stroke="#006842" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_362_2372">
|
||||
<rect width="24" height="24" fill="white" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
<div><?=calculate_reading_time()?> на прочтение</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="article-text--rfo">
|
||||
<?php
|
||||
//$content = get_the_content();
|
||||
$post_id = get_the_ID();
|
||||
|
||||
//echo replace_first_figure_in_content($content);
|
||||
|
||||
$content = apply_filters('the_content', get_the_content());
|
||||
echo delete_first_figure_in_content($content);?>
|
||||
|
||||
<div class="social-post--rfo">
|
||||
<div class="social-post-info--rfo">Подписывайтесь на нас в <a href="https://dzen.ru/agroexpert_press?favid=254170145" target="_blank">Дзен</a> и <a href="https://t.me/agroexpert_press" target="_blank">Telegram</a></div>
|
||||
<div class="social-post-icons--rfo">
|
||||
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="36" height="36" rx="10" fill="white" />
|
||||
<path d="M19.7357 19.7357C18.3214 21.195 18.2186 23.0143 18.0964 27C21.8121 27 24.3771 26.9871 25.7014 25.7014C26.9871 24.3771 27 21.69 27 18.0964C23.0143 18.225 21.195 18.3214 19.7357 19.7357ZM9 18.0964C9 21.69 9.01286 24.3771 10.2986 25.7014C11.6229 26.9871 14.1879 27 17.9036 27C17.775 23.0143 17.6786 21.195 16.2643 19.7357C14.805 18.3214 12.9857 18.2186 9 18.0964ZM17.9036 9C14.1943 9 11.6229 9.01286 10.2986 10.2986C9.01286 11.6229 9 14.31 9 17.9036C12.9857 17.775 14.805 17.6786 16.2643 16.2643C17.6786 14.805 17.7814 12.9857 17.9036 9ZM19.7357 16.2643C18.3214 14.805 18.2186 12.9857 18.0964 9C21.8121 9 24.3771 9.01286 25.7014 10.2986C26.9871 11.6229 27 14.31 27 17.9036C23.0143 17.775 21.195 17.6786 19.7357 16.2643Z" fill="black" />
|
||||
<path d="M27 18.0964V17.9036C23.0143 17.775 21.195 17.6786 19.7357 16.2643C18.3214 14.805 18.2186 12.9857 18.0964 9H17.9036C17.775 12.9857 17.6786 14.805 16.2643 16.2643C14.805 17.6786 12.9857 17.7814 9 17.9036V18.0964C12.9857 18.225 14.805 18.3214 16.2643 19.7357C17.6786 21.195 17.7814 23.0143 17.9036 27H18.0964C18.225 23.0143 18.3214 21.195 19.7357 19.7357C21.195 18.3214 23.0143 18.2186 27 18.0964Z" fill="white" />
|
||||
</svg>
|
||||
<svg width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="36" height="36" rx="10" fill="white" />
|
||||
<path d="M26.1 11.3418L23.3951 25.4628C23.3951 25.4628 23.0167 26.4419 21.977 25.9724L15.7361 21.0171L15.7072 21.0025C16.5502 20.2187 23.0872 14.1322 23.3729 13.8563C23.8151 13.429 23.5406 13.1747 23.027 13.4974L13.3711 19.8475L9.64587 18.5495C9.64587 18.5495 9.05963 18.3335 9.00323 17.864C8.94609 17.3937 9.66517 17.1393 9.66517 17.1393L24.8518 10.9699C24.8518 10.9699 26.1 10.4019 26.1 11.3418Z" fill="black" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</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('rfo/related-posts'); ?>
|
||||
<? 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; ?>
|
||||
<div class="article-show-next__rfo">
|
||||
<a href="<?= home_url(); ?>/rfo">На главную</a>
|
||||
</div>
|
||||
<div class="articles__spacer-container">
|
||||
<div class="articles__spacer"></div>
|
||||
<div class="articles__spacer"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php get_footer( 'rfo' ); ?>
|
||||
Reference in New Issue
Block a user