<?php
/**
 * Custom post type: Production.
 *
 * Private content type. Not publicly queryable, no archive, no rewrites.
 * Surfaces only through the audace/production block.
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

add_action( 'init', function () {
    register_post_type( 'production', array(
        'labels' => array(
            'name'               => __( 'Productions', 'audace' ),
            'singular_name'      => __( 'Production', 'audace' ),
            'add_new'            => __( 'Ajouter', 'audace' ),
            'add_new_item'       => __( 'Ajouter une production', 'audace' ),
            'edit_item'          => __( 'Modifier la production', 'audace' ),
            'new_item'           => __( 'Nouvelle production', 'audace' ),
            'view_item'          => __( 'Voir la production', 'audace' ),
            'search_items'       => __( 'Rechercher une production', 'audace' ),
            'not_found'          => __( 'Aucune production trouvée', 'audace' ),
            'not_found_in_trash' => __( 'Aucune production dans la corbeille', 'audace' ),
            'menu_name'          => __( 'Productions', 'audace' ),
        ),
        'public'             => false,
        'show_ui'            => true,
        'show_in_menu'       => true,
        'show_in_rest'       => true,
        'publicly_queryable' => false,
        'has_archive'        => false,
        'rewrite'            => false,
        'exclude_from_search'=> true,
        'supports'           => array( 'title', 'editor', 'thumbnail', 'excerpt', 'page-attributes', 'custom-fields' ),
        'menu_icon'          => 'dashicons-download',
        'menu_position'      => 23,
    ) );

    register_post_meta( 'production', '_audace_download_file', array(
        'type'          => 'integer',
        'single'        => true,
        'default'       => 0,
        'show_in_rest'  => true,
        'auth_callback' => function () { return current_user_can( 'edit_posts' ); },
    ) );
} );
