<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}


/**
 * Admin functions for the Event post type
 *
 * @author 		Themeum
 * @category 	Admin
 * @package 	Vocal
 * @version     1.0
 *-------------------------------------------------------------*/

/**
 * Register post type event
 *
 * @return void
 */

function themeum_post_type_event()
{
	$labels = array( 
		'name'                	=> _x( 'Events', 'Events', 'themeum' ),
		'singular_name'       	=> _x( 'Event', 'Event', 'themeum' ),
		'menu_name'           	=> __( 'Events', 'themeum' ),
		'parent_item_colon'   	=> __( 'Parent Event:', 'themeum' ),
		'all_items'           	=> __( 'All Events', 'themeum' ),
		'view_item'           	=> __( 'View Event', 'themeum' ),
		'add_new_item'        	=> __( 'Add New Event', 'themeum' ),
		'add_new'             	=> __( 'New Event', 'themeum' ),
		'edit_item'           	=> __( 'Edit Event', 'themeum' ),
		'update_item'         	=> __( 'Update Event', 'themeum' ),
		'search_items'        	=> __( 'Search Event', 'themeum' ),
		'not_found'           	=> __( 'No article found', 'themeum' ),
		'not_found_in_trash'  	=> __( 'No article found in Trash', 'themeum' )
		);

	$args = array(  
		'labels'             	=> $labels,
		'public'             	=> true,
		'publicly_queryable' 	=> true,
		'show_in_menu'       	=> true,
		'show_in_admin_bar'   	=> true,
		'can_export'          	=> true,
		'has_archive'        	=> true,
		'hierarchical'       	=> false,
		'menu_position'      	=> null,
		'menu_icon'				=> '',
		'supports'           	=> array( 'title','editor','thumbnail','comments')
		);

	register_post_type('event',$args);

}

add_action('init','themeum_post_type_event');


/**
 * View Message When Updated Project
 *
 * @param array $messages Existing post update messages.
 * @return array
 */

function themeum_update_message_event( $messages )
{
	global $post, $post_ID;

	$message['event'] = array(
		0 => '',
		1 => sprintf( __('Event updated. <a href="%s">View Event</a>', 'themeum' ), esc_url( get_permalink($post_ID) ) ),
		2 => __('Custom field updated.', 'themeum' ),
		3 => __('Custom field deleted.', 'themeum' ),
		4 => __('Event updated.', 'themeum' ),
		5 => isset($_GET['revision']) ? sprintf( __('Event restored to revision from %s', 'themeum' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
		6 => sprintf( __('Event published. <a href="%s">View Event</a>', 'themeum' ), esc_url( get_permalink($post_ID) ) ),
		7 => __('Event saved.', 'themeum' ),
		8 => sprintf( __('Event submitted. <a target="_blank" href="%s">Preview Event</a>', 'themeum' ), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
		9 => sprintf( __('Event scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview Event</a>', 'themeum' ), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
		10 => sprintf( __('Event draft updated. <a target="_blank" href="%s">Preview Event</a>', 'themeum' ), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
		);

return $message;
}

add_filter( 'post_updated_messages', 'themeum_update_message_event' );


/**
 * Register Event Category Taxonomies
 *
 * @return void
 */

function themeum_register_event_cat_taxonomy()
{
	$labels = array(
		'name'              	=> _x( 'Event Categories', 'taxonomy general name' ),
		'singular_name'     	=> _x( 'Event Category', 'taxonomy singular name' ),
		'search_items'      	=> __( 'Search Event Category' ),
		'all_items'         	=> __( 'All Event Category' ),
		'parent_item'       	=> __( 'Event Parent Category' ),
		'parent_item_colon' 	=> __( 'Event Parent Category:' ),
		'edit_item'         	=> __( 'Edit Event Category' ),
		'update_item'       	=> __( 'Update Event Category' ),
		'add_new_item'      	=> __( 'Add New Event Category' ),
		'new_item_name'     	=> __( 'New Event Category Name' ),
		'menu_name'         	=> __( 'Event Category' )
		);

	$args = array(	'hierarchical'      	=> true,
		'labels'            	=> $labels,
		'show_ui'           	=> true,
		'show_admin_column' 	=> true,
		'query_var'         	=> true
		);

	register_taxonomy('event_cat',array( 'event' ),$args);
}

add_action('init','themeum_register_event_cat_taxonomy');




