<?php
class WPCTP_Sliders_Post_Type {
	function __construct() {
		add_action( 'init', array( $this, 'wpctp_slider_post_type' ) );
		add_action( 'template_redirect', array( $this, 'wpctp_template_redirect' ) );
	}
	function wpctp_slider_post_type() {
		register_post_type(
			'wpcargo_slider',
			array(
				'labels' => array(
					'name' 				=> __( 'WPCargo Sliders', 'wpctp' ),
					'singular_name' 	=> __( 'WPCargo Slider', 'wpctp' ),
					'add_new' 			=> __( 'Add Slider', 'wpctp' ),
					'add_new_item' 		=> __( 'Add New Slider', 'wpctp' ),
					'edit_item' 		=> __( 'Edit Slider', 'wpctp' ),
					'all_items'			=> __( 'Sliders', 'wpctp' ),
					'menu_name' 		=> __( 'WPCargo Sliders', 'wpctp' ),
					'view_item' 		=> false,
					'featured_image'	=> __( 'Slider Image', 'wpctp' ),
					'set_featured_image'	=> __( 'Set Slider Image', 'wpctp' ),
					'remove_featured_image'	=> __( 'Remove Slider Image', 'wpctp' ),
					'use_featured_image'	=> __( 'Use as Slider Image', 'wpctp' ),
				),
				'public'		 		=> true,
				'hierarchical' 			=> false,
				'rewrite' 				=> false,
				'query_var' 			=> false,
				'show_in_nav_menus' 	=> false,
				'exclude_from_search' 	=> true,
				'supports' 				=> array( 'title', 'editor', 'revisions', 'thumbnail' ),
			)
		);
	}
	public function wpctp_template_redirect(){
		if( get_post_type() == 'wpcargo_slider' ){
			wp_redirect( get_bloginfo( 'url' ) );
			exit();
		}
	}
}
new WPCTP_Sliders_Post_Type;