<?php


if (!function_exists('tdg_custom_post_type_about_us')) {

	// Register Custom Post Type About Us
	function tdg_custom_post_type_about_us()
	{
		$labels = array(
			'name' => _x('About Us', 'Post Type General Name', 'hello-thedavanigroup'),
			'singular_name' => _x('About Us', 'Post Type Singular Name', 'hello-thedavanigroup'),
			'menu_name' => __('About Us', 'hello-thedavanigroup'),
			'name_admin_bar' => __('About Us', 'hello-thedavanigroup'),
			'archives' => __('Item Archives', 'hello-thedavanigroup'),
			'attributes' => __('Item Attributes', 'hello-thedavanigroup'),
			'parent_item_colon' => __('Parent Item:', 'hello-thedavanigroup'),
			'all_items' => __('All Items', 'hello-thedavanigroup'),
			'add_new_item' => __('Add New Item', 'hello-thedavanigroup'),
			'add_new' => __('Add New', 'hello-thedavanigroup'),
			'new_item' => __('New Item', 'hello-thedavanigroup'),
			'edit_item' => __('Edit Item', 'hello-thedavanigroup'),
			'update_item' => __('Update Item', 'hello-thedavanigroup'),
			'view_item' => __('View Item', 'hello-thedavanigroup'),
			'view_items' => __('View Items', 'hello-thedavanigroup'),
			'search_items' => __('Search Item', 'hello-thedavanigroup'),
			'not_found' => __('Not found', 'hello-thedavanigroup'),
			'not_found_in_trash' => __('Not found in Trash', 'hello-thedavanigroup'),
			'featured_image' => __('Featured Image', 'hello-thedavanigroup'),
			'set_featured_image' => __('Set featured image', 'hello-thedavanigroup'),
			'remove_featured_image' => __('Remove featured image', 'hello-thedavanigroup'),
			'use_featured_image' => __('Use as featured image', 'hello-thedavanigroup'),
			'insert_into_item' => __('Insert into item', 'hello-thedavanigroup'),
			'uploaded_to_this_item' => __('Uploaded to this item', 'hello-thedavanigroup'),
			'items_list' => __('Items list', 'hello-thedavanigroup'),
			'items_list_navigation' => __('Items list navigation', 'hello-thedavanigroup'),
			'filter_items_list' => __('Filter items list', 'hello-thedavanigroup'),
		);
		$rewrite = array(
			'slug' => 'about-us',
			'with_front' => true,
		);
		$args = array(
			'label' => __('About Us', 'hello-thedavanigroup'),
			'description' => __('Post Type Description', 'hello-thedavanigroup'),
			'labels' => $labels,
			'supports' => array('title', 'editor', 'thumbnail', 'page-attributes', 'custom-fields'),
			'hierarchical' => false,
			'public' => true,
			'publicly_queryable' => true,
			'show_ui' => true,
			'query_var' => true,
			'show_in_menu' => true,
			'menu_position' => 5,
			'menu_icon' => 'dashicons-admin-comments',
			'show_in_admin_bar' => true,
			'show_in_nav_menus' => true,
			'can_export' => true,
			'has_archive' => 'about-us',
			'exclude_from_search' => false,
			'rewrite' => $rewrite, //$rewrite,
			'capability_type' => 'post',
			'show_in_rest' => true,
		);
		register_post_type('about-us', $args);
	}
	add_action('init', 'tdg_custom_post_type_about_us', 0);
}

if (!function_exists('tdg_custom_post_type_collections')) {

	// Register Custom Post Type Collection Product
	function tdg_custom_post_type_collections()
	{
		$labels = array(
			'name' => _x('Collections', 'Post Type General Name', 'hello-thedavanigroup'),
			'singular_name' => _x('Collections', 'Post Type Singular Name', 'hello-thedavanigroup'),
			'menu_name' => __('Collections', 'hello-thedavanigroup'),
			'name_admin_bar' => __('Collections', 'hello-thedavanigroup'),
			'archives' => __('Item Archives', 'hello-thedavanigroup'),
			'attributes' => __('Item Attributes', 'hello-thedavanigroup'),
			'parent_item_colon' => __('Parent Item:', 'hello-thedavanigroup'),
			'all_items' => __('All Items', 'hello-thedavanigroup'),
			'add_new_item' => __('Add New Item', 'hello-thedavanigroup'),
			'add_new' => __('Add New', 'hello-thedavanigroup'),
			'new_item' => __('New Item', 'hello-thedavanigroup'),
			'edit_item' => __('Edit Item', 'hello-thedavanigroup'),
			'update_item' => __('Update Item', 'hello-thedavanigroup'),
			'view_item' => __('View Item', 'hello-thedavanigroup'),
			'view_items' => __('View Items', 'hello-thedavanigroup'),
			'search_items' => __('Search Item', 'hello-thedavanigroup'),
			'not_found' => __('Not found', 'hello-thedavanigroup'),
			'not_found_in_trash' => __('Not found in Trash', 'hello-thedavanigroup'),
			'featured_image' => __('Featured Image', 'hello-thedavanigroup'),
			'set_featured_image' => __('Set featured image', 'hello-thedavanigroup'),
			'remove_featured_image' => __('Remove featured image', 'hello-thedavanigroup'),
			'use_featured_image' => __('Use as featured image', 'hello-thedavanigroup'),
			'insert_into_item' => __('Insert into item', 'hello-thedavanigroup'),
			'uploaded_to_this_item' => __('Uploaded to this item', 'hello-thedavanigroup'),
			'items_list' => __('Items list', 'hello-thedavanigroup'),
			'items_list_navigation' => __('Items list navigation', 'hello-thedavanigroup'),
			'filter_items_list' => __('Filter items list', 'hello-thedavanigroup'),
		);
		$rewrite = array(
			'slug' => 'collection-product',
			// 'with_front' => true,
		);
		$args = array(
			'label' => __('Collection', 'hello-thedavanigroup'),
			'description' => __('Post Type Description', 'hello-thedavanigroup'),
			'labels' => $labels,
			'supports' => array('title', 'editor', 'thumbnail', 'page-attributes', 'custom-fields'),
			'hierarchical' => false,
			'public' => true,
			'publicly_queryable' => true,
			'show_ui' => true,
			'query_var' => true,
			'show_in_menu' => true,
			'menu_position' => 5,
			'menu_icon' => 'dashicons-archive',
			'show_in_admin_bar' => true,
			'show_in_nav_menus' => true,
			'can_export' => true,
			'has_archive' => 'collections',
			'exclude_from_search' => false,
			'rewrite' => $rewrite, //$rewrite,
			'capability_type' => 'post',
			'show_in_rest' => true,
		);
		register_post_type('collection-product', $args);
	}
	add_action('init', 'tdg_custom_post_type_collections', 0);
}

