<?php
class TFL_Register_Post_Type {
	function __construct() {
		add_action('init', array($this, 'tfl_register_case'));
        add_action( 'init', array($this, 'tfl_register_case_tag'));
		add_action('init', array($this, 'tfl_register_footer'));
		add_action('init', array($this, 'tfl_register_service'));
        add_action('init', array($this, 'tfl_register_service_cat'));

	}

	function tfl_register_case() {
		$case_slug = 'case';
	    $labels = array(
	        'name'                  => esc_html__( 'Case', 'tfl' ),
	        'singular_name'         => esc_html__( 'Case', 'tfl' ),
	        'menu_name'             => esc_html__( 'Case', 'tfl' ),
	        'add_new'               => esc_html__( 'New Case', 'tfl' ),
	        'add_new_item'          => esc_html__( 'Add New Case', 'tfl' ),
	        'new_item'              => esc_html__( 'New Case Item', 'tfl' ),
	        'edit_item'             => esc_html__( 'Edit Case Item', 'tfl' ),
	        'view_item'             => esc_html__( 'View Case', 'tfl' ),
	        'all_items'             => esc_html__( 'All Case', 'tfl' ),
	        'search_items'          => esc_html__( 'Search Case', 'tfl' ),
	        'not_found'             => esc_html__( 'No Case Items Found', 'tfl' ),
	        'not_found_in_trash'    => esc_html__( 'No Case Items Found In Trash', 'tfl' ),
	        'parent_item_colon'     => esc_html__( 'Parent Case:', 'tfl' ),
	        'not_found'             => esc_html__( 'No Case found', 'tfl' ),
	        'not_found_in_trash'    => esc_html__( 'No Case found in Trash', 'tfl' )
	    );
	    $args = array(
	        'labels'      => $labels,
	        'rewrite'               => array( 'slug' => $case_slug ),
	        'supports'    => array( 'title', 'editor', 'thumbnail','excerpt' ),
	        'public'      => true,
	        'has_archive' => true,
//	        'publicly_queryable'  => false,
	        'menu_icon'   => 'dashicons-calendar',
	    );
	    register_post_type( 'case', $args );
	    flush_rewrite_rules();
	}

	function tfl_register_footer() {

        $labels = array(
            'name'                  => _x( 'Footer', 'Post type general name', 'footer' ),
            'singular_name'         => _x( 'Footer', 'Post type singular name', 'footer' ),
            'menu_name'             => _x( 'Footer', 'Admin Menu text', 'footer' ),
            'name_admin_bar'        => _x( 'Footer', 'Add New on Toolbar', 'footer' ),
            'add_new'               => __( 'Add New', 'footer' ),
            'add_new_item'          => __( 'Add New footer', 'footer' ),
            'new_item'              => __( 'New footer', 'footer' ),
            'edit_item'             => __( 'Edit footer', 'footer' ),
            'view_item'             => __( 'View footer', 'footer' ),
            'all_items'             => __( 'All footers', 'footer' ),
            'search_items'          => __( 'Search footers', 'footer' ),
            'parent_item_colon'     => __( 'Parent footers:', 'footer' ),
            'not_found'             => __( 'No footers found.', 'footer' ),
            'not_found_in_trash'    => __( 'No footers found in Trash.', 'footer' ),
            'featured_image'        => _x( 'Footer Cover Image', 'Overrides the “Featured Image” phrase for this post type. Added in 4.3', 'footer' ),
            'set_featured_image'    => _x( 'Set cover image', 'Overrides the “Set featured image” phrase for this post type. Added in 4.3', 'footer' ),
            'remove_featured_image' => _x( 'Remove cover image', 'Overrides the “Remove featured image” phrase for this post type. Added in 4.3', 'footer' ),
            'use_featured_image'    => _x( 'Use as cover image', 'Overrides the “Use as featured image” phrase for this post type. Added in 4.3', 'footer' ),
            'archives'              => _x( 'Footer archives', 'The post type archive label used in nav menus. Default “Post Archives”. Added in 4.4', 'footer' ),
            'insert_into_item'      => _x( 'Insert into footer', 'Overrides the “Insert into post”/”Insert into page” phrase (used when inserting media into a post). Added in 4.4', 'footer' ),
            'uploaded_to_this_item' => _x( 'Uploaded to this footer', 'Overrides the “Uploaded to this post”/”Uploaded to this page” phrase (used when viewing media attached to a post). Added in 4.4', 'footer' ),
            'filter_items_list'     => _x( 'Filter footers list', 'Screen reader text for the filter links heading on the post type listing screen. Default “Filter posts list”/”Filter pages list”. Added in 4.4', 'footer' ),
            'items_list_navigation' => _x( 'Footers list navigation', 'Screen reader text for the pagination heading on the post type listing screen. Default “Posts list navigation”/”Pages list navigation”. Added in 4.4', 'footer' ),
            'items_list'            => _x( 'Footers list', 'Screen reader text for the items list heading on the post type listing screen. Default “Posts list”/”Pages list”. Added in 4.4', 'footer' ),
        );
        $args = array(
            'labels'             => $labels,
            'description'        => 'Footer custom post type.',
            'public'             => true,
            'publicly_queryable' => true,
            'show_ui'            => true,
            'show_in_menu'       => true,
            'query_var'          => true,
            'rewrite'            => array( 'slug' => 'tfl_footer' ),
            'capability_type'    => 'post',
            'has_archive'        => false,
            'hierarchical'       => false,
            'menu_position'      => 20,
            'show_in_rest'       => true
        );
        register_post_type( 'tfl_footer', $args );

	}

