// ======================================================== // KALLYAS CHILD - STYLES // ======================================================== add_action('wp_enqueue_scripts', 'kl_child_scripts', 11); function kl_child_scripts() { wp_deregister_style('kallyas-styles'); wp_enqueue_style( 'kallyas-styles', get_template_directory_uri() . '/style.css', array(), ZN_FW_VERSION ); wp_enqueue_style( 'kallyas-child', get_stylesheet_uri(), array('kallyas-styles'), ZN_FW_VERSION ); } // ======================================================== // TEXTDOMAIN // ======================================================== add_action('after_setup_theme', 'kallyasChildLoadTextDomain'); function kallyasChildLoadTextDomain() { load_child_theme_textdomain( 'zn_framework', get_stylesheet_directory() . '/languages' ); } // ======================================================== // CPT : MEMBRES // ======================================================== add_action('init', 'create_membres_cpt'); function create_membres_cpt() { register_post_type('membre', [ 'labels' => [ 'name' => 'Membres', 'singular_name' => 'Membre', 'add_new_item' => 'Ajouter un membre', 'edit_item' => 'Modifier le membre' ], 'public' => true, 'has_archive' => true, 'menu_icon' => 'dashicons-groups', 'supports' => ['title', 'thumbnail', 'editor'], 'rewrite' => ['slug' => 'membres'], 'show_in_rest' => true ]); } // ======================================================== // TAXONOMIE : ROLES // ======================================================== add_action('init', 'create_roles_taxonomy'); function create_roles_taxonomy() { register_taxonomy('role', 'membre', [ 'label' => 'Rôles', 'hierarchical' => true, 'show_admin_column' => true, 'rewrite' => ['slug' => 'role'] ]); } // ======================================================== // BACK-OFFICE : CHAMPS MEMBRES // ======================================================== add_action('add_meta_boxes', function () { add_meta_box( 'membre_infos_box', 'Fiche membre', function ($post) { $fields = [ 'nom' => get_post_meta($post->ID, '_nom', true), 'prenom' => get_post_meta($post->ID, '_prenom', true), 'journal' => get_post_meta($post->ID, '_journal', true), 'tel' => get_post_meta($post->ID, '_tel', true), 'apf' => get_post_meta($post->ID, '_apf_since', true), 'email' => get_post_meta($post->ID, '_member_email', true), ]; foreach ($fields as $key => $value) { echo '

' . ucfirst($key) . '

'; echo ''; } }, 'membre', 'normal', 'high' ); }); // ======================================================== // SAUVEGARDE CHAMPS // ======================================================== add_action('save_post_membre', function ($post_id) { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return; if (get_post_type($post_id) !== 'membre') return; $keys = [ 'nom' => '_nom', 'prenom' => '_prenom', 'journal' => '_journal', 'tel' => '_tel', 'apf' => '_apf_since', 'email' => '_member_email' ]; foreach ($keys as $field => $meta) { if (isset($_POST[$field])) { $value = ($field === 'email') ? sanitize_email($_POST[$field]) : sanitize_text_field($_POST[$field]); update_post_meta($post_id, $meta, $value); } } }); // ======================================================== // FRONT : LISTE MEMBRES (JS READY) // ======================================================== add_shortcode('members_list', function () { $members = get_posts([ 'post_type' => 'membre', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC' ]); ob_start(); foreach ($members as $m) { $id = $m->ID; $nom = get_post_meta($id, '_nom', true); $prenom = get_post_meta($id, '_prenom', true); $journal = get_post_meta($id, '_journal', true); $tel = get_post_meta($id, '_tel', true); $apf = get_post_meta($id, '_apf_since', true); $email = get_post_meta($id, '_member_email', true); $img = get_the_post_thumbnail_url($id, 'medium'); echo '
'.($img ? '' : '').'
'.$prenom.' '.$nom.'
'.$journal.'
'; } return ob_get_clean(); }); // ======================================================== // TRI A → Z // ======================================================== add_action('pre_get_posts', function ($query) { if (is_admin()) return; if ($query->get('post_type') === 'membre') { $query->set('orderby', 'title'); $query->set('order', 'ASC'); } }); Association de la Presse Diplomatique Française

Bienvenue sur le site de l'Association de la Presse Diplomatique Française Nous travaillons actuellement sur une nouvelle version de qui vous sera bientôt proposée. Merci pour votre patience.