if (!function_exists('custom_taxonomy_collections')) {

	// Register Taxonomy Collections
	function custom_taxonomy_collections()
	{
		$labels = array(
			'name' => _x('Category Collections', 'Taxonomy General Name', 'hello-thedavanigroup'),
			'singular_name' => _x('Category', 'Taxonomy Singular Name', 'hello-thedavanigroup'),
			'menu_name' => __('Category', 'hello-thedavanigroup'),
			'all_items' => __('All Items', 'hello-thedavanigroup'),
			'parent_item' => __('Parent Item', 'hello-thedavanigroup'),
			'parent_item_colon' => __('Parent Item:', 'hello-thedavanigroup'),
			'new_item_name' => __('New Item Name', 'hello-thedavanigroup'),
			'add_new_item' => __('Add New Item', 'hello-thedavanigroup'),
			'edit_item' => __('Edit Item', 'hello-thedavanigroup'),
			'update_item' => __('Update Item', 'hello-thedavanigroup'),
			'view_item' => __('View Item', 'hello-thedavanigroup'),
			'separate_items_with_commas' => __('Separate items with commas', 'hello-thedavanigroup'),
			'add_or_remove_items' => __('Add or remove items', 'hello-thedavanigroup'),
			'choose_from_most_used' => __('Choose from the most used', 'hello-thedavanigroup'),
			'popular_items' => __('Popular Items', 'hello-thedavanigroup'),
			'search_items' => __('Search Items', 'hello-thedavanigroup'),
			'not_found' => __('Not Found', 'hello-thedavanigroup'),
			'no_terms' => __('No items', 'hello-thedavanigroup'),
			'items_list' => __('Items list', 'hello-thedavanigroup'),
			'items_list_navigation' => __('Items list navigation', 'hello-thedavanigroup'),
		);
		$rewrite = array(
			'slug' => 'collections',
			'with_front' => true,
			'hierarchical' => true,
		);
		$args = array(
			'labels' => $labels,
			'hierarchical' => true,
			'public' => true,
			'show_ui' => true,
			'show_admin_column' => true,
			'show_in_nav_menus' => true,
			'show_tagcloud' => true,
			'rewrite' => $rewrite,
			'show_in_rest' => true,
		);
		register_taxonomy('collections', array('collection-product'), $args);

	}
	add_action('init', 'custom_taxonomy_collections', 0);
}