	function tfl_register_service() {
		$services_slug = 'services';
	    $labels = array(
	        'name'                  => esc_html__( 'Services', 'tfl' ),
	        'singular_name'         => esc_html__( 'Service', 'tfl' ),
	        'menu_name'             => esc_html__( 'Services', 'tfl' ),
	        'add_new'               => esc_html__( 'New Service', 'tfl' ),
	        'add_new_item'          => esc_html__( 'Add New Service', 'tfl' ),
	        'new_item'              => esc_html__( 'New Service Item', 'tfl' ),
	        'edit_item'             => esc_html__( 'Edit Service Item', 'tfl' ),
	        'view_item'             => esc_html__( 'View Service', 'tfl' ),
	        'all_items'             => esc_html__( 'All Service', 'tfl' ),
	        'search_items'          => esc_html__( 'Search Service', 'tfl' ),
	        'not_found'             => esc_html__( 'No Service Items Found', 'tfl' ),
	        'not_found_in_trash'    => esc_html__( 'No Service Items Found In Trash', 'tfl' ),
	        'parent_item_colon'     => esc_html__( 'Parent Service:', 'tfl' ),
	        'not_found'             => esc_html__( 'No Service found', 'tfl' ),
	        'not_found_in_trash'    => esc_html__( 'No Service found in Trash', 'tfl' )
	    );
	    $args = array(
	        'labels'      => $labels,
	        'supports'    => array( 'title', 'editor', 'thumbnail','excerpt' ),
	        'rewrite'               => array( 'slug' => $services_slug ),
	        'public'      => true,
	        'has_archive' => true,
//	        'publicly_queryable'  => false,
	        'menu_icon'   => 'dashicons-id-alt',
	    );
	    register_post_type( 'service', $args );
	    flush_rewrite_rules();
	}

	function tfl_register_case_tag() {
	    $labels = array(
	        'name'                       => esc_html__( 'Tags', 'tfl' ),
	        'singular_name'              => esc_html__( 'Tags', 'tfl' ),
	        'search_items'               => esc_html__( 'Search Tags', 'tfl' ),
	        'menu_name'                  => esc_html__( 'Tags', 'tfl' ),
	        'all_items'                  => esc_html__( 'All Tags', 'tfl' ),
	        'parent_item'                => esc_html__( 'Parent Tags', 'tfl' ),
	        'parent_item_colon'          => esc_html__( 'Parent Tags:', 'tfl' ),
	        'new_item_name'              => esc_html__( 'New Tags Name', 'tfl' ),
	        'add_new_item'               => esc_html__( 'Add New Tags', 'tfl' ),
	        'edit_item'                  => esc_html__( 'Edit Tags', 'tfl' ),
	        'update_item'                => esc_html__( 'Update Tags', 'tfl' ),
	        'add_or_remove_items'        => esc_html__( 'Add or remove Tags', 'tfl' ),
	        'choose_from_most_used'      => esc_html__( 'Choose from the most used Tags', 'tfl' ),
	        'not_found'                  => esc_html__( 'No Tags found.' ),
	        'menu_name'                  => esc_html__( 'Tags' ),
	    );
	    $args = array(
	        'labels'       => $labels,
	        'hierarchical' => true,
	    );
	    register_taxonomy( 'case_tag', 'case', $args );
	    flush_rewrite_rules();
	}

    function tfl_register_service_cat() {
        $labels = array(
            'name'                       => esc_html__( 'Categories', 'tfl' ),
            'singular_name'              => esc_html__( 'Categories', 'tfl' ),
            'search_items'               => esc_html__( 'Search Categories', 'tfl' ),
            'menu_name'                  => esc_html__( 'Categories', 'tfl' ),
            'all_items'                  => esc_html__( 'All Categories', 'tfl' ),
            'parent_item'                => esc_html__( 'Parent Categories', 'tfl' ),
            'parent_item_colon'          => esc_html__( 'Parent Categories:', 'tfl' ),
            'new_item_name'              => esc_html__( 'New Categories Name', 'tfl' ),
            'add_new_item'               => esc_html__( 'Add New Categories', 'tfl' ),
            'edit_item'                  => esc_html__( 'Edit Categories', 'tfl' ),
            'update_item'                => esc_html__( 'Update Categories', 'tfl' ),
            'add_or_remove_items'        => esc_html__( 'Add or remove Categories', 'tfl' ),
            'choose_from_most_used'      => esc_html__( 'Choose from the most used Categories', 'tfl' ),
            'not_found'                  => esc_html__( 'No Categories found.' ),
            'menu_name'                  => esc_html__( 'Categories' ),
        );
        $args = array(
            'labels'       => $labels,
            'hierarchical' => true,
        );
        register_taxonomy( 'service_cat', 'service', $args );
        flush_rewrite_rules();
    }


}
$tfl_register_post_type = new TFL_Register_Post_Type();