feat: register custom post types (case, webinar, course, event, material)

This commit is contained in:
2026-04-03 01:07:25 +05:00
parent b47ad7bef4
commit 4019a565ec
2 changed files with 204 additions and 0 deletions
+195
View File
@@ -0,0 +1,195 @@
<?php
/**
* БИТ.WMS Child Theme — Custom Post Types & Taxonomies
*
* Registers 5 CPTs (case, webinar, course, event, material) and
* 2 hierarchical taxonomies (industry, material_type).
*
* @package bitwms-child
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_action( 'init', 'bitwms_register_post_types' );
/**
* Register all custom post types.
*/
function bitwms_register_post_types() {
// -----------------------------------------------------------------------
// 1. Кейсы (case)
// -----------------------------------------------------------------------
register_post_type( 'case', array(
'labels' => array(
'name' => 'Кейсы',
'singular_name' => 'Кейс',
'add_new' => 'Добавить кейс',
'add_new_item' => 'Добавить новый кейс',
'edit_item' => 'Редактировать кейс',
'view_item' => 'Просмотреть кейс',
'all_items' => 'Все кейсы',
'search_items' => 'Найти кейс',
'not_found' => 'Кейсы не найдены',
'not_found_in_trash' => 'В корзине кейсов нет',
),
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
'menu_icon' => 'dashicons-portfolio',
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
'rewrite' => array( 'slug' => 'cases' ),
) );
// -----------------------------------------------------------------------
// 2. Вебинары (webinar)
// -----------------------------------------------------------------------
register_post_type( 'webinar', array(
'labels' => array(
'name' => 'Вебинары',
'singular_name' => 'Вебинар',
'add_new' => 'Добавить вебинар',
'add_new_item' => 'Добавить новый вебинар',
'edit_item' => 'Редактировать вебинар',
'view_item' => 'Просмотреть вебинар',
'all_items' => 'Все вебинары',
'search_items' => 'Найти вебинар',
'not_found' => 'Вебинары не найдены',
'not_found_in_trash' => 'В корзине вебинаров нет',
),
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
'menu_icon' => 'dashicons-video-alt3',
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
'rewrite' => array( 'slug' => 'webinars' ),
) );
// -----------------------------------------------------------------------
// 3. Курсы (course)
// -----------------------------------------------------------------------
register_post_type( 'course', array(
'labels' => array(
'name' => 'Курсы',
'singular_name' => 'Курс',
'add_new' => 'Добавить курс',
'add_new_item' => 'Добавить новый курс',
'edit_item' => 'Редактировать курс',
'view_item' => 'Просмотреть курс',
'all_items' => 'Все курсы',
'search_items' => 'Найти курс',
'not_found' => 'Курсы не найдены',
'not_found_in_trash' => 'В корзине курсов нет',
),
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
'menu_icon' => 'dashicons-welcome-learn-more',
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
'rewrite' => array( 'slug' => 'courses' ),
) );
// -----------------------------------------------------------------------
// 4. Мероприятия (event)
// -----------------------------------------------------------------------
register_post_type( 'event', array(
'labels' => array(
'name' => 'Мероприятия',
'singular_name' => 'Мероприятие',
'add_new' => 'Добавить мероприятие',
'add_new_item' => 'Добавить новое мероприятие',
'edit_item' => 'Редактировать мероприятие',
'view_item' => 'Просмотреть мероприятие',
'all_items' => 'Все мероприятия',
'search_items' => 'Найти мероприятие',
'not_found' => 'Мероприятия не найдены',
'not_found_in_trash' => 'В корзине мероприятий нет',
),
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
'menu_icon' => 'dashicons-calendar-alt',
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
'rewrite' => array( 'slug' => 'events' ),
) );
// -----------------------------------------------------------------------
// 5. Материалы (material) — no 'editor' support
// -----------------------------------------------------------------------
register_post_type( 'material', array(
'labels' => array(
'name' => 'Материалы',
'singular_name' => 'Материал',
'add_new' => 'Добавить материал',
'add_new_item' => 'Добавить новый материал',
'edit_item' => 'Редактировать материал',
'view_item' => 'Просмотреть материал',
'all_items' => 'Все материалы',
'search_items' => 'Найти материал',
'not_found' => 'Материалы не найдены',
'not_found_in_trash' => 'В корзине материалов нет',
),
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
'menu_icon' => 'dashicons-download',
'supports' => array( 'title', 'thumbnail', 'excerpt' ),
'rewrite' => array( 'slug' => 'materials' ),
) );
}
add_action( 'init', 'bitwms_register_taxonomies' );
/**
* Register custom taxonomies.
*/
function bitwms_register_taxonomies() {
// -----------------------------------------------------------------------
// 1. Отрасли (industry) — for case CPT, hierarchical
// -----------------------------------------------------------------------
register_taxonomy( 'industry', array( 'case' ), array(
'labels' => array(
'name' => 'Отрасли',
'singular_name' => 'Отрасль',
'search_items' => 'Найти отрасль',
'all_items' => 'Все отрасли',
'parent_item' => 'Родительская отрасль',
'parent_item_colon' => 'Родительская отрасль:',
'edit_item' => 'Редактировать отрасль',
'update_item' => 'Обновить отрасль',
'add_new_item' => 'Добавить новую отрасль',
'new_item_name' => 'Название новой отрасли',
'menu_name' => 'Отрасли',
),
'hierarchical' => true,
'public' => true,
'show_in_rest' => true,
'rewrite' => array( 'slug' => 'industry' ),
) );
// -----------------------------------------------------------------------
// 2. Тип материала (material_type) — for material CPT, hierarchical
// -----------------------------------------------------------------------
register_taxonomy( 'material_type', array( 'material' ), array(
'labels' => array(
'name' => 'Типы материалов',
'singular_name' => 'Тип материала',
'search_items' => 'Найти тип материала',
'all_items' => 'Все типы материалов',
'parent_item' => 'Родительский тип',
'parent_item_colon' => 'Родительский тип:',
'edit_item' => 'Редактировать тип',
'update_item' => 'Обновить тип',
'add_new_item' => 'Добавить новый тип',
'new_item_name' => 'Название нового типа',
'menu_name' => 'Тип материала',
),
'hierarchical' => true,
'public' => true,
'show_in_rest' => true,
'rewrite' => array( 'slug' => 'material-type' ),
) );
}