if (!function_exists('tdg_custom_post_type_custom_fabric')) {

	// Register Custom Post Type About Us
	function tdg_custom_post_type_custom_fabric()
	{
		$labels = array(
			'name' => _x('Custom Fabrication', 'Post Type General Name', 'hello-thedavanigroup'),
			'singular_name' => _x('Custom Fabrication', 'Post Type Singular Name', 'hello-thedavanigroup'),
			'menu_name' => __('Custom Fabrication', 'hello-thedavanigroup'),
			'name_admin_bar' => __('Custom Fabrication', 'hello-thedavanigroup'),
			'archives' => __('Item Archives', 'hello-thedavanigroup'),
			'attributes' => __('Item Attributes', 'hello-thedavanigroup'),
			'parent_item_colon' => __('Parent Item:', 'hello-thedavanigroup'),
			'all_items' => __('All Items', 'hello-thedavanigroup'),
			'add_new_item' => __('Add New Item', 'hello-thedavanigroup'),
			'add_new' => __('Add New', 'hello-thedavanigroup'),
			'new_item' => __('New Item', 'hello-thedavanigroup'),
			'edit_item' => __('Edit Item', 'hello-thedavanigroup'),
			'update_item' => __('Update Item', 'hello-thedavanigroup'),
			'view_item' => __('View Item', 'hello-thedavanigroup'),
			'view_items' => __('View Items', 'hello-thedavanigroup'),
			'search_items' => __('Search Item', 'hello-thedavanigroup'),
			'not_found' => __('Not found', 'hello-thedavanigroup'),
			'not_found_in_trash' => __('Not found in Trash', 'hello-thedavanigroup'),
			'featured_image' => __('Featured Image', 'hello-thedavanigroup'),
			'set_featured_image' => __('Set featured image', 'hello-thedavanigroup'),
			'remove_featured_image' => __('Remove featured image', 'hello-thedavanigroup'),
			'use_featured_image' => __('Use as featured image', 'hello-thedavanigroup'),
			'insert_into_item' => __('Insert into item', 'hello-thedavanigroup'),
			'uploaded_to_this_item' => __('Uploaded to this item', 'hello-thedavanigroup'),
			'items_list' => __('Items list', 'hello-thedavanigroup'),
			'items_list_navigation' => __('Items list navigation', 'hello-thedavanigroup'),
			'filter_items_list' => __('Filter items list', 'hello-thedavanigroup'),
		);
		$rewrite = array(
			'slug' => 'custom-product',
			// 'with_front' => true,
		);
		$args = array(
			'label' => __('Custom Fabrication', 'hello-thedavanigroup'),
			'description' => __('Post Type Description', 'hello-thedavanigroup'),
			'labels' => $labels,
			'supports' => array('title', 'editor', 'thumbnail', 'page-attributes', 'custom-fields'),
			'hierarchical' => false,
			'public' => true,
			'publicly_queryable' => true,
			'show_ui' => true,
			'query_var' => true,
			'show_in_menu' => true,
			'menu_position' => 5,
			'menu_icon' => 'dashicons-archive',
			'show_in_admin_bar' => true,
			'show_in_nav_menus' => true,
			'can_export' => true,
			'has_archive' => 'fabrication-services',
			'exclude_from_search' => false,
			'rewrite' => $rewrite, //$rewrite,
			'capability_type' => 'post',
			'show_in_rest' => true,
		);
		register_post_type('custom-fabrication', $args);
	}
	add_action('init', 'tdg_custom_post_type_custom_fabric', 0);
}

if (!function_exists('custom_taxonomy_custom_fabric')) {

	// Register Taxonomy Fabric
	function custom_taxonomy_custom_fabric()
	{
		$labels = array(
			'name' => _x('Category Fabric', 'Taxonomy General Name', 'hello-thedavanigroup'),
			'singular_name' => _x('Category', 'Taxonomy Singular Name', 'hello-thedavanigroup'),
			'menu_name' => __('Category', 'hello-thedavanigroup'),
			'all_items' => __('All Items', 'hello-thedavanigroup'),
			'parent_item' => __('Parent Item', 'hello-thedavanigroup'),
			'parent_item_colon' => __('Parent Item:', 'hello-thedavanigroup'),
			'new_item_name' => __('New Item Name', 'hello-thedavanigroup'),
			'add_new_item' => __('Add New Item', 'hello-thedavanigroup'),
			'edit_item' => __('Edit Item', 'hello-thedavanigroup'),
			'update_item' => __('Update Item', 'hello-thedavanigroup'),
			'view_item' => __('View Item', 'hello-thedavanigroup'),
			'separate_items_with_commas' => __('Separate items with commas', 'hello-thedavanigroup'),
			'add_or_remove_items' => __('Add or remove items', 'hello-thedavanigroup'),
			'choose_from_most_used' => __('Choose from the most used', 'hello-thedavanigroup'),
			'popular_items' => __('Popular Items', 'hello-thedavanigroup'),
			'search_items' => __('Search Items', 'hello-thedavanigroup'),
			'not_found' => __('Not Found', 'hello-thedavanigroup'),
			'no_terms' => __('No items', 'hello-thedavanigroup'),
			'items_list' => __('Items list', 'hello-thedavanigroup'),
			'items_list_navigation' => __('Items list navigation', 'hello-thedavanigroup'),
		);
		$rewrite = array(
			'slug' => 'fabrication-services',
			'with_front' => true,
			'hierarchical' => true,
		);
		$args = array(
			'labels' => $labels,
			'hierarchical' => true,
			'public' => true,
			'show_ui' => true,
			'show_admin_column' => true,
			'show_in_nav_menus' => true,
			'show_tagcloud' => true,
			'rewrite' => $rewrite,
			'show_in_rest' => true,
		);
		register_taxonomy('custom-fabric-cat', array('custom-fabrication'), $args);

	}
	add_action('init', 'custom_taxonomy_custom_fabric', 0);
}

