Portfolio Items

add_action('after_setup_theme', function() {
	remove_action('init', 'portfolio_register');
});

add_action('init', 'portfolio_register_mod');
function portfolio_register_mod()
{
	global $avia_config;

	$labels = array(
		'name' => _x('Change This Change This', 'post type general name','avia_framework'),
		'singular_name' => _x('Change This', 'post type singular name','avia_framework'),
		'add_new' => _x('Add New', 'portfolio','avia_framework'),
		'add_new_item' => __('Add New Portfolio Entry','avia_framework'),
		'edit_item' => __('Edit Portfolio Entry','avia_framework'),
		'new_item' => __('New Portfolio Entry','avia_framework'),
		'view_item' => __('View Portfolio Entry','avia_framework'),
		'search_items' => __('Search Portfolio Entries','avia_framework'),
		'not_found' =>  __('No Portfolio Entries found','avia_framework'),
		'not_found_in_trash' => __('No Portfolio Entries found in Trash','avia_framework'),
		'parent_item_colon' => ''
	);

    $permalinks = get_option('avia_permalink_settings');
    if(!$permalinks) $permalinks = array();

    $permalinks['portfolio_permalink_base'] = empty($permalinks['portfolio_permalink_base']) ? __('portfolio-item', 'avia_framework') : $permalinks['portfolio_permalink_base'];
    $permalinks['portfolio_entries_taxonomy_base'] = empty($permalinks['portfolio_entries_taxonomy_base']) ? __('portfolio_entries', 'avia_framework') : $permalinks['portfolio_entries_taxonomy_base'];

	$args = array(
		'labels' => $labels,
		'public' => true,
		'show_ui' => true,
		'capability_type' => 'post',
		'hierarchical' => false,
		'rewrite' => array('slug'=>_x($permalinks['portfolio_permalink_base'],'URL slug','avia_framework'), 'with_front'=>true),
		'query_var' => true,
		'show_in_nav_menus'=> true,
		'taxonomies' => array('post_tag'),
		'supports' => array('title','thumbnail','excerpt','editor','comments')
	);

	$args = apply_filters('avf_portfolio_cpt_args', $args);
	$avia_config['custom_post']['portfolio']['args'] = $args;

	register_post_type( 'portfolio' , $args );

	$tax_args = array(
		"hierarchical" => true,
		"label" => "Portfolio Categories",
		"singular_label" => "Portfolio Category",
		"rewrite" => array('slug'=>_x($permalinks['portfolio_entries_taxonomy_base'],'URL slug','avia_framework'), 'with_front'=>true),
		"query_var" => true
	);

 	$avia_config['custom_taxonomy']['portfolio']['portfolio_entries']['args'] = $tax_args;

	register_taxonomy("portfolio_entries", array("portfolio"), $tax_args);

	//deactivate the avia_flush_rewrites() function - not required because we rely on the default wordpress permalink settings
	remove_action('wp_loaded', 'avia_flush_rewrites');
}