| @@ 793-810 (lines=18) @@ | ||
| 790 | $terms = false; | |
| 791 | 		if(isset($data[0]['position'])){ | |
| 792 | $country_id = 0; | |
| 793 | 			if(isset($data[0]['position']['country'])){ | |
| 794 | ||
| 795 | if(!$term = term_exists(trim($data[0]['position']['country']), 'location')) | |
| 796 | 		        { | |
| 797 | $term = wp_insert_term(trim($data[0]['position']['country']), 'location'); | |
| 798 | 		            if ( is_wp_error($term) ){ | |
| 799 | echo $term->get_error_message(); | |
| 800 | } | |
| 801 | 		            else { | |
| 802 | wp_set_object_terms( $id, intval($term['term_id']), 'location',true); | |
| 803 | } | |
| 804 | } | |
| 805 | else | |
| 806 | 		        { | |
| 807 | wp_set_object_terms( $id, intval($term['term_id']), 'location',true); | |
| 808 | } | |
| 809 | $country_id = intval($term['term_id']); | |
| 810 | } | |
| 811 | ||
| 812 | 			if(isset($data[0]['position']['destination'])){ | |
| 813 | ||
| @@ 812-825 (lines=14) @@ | ||
| 809 | $country_id = intval($term['term_id']); | |
| 810 | } | |
| 811 | ||
| 812 | 			if(isset($data[0]['position']['destination'])){ | |
| 813 | ||
| 814 | 				$tax_args = array('parent'=>$country_id); | |
| 815 | if(!$term = term_exists(trim($data[0]['position']['destination']), 'location')) | |
| 816 | 		        { | |
| 817 | $term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args); | |
| 818 | 		            if ( is_wp_error($term) ){echo $term->get_error_message();} | |
| 819 | 		            else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); } | |
| 820 | } | |
| 821 | else | |
| 822 | 		        { | |
| 823 | wp_set_object_terms( $id, intval($term['term_id']), 'location',true); | |
| 824 | } | |
| 825 | } | |
| 826 | } | |
| 827 | } | |
| 828 | ||