if (!function_exists('tdg_custom_post_type_stones')) {

	// Register Custom Post Type Stone Product
	function tdg_custom_post_type_stones()
	{
		$labels = array(
			'name' => _x('Stones', 'Post Type General Name', 'hello-thedavanigroup'),
			'singular_name' => _x('Stones', 'Post Type Singular Name', 'hello-thedavanigroup'),
			'menu_name' => __('Stones', 'hello-thedavanigroup'),
			'name_admin_bar' => __('Stones', 'hello-thedavanigroup'),
			'archives' => __('Item Archives', 'hello-thedavanigroup'),
			'attributes' => __('Item Attributes', 'hello-thedavanigroup'),
			'parent_item_colon' => __('Parent Item:', 'hello-thedavanigroup'),
			'all_items' => __('All Items', 'hello-thedavanigroup'),
			'add_new_item' => __('Add New Item', 'hello-thedavanigroup'),
			'add_new' => __('Add New', 'hello-thedavanigroup'),
			'new_item' => __('New Item', 'hello-thedavanigroup'),
			'edit_item' => __('Edit Item', 'hello-thedavanigroup'),
			'update_item' => __('Update Item', 'hello-thedavanigroup'),
			'view_item' => __('View Item', 'hello-thedavanigroup'),
			'view_items' => __('View Items', 'hello-thedavanigroup'),
			'search_items' => __('Search Item', 'hello-thedavanigroup'),
			'not_found' => __('Not found', 'hello-thedavanigroup'),
			'not_found_in_trash' => __('Not found in Trash', 'hello-thedavanigroup'),
			'featured_image' => __('Featured Image', 'hello-thedavanigroup'),
			'set_featured_image' => __('Set featured image', 'hello-thedavanigroup'),
			'remove_featured_image' => __('Remove featured image', 'hello-thedavanigroup'),
			'use_featured_image' => __('Use as featured image', 'hello-thedavanigroup'),
			'insert_into_item' => __('Insert into item', 'hello-thedavanigroup'),
			'uploaded_to_this_item' => __('Uploaded to this item', 'hello-thedavanigroup'),
			'items_list' => __('Items list', 'hello-thedavanigroup'),
			'items_list_navigation' => __('Items list navigation', 'hello-thedavanigroup'),
			'filter_items_list' => __('Filter items list', 'hello-thedavanigroup'),
		);
		$rewrite = array(
			'slug' => 'stone-product',
			// 'with_front' => true,
		);
		$args = array(
			'label' => __('Stone', 'hello-thedavanigroup'),
			'description' => __('Post Type Description', 'hello-thedavanigroup'),
			'labels' => $labels,
			'supports' => array('title', 'editor', 'thumbnail', 'page-attributes', 'custom-fields'),
			'hierarchical' => false,
			'public' => true,
			'publicly_queryable' => true,
			'show_ui' => true,
			'query_var' => true,
			'show_in_menu' => true,
			'menu_position' => 5,
			'menu_icon' => 'dashicons-archive',
			'show_in_admin_bar' => true,
			'show_in_nav_menus' => true,
			'can_export' => true,
			'has_archive' => 'stones',
			'exclude_from_search' => false,
			'rewrite' => $rewrite, //$rewrite,
			'capability_type' => 'post',
			'show_in_rest' => true,
		);
		register_post_type('stone-product', $args);
	}
	add_action('init', 'tdg_custom_post_type_stones', 0);
}

if (!function_exists('custom_taxonomy_stones')) {

	// Register Taxonomy Stones
	function custom_taxonomy_stones()
	{
		$labels = array(
			'name' => _x('Category Stone', 'Taxonomy General Name', 'hello-thedavanigroup'),
			'singular_name' => _x('Category', 'Taxonomy Singular Name', 'hello-thedavanigroup'),
			'menu_name' => __('Category', 'hello-thedavanigroup'),
			'all_items' => __('All Items', 'hello-thedavanigroup'),
			'parent_item' => __('Parent Item', 'hello-thedavanigroup'),
			'parent_item_colon' => __('Parent Item:', 'hello-thedavanigroup'),
			'new_item_name' => __('New Item Name', 'hello-thedavanigroup'),
			'add_new_item' => __('Add New Item', 'hello-thedavanigroup'),
			'edit_item' => __('Edit Item', 'hello-thedavanigroup'),
			'update_item' => __('Update Item', 'hello-thedavanigroup'),
			'view_item' => __('View Item', 'hello-thedavanigroup'),
			'separate_items_with_commas' => __('Separate items with commas', 'hello-thedavanigroup'),
			'add_or_remove_items' => __('Add or remove items', 'hello-thedavanigroup'),
			'choose_from_most_used' => __('Choose from the most used', 'hello-thedavanigroup'),
			'popular_items' => __('Popular Items', 'hello-thedavanigroup'),
			'search_items' => __('Search Items', 'hello-thedavanigroup'),
			'not_found' => __('Not Found', 'hello-thedavanigroup'),
			'no_terms' => __('No items', 'hello-thedavanigroup'),
			'items_list' => __('Items list', 'hello-thedavanigroup'),
			'items_list_navigation' => __('Items list navigation', 'hello-thedavanigroup'),
		);
		$rewrite = array(
			'slug' => 'stones',
			'with_front' => true,
			'hierarchical' => true,
		);
		$args = array(
			'labels' => $labels,
			'hierarchical' => true,
			'public' => true,
			'show_ui' => true,
			'show_admin_column' => true,
			'show_in_nav_menus' => true,
			'show_tagcloud' => true,
			'rewrite' => $rewrite,
			'show_in_rest' => true,
		);
		register_taxonomy('stones', array('stone-product'), $args);

		
		register_taxonomy('color_tags', 'stone-product', array(
			'hierarchical' => true, 
			'labels' => array(
					'name' => __('Color Tags'),
					'singular_name' => __('Color'),
					'search_items' => __('Search Color Tags'),
					'all_items' => __('All Color Tags'),
					'edit_item' => __('Edit Color Tag'),
					'update_item' => __('Update Color Tag'),
					'add_new_item' => __('Add New Color Tag'),
					'new_item_name' => __('New Color Tag Name'),
					'menu_name' => __('Color Tags'),
			),
			'show_ui' => true,
			'show_admin_column' => true,
			'query_var' => true,
			'rewrite' => array('slug' => 'color-tags'),
		));

		register_taxonomy('material_tags', 'stone-product', array(
			'hierarchical' => true, 
			'labels' => array(
					'name' => __('Material Tags'),
					'singular_name' => __('Material'),
					'search_items' => __('Search Material Tags'),
					'all_items' => __('All Material Tags'),
					'edit_item' => __('Edit Material Tag'),
					'update_item' => __('Update Material Tag'),
					'add_new_item' => __('Add New Material Tag'),
					'new_item_name' => __('New Material Tag Name'),
					'menu_name' => __('Material Tags'),
			),
			'show_ui' => true,
			'show_admin_column' => true,
			'query_var' => true,
			'rewrite' => array('slug' => 'material-tags'),
		));

		register_taxonomy('finish_tags', 'stone-product', array(
			'hierarchical' => true, 
			'labels' => array(
					'name' => __('Finish Tags'),
					'singular_name' => __('Finish'),
					'search_items' => __('Search Finish Tags'),
					'all_items' => __('All Finish Tags'),
					'edit_item' => __('Edit Finish Tag'),
					'update_item' => __('Update Finish Tag'),
					'add_new_item' => __('Add New Finish Tag'),
					'new_item_name' => __('New Finish Tag Name'),
					'menu_name' => __('Finish Tags'),
			),
			'show_ui' => true,
			'show_admin_column' => true,
			'query_var' => true,
			'rewrite' => array('slug' => 'finish-tags'),
		));

	}
	add_action('init', 'custom_taxonomy_stones', 0);
}

