<?php
 	$product_categories = get_categories('taxonomy=product_cat&type=product&hide_empty=0');
	$cat_array=array();
	$cat_count=0;
 	if( !empty($product_categories) ){
		foreach ($product_categories as $category) {
		$cat_count++;
  		$cat_array[] = array(
						'slug' => $category->slug,
						'parent' => 0,
						'title' => $category->name,
						'url' => get_term_link($category)
				);
	
			if($cat_count==10){
				break;
			}

		} 
		
	}
	
	$cat_menu_name  = 'دسته بندی محصولات';
	$cat_menu = get_term_by( 'slug', $cat_menu_name, 'nav_menu' );
	if(empty($cat_menu)){
		$cat_menu_id = wp_create_nav_menu($cat_menu_name);
		$cat_menu=array(array(
					'location' => false,
					'name' => $cat_menu_name,
					'slug' => 'cat_menu',
					'items' => $cat_array,
					),
		);
			
		bazinewsdemoimport_menu_import_json($cat_menu);
			
		 
		echo $cat_menu_name .' ساخته شد <br>';
	
	}else{
			echo $cat_menu_name .' قبلا وجود داشت <br>';
	}
	 
 	$locations['bazinews_category_menu'] =  wp_get_nav_menu_object(  'دسته بندی محصولات' )->term_id;
