@@ 762-779 (lines=18) @@ | ||
759 | $terms = false; |
|
760 | if(isset($data[0]['position'])){ |
|
761 | $country_id = 0; |
|
762 | if(isset($data[0]['position']['country'])){ |
|
763 | ||
764 | if(!$term = term_exists(trim($data[0]['position']['country']), 'location')) |
|
765 | { |
|
766 | $term = wp_insert_term(trim($data[0]['position']['country']), 'location'); |
|
767 | if ( is_wp_error($term) ){ |
|
768 | echo $term->get_error_message(); |
|
769 | } |
|
770 | else { |
|
771 | wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
772 | } |
|
773 | } |
|
774 | else |
|
775 | { |
|
776 | wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
777 | } |
|
778 | $country_id = intval($term['term_id']); |
|
779 | } |
|
780 | ||
781 | if(isset($data[0]['position']['destination'])){ |
|
782 | ||
@@ 781-794 (lines=14) @@ | ||
778 | $country_id = intval($term['term_id']); |
|
779 | } |
|
780 | ||
781 | if(isset($data[0]['position']['destination'])){ |
|
782 | ||
783 | $tax_args = array('parent'=>$country_id); |
|
784 | if(!$term = term_exists(trim($data[0]['position']['destination']), 'location')) |
|
785 | { |
|
786 | $term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args); |
|
787 | if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
788 | else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); } |
|
789 | } |
|
790 | else |
|
791 | { |
|
792 | wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
793 | } |
|
794 | } |
|
795 | } |
|
796 | } |
|
797 |