if (!function_exists('tdg_custom_post_type_installation')) {

	// Register Custom Post Type Installation Product
	function tdg_custom_post_type_installation()
	{
		$labels = array(
			'name' => _x('Installation', 'Post Type General Name', 'hello-thedavanigroup'),
			'singular_name' => _x('Installation', 'Post Type Singular Name', 'hello-thedavanigroup'),
			'menu_name' => __('Installation', 'hello-thedavanigroup'),
			'name_admin_bar' => __('Installation', 'hello-thedavanigroup'),
			'archives' => __('Item Archives', 'hello-thedavanigroup'),
			'attributes' => __('Item Attributes', 'hello-thedavanigroup'),
			'parent_item_colon' => __('Parent Item:', 'hello-thedavanigroup'),
			'all_items' => __('All Items', 'hello-thedavanigroup'),
			'add_new_item' => __('Add New Item', 'hello-thedavanigroup'),
			'add_new' => __('Add New', 'hello-thedavanigroup'),
			'new_item' => __('New Item', 'hello-thedavanigroup'),
			'edit_item' => __('Edit Item', 'hello-thedavanigroup'),
			'update_item' => __('Update Item', 'hello-thedavanigroup'),
			'view_item' => __('View Item', 'hello-thedavanigroup'),
			'view_items' => __('View Items', 'hello-thedavanigroup'),
			'search_items' => __('Search Item', 'hello-thedavanigroup'),
			'not_found' => __('Not found', 'hello-thedavanigroup'),
			'not_found_in_trash' => __('Not found in Trash', 'hello-thedavanigroup'),
			'featured_image' => __('Featured Image', 'hello-thedavanigroup'),
			'set_featured_image' => __('Set featured image', 'hello-thedavanigroup'),
			'remove_featured_image' => __('Remove featured image', 'hello-thedavanigroup'),
			'use_featured_image' => __('Use as featured image', 'hello-thedavanigroup'),
			'insert_into_item' => __('Insert into item', 'hello-thedavanigroup'),
			'uploaded_to_this_item' => __('Uploaded to this item', 'hello-thedavanigroup'),
			'items_list' => __('Items list', 'hello-thedavanigroup'),
			'items_list_navigation' => __('Items list navigation', 'hello-thedavanigroup'),
			'filter_items_list' => __('Filter items list', 'hello-thedavanigroup'),
		);
		$rewrite = array(
			'slug' => 'installation-product',
			// 'with_front' => true,
		);
		$args = array(
			'label' => __('installation', 'hello-thedavanigroup'),
			'description' => __('Post Type Description', 'hello-thedavanigroup'),
			'labels' => $labels,
			'supports' => array('title', 'editor', 'thumbnail', 'page-attributes', 'custom-fields'),
			'hierarchical' => false,
			'public' => true,
			'publicly_queryable' => true,
			'show_ui' => true,
			'query_var' => true,
			'show_in_menu' => true,
			'menu_position' => 5,
			'menu_icon' => 'dashicons-archive',
			'show_in_admin_bar' => true,
			'show_in_nav_menus' => true,
			'can_export' => true,
			'has_archive' => 'installation',
			'exclude_from_search' => false,
			'rewrite' => $rewrite, //$rewrite,
			'capability_type' => 'post',
			'show_in_rest' => true,
		);
		register_post_type('installation-product', $args);
	}
	add_action('init', 'tdg_custom_post_type_installation', 0);
}

