<?php
/**
 * The template for displaying Custom Post Type for this theme
 *
 * @package WordPress
 * @subpackage IZI_THEME
 * @since 1.0.0
 */

if ( ! function_exists( 'series_cpt' ) ) :
	/**
	 * Déclaration du custom_post_type "Produits"
	 */
	function series_cpt() {

		$labels = array(
			'name'                  => _x( 'Séries', 'Post Type General Name', 'izitheme' ),
			'singular_name'         => _x( 'série', 'Post Type Singular Name', 'izitheme' ),
			'menu_name'             => __( 'Séries', 'izitheme' ),
			'name_admin_bar'        => __( 'Série', 'izitheme' ),
			// Les différents libellés de l'administration
			'archives'              => __( 'Item Archives', 'izitheme' ),
			//'attributes'            => __( 'Item Attributes', 'izitheme' ),
			'parent_item_colon'     => __( 'Parent Item:', 'izitheme' ),
			'all_items'             => __( 'Toutes les séries', 'izitheme' ),
			'add_new_item'          => __( 'Ajouter une série', 'izitheme' ),
			'add_new'               => __( 'Ajouter une série', 'izitheme' ),
			'new_item'              => __( 'Nouvelle série', 'izitheme' ),
			'edit_item'             => __( 'Editer une série', 'izitheme' ),
			'update_item'           => __( 'Mettre à jour', 'izitheme' ),
			'view_item'             => __( 'voir série', 'izitheme' ),
			'view_items'            => __( 'voir séries', 'izitheme' ),
			'search_items'          => __( 'Chercher une série', 'izitheme' ),
			'not_found'             => __( 'Aucune série trouvée', 'izitheme' ),
			'not_found_in_trash'    => __( 'Aucune série trouvée dans la corbeille', 'izitheme' ),
			'featured_image'        => __( 'Image à la une', 'fimheme' ),
			'set_featured_image'    => __( 'ajouter Image à la une', 'izitheme' ),
			'remove_featured_image' => __( 'Supprimer Image à la une', 'izitheme' ),
			'use_featured_image'    => __( 'Utiliser Image à la une', 'izitheme' ),
			'insert_into_item'      => __( 'Insert into item', 'izitheme' ),
			'uploaded_to_this_item' => __( 'Uploaded to this item', 'izitheme' ),
			'items_list'            => __( 'Items list', 'izitheme' ),
			'items_list_navigation' => __( 'Items list navigation', 'izitheme' ),
			'filter_items_list'     => __( 'Filter items list', 'izitheme' ),
		);
		$args = array(
			'label'                 => __( 'séries', 'izitheme' ),
			'description'           => __( 'Permet de déposer des séries.', 'izitheme' ),
			'labels'                => $labels,
			'show_in_rest'			=> true, // if false, post type will have classic editor
			'supports'              => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'post-formats', 'comments', 'revisions', 'custom-fields' ),
			'taxonomies'            => array( 'vod', 'annee', 'saisons', 'genre' ),
			'hierarchical'          => false,
			'public'                => true,
			'show_ui'               => true,
			'show_in_menu'          => true,
			'menu_position'         => 5,
			'show_in_admin_bar'     => true,
			'show_in_nav_menus'     => true,
			'can_export'            => true,
			'has_archive'           => true,
			'exclude_from_search'   => false,
			'publicly_queryable'    => true,
			'capability_type'       => 'post',
			'menu_icon'       		=> 'dashicons-video-alt3',
			'query_var'       		=> true,
			'rewrite'       		=> array('slug' => 'series'),
		);
		register_post_type( 'series', $args );
		flush_rewrite_rules();
	}
	add_action( 'init', 'series_cpt', 10 );
endif;

