diff --git a/footer.php b/footer.php index 07039ed..b925b73 100755 --- a/footer.php +++ b/footer.php @@ -10,19 +10,37 @@ \ No newline at end of file diff --git a/functions.php b/functions.php index d0713dd..7b1dee6 100755 --- a/functions.php +++ b/functions.php @@ -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'; //Афиша ЗОЖ diff --git a/inc/afisha.php b/inc/afisha.php new file mode 100644 index 0000000..37b1a0e --- /dev/null +++ b/inc/afisha.php @@ -0,0 +1,129 @@ + 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); + ?> +

+
+ +

+

+
+ + Укажите ссылки на пресс-релизы, каждая с новой строки +

+