if (!function_exists('custom_taxonomy_installation')) {

	// Register Taxonomy Installation
	function custom_taxonomy_installation()
	{
		$labels = array(
			'name' => _x('Category Installation', 'Taxonomy General Name', 'hello-thedavanigroup'),
			'singular_name' => _x('Category', 'Taxonomy Singular Name', 'hello-thedavanigroup'),
			'menu_name' => __('Category', 'hello-thedavanigroup'),
			'all_items' => __('All Items', 'hello-thedavanigroup'),
			'parent_item' => __('Parent Item', 'hello-thedavanigroup'),
			'parent_item_colon' => __('Parent Item:', 'hello-thedavanigroup'),
			'new_item_name' => __('New Item Name', 'hello-thedavanigroup'),
			'add_new_item' => __('Add New Item', 'hello-thedavanigroup'),
			'edit_item' => __('Edit Item', 'hello-thedavanigroup'),
			'update_item' => __('Update Item', 'hello-thedavanigroup'),
			'view_item' => __('View Item', 'hello-thedavanigroup'),
			'separate_items_with_commas' => __('Separate items with commas', 'hello-thedavanigroup'),
			'add_or_remove_items' => __('Add or remove items', 'hello-thedavanigroup'),
			'choose_from_most_used' => __('Choose from the most used', 'hello-thedavanigroup'),
			'popular_items' => __('Popular Items', 'hello-thedavanigroup'),
			'search_items' => __('Search Items', 'hello-thedavanigroup'),
			'not_found' => __('Not Found', 'hello-thedavanigroup'),
			'no_terms' => __('No items', 'hello-thedavanigroup'),
			'items_list' => __('Items list', 'hello-thedavanigroup'),
			'items_list_navigation' => __('Items list navigation', 'hello-thedavanigroup'),
		);
		$rewrite = array(
			'slug' => 'installation',
			'with_front' => true,
			'hierarchical' => true,
		);
		$args = array(
			'labels' => $labels,
			'hierarchical' => true,
			'public' => true,
			'show_ui' => true,
			'show_admin_column' => true,
			'show_in_nav_menus' => true,
			'show_tagcloud' => true,
			'rewrite' => $rewrite,
			'show_in_rest' => true,
		);
		register_taxonomy('installation', array('installation-product'), $args);

	}
	add_action('init', 'custom_taxonomy_installation', 0);
}

if (!function_exists('tdg_custom_post_type_architect_stone')) {

	// Register Custom Post Type Architect Stone
	function tdg_custom_post_type_architect_stone()
	{
		$labels = array(
			'name' => _x('Architect Stone', 'Post Type General Name', 'hello-thedavanigroup'),
			'singular_name' => _x('Architect Stone', 'Post Type Singular Name', 'hello-thedavanigroup'),
			'menu_name' => __('Architect Stone', 'hello-thedavanigroup'),
			'name_admin_bar' => __('Architect Stone', 'hello-thedavanigroup'),
			'archives' => __('Item Archives', 'hello-thedavanigroup'),
			'attributes' => __('Item Attributes', 'hello-thedavanigroup'),
			'parent_item_colon' => __('Parent Item:', 'hello-thedavanigroup'),
			'all_items' => __('All Items', 'hello-thedavanigroup'),
			'add_new_item' => __('Add New Item', 'hello-thedavanigroup'),
			'add_new' => __('Add New', 'hello-thedavanigroup'),
			'new_item' => __('New Item', 'hello-thedavanigroup'),
			'edit_item' => __('Edit Item', 'hello-thedavanigroup'),
			'update_item' => __('Update Item', 'hello-thedavanigroup'),
			'view_item' => __('View Item', 'hello-thedavanigroup'),
			'view_items' => __('View Items', 'hello-thedavanigroup'),
			'search_items' => __('Search Item', 'hello-thedavanigroup'),
			'not_found' => __('Not found', 'hello-thedavanigroup'),
			'not_found_in_trash' => __('Not found in Trash', 'hello-thedavanigroup'),
			'featured_image' => __('Featured Image', 'hello-thedavanigroup'),
			'set_featured_image' => __('Set featured image', 'hello-thedavanigroup'),
			'remove_featured_image' => __('Remove featured image', 'hello-thedavanigroup'),
			'use_featured_image' => __('Use as featured image', 'hello-thedavanigroup'),
			'insert_into_item' => __('Insert into item', 'hello-thedavanigroup'),
			'uploaded_to_this_item' => __('Uploaded to this item', 'hello-thedavanigroup'),
			'items_list' => __('Items list', 'hello-thedavanigroup'),
			'items_list_navigation' => __('Items list navigation', 'hello-thedavanigroup'),
			'filter_items_list' => __('Filter items list', 'hello-thedavanigroup'),
		);
		$rewrite = array(
			'slug' => 'architect-stone-product',
			// 'with_front' => true,
		);
		$args = array(
			'label' => __('Architect Stone', 'hello-thedavanigroup'),
			'description' => __('Post Type Description', 'hello-thedavanigroup'),
			'labels' => $labels,
			'supports' => array('title', 'editor', 'thumbnail', 'page-attributes', 'custom-fields'),
			'hierarchical' => false,
			'public' => true,
			'publicly_queryable' => true,
			'show_ui' => true,
			'query_var' => true,
			'show_in_menu' => true,
			'menu_position' => 5,
			'menu_icon' => 'dashicons-archive',
			'show_in_admin_bar' => true,
			'show_in_nav_menus' => true,
			'can_export' => true,
			'has_archive' => false,
			'exclude_from_search' => false,
			'rewrite' => $rewrite, //$rewrite,
			'capability_type' => 'post',
			'show_in_rest' => true,
		);
		register_post_type('architect-stones', $args);
	}
	add_action('init', 'tdg_custom_post_type_architect_stone', 0);
}

