<?php
/**
 * Class ShipmentTemplatePostType
 *
 * @package DhlPolska\ShipmentTemplates
 */

namespace DhlPolska\ShipmentTemplates;

use DhlPolskaVendor\WPDesk\PluginBuilder\Plugin\Hookable;

/**
 * Register shipment templates post type.
 */
class ShipmentTemplatePostType implements Hookable {
	public const POST_TYPE = 'dpd-polska-template';

	/**
	 * Hooks.
	 */
	public function hooks() {
		add_action( 'init', [ $this, 'register_post_type' ] );
	}

	/**
	 * Register post type.
	 *
	 * @return void
	 */
	public function register_post_type(): void {
		$labels = [
			'name'               => __( 'Szablony przesyłek', 'dhl-polska' ),
			'singular_name'      => __( 'Szablon przesyłki', 'dhl-polska' ),
			'add_new'            => __( 'Dodaj nowy', 'dhl-polska' ),
			'add_new_item'       => __( 'Dodaj nowy szablon', 'dhl-polska' ),
			'edit_item'          => __( 'Edytuj szablon', 'dhl-polska' ),
			'new_item'           => __( 'Nowy szablon', 'dhl-polska' ),
			'view_item'          => __( 'Zobacz szablon', 'dhl-polska' ),
			'search_items'       => __( 'Szukaj szablonów', 'dhl-polska' ),
			'not_found'          => __( 'Nie znaleziono szablonów', 'dhl-polska' ),
			'not_found_in_trash' => __( 'Nie znaleziono szablonów w koszu', 'dhl-polska' ),
			'menu_name'          => __( 'Szablony przesyłek', 'dhl-polska' ),
		];

		register_post_type(
			self::POST_TYPE,
			[
				'labels'              => $labels,
				'public'              => false,
				'show_ui'             => true,
				'show_in_menu'        => 'dhl-polska',
				'menu_position'       => 20,
				'exclude_from_search' => true,
				'publicly_queryable'  => false,
				'show_in_admin_bar'   => false,
				'show_in_rest'        => false,
				'has_archive'         => false,
				'rewrite'             => false,
				'supports'            => [ 'title' ],
				'capability_type'     => 'post',
				'map_meta_cap'        => false,
				'capabilities'        => [
					'edit_post'              => 'manage_woocommerce',
					'read_post'              => 'manage_woocommerce',
					'delete_post'            => 'manage_woocommerce',
					'edit_posts'             => 'manage_woocommerce',
					'edit_others_posts'      => 'manage_woocommerce',
					'publish_posts'          => 'manage_woocommerce',
					'read_private_posts'     => 'manage_woocommerce',
					'delete_posts'           => 'manage_woocommerce',
					'delete_private_posts'   => 'manage_woocommerce',
					'delete_published_posts' => 'manage_woocommerce',
					'delete_others_posts'    => 'manage_woocommerce',
					'edit_private_posts'     => 'manage_woocommerce',
					'edit_published_posts'   => 'manage_woocommerce',
					'create_posts'           => 'manage_woocommerce',
				],
			]
		);
	}
}
