<?php

/**
 * @package safi
 */

namespace WPJoli\SAFI\Controllers;

use WPJoli\SAFI\Application;

class CustomPostType
{
    public function registerCustomPostType()
    {

        /**
         * Meta fields for this post type:
         * - safi_id
         * - safi_index
         * - safi_screenshot
         */

        $args = array(
            'label'                 => 'SAFI Template',
            'supports'              => array('title', 'editor', 'custom-fields'),
            'hierarchical'          => false,
            'public'                => false,
            'show_ui'               => false,
            'show_in_menu'          => false,
            'show_in_admin_bar'     => false,
            'show_in_nav_menus'     => false,
            'query_var'             => false,
            'can_export'            => true,
            'has_archive'           => false,
            'exclude_from_search'   => true,
            'publicly_queryable'    => false,
            'capability_type'       => 'post',
            // 'labels'                => $labels,
            'taxonomies'            => array(Application::TAXONOMY_TEMPLATE, Application::TAXONOMY_TEMPLATE_TAG),
            'show_in_rest'          => true, // Show guttenberg
            'menu_position'         => 5,
        );

        register_post_type(
            Application::POST_TYPE_TEMPLATE,
            apply_filters('safi_template_post_type_args', $args)
        );
    }

    function registerCustomTaxonomies()
    {
        // Template category
        $labels = [
            'name' => __('Template Groups', 'smart-auto-featured-image'),
            'singular_name' => __('Template Group', 'smart-auto-featured-image'),
        ];

        $args = [
            'labels' => $labels,
            'public' => false,
            'hierarchical' => true,
            'show_ui' => false,
            'show_in_rest' => true,
            'show_in_menu' => false,
            'show_admin_column' => false,
            'query_var' => false,
        ];

        register_taxonomy(
            Application::TAXONOMY_TEMPLATE,
            [Application::POST_TYPE_TEMPLATE],
            apply_filters('safi_template_groups_args', $args)
        );


        // Template tags
        $labels = [
            'name' => __('Template Tags', 'smart-auto-featured-image'),
            'singular_name' => __('Template Tag', 'smart-auto-featured-image'),
        ];

        $args = [
            'labels' => $labels,
            'public' => false,
            'hierarchical' => false,
            'show_ui' => false,
            'show_in_rest' => true,
            'show_in_menu' =>false,
            'show_admin_column' => false,
            'query_var' => false,
        ];

        register_taxonomy(
            Application::TAXONOMY_TEMPLATE_TAG,
            [Application::POST_TYPE_TEMPLATE],
            apply_filters('safi_template_tags_args', $args)
        );
    }
}
