<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
/**
 * Register the Custom Post Type for Reusable Templates.
 *
 * This function creates the 'section_templates' post type, which will be used
 * to store reusable sections built with Elementor.
 *
 * @since 1.0.4
 */
function sifency_addons_register_section_templates_cpt() {

	/**
	 * Defines the labels for the Custom Post Type.
	 * These are the strings that will appear throughout the WordPress admin UI.
	 */
	$labels = array(
		'name'                  => _x( 'Reusable Templates', 'Post Type General Name', 'sifency-addons' ),
		'singular_name'         => _x( 'Section Template', 'Post Type Singular Name', 'sifency-addons' ),
		'menu_name'             => __( 'Reusable Templates', 'sifency-addons' ),
		'name_admin_bar'        => __( 'Section Template', 'sifency-addons' ),
		'archives'              => __( 'Section Archives', 'sifency-addons' ),
		'attributes'            => __( 'Section Attributes', 'sifency-addons' ),
		'parent_item_colon'     => __( 'Parent Section:', 'sifency-addons' ),
		'all_items'             => __( 'All Sections', 'sifency-addons' ),
		'add_new_item'          => __( 'Add New Section', 'sifency-addons' ),
		'add_new'               => __( 'Add New', 'sifency-addons' ),
		'new_item'              => __( 'New Section', 'sifency-addons' ),
		'edit_item'             => __( 'Edit Section', 'sifency-addons' ),
		'update_item'           => __( 'Update Section', 'sifency-addons' ),
		'view_item'             => __( 'View Section', 'sifency-addons' ),
		'view_items'            => __( 'View Sections', 'sifency-addons' ),
		'search_items'          => __( 'Search Section', 'sifency-addons' ),
		'not_found'             => __( 'No sections found.', 'sifency-addons' ),
		'not_found_in_trash'    => __( 'No sections found in Trash.', 'sifency-addons' ),
		'featured_image'        => __( 'Featured Image', 'sifency-addons' ),
		'set_featured_image'    => __( 'Set featured image', 'sifency-addons' ),
		'remove_featured_image' => __( 'Remove featured image', 'sifency-addons' ),
		'use_featured_image'    => __( 'Use as featured image', 'sifency-addons' ),
		'insert_into_item'      => __( 'Insert into section', 'sifency-addons' ),
		'uploaded_to_this_item' => __( 'Uploaded to this section', 'sifency-addons' ),
		'items_list'            => __( 'Sections list', 'sifency-addons' ),
		'items_list_navigation' => __( 'Sections list navigation', 'sifency-addons' ),
		'filter_items_list'     => __( 'Filter sections list', 'sifency-addons' ),
	);

	/**
	 * Defines the arguments for registering the Custom Post Type.
	 */
	$args = array(
		'label'               => __( 'Section Template', 'sifency-addons' ),
		'description'         => __( 'Reusable templates for sections, displayed via shortcode.', 'sifency-addons' ),
		'labels'              => $labels,
		'supports'            => array( 'title', 'editor', 'revisions', 'elementor' ),
		'hierarchical'        => false,
		'public'              => true,
		'show_ui'             => true,
		'show_in_menu'        => false,
		'menu_position'       => 5,
		'menu_icon'           => 'dashicons-layout',
		'show_in_admin_bar'   => true,
		'show_in_nav_menus'   => false,
		'can_export'          => true,
		'has_archive'         => false,
		'exclude_from_search' => true,
		'publicly_queryable'  => true,
		'capability_type'     => 'post',
		'show_in_rest'        => true,
	);

	register_post_type( 'section_templates', $args );

}

add_action( 'init', 'sifency_addons_register_section_templates_cpt', 0 );
