<?php
/**
 * Flavor – Restaurant Menu
 *
 * Registers the Menu Item custom post type and the Menu Category taxonomy.
 *
 * @package    FlavorMenu
 * @copyright  Copyright (c) 2024 Flavor Studio
 * @license    GPL-2.0-or-later
 * @link       https://flavor-menu.com
 */

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

class Flavor_CPT {

    public static function init() {
        add_action( 'init', array( __CLASS__, 'register_post_type' ) );
        add_action( 'init', array( __CLASS__, 'register_taxonomy' ) );
    }

    /**
     * Register the Menu Item CPT.
     */
    public static function register_post_type() {
        $labels = array(
            'name'               => __( 'Menu', 'flavor-restaurant-menu' ),
            'singular_name'      => __( 'Menu Item', 'flavor-restaurant-menu' ),
            'menu_name'          => __( 'Menu', 'flavor-restaurant-menu' ),
            'add_new'            => __( 'Add New Item', 'flavor-restaurant-menu' ),
            'add_new_item'       => __( 'Add New Menu Item', 'flavor-restaurant-menu' ),
            'edit_item'          => __( 'Edit Menu Item', 'flavor-restaurant-menu' ),
            'new_item'           => __( 'New Menu Item', 'flavor-restaurant-menu' ),
            'view_item'          => __( 'View Menu Item', 'flavor-restaurant-menu' ),
            'search_items'       => __( 'Search Menu Items', 'flavor-restaurant-menu' ),
            'not_found'          => __( 'No menu items found', 'flavor-restaurant-menu' ),
            'not_found_in_trash' => __( 'No menu items found in trash', 'flavor-restaurant-menu' ),
            'all_items'          => __( 'All Menu Items', 'flavor-restaurant-menu' ),
        );

        $args = array(
            'labels'        => $labels,
            'public'        => false,
            'show_ui'       => true,
            'show_in_menu'  => true,
            'menu_icon'     => 'dashicons-food',
            'supports'      => array( 'title', 'editor', 'thumbnail' ),
            'has_archive'   => false,
            'rewrite'       => false,
            'menu_position' => 25,
        );

        register_post_type( 'flavor_menu_item', $args );
    }

    /**
     * Register the Menu Category taxonomy.
     */
    public static function register_taxonomy() {
        $labels = array(
            'name'          => __( 'Menu Categories', 'flavor-restaurant-menu' ),
            'singular_name' => __( 'Category', 'flavor-restaurant-menu' ),
            'search_items'  => __( 'Search Categories', 'flavor-restaurant-menu' ),
            'all_items'     => __( 'All Categories', 'flavor-restaurant-menu' ),
            'parent_item'   => __( 'Parent Category', 'flavor-restaurant-menu' ),
            'edit_item'     => __( 'Edit Category', 'flavor-restaurant-menu' ),
            'update_item'   => __( 'Update Category', 'flavor-restaurant-menu' ),
            'add_new_item'  => __( 'Add New Category', 'flavor-restaurant-menu' ),
            'new_item_name' => __( 'New Category Name', 'flavor-restaurant-menu' ),
            'menu_name'     => __( 'Categories', 'flavor-restaurant-menu' ),
        );

        register_taxonomy( 'flavor_menu_cat', 'flavor_menu_item', array(
            'labels'            => $labels,
            'hierarchical'      => true,
            'show_ui'           => true,
            'show_admin_column' => true,
            'rewrite'           => false,
        ) );
    }
}
