<?php

/**
 * Docs :: https://developer.wordpress.org/reference/functions/register_post_type/
 */

$dev_mode = isset($_COOKIE["fgt_development_mode"]) && $_COOKIE["fgt_development_mode"] === 'active' ? TRUE : FALSE;

// Get Options
$data = flo_get_global_option_arr('fgt_options');
if (gettype($data) === 'string') {
	$data = json_decode($data, TRUE);
}

if (isset($data['gallerySlug']) && strlen(trim($data['gallerySlug']))) {
	$gallery_permalink = $data['gallerySlug'];
} else {
	$gallery_permalink = 'gallery';
}

$post_types_arr = array(
	'fgt_header' => array(
		'labels' => array(
			'name'         => 'Headers',
			'singular_name'   => 'Header',
			'menu_name'    => 'Headers'
		),
		'public'             => FALSE,
		'publicly_queryable' => FALSE,
		'show_ui'         => TRUE,
		'show_in_menu'     => $dev_mode,
		'query_var'    => TRUE,
		'rewrite'         => TRUE,
		'capability_type'   => 'post',
		'has_archive'      => TRUE,
		'hierarchical'     => FALSE,
		'menu_position'   => NULL,
		'show_in_rest' => TRUE,
		'rest_controller_class' => 'WP_REST_Posts_Controller',
		'supports'       => array('title', 'editor')
	),
	'fgt_footer' => array(
		'labels' => array(
			'name'         => 'Footers',
			'singular_name'   => 'Footer',
			'menu_name'    => 'Footers'
		),
		'public'             => FALSE,
		'publicly_queryable' => FALSE,
		'show_ui'         => TRUE,
		'show_in_menu'     => $dev_mode,
		'query_var'    => TRUE,
		'rewrite'         => TRUE,
		'capability_type'   => 'post',
		'has_archive'      => TRUE,
		'hierarchical'     => FALSE,
		'menu_position'   => NULL,
		'show_in_rest' => TRUE,
		'rest_controller_class' => 'WP_REST_Posts_Controller',
		'supports'       => array('title', 'editor')
	),
	'fgt_template' => array(
		'labels' => array(
			'name'         => 'Templates',
			'singular_name'   => 'Template',
			'menu_name'    => 'Templates'
		),
		'public'             => FALSE,
		'publicly_queryable' => FALSE,
		'show_ui'         => TRUE,
		'show_in_menu'     => $dev_mode,
		'query_var'    => TRUE,
		'rewrite'         => TRUE,
		'capability_type'   => 'post',
		'has_archive'      => TRUE,
		'hierarchical'     => FALSE,
		'menu_position'   => NULL,
		'show_in_rest' => TRUE,
		'rest_controller_class' => 'WP_REST_Posts_Controller',
		'supports'       => array('title', 'editor')
	),
	'fgt_g_template' => array(
		'labels' => array(
			'name'         => 'Gallery Templates',
			'singular_name'   => 'Gallery Template',
			'menu_name'    => 'Gallery Templates'
		),
		'public'             => FALSE,
		'publicly_queryable' => FALSE,
		'show_ui'         => TRUE,
		'show_in_menu'     => $dev_mode,
		'query_var'    => TRUE,
		'rewrite'         => TRUE,
		'capability_type'   => 'post',
		'has_archive'      => TRUE,
		'hierarchical'     => FALSE,
		'menu_position'   => NULL,
		'show_in_rest' => TRUE,
		'rest_controller_class' => 'WP_REST_Posts_Controller',
		'supports'       => array('title', 'editor')
	),
	'fgt_p_template' => array(
		'labels' => array(
			'name'         => 'Post Templates',
			'singular_name'   => 'Post Template',
			'menu_name'    => 'Post Templates'
		),
		'public'             => FALSE,
		'publicly_queryable' => FALSE,
		'show_ui'         => TRUE,
		'show_in_menu'     => $dev_mode,
		'query_var'    => TRUE,
		'rewrite'         => TRUE,
		'capability_type'   => 'post',
		'has_archive'      => TRUE,
		'hierarchical'     => FALSE,
		'menu_position'   => NULL,
		'show_in_rest' => TRUE,
		'rest_controller_class' => 'WP_REST_Posts_Controller',
		'supports'       => array('title', 'editor')
	),
	'gallery' => array(
		'labels' => array(
			'name'         => 'Galleries',
			'singular_name'   => 'Gallery',
			'menu_name'    => 'Galleries'
		),
		'public'             => TRUE,
		'publicly_queryable' => TRUE,
		'show_ui'         => TRUE,
		'show_in_menu'     => TRUE,
		'query_var'    => TRUE,
		//'rewrite'         => true,
		'rewrite' => array('slug' => $gallery_permalink, 'with_front' => TRUE),
		'capability_type'   => 'post',
		'has_archive'      => TRUE,
		'hierarchical'     => FALSE,
		'menu_position'   => NULL,
		'show_in_rest' => TRUE,
		'rest_controller_class' => 'WP_REST_Posts_Controller',
		'supports'       => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments')
	)
);

if (defined('FGT_WOO_SUPPORT') && FGT_WOO_SUPPORT) {
	$post_types_arr['fgt_woo_templates'] = array(
		'labels' => array(
			'name'         => 'Woo Templates',
			'singular_name'   => 'Woo Templates',
			'menu_name'    => 'Woo Templates'
		),
		'public'             => FALSE,
		'publicly_queryable' => FALSE,
		'show_ui'         => TRUE,
		'show_in_menu'     => $dev_mode,
		'query_var'    => TRUE,
		'rewrite'         => TRUE,
		'capability_type'   => 'post',
		'has_archive'      => TRUE,
		'hierarchical'     => FALSE,
		'menu_position'   => NULL,
		'show_in_rest' => TRUE,
		'rest_controller_class' => 'WP_REST_Posts_Controller',
		'supports'       => array('title', 'editor')
	);
}
