<?php

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

/**
 * Register the 'stpo_collection' custom post type.
 *
 * @since      1.0.0
 * @package    Storyposts
 * @subpackage Storyposts/includes/post-types
 */
class Storyposts_Collection_CPT {

	/**
	 * Initialize the class and set its properties.
	 *
	 * @since    1.0.0
	 */
	public function __construct() {
		add_action( 'init', array( $this, 'register_cpt' ), 11 );
	}

	/**
	 * Register the custom post type.
	 *
	 * @since    1.0.0
	 */
	public function register_cpt() {

		$labels = array(
			'name'                  => esc_html_x( 'Collections', 'Post Type General Name', 'storyposts' ),
			'singular_name'         => esc_html_x( 'Collection', 'Post Type Singular Name', 'storyposts' ),
			'menu_name'             => esc_html__( 'Collections', 'storyposts' ),
			'name_admin_bar'        => esc_html__( 'Collection', 'storyposts' ),
			'archives'              => esc_html__( 'Collection Archives', 'storyposts' ),
			'attributes'            => esc_html__( 'Collection Attributes', 'storyposts' ),
			'parent_item_colon'     => esc_html__( 'Parent Collection:', 'storyposts' ),
			'all_items'             => esc_html__( 'Collections', 'storyposts' ),
			'add_new_item'          => esc_html__( 'Add New Collection', 'storyposts' ),
			'add_new'               => esc_html__( 'Add New', 'storyposts' ),
			'new_item'              => esc_html__( 'New Collection', 'storyposts' ),
			'edit_item'             => esc_html__( 'Edit Collection', 'storyposts' ),
			'update_item'           => esc_html__( 'Update Collection', 'storyposts' ),
			'view_item'             => esc_html__( 'View Collection', 'storyposts' ),
			'view_items'            => esc_html__( 'View Collections', 'storyposts' ),
			'search_items'          => esc_html__( 'Search Collection', 'storyposts' ),
			'not_found'             => esc_html__( 'Not found', 'storyposts' ),
			'not_found_in_trash'    => esc_html__( 'Not found in Trash', 'storyposts' ),
			'featured_image'        => esc_html__( 'Cover Image', 'storyposts' ),
			'set_featured_image'    => esc_html__( 'Set cover image', 'storyposts' ),
			'remove_featured_image' => esc_html__( 'Remove cover image', 'storyposts' ),
			'use_featured_image'    => esc_html__( 'Use as cover image', 'storyposts' ),
			'insert_into_item'      => esc_html__( 'Insert into collection', 'storyposts' ),
			'uploaded_to_this_item' => esc_html__( 'Uploaded to this collection', 'storyposts' ),
			'items_list'            => esc_html__( 'Collections list', 'storyposts' ),
			'items_list_navigation' => esc_html__( 'Collections list navigation', 'storyposts' ),
			'filter_items_list'     => esc_html__( 'Filter collections list', 'storyposts' ),
		);

		$args = array(
			'label'                 => esc_html__( 'Collection', 'storyposts' ),
			'description'           => esc_html__( 'Story Collections/Albums', 'storyposts' ),
			'labels'                => $labels,
			'supports'              => array( 'title', 'thumbnail' ),
			'hierarchical'          => false,
			'public'                => false, // Not publicly queryable
			'show_ui'               => true,
			'show_in_menu'          => 'edit.php?post_type=stpo_story', // Submenu of StoryPosts
			'menu_position'         => 5,
			'show_in_admin_bar'     => true,
			'show_in_nav_menus'     => false,
			'can_export'            => true,
			'has_archive'           => false,
			'exclude_from_search'   => true,
			'publicly_queryable'    => false,
			'capability_type'       => 'post',
			'show_in_rest'          => false, // No Gutenberg for now, using classic editor/meta boxes
		);

		register_post_type( 'stpo_collection', $args );

	}

}
