add afisha
This commit is contained in:
22
footer.php
22
footer.php
@@ -10,19 +10,37 @@
|
||||
<footer>
|
||||
<a href="#top" class="to-top"><svg width="53" height="53" viewBox="0 0 53 53" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect width="53" height="53" fill="#006842"></rect> <path d="M26.9091 24.1732L39.8181 31.6279L39.8181 24.4546L26.9091 16.9999L26.9091 24.1732Z" fill="#F18917"></path> <path d="M26.909 24.1732L14 31.6279L14 24.4546L26.909 16.9999L26.909 24.1732Z" fill="#F18917"></path> </svg></a>
|
||||
<div class="footer-content">
|
||||
<div class="footer-line-1">
|
||||
<div class="sportpressa-logo-footer">
|
||||
|
||||
<div class="footer-line-1">
|
||||
|
||||
<div class="sportpressa-logo-footer">
|
||||
<a href="<?php echo home_url()?>"><span class="redword">С</span>порт</a>
|
||||
<img src="<?php echo home_url()?>/sportpressa.svg" width="30">
|
||||
<a href="<?php echo home_url()?>">Пресса</a>
|
||||
</div>
|
||||
<div class="rating">18+</div>
|
||||
</div>
|
||||
|
||||
<?php get_template_part( 'template-parts/subscripts-promo' ); ?>
|
||||
|
||||
<div id="copyr">
|
||||
© Сетевое издание Спортпресса, 2018 - <?=date('Y')?> (sportpressa.ru). Учредитель: Синьковский Петр Сергеевич. Главный редактор: Синьковский П.С. Электронный адрес: info@sportpressa.ru. Телефон редакции: +7(495)511-49-05. Свидетельство о регистрации ЭЛ № ФС 77 - 73274 от 13.07.2018 года. Выдано Федеральной службой по надзору в сфере связи, информационных технологий и массовых коммуникаций (Роскомнадзор). 2002-2024 SportPressa.ru™ Все права защищены.
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="live_counter"><!--LiveInternet counter--><a href="https://www.liveinternet.ru/click"
|
||||
target="_blank"><img id="licntAB10" width="31" height="31" style="border:0"
|
||||
title="LiveInternet"
|
||||
src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAEALAAAAAABAAEAAAIBTAA7"
|
||||
alt=""/></a><script>(function(d,s){d.getElementById("licntAB10").src=
|
||||
"https://counter.yadro.ru/hit?t50.6;r"+escape(d.referrer)+
|
||||
((typeof(s)=="undefined")?"":";s"+s.width+"*"+s.height+"*"+
|
||||
(s.colorDepth?s.colorDepth:s.pixelDepth))+";u"+escape(d.URL)+
|
||||
";h"+escape(d.title.substring(0,150))+";"+Math.random()})
|
||||
(document,screen)</script><!--/LiveInternet-->
|
||||
</div>
|
||||
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
@@ -247,6 +247,7 @@ add_filter('post_class', 'add_category_class_to_posts', 10, 3);
|
||||
|
||||
require_once 'inc/opengraph.php'; //опенграф
|
||||
require_once 'inc/postdate.php'; //постдаты
|
||||
require_once 'inc/afisha.php'; //Афиша ЗОЖ
|
||||
|
||||
|
||||
|
||||
|
||||
129
inc/afisha.php
Normal file
129
inc/afisha.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
// Регистрация кастомного типа поста
|
||||
function azozh_register_post_type() {
|
||||
register_post_type('afisha_zozh', array(
|
||||
'labels' => array(
|
||||
'name' => 'Афиша ЗОЖ',
|
||||
'singular_name' => 'Событие',
|
||||
'add_new' => 'Добавить событие',
|
||||
'add_new_item' => 'Добавить новое событие',
|
||||
'edit_item' => 'Редактировать событие',
|
||||
'new_item' => 'Новое событие',
|
||||
'view_item' => 'Посмотреть событие',
|
||||
'search_items' => 'Найти событие',
|
||||
'not_found' => 'События не найдены',
|
||||
),
|
||||
'public' => true,
|
||||
'has_archive' => true,
|
||||
'menu_icon' => 'dashicons-calendar-alt',
|
||||
'supports' => array('title', 'editor', 'thumbnail'),
|
||||
'show_in_rest' => true,
|
||||
'rewrite' => array('slug' => 'afisha'),
|
||||
));
|
||||
}
|
||||
add_action('init', 'azozh_register_post_type');
|
||||
|
||||
// Регистрация таксономии "Разделы" (иерархическая, как категории)
|
||||
function azozh_register_taxonomies() {
|
||||
// Разделы (категории): бег, йога, фитнес и т.п.
|
||||
register_taxonomy('afisha_category', 'afisha_zozh', array(
|
||||
'labels' => array(
|
||||
'name' => 'Разделы',
|
||||
'singular_name' => 'Раздел',
|
||||
'search_items' => 'Найти раздел',
|
||||
'all_items' => 'Все разделы',
|
||||
'edit_item' => 'Редактировать раздел',
|
||||
'update_item' => 'Обновить раздел',
|
||||
'add_new_item' => 'Добавить раздел',
|
||||
'new_item_name' => 'Название нового раздела',
|
||||
),
|
||||
'hierarchical' => true,
|
||||
'show_admin_column' => true,
|
||||
'show_in_rest' => true,
|
||||
'rewrite' => array('slug' => 'razdel'),
|
||||
));
|
||||
|
||||
// Компании (неиерархическая, как метки)
|
||||
register_taxonomy('afisha_company', 'afisha_zozh', array(
|
||||
'labels' => array(
|
||||
'name' => 'Компании',
|
||||
'singular_name' => 'Компания',
|
||||
'search_items' => 'Найти компанию',
|
||||
'all_items' => 'Все компании',
|
||||
'edit_item' => 'Редактировать компанию',
|
||||
'update_item' => 'Обновить компанию',
|
||||
'add_new_item' => 'Добавить компанию',
|
||||
'new_item_name' => 'Название компании',
|
||||
'separate_items_with_commas' => 'Разделяйте компании запятыми',
|
||||
'choose_from_most_used' => 'Выбрать из часто используемых',
|
||||
),
|
||||
'hierarchical' => false, // Как метки
|
||||
'show_admin_column' => true,
|
||||
'show_in_rest' => true,
|
||||
'rewrite' => array('slug' => 'kompaniya'),
|
||||
));
|
||||
}
|
||||
add_action('init', 'azozh_register_taxonomies');
|
||||
|
||||
// Добавление meta box для даты события
|
||||
function azozh_add_meta_boxes() {
|
||||
add_meta_box(
|
||||
'azozh_event_details',
|
||||
'Детали события',
|
||||
'azozh_meta_box_html',
|
||||
'afisha_zozh',
|
||||
'normal',
|
||||
'high'
|
||||
);
|
||||
}
|
||||
add_action('add_meta_boxes', 'azozh_add_meta_boxes');
|
||||
|
||||
// HTML meta box
|
||||
function azozh_meta_box_html($post) {
|
||||
wp_nonce_field('azozh_save_meta', 'azozh_nonce');
|
||||
|
||||
$event_date = get_post_meta($post->ID, '_azozh_event_date', true);
|
||||
$press_links = get_post_meta($post->ID, '_azozh_press_links', true);
|
||||
?>
|
||||
<p>
|
||||
<label for="azozh_event_date"><strong>Дата события:</strong></label><br>
|
||||
<input type="date" id="azozh_event_date" name="azozh_event_date"
|
||||
value="<?php echo esc_attr($event_date); ?>"
|
||||
style="width: 100%; max-width: 300px;">
|
||||
</p>
|
||||
<p>
|
||||
<label for="azozh_press_links"><strong>Ссылки на пресс-релизы:</strong></label><br>
|
||||
<textarea id="azozh_press_links" name="azozh_press_links"
|
||||
rows="5" style="width: 100%;"><?php echo esc_textarea($press_links); ?></textarea>
|
||||
<span class="description">Укажите ссылки на пресс-релизы, каждая с новой строки</span>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
// Сохранение meta данных
|
||||
function azozh_save_meta($post_id) {
|
||||
// Проверки
|
||||
if (!isset($_POST['azozh_nonce']) || !wp_verify_nonce($_POST['azozh_nonce'], 'azozh_save_meta')) {
|
||||
return;
|
||||
}
|
||||
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
||||
return;
|
||||
}
|
||||
if (!current_user_can('edit_post', $post_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Сохранение даты события
|
||||
if (isset($_POST['azozh_event_date'])) {
|
||||
update_post_meta($post_id, '_azozh_event_date', sanitize_text_field($_POST['azozh_event_date']));
|
||||
}
|
||||
|
||||
// Сохранение ссылок на пресс-релизы
|
||||
if (isset($_POST['azozh_press_links'])) {
|
||||
update_post_meta($post_id, '_azozh_press_links', sanitize_textarea_field($_POST['azozh_press_links']));
|
||||
}
|
||||
}
|
||||
add_action('save_post_afisha_zozh', 'azozh_save_meta');
|
||||
Reference in New Issue
Block a user