From f4af47691daf6fc4947b0b8f7ae2f27c7263c715 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Tue, 3 Mar 2026 17:07:16 +0100 Subject: [PATCH] FEATURE Introducing post type activite and refactoring moving the taxonomies into a dedicated file --- mu-plugins/carhop-post-types.php | 93 ++++++-------------------------- 1 file changed, 17 insertions(+), 76 deletions(-) diff --git a/mu-plugins/carhop-post-types.php b/mu-plugins/carhop-post-types.php index 527b70d..3764fa5 100644 --- a/mu-plugins/carhop-post-types.php +++ b/mu-plugins/carhop-post-types.php @@ -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(''), + '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');