correct bg menus
This commit is contained in:
@@ -6,7 +6,6 @@ $class = $full_width ? 'article-item article-item--lg' : 'article-item';
|
|||||||
<div class="<?= $class; ?>">
|
<div class="<?= $class; ?>">
|
||||||
<a href="<?php the_permalink(); ?>" class="article-item__image-container">
|
<a href="<?php the_permalink(); ?>" class="article-item__image-container">
|
||||||
<?= show_post_image(); ?>
|
<?= show_post_image(); ?>
|
||||||
<div class="tag article-item__tag"><?=get_category_name(); ?></div>
|
|
||||||
</a>
|
</a>
|
||||||
<div class="article-item__text">
|
<div class="article-item__text">
|
||||||
<div class="article-time">
|
<div class="article-time">
|
||||||
|
|||||||
133
functions.php
133
functions.php
@@ -19,7 +19,7 @@ function redirect_non_admin_users() {
|
|||||||
$current_user = wp_get_current_user();
|
$current_user = wp_get_current_user();
|
||||||
|
|
||||||
// Проверяем, если пользователь не является администратором
|
// Проверяем, если пользователь не является администратором
|
||||||
if (in_array('subscriber', $current_user->roles) || in_array('author', $current_user->roles)) {
|
if (in_array('subscriber', $current_user->roles)) {
|
||||||
// Если это запрос к административной панели или если пользователь пытается получить доступ к wp-admin
|
// Если это запрос к административной панели или если пользователь пытается получить доступ к wp-admin
|
||||||
if (is_admin()) {
|
if (is_admin()) {
|
||||||
// Перенаправляем на главную страницу сайта
|
// Перенаправляем на главную страницу сайта
|
||||||
@@ -613,92 +613,75 @@ function get_category_name_en($post = null)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Добавляем функцию для формирования мета-тегов страницы
|
|
||||||
function custom_meta_tags() {
|
function custom_meta_tags() {
|
||||||
|
|
||||||
$sitename = get_bloginfo('name');
|
$sitename = get_bloginfo('name');
|
||||||
|
|
||||||
$meta_tags = '';
|
$meta_tags = '';
|
||||||
$og_tags = '';
|
$og_tags = '';
|
||||||
|
|
||||||
$og_tags .= '<meta property="og:locale" content="ru_RU">';
|
$og_tags .= '<meta property="og:locale" content="ru_RU">' . PHP_EOL;
|
||||||
$og_tags .= '<meta property="og:site_name" content="'. $sitename .'">'. PHP_EOL;
|
$og_tags .= '<meta property="og:site_name" content="' . esc_html($sitename) . '">' . PHP_EOL;
|
||||||
|
|
||||||
|
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
|
||||||
|
|
||||||
// Получаем заголовок страницы
|
if (is_home() || is_front_page()) {
|
||||||
if (is_single() || is_page()) {
|
$title = 'Федеральное издание «Агроэксперт» - новости в сфере сельского хозяйства России';
|
||||||
|
$description = get_bloginfo('description');
|
||||||
|
|
||||||
$current_url = get_permalink();
|
|
||||||
|
|
||||||
$post = get_post(); // Получаем объект текущего поста или страницы
|
|
||||||
$title = get_the_title($post).' - '.$sitename; // Получаем заголовок текущего поста или страницы
|
|
||||||
$excerpt = get_the_excerpt($post);
|
|
||||||
|
|
||||||
if (has_excerpt()) {
|
|
||||||
$description = $excerpt;
|
|
||||||
} elseif (strlen($excerpt) > 300) {
|
|
||||||
$description = wp_trim_words($excerpt, 30, '...');
|
|
||||||
} else {
|
|
||||||
$description = $excerpt;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tags = get_the_tags($post); // Получаем теги текущего поста или страницы
|
|
||||||
$keywords = ''; // Переменная для хранения ключевых слов
|
|
||||||
if ($tags) {
|
|
||||||
$keywords = implode(', ', wp_list_pluck($tags, 'name')); // Формируем строку с тегами через запятую
|
|
||||||
}
|
|
||||||
|
|
||||||
$post_thumbnail_id = get_post_thumbnail_id($post->ID);
|
|
||||||
$post_thumbnail_url = wp_get_attachment_image_src($post_thumbnail_id, 'full');
|
|
||||||
if ($post_thumbnail_url) {
|
|
||||||
$og_image = esc_url($post_thumbnail_url[0]);
|
|
||||||
$og_tags .= '<meta property="og:image" content="' . $og_image . '">'. PHP_EOL;
|
|
||||||
$og_tags .= '<meta name="twitter:card" content="summary_large_image">'. PHP_EOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
$og_tags .= '<meta property="og:type" content="article">'. PHP_EOL;
|
|
||||||
|
|
||||||
} elseif (is_category()) {
|
|
||||||
$category = get_queried_object(); // Получаем объект текущей рубрики
|
|
||||||
$current_url = get_term_link($category);
|
|
||||||
$title = $category->name.': Новости, комментарии по теме - '.$sitename; // Получаем название текущей рубрики
|
|
||||||
$description = $category->description; // Получаем описание текущей рубрики
|
|
||||||
$keywords = $category->name; // Ключевые слова - название рубрики
|
|
||||||
} elseif (is_home()) {
|
|
||||||
|
|
||||||
$current_url = get_site_url();
|
|
||||||
|
|
||||||
$title = $sitename; // Получаем название сайта для главной страницы
|
|
||||||
$description = get_bloginfo('description'); // Получаем описание сайта для главной страницы
|
|
||||||
$keywords = ''; // Для главной страницы ключевые слова оставляем пустыми
|
|
||||||
|
|
||||||
$og_tags .= '<meta property="og:type" content="website">'. PHP_EOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Добавляем мета-теги только в случае, если их значения не пусты
|
|
||||||
if (!empty($current_url)) {
|
|
||||||
$og_tags .= '<meta property="og:url" content="' . esc_url($current_url) . '" />' . PHP_EOL;
|
|
||||||
}
|
|
||||||
if (!empty($title)) {
|
|
||||||
$meta_tags .= '<title>' . esc_html($title) . '</title>' . PHP_EOL;
|
$meta_tags .= '<title>' . esc_html($title) . '</title>' . PHP_EOL;
|
||||||
$og_tags .= '<meta property="og:title" content="'. esc_html($title) .'" />'. PHP_EOL;
|
|
||||||
}
|
|
||||||
if (!empty($description)) {
|
|
||||||
$description = wp_strip_all_tags($description);
|
|
||||||
$meta_tags .= '<meta name="description" content="' . esc_attr($description) . '">' . PHP_EOL;
|
$meta_tags .= '<meta name="description" content="' . esc_attr($description) . '">' . PHP_EOL;
|
||||||
|
$og_tags .= '<meta property="og:title" content="' . esc_html($title) . '" />' . PHP_EOL;
|
||||||
$og_tags .= '<meta property="og:description" content="' . esc_attr($description) . '" />' . PHP_EOL;
|
$og_tags .= '<meta property="og:description" content="' . esc_attr($description) . '" />' . PHP_EOL;
|
||||||
}
|
|
||||||
if (!empty($keywords)) {
|
} elseif (is_category() || is_tag()) {
|
||||||
$meta_tags .= '<meta name="keywords" content="' . esc_attr($keywords) . '">'. PHP_EOL;
|
$term = get_queried_object();
|
||||||
|
$canonical_url = get_term_link($term);
|
||||||
|
|
||||||
|
if ($paged > 1) {
|
||||||
|
$meta_tags .= '<link rel="canonical" href="' . esc_url($canonical_url) . '" />' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$title = $term->name . ' - ' . $sitename;
|
||||||
|
$description = !empty(trim($term->description)) ? $term->description : $term->name;
|
||||||
|
|
||||||
|
if ($paged > 1) {
|
||||||
|
$title .= ', страница ' . $paged;
|
||||||
|
$description .= '. Страница ' . $paged;
|
||||||
|
}
|
||||||
|
|
||||||
|
$og_tags .= '<meta property="og:url" content="' . esc_url($canonical_url) . '" />' . PHP_EOL;
|
||||||
|
$meta_tags .= '<title>' . esc_html($title) . '</title>' . PHP_EOL;
|
||||||
|
$meta_tags .= '<meta name="description" content="' . esc_attr($description) . '">' . PHP_EOL;
|
||||||
|
$og_tags .= '<meta property="og:title" content="' . esc_html($title) . '" />' . PHP_EOL;
|
||||||
|
$og_tags .= '<meta property="og:description" content="' . esc_attr($description) . '" />' . PHP_EOL;
|
||||||
|
|
||||||
|
} elseif (is_single() || is_page()) {
|
||||||
|
$post = get_queried_object();
|
||||||
|
|
||||||
|
if (is_page('kontakty')) { //конкретные страницы
|
||||||
|
$title = get_the_title($post).' '. $sitename;
|
||||||
|
} else {
|
||||||
|
$title = get_the_title($post) . ' - ' . $sitename;
|
||||||
|
}
|
||||||
|
|
||||||
|
$description = has_excerpt($post) ? get_the_excerpt($post) : wp_trim_words(strip_shortcodes($post->post_content), 30);
|
||||||
|
|
||||||
|
$og_tags .= '<meta property="og:url" content="' . esc_url($canonical_url) . '" />' . PHP_EOL;
|
||||||
|
$meta_tags .= '<title>' . esc_html($title) . '</title>' . PHP_EOL;
|
||||||
|
$meta_tags .= '<meta name="description" content="' . esc_attr($description) . '">' . PHP_EOL;
|
||||||
|
$og_tags .= '<meta property="og:title" content="' . esc_html($title) . '" />' . PHP_EOL;
|
||||||
|
$og_tags .= '<meta property="og:description" content="' . esc_attr($description) . '" />' . PHP_EOL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Выводим мета-теги
|
|
||||||
echo $meta_tags;
|
echo $meta_tags;
|
||||||
echo $og_tags;
|
echo $og_tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_action('wp_head', 'custom_meta_tags');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
add_action('wpcf7_before_send_mail', 'my_custom_contact_form_handler', 10, 3);
|
add_action('wpcf7_before_send_mail', 'my_custom_contact_form_handler', 10, 3);
|
||||||
function my_custom_contact_form_handler($contact_form, $abort, $submission) {
|
function my_custom_contact_form_handler($contact_form, $abort, $submission) {
|
||||||
@@ -1176,7 +1159,7 @@ function change_author_name($author) {
|
|||||||
add_filter('the_author', 'change_author_name');
|
add_filter('the_author', 'change_author_name');
|
||||||
|
|
||||||
// подписчики на главную
|
// подписчики на главную
|
||||||
add_action('admin_init', 'restrict_subscriber_admin_access');
|
//add_action('admin_init', 'restrict_subscriber_admin_access');
|
||||||
function restrict_subscriber_admin_access() {
|
function restrict_subscriber_admin_access() {
|
||||||
// Проверяем, что пользователь вошел в систему и имеет роль 'subscriber'
|
// Проверяем, что пользователь вошел в систему и имеет роль 'subscriber'
|
||||||
if (current_user_can('subscriber')) {
|
if (current_user_can('subscriber')) {
|
||||||
@@ -1186,4 +1169,16 @@ function restrict_subscriber_admin_access() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//авторы только в черновики
|
||||||
|
function restrict_author_publish_posts( $data ) {
|
||||||
|
// Проверяем, что текущий пользователь - автор
|
||||||
|
if ( current_user_can( 'author' ) && $data['post_status'] == 'publish' ) {
|
||||||
|
// Отключаем публикацию для авторов
|
||||||
|
$data['post_status'] = 'draft'; // Сохраняем как черновик
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
add_filter( 'wp_insert_post_data', 'restrict_author_publish_posts' );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<?custom_meta_tags();?>
|
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||||
@@ -53,7 +52,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
|||||||
<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(); ?>/en" 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">
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta name="zen-verification" content="xdaKRGoPCQTgRYUKZ7tBq2pDm8JxN4zVv8KxInVPCyE11AQGYpdnVL5ocisUY6w7" />
|
<meta name="zen-verification" content="xdaKRGoPCQTgRYUKZ7tBq2pDm8JxN4zVv8KxInVPCyE11AQGYpdnVL5ocisUY6w7" />
|
||||||
<?custom_meta_tags();?>
|
<meta name="google-site-verification" content="wKVjdTPQrw11PE9o4Blxqv7qbdFmxarn8ez4fCJd_po" />
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||||
@@ -80,7 +80,7 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
|||||||
<nav class="nav header__nav">
|
<nav class="nav header__nav">
|
||||||
<?php get_template_part('partials/menu-primary'); ?>
|
<?php get_template_part('partials/menu-primary'); ?>
|
||||||
</nav>
|
</nav>
|
||||||
<div class="lang-switch"><a href="<?php echo home_url();?>/en">EN</a></div>
|
<div class="lang-switch"><a href="<?php echo home_url();?>/en/">EN</a></div>
|
||||||
<div class="header__right">
|
<div class="header__right">
|
||||||
<div class="header__actions">
|
<div class="header__actions">
|
||||||
<a href="/search/?orderby=post_date&order=desc">
|
<a href="/search/?orderby=post_date&order=desc">
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ array_push($categories, $firstElement);
|
|||||||
$icon = get_field('icon', 'category_' . $cat->term_id);
|
$icon = get_field('icon', 'category_' . $cat->term_id);
|
||||||
$bg_image = get_field('bg_image', 'category_' . $cat->term_id);
|
$bg_image = get_field('bg_image', 'category_' . $cat->term_id);
|
||||||
|
|
||||||
|
if($bg_image){
|
||||||
|
|
||||||
$class = in_array($cat->term_id, $current_term_ids) ? 'is-active' : '';
|
$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 . "'>
|
echo "<a href='" . get_category_link($cat->term_id) . "' class='menu-vertical__item " . $class . "'>
|
||||||
@@ -33,3 +35,4 @@ array_push($categories, $firstElement);
|
|||||||
</a>
|
</a>
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ foreach ($categories as $category) {
|
|||||||
$bg_image = get_field('bg_image', 'category_' . $category->term_id);
|
$bg_image = get_field('bg_image', 'category_' . $category->term_id);
|
||||||
$category_link = get_category_link($category->term_id);
|
$category_link = get_category_link($category->term_id);
|
||||||
?>
|
?>
|
||||||
|
<?php if ($icon) : ?>
|
||||||
<a href="<?php echo esc_url($category_link); ?>" class="menu-link">
|
<a href="<?php echo esc_url($category_link); ?>" class="menu-link">
|
||||||
<div class="menu-link__bg">
|
<div class="menu-link__bg">
|
||||||
<?php if ($bg_image) : ?>
|
<?php if ($bg_image) : ?>
|
||||||
@@ -30,6 +31,7 @@ foreach ($categories as $category) {
|
|||||||
</div>
|
</div>
|
||||||
<span class="menu-link__text"><?php echo esc_html($category->name); ?></span>
|
<span class="menu-link__text"><?php echo esc_html($category->name); ?></span>
|
||||||
</a>
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -19,7 +19,7 @@ if ($pinned_post) :
|
|||||||
<?php echo get_the_excerpt($pinned_post->ID); ?>
|
<?php echo get_the_excerpt($pinned_post->ID); ?>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="tag hero-banner__tag"><?php echo esc_html(get_category_name($pinned_post)); ?></div>
|
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
Reference in New Issue
Block a user