<?php
/**
 * Plugin Name: Annuaire Local 04
 * Description: Core functionality for the 04 directory.
 */

add_action('init', function() {
    register_post_type('listing', [
        'labels' => [
            'name' => 'Fiches',
            'singular_name' => 'Fiche',
            'add_new' => 'Ajouter une fiche',
            'edit_item' => 'Modifier la fiche',
        ],
        'public' => true,
        'has_archive' => true,
        'show_in_rest' => true,
        'supports' => ['title', 'editor', 'thumbnail', 'excerpt', 'custom-fields'],
        'menu_icon' => 'dashicons-store',
        'rewrite' => ['slug' => 'annuaire-pro'],
    ]);

    register_taxonomy('cat_pro', 'listing', [
        'labels' => ['name' => 'Catégories', 'singular_name' => 'Catégorie'],
        'hierarchical' => true,
        'show_in_rest' => true,
        'rewrite' => ['slug' => 'categorie-pro'],
    ]);

    register_taxonomy('ville_pro', 'listing', [
        'labels' => ['name' => 'Villes', 'singular_name' => 'Ville'],
        'hierarchical' => true,
        'show_in_rest' => true,
        'rewrite' => ['slug' => 'ville'],
    ]);
});