if (!function_exists('custom_taxonomy_architect_stone')) {

	// Register Taxonomy For Architect Stone
	function custom_taxonomy_architect_stone()
	{
		$labels = array(
			'name' => _x('Category Architect Stone', 'Taxonomy General Name', 'hello-thedavanigroup'),
			'singular_name' => _x('Category', 'Taxonomy Singular Name', 'hello-thedavanigroup'),
			'menu_name' => __('Category', 'hello-thedavanigroup'),
			'all_items' => __('All Items', 'hello-thedavanigroup'),
			'parent_item' => __('Parent Item', 'hello-thedavanigroup'),
			'parent_item_colon' => __('Parent Item:', 'hello-thedavanigroup'),
			'new_item_name' => __('New Item Name', 'hello-thedavanigroup'),
			'add_new_item' => __('Add New Item', 'hello-thedavanigroup'),
			'edit_item' => __('Edit Item', 'hello-thedavanigroup'),
			'update_item' => __('Update Item', 'hello-thedavanigroup'),
			'view_item' => __('View Item', 'hello-thedavanigroup'),
			'separate_items_with_commas' => __('Separate items with commas', 'hello-thedavanigroup'),
			'add_or_remove_items' => __('Add or remove items', 'hello-thedavanigroup'),
			'choose_from_most_used' => __('Choose from the most used', 'hello-thedavanigroup'),
			'popular_items' => __('Popular Items', 'hello-thedavanigroup'),
			'search_items' => __('Search Items', 'hello-thedavanigroup'),
			'not_found' => __('Not Found', 'hello-thedavanigroup'),
			'no_terms' => __('No items', 'hello-thedavanigroup'),
			'items_list' => __('Items list', 'hello-thedavanigroup'),
			'items_list_navigation' => __('Items list navigation', 'hello-thedavanigroup'),
		);
		$rewrite = array(
			'slug' => 'architect-stone',
			'with_front' => true,
			'hierarchical' => true,
		);
		$args = array(
			'labels' => $labels,
			'hierarchical' => true,
			'public' => true,
			'show_ui' => true,
			'show_admin_column' => true,
			'show_in_nav_menus' => true,
			'show_tagcloud' => true,
			'rewrite' => $rewrite,
			'show_in_rest' => true,
		);
		register_taxonomy('architect-stone-cat', array('architect-stones'), $args);

	}
	add_action('init', 'custom_taxonomy_architect_stone', 0);
}


////////////////////////////

if (!function_exists('tdg_custom_post_type_locations')) {

	// Register Custom Post Type Locations Product
	function tdg_custom_post_type_locations()
	{
		$labels = array(
			'name' => _x('Locations', 'Post Type General Name', 'hello-thedavanigroup'),
			'singular_name' => _x('Locations', 'Post Type Singular Name', 'hello-thedavanigroup'),
			'menu_name' => __('Locations', 'hello-thedavanigroup'),
			'name_admin_bar' => __('Locations', 'hello-thedavanigroup'),
			'archives' => __('Item Archives', 'hello-thedavanigroup'),
			'attributes' => __('Item Attributes', 'hello-thedavanigroup'),
			'parent_item_colon' => __('Parent Item:', 'hello-thedavanigroup'),
			'all_items' => __('All Items', 'hello-thedavanigroup'),
			'add_new_item' => __('Add New Item', 'hello-thedavanigroup'),
			'add_new' => __('Add New', 'hello-thedavanigroup'),
			'new_item' => __('New Item', 'hello-thedavanigroup'),
			'edit_item' => __('Edit Item', 'hello-thedavanigroup'),
			'update_item' => __('Update Item', 'hello-thedavanigroup'),
			'view_item' => __('View Item', 'hello-thedavanigroup'),
			'view_items' => __('View Items', 'hello-thedavanigroup'),
			'search_items' => __('Search Item', 'hello-thedavanigroup'),
			'not_found' => __('Not found', 'hello-thedavanigroup'),
			'not_found_in_trash' => __('Not found in Trash', 'hello-thedavanigroup'),
			'featured_image' => __('Featured Image', 'hello-thedavanigroup'),
			'set_featured_image' => __('Set featured image', 'hello-thedavanigroup'),
			'remove_featured_image' => __('Remove featured image', 'hello-thedavanigroup'),
			'use_featured_image' => __('Use as featured image', 'hello-thedavanigroup'),
			'insert_into_item' => __('Insert into item', 'hello-thedavanigroup'),
			'uploaded_to_this_item' => __('Uploaded to this item', 'hello-thedavanigroup'),
			'items_list' => __('Items list', 'hello-thedavanigroup'),
			'items_list_navigation' => __('Items list navigation', 'hello-thedavanigroup'),
			'filter_items_list' => __('Filter items list', 'hello-thedavanigroup'),
		);
		$rewrite = array(
			'slug' => 'location-product',
			// 'with_front' => true,
		);
		$args = array(
			'label' => __('Locations', 'hello-thedavanigroup'),
			'description' => __('Post Type Description', 'hello-thedavanigroup'),
			'labels' => $labels,
			'supports' => array('title', 'editor', 'thumbnail', 'page-attributes', 'custom-fields'),
			'hierarchical' => false,
			'public' => true,
			'publicly_queryable' => true,
			'show_ui' => true,
			'query_var' => true,
			'show_in_menu' => true,
			'menu_position' => 5,
			'menu_icon' => 'dashicons-archive',
			'show_in_admin_bar' => true,
			'show_in_nav_menus' => true,
			'can_export' => true,
			'has_archive' => 'locations',
			'exclude_from_search' => false,
			'rewrite' => $rewrite, //$rewrite,
			'capability_type' => 'post',
			'show_in_rest' => true,
		);
		register_post_type('location-product', $args);
	}
	add_action('init', 'tdg_custom_post_type_locations', 0);
}

