<?php

namespace MovieEngine\PostTypes;

if (! defined("ABSPATH")) {
    exit; // Exit if accessed directly
}

class Episode {

    public function __construct() {
        add_action('init', [$this, 'register']);
    }

    public function register() {
        $labels = [
            'name'               => esc_html_x('Episodes', 'post type general name', 'cine-movie-engine'),
            'singular_name'      => esc_html_x('Episode', 'post type singular name', 'cine-movie-engine'),
            'menu_name'          => esc_html_x('Episodes', 'admin menu', 'cine-movie-engine'),
            'name_admin_bar'     => esc_html_x('Episode', 'add new on admin bar', 'cine-movie-engine'),
            'add_new'            => esc_html_x('Add New', 'episode', 'cine-movie-engine'),
            'add_new_item'       => esc_html__('Add New Episode', 'cine-movie-engine'),
            'new_item'           => esc_html__('New Episode', 'cine-movie-engine'),
            'edit_item'          => esc_html__('Edit Episode', 'cine-movie-engine'),
            'view_item'          => esc_html__('View Episode', 'cine-movie-engine'),
            'all_items'          => esc_html__('All Episodes', 'cine-movie-engine'),
            'search_items'       => esc_html__('Search Episodes', 'cine-movie-engine'),
            'not_found'          => esc_html__('No episodes found.', 'cine-movie-engine'),
            'not_found_in_trash' => esc_html__('No episodes found in Trash.', 'cine-movie-engine'),
        ];

        $args = [
            'labels'             => $labels,
            'public'             => true,
            'publicly_queryable' => true,
            'show_ui'            => true,
            'show_in_menu'       => 'edit.php?post_type=movie_engine_series',
            'query_var'          => true,
            'rewrite'            => ['slug' => 'episode'],
            'capability_type'    => 'post',
            'has_archive'        => false,
            'hierarchical'       => false,
            'menu_icon'          => 'dashicons-format-video',
            'supports'           => ['title', 'editor', 'thumbnail', 'excerpt', 'comments'],
            'show_in_rest'       => true,
        ];

        register_post_type('movie_engine_episode', $args);
    }
}
