<?php
/*-----------------------------------------------------------------------------------*/
/* Register Custom Post Types - Slideshow */
/*-----------------------------------------------------------------------------------*/
function register_slideshow_post_type(){
	register_post_type('slideshow', array(
		'labels' => array(
			'name' => _x('Slider Items', 'post type general name', THEME_ADMIN_DOMAIN),
			'singular_name' => _x('Slider Item', 'post type singular name', THEME_ADMIN_DOMAIN),
			'add_new' => _x('Add New', 'slideshow', THEME_ADMIN_DOMAIN),
			'add_new_item' => __('Add New Slider Item', THEME_ADMIN_DOMAIN),
			'edit_item' => __('Edit Slider Item', THEME_ADMIN_DOMAIN),
			'new_item' => __('New Slider Item', THEME_ADMIN_DOMAIN),
			'view_item' => __('View Slider Item', THEME_ADMIN_DOMAIN),
			'search_items' => __('Search Slider Items', THEME_ADMIN_DOMAIN),
			'not_found' =>  __('No slider item found', THEME_ADMIN_DOMAIN),
			'not_found_in_trash' => __('No slider items found in Trash', THEME_ADMIN_DOMAIN), 
			'parent_item_colon' => ''
		),
		'singular_label' => __('slideshow', THEME_ADMIN_DOMAIN),
		'public' => false,
		'publicly_queryable' => false,
		'exclude_from_search' => true,
		'show_ui' => true,
		'show_in_menu' => true,
		//'menu_position' => 20,
		'capability_type' => 'page',
		'hierarchical' => false,
		'supports' => array('title','editor', 'page-attributes'),
		'has_archive' => false,
		'rewrite' => false,
		'query_var' => false,
		'can_export' => true,
		'show_in_nav_menus' => false,
	));
	
	//register taxonomy for slideshow
	register_taxonomy('slideshow_category','slideshow',array(
		'hierarchical' => true,
		'labels' => array(
			'name' => _x( 'Slider Categories', 'taxonomy general name', THEME_ADMIN_DOMAIN ),
			'singular_name' => _x( 'Slideshow Category', 'taxonomy singular name', THEME_ADMIN_DOMAIN ),
			'search_items' =>  __( 'Search Categories', THEME_ADMIN_DOMAIN ),
			'popular_items' => __( 'Popular Categories', THEME_ADMIN_DOMAIN ),
			'all_items' => __( 'All Categories', THEME_ADMIN_DOMAIN ),
			'parent_item' => null,
			'parent_item_colon' => null,
			'edit_item' => __( 'Edit Slideshow Category', THEME_ADMIN_DOMAIN ), 
			'update_item' => __( 'Update Slideshow Category', THEME_ADMIN_DOMAIN ),
			'add_new_item' => __( 'Add New Slideshow Category', THEME_ADMIN_DOMAIN ),
			'new_item_name' => __( 'New Slideshow Category Name', THEME_ADMIN_DOMAIN ),
			'separate_items_with_commas' => __( 'Separate Slideshow category with commas', THEME_ADMIN_DOMAIN ),
			'add_or_remove_items' => __( 'Add or remove slideshow category', THEME_ADMIN_DOMAIN ),
			'choose_from_most_used' => __( 'Choose from the most used slideshow category', THEME_ADMIN_DOMAIN ),
			'menu_name' => __( 'Categories', THEME_ADMIN_DOMAIN ),
		),
		'public' => false,
		'show_in_nav_menus' => false,
		'show_ui' => true,
		'show_tagcloud' => false,
		'query_var' => false,
		'rewrite' => false,
	));
}
add_action('init','register_slideshow_post_type',0);

function slideshow_context_fixer() {
	if ( get_query_var( 'post_type' ) == 'slideshow' ) {
		global $wp_query;
		$wp_query->is_home = false;
		$wp_query->is_404 = true;
		$wp_query->is_single = false;
		$wp_query->is_singular = false;
	}
}
add_action( 'template_redirect', 'slideshow_context_fixer' );

