FEATURE Introducing post type activite and refactoring moving the taxonomies into a dedicated file

This commit is contained in:
Antoine M 2026-03-03 17:07:16 +01:00
parent d11d9cd40a
commit f4af47691d

View File

@ -191,86 +191,27 @@ function carhop_create_posttype()
'menu_position' => 4,
)
);
// -------ACTIVITÉS------- //
register_post_type(
'activites',
array(
'labels' => array(
'name' => __('Activités'),
'singular_name' => __('Activité'),
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'formations-activites'),
'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode('<svg width="20" height="20" viewBox="0 0 20 20" fill="#9BA2A9" xmlns="http://www.w3.org/2000/svg"><path d="M19.7648 5.22804L14.0012 11.0178L17.2518 14.9264V14.9352H17.2606L18.7667 16.7631C19.1642 17.2422 19.1377 17.921 18.7137 18.276L16.9117 19.78C16.7218 19.9441 16.4701 20.0151 16.2007 19.9973C15.9048 19.9707 15.6221 19.8154 15.4189 19.5714L13.9217 17.7613C13.9129 17.7524 13.9041 17.7524 13.8952 17.7436C13.8864 17.7347 13.8864 17.7258 13.8864 17.717L10.8964 14.1322L5.7511 19.3052C5.4287 19.6291 4.91196 19.6291 4.58955 19.3052L1.24181 15.9468C0.919398 15.6229 0.919398 15.1038 1.24181 14.78L6.79783 9.18989L2.84501 4.42059C2.80085 4.36735 2.77435 4.30524 2.75668 4.24756L2.74785 4.23869L1.95729 0.529729C1.92195 0.37445 1.98379 0.20586 2.10303 0.103819C2.18253 0.0417075 2.27528 0.00621582 2.38128 0.00621582C2.48727 0.00621582 2.49611 0.0150884 2.54469 0.0417077L6.01168 1.48803H6.02051C6.08235 1.51465 6.13534 1.55901 6.18393 1.60781L9.89383 6.07543L15.2511 0.702755C15.4057 0.538602 15.6221 0.458744 15.8297 0.458744C16.0373 0.458744 16.2448 0.538602 16.4082 0.702755L19.7516 4.06123C20.074 4.3851 20.074 4.90417 19.7516 5.22804H19.7648ZM16.0902 19.0213C16.1432 19.0834 16.2183 19.1367 16.3597 19.1189L18.1616 17.6149C18.1969 17.5883 18.2058 17.4508 18.0998 17.3265L16.8676 15.827L14.8404 17.5262L16.0902 19.0257V19.0213ZM2.98634 1.16416L3.4545 3.34251L5.03121 2.02041L2.98634 1.16859V1.16416ZM15.865 1.31056L14.0277 3.15617L14.7476 3.8882C14.9199 4.06123 14.9199 4.33186 14.7476 4.50488C14.5842 4.67791 14.306 4.67791 14.1426 4.50488L13.4138 3.77285L12.8088 4.37179L13.5375 5.11269C13.7097 5.27684 13.7097 5.55635 13.5375 5.7205C13.3741 5.89353 13.0958 5.89353 12.9324 5.7205L12.1949 4.98847L11.5986 5.5874L12.3273 6.32831C12.4996 6.49246 12.4996 6.77196 12.3273 6.93612C12.1639 7.10914 11.8857 7.10914 11.7134 6.93612L10.9847 6.20409L10.3796 6.80302L11.1172 7.54393C11.2806 7.70808 11.2806 7.98758 11.1172 8.16061C10.945 8.32476 10.6756 8.32476 10.5033 8.16061L9.76575 7.4197L9.16068 8.01864L9.90708 8.75954C10.0705 8.93257 10.0705 9.2032 9.90708 9.37622C9.73483 9.54038 9.45659 9.54038 9.29318 9.37622L8.55561 8.63532L7.96821 9.21207C7.99471 9.24756 8.01238 9.27418 8.02121 9.30968L8.68811 9.9796C8.86036 10.1526 8.86036 10.4321 8.68811 10.5963C8.5247 10.7693 8.24645 10.7693 8.08304 10.5963L7.33665 9.8465L6.73158 10.4543L7.47798 11.2041C7.65022 11.3682 7.65022 11.6477 7.47798 11.8119C7.31456 11.9849 7.03632 11.9849 6.87291 11.8119L6.12651 11.0621L5.52144 11.6699L6.26784 12.4197C6.44009 12.5839 6.44009 12.8634 6.26784 13.0275C6.09559 13.2005 5.82619 13.2005 5.65394 13.0275L4.90754 12.2777L4.30248 12.8855L5.05771 13.6353C5.22112 13.7995 5.22112 14.079 5.05771 14.252C4.88546 14.4162 4.61605 14.4162 4.44381 14.252L3.69741 13.4933L3.09234 14.0923L3.84757 14.8509C4.01098 15.024 4.01098 15.2946 3.84757 15.4676C3.67533 15.6318 3.39708 15.6318 3.23367 15.4676L2.47844 14.709L1.88221 15.299L5.1372 18.6886L13.0914 10.6983L19.1509 4.68235L15.865 1.315V1.31056ZM17.0266 3.45342C17.3136 3.75067 17.3136 4.22095 17.0266 4.50488C16.7395 4.78882 16.2625 4.80213 15.971 4.50488C15.6795 4.20764 15.6839 3.74623 15.971 3.45342C16.2669 3.15617 16.7351 3.15617 17.0266 3.45342Z" fill="#9BA2A9"/></svg>'),
'show_in_rest' => true,
'supports' => array('title', 'editor', 'thumbnail'),
'menu_position' => 4,
)
);
}
add_action('init', 'carhop_create_posttype');
/* ------------------------------------------------
##### TAXONOMIES
--------------------------------------------------*/
function carhop_register_taxonomies()
{
$current_site = get_current_blog_id();
if ($current_site !== 1) return;
// Taxonomie "Type" pour Analyses & Études
$labels = array(
'name' => _x('Types de publication', 'Taxonomy General Name', 'carhop-post-types'),
'singular_name' => _x('Type de publication', 'Taxonomy Singular Name', 'carhop-post-types'),
'menu_name' => __('Types', 'carhop-post-types'),
'all_items' => __('Tous les types', 'carhop-post-types'),
'parent_item' => __('Type parent', 'carhop-post-types'),
'parent_item_colon' => __('Type parent:', 'carhop-post-types'),
'new_item_name' => __('Nouveau type', 'carhop-post-types'),
'add_new_item' => __('Ajouter un type', 'carhop-post-types'),
'edit_item' => __('Modifier le type', 'carhop-post-types'),
'update_item' => __('Mettre à jour le type', 'carhop-post-types'),
'view_item' => __('Voir le type', 'carhop-post-types'),
'separate_items_with_commas' => __('Séparer les types avec des virgules', 'carhop-post-types'),
'add_or_remove_items' => __('Ajouter ou supprimer des types', 'carhop-post-types'),
'choose_from_most_used' => __('Choisir parmi les plus utilisés', 'carhop-post-types'),
'popular_items' => __('Types populaires', 'carhop-post-types'),
'search_items' => __('Rechercher des types', 'carhop-post-types'),
'not_found' => __('Non trouvé', 'carhop-post-types'),
'no_terms' => __('Aucun type', 'carhop-post-types'),
'items_list' => __('Liste des types', 'carhop-post-types'),
'items_list_navigation' => __('Navigation dans la liste des types', 'carhop-post-types'),
);
$args = array(
'labels' => $labels,
'hierarchical' => true, // true pour catégories (hiérarchique), false pour tags
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'show_in_rest' => true, // Important pour l'éditeur Gutenberg
'rest_base' => 'study_type',
'rewrite' => array('slug' => 'type'),
);
register_taxonomy('type', array('analyses-etudes'), $args);
}
add_action('init', 'carhop_register_taxonomies', 0);
/* ------------------------------------------------
##### CHANGE LE NOM DES POSTS PAR ACTUALITES
--------------------------------------------------*/
// function carhop_change_post_object()
// {
// $current_site = get_current_blog_id();
// if ($current_site !== 1) return;
// $get_post_type = get_post_type_object('post');
// $labels = $get_post_type->labels;
// $labels->name = 'Actualités';
// $labels->singular_name = 'Actualité';
// $labels->add_new = 'Ajouter une actualité';
// $labels->add_new_item = 'Ajouter une nouvelle actualité';
// $labels->edit_item = 'Editer l\'actualité';
// $labels->new_item = 'Actualité';
// $labels->view_item = 'Voir l\'actualité';
// $labels->search_items = 'Chercher une actualité';
// $labels->not_found = 'Pas d\'actualité trouvée';
// $labels->not_found_in_trash = 'Pas d\'actualité trouvée dans la corbeille';
// $labels->all_items = 'Toutes les actualités';
// $labels->menu_name = 'Actualités';
// $labels->name_admin_bar = 'Actualités';
// // remove_post_type_support('post', 'editor');
// unregister_taxonomy_for_object_type('category', 'post');
// unregister_taxonomy_for_object_type('post_tag', 'post');
// }
// add_action('init', 'carhop_change_post_object');