<?php
/**
 * Post_Type_Review Class
 *
 * @package dvcrs-core
 */

namespace DVCRS\Core;

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

/**
 * Post_Type_Review Class
 */
class Post_Type_Review {

	/**
	 * Post_Type_Review constuctor
	 */
	public function __construct() {

		\add_action( 'init', [ $this, 'register_post_type' ], 1 );

	}

	/**
	 * Registers the custom post type
	 */
	public function register_post_type() {

		$labels = [
			'name'                  => _x( 'Reviews', 'Post Type General Name', 'dvcrs-core' ),
			'singular_name'         => _x( 'Review', 'Post Type Singular Name', 'dvcrs-core' ),
			'menu_name'             => __( 'Reviews', 'dvcrs-core' ),
			'name_admin_bar'        => __( 'Review', 'dvcrs-core' ),
			'archives'              => __( 'Review Archives', 'dvcrs-core' ),
			'attributes'            => __( 'Review Attributes', 'dvcrs-core' ),
			'parent_item_colon'     => __( 'Parent Review:', 'dvcrs-core' ),
			'all_items'             => __( 'All Reviews', 'dvcrs-core' ),
			'add_new_item'          => __( 'Add New Review', 'dvcrs-core' ),
			'add_new'               => __( 'Add New', 'dvcrs-core' ),
			'new_item'              => __( 'New Review', 'dvcrs-core' ),
			'edit_item'             => __( 'Edit Review', 'dvcrs-core' ),
			'update_item'           => __( 'Update Review', 'dvcrs-core' ),
			'view_item'             => __( 'View Review', 'dvcrs-core' ),
			'view_items'            => __( 'View Reviews', 'dvcrs-core' ),
			'search_items'          => __( 'Search Reviews', 'dvcrs-core' ),
			'not_found'             => __( 'Not found', 'dvcrs-core' ),
			'not_found_in_trash'    => __( 'Not found in Trash', 'dvcrs-core' ),
			'featured_image'        => __( 'Featured Image', 'dvcrs-core' ),
			'set_featured_image'    => __( 'Set featured image', 'dvcrs-core' ),
			'remove_featured_image' => __( 'Remove featured image', 'dvcrs-core' ),
			'use_featured_image'    => __( 'Use as featured image', 'dvcrs-core' ),
			'insert_into_item'      => __( 'Add to Review', 'dvcrs-core' ),
			'uploaded_to_this_item' => __( 'Uploaded to this Review', 'dvcrs-core' ),
			'items_list'            => __( 'Review list', 'dvcrs-core' ),
			'items_list_navigation' => __( 'Review list navigation', 'dvcrs-core' ),
			'filter_items_list'     => __( 'Filter Review list', 'dvcrs-core' ),
		];
		$args   = [
			'label'               => __( 'Reviews', 'dvcrs-core' ),
			'description'         => __( 'Reviews at DVC Rental Store', 'dvcrs-core' ),
			'labels'              => $labels,
			'supports'            => [ 'title', 'editor', 'thumbnail' ],
			'hierarchical'        => false,
			'menu_icon'           => 'dashicons-awards',
			'public'              => true,
			'show_in_rest'        => true,
			'has_archive'         => true,
			'has_post_type_page'  => false, // Has category, so we can't have one page for all reviews.
			'exclude_from_search' => false,
			'publicly_queryable'  => true,
			'show_in_nav_menus'   => false,
			'rewrite'            => [
				'slug'       => 'review',
				'with_front' => false,
			],
			'taxonomies'          => [ 'review-type' ],
		];

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

new Post_Type_Review();