if (!function_exists('custom_taxonomy_locations')) {

	// Register Taxonomy Locations
	function custom_taxonomy_locations()
	{
		$labels = array(
			'name' => _x('Category Locations', 'Taxonomy General Name', 'hello-thedavanigroup'),
			'singular_name' => _x('Category', 'Taxonomy Singular Name', 'hello-thedavanigroup'),
			'menu_name' => __('Category', 'hello-thedavanigroup'),
			'all_items' => __('All Items', 'hello-thedavanigroup'),
			'parent_item' => __('Parent Item', 'hello-thedavanigroup'),
			'parent_item_colon' => __('Parent Item:', 'hello-thedavanigroup'),
			'new_item_name' => __('New Item Name', 'hello-thedavanigroup'),
			'add_new_item' => __('Add New Item', 'hello-thedavanigroup'),
			'edit_item' => __('Edit Item', 'hello-thedavanigroup'),
			'update_item' => __('Update Item', 'hello-thedavanigroup'),
			'view_item' => __('View Item', 'hello-thedavanigroup'),
			'separate_items_with_commas' => __('Separate items with commas', 'hello-thedavanigroup'),
			'add_or_remove_items' => __('Add or remove items', 'hello-thedavanigroup'),
			'choose_from_most_used' => __('Choose from the most used', 'hello-thedavanigroup'),
			'popular_items' => __('Popular Items', 'hello-thedavanigroup'),
			'search_items' => __('Search Items', 'hello-thedavanigroup'),
			'not_found' => __('Not Found', 'hello-thedavanigroup'),
			'no_terms' => __('No items', 'hello-thedavanigroup'),
			'items_list' => __('Items list', 'hello-thedavanigroup'),
			'items_list_navigation' => __('Items list navigation', 'hello-thedavanigroup'),
		);
		$rewrite = array(
			'slug' => 'locations',
			'with_front' => true,
			'hierarchical' => true,
		);
		$args = array(
			'labels' => $labels,
			'hierarchical' => true,
			'public' => true,
			'show_ui' => true,
			'show_admin_column' => true,
			'show_in_nav_menus' => true,
			'show_tagcloud' => true,
			'rewrite' => $rewrite,
			'show_in_rest' => true,
		);
		register_taxonomy('locations', array('location-product'), $args);

	}
	add_action('init', 'custom_taxonomy_locations', 0);
}

////////////////////////////

add_action('init', 'tdg_custom_url_taxonomy_rewrite');
function tdg_custom_url_taxonomy_rewrite()
{
	add_rewrite_rule(
		'custom-product/([^/]+)/([^/]+)/?$',
		'index.php?custom-fabrication=$matches[2]',
		'top'
	);

	// Parent taxonomy archive rewrite rule
	add_rewrite_rule(
		'fabrication-services/([^/]+)/?$',
		'index.php?custom-fabric-cat=$matches[1]',
		'top'
	);

	// Child taxonomy archive rewrite rule
	add_rewrite_rule(
		'fabrication-services/([^/]+)/([^/]+)/?$',
		'index.php?custom-fabric-cat=$matches[2]',
		'top'
	);

	add_rewrite_rule(
        'blogs/([^/]+)/?$',
        'index.php?name=$matches[1]',
        'top'
    );
}

function custom_post_link_function($post_link, $post){

	if ($post->post_type === 'post') {
        return home_url('/blogs/' . $post->post_name . '/');
    }

	return $post_link;
}
add_filter('post_link', 'custom_post_link_function', 10, 2);

function custom_post_type_link_function($post_link, $post)
{
	if ($post->post_type === 'custom-fabrication') {
		$terms = wp_get_object_terms($post->ID, 'custom-fabric-cat');
		if (!is_wp_error($terms) && !empty($terms)) {

			$parent_term = '';
            $child_term = '';

			foreach ($terms as $term) {
				if ($term->parent == 0) {
					$parent_term = $term->slug;
				} else {
					$child_term = $term->slug;
				}
			}

			if ($parent_term && $child_term) {
				return home_url("custom-product/{$child_term}/{$post->post_name}/");
			}elseif( $parent_term && !$child_term ){
				return home_url("custom-product/{$parent_term}/{$post->post_name}/");
			}

		}
	}

	return $post_link;
}
add_filter('post_type_link', 'custom_post_type_link_function', 10, 2);

function custom_fabric_term_link($termlink, $term, $taxonomy)
{
	if ($taxonomy === 'custom-fabric-cat') {
		if ($term->parent == 0) {
			return home_url("fabrication-services/{$term->slug}/");
		} else {
			$parent_term = get_term($term->parent, 'custom-fabric-cat');
			return home_url("fabrication-services/{$parent_term->slug}/{$term->slug}/");
		}
	}
	return $termlink;
}
add_filter('term_link', 'custom_fabric_term_link', 10, 3);