<?php
/**
 * Post Type Registration
 *
 * @package Spin_Wheel
 */

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

/**
 * SWP_Post_Type Class
 */
class SWP_Post_Type {
    
    /**
     * Instance
     *
     * @var SWP_Post_Type
     */
    private static $instance = null;
    
    /**
     * Get instance
     *
     * @return SWP_Post_Type
     */
    public static function instance() {
        if (is_null(self::$instance)) {
            self::$instance = new self();
        }
        return self::$instance;
    }
    
    /**
     * Constructor
     */
    private function __construct() {
        add_action('init', [$this, 'register']);
    }
    
    /**
     * Register post type
     */
    public static function register() {
        $labels = [
            'name'                  => _x('Spin Wheels', 'Post type general name', 'spin-wheel'),
            'singular_name'         => _x('Spin Wheel', 'Post type singular name', 'spin-wheel'),
            'menu_name'             => _x('Spin Wheels', 'Admin Menu text', 'spin-wheel'),
            'name_admin_bar'        => _x('Spin Wheel', 'Add New on Toolbar', 'spin-wheel'),
            'add_new'               => __('Add New', 'spin-wheel'),
            'add_new_item'          => __('Add New Spin Wheel', 'spin-wheel'),
            'new_item'              => __('New Spin Wheel', 'spin-wheel'),
            'edit_item'             => __('Edit Spin Wheel', 'spin-wheel'),
            'view_item'             => __('View Spin Wheel', 'spin-wheel'),
            'all_items'             => __('All Wheels', 'spin-wheel'),
            'search_items'          => __('Search Spin Wheels', 'spin-wheel'),
            'parent_item_colon'     => __('Parent Spin Wheels:', 'spin-wheel'),
            'not_found'             => __('No spin wheels found.', 'spin-wheel'),
            'not_found_in_trash'    => __('No spin wheels found in Trash.', 'spin-wheel'),
        ];
        
        $args = [
            'labels'             => $labels,
            'public'             => false,
            'publicly_queryable' => false,
            'show_ui'            => true,
            'show_in_menu'       => true,
            'menu_icon'          => 'dashicons-sos',
            'query_var'          => true,
            'rewrite'            => ['slug' => 'spin-wheel'],
            'capability_type'    => 'post',
            'has_archive'        => false,
            'hierarchical'       => false,
            'menu_position'      => 25,
            'supports'           => ['title'],
            'show_in_rest'       => true,
        ];
        
        register_post_type('swp_wheel', $args);
    }
}