if ( ! function_exists( 'item_taxonomy' ) ) :
	/**
	 * Déclaration des custom_taxonomies
	 */
	function item_taxonomy() {

		// Taxonomie Plateforme de VOD
		$labels_vod = array(
			'name'                       => _x( 'Plateforme de VOD', 'Taxonomy General Name', 'izitheme' ),
			'singular_name'              => _x( 'VOD', 'Taxonomy Singular Name', 'izitheme' ),
			'menu_name'                  => __( 'Plateforme de VOD', 'izitheme' ),
			'all_items'                  => __( 'All Items', 'izitheme' ),
			'parent_item'                => __( 'Parent Item', 'izitheme' ),
			'parent_item_colon'          => __( 'Parent Item:', 'izitheme' ),
			'new_item_name'              => __( 'New Item Name', 'izitheme' ),
			'add_new_item'               => __( 'Add New Item', 'izitheme' ),
			'edit_item'                  => __( 'Edit Item', 'izitheme' ),
			'update_item'                => __( 'Update Item', 'izitheme' ),
			'view_item'                  => __( 'View Item', 'izitheme' ),
			'separate_items_with_commas' => __( 'Separate items with commas', 'izitheme' ),
			'add_or_remove_items'        => __( 'Add or remove items', 'izitheme' ),
			'choose_from_most_used'      => __( 'Choose from the most used', 'izitheme' ),
			'popular_items'              => __( 'Popular Items', 'izitheme' ),
			'search_items'               => __( 'Search Items', 'izitheme' ),
			'not_found'                  => __( 'Not Found', 'izitheme' ),
			'no_terms'                   => __( 'No items', 'izitheme' ),
			'items_list'                 => __( 'Items list', 'izitheme' ),
			'items_list_navigation'      => __( 'Items list navigation', 'izitheme' ),
		);
		$args_vod = array(
			'labels'                     => $labels_vod,
			'hierarchical'               => false,
			'public'                     => true,
			'show_in_rest'				 => true,
			'show_ui'                    => true,
			'show_admin_column'          => true,
			'show_in_nav_menus'          => true,
			'show_tagcloud'              => true,
			'query_var'       			 => true,
			'rewrite'       			 => array('slug' => 'vod'),
		);
		register_taxonomy( 'vod', array( 'series' ), $args_vod );
		
		// Taxonomie Année de production
		$labels_annee = array(
			'name'                       => _x( 'Année de production', 'Taxonomy General Name', 'izitheme' ),
			'singular_name'              => _x( 'Année', 'Taxonomy Singular Name', 'izitheme' ),
			'menu_name'                  => __( 'Année de production', 'izitheme' ),
			'all_items'                  => __( 'All Items', 'izitheme' ),
			'parent_item'                => __( 'Parent Item', 'izitheme' ),
			'parent_item_colon'          => __( 'Parent Item:', 'izitheme' ),
			'new_item_name'              => __( 'New Item Name', 'izitheme' ),
			'add_new_item'               => __( 'Add New Item', 'izitheme' ),
			'edit_item'                  => __( 'Edit Item', 'izitheme' ),
			'update_item'                => __( 'Update Item', 'izitheme' ),
			'view_item'                  => __( 'View Item', 'izitheme' ),
			'separate_items_with_commas' => __( 'Separate items with commas', 'izitheme' ),
			'add_or_remove_items'        => __( 'Add or remove items', 'izitheme' ),
			'choose_from_most_used'      => __( 'Choose from the most used', 'izitheme' ),
			'popular_items'              => __( 'Popular Items', 'izitheme' ),
			'search_items'               => __( 'Search Items', 'izitheme' ),
			'not_found'                  => __( 'Not Found', 'izitheme' ),
			'no_terms'                   => __( 'No items', 'izitheme' ),
			'items_list'                 => __( 'Items list', 'izitheme' ),
			'items_list_navigation'      => __( 'Items list navigation', 'izitheme' ),
		);
		$args_annee = array(
			'labels'                     => $labels_annee,
			'hierarchical'               => false,
			'public'                     => true,
			'show_in_rest'				 => true,
			'show_ui'                    => true,
			'show_admin_column'          => true,
			'show_in_nav_menus'          => true,
			'show_tagcloud'              => true,
			'query_var'       			 => true,
			'rewrite'       			 => array('slug' => 'annee'),
			// 'meta_box_cb'           	 => 'taxonomy_select_meta_box',
		);
		register_taxonomy( 'annee', array( 'series' ), $args_annee );

		// Taxonomie saisons
		$labels_saisons = array(
			'name'                       => _x( 'Nombre de saisons', 'Taxonomy General Name', 'izitheme' ),
			'singular_name'              => _x( 'Saisons', 'Taxonomy Singular Name', 'izitheme' ),
			'menu_name'                  => __( 'Nombre de saisons', 'izitheme' ),
			'all_items'                  => __( 'All Items', 'izitheme' ),
			'parent_item'                => __( 'Parent Item', 'izitheme' ),
			'parent_item_colon'          => __( 'Parent Item:', 'izitheme' ),
			'new_item_name'              => __( 'New Item Name', 'izitheme' ),
			'add_new_item'               => __( 'Add New Item', 'izitheme' ),
			'edit_item'                  => __( 'Edit Item', 'izitheme' ),
			'update_item'                => __( 'Update Item', 'izitheme' ),
			'view_item'                  => __( 'View Item', 'izitheme' ),
			'separate_items_with_commas' => __( 'Separate items with commas', 'izitheme' ),
			'add_or_remove_items'        => __( 'Add or remove items', 'izitheme' ),
			'choose_from_most_used'      => __( 'Choose from the most used', 'izitheme' ),
			'popular_items'              => __( 'Popular Items', 'izitheme' ),
			'search_items'               => __( 'Search Items', 'izitheme' ),
			'not_found'                  => __( 'Not Found', 'izitheme' ),
			'no_terms'                   => __( 'No items', 'izitheme' ),
			'items_list'                 => __( 'Items list', 'izitheme' ),
			'items_list_navigation'      => __( 'Items list navigation', 'izitheme' ),
		);
		$args_saisons = array(
			'labels'                     => $labels_saisons,
			'hierarchical'               => false,
			'public'                     => true,
			'show_in_rest'				 => true,
			'show_ui'                    => true,
			'show_admin_column'          => true,
			'show_in_nav_menus'          => true,
			'show_tagcloud'              => true,
			'query_var'       			 => true,
			'rewrite'       			 => array('slug' => 'saisons'),
		);
		register_taxonomy( 'saisons', array( 'series' ), $args_saisons );
		
		// Taxonomie genre
		$labels_genre = array(
			'name'                       => _x( 'Genre', 'Taxonomy General Name', 'izitheme' ),
			'singular_name'              => _x( 'genre', 'Taxonomy Singular Name', 'izitheme' ),
			'menu_name'                  => __( 'Genre', 'izitheme' ),
			'all_items'                  => __( 'All Items', 'izitheme' ),
			'parent_item'                => __( 'Parent Item', 'izitheme' ),
			'parent_item_colon'          => __( 'Parent Item:', 'izitheme' ),
			'new_item_name'              => __( 'New Item Name', 'izitheme' ),
			'add_new_item'               => __( 'Add New Item', 'izitheme' ),
			'edit_item'                  => __( 'Edit Item', 'izitheme' ),
			'update_item'                => __( 'Update Item', 'izitheme' ),
			'view_item'                  => __( 'View Item', 'izitheme' ),
			'separate_items_with_commas' => __( 'Separate items with commas', 'izitheme' ),
			'add_or_remove_items'        => __( 'Add or remove items', 'izitheme' ),
			'choose_from_most_used'      => __( 'Choose from the most used', 'izitheme' ),
			'popular_items'              => __( 'Popular Items', 'izitheme' ),
			'search_items'               => __( 'Search Items', 'izitheme' ),
			'not_found'                  => __( 'Not Found', 'izitheme' ),
			'no_terms'                   => __( 'No items', 'izitheme' ),
			'items_list'                 => __( 'Items list', 'izitheme' ),
			'items_list_navigation'      => __( 'Items list navigation', 'izitheme' ),
		);
		$args_genre = array(
			'labels'                     => $labels_genre,
			'hierarchical'               => false,
			'public'                     => true,
			'show_in_rest'				 => true,
			'show_ui'                    => true,
			'show_admin_column'          => true,
			'show_in_nav_menus'          => true,
			'show_tagcloud'              => true,
			'query_var'       			 => true,
			'rewrite'       			 => array('slug' => 'genre'),
		);
		register_taxonomy( 'genre', array( 'series' ), $args_genre );

	}
	add_action( 'init', 'item_taxonomy', 10 );
endif;
