@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * Display the importer administration screen |
137 | 137 | */ |
138 | 138 | public function display_page() { |
139 | - ?> |
|
139 | + ?> |
|
140 | 140 | <div class="wrap"> |
141 | 141 | <?php $this->navigation('accommodation'); ?> |
142 | 142 | |
@@ -315,8 +315,8 @@ discard block |
||
315 | 315 | $accommodation = json_decode($data, true); |
316 | 316 | |
317 | 317 | if(isset($accommodation['error'])){ |
318 | - return $accommodation['error']; |
|
319 | - }elseif (isset($accommodation) && !empty($accommodation)) { |
|
318 | + return $accommodation['error']; |
|
319 | + }elseif (isset($accommodation) && !empty($accommodation)) { |
|
320 | 320 | set_transient('lsx_ti_accommodation',$accommodation,60*60*2); |
321 | 321 | return true; |
322 | 322 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | $keyphrases = $_POST['keyword']; |
365 | 365 | }else{ |
366 | 366 | $keyphrases = array(0); |
367 | - } |
|
367 | + } |
|
368 | 368 | |
369 | 369 | if(!is_array($keyphrases)){ |
370 | 370 | $keyphrases = array($keyphrases); |
@@ -461,13 +461,13 @@ discard block |
||
461 | 461 | public function multineedle_stripos($haystack, $needles, $offset=0) { |
462 | 462 | $found = false; |
463 | 463 | $needle_count = count($needles); |
464 | - foreach($needles as $needle) { |
|
465 | - if(false !== stripos($haystack, $needle, $offset)){ |
|
466 | - $found[] = true; |
|
467 | - } |
|
468 | - } |
|
469 | - if(false !== $found && $needle_count === count($found)){ |
|
470 | - return true; |
|
464 | + foreach($needles as $needle) { |
|
465 | + if(false !== stripos($haystack, $needle, $offset)){ |
|
466 | + $found[] = true; |
|
467 | + } |
|
468 | + } |
|
469 | + if(false !== $found && $needle_count === count($found)){ |
|
470 | + return true; |
|
471 | 471 | }else{ |
472 | 472 | return false; |
473 | 473 | } |
@@ -538,16 +538,16 @@ discard block |
||
538 | 538 | $content = false; |
539 | 539 | } |
540 | 540 | |
541 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
542 | - if($jdata) |
|
543 | - { |
|
544 | - $adata=json_decode($jdata,true); |
|
545 | - if(!empty($adata)) |
|
546 | - { |
|
547 | - $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
548 | - $this->format_completed_row($return); |
|
549 | - } |
|
550 | - } |
|
541 | + $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
542 | + if($jdata) |
|
543 | + { |
|
544 | + $adata=json_decode($jdata,true); |
|
545 | + if(!empty($adata)) |
|
546 | + { |
|
547 | + $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
548 | + $this->format_completed_row($return); |
|
549 | + } |
|
550 | + } |
|
551 | 551 | |
552 | 552 | die(); |
553 | 553 | } |
@@ -564,148 +564,148 @@ discard block |
||
564 | 564 | */ |
565 | 565 | public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) { |
566 | 566 | |
567 | - if(trim($data[0]['type'])=='Accommodation') |
|
568 | - { |
|
569 | - $post_name = $data_post_content = $data_post_excerpt = ''; |
|
570 | - $post = array( |
|
571 | - 'post_type' => 'accommodation', |
|
572 | - ); |
|
573 | - |
|
574 | - $content_used_general_description = false; |
|
575 | - |
|
576 | - //Set the post_content |
|
577 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
578 | - if(isset($data[0]['content']['extended_description'])) |
|
579 | - { |
|
580 | - $data_post_content = $data[0]['content']['extended_description']; |
|
581 | - }elseif(isset($data[0]['content']['general_description'])){ |
|
582 | - $data_post_content = $data[0]['content']['general_description']; |
|
583 | - $content_used_general_description = true; |
|
584 | - }elseif(isset($data[0]['content']['teaser_description'])){ |
|
585 | - $data_post_content = $data[0]['content']['teaser_description']; |
|
586 | - } |
|
587 | - $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
588 | - } |
|
589 | - |
|
590 | - //set the post_excerpt |
|
591 | - if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
592 | - if(isset($data[0]['content']['teaser_description'])){ |
|
593 | - $data_post_excerpt = $data[0]['content']['teaser_description']; |
|
594 | - }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
595 | - $data_post_excerpt = $data[0]['content']['general_description']; |
|
596 | - } |
|
597 | - $post['post_excerpt'] = $data_post_excerpt; |
|
598 | - } |
|
599 | - |
|
600 | - if(false !== $id && '0' !== $id){ |
|
601 | - $post['ID'] = $id; |
|
567 | + if(trim($data[0]['type'])=='Accommodation') |
|
568 | + { |
|
569 | + $post_name = $data_post_content = $data_post_excerpt = ''; |
|
570 | + $post = array( |
|
571 | + 'post_type' => 'accommodation', |
|
572 | + ); |
|
573 | + |
|
574 | + $content_used_general_description = false; |
|
575 | + |
|
576 | + //Set the post_content |
|
577 | + if(false !== $importable_content && in_array('description',$importable_content)){ |
|
578 | + if(isset($data[0]['content']['extended_description'])) |
|
579 | + { |
|
580 | + $data_post_content = $data[0]['content']['extended_description']; |
|
581 | + }elseif(isset($data[0]['content']['general_description'])){ |
|
582 | + $data_post_content = $data[0]['content']['general_description']; |
|
583 | + $content_used_general_description = true; |
|
584 | + }elseif(isset($data[0]['content']['teaser_description'])){ |
|
585 | + $data_post_content = $data[0]['content']['teaser_description']; |
|
586 | + } |
|
587 | + $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
588 | + } |
|
589 | + |
|
590 | + //set the post_excerpt |
|
591 | + if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
592 | + if(isset($data[0]['content']['teaser_description'])){ |
|
593 | + $data_post_excerpt = $data[0]['content']['teaser_description']; |
|
594 | + }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
595 | + $data_post_excerpt = $data[0]['content']['general_description']; |
|
596 | + } |
|
597 | + $post['post_excerpt'] = $data_post_excerpt; |
|
598 | + } |
|
599 | + |
|
600 | + if(false !== $id && '0' !== $id){ |
|
601 | + $post['ID'] = $id; |
|
602 | 602 | if(isset($data[0]['name'])){ |
603 | 603 | $post['post_title'] = $data[0]['name']; |
604 | - $post['post_status'] = 'publish'; |
|
604 | + $post['post_status'] = 'publish'; |
|
605 | 605 | $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
606 | 606 | } |
607 | - $id = wp_update_post($post); |
|
608 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
609 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
610 | - }else{ |
|
611 | - |
|
612 | - //Set the name |
|
613 | - if(isset($data[0]['name'])){ |
|
614 | - $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
615 | - } |
|
616 | - $post['post_name'] = $post_name; |
|
617 | - $post['post_title'] = $data[0]['name']; |
|
618 | - $post['post_status'] = 'publish'; |
|
619 | - $id = wp_insert_post($post); |
|
620 | - |
|
621 | - //Save the WETU ID and the Last date it was modified. |
|
622 | - if(false !== $id){ |
|
623 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
624 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
625 | - } |
|
626 | - } |
|
627 | - //Setup some default for use in the import |
|
628 | - if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
|
607 | + $id = wp_update_post($post); |
|
608 | + $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
609 | + update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
610 | + }else{ |
|
611 | + |
|
612 | + //Set the name |
|
613 | + if(isset($data[0]['name'])){ |
|
614 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
615 | + } |
|
616 | + $post['post_name'] = $post_name; |
|
617 | + $post['post_title'] = $data[0]['name']; |
|
618 | + $post['post_status'] = 'publish'; |
|
619 | + $id = wp_insert_post($post); |
|
620 | + |
|
621 | + //Save the WETU ID and the Last date it was modified. |
|
622 | + if(false !== $id){ |
|
623 | + add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
624 | + add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
625 | + } |
|
626 | + } |
|
627 | + //Setup some default for use in the import |
|
628 | + if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
|
629 | 629 | $this->find_attachments($id); |
630 | 630 | } |
631 | 631 | |
632 | - //Set the team member if it is there |
|
633 | - if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
634 | - $this->set_team_member($id,$team_members); |
|
635 | - } |
|
636 | - |
|
637 | - //Set the safari brand |
|
638 | - if(false !== $safari_brands && '' !== $safari_brands){ |
|
639 | - $this->set_safari_brands($id,$safari_brands); |
|
640 | - |
|
641 | - } |
|
642 | - |
|
643 | - if(class_exists('LSX_TO_Maps')){ |
|
644 | - $this->set_map_data($data,$id,9); |
|
645 | - $this->set_location_taxonomy($data,$id); |
|
646 | - } |
|
647 | - |
|
648 | - if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){ |
|
649 | - $this->connect_destinations($data,$id); |
|
650 | - } |
|
651 | - |
|
652 | - if(false !== $importable_content && in_array('category',$importable_content)){ |
|
653 | - $this->set_taxonomy_style($data,$id); |
|
654 | - } |
|
655 | - |
|
656 | - //Set the Room Data |
|
657 | - if(false !== $importable_content && in_array('rooms',$importable_content)){ |
|
658 | - $this->set_room_data($data,$id); |
|
659 | - } |
|
660 | - |
|
661 | - //Set the rating |
|
662 | - if(false !== $importable_content && in_array('rating',$importable_content)){ |
|
663 | - $this->set_rating($data,$id); |
|
664 | - } |
|
665 | - |
|
666 | - //Set the checkin checkout data |
|
667 | - if(false !== $importable_content && in_array('checkin',$importable_content)){ |
|
668 | - $this->set_checkin_checkout($data,$id); |
|
669 | - } |
|
670 | - |
|
671 | - //Set the Spoken Languages |
|
672 | - if(false !== $importable_content && in_array('spoken_languages',$importable_content)){ |
|
673 | - $this->set_spoken_languages($data,$id); |
|
674 | - } |
|
675 | - |
|
676 | - //Set the friendly options |
|
677 | - if(false !== $importable_content && in_array('friendly',$importable_content)){ |
|
678 | - $this->set_friendly($data,$id); |
|
679 | - } |
|
680 | - |
|
681 | - //Set the special_interests |
|
682 | - if(false !== $importable_content && in_array('special_interests',$importable_content)){ |
|
683 | - $this->set_special_interests($data,$id); |
|
684 | - } |
|
685 | - |
|
686 | - //Import the videos |
|
687 | - if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
688 | - $this->set_video_data($data,$id); |
|
689 | - } |
|
690 | - |
|
691 | - //Import the facilities |
|
692 | - if(false !== $importable_content && in_array('facilities',$importable_content)){ |
|
693 | - $this->set_facilities($data,$id); |
|
694 | - } |
|
695 | - |
|
696 | - //Set the featured image |
|
697 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
698 | - $this->set_featured_image($data,$id); |
|
699 | - } |
|
700 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
701 | - $this->set_banner_image($data,$id); |
|
702 | - } |
|
703 | - //Import the main gallery |
|
704 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
705 | - $this->create_main_gallery($data,$id); |
|
706 | - } |
|
707 | - } |
|
708 | - return $id; |
|
632 | + //Set the team member if it is there |
|
633 | + if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
634 | + $this->set_team_member($id,$team_members); |
|
635 | + } |
|
636 | + |
|
637 | + //Set the safari brand |
|
638 | + if(false !== $safari_brands && '' !== $safari_brands){ |
|
639 | + $this->set_safari_brands($id,$safari_brands); |
|
640 | + |
|
641 | + } |
|
642 | + |
|
643 | + if(class_exists('LSX_TO_Maps')){ |
|
644 | + $this->set_map_data($data,$id,9); |
|
645 | + $this->set_location_taxonomy($data,$id); |
|
646 | + } |
|
647 | + |
|
648 | + if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){ |
|
649 | + $this->connect_destinations($data,$id); |
|
650 | + } |
|
651 | + |
|
652 | + if(false !== $importable_content && in_array('category',$importable_content)){ |
|
653 | + $this->set_taxonomy_style($data,$id); |
|
654 | + } |
|
655 | + |
|
656 | + //Set the Room Data |
|
657 | + if(false !== $importable_content && in_array('rooms',$importable_content)){ |
|
658 | + $this->set_room_data($data,$id); |
|
659 | + } |
|
660 | + |
|
661 | + //Set the rating |
|
662 | + if(false !== $importable_content && in_array('rating',$importable_content)){ |
|
663 | + $this->set_rating($data,$id); |
|
664 | + } |
|
665 | + |
|
666 | + //Set the checkin checkout data |
|
667 | + if(false !== $importable_content && in_array('checkin',$importable_content)){ |
|
668 | + $this->set_checkin_checkout($data,$id); |
|
669 | + } |
|
670 | + |
|
671 | + //Set the Spoken Languages |
|
672 | + if(false !== $importable_content && in_array('spoken_languages',$importable_content)){ |
|
673 | + $this->set_spoken_languages($data,$id); |
|
674 | + } |
|
675 | + |
|
676 | + //Set the friendly options |
|
677 | + if(false !== $importable_content && in_array('friendly',$importable_content)){ |
|
678 | + $this->set_friendly($data,$id); |
|
679 | + } |
|
680 | + |
|
681 | + //Set the special_interests |
|
682 | + if(false !== $importable_content && in_array('special_interests',$importable_content)){ |
|
683 | + $this->set_special_interests($data,$id); |
|
684 | + } |
|
685 | + |
|
686 | + //Import the videos |
|
687 | + if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
688 | + $this->set_video_data($data,$id); |
|
689 | + } |
|
690 | + |
|
691 | + //Import the facilities |
|
692 | + if(false !== $importable_content && in_array('facilities',$importable_content)){ |
|
693 | + $this->set_facilities($data,$id); |
|
694 | + } |
|
695 | + |
|
696 | + //Set the featured image |
|
697 | + if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
698 | + $this->set_featured_image($data,$id); |
|
699 | + } |
|
700 | + if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
701 | + $this->set_banner_image($data,$id); |
|
702 | + } |
|
703 | + //Import the main gallery |
|
704 | + if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
705 | + $this->create_main_gallery($data,$id); |
|
706 | + } |
|
707 | + } |
|
708 | + return $id; |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | /** |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | |
716 | 716 | delete_post_meta($id, 'team_to_'.$this->tab_slug); |
717 | 717 | foreach($team_members as $team){ |
718 | - add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
718 | + add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
719 | 719 | } |
720 | 720 | } |
721 | 721 | |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | */ |
725 | 725 | public function set_safari_brands($id,$safari_brands) { |
726 | 726 | foreach($safari_brands as $safari_brand){ |
727 | - wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true); |
|
727 | + wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true); |
|
728 | 728 | } |
729 | 729 | } |
730 | 730 | |
@@ -774,11 +774,11 @@ discard block |
||
774 | 774 | 'elevation' => '', |
775 | 775 | ); |
776 | 776 | if(false !== $id && '0' !== $id){ |
777 | - $prev = get_post_meta($id,'location',true); |
|
778 | - update_post_meta($id,'location',$location_data,$prev); |
|
779 | - }else{ |
|
780 | - add_post_meta($id,'location',$location_data,true); |
|
781 | - } |
|
777 | + $prev = get_post_meta($id,'location',true); |
|
778 | + update_post_meta($id,'location',$location_data,$prev); |
|
779 | + }else{ |
|
780 | + add_post_meta($id,'location',$location_data,true); |
|
781 | + } |
|
782 | 782 | } |
783 | 783 | } |
784 | 784 | /** |
@@ -792,35 +792,35 @@ discard block |
||
792 | 792 | if(isset($data[0]['position']['country'])){ |
793 | 793 | |
794 | 794 | if(!$term = term_exists(trim($data[0]['position']['country']), 'location')) |
795 | - { |
|
796 | - $term = wp_insert_term(trim($data[0]['position']['country']), 'location'); |
|
797 | - if ( is_wp_error($term) ){ |
|
798 | - echo $term->get_error_message(); |
|
799 | - } |
|
800 | - else { |
|
801 | - wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
802 | - } |
|
803 | - } |
|
804 | - else |
|
805 | - { |
|
806 | - wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
807 | - } |
|
808 | - $country_id = intval($term['term_id']); |
|
809 | - } |
|
795 | + { |
|
796 | + $term = wp_insert_term(trim($data[0]['position']['country']), 'location'); |
|
797 | + if ( is_wp_error($term) ){ |
|
798 | + echo $term->get_error_message(); |
|
799 | + } |
|
800 | + else { |
|
801 | + wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
802 | + } |
|
803 | + } |
|
804 | + else |
|
805 | + { |
|
806 | + wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
807 | + } |
|
808 | + $country_id = intval($term['term_id']); |
|
809 | + } |
|
810 | 810 | |
811 | 811 | if(isset($data[0]['position']['destination'])){ |
812 | 812 | |
813 | 813 | $tax_args = array('parent'=>$country_id); |
814 | 814 | if(!$term = term_exists(trim($data[0]['position']['destination']), 'location')) |
815 | - { |
|
816 | - $term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args); |
|
817 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
818 | - else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); } |
|
819 | - } |
|
820 | - else |
|
821 | - { |
|
822 | - wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
823 | - } |
|
815 | + { |
|
816 | + $term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args); |
|
817 | + if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
818 | + else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); } |
|
819 | + } |
|
820 | + else |
|
821 | + { |
|
822 | + wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
823 | + } |
|
824 | 824 | } |
825 | 825 | } |
826 | 826 | } |
@@ -830,31 +830,31 @@ discard block |
||
830 | 830 | */ |
831 | 831 | public function connect_destinations($data,$id) { |
832 | 832 | if(isset($data[0]['position'])){ |
833 | - $destinations = false; |
|
834 | - if(isset($data[0]['position']['country'])){ |
|
835 | - $destinations['country'] = $data[0]['position']['country']; |
|
836 | - } |
|
837 | - if(isset($data[0]['position']['destination'])){ |
|
838 | - $destinations['destination'] = $data[0]['position']['destination']; |
|
839 | - } |
|
833 | + $destinations = false; |
|
834 | + if(isset($data[0]['position']['country'])){ |
|
835 | + $destinations['country'] = $data[0]['position']['country']; |
|
836 | + } |
|
837 | + if(isset($data[0]['position']['destination'])){ |
|
838 | + $destinations['destination'] = $data[0]['position']['destination']; |
|
839 | + } |
|
840 | 840 | |
841 | - if(false !== $destinations){ |
|
842 | - $prev_values = get_post_meta($id,'destination_to_accommodation',false); |
|
843 | - if(false === $prev_values || !is_array($prev_values)){ |
|
844 | - $prev_values = array(); |
|
845 | - } |
|
846 | - //print_r($destinations); |
|
841 | + if(false !== $destinations){ |
|
842 | + $prev_values = get_post_meta($id,'destination_to_accommodation',false); |
|
843 | + if(false === $prev_values || !is_array($prev_values)){ |
|
844 | + $prev_values = array(); |
|
845 | + } |
|
846 | + //print_r($destinations); |
|
847 | 847 | $destinations = array_unique($destinations); |
848 | 848 | //print_r($destinations); |
849 | - foreach($destinations as $key => $value){ |
|
850 | - $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
|
851 | - if (null !== $destination) { |
|
852 | - if(!in_array($destination->ID,$prev_values)){ |
|
853 | - add_post_meta($id,'destination_to_accommodation',$destination->ID,false); |
|
854 | - add_post_meta($destination->ID,'accommodation_to_destination',$id,false); |
|
855 | - } |
|
856 | - } |
|
857 | - } |
|
849 | + foreach($destinations as $key => $value){ |
|
850 | + $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
|
851 | + if (null !== $destination) { |
|
852 | + if(!in_array($destination->ID,$prev_values)){ |
|
853 | + add_post_meta($id,'destination_to_accommodation',$destination->ID,false); |
|
854 | + add_post_meta($destination->ID,'accommodation_to_destination',$id,false); |
|
855 | + } |
|
856 | + } |
|
857 | + } |
|
858 | 858 | } |
859 | 859 | } |
860 | 860 | } |
@@ -866,15 +866,15 @@ discard block |
||
866 | 866 | $terms = false; |
867 | 867 | if(isset($data[0]['category'])){ |
868 | 868 | if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) |
869 | - { |
|
870 | - $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type'); |
|
871 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
872 | - else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); } |
|
873 | - } |
|
874 | - else |
|
875 | - { |
|
876 | - wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); |
|
877 | - } |
|
869 | + { |
|
870 | + $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type'); |
|
871 | + if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
872 | + else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); } |
|
873 | + } |
|
874 | + else |
|
875 | + { |
|
876 | + wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); |
|
877 | + } |
|
878 | 878 | } |
879 | 879 | } |
880 | 880 | |
@@ -898,25 +898,25 @@ discard block |
||
898 | 898 | $temp_room['type'] = 'room'; |
899 | 899 | |
900 | 900 | if(!empty($room['images']) && is_array($room['images'])){ |
901 | - $attachments_args = array( |
|
902 | - 'post_parent' => $id, |
|
903 | - 'post_status' => 'inherit', |
|
904 | - 'post_type' => 'attachment', |
|
905 | - 'order' => 'ASC', |
|
906 | - ); |
|
907 | - $attachments = new WP_Query($attachments_args); |
|
908 | - $found_attachments = array(); |
|
909 | - |
|
910 | - if($attachments->have_posts()){ |
|
911 | - foreach($attachments->posts as $attachment){ |
|
912 | - $found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
913 | - } |
|
914 | - } |
|
901 | + $attachments_args = array( |
|
902 | + 'post_parent' => $id, |
|
903 | + 'post_status' => 'inherit', |
|
904 | + 'post_type' => 'attachment', |
|
905 | + 'order' => 'ASC', |
|
906 | + ); |
|
907 | + $attachments = new WP_Query($attachments_args); |
|
908 | + $found_attachments = array(); |
|
909 | + |
|
910 | + if($attachments->have_posts()){ |
|
911 | + foreach($attachments->posts as $attachment){ |
|
912 | + $found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
913 | + } |
|
914 | + } |
|
915 | 915 | |
916 | 916 | $temp_room['gallery'] = array(); |
917 | 917 | foreach($room['images'] as $image_data){ |
918 | - $temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments); |
|
919 | - } |
|
918 | + $temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments); |
|
919 | + } |
|
920 | 920 | } |
921 | 921 | $rooms[] = $temp_room; |
922 | 922 | } |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | delete_post_meta($id, 'units'); |
926 | 926 | } |
927 | 927 | foreach($rooms as $room){ |
928 | - add_post_meta($id,'units',$room,false); |
|
928 | + add_post_meta($id,'units',$room,false); |
|
929 | 929 | } |
930 | 930 | |
931 | 931 | if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){ |
@@ -935,11 +935,11 @@ discard block |
||
935 | 935 | } |
936 | 936 | |
937 | 937 | if(false !== $id && '0' !== $id){ |
938 | - $prev_rooms = get_post_meta($id,'number_of_rooms',true); |
|
939 | - update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms); |
|
940 | - }else{ |
|
941 | - add_post_meta($id,'number_of_rooms',$room_count,true); |
|
942 | - } |
|
938 | + $prev_rooms = get_post_meta($id,'number_of_rooms',true); |
|
939 | + update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms); |
|
940 | + }else{ |
|
941 | + add_post_meta($id,'number_of_rooms',$room_count,true); |
|
942 | + } |
|
943 | 943 | } |
944 | 944 | } |
945 | 945 | |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | delete_post_meta($id, 'videos'); |
1050 | 1050 | } |
1051 | 1051 | foreach($videos as $video){ |
1052 | - add_post_meta($id,'videos',$video,false); |
|
1052 | + add_post_meta($id,'videos',$video,false); |
|
1053 | 1053 | } |
1054 | 1054 | } |
1055 | 1055 | } |
@@ -1078,17 +1078,17 @@ discard block |
||
1078 | 1078 | |
1079 | 1079 | function set_term($id=false,$name=false,$taxonomy=false,$parent=false){ |
1080 | 1080 | if(!$term = term_exists($name, $taxonomy)) |
1081 | - { |
|
1082 | - if(false !== $parent){ $parent = array('parent'=>$parent); } |
|
1083 | - $term = wp_insert_term(trim($name), $taxonomy,$parent); |
|
1084 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
1085 | - else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); } |
|
1086 | - } |
|
1087 | - else |
|
1088 | - { |
|
1089 | - wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
1090 | - } |
|
1091 | - return $term['term_id']; |
|
1081 | + { |
|
1082 | + if(false !== $parent){ $parent = array('parent'=>$parent); } |
|
1083 | + $term = wp_insert_term(trim($name), $taxonomy,$parent); |
|
1084 | + if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
1085 | + else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); } |
|
1086 | + } |
|
1087 | + else |
|
1088 | + { |
|
1089 | + wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
1090 | + } |
|
1091 | + return $term['term_id']; |
|
1092 | 1092 | } |
1093 | 1093 | |
1094 | 1094 | /** |
@@ -1096,17 +1096,17 @@ discard block |
||
1096 | 1096 | */ |
1097 | 1097 | public function set_featured_image($data,$id) { |
1098 | 1098 | if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
1099 | - $this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id); |
|
1099 | + $this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id); |
|
1100 | 1100 | |
1101 | - if(false !== $this->featured_image){ |
|
1102 | - delete_post_meta($id,'_thumbnail_id'); |
|
1103 | - add_post_meta($id,'_thumbnail_id',$this->featured_image,true); |
|
1101 | + if(false !== $this->featured_image){ |
|
1102 | + delete_post_meta($id,'_thumbnail_id'); |
|
1103 | + add_post_meta($id,'_thumbnail_id',$this->featured_image,true); |
|
1104 | 1104 | |
1105 | - if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){ |
|
1106 | - add_post_meta($id,'gallery',$this->featured_image,false); |
|
1107 | - $this->gallery_meta[] = $this->featured_image; |
|
1108 | - } |
|
1109 | - } |
|
1105 | + if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){ |
|
1106 | + add_post_meta($id,'gallery',$this->featured_image,false); |
|
1107 | + $this->gallery_meta[] = $this->featured_image; |
|
1108 | + } |
|
1109 | + } |
|
1110 | 1110 | } |
1111 | 1111 | } |
1112 | 1112 | |
@@ -1115,18 +1115,18 @@ discard block |
||
1115 | 1115 | */ |
1116 | 1116 | public function set_banner_image($data,$id) { |
1117 | 1117 | if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
1118 | - $this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c')); |
|
1119 | - |
|
1120 | - if(false !== $this->banner_image){ |
|
1121 | - delete_post_meta($id,'image_group'); |
|
1122 | - $new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image)); |
|
1123 | - add_post_meta($id,'image_group',$new_banner,true); |
|
1124 | - |
|
1125 | - if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){ |
|
1126 | - add_post_meta($id,'gallery',$this->banner_image,false); |
|
1127 | - $this->gallery_meta[] = $this->banner_image; |
|
1128 | - } |
|
1129 | - } |
|
1118 | + $this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c')); |
|
1119 | + |
|
1120 | + if(false !== $this->banner_image){ |
|
1121 | + delete_post_meta($id,'image_group'); |
|
1122 | + $new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image)); |
|
1123 | + add_post_meta($id,'image_group',$new_banner,true); |
|
1124 | + |
|
1125 | + if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){ |
|
1126 | + add_post_meta($id,'gallery',$this->banner_image,false); |
|
1127 | + $this->gallery_meta[] = $this->banner_image; |
|
1128 | + } |
|
1129 | + } |
|
1130 | 1130 | } |
1131 | 1131 | } |
1132 | 1132 | |
@@ -1136,25 +1136,25 @@ discard block |
||
1136 | 1136 | public function create_main_gallery($data,$id) { |
1137 | 1137 | |
1138 | 1138 | if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
1139 | - $counter = 0; |
|
1140 | - foreach($data[0]['content']['images'] as $image_data){ |
|
1141 | - if($counter === 0 && false !== $this->featured_image){$counter++;continue;} |
|
1142 | - if($counter === 1 && false !== $this->banner_image){$counter++;continue;} |
|
1139 | + $counter = 0; |
|
1140 | + foreach($data[0]['content']['images'] as $image_data){ |
|
1141 | + if($counter === 0 && false !== $this->featured_image){$counter++;continue;} |
|
1142 | + if($counter === 1 && false !== $this->banner_image){$counter++;continue;} |
|
1143 | 1143 | |
1144 | - $this->gallery_meta[] = $this->attach_image($image_data,$id); |
|
1145 | - $counter++; |
|
1146 | - } |
|
1144 | + $this->gallery_meta[] = $this->attach_image($image_data,$id); |
|
1145 | + $counter++; |
|
1146 | + } |
|
1147 | 1147 | |
1148 | - if(!empty($this->gallery_meta)){ |
|
1149 | - delete_post_meta($id,'gallery'); |
|
1148 | + if(!empty($this->gallery_meta)){ |
|
1149 | + delete_post_meta($id,'gallery'); |
|
1150 | 1150 | $this->gallery_meta = array_unique($this->gallery_meta); |
1151 | - foreach($this->gallery_meta as $gallery_id){ |
|
1152 | - if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){ |
|
1153 | - add_post_meta($id,'gallery',$gallery_id,false); |
|
1154 | - } |
|
1155 | - } |
|
1156 | - } |
|
1157 | - } |
|
1151 | + foreach($this->gallery_meta as $gallery_id){ |
|
1152 | + if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){ |
|
1153 | + add_post_meta($id,'gallery',$gallery_id,false); |
|
1154 | + } |
|
1155 | + } |
|
1156 | + } |
|
1157 | + } |
|
1158 | 1158 | } |
1159 | 1159 | |
1160 | 1160 | /** |
@@ -1163,42 +1163,42 @@ discard block |
||
1163 | 1163 | public function attach_image($v=false,$parent_id,$image_sizes=false){ |
1164 | 1164 | if(false !== $v){ |
1165 | 1165 | $temp_fragment = explode('/',$v['url_fragment']); |
1166 | - $url_filename = $temp_fragment[count($temp_fragment)-1]; |
|
1167 | - $url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename); |
|
1166 | + $url_filename = $temp_fragment[count($temp_fragment)-1]; |
|
1167 | + $url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename); |
|
1168 | 1168 | |
1169 | - if(in_array($url_filename,$this->found_attachments)){ |
|
1170 | - return array_search($url_filename,$this->found_attachments); |
|
1171 | - } |
|
1169 | + if(in_array($url_filename,$this->found_attachments)){ |
|
1170 | + return array_search($url_filename,$this->found_attachments); |
|
1171 | + } |
|
1172 | 1172 | |
1173 | - $postdata=array(); |
|
1174 | - if(empty($v['label'])) |
|
1175 | - { |
|
1176 | - $v['label']=''; |
|
1177 | - } |
|
1178 | - if(!empty($v['description'])) |
|
1179 | - { |
|
1180 | - $desc=wp_strip_all_tags($v['description']); |
|
1181 | - $posdata=array('post_excerpt'=>$desc); |
|
1182 | - } |
|
1183 | - if(!empty($v['section'])) |
|
1184 | - { |
|
1185 | - $desc=wp_strip_all_tags($v['section']); |
|
1186 | - $posdata=array('post_excerpt'=>$desc); |
|
1187 | - } |
|
1188 | - |
|
1189 | - $attachID=NULL; |
|
1190 | - //Resizor - add option to setting if required |
|
1191 | - $fragment = str_replace(' ','%20',$v['url_fragment']); |
|
1192 | - $url = $this->get_scaling_url($image_sizes).$fragment; |
|
1193 | - $attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata); |
|
1194 | - |
|
1195 | - //echo($attachID.' add image'); |
|
1196 | - if($attachID!=NULL) |
|
1197 | - { |
|
1198 | - return $attachID; |
|
1199 | - } |
|
1200 | - } |
|
1201 | - return false; |
|
1173 | + $postdata=array(); |
|
1174 | + if(empty($v['label'])) |
|
1175 | + { |
|
1176 | + $v['label']=''; |
|
1177 | + } |
|
1178 | + if(!empty($v['description'])) |
|
1179 | + { |
|
1180 | + $desc=wp_strip_all_tags($v['description']); |
|
1181 | + $posdata=array('post_excerpt'=>$desc); |
|
1182 | + } |
|
1183 | + if(!empty($v['section'])) |
|
1184 | + { |
|
1185 | + $desc=wp_strip_all_tags($v['section']); |
|
1186 | + $posdata=array('post_excerpt'=>$desc); |
|
1187 | + } |
|
1188 | + |
|
1189 | + $attachID=NULL; |
|
1190 | + //Resizor - add option to setting if required |
|
1191 | + $fragment = str_replace(' ','%20',$v['url_fragment']); |
|
1192 | + $url = $this->get_scaling_url($image_sizes).$fragment; |
|
1193 | + $attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata); |
|
1194 | + |
|
1195 | + //echo($attachID.' add image'); |
|
1196 | + if($attachID!=NULL) |
|
1197 | + { |
|
1198 | + return $attachID; |
|
1199 | + } |
|
1200 | + } |
|
1201 | + return false; |
|
1202 | 1202 | } |
1203 | 1203 | public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) { |
1204 | 1204 |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * Display the importer administration screen |
80 | 80 | */ |
81 | 81 | public function display_page() { |
82 | - ?> |
|
82 | + ?> |
|
83 | 83 | <div class="wrap"> |
84 | 84 | <?php screen_icon(); ?> |
85 | 85 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | </ul> |
102 | 102 | |
103 | 103 | <?php } else { |
104 | - do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']); |
|
105 | - } ?> |
|
104 | + do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']); |
|
105 | + } ?> |
|
106 | 106 | </div> |
107 | 107 | <?php |
108 | 108 | } |
@@ -149,37 +149,37 @@ discard block |
||
149 | 149 | * set_taxonomy with some terms |
150 | 150 | */ |
151 | 151 | public function set_taxonomy($taxonomy,$terms,$id) { |
152 | - $result=array(); |
|
153 | - if(!empty($data)) |
|
154 | - { |
|
155 | - foreach($data as $k) |
|
156 | - { |
|
157 | - if($id) |
|
158 | - { |
|
159 | - if(!$term = term_exists(trim($k), $tax)) |
|
160 | - { |
|
161 | - $term = wp_insert_term(trim($k), $tax); |
|
162 | - if ( is_wp_error($term) ) |
|
163 | - { |
|
164 | - echo $term->get_error_message(); |
|
165 | - } |
|
166 | - else |
|
167 | - { |
|
168 | - wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
169 | - } |
|
170 | - } |
|
171 | - else |
|
172 | - { |
|
173 | - wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
174 | - } |
|
175 | - } |
|
176 | - else |
|
177 | - { |
|
178 | - $result[]=trim($k); |
|
179 | - } |
|
180 | - } |
|
181 | - } |
|
182 | - return $result; |
|
152 | + $result=array(); |
|
153 | + if(!empty($data)) |
|
154 | + { |
|
155 | + foreach($data as $k) |
|
156 | + { |
|
157 | + if($id) |
|
158 | + { |
|
159 | + if(!$term = term_exists(trim($k), $tax)) |
|
160 | + { |
|
161 | + $term = wp_insert_term(trim($k), $tax); |
|
162 | + if ( is_wp_error($term) ) |
|
163 | + { |
|
164 | + echo $term->get_error_message(); |
|
165 | + } |
|
166 | + else |
|
167 | + { |
|
168 | + wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
169 | + } |
|
170 | + } |
|
171 | + else |
|
172 | + { |
|
173 | + wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
174 | + } |
|
175 | + } |
|
176 | + else |
|
177 | + { |
|
178 | + $result[]=trim($k); |
|
179 | + } |
|
180 | + } |
|
181 | + } |
|
182 | + return $result; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -189,21 +189,21 @@ discard block |
||
189 | 189 | if(post_type_exists('team')) { ?> |
190 | 190 | <ul> |
191 | 191 | <?php |
192 | - $team_args=array( |
|
193 | - 'post_type' => 'team', |
|
194 | - 'post_status' => 'publish', |
|
195 | - 'nopagin' => true, |
|
196 | - 'fields' => 'ids' |
|
197 | - ); |
|
198 | - $team_members = new WP_Query($team_args); |
|
199 | - if($team_members->have_posts()){ |
|
200 | - foreach($team_members->posts as $member){ ?> |
|
192 | + $team_args=array( |
|
193 | + 'post_type' => 'team', |
|
194 | + 'post_status' => 'publish', |
|
195 | + 'nopagin' => true, |
|
196 | + 'fields' => 'ids' |
|
197 | + ); |
|
198 | + $team_members = new WP_Query($team_args); |
|
199 | + if($team_members->have_posts()){ |
|
200 | + foreach($team_members->posts as $member){ ?> |
|
201 | 201 | <li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li> |
202 | 202 | <?php } |
203 | - }else{ ?> |
|
203 | + }else{ ?> |
|
204 | 204 | <li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li> |
205 | 205 | <?php } |
206 | - ?> |
|
206 | + ?> |
|
207 | 207 | </ul> |
208 | 208 | <?php } |
209 | 209 | } |
@@ -255,36 +255,36 @@ discard block |
||
255 | 255 | if(false !== $id){ |
256 | 256 | if(empty($this->found_attachments)){ |
257 | 257 | |
258 | - $attachments_args = array( |
|
259 | - 'post_parent' => $id, |
|
260 | - 'post_status' => 'inherit', |
|
261 | - 'post_type' => 'attachment', |
|
262 | - 'order' => 'ASC', |
|
263 | - 'nopagin' => 'true', |
|
264 | - 'posts_per_page' => '-1' |
|
265 | - ); |
|
258 | + $attachments_args = array( |
|
259 | + 'post_parent' => $id, |
|
260 | + 'post_status' => 'inherit', |
|
261 | + 'post_type' => 'attachment', |
|
262 | + 'order' => 'ASC', |
|
263 | + 'nopagin' => 'true', |
|
264 | + 'posts_per_page' => '-1' |
|
265 | + ); |
|
266 | 266 | |
267 | - $attachments = new WP_Query($attachments_args); |
|
268 | - if($attachments->have_posts()){ |
|
269 | - foreach($attachments->posts as $attachment){ |
|
270 | - $this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
271 | - $this->gallery_meta[] = $attachment->ID; |
|
272 | - } |
|
273 | - } |
|
267 | + $attachments = new WP_Query($attachments_args); |
|
268 | + if($attachments->have_posts()){ |
|
269 | + foreach($attachments->posts as $attachment){ |
|
270 | + $this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
271 | + $this->gallery_meta[] = $attachment->ID; |
|
272 | + } |
|
273 | + } |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
279 | 279 | * Checks to see if an item is checked. |
280 | - * |
|
281 | - * @param $haystack array|string |
|
282 | - * @param $needle string |
|
283 | - * @param $echo bool |
|
280 | + * |
|
281 | + * @param $haystack array|string |
|
282 | + * @param $needle string |
|
283 | + * @param $echo bool |
|
284 | 284 | */ |
285 | 285 | public function checked($haystack=false,$needle='',$echo=true) { |
286 | - $return = $this->itemd($haystack,$needle,'checked'); |
|
287 | - if('' !== $return) { |
|
286 | + $return = $this->itemd($haystack,$needle,'checked'); |
|
287 | + if('' !== $return) { |
|
288 | 288 | if (true === $echo) { |
289 | 289 | echo $return; |
290 | 290 | } else { |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @param $haystack array|string |
300 | 300 | * @param $needle string |
301 | - * @param $echo bool |
|
301 | + * @param $echo bool |
|
302 | 302 | */ |
303 | 303 | public function selected($haystack=false,$needle='',$echo=true) { |
304 | 304 | $return = $this->itemd($haystack,$needle,'selected'); |
@@ -316,9 +316,9 @@ discard block |
||
316 | 316 | * |
317 | 317 | * @param $haystack array|string |
318 | 318 | * @param $needle string |
319 | - * @param $type string |
|
320 | - * @param $wrap bool |
|
321 | - * @return $html string |
|
319 | + * @param $type string |
|
320 | + * @param $wrap bool |
|
321 | + * @return $html string |
|
322 | 322 | */ |
323 | 323 | public function itemd($haystack=false,$needle='',$type='',$wrap=true) { |
324 | 324 | $html = ''; |
@@ -327,14 +327,14 @@ discard block |
||
327 | 327 | $haystack = array($haystack); |
328 | 328 | } |
329 | 329 | if (in_array($needle, $haystack)) { |
330 | - if(true === $wrap || 'true' === $wrap) { |
|
330 | + if(true === $wrap || 'true' === $wrap) { |
|
331 | 331 | $html = $type . '"' . $type . '"'; |
332 | 332 | }else{ |
333 | 333 | $html = $type; |
334 | - } |
|
334 | + } |
|
335 | 335 | } |
336 | 336 | } |
337 | - return $html; |
|
337 | + return $html; |
|
338 | 338 | |
339 | 339 | } |
340 | 340 | |
@@ -344,18 +344,18 @@ discard block |
||
344 | 344 | * @param $tab string |
345 | 345 | */ |
346 | 346 | public function navigation($tab='') { |
347 | - $post_types = array( |
|
348 | - 'tour' => esc_attr('Tours','wetu-importer'), |
|
349 | - 'accommodation' => esc_attr('Accommodation','wetu-importer'), |
|
350 | - 'destination' => esc_attr('Destinations','wetu-importer'), |
|
351 | - ); |
|
347 | + $post_types = array( |
|
348 | + 'tour' => esc_attr('Tours','wetu-importer'), |
|
349 | + 'accommodation' => esc_attr('Accommodation','wetu-importer'), |
|
350 | + 'destination' => esc_attr('Destinations','wetu-importer'), |
|
351 | + ); |
|
352 | 352 | |
353 | 353 | |
354 | 354 | echo '<div class="wet-navigation"><div class="subsubsub"><a class="'.$this->itemd($tab,'','current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'">'.esc_attr('Home','wetu-importer').'</a>'; |
355 | 355 | foreach($post_types as $post_type => $label){ |
356 | - echo ' | <a class="'.$this->itemd($tab,$post_type,'current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>'; |
|
357 | - } |
|
358 | - echo '</div><br clear="both"/></div>'; |
|
356 | + echo ' | <a class="'.$this->itemd($tab,$post_type,'current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>'; |
|
357 | + } |
|
358 | + echo '</div><br clear="both"/></div>'; |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | $wetu_importer_admin = new WETU_Importer_Admin(); |
362 | 362 | \ No newline at end of file |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $tour_options = get_option('wetu_importer_tour_settings',false); |
98 | 98 | if(false !== $tour_options){ |
99 | 99 | $this->tour_options = $tour_options; |
100 | - } |
|
100 | + } |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * Display the importer administration screen |
121 | 121 | */ |
122 | 122 | public function display_page() { |
123 | - ?> |
|
123 | + ?> |
|
124 | 124 | <div class="wrap"> |
125 | 125 | <?php $this->navigation('tour'); ?> |
126 | 126 | |
@@ -249,16 +249,16 @@ discard block |
||
249 | 249 | $result = $this->update_options(); |
250 | 250 | |
251 | 251 | if(true === $result){ |
252 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
253 | - if(!isset($_GET['refresh_tours'])){ |
|
254 | - echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
255 | - } |
|
256 | - }else{ |
|
257 | - echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
258 | - } |
|
252 | + echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
253 | + if(!isset($_GET['refresh_tours'])){ |
|
254 | + echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
255 | + } |
|
256 | + }else{ |
|
257 | + echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
258 | + } |
|
259 | 259 | }else{ |
260 | 260 | echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
261 | - } |
|
261 | + } |
|
262 | 262 | echo '</h3></div>'; |
263 | 263 | } |
264 | 264 | |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | $tours = json_decode($data, true); |
271 | 271 | |
272 | 272 | if(isset($tours['error'])){ |
273 | - return $tours['error']; |
|
274 | - }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
273 | + return $tours['error']; |
|
274 | + }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
275 | 275 | set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2); |
276 | 276 | return true; |
277 | 277 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $keyphrases = $_POST['keyword']; |
321 | 321 | }else{ |
322 | 322 | $keyphrases = array(0); |
323 | - } |
|
323 | + } |
|
324 | 324 | |
325 | 325 | if(!is_array($keyphrases)){ |
326 | 326 | $keyphrases = array($keyphrases); |
@@ -349,15 +349,15 @@ discard block |
||
349 | 349 | |
350 | 350 | foreach($tours as $row_key => $row){ |
351 | 351 | |
352 | - if(isset($row['is_disabled']) && true === $row['is_disabled']){ |
|
353 | - continue; |
|
354 | - } |
|
352 | + if(isset($row['is_disabled']) && true === $row['is_disabled']){ |
|
353 | + continue; |
|
354 | + } |
|
355 | 355 | |
356 | - /*if('Sample' === $row['type']){ |
|
356 | + /*if('Sample' === $row['type']){ |
|
357 | 357 | continue; |
358 | 358 | }*/ |
359 | 359 | |
360 | - //If this is a current tour, add its ID to the row. |
|
360 | + //If this is a current tour, add its ID to the row. |
|
361 | 361 | $row['post_id'] = 0; |
362 | 362 | if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){ |
363 | 363 | $row['post_id'] = $current_tours[$row['identifier']]->post_id; |
@@ -366,31 +366,31 @@ discard block |
||
366 | 366 | //If we are searching for |
367 | 367 | if(false !== $post_status){ |
368 | 368 | |
369 | - if('import' === $post_status){ |
|
369 | + if('import' === $post_status){ |
|
370 | 370 | |
371 | 371 | if(0 !== $row['post_id']){ |
372 | - continue; |
|
372 | + continue; |
|
373 | 373 | }else{ |
374 | 374 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
375 | - } |
|
375 | + } |
|
376 | 376 | |
377 | 377 | |
378 | - }else{ |
|
378 | + }else{ |
|
379 | 379 | |
380 | 380 | if(0 === $row['post_id']){ |
381 | 381 | continue; |
382 | 382 | }else{ |
383 | 383 | $current_status = get_post_status($row['post_id']); |
384 | 384 | if($current_status !== $post_status){ |
385 | - continue; |
|
386 | - } |
|
385 | + continue; |
|
386 | + } |
|
387 | 387 | |
388 | 388 | } |
389 | 389 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
390 | 390 | |
391 | - } |
|
391 | + } |
|
392 | 392 | |
393 | - }else{ |
|
393 | + }else{ |
|
394 | 394 | //Search through each keyword. |
395 | 395 | foreach($keyphrases as $keyphrase){ |
396 | 396 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
405 | 405 | } |
406 | 406 | } |
407 | - } |
|
407 | + } |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
@@ -471,17 +471,17 @@ discard block |
||
471 | 471 | $content = false; |
472 | 472 | } |
473 | 473 | |
474 | - $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
474 | + $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
475 | 475 | |
476 | - if($jdata) |
|
477 | - { |
|
476 | + if($jdata) |
|
477 | + { |
|
478 | 478 | $jdata=json_decode($jdata,true); |
479 | - if(!empty($jdata)) |
|
480 | - { |
|
481 | - $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
482 | - $this->format_completed_row($return); |
|
483 | - } |
|
484 | - } |
|
479 | + if(!empty($jdata)) |
|
480 | + { |
|
481 | + $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
482 | + $this->format_completed_row($return); |
|
483 | + } |
|
484 | + } |
|
485 | 485 | die(); |
486 | 486 | } |
487 | 487 | |
@@ -489,53 +489,53 @@ discard block |
||
489 | 489 | |
490 | 490 | /** |
491 | 491 | * Connect to wetu |
492 | - * |
|
493 | - * @param $data array |
|
494 | - * @param $wetu_id string |
|
492 | + * |
|
493 | + * @param $data array |
|
494 | + * @param $wetu_id string |
|
495 | 495 | */ |
496 | 496 | public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) { |
497 | - $post_name = $data_post_content = $data_post_excerpt = ''; |
|
498 | - $post = array( |
|
499 | - 'post_type' => 'tour', |
|
500 | - ); |
|
497 | + $post_name = $data_post_content = $data_post_excerpt = ''; |
|
498 | + $post = array( |
|
499 | + 'post_type' => 'tour', |
|
500 | + ); |
|
501 | 501 | |
502 | - //Set the post_content |
|
502 | + //Set the post_content |
|
503 | 503 | $content_used_general_description = false; |
504 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
505 | - $data_post_content = ''; |
|
506 | - |
|
507 | - if(isset($data['description'])){ |
|
508 | - $data_post_content = $data['description']; |
|
509 | - }elseif(isset($data['summary'])){ |
|
510 | - $data_post_content = $data['summary']; |
|
511 | - } |
|
512 | - $post['post_content'] = $data_post_content; |
|
513 | - } |
|
514 | - |
|
515 | - //Create or update the post |
|
516 | - if(false !== $id && '0' !== $id){ |
|
517 | - $post['ID'] = $id; |
|
518 | - $post['post_status'] = 'publish'; |
|
519 | - $id = wp_update_post($post); |
|
520 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
521 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
522 | - }else{ |
|
523 | - |
|
524 | - //Set the name |
|
525 | - if(isset($data['name'])){ |
|
526 | - $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
527 | - } |
|
528 | - $post['post_name'] = $post_name; |
|
529 | - $post['post_title'] = $data['name']; |
|
530 | - $post['post_status'] = 'publish'; |
|
531 | - $id = wp_insert_post($post); |
|
532 | - |
|
533 | - //Save the WETU ID and the Last date it was modified. |
|
534 | - if(false !== $id){ |
|
535 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
536 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
537 | - } |
|
538 | - } |
|
504 | + if(false !== $importable_content && in_array('description',$importable_content)){ |
|
505 | + $data_post_content = ''; |
|
506 | + |
|
507 | + if(isset($data['description'])){ |
|
508 | + $data_post_content = $data['description']; |
|
509 | + }elseif(isset($data['summary'])){ |
|
510 | + $data_post_content = $data['summary']; |
|
511 | + } |
|
512 | + $post['post_content'] = $data_post_content; |
|
513 | + } |
|
514 | + |
|
515 | + //Create or update the post |
|
516 | + if(false !== $id && '0' !== $id){ |
|
517 | + $post['ID'] = $id; |
|
518 | + $post['post_status'] = 'publish'; |
|
519 | + $id = wp_update_post($post); |
|
520 | + $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
521 | + update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
522 | + }else{ |
|
523 | + |
|
524 | + //Set the name |
|
525 | + if(isset($data['name'])){ |
|
526 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
527 | + } |
|
528 | + $post['post_name'] = $post_name; |
|
529 | + $post['post_title'] = $data['name']; |
|
530 | + $post['post_status'] = 'publish'; |
|
531 | + $id = wp_insert_post($post); |
|
532 | + |
|
533 | + //Save the WETU ID and the Last date it was modified. |
|
534 | + if(false !== $id){ |
|
535 | + add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
536 | + add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
537 | + } |
|
538 | + } |
|
539 | 539 | |
540 | 540 | |
541 | 541 | //Set the price |
@@ -548,9 +548,9 @@ discard block |
||
548 | 548 | $this->set_duration($data,$id); |
549 | 549 | } |
550 | 550 | |
551 | - if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
552 | - $this->process_itineraries($data,$id,$importable_content); |
|
553 | - } |
|
551 | + if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
552 | + $this->process_itineraries($data,$id,$importable_content); |
|
553 | + } |
|
554 | 554 | |
555 | 555 | if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){ |
556 | 556 | $this->process_map_points($data,$id); |
@@ -561,24 +561,24 @@ discard block |
||
561 | 561 | if(false !== $importable_content && (in_array('itinerary_gallery',$importable_content) || in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
562 | 562 | $this->find_attachments($id); |
563 | 563 | } |
564 | - //Set the featured image |
|
565 | - //TODO Test These |
|
566 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
567 | - $this->set_featured_image($data,$id); |
|
568 | - } |
|
564 | + //Set the featured image |
|
565 | + //TODO Test These |
|
566 | + if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
567 | + $this->set_featured_image($data,$id); |
|
568 | + } |
|
569 | 569 | |
570 | 570 | //TODO Test These |
571 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
572 | - $this->set_banner_image($data,$id); |
|
573 | - } |
|
571 | + if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
572 | + $this->set_banner_image($data,$id); |
|
573 | + } |
|
574 | 574 | |
575 | 575 | //TODO Test These |
576 | - //Import the main gallery |
|
577 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
578 | - $this->create_main_gallery($data,$id); |
|
579 | - } |
|
576 | + //Import the main gallery |
|
577 | + if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
578 | + $this->create_main_gallery($data,$id); |
|
579 | + } |
|
580 | 580 | |
581 | - return $id; |
|
581 | + return $id; |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | /** |
@@ -706,31 +706,31 @@ discard block |
||
706 | 706 | */ |
707 | 707 | public function process_map_points($data,$id) { |
708 | 708 | |
709 | - if(!empty($data['routes'])){ |
|
709 | + if(!empty($data['routes'])){ |
|
710 | 710 | |
711 | - delete_post_meta($id,'wetu_map_points'); |
|
711 | + delete_post_meta($id,'wetu_map_points'); |
|
712 | 712 | |
713 | - $points = array(); |
|
713 | + $points = array(); |
|
714 | 714 | |
715 | - foreach($data['routes'] as $route){ |
|
715 | + foreach($data['routes'] as $route){ |
|
716 | 716 | |
717 | 717 | |
718 | - if(isset($route['points']) && '' !== $route['points']){ |
|
718 | + if(isset($route['points']) && '' !== $route['points']){ |
|
719 | 719 | |
720 | - $temp_points = explode(';',$route['points']); |
|
721 | - $point_counter = count($temp_points); |
|
720 | + $temp_points = explode(';',$route['points']); |
|
721 | + $point_counter = count($temp_points); |
|
722 | 722 | |
723 | 723 | for ($x = 0; $x <= $point_counter; $x++) { |
724 | - $y = $x+1; |
|
724 | + $y = $x+1; |
|
725 | 725 | $points[] = $temp_points[$x].','.$temp_points[$y]; |
726 | 726 | $x++; |
727 | 727 | } |
728 | 728 | } |
729 | - } |
|
730 | - if(!empty($points)){ |
|
729 | + } |
|
730 | + if(!empty($points)){ |
|
731 | 731 | $this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true); |
732 | - } |
|
733 | - } |
|
732 | + } |
|
733 | + } |
|
734 | 734 | |
735 | 735 | } |
736 | 736 | |
@@ -738,17 +738,17 @@ discard block |
||
738 | 738 | * Set the Itinerary Day |
739 | 739 | */ |
740 | 740 | public function set_itinerary_day($day,$id) { |
741 | - $this->save_custom_field($day,'itinerary',$id,false,false); |
|
741 | + $this->save_custom_field($day,'itinerary',$id,false,false); |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | /** |
745 | 745 | * Set the price |
746 | 746 | */ |
747 | 747 | public function set_price($data,$id) { |
748 | - //Price |
|
748 | + //Price |
|
749 | 749 | if(isset($data['price']) && ''!== $data['price']){ |
750 | - $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
|
751 | - $this->save_custom_field($price,'price',$id); |
|
750 | + $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
|
751 | + $this->save_custom_field($price,'price',$id); |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | //Price includes |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | $this->save_custom_field($data['price_includes'],'included',$id); |
757 | 757 | } |
758 | 758 | |
759 | - //Price Excludes |
|
759 | + //Price Excludes |
|
760 | 760 | if(isset($data['price_excludes']) && ''!== $data['price_excludes']){ |
761 | 761 | $this->save_custom_field($data['price_excludes'],'not_included',$id); |
762 | 762 | } |
@@ -780,35 +780,35 @@ discard block |
||
780 | 780 | */ |
781 | 781 | public function set_accommodation($day,$id) { |
782 | 782 | |
783 | - $ac_id = false; |
|
783 | + $ac_id = false; |
|
784 | 784 | $this->current_accommodation = $this->find_current_accommodation(); |
785 | 785 | |
786 | 786 | if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){ |
787 | 787 | |
788 | 788 | if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
789 | - $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
789 | + $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
790 | 790 | }else{ |
791 | 791 | $ac_id = wp_insert_post(array( |
792 | - 'post_type' => 'accommodation', |
|
793 | - 'post_status' => 'draft', |
|
794 | - 'post_title' => $day['content_entity_id'] |
|
795 | - )); |
|
792 | + 'post_type' => 'accommodation', |
|
793 | + 'post_status' => 'draft', |
|
794 | + 'post_title' => $day['content_entity_id'] |
|
795 | + )); |
|
796 | 796 | $this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id); |
797 | 797 | } |
798 | 798 | |
799 | 799 | if('' !== $ac_id && false !== $ac_id){ |
800 | - $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
800 | + $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
801 | 801 | $this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false); |
802 | - } |
|
802 | + } |
|
803 | 803 | } |
804 | 804 | return $ac_id; |
805 | 805 | } |
806 | 806 | |
807 | 807 | /** |
808 | 808 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
809 | - * |
|
810 | - * @param $post_type string |
|
811 | - * @return boolean / array |
|
809 | + * |
|
810 | + * @param $post_type string |
|
811 | + * @return boolean / array |
|
812 | 812 | */ |
813 | 813 | public function find_current_accommodation($post_type='accommodation') { |
814 | 814 | global $wpdb; |
@@ -816,16 +816,16 @@ discard block |
||
816 | 816 | |
817 | 817 | $return = false; |
818 | 818 | if(!empty($accommodation)){ |
819 | - foreach($accommodation as $key => $acc){ |
|
819 | + foreach($accommodation as $key => $acc){ |
|
820 | 820 | $return[$acc->meta_value] = $acc->post_id; |
821 | - } |
|
822 | - } |
|
821 | + } |
|
822 | + } |
|
823 | 823 | return $return; |
824 | 824 | } |
825 | 825 | |
826 | 826 | /** |
827 | 827 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
828 | - * @return boolean / array |
|
828 | + * @return boolean / array |
|
829 | 829 | */ |
830 | 830 | public function find_current_destinations() { |
831 | 831 | return $this->find_current_accommodation('destination'); |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | $country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true); |
853 | 853 | if(false !== $country_wetu_id){ |
854 | 854 | $this->set_country($country_wetu_id, $id); |
855 | - } |
|
855 | + } |
|
856 | 856 | |
857 | 857 | }else { |
858 | 858 | |
@@ -863,27 +863,27 @@ discard block |
||
863 | 863 | |
864 | 864 | if (!empty($destination_data) && !isset($destination_data['error'])) { |
865 | 865 | |
866 | - $destination_title = $day['destination_content_entity_id']; |
|
866 | + $destination_title = $day['destination_content_entity_id']; |
|
867 | 867 | |
868 | - if(isset($destination_data[0]['name'])){ |
|
868 | + if(isset($destination_data[0]['name'])){ |
|
869 | 869 | $destination_title = $destination_data[0]['name']; |
870 | - } |
|
870 | + } |
|
871 | 871 | |
872 | - if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
873 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
872 | + if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
873 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
874 | 874 | |
875 | 875 | $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
876 | - } |
|
876 | + } |
|
877 | 877 | |
878 | - $dest_post = array( |
|
878 | + $dest_post = array( |
|
879 | 879 | 'post_type' => 'destination', |
880 | 880 | 'post_status' => 'draft', |
881 | 881 | 'post_title' => $destination_title |
882 | 882 | ); |
883 | 883 | |
884 | - if(false !== $country_id){ |
|
884 | + if(false !== $country_id){ |
|
885 | 885 | $dest_post['post_parent'] = $country_id; |
886 | - } |
|
886 | + } |
|
887 | 887 | $dest_id = wp_insert_post($dest_post); |
888 | 888 | |
889 | 889 | //Make sure we register the |
@@ -905,50 +905,50 @@ discard block |
||
905 | 905 | * Connects the destinations post type |
906 | 906 | * |
907 | 907 | * @param $dest_id string |
908 | - * @param $country_id array |
|
908 | + * @param $country_id array |
|
909 | 909 | * @param $id string |
910 | 910 | */ |
911 | 911 | public function set_country($country_wetu_id, $id) { |
912 | - $country_id = false; |
|
912 | + $country_id = false; |
|
913 | 913 | $this->current_destinations = $this->find_current_destinations(); |
914 | 914 | |
915 | - if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
916 | - $country_id = $this->current_destinations[$country_wetu_id]; |
|
917 | - } else { |
|
915 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
916 | + $country_id = $this->current_destinations[$country_wetu_id]; |
|
917 | + } else { |
|
918 | 918 | |
919 | - $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
919 | + $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
920 | 920 | |
921 | - if ($country_json) { |
|
922 | - $country_data = json_decode($country_json, true); |
|
921 | + if ($country_json) { |
|
922 | + $country_data = json_decode($country_json, true); |
|
923 | 923 | |
924 | - if (!empty($country_data) && !isset($country_data['error'])) { |
|
924 | + if (!empty($country_data) && !isset($country_data['error'])) { |
|
925 | 925 | |
926 | 926 | //Format the title of the destination if its available, otherwise default to the WETU ID. |
927 | - $country_title = $country_wetu_id; |
|
928 | - if (isset($country_data[0]['name'])) { |
|
927 | + $country_title = $country_wetu_id; |
|
928 | + if (isset($country_data[0]['name'])) { |
|
929 | 929 | $country_title = $country_data[0]['name']; |
930 | - } |
|
930 | + } |
|
931 | 931 | |
932 | 932 | $country_id = wp_insert_post(array( |
933 | - 'post_type' => 'destination', |
|
934 | - 'post_status' => 'draft', |
|
935 | - 'post_title' => $country_title |
|
936 | - )); |
|
933 | + 'post_type' => 'destination', |
|
934 | + 'post_status' => 'draft', |
|
935 | + 'post_title' => $country_title |
|
936 | + )); |
|
937 | 937 | //add the country to the current destination stack |
938 | 938 | $this->current_destinations[$country_wetu_id] = $country_id; |
939 | 939 | |
940 | 940 | //Save the wetu field |
941 | - $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
942 | - } |
|
943 | - } |
|
944 | - } |
|
941 | + $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
942 | + } |
|
943 | + } |
|
944 | + } |
|
945 | 945 | |
946 | - if ('' !== $country_id && false !== $country_id) { |
|
947 | - $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
948 | - $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
946 | + if ('' !== $country_id && false !== $country_id) { |
|
947 | + $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
948 | + $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
949 | 949 | |
950 | - return $country_id; |
|
951 | - } |
|
950 | + return $country_id; |
|
951 | + } |
|
952 | 952 | } |
953 | 953 | } |
954 | 954 | $wetu_importer_tours = new WETU_Importer_Tours(); |
955 | 955 | \ No newline at end of file |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * Display the importer administration screen |
105 | 105 | */ |
106 | 106 | public function display_page() { |
107 | - ?> |
|
107 | + ?> |
|
108 | 108 | <div class="wrap"> |
109 | 109 | <?php $this->navigation('destination'); ?> |
110 | 110 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $keyphrases = $_POST['keyword']; |
331 | 331 | }else{ |
332 | 332 | $keyphrases = array(0); |
333 | - } |
|
333 | + } |
|
334 | 334 | |
335 | 335 | if(!is_array($keyphrases)){ |
336 | 336 | $keyphrases = array($keyphrases); |
@@ -359,11 +359,11 @@ discard block |
||
359 | 359 | //If we are searching for |
360 | 360 | if(false !== $post_status){ |
361 | 361 | |
362 | - $current_status = get_post_status($row->post_id); |
|
363 | - if($current_status !== $post_status){ |
|
364 | - continue; |
|
365 | - } |
|
366 | - $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row); |
|
362 | + $current_status = get_post_status($row->post_id); |
|
363 | + if($current_status !== $post_status){ |
|
364 | + continue; |
|
365 | + } |
|
366 | + $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row); |
|
367 | 367 | |
368 | 368 | |
369 | 369 | }else{ |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | $team_members = false; |
446 | 446 | } |
447 | 447 | |
448 | - $safari_brands = false; |
|
448 | + $safari_brands = false; |
|
449 | 449 | |
450 | 450 | if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
451 | 451 | $content = $_POST['content']; |
@@ -456,16 +456,16 @@ discard block |
||
456 | 456 | $content = false; |
457 | 457 | } |
458 | 458 | |
459 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
460 | - if($jdata) |
|
461 | - { |
|
462 | - $adata=json_decode($jdata,true); |
|
463 | - if(!empty($adata)) |
|
464 | - { |
|
465 | - $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
466 | - $this->format_completed_row($return); |
|
467 | - } |
|
468 | - } |
|
459 | + $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
460 | + if($jdata) |
|
461 | + { |
|
462 | + $adata=json_decode($jdata,true); |
|
463 | + if(!empty($adata)) |
|
464 | + { |
|
465 | + $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
466 | + $this->format_completed_row($return); |
|
467 | + } |
|
468 | + } |
|
469 | 469 | |
470 | 470 | die(); |
471 | 471 | } |
@@ -477,82 +477,82 @@ discard block |
||
477 | 477 | */ |
478 | 478 | public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) { |
479 | 479 | |
480 | - if(trim($data[0]['type'])=='Destination') |
|
481 | - { |
|
482 | - $post_name = $data_post_content = $data_post_excerpt = ''; |
|
483 | - $post = array( |
|
484 | - 'post_type' => 'destination', |
|
485 | - ); |
|
486 | - |
|
487 | - $content_used_general_description = false; |
|
488 | - |
|
489 | - //Set the post_content |
|
490 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
491 | - if(isset($data[0]['content']['extended_description'])) |
|
492 | - { |
|
493 | - $data_post_content = $data[0]['content']['extended_description']; |
|
494 | - }elseif(isset($data[0]['content']['general_description'])){ |
|
495 | - $data_post_content = $data[0]['content']['general_description']; |
|
496 | - $content_used_general_description = true; |
|
497 | - }elseif(isset($data[0]['content']['teaser_description'])){ |
|
498 | - $data_post_content = $data[0]['content']['teaser_description']; |
|
499 | - } |
|
500 | - $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
501 | - } |
|
502 | - |
|
503 | - //set the post_excerpt |
|
504 | - if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
505 | - if(isset($data[0]['content']['teaser_description'])){ |
|
506 | - $data_post_excerpt = $data[0]['content']['teaser_description']; |
|
507 | - }elseif(isset($data[0]['content']['extended_description'])){ |
|
480 | + if(trim($data[0]['type'])=='Destination') |
|
481 | + { |
|
482 | + $post_name = $data_post_content = $data_post_excerpt = ''; |
|
483 | + $post = array( |
|
484 | + 'post_type' => 'destination', |
|
485 | + ); |
|
486 | + |
|
487 | + $content_used_general_description = false; |
|
488 | + |
|
489 | + //Set the post_content |
|
490 | + if(false !== $importable_content && in_array('description',$importable_content)){ |
|
491 | + if(isset($data[0]['content']['extended_description'])) |
|
492 | + { |
|
493 | + $data_post_content = $data[0]['content']['extended_description']; |
|
494 | + }elseif(isset($data[0]['content']['general_description'])){ |
|
495 | + $data_post_content = $data[0]['content']['general_description']; |
|
496 | + $content_used_general_description = true; |
|
497 | + }elseif(isset($data[0]['content']['teaser_description'])){ |
|
498 | + $data_post_content = $data[0]['content']['teaser_description']; |
|
499 | + } |
|
500 | + $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
501 | + } |
|
502 | + |
|
503 | + //set the post_excerpt |
|
504 | + if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
505 | + if(isset($data[0]['content']['teaser_description'])){ |
|
506 | + $data_post_excerpt = $data[0]['content']['teaser_description']; |
|
507 | + }elseif(isset($data[0]['content']['extended_description'])){ |
|
508 | 508 | $data_post_excerpt = $data[0]['content']['extended_description']; |
509 | 509 | }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
510 | - $data_post_excerpt = $data[0]['content']['general_description']; |
|
511 | - } |
|
512 | - $post['post_excerpt'] = $data_post_excerpt; |
|
513 | - } |
|
510 | + $data_post_excerpt = $data[0]['content']['general_description']; |
|
511 | + } |
|
512 | + $post['post_excerpt'] = $data_post_excerpt; |
|
513 | + } |
|
514 | 514 | |
515 | - if(false !== $id && '0' !== $id){ |
|
516 | - $post['ID'] = $id; |
|
515 | + if(false !== $id && '0' !== $id){ |
|
516 | + $post['ID'] = $id; |
|
517 | 517 | if(isset($data[0]['name'])){ |
518 | 518 | $post['post_title'] = $data[0]['name']; |
519 | 519 | $post['post_status'] = 'publish'; |
520 | 520 | $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0); |
521 | 521 | } |
522 | - $id = wp_update_post($post); |
|
523 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
524 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
525 | - }else{ |
|
526 | - |
|
527 | - //Set the name |
|
528 | - if(isset($data[0]['name'])){ |
|
529 | - $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0); |
|
530 | - } |
|
531 | - $post['post_name'] = $post_name; |
|
532 | - $post['post_title'] = $data[0]['name']; |
|
533 | - $post['post_status'] = 'publish'; |
|
534 | - $id = wp_insert_post($post); |
|
535 | - |
|
536 | - //Save the WETU ID and the Last date it was modified. |
|
537 | - if(false !== $id){ |
|
538 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
539 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
540 | - } |
|
541 | - } |
|
542 | - |
|
543 | - //Set the team member if it is there |
|
544 | - if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
545 | - $this->set_team_member($id,$team_members); |
|
546 | - } |
|
547 | - |
|
548 | - if(class_exists('LSX_TO_Maps')){ |
|
549 | - $this->set_map_data($data,$id,4); |
|
550 | - } |
|
551 | - |
|
552 | - //Set the Room Data |
|
553 | - if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
554 | - $this->set_video_data($data,$id); |
|
555 | - } |
|
522 | + $id = wp_update_post($post); |
|
523 | + $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
524 | + update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
525 | + }else{ |
|
526 | + |
|
527 | + //Set the name |
|
528 | + if(isset($data[0]['name'])){ |
|
529 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0); |
|
530 | + } |
|
531 | + $post['post_name'] = $post_name; |
|
532 | + $post['post_title'] = $data[0]['name']; |
|
533 | + $post['post_status'] = 'publish'; |
|
534 | + $id = wp_insert_post($post); |
|
535 | + |
|
536 | + //Save the WETU ID and the Last date it was modified. |
|
537 | + if(false !== $id){ |
|
538 | + add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
539 | + add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
540 | + } |
|
541 | + } |
|
542 | + |
|
543 | + //Set the team member if it is there |
|
544 | + if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
545 | + $this->set_team_member($id,$team_members); |
|
546 | + } |
|
547 | + |
|
548 | + if(class_exists('LSX_TO_Maps')){ |
|
549 | + $this->set_map_data($data,$id,4); |
|
550 | + } |
|
551 | + |
|
552 | + //Set the Room Data |
|
553 | + if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
554 | + $this->set_video_data($data,$id); |
|
555 | + } |
|
556 | 556 | |
557 | 557 | //Set the Electricity |
558 | 558 | if(false !== $importable_content && in_array('electricity',$importable_content)){ |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | } |
598 | 598 | |
599 | 599 | } |
600 | - return $id; |
|
600 | + return $id; |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | /** |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | |
608 | 608 | delete_post_meta($id, 'team_to_'.$this->tab_slug); |
609 | 609 | foreach($team_members as $team){ |
610 | - add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
610 | + add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
611 | 611 | } |
612 | 612 | } |
613 | 613 | |
@@ -658,11 +658,11 @@ discard block |
||
658 | 658 | 'elevation' => '', |
659 | 659 | ); |
660 | 660 | if(false !== $id && '0' !== $id){ |
661 | - $prev = get_post_meta($id,'location',true); |
|
662 | - update_post_meta($id,'location',$location_data,$prev); |
|
663 | - }else{ |
|
664 | - add_post_meta($id,'location',$location_data,true); |
|
665 | - } |
|
661 | + $prev = get_post_meta($id,'location',true); |
|
662 | + update_post_meta($id,'location',$location_data,$prev); |
|
663 | + }else{ |
|
664 | + add_post_meta($id,'location',$location_data,true); |
|
665 | + } |
|
666 | 666 | } |
667 | 667 | } |
668 | 668 |