@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * Display the importer administration screen |
123 | 123 | */ |
124 | 124 | public function display_page() { |
125 | - ?> |
|
125 | + ?> |
|
126 | 126 | <div class="wrap"> |
127 | 127 | <?php screen_icon(); ?> |
128 | 128 | |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | $accommodation = json_decode($data, true); |
301 | 301 | |
302 | 302 | if(isset($accommodation['error'])){ |
303 | - return $accommodation['error']; |
|
304 | - }elseif (isset($accommodation) && !empty($accommodation)) { |
|
303 | + return $accommodation['error']; |
|
304 | + }elseif (isset($accommodation) && !empty($accommodation)) { |
|
305 | 305 | set_transient('lsx_ti_accommodation',$accommodation,60*60*2); |
306 | 306 | return true; |
307 | 307 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | $keyphrases = $_POST['keyword']; |
350 | 350 | }else{ |
351 | 351 | $keyphrases = array(0); |
352 | - } |
|
352 | + } |
|
353 | 353 | |
354 | 354 | if(!is_array($keyphrases)){ |
355 | 355 | $keyphrases = array($keyphrases); |
@@ -446,13 +446,13 @@ discard block |
||
446 | 446 | public function multineedle_stripos($haystack, $needles, $offset=0) { |
447 | 447 | $found = false; |
448 | 448 | $needle_count = count($needles); |
449 | - foreach($needles as $needle) { |
|
450 | - if(false !== stripos($haystack, $needle, $offset)){ |
|
451 | - $found[] = true; |
|
452 | - } |
|
453 | - } |
|
454 | - if(false !== $found && $needle_count === count($found)){ |
|
455 | - return true; |
|
449 | + foreach($needles as $needle) { |
|
450 | + if(false !== stripos($haystack, $needle, $offset)){ |
|
451 | + $found[] = true; |
|
452 | + } |
|
453 | + } |
|
454 | + if(false !== $found && $needle_count === count($found)){ |
|
455 | + return true; |
|
456 | 456 | }else{ |
457 | 457 | return false; |
458 | 458 | } |
@@ -521,16 +521,16 @@ discard block |
||
521 | 521 | $content = false; |
522 | 522 | } |
523 | 523 | |
524 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
525 | - if($jdata) |
|
526 | - { |
|
527 | - $adata=json_decode($jdata,true); |
|
528 | - if(!empty($adata)) |
|
529 | - { |
|
530 | - $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
531 | - $this->format_completed_row($return); |
|
532 | - } |
|
533 | - } |
|
524 | + $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
525 | + if($jdata) |
|
526 | + { |
|
527 | + $adata=json_decode($jdata,true); |
|
528 | + if(!empty($adata)) |
|
529 | + { |
|
530 | + $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
531 | + $this->format_completed_row($return); |
|
532 | + } |
|
533 | + } |
|
534 | 534 | |
535 | 535 | die(); |
536 | 536 | } |
@@ -547,148 +547,148 @@ discard block |
||
547 | 547 | */ |
548 | 548 | public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) { |
549 | 549 | |
550 | - if(trim($data[0]['type'])=='Accommodation') |
|
551 | - { |
|
552 | - $post_name = $data_post_content = $data_post_excerpt = ''; |
|
553 | - $post = array( |
|
554 | - 'post_type' => 'accommodation', |
|
555 | - ); |
|
556 | - |
|
557 | - $content_used_general_description = false; |
|
558 | - |
|
559 | - //Set the post_content |
|
560 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
561 | - if(isset($data[0]['content']['extended_description'])) |
|
562 | - { |
|
563 | - $data_post_content = $data[0]['content']['extended_description']; |
|
564 | - }elseif(isset($data[0]['content']['general_description'])){ |
|
565 | - $data_post_content = $data[0]['content']['general_description']; |
|
566 | - $content_used_general_description = true; |
|
567 | - }elseif(isset($data[0]['content']['teaser_description'])){ |
|
568 | - $data_post_content = $data[0]['content']['teaser_description']; |
|
569 | - } |
|
570 | - $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
571 | - } |
|
572 | - |
|
573 | - //set the post_excerpt |
|
574 | - if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
575 | - if(isset($data[0]['content']['teaser_description'])){ |
|
576 | - $data_post_excerpt = $data[0]['content']['teaser_description']; |
|
577 | - }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
578 | - $data_post_excerpt = $data[0]['content']['general_description']; |
|
579 | - } |
|
580 | - $post['post_excerpt'] = $data_post_excerpt; |
|
581 | - } |
|
582 | - |
|
583 | - if(false !== $id && '0' !== $id){ |
|
584 | - $post['ID'] = $id; |
|
550 | + if(trim($data[0]['type'])=='Accommodation') |
|
551 | + { |
|
552 | + $post_name = $data_post_content = $data_post_excerpt = ''; |
|
553 | + $post = array( |
|
554 | + 'post_type' => 'accommodation', |
|
555 | + ); |
|
556 | + |
|
557 | + $content_used_general_description = false; |
|
558 | + |
|
559 | + //Set the post_content |
|
560 | + if(false !== $importable_content && in_array('description',$importable_content)){ |
|
561 | + if(isset($data[0]['content']['extended_description'])) |
|
562 | + { |
|
563 | + $data_post_content = $data[0]['content']['extended_description']; |
|
564 | + }elseif(isset($data[0]['content']['general_description'])){ |
|
565 | + $data_post_content = $data[0]['content']['general_description']; |
|
566 | + $content_used_general_description = true; |
|
567 | + }elseif(isset($data[0]['content']['teaser_description'])){ |
|
568 | + $data_post_content = $data[0]['content']['teaser_description']; |
|
569 | + } |
|
570 | + $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
571 | + } |
|
572 | + |
|
573 | + //set the post_excerpt |
|
574 | + if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
575 | + if(isset($data[0]['content']['teaser_description'])){ |
|
576 | + $data_post_excerpt = $data[0]['content']['teaser_description']; |
|
577 | + }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
578 | + $data_post_excerpt = $data[0]['content']['general_description']; |
|
579 | + } |
|
580 | + $post['post_excerpt'] = $data_post_excerpt; |
|
581 | + } |
|
582 | + |
|
583 | + if(false !== $id && '0' !== $id){ |
|
584 | + $post['ID'] = $id; |
|
585 | 585 | if(isset($data[0]['name'])){ |
586 | 586 | $post['post_title'] = $data[0]['name']; |
587 | - $post['post_status'] = 'publish'; |
|
587 | + $post['post_status'] = 'publish'; |
|
588 | 588 | $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
589 | 589 | } |
590 | - $id = wp_update_post($post); |
|
591 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
592 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
593 | - }else{ |
|
594 | - |
|
595 | - //Set the name |
|
596 | - if(isset($data[0]['name'])){ |
|
597 | - $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
598 | - } |
|
599 | - $post['post_name'] = $post_name; |
|
600 | - $post['post_title'] = $data[0]['name']; |
|
601 | - $post['post_status'] = 'publish'; |
|
602 | - $id = wp_insert_post($post); |
|
603 | - |
|
604 | - //Save the WETU ID and the Last date it was modified. |
|
605 | - if(false !== $id){ |
|
606 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
607 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
608 | - } |
|
609 | - } |
|
610 | - //Setup some default for use in the import |
|
611 | - if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
|
590 | + $id = wp_update_post($post); |
|
591 | + $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
592 | + update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
593 | + }else{ |
|
594 | + |
|
595 | + //Set the name |
|
596 | + if(isset($data[0]['name'])){ |
|
597 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
598 | + } |
|
599 | + $post['post_name'] = $post_name; |
|
600 | + $post['post_title'] = $data[0]['name']; |
|
601 | + $post['post_status'] = 'publish'; |
|
602 | + $id = wp_insert_post($post); |
|
603 | + |
|
604 | + //Save the WETU ID and the Last date it was modified. |
|
605 | + if(false !== $id){ |
|
606 | + add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
607 | + add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
608 | + } |
|
609 | + } |
|
610 | + //Setup some default for use in the import |
|
611 | + if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
|
612 | 612 | $this->find_attachments($id); |
613 | 613 | } |
614 | 614 | |
615 | - //Set the team member if it is there |
|
616 | - if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
617 | - $this->set_team_member($id,$team_members); |
|
618 | - } |
|
619 | - |
|
620 | - //Set the safari brand |
|
621 | - if(false !== $safari_brands && '' !== $safari_brands){ |
|
622 | - $this->set_safari_brands($id,$safari_brands); |
|
623 | - |
|
624 | - } |
|
625 | - |
|
626 | - if(false !== $importable_content && in_array('location',$importable_content)){ |
|
627 | - $this->set_map_data($data,$id); |
|
628 | - $this->set_location_taxonomy($data,$id); |
|
629 | - } |
|
630 | - |
|
631 | - if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){ |
|
632 | - $this->connect_destinations($data,$id); |
|
633 | - } |
|
634 | - |
|
635 | - if(false !== $importable_content && in_array('category',$importable_content)){ |
|
636 | - $this->set_taxonomy_style($data,$id); |
|
637 | - } |
|
638 | - |
|
639 | - //Set the Room Data |
|
640 | - if(false !== $importable_content && in_array('rooms',$importable_content)){ |
|
641 | - $this->set_room_data($data,$id); |
|
642 | - } |
|
643 | - |
|
644 | - //Set the rating |
|
645 | - if(false !== $importable_content && in_array('rating',$importable_content)){ |
|
646 | - $this->set_rating($data,$id); |
|
647 | - } |
|
648 | - |
|
649 | - //Set the checkin checkout data |
|
650 | - if(false !== $importable_content && in_array('checkin',$importable_content)){ |
|
651 | - $this->set_checkin_checkout($data,$id); |
|
652 | - } |
|
653 | - |
|
654 | - //Set the Spoken Languages |
|
655 | - if(false !== $importable_content && in_array('spoken_languages',$importable_content)){ |
|
656 | - $this->set_spoken_languages($data,$id); |
|
657 | - } |
|
658 | - |
|
659 | - //Set the friendly options |
|
660 | - if(false !== $importable_content && in_array('friendly',$importable_content)){ |
|
661 | - $this->set_friendly($data,$id); |
|
662 | - } |
|
663 | - |
|
664 | - //Set the special_interests |
|
665 | - if(false !== $importable_content && in_array('special_interests',$importable_content)){ |
|
666 | - $this->set_special_interests($data,$id); |
|
667 | - } |
|
668 | - |
|
669 | - //Import the videos |
|
670 | - if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
671 | - $this->set_video_data($data,$id); |
|
672 | - } |
|
673 | - |
|
674 | - //Import the facilities |
|
675 | - if(false !== $importable_content && in_array('facilities',$importable_content)){ |
|
676 | - $this->set_facilities($data,$id); |
|
677 | - } |
|
678 | - |
|
679 | - //Set the featured image |
|
680 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
681 | - $this->set_featured_image($data,$id); |
|
682 | - } |
|
683 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
684 | - $this->set_banner_image($data,$id); |
|
685 | - } |
|
686 | - //Import the main gallery |
|
687 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
688 | - $this->create_main_gallery($data,$id); |
|
689 | - } |
|
690 | - } |
|
691 | - return $id; |
|
615 | + //Set the team member if it is there |
|
616 | + if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
617 | + $this->set_team_member($id,$team_members); |
|
618 | + } |
|
619 | + |
|
620 | + //Set the safari brand |
|
621 | + if(false !== $safari_brands && '' !== $safari_brands){ |
|
622 | + $this->set_safari_brands($id,$safari_brands); |
|
623 | + |
|
624 | + } |
|
625 | + |
|
626 | + if(false !== $importable_content && in_array('location',$importable_content)){ |
|
627 | + $this->set_map_data($data,$id); |
|
628 | + $this->set_location_taxonomy($data,$id); |
|
629 | + } |
|
630 | + |
|
631 | + if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){ |
|
632 | + $this->connect_destinations($data,$id); |
|
633 | + } |
|
634 | + |
|
635 | + if(false !== $importable_content && in_array('category',$importable_content)){ |
|
636 | + $this->set_taxonomy_style($data,$id); |
|
637 | + } |
|
638 | + |
|
639 | + //Set the Room Data |
|
640 | + if(false !== $importable_content && in_array('rooms',$importable_content)){ |
|
641 | + $this->set_room_data($data,$id); |
|
642 | + } |
|
643 | + |
|
644 | + //Set the rating |
|
645 | + if(false !== $importable_content && in_array('rating',$importable_content)){ |
|
646 | + $this->set_rating($data,$id); |
|
647 | + } |
|
648 | + |
|
649 | + //Set the checkin checkout data |
|
650 | + if(false !== $importable_content && in_array('checkin',$importable_content)){ |
|
651 | + $this->set_checkin_checkout($data,$id); |
|
652 | + } |
|
653 | + |
|
654 | + //Set the Spoken Languages |
|
655 | + if(false !== $importable_content && in_array('spoken_languages',$importable_content)){ |
|
656 | + $this->set_spoken_languages($data,$id); |
|
657 | + } |
|
658 | + |
|
659 | + //Set the friendly options |
|
660 | + if(false !== $importable_content && in_array('friendly',$importable_content)){ |
|
661 | + $this->set_friendly($data,$id); |
|
662 | + } |
|
663 | + |
|
664 | + //Set the special_interests |
|
665 | + if(false !== $importable_content && in_array('special_interests',$importable_content)){ |
|
666 | + $this->set_special_interests($data,$id); |
|
667 | + } |
|
668 | + |
|
669 | + //Import the videos |
|
670 | + if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
671 | + $this->set_video_data($data,$id); |
|
672 | + } |
|
673 | + |
|
674 | + //Import the facilities |
|
675 | + if(false !== $importable_content && in_array('facilities',$importable_content)){ |
|
676 | + $this->set_facilities($data,$id); |
|
677 | + } |
|
678 | + |
|
679 | + //Set the featured image |
|
680 | + if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
681 | + $this->set_featured_image($data,$id); |
|
682 | + } |
|
683 | + if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
684 | + $this->set_banner_image($data,$id); |
|
685 | + } |
|
686 | + //Import the main gallery |
|
687 | + if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
688 | + $this->create_main_gallery($data,$id); |
|
689 | + } |
|
690 | + } |
|
691 | + return $id; |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | /** |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | |
699 | 699 | delete_post_meta($id, 'team_to_'.$this->tab_slug); |
700 | 700 | foreach($team_members as $team){ |
701 | - add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
701 | + add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
702 | 702 | } |
703 | 703 | } |
704 | 704 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | */ |
708 | 708 | public function set_safari_brands($id,$safari_brands) { |
709 | 709 | foreach($safari_brands as $safari_brand){ |
710 | - wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true); |
|
710 | + wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true); |
|
711 | 711 | } |
712 | 712 | } |
713 | 713 | |
@@ -759,11 +759,11 @@ discard block |
||
759 | 759 | 'elevation' => '', |
760 | 760 | ); |
761 | 761 | if(false !== $id && '0' !== $id){ |
762 | - $prev = get_post_meta($id,'location',true); |
|
763 | - update_post_meta($id,'location',$location_data,$prev); |
|
764 | - }else{ |
|
765 | - add_post_meta($id,'location',$location_data,true); |
|
766 | - } |
|
762 | + $prev = get_post_meta($id,'location',true); |
|
763 | + update_post_meta($id,'location',$location_data,$prev); |
|
764 | + }else{ |
|
765 | + add_post_meta($id,'location',$location_data,true); |
|
766 | + } |
|
767 | 767 | } |
768 | 768 | } |
769 | 769 | /** |
@@ -777,35 +777,35 @@ discard block |
||
777 | 777 | if(isset($data[0]['position']['country'])){ |
778 | 778 | |
779 | 779 | if(!$term = term_exists(trim($data[0]['position']['country']), 'location')) |
780 | - { |
|
781 | - $term = wp_insert_term(trim($data[0]['position']['country']), 'location'); |
|
782 | - if ( is_wp_error($term) ){ |
|
783 | - echo $term->get_error_message(); |
|
784 | - } |
|
785 | - else { |
|
786 | - wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
787 | - } |
|
788 | - } |
|
789 | - else |
|
790 | - { |
|
791 | - wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
792 | - } |
|
793 | - $country_id = intval($term['term_id']); |
|
794 | - } |
|
780 | + { |
|
781 | + $term = wp_insert_term(trim($data[0]['position']['country']), 'location'); |
|
782 | + if ( is_wp_error($term) ){ |
|
783 | + echo $term->get_error_message(); |
|
784 | + } |
|
785 | + else { |
|
786 | + wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
787 | + } |
|
788 | + } |
|
789 | + else |
|
790 | + { |
|
791 | + wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
792 | + } |
|
793 | + $country_id = intval($term['term_id']); |
|
794 | + } |
|
795 | 795 | |
796 | 796 | if(isset($data[0]['position']['destination'])){ |
797 | 797 | |
798 | 798 | $tax_args = array('parent'=>$country_id); |
799 | 799 | if(!$term = term_exists(trim($data[0]['position']['destination']), 'location')) |
800 | - { |
|
801 | - $term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args); |
|
802 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
803 | - else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); } |
|
804 | - } |
|
805 | - else |
|
806 | - { |
|
807 | - wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
808 | - } |
|
800 | + { |
|
801 | + $term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args); |
|
802 | + if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
803 | + else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); } |
|
804 | + } |
|
805 | + else |
|
806 | + { |
|
807 | + wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
808 | + } |
|
809 | 809 | } |
810 | 810 | } |
811 | 811 | } |
@@ -815,28 +815,28 @@ discard block |
||
815 | 815 | */ |
816 | 816 | public function connect_destinations($data,$id) { |
817 | 817 | if(isset($data[0]['position'])){ |
818 | - $destinations = false; |
|
819 | - if(isset($data[0]['position']['country'])){ |
|
820 | - $destinations['country'] = $data[0]['position']['country']; |
|
821 | - } |
|
822 | - if(isset($data[0]['position']['destination'])){ |
|
823 | - $destinations['destination'] = $data[0]['position']['destination']; |
|
824 | - } |
|
818 | + $destinations = false; |
|
819 | + if(isset($data[0]['position']['country'])){ |
|
820 | + $destinations['country'] = $data[0]['position']['country']; |
|
821 | + } |
|
822 | + if(isset($data[0]['position']['destination'])){ |
|
823 | + $destinations['destination'] = $data[0]['position']['destination']; |
|
824 | + } |
|
825 | 825 | |
826 | - if(false !== $destinations){ |
|
827 | - $prev_values = get_post_meta($id,'destination_to_accommodation',false); |
|
828 | - if(false === $prev_values || !is_array($prev_values)){ |
|
829 | - $prev_values = array(); |
|
830 | - } |
|
831 | - foreach($destinations as $key => $value){ |
|
832 | - $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
|
833 | - if (null !== $destination) { |
|
834 | - if(!in_array($destination->ID,$prev_values)){ |
|
835 | - add_post_meta($id,'destination_to_accommodation',$destination->ID,false); |
|
836 | - add_post_meta($destination->ID,'accommodation_to_destination',$id,false); |
|
837 | - } |
|
838 | - } |
|
839 | - } |
|
826 | + if(false !== $destinations){ |
|
827 | + $prev_values = get_post_meta($id,'destination_to_accommodation',false); |
|
828 | + if(false === $prev_values || !is_array($prev_values)){ |
|
829 | + $prev_values = array(); |
|
830 | + } |
|
831 | + foreach($destinations as $key => $value){ |
|
832 | + $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
|
833 | + if (null !== $destination) { |
|
834 | + if(!in_array($destination->ID,$prev_values)){ |
|
835 | + add_post_meta($id,'destination_to_accommodation',$destination->ID,false); |
|
836 | + add_post_meta($destination->ID,'accommodation_to_destination',$id,false); |
|
837 | + } |
|
838 | + } |
|
839 | + } |
|
840 | 840 | } |
841 | 841 | } |
842 | 842 | } |
@@ -848,15 +848,15 @@ discard block |
||
848 | 848 | $terms = false; |
849 | 849 | if(isset($data[0]['category'])){ |
850 | 850 | if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) |
851 | - { |
|
852 | - $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type'); |
|
853 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
854 | - else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); } |
|
855 | - } |
|
856 | - else |
|
857 | - { |
|
858 | - wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); |
|
859 | - } |
|
851 | + { |
|
852 | + $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type'); |
|
853 | + if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
854 | + else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); } |
|
855 | + } |
|
856 | + else |
|
857 | + { |
|
858 | + wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); |
|
859 | + } |
|
860 | 860 | } |
861 | 861 | } |
862 | 862 | |
@@ -880,25 +880,25 @@ discard block |
||
880 | 880 | $temp_room['type'] = 'room'; |
881 | 881 | |
882 | 882 | if(!empty($room['images']) && is_array($room['images'])){ |
883 | - $attachments_args = array( |
|
884 | - 'post_parent' => $id, |
|
885 | - 'post_status' => 'inherit', |
|
886 | - 'post_type' => 'attachment', |
|
887 | - 'order' => 'ASC', |
|
888 | - ); |
|
889 | - $attachments = new WP_Query($attachments_args); |
|
890 | - $found_attachments = array(); |
|
891 | - |
|
892 | - if($attachments->have_posts()){ |
|
893 | - foreach($attachments->posts as $attachment){ |
|
894 | - $found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
895 | - } |
|
896 | - } |
|
883 | + $attachments_args = array( |
|
884 | + 'post_parent' => $id, |
|
885 | + 'post_status' => 'inherit', |
|
886 | + 'post_type' => 'attachment', |
|
887 | + 'order' => 'ASC', |
|
888 | + ); |
|
889 | + $attachments = new WP_Query($attachments_args); |
|
890 | + $found_attachments = array(); |
|
891 | + |
|
892 | + if($attachments->have_posts()){ |
|
893 | + foreach($attachments->posts as $attachment){ |
|
894 | + $found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
895 | + } |
|
896 | + } |
|
897 | 897 | |
898 | 898 | $temp_room['gallery'] = array(); |
899 | 899 | foreach($room['images'] as $image_data){ |
900 | - $temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments); |
|
901 | - } |
|
900 | + $temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments); |
|
901 | + } |
|
902 | 902 | } |
903 | 903 | $rooms[] = $temp_room; |
904 | 904 | } |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | delete_post_meta($id, 'units'); |
908 | 908 | } |
909 | 909 | foreach($rooms as $room){ |
910 | - add_post_meta($id,'units',$room,false); |
|
910 | + add_post_meta($id,'units',$room,false); |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){ |
@@ -917,11 +917,11 @@ discard block |
||
917 | 917 | } |
918 | 918 | |
919 | 919 | if(false !== $id && '0' !== $id){ |
920 | - $prev_rooms = get_post_meta($id,'number_of_rooms',true); |
|
921 | - update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms); |
|
922 | - }else{ |
|
923 | - add_post_meta($id,'number_of_rooms',$room_count,true); |
|
924 | - } |
|
920 | + $prev_rooms = get_post_meta($id,'number_of_rooms',true); |
|
921 | + update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms); |
|
922 | + }else{ |
|
923 | + add_post_meta($id,'number_of_rooms',$room_count,true); |
|
924 | + } |
|
925 | 925 | } |
926 | 926 | } |
927 | 927 | |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | delete_post_meta($id, 'videos'); |
1031 | 1031 | } |
1032 | 1032 | foreach($videos as $video){ |
1033 | - add_post_meta($id,'videos',$video,false); |
|
1033 | + add_post_meta($id,'videos',$video,false); |
|
1034 | 1034 | } |
1035 | 1035 | } |
1036 | 1036 | } |
@@ -1059,17 +1059,17 @@ discard block |
||
1059 | 1059 | |
1060 | 1060 | function set_term($id=false,$name=false,$taxonomy=false,$parent=false){ |
1061 | 1061 | if(!$term = term_exists($name, $taxonomy)) |
1062 | - { |
|
1063 | - if(false !== $parent){ $parent = array('parent'=>$parent); } |
|
1064 | - $term = wp_insert_term(trim($name), $taxonomy,$parent); |
|
1065 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
1066 | - else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); } |
|
1067 | - } |
|
1068 | - else |
|
1069 | - { |
|
1070 | - wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
1071 | - } |
|
1072 | - return $term['term_id']; |
|
1062 | + { |
|
1063 | + if(false !== $parent){ $parent = array('parent'=>$parent); } |
|
1064 | + $term = wp_insert_term(trim($name), $taxonomy,$parent); |
|
1065 | + if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
1066 | + else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); } |
|
1067 | + } |
|
1068 | + else |
|
1069 | + { |
|
1070 | + wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
1071 | + } |
|
1072 | + return $term['term_id']; |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | /** |
@@ -1077,17 +1077,17 @@ discard block |
||
1077 | 1077 | */ |
1078 | 1078 | public function set_featured_image($data,$id) { |
1079 | 1079 | if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
1080 | - $this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id); |
|
1080 | + $this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id); |
|
1081 | 1081 | |
1082 | - if(false !== $this->featured_image){ |
|
1083 | - delete_post_meta($id,'_thumbnail_id'); |
|
1084 | - add_post_meta($id,'_thumbnail_id',$this->featured_image,true); |
|
1082 | + if(false !== $this->featured_image){ |
|
1083 | + delete_post_meta($id,'_thumbnail_id'); |
|
1084 | + add_post_meta($id,'_thumbnail_id',$this->featured_image,true); |
|
1085 | 1085 | |
1086 | - if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){ |
|
1087 | - add_post_meta($id,'gallery',$this->featured_image,false); |
|
1088 | - $this->gallery_meta[] = $this->featured_image; |
|
1089 | - } |
|
1090 | - } |
|
1086 | + if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){ |
|
1087 | + add_post_meta($id,'gallery',$this->featured_image,false); |
|
1088 | + $this->gallery_meta[] = $this->featured_image; |
|
1089 | + } |
|
1090 | + } |
|
1091 | 1091 | } |
1092 | 1092 | } |
1093 | 1093 | |
@@ -1096,18 +1096,18 @@ discard block |
||
1096 | 1096 | */ |
1097 | 1097 | public function set_banner_image($data,$id) { |
1098 | 1098 | if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
1099 | - $this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c')); |
|
1100 | - |
|
1101 | - if(false !== $this->banner_image){ |
|
1102 | - delete_post_meta($id,'image_group'); |
|
1103 | - $new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image)); |
|
1104 | - add_post_meta($id,'image_group',$new_banner,true); |
|
1105 | - |
|
1106 | - if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){ |
|
1107 | - add_post_meta($id,'gallery',$this->banner_image,false); |
|
1108 | - $this->gallery_meta[] = $this->banner_image; |
|
1109 | - } |
|
1110 | - } |
|
1099 | + $this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c')); |
|
1100 | + |
|
1101 | + if(false !== $this->banner_image){ |
|
1102 | + delete_post_meta($id,'image_group'); |
|
1103 | + $new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image)); |
|
1104 | + add_post_meta($id,'image_group',$new_banner,true); |
|
1105 | + |
|
1106 | + if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){ |
|
1107 | + add_post_meta($id,'gallery',$this->banner_image,false); |
|
1108 | + $this->gallery_meta[] = $this->banner_image; |
|
1109 | + } |
|
1110 | + } |
|
1111 | 1111 | } |
1112 | 1112 | } |
1113 | 1113 | |
@@ -1118,24 +1118,24 @@ discard block |
||
1118 | 1118 | |
1119 | 1119 | if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
1120 | 1120 | |
1121 | - $counter = 0; |
|
1122 | - foreach($data[0]['content']['images'] as $image_data){ |
|
1123 | - if($counter === 0 && false !== $this->featured_image){continue;} |
|
1124 | - if($counter === 1 && false !== $this->banner_image){continue;} |
|
1125 | - |
|
1126 | - $this->gallery_meta[] = $temp_id = $this->attach_image($image_data,$id); |
|
1127 | - $counter++; |
|
1128 | - } |
|
1129 | - |
|
1130 | - if(!empty($this->gallery_meta)){ |
|
1131 | - delete_post_meta($id,'gallery'); |
|
1132 | - foreach($this->gallery_meta as $gallery_id){ |
|
1133 | - if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){ |
|
1134 | - add_post_meta($id,'gallery',$gallery_id,false); |
|
1135 | - } |
|
1136 | - } |
|
1137 | - } |
|
1138 | - } |
|
1121 | + $counter = 0; |
|
1122 | + foreach($data[0]['content']['images'] as $image_data){ |
|
1123 | + if($counter === 0 && false !== $this->featured_image){continue;} |
|
1124 | + if($counter === 1 && false !== $this->banner_image){continue;} |
|
1125 | + |
|
1126 | + $this->gallery_meta[] = $temp_id = $this->attach_image($image_data,$id); |
|
1127 | + $counter++; |
|
1128 | + } |
|
1129 | + |
|
1130 | + if(!empty($this->gallery_meta)){ |
|
1131 | + delete_post_meta($id,'gallery'); |
|
1132 | + foreach($this->gallery_meta as $gallery_id){ |
|
1133 | + if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){ |
|
1134 | + add_post_meta($id,'gallery',$gallery_id,false); |
|
1135 | + } |
|
1136 | + } |
|
1137 | + } |
|
1138 | + } |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | /** |
@@ -1144,42 +1144,42 @@ discard block |
||
1144 | 1144 | public function attach_image($v=false,$parent_id,$image_sizes=false){ |
1145 | 1145 | if(false !== $v){ |
1146 | 1146 | $temp_fragment = explode('/',$v['url_fragment']); |
1147 | - $url_filename = $temp_fragment[count($temp_fragment)-1]; |
|
1148 | - $url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename); |
|
1147 | + $url_filename = $temp_fragment[count($temp_fragment)-1]; |
|
1148 | + $url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename); |
|
1149 | 1149 | |
1150 | - if(in_array($url_filename,$this->found_attachments)){ |
|
1151 | - return array_search($url_filename,$this->found_attachments); |
|
1152 | - } |
|
1150 | + if(in_array($url_filename,$this->found_attachments)){ |
|
1151 | + return array_search($url_filename,$this->found_attachments); |
|
1152 | + } |
|
1153 | 1153 | |
1154 | - $postdata=array(); |
|
1155 | - if(empty($v['label'])) |
|
1156 | - { |
|
1157 | - $v['label']=''; |
|
1158 | - } |
|
1159 | - if(!empty($v['description'])) |
|
1160 | - { |
|
1161 | - $desc=wp_strip_all_tags($v['description']); |
|
1162 | - $posdata=array('post_excerpt'=>$desc); |
|
1163 | - } |
|
1164 | - if(!empty($v['section'])) |
|
1165 | - { |
|
1166 | - $desc=wp_strip_all_tags($v['section']); |
|
1167 | - $posdata=array('post_excerpt'=>$desc); |
|
1168 | - } |
|
1169 | - |
|
1170 | - $attachID=NULL; |
|
1171 | - //Resizor - add option to setting if required |
|
1172 | - $fragment = str_replace(' ','%20',$v['url_fragment']); |
|
1173 | - $url = $this->get_scaling_url($image_sizes).$fragment; |
|
1174 | - $attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata); |
|
1175 | - |
|
1176 | - //echo($attachID.' add image'); |
|
1177 | - if($attachID!=NULL) |
|
1178 | - { |
|
1179 | - return $attachID; |
|
1180 | - } |
|
1181 | - } |
|
1182 | - return false; |
|
1154 | + $postdata=array(); |
|
1155 | + if(empty($v['label'])) |
|
1156 | + { |
|
1157 | + $v['label']=''; |
|
1158 | + } |
|
1159 | + if(!empty($v['description'])) |
|
1160 | + { |
|
1161 | + $desc=wp_strip_all_tags($v['description']); |
|
1162 | + $posdata=array('post_excerpt'=>$desc); |
|
1163 | + } |
|
1164 | + if(!empty($v['section'])) |
|
1165 | + { |
|
1166 | + $desc=wp_strip_all_tags($v['section']); |
|
1167 | + $posdata=array('post_excerpt'=>$desc); |
|
1168 | + } |
|
1169 | + |
|
1170 | + $attachID=NULL; |
|
1171 | + //Resizor - add option to setting if required |
|
1172 | + $fragment = str_replace(' ','%20',$v['url_fragment']); |
|
1173 | + $url = $this->get_scaling_url($image_sizes).$fragment; |
|
1174 | + $attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata); |
|
1175 | + |
|
1176 | + //echo($attachID.' add image'); |
|
1177 | + if($attachID!=NULL) |
|
1178 | + { |
|
1179 | + return $attachID; |
|
1180 | + } |
|
1181 | + } |
|
1182 | + return false; |
|
1183 | 1183 | } |
1184 | 1184 | public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) { |
1185 | 1185 |
@@ -55,15 +55,15 @@ discard block |
||
55 | 55 | public function __construct() { |
56 | 56 | $this->set_variables(); |
57 | 57 | |
58 | - add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') ); |
|
59 | - add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search')); |
|
60 | - add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search')); |
|
58 | + add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page')); |
|
59 | + add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
60 | + add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
61 | 61 | |
62 | - add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import')); |
|
63 | - add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import')); |
|
62 | + add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import')); |
|
63 | + add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import')); |
|
64 | 64 | |
65 | - $temp_options = get_option('_lsx-to_settings',false); |
|
66 | - if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){ |
|
65 | + $temp_options = get_option('_lsx-to_settings', false); |
|
66 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
67 | 67 | $this->options = $temp_options[$this->plugin_slug]; |
68 | 68 | } |
69 | 69 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | // $this->url = 'https://wetu.com/API/Pins/'; |
81 | 81 | // $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
82 | 82 | //} elseif ( false !== $this->api_key ) { |
83 | - $this->url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
83 | + $this->url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
84 | 84 | $this->url_qs = ''; |
85 | 85 | //} |
86 | 86 | } |
@@ -88,27 +88,27 @@ discard block |
||
88 | 88 | /** |
89 | 89 | * search_form |
90 | 90 | */ |
91 | - public function get_scaling_url($args=array()) { |
|
91 | + public function get_scaling_url($args = array()) { |
|
92 | 92 | |
93 | 93 | $defaults = array( |
94 | 94 | 'width' => '640', |
95 | 95 | 'height' => '480', |
96 | 96 | 'cropping' => 'c' |
97 | 97 | ); |
98 | - if(false !== $this->options){ |
|
99 | - if(isset($this->options['width']) && '' !== $this->options['width']){ |
|
98 | + if (false !== $this->options) { |
|
99 | + if (isset($this->options['width']) && '' !== $this->options['width']) { |
|
100 | 100 | $defaults['width'] = $this->options['width']; |
101 | 101 | } |
102 | 102 | |
103 | - if(isset($this->options['height']) && '' !== $this->options['height']){ |
|
103 | + if (isset($this->options['height']) && '' !== $this->options['height']) { |
|
104 | 104 | $defaults['height'] = $this->options['height']; |
105 | 105 | } |
106 | 106 | |
107 | - if(isset($this->options['cropping']) && '' !== $this->options['cropping']){ |
|
107 | + if (isset($this->options['cropping']) && '' !== $this->options['cropping']) { |
|
108 | 108 | $defaults['cropping'] = $this->options['cropping']; |
109 | 109 | } |
110 | 110 | } |
111 | - $args = wp_parse_args($args,$defaults); |
|
111 | + $args = wp_parse_args($args, $defaults); |
|
112 | 112 | |
113 | 113 | $cropping = $args['cropping']; |
114 | 114 | $width = $args['width']; |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | <form method="get" action="" id="posts-filter"> |
134 | 134 | <input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" /> |
135 | 135 | |
136 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
137 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
136 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
137 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
138 | 138 | </p> |
139 | 139 | |
140 | 140 | <table class="wp-list-table widefat fixed posts"> |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | <tbody id="the-list"> |
144 | 144 | <tr class="post-0 type-tour status-none" id="post-0"> |
145 | 145 | <th class="check-column" scope="row"> |
146 | - <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label> |
|
146 | + <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label> |
|
147 | 147 | </th> |
148 | 148 | <td class="post-title page-title column-title"> |
149 | 149 | <strong> |
150 | - <?php _e('Enter a title to search for','wetu-importer'); ?> |
|
150 | + <?php _e('Enter a title to search for', 'wetu-importer'); ?> |
|
151 | 151 | </strong> |
152 | 152 | </td> |
153 | 153 | <td class="date column-date"> |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | |
162 | 162 | </table> |
163 | 163 | |
164 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
165 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
164 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
165 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
166 | 166 | </p> |
167 | 167 | </form> |
168 | 168 | |
@@ -174,31 +174,31 @@ discard block |
||
174 | 174 | <div style="width:30%;display:block;float:left;"> |
175 | 175 | <h3><?php _e('What content to Sync from WETU'); ?></h3> |
176 | 176 | <ul> |
177 | - <li><input class="content" type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
178 | - <li><input class="content" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li> |
|
179 | - <li><input class="content" type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery','wetu-importer'); ?></li> |
|
180 | - <li><input class="content" type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li> |
|
181 | - <?php if(class_exists('TO_Maps')){ ?> |
|
182 | - <li><input class="content" type="checkbox" name="content[]" value="location" /> <?php _e('Location','wetu-importer'); ?></li> |
|
177 | + <li><input class="content" type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
178 | + <li><input class="content" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li> |
|
179 | + <li><input class="content" type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery', 'wetu-importer'); ?></li> |
|
180 | + <li><input class="content" type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li> |
|
181 | + <?php if (class_exists('TO_Maps')) { ?> |
|
182 | + <li><input class="content" type="checkbox" name="content[]" value="location" /> <?php _e('Location', 'wetu-importer'); ?></li> |
|
183 | 183 | <?php } ?> |
184 | - <li><input class="content" type="checkbox" name="content[]" value="destination" /> <?php _e('Connect Destinations','wetu-importer'); ?></li> |
|
185 | - <li><input class="content" type="checkbox" name="content[]" value="checkin" /> <?php _e('Check In / Check Out','wetu-importer'); ?></li> |
|
186 | - <li><input class="content" type="checkbox" name="content[]" value="facilities" /> <?php _e('Facilities','wetu-importer'); ?></li> |
|
187 | - <li><input class="content" type="checkbox" name="content[]" value="friendly" /> <?php _e('Friendly','wetu-importer'); ?></li> |
|
188 | - <li><input class="content" type="checkbox" name="content[]" value="rating" /> <?php _e('Rating','wetu-importer'); ?></li> |
|
189 | - <li><input class="content" type="checkbox" name="content[]" value="rooms" /> <?php _e('Rooms','wetu-importer'); ?></li> |
|
190 | - <li><input class="content" type="checkbox" name="content[]" value="special_interests" /> <?php _e('Special Interests','wetu-importer'); ?></li> |
|
191 | - <li><input class="content" type="checkbox" name="content[]" value="spoken_languages" /> <?php _e('Spoken Languages','wetu-importer'); ?></li> |
|
192 | - |
|
193 | - <?php if(class_exists('TO_Videos')){ ?> |
|
194 | - <li><input class="content" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos','wetu-importer'); ?></li> |
|
184 | + <li><input class="content" type="checkbox" name="content[]" value="destination" /> <?php _e('Connect Destinations', 'wetu-importer'); ?></li> |
|
185 | + <li><input class="content" type="checkbox" name="content[]" value="checkin" /> <?php _e('Check In / Check Out', 'wetu-importer'); ?></li> |
|
186 | + <li><input class="content" type="checkbox" name="content[]" value="facilities" /> <?php _e('Facilities', 'wetu-importer'); ?></li> |
|
187 | + <li><input class="content" type="checkbox" name="content[]" value="friendly" /> <?php _e('Friendly', 'wetu-importer'); ?></li> |
|
188 | + <li><input class="content" type="checkbox" name="content[]" value="rating" /> <?php _e('Rating', 'wetu-importer'); ?></li> |
|
189 | + <li><input class="content" type="checkbox" name="content[]" value="rooms" /> <?php _e('Rooms', 'wetu-importer'); ?></li> |
|
190 | + <li><input class="content" type="checkbox" name="content[]" value="special_interests" /> <?php _e('Special Interests', 'wetu-importer'); ?></li> |
|
191 | + <li><input class="content" type="checkbox" name="content[]" value="spoken_languages" /> <?php _e('Spoken Languages', 'wetu-importer'); ?></li> |
|
192 | + |
|
193 | + <?php if (class_exists('TO_Videos')) { ?> |
|
194 | + <li><input class="content" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos', 'wetu-importer'); ?></li> |
|
195 | 195 | <?php } ?> |
196 | 196 | </ul> |
197 | 197 | <h4><?php _e('Additional Content'); ?></h4> |
198 | 198 | <ul> |
199 | - <li><input class="content" type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image','wetu-importer'); ?></li> |
|
200 | - <?php if(class_exists('LSX_Banners')){ ?> |
|
201 | - <li><input class="content" type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image','wetu-importer'); ?></li> |
|
199 | + <li><input class="content" type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image', 'wetu-importer'); ?></li> |
|
200 | + <?php if (class_exists('LSX_Banners')) { ?> |
|
201 | + <li><input class="content" type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image', 'wetu-importer'); ?></li> |
|
202 | 202 | <?php } ?> |
203 | 203 | </ul> |
204 | 204 | </div> |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | |
218 | 218 | |
219 | 219 | <h3><?php _e('Your List'); ?></h3> |
220 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
220 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
221 | 221 | <table class="wp-list-table widefat fixed posts"> |
222 | 222 | <?php $this->table_header(); ?> |
223 | 223 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | |
230 | 230 | </table> |
231 | 231 | |
232 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
232 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
233 | 233 | </form> |
234 | 234 | </div> |
235 | 235 | |
@@ -250,30 +250,30 @@ discard block |
||
250 | 250 | <form class="ajax-form" id="<?php echo $this->plugin_slug; ?>-search-form" method="get" action="tools.php" data-type="<?php echo $this->tab_slug; ?>"> |
251 | 251 | <input type="hidden" name="page" value="<?php echo $this->tab_slug; ?>" /> |
252 | 252 | |
253 | - <h3><span class="dashicons dashicons-search"></span> <?php _e('Search','wetu-importer'); ?></h3> |
|
253 | + <h3><span class="dashicons dashicons-search"></span> <?php _e('Search', 'wetu-importer'); ?></h3> |
|
254 | 254 | <div class="normal-search"> |
255 | - <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" /> |
|
255 | + <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" /> |
|
256 | 256 | </div> |
257 | 257 | <div class="advanced-search hidden" style="display:none;"> |
258 | - <p><?php _e('Enter several keywords, each on a new line.','wetu-importer'); ?></p> |
|
258 | + <p><?php _e('Enter several keywords, each on a new line.', 'wetu-importer'); ?></p> |
|
259 | 259 | <textarea rows="10" cols="40" name="bulk-keywords"></textarea> |
260 | - <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" /> |
|
260 | + <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" /> |
|
261 | 261 | </div> |
262 | 262 | |
263 | 263 | <p> |
264 | - <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search','wetu-importer'); ?></a> | |
|
265 | - <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published','wetu-importer'); ?></a> | |
|
266 | - <a class="pending search-toggle" href="#pending"><?php esc_attr_e('Pending','wetu-importer'); ?></a> | |
|
267 | - <a class="draft search-toggle" href="#draft"><?php esc_attr_e('Draft','wetu-importer'); ?></a> | |
|
268 | - <a class="import search-toggle" href="#import"><?php esc_attr_e('WETU','wetu-importer'); ?></a> |
|
264 | + <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search', 'wetu-importer'); ?></a> | |
|
265 | + <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published', 'wetu-importer'); ?></a> | |
|
266 | + <a class="pending search-toggle" href="#pending"><?php esc_attr_e('Pending', 'wetu-importer'); ?></a> | |
|
267 | + <a class="draft search-toggle" href="#draft"><?php esc_attr_e('Draft', 'wetu-importer'); ?></a> | |
|
268 | + <a class="import search-toggle" href="#import"><?php esc_attr_e('WETU', 'wetu-importer'); ?></a> |
|
269 | 269 | </p> |
270 | 270 | |
271 | 271 | <div class="ajax-loader" style="display:none;width:100%;text-align:center;"> |
272 | - <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" /> |
|
272 | + <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" /> |
|
273 | 273 | </div> |
274 | 274 | |
275 | 275 | <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;"> |
276 | - <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" /> |
|
276 | + <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" /> |
|
277 | 277 | </div> |
278 | 278 | </form> |
279 | 279 | <?php |
@@ -283,9 +283,9 @@ discard block |
||
283 | 283 | * search_form |
284 | 284 | */ |
285 | 285 | public function update_options_form() { |
286 | - echo '<div style="display:none;" class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').'</h3>'; |
|
286 | + echo '<div style="display:none;" class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').'</h3>'; |
|
287 | 287 | $accommodation = get_transient('lsx_ti_accommodation'); |
288 | - if('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])){ |
|
288 | + if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) { |
|
289 | 289 | $this->update_options(); |
290 | 290 | } |
291 | 291 | echo '</div>'; |
@@ -296,13 +296,13 @@ discard block |
||
296 | 296 | * Save the list of Accommodation into an option |
297 | 297 | */ |
298 | 298 | public function update_options() { |
299 | - $data = file_get_contents( $this->url . '/List?' . $this->url_qs ); |
|
299 | + $data = file_get_contents($this->url.'/List?'.$this->url_qs); |
|
300 | 300 | $accommodation = json_decode($data, true); |
301 | 301 | |
302 | - if(isset($accommodation['error'])){ |
|
302 | + if (isset($accommodation['error'])) { |
|
303 | 303 | return $accommodation['error']; |
304 | 304 | }elseif (isset($accommodation) && !empty($accommodation)) { |
305 | - set_transient('lsx_ti_accommodation',$accommodation,60*60*2); |
|
305 | + set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2); |
|
306 | 306 | return true; |
307 | 307 | } |
308 | 308 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | /** |
311 | 311 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
312 | 312 | */ |
313 | - public function find_current_accommodation($post_type='accommodation') { |
|
313 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
314 | 314 | global $wpdb; |
315 | 315 | $return = array(); |
316 | 316 | |
@@ -326,8 +326,8 @@ discard block |
||
326 | 326 | |
327 | 327 | LIMIT 0,500 |
328 | 328 | "); |
329 | - if(null !== $current_accommodation && !empty($current_accommodation)){ |
|
330 | - foreach($current_accommodation as $accom){ |
|
329 | + if (null !== $current_accommodation && !empty($current_accommodation)) { |
|
330 | + foreach ($current_accommodation as $accom) { |
|
331 | 331 | $return[$accom->meta_value] = $accom; |
332 | 332 | } |
333 | 333 | } |
@@ -339,37 +339,37 @@ discard block |
||
339 | 339 | */ |
340 | 340 | public function process_ajax_search() { |
341 | 341 | $return = false; |
342 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation'){ |
|
342 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation') { |
|
343 | 343 | $accommodation = get_transient('lsx_ti_accommodation'); |
344 | 344 | |
345 | - if ( false !== $accommodation ) { |
|
345 | + if (false !== $accommodation) { |
|
346 | 346 | $searched_items = false; |
347 | 347 | |
348 | - if(isset($_POST['keyword'] )) { |
|
348 | + if (isset($_POST['keyword'])) { |
|
349 | 349 | $keyphrases = $_POST['keyword']; |
350 | - }else{ |
|
350 | + }else { |
|
351 | 351 | $keyphrases = array(0); |
352 | 352 | } |
353 | 353 | |
354 | - if(!is_array($keyphrases)){ |
|
354 | + if (!is_array($keyphrases)) { |
|
355 | 355 | $keyphrases = array($keyphrases); |
356 | 356 | } |
357 | - foreach($keyphrases as &$keyword){ |
|
357 | + foreach ($keyphrases as &$keyword) { |
|
358 | 358 | $keyword = ltrim(rtrim($keyword)); |
359 | 359 | } |
360 | 360 | |
361 | 361 | |
362 | 362 | $post_status = false; |
363 | - if(in_array('publish',$keyphrases)){ |
|
363 | + if (in_array('publish', $keyphrases)) { |
|
364 | 364 | $post_status = 'publish'; |
365 | 365 | } |
366 | - if(in_array('pending',$keyphrases)){ |
|
366 | + if (in_array('pending', $keyphrases)) { |
|
367 | 367 | $post_status = 'pending'; |
368 | 368 | } |
369 | - if(in_array('draft',$keyphrases)){ |
|
369 | + if (in_array('draft', $keyphrases)) { |
|
370 | 370 | $post_status = 'draft'; |
371 | 371 | } |
372 | - if(in_array('import',$keyphrases)){ |
|
372 | + if (in_array('import', $keyphrases)) { |
|
373 | 373 | $post_status = 'import'; |
374 | 374 | } |
375 | 375 | |
@@ -377,33 +377,33 @@ discard block |
||
377 | 377 | |
378 | 378 | $current_accommodation = $this->find_current_accommodation(); |
379 | 379 | |
380 | - foreach($accommodation as $row_key => $row){ |
|
380 | + foreach ($accommodation as $row_key => $row) { |
|
381 | 381 | |
382 | 382 | //If this is a current tour, add its ID to the row. |
383 | 383 | $row['post_id'] = 0; |
384 | - if(false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)){ |
|
384 | + if (false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)) { |
|
385 | 385 | $row['post_id'] = $current_accommodation[$row['id']]->post_id; |
386 | 386 | } |
387 | 387 | |
388 | 388 | //If we are searching for |
389 | - if(false !== $post_status){ |
|
389 | + if (false !== $post_status) { |
|
390 | 390 | |
391 | - if('import' === $post_status){ |
|
391 | + if ('import' === $post_status) { |
|
392 | 392 | |
393 | - if(0 !== $row['post_id']){ |
|
393 | + if (0 !== $row['post_id']) { |
|
394 | 394 | continue; |
395 | - }else{ |
|
395 | + }else { |
|
396 | 396 | $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
397 | 397 | } |
398 | 398 | |
399 | 399 | |
400 | - }else{ |
|
400 | + }else { |
|
401 | 401 | |
402 | - if(0 === $row['post_id']){ |
|
402 | + if (0 === $row['post_id']) { |
|
403 | 403 | continue; |
404 | - }else{ |
|
404 | + }else { |
|
405 | 405 | $current_status = get_post_status($row['post_id']); |
406 | - if($current_status !== $post_status){ |
|
406 | + if ($current_status !== $post_status) { |
|
407 | 407 | continue; |
408 | 408 | } |
409 | 409 | |
@@ -411,17 +411,17 @@ discard block |
||
411 | 411 | $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
412 | 412 | } |
413 | 413 | |
414 | - }else{ |
|
414 | + }else { |
|
415 | 415 | //Search through each keyword. |
416 | - foreach($keyphrases as $keyphrase){ |
|
416 | + foreach ($keyphrases as $keyphrase) { |
|
417 | 417 | |
418 | 418 | //Make sure the keyphrase is turned into an array |
419 | - $keywords = explode(" ",$keyphrase); |
|
420 | - if(!is_array($keywords)){ |
|
419 | + $keywords = explode(" ", $keyphrase); |
|
420 | + if (!is_array($keywords)) { |
|
421 | 421 | $keywords = array($keywords); |
422 | 422 | } |
423 | 423 | |
424 | - if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){ |
|
424 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
425 | 425 | $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
426 | 426 | } |
427 | 427 | } |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | } |
431 | 431 | |
432 | 432 | |
433 | - if(false !== $searched_items){ |
|
433 | + if (false !== $searched_items) { |
|
434 | 434 | ksort($searched_items); |
435 | 435 | $return = implode($searched_items); |
436 | 436 | } |
@@ -443,17 +443,17 @@ discard block |
||
443 | 443 | /** |
444 | 444 | * Does a multine search |
445 | 445 | */ |
446 | - public function multineedle_stripos($haystack, $needles, $offset=0) { |
|
446 | + public function multineedle_stripos($haystack, $needles, $offset = 0) { |
|
447 | 447 | $found = false; |
448 | 448 | $needle_count = count($needles); |
449 | - foreach($needles as $needle) { |
|
450 | - if(false !== stripos($haystack, $needle, $offset)){ |
|
449 | + foreach ($needles as $needle) { |
|
450 | + if (false !== stripos($haystack, $needle, $offset)) { |
|
451 | 451 | $found[] = true; |
452 | 452 | } |
453 | 453 | } |
454 | - if(false !== $found && $needle_count === count($found)){ |
|
454 | + if (false !== $found && $needle_count === count($found)) { |
|
455 | 455 | return true; |
456 | - }else{ |
|
456 | + }else { |
|
457 | 457 | return false; |
458 | 458 | } |
459 | 459 | } |
@@ -461,11 +461,11 @@ discard block |
||
461 | 461 | /** |
462 | 462 | * Formats the row for output on the screen. |
463 | 463 | */ |
464 | - public function format_row($row = false){ |
|
465 | - if(false !== $row){ |
|
464 | + public function format_row($row = false) { |
|
465 | + if (false !== $row) { |
|
466 | 466 | |
467 | 467 | $status = 'import'; |
468 | - if(0 !== $row['post_id']){ |
|
468 | + if (0 !== $row['post_id']) { |
|
469 | 469 | $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
470 | 470 | } |
471 | 471 | |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | <strong>'.$row['name'].'</strong> - '.$status.' |
480 | 480 | </td> |
481 | 481 | <td class="date column-date"> |
482 | - <abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
482 | + <abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
483 | 483 | </td> |
484 | 484 | <td class="ssid column-ssid"> |
485 | 485 | '.$row['id'].' |
@@ -494,40 +494,40 @@ discard block |
||
494 | 494 | */ |
495 | 495 | public function process_ajax_import() { |
496 | 496 | $return = false; |
497 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])){ |
|
497 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])) { |
|
498 | 498 | |
499 | 499 | $wetu_id = $_POST['wetu_id']; |
500 | - if(isset($_POST['post_id'])){ |
|
500 | + if (isset($_POST['post_id'])) { |
|
501 | 501 | $post_id = $_POST['post_id']; |
502 | - }else{ |
|
502 | + }else { |
|
503 | 503 | $post_id = 0; |
504 | 504 | } |
505 | 505 | |
506 | - if(isset($_POST['team_members'])){ |
|
506 | + if (isset($_POST['team_members'])) { |
|
507 | 507 | $team_members = $_POST['team_members']; |
508 | - }else{ |
|
508 | + }else { |
|
509 | 509 | $team_members = false; |
510 | 510 | } |
511 | 511 | |
512 | - if(isset($_POST['safari_brands'])){ |
|
512 | + if (isset($_POST['safari_brands'])) { |
|
513 | 513 | $safari_brands = $_POST['safari_brands']; |
514 | - }else{ |
|
514 | + }else { |
|
515 | 515 | $safari_brands = false; |
516 | 516 | } |
517 | 517 | |
518 | - if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
|
518 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
519 | 519 | $content = $_POST['content']; |
520 | - }else{ |
|
520 | + }else { |
|
521 | 521 | $content = false; |
522 | 522 | } |
523 | 523 | |
524 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
525 | - if($jdata) |
|
524 | + $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id); |
|
525 | + if ($jdata) |
|
526 | 526 | { |
527 | - $adata=json_decode($jdata,true); |
|
528 | - if(!empty($adata)) |
|
527 | + $adata = json_decode($jdata, true); |
|
528 | + if (!empty($adata)) |
|
529 | 529 | { |
530 | - $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
530 | + $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
|
531 | 531 | $this->format_completed_row($return); |
532 | 532 | } |
533 | 533 | } |
@@ -539,15 +539,15 @@ discard block |
||
539 | 539 | /** |
540 | 540 | * Formats the row for the completed list. |
541 | 541 | */ |
542 | - public function format_completed_row($response){ |
|
542 | + public function format_completed_row($response) { |
|
543 | 543 | echo '<li class="post-'.$response.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($response).'">'.get_the_title($response).'</a></li>'; |
544 | 544 | } |
545 | 545 | /** |
546 | 546 | * Connect to wetu |
547 | 547 | */ |
548 | - public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) { |
|
548 | + public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false) { |
|
549 | 549 | |
550 | - if(trim($data[0]['type'])=='Accommodation') |
|
550 | + if (trim($data[0]['type']) == 'Accommodation') |
|
551 | 551 | { |
552 | 552 | $post_name = $data_post_content = $data_post_excerpt = ''; |
553 | 553 | $post = array( |
@@ -557,44 +557,44 @@ discard block |
||
557 | 557 | $content_used_general_description = false; |
558 | 558 | |
559 | 559 | //Set the post_content |
560 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
561 | - if(isset($data[0]['content']['extended_description'])) |
|
560 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
561 | + if (isset($data[0]['content']['extended_description'])) |
|
562 | 562 | { |
563 | 563 | $data_post_content = $data[0]['content']['extended_description']; |
564 | - }elseif(isset($data[0]['content']['general_description'])){ |
|
564 | + }elseif (isset($data[0]['content']['general_description'])) { |
|
565 | 565 | $data_post_content = $data[0]['content']['general_description']; |
566 | 566 | $content_used_general_description = true; |
567 | - }elseif(isset($data[0]['content']['teaser_description'])){ |
|
567 | + }elseif (isset($data[0]['content']['teaser_description'])) { |
|
568 | 568 | $data_post_content = $data[0]['content']['teaser_description']; |
569 | 569 | } |
570 | 570 | $post['post_content'] = wp_strip_all_tags($data_post_content); |
571 | 571 | } |
572 | 572 | |
573 | 573 | //set the post_excerpt |
574 | - if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
575 | - if(isset($data[0]['content']['teaser_description'])){ |
|
574 | + if (false !== $importable_content && in_array('excerpt', $importable_content)) { |
|
575 | + if (isset($data[0]['content']['teaser_description'])) { |
|
576 | 576 | $data_post_excerpt = $data[0]['content']['teaser_description']; |
577 | - }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
577 | + }elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) { |
|
578 | 578 | $data_post_excerpt = $data[0]['content']['general_description']; |
579 | 579 | } |
580 | 580 | $post['post_excerpt'] = $data_post_excerpt; |
581 | 581 | } |
582 | 582 | |
583 | - if(false !== $id && '0' !== $id){ |
|
583 | + if (false !== $id && '0' !== $id) { |
|
584 | 584 | $post['ID'] = $id; |
585 | - if(isset($data[0]['name'])){ |
|
585 | + if (isset($data[0]['name'])) { |
|
586 | 586 | $post['post_title'] = $data[0]['name']; |
587 | 587 | $post['post_status'] = 'publish'; |
588 | - $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
588 | + $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0); |
|
589 | 589 | } |
590 | 590 | $id = wp_update_post($post); |
591 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
592 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
593 | - }else{ |
|
591 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
592 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date); |
|
593 | + }else { |
|
594 | 594 | |
595 | 595 | //Set the name |
596 | - if(isset($data[0]['name'])){ |
|
597 | - $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
596 | + if (isset($data[0]['name'])) { |
|
597 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0); |
|
598 | 598 | } |
599 | 599 | $post['post_name'] = $post_name; |
600 | 600 | $post['post_title'] = $data[0]['name']; |
@@ -602,90 +602,90 @@ discard block |
||
602 | 602 | $id = wp_insert_post($post); |
603 | 603 | |
604 | 604 | //Save the WETU ID and the Last date it was modified. |
605 | - if(false !== $id){ |
|
606 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
607 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
605 | + if (false !== $id) { |
|
606 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
607 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified'])); |
|
608 | 608 | } |
609 | 609 | } |
610 | 610 | //Setup some default for use in the import |
611 | - if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
|
611 | + if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) { |
|
612 | 612 | $this->find_attachments($id); |
613 | 613 | } |
614 | 614 | |
615 | 615 | //Set the team member if it is there |
616 | - if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
617 | - $this->set_team_member($id,$team_members); |
|
616 | + if (post_type_exists('team') && false !== $team_members && '' !== $team_members) { |
|
617 | + $this->set_team_member($id, $team_members); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | //Set the safari brand |
621 | - if(false !== $safari_brands && '' !== $safari_brands){ |
|
622 | - $this->set_safari_brands($id,$safari_brands); |
|
621 | + if (false !== $safari_brands && '' !== $safari_brands) { |
|
622 | + $this->set_safari_brands($id, $safari_brands); |
|
623 | 623 | |
624 | 624 | } |
625 | 625 | |
626 | - if(false !== $importable_content && in_array('location',$importable_content)){ |
|
627 | - $this->set_map_data($data,$id); |
|
628 | - $this->set_location_taxonomy($data,$id); |
|
626 | + if (false !== $importable_content && in_array('location', $importable_content)) { |
|
627 | + $this->set_map_data($data, $id); |
|
628 | + $this->set_location_taxonomy($data, $id); |
|
629 | 629 | } |
630 | 630 | |
631 | - if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){ |
|
632 | - $this->connect_destinations($data,$id); |
|
631 | + if (post_type_exists('destination') && false !== $importable_content && in_array('destination', $importable_content)) { |
|
632 | + $this->connect_destinations($data, $id); |
|
633 | 633 | } |
634 | 634 | |
635 | - if(false !== $importable_content && in_array('category',$importable_content)){ |
|
636 | - $this->set_taxonomy_style($data,$id); |
|
635 | + if (false !== $importable_content && in_array('category', $importable_content)) { |
|
636 | + $this->set_taxonomy_style($data, $id); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | //Set the Room Data |
640 | - if(false !== $importable_content && in_array('rooms',$importable_content)){ |
|
641 | - $this->set_room_data($data,$id); |
|
640 | + if (false !== $importable_content && in_array('rooms', $importable_content)) { |
|
641 | + $this->set_room_data($data, $id); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | //Set the rating |
645 | - if(false !== $importable_content && in_array('rating',$importable_content)){ |
|
646 | - $this->set_rating($data,$id); |
|
645 | + if (false !== $importable_content && in_array('rating', $importable_content)) { |
|
646 | + $this->set_rating($data, $id); |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | //Set the checkin checkout data |
650 | - if(false !== $importable_content && in_array('checkin',$importable_content)){ |
|
651 | - $this->set_checkin_checkout($data,$id); |
|
650 | + if (false !== $importable_content && in_array('checkin', $importable_content)) { |
|
651 | + $this->set_checkin_checkout($data, $id); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | //Set the Spoken Languages |
655 | - if(false !== $importable_content && in_array('spoken_languages',$importable_content)){ |
|
656 | - $this->set_spoken_languages($data,$id); |
|
655 | + if (false !== $importable_content && in_array('spoken_languages', $importable_content)) { |
|
656 | + $this->set_spoken_languages($data, $id); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | //Set the friendly options |
660 | - if(false !== $importable_content && in_array('friendly',$importable_content)){ |
|
661 | - $this->set_friendly($data,$id); |
|
660 | + if (false !== $importable_content && in_array('friendly', $importable_content)) { |
|
661 | + $this->set_friendly($data, $id); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | //Set the special_interests |
665 | - if(false !== $importable_content && in_array('special_interests',$importable_content)){ |
|
666 | - $this->set_special_interests($data,$id); |
|
665 | + if (false !== $importable_content && in_array('special_interests', $importable_content)) { |
|
666 | + $this->set_special_interests($data, $id); |
|
667 | 667 | } |
668 | 668 | |
669 | 669 | //Import the videos |
670 | - if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
671 | - $this->set_video_data($data,$id); |
|
670 | + if (false !== $importable_content && in_array('videos', $importable_content)) { |
|
671 | + $this->set_video_data($data, $id); |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | //Import the facilities |
675 | - if(false !== $importable_content && in_array('facilities',$importable_content)){ |
|
676 | - $this->set_facilities($data,$id); |
|
675 | + if (false !== $importable_content && in_array('facilities', $importable_content)) { |
|
676 | + $this->set_facilities($data, $id); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | //Set the featured image |
680 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
681 | - $this->set_featured_image($data,$id); |
|
680 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
681 | + $this->set_featured_image($data, $id); |
|
682 | 682 | } |
683 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
684 | - $this->set_banner_image($data,$id); |
|
683 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
684 | + $this->set_banner_image($data, $id); |
|
685 | 685 | } |
686 | 686 | //Import the main gallery |
687 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
688 | - $this->create_main_gallery($data,$id); |
|
687 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
688 | + $this->create_main_gallery($data, $id); |
|
689 | 689 | } |
690 | 690 | } |
691 | 691 | return $id; |
@@ -694,63 +694,63 @@ discard block |
||
694 | 694 | /** |
695 | 695 | * Set the team memberon each item. |
696 | 696 | */ |
697 | - public function set_team_member($id,$team_members) { |
|
697 | + public function set_team_member($id, $team_members) { |
|
698 | 698 | |
699 | 699 | delete_post_meta($id, 'team_to_'.$this->tab_slug); |
700 | - foreach($team_members as $team){ |
|
701 | - add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
700 | + foreach ($team_members as $team) { |
|
701 | + add_post_meta($id, 'team_to_'.$this->tab_slug, $team); |
|
702 | 702 | } |
703 | 703 | } |
704 | 704 | |
705 | 705 | /** |
706 | 706 | * Set the safari brand |
707 | 707 | */ |
708 | - public function set_safari_brands($id,$safari_brands) { |
|
709 | - foreach($safari_brands as $safari_brand){ |
|
710 | - wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true); |
|
708 | + public function set_safari_brands($id, $safari_brands) { |
|
709 | + foreach ($safari_brands as $safari_brand) { |
|
710 | + wp_set_object_terms($id, intval($safari_brand), 'accommodation-brand', true); |
|
711 | 711 | } |
712 | 712 | } |
713 | 713 | |
714 | 714 | /** |
715 | 715 | * Saves the longitude and lattitude, as well as sets the map marker. |
716 | 716 | */ |
717 | - public function set_map_data($data,$id) { |
|
717 | + public function set_map_data($data, $id) { |
|
718 | 718 | $longitude = $latitude = $address = false; |
719 | 719 | $zoom = '15'; |
720 | 720 | |
721 | - if(isset($data[0]['position'])){ |
|
721 | + if (isset($data[0]['position'])) { |
|
722 | 722 | |
723 | - if(isset($data[0]['position']['driving_latitude'])){ |
|
723 | + if (isset($data[0]['position']['driving_latitude'])) { |
|
724 | 724 | $latitude = $data[0]['position']['driving_latitude']; |
725 | - }elseif(isset($data[0]['position']['latitude'])){ |
|
725 | + }elseif (isset($data[0]['position']['latitude'])) { |
|
726 | 726 | $latitude = $data[0]['position']['latitude']; |
727 | 727 | } |
728 | 728 | |
729 | - if(isset($data[0]['position']['driving_longitude'])){ |
|
729 | + if (isset($data[0]['position']['driving_longitude'])) { |
|
730 | 730 | $longitude = $data[0]['position']['driving_longitude']; |
731 | - }elseif(isset($data[0]['position']['longitude'])){ |
|
731 | + }elseif (isset($data[0]['position']['longitude'])) { |
|
732 | 732 | $longitude = $data[0]['position']['longitude']; |
733 | 733 | } |
734 | 734 | |
735 | 735 | } |
736 | - if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){ |
|
737 | - if(isset($data[0]['content']['contact_information']['address'])){ |
|
736 | + if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) { |
|
737 | + if (isset($data[0]['content']['contact_information']['address'])) { |
|
738 | 738 | $address = strip_tags($data[0]['content']['contact_information']['address']); |
739 | 739 | |
740 | - $address = explode("\n",$address); |
|
741 | - foreach($address as $bitkey => $bit){ |
|
740 | + $address = explode("\n", $address); |
|
741 | + foreach ($address as $bitkey => $bit) { |
|
742 | 742 | $bit = ltrim(rtrim($bit)); |
743 | - if(false === $bit || '' === $bit || null === $bit or empty($bit)){ |
|
743 | + if (false === $bit || '' === $bit || null === $bit or empty($bit)) { |
|
744 | 744 | unset($address[$bitkey]); |
745 | 745 | } |
746 | 746 | } |
747 | - $address = implode(', ',$address); |
|
747 | + $address = implode(', ', $address); |
|
748 | 748 | $address = str_replace(', , ', ', ', $address); |
749 | 749 | } |
750 | 750 | } |
751 | 751 | |
752 | 752 | |
753 | - if(false !== $longitude){ |
|
753 | + if (false !== $longitude) { |
|
754 | 754 | $location_data = array( |
755 | 755 | 'address' => $address, |
756 | 756 | 'lat' => $latitude, |
@@ -758,53 +758,53 @@ discard block |
||
758 | 758 | 'zoom' => $zoom, |
759 | 759 | 'elevation' => '', |
760 | 760 | ); |
761 | - if(false !== $id && '0' !== $id){ |
|
762 | - $prev = get_post_meta($id,'location',true); |
|
763 | - update_post_meta($id,'location',$location_data,$prev); |
|
764 | - }else{ |
|
765 | - add_post_meta($id,'location',$location_data,true); |
|
761 | + if (false !== $id && '0' !== $id) { |
|
762 | + $prev = get_post_meta($id, 'location', true); |
|
763 | + update_post_meta($id, 'location', $location_data, $prev); |
|
764 | + }else { |
|
765 | + add_post_meta($id, 'location', $location_data, true); |
|
766 | 766 | } |
767 | 767 | } |
768 | 768 | } |
769 | 769 | /** |
770 | 770 | * Saves the longitude and lattitude, as well as sets the map marker. |
771 | 771 | */ |
772 | - public function set_location_taxonomy($data,$id) { |
|
772 | + public function set_location_taxonomy($data, $id) { |
|
773 | 773 | $taxonomy = 'location'; |
774 | 774 | $terms = false; |
775 | - if(isset($data[0]['position'])){ |
|
775 | + if (isset($data[0]['position'])) { |
|
776 | 776 | $country_id = 0; |
777 | - if(isset($data[0]['position']['country'])){ |
|
777 | + if (isset($data[0]['position']['country'])) { |
|
778 | 778 | |
779 | - if(!$term = term_exists(trim($data[0]['position']['country']), 'location')) |
|
779 | + if (!$term = term_exists(trim($data[0]['position']['country']), 'location')) |
|
780 | 780 | { |
781 | 781 | $term = wp_insert_term(trim($data[0]['position']['country']), 'location'); |
782 | - if ( is_wp_error($term) ){ |
|
782 | + if (is_wp_error($term)) { |
|
783 | 783 | echo $term->get_error_message(); |
784 | 784 | } |
785 | 785 | else { |
786 | - wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
786 | + wp_set_object_terms($id, intval($term['term_id']), 'location', true); |
|
787 | 787 | } |
788 | 788 | } |
789 | 789 | else |
790 | 790 | { |
791 | - wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
791 | + wp_set_object_terms($id, intval($term['term_id']), 'location', true); |
|
792 | 792 | } |
793 | 793 | $country_id = intval($term['term_id']); |
794 | 794 | } |
795 | 795 | |
796 | - if(isset($data[0]['position']['destination'])){ |
|
796 | + if (isset($data[0]['position']['destination'])) { |
|
797 | 797 | |
798 | 798 | $tax_args = array('parent'=>$country_id); |
799 | - if(!$term = term_exists(trim($data[0]['position']['destination']), 'location')) |
|
799 | + if (!$term = term_exists(trim($data[0]['position']['destination']), 'location')) |
|
800 | 800 | { |
801 | 801 | $term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args); |
802 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
803 | - else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); } |
|
802 | + if (is_wp_error($term)) {echo $term->get_error_message(); } |
|
803 | + else { wp_set_object_terms($id, intval($term['term_id']), 'location', true); } |
|
804 | 804 | } |
805 | 805 | else |
806 | 806 | { |
807 | - wp_set_object_terms( $id, intval($term['term_id']), 'location',true); |
|
807 | + wp_set_object_terms($id, intval($term['term_id']), 'location', true); |
|
808 | 808 | } |
809 | 809 | } |
810 | 810 | } |
@@ -813,27 +813,27 @@ discard block |
||
813 | 813 | /** |
814 | 814 | * Connects the destinations post type |
815 | 815 | */ |
816 | - public function connect_destinations($data,$id) { |
|
817 | - if(isset($data[0]['position'])){ |
|
816 | + public function connect_destinations($data, $id) { |
|
817 | + if (isset($data[0]['position'])) { |
|
818 | 818 | $destinations = false; |
819 | - if(isset($data[0]['position']['country'])){ |
|
819 | + if (isset($data[0]['position']['country'])) { |
|
820 | 820 | $destinations['country'] = $data[0]['position']['country']; |
821 | 821 | } |
822 | - if(isset($data[0]['position']['destination'])){ |
|
822 | + if (isset($data[0]['position']['destination'])) { |
|
823 | 823 | $destinations['destination'] = $data[0]['position']['destination']; |
824 | 824 | } |
825 | 825 | |
826 | - if(false !== $destinations){ |
|
827 | - $prev_values = get_post_meta($id,'destination_to_accommodation',false); |
|
828 | - if(false === $prev_values || !is_array($prev_values)){ |
|
826 | + if (false !== $destinations) { |
|
827 | + $prev_values = get_post_meta($id, 'destination_to_accommodation', false); |
|
828 | + if (false === $prev_values || !is_array($prev_values)) { |
|
829 | 829 | $prev_values = array(); |
830 | 830 | } |
831 | - foreach($destinations as $key => $value){ |
|
831 | + foreach ($destinations as $key => $value) { |
|
832 | 832 | $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
833 | 833 | if (null !== $destination) { |
834 | - if(!in_array($destination->ID,$prev_values)){ |
|
835 | - add_post_meta($id,'destination_to_accommodation',$destination->ID,false); |
|
836 | - add_post_meta($destination->ID,'accommodation_to_destination',$id,false); |
|
834 | + if (!in_array($destination->ID, $prev_values)) { |
|
835 | + add_post_meta($id, 'destination_to_accommodation', $destination->ID, false); |
|
836 | + add_post_meta($destination->ID, 'accommodation_to_destination', $id, false); |
|
837 | 837 | } |
838 | 838 | } |
839 | 839 | } |
@@ -844,18 +844,18 @@ discard block |
||
844 | 844 | /** |
845 | 845 | * Set the Travel Style |
846 | 846 | */ |
847 | - public function set_taxonomy_style($data,$id) { |
|
847 | + public function set_taxonomy_style($data, $id) { |
|
848 | 848 | $terms = false; |
849 | - if(isset($data[0]['category'])){ |
|
850 | - if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) |
|
849 | + if (isset($data[0]['category'])) { |
|
850 | + if (!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) |
|
851 | 851 | { |
852 | 852 | $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type'); |
853 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
854 | - else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); } |
|
853 | + if (is_wp_error($term)) {echo $term->get_error_message(); } |
|
854 | + else { wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true); } |
|
855 | 855 | } |
856 | 856 | else |
857 | 857 | { |
858 | - wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); |
|
858 | + wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true); |
|
859 | 859 | } |
860 | 860 | } |
861 | 861 | } |
@@ -863,23 +863,23 @@ discard block |
||
863 | 863 | /** |
864 | 864 | * Saves the room data |
865 | 865 | */ |
866 | - public function set_room_data($data,$id) { |
|
867 | - if(!empty($data[0]['rooms']) && is_array($data[0]['rooms'])){ |
|
866 | + public function set_room_data($data, $id) { |
|
867 | + if (!empty($data[0]['rooms']) && is_array($data[0]['rooms'])) { |
|
868 | 868 | $rooms = false; |
869 | 869 | |
870 | - foreach($data[0]['rooms'] as $room){ |
|
870 | + foreach ($data[0]['rooms'] as $room) { |
|
871 | 871 | |
872 | 872 | $temp_room = array(); |
873 | - if(isset($room['name'])){ |
|
873 | + if (isset($room['name'])) { |
|
874 | 874 | $temp_room['title'] = $room['name']; |
875 | 875 | } |
876 | - if(isset($room['description'])){ |
|
876 | + if (isset($room['description'])) { |
|
877 | 877 | $temp_room['description'] = strip_tags($room['description']); |
878 | 878 | } |
879 | 879 | $temp_room['price'] = 0; |
880 | 880 | $temp_room['type'] = 'room'; |
881 | 881 | |
882 | - if(!empty($room['images']) && is_array($room['images'])){ |
|
882 | + if (!empty($room['images']) && is_array($room['images'])) { |
|
883 | 883 | $attachments_args = array( |
884 | 884 | 'post_parent' => $id, |
885 | 885 | 'post_status' => 'inherit', |
@@ -889,38 +889,38 @@ discard block |
||
889 | 889 | $attachments = new WP_Query($attachments_args); |
890 | 890 | $found_attachments = array(); |
891 | 891 | |
892 | - if($attachments->have_posts()){ |
|
893 | - foreach($attachments->posts as $attachment){ |
|
894 | - $found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
892 | + if ($attachments->have_posts()) { |
|
893 | + foreach ($attachments->posts as $attachment) { |
|
894 | + $found_attachments[] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title); |
|
895 | 895 | } |
896 | 896 | } |
897 | 897 | |
898 | 898 | $temp_room['gallery'] = array(); |
899 | - foreach($room['images'] as $image_data){ |
|
900 | - $temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments); |
|
899 | + foreach ($room['images'] as $image_data) { |
|
900 | + $temp_room['gallery'][] = $this->attach_image($image_data, $id, $found_attachments); |
|
901 | 901 | } |
902 | 902 | } |
903 | 903 | $rooms[] = $temp_room; |
904 | 904 | } |
905 | 905 | |
906 | - if(false !== $id && '0' !== $id){ |
|
906 | + if (false !== $id && '0' !== $id) { |
|
907 | 907 | delete_post_meta($id, 'units'); |
908 | 908 | } |
909 | - foreach($rooms as $room){ |
|
910 | - add_post_meta($id,'units',$room,false); |
|
909 | + foreach ($rooms as $room) { |
|
910 | + add_post_meta($id, 'units', $room, false); |
|
911 | 911 | } |
912 | 912 | |
913 | - if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){ |
|
913 | + if (isset($data[0]['features']) && isset($data[0]['features']['rooms'])) { |
|
914 | 914 | $room_count = $data[0]['features']['rooms']; |
915 | - }else{ |
|
915 | + }else { |
|
916 | 916 | $room_count = count($data[0]['rooms']); |
917 | 917 | } |
918 | 918 | |
919 | - if(false !== $id && '0' !== $id){ |
|
920 | - $prev_rooms = get_post_meta($id,'number_of_rooms',true); |
|
921 | - update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms); |
|
922 | - }else{ |
|
923 | - add_post_meta($id,'number_of_rooms',$room_count,true); |
|
919 | + if (false !== $id && '0' !== $id) { |
|
920 | + $prev_rooms = get_post_meta($id, 'number_of_rooms', true); |
|
921 | + update_post_meta($id, 'number_of_rooms', $room_count, $prev_rooms); |
|
922 | + }else { |
|
923 | + add_post_meta($id, 'number_of_rooms', $room_count, true); |
|
924 | 924 | } |
925 | 925 | } |
926 | 926 | } |
@@ -928,31 +928,31 @@ discard block |
||
928 | 928 | /** |
929 | 929 | * Set the ratings |
930 | 930 | */ |
931 | - public function set_rating($data,$id) { |
|
931 | + public function set_rating($data, $id) { |
|
932 | 932 | |
933 | - if(!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])){ |
|
933 | + if (!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])) { |
|
934 | 934 | $rating_type = $data[0]['features']['star_authority']; |
935 | - }else{ |
|
935 | + }else { |
|
936 | 936 | $rating_type = 'Unspecified2'; |
937 | 937 | } |
938 | - $this->save_custom_field($rating_type,'rating_type',$id); |
|
938 | + $this->save_custom_field($rating_type, 'rating_type', $id); |
|
939 | 939 | |
940 | - if(!empty($data[0]['features']) && isset($data[0]['features']['stars'])){ |
|
941 | - $this->save_custom_field($data[0]['features']['stars'],'rating',$id,true); |
|
940 | + if (!empty($data[0]['features']) && isset($data[0]['features']['stars'])) { |
|
941 | + $this->save_custom_field($data[0]['features']['stars'], 'rating', $id, true); |
|
942 | 942 | } |
943 | 943 | } |
944 | 944 | |
945 | 945 | /** |
946 | 946 | * Set the spoken_languages |
947 | 947 | */ |
948 | - public function set_spoken_languages($data,$id) { |
|
949 | - if(!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])){ |
|
948 | + public function set_spoken_languages($data, $id) { |
|
949 | + if (!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])) { |
|
950 | 950 | $languages = false; |
951 | - foreach($data[0]['features']['spoken_languages'] as $spoken_language){ |
|
951 | + foreach ($data[0]['features']['spoken_languages'] as $spoken_language) { |
|
952 | 952 | $languages[] = sanitize_title($spoken_language); |
953 | 953 | } |
954 | - if(false !== $languages){ |
|
955 | - $this->save_custom_field($languages,'spoken_languages',$id); |
|
954 | + if (false !== $languages) { |
|
955 | + $this->save_custom_field($languages, 'spoken_languages', $id); |
|
956 | 956 | } |
957 | 957 | } |
958 | 958 | } |
@@ -960,14 +960,14 @@ discard block |
||
960 | 960 | /** |
961 | 961 | * Set the friendly |
962 | 962 | */ |
963 | - public function set_friendly($data,$id) { |
|
964 | - if(!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])){ |
|
963 | + public function set_friendly($data, $id) { |
|
964 | + if (!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])) { |
|
965 | 965 | $friendly_options = false; |
966 | - foreach($data[0]['features']['suggested_visitor_types'] as $visitor_type){ |
|
966 | + foreach ($data[0]['features']['suggested_visitor_types'] as $visitor_type) { |
|
967 | 967 | $friendly_options[] = sanitize_title($visitor_type); |
968 | 968 | } |
969 | - if(false !== $friendly_options){ |
|
970 | - $this->save_custom_field($friendly_options,'suggested_visitor_types',$id); |
|
969 | + if (false !== $friendly_options) { |
|
970 | + $this->save_custom_field($friendly_options, 'suggested_visitor_types', $id); |
|
971 | 971 | } |
972 | 972 | } |
973 | 973 | } |
@@ -975,14 +975,14 @@ discard block |
||
975 | 975 | /** |
976 | 976 | * Set the special interests |
977 | 977 | */ |
978 | - public function set_special_interests($data,$id) { |
|
979 | - if(!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])){ |
|
978 | + public function set_special_interests($data, $id) { |
|
979 | + if (!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])) { |
|
980 | 980 | $interests = false; |
981 | - foreach($data[0]['features']['special_interests'] as $special_interest){ |
|
981 | + foreach ($data[0]['features']['special_interests'] as $special_interest) { |
|
982 | 982 | $interests[] = sanitize_title($special_interest); |
983 | 983 | } |
984 | - if(false !== $interests){ |
|
985 | - $this->save_custom_field($interests,'special_interests',$id); |
|
984 | + if (false !== $interests) { |
|
985 | + $this->save_custom_field($interests, 'special_interests', $id); |
|
986 | 986 | } |
987 | 987 | } |
988 | 988 | } |
@@ -990,47 +990,47 @@ discard block |
||
990 | 990 | /** |
991 | 991 | * Set the Check in and Check out Date |
992 | 992 | */ |
993 | - public function set_checkin_checkout($data,$id) { |
|
993 | + public function set_checkin_checkout($data, $id) { |
|
994 | 994 | |
995 | - if(!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])){ |
|
996 | - $time = str_replace('h',':',$data[0]['features']['check_in_time']); |
|
997 | - $time = date('h:ia',strtotime($time)); |
|
998 | - $this->save_custom_field($time,'checkin_time',$id); |
|
995 | + if (!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])) { |
|
996 | + $time = str_replace('h', ':', $data[0]['features']['check_in_time']); |
|
997 | + $time = date('h:ia', strtotime($time)); |
|
998 | + $this->save_custom_field($time, 'checkin_time', $id); |
|
999 | 999 | } |
1000 | - if(!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])){ |
|
1001 | - $time = str_replace('h',':',$data[0]['features']['check_out_time']); |
|
1002 | - $time = date('h:ia',strtotime($time)); |
|
1003 | - $this->save_custom_field($time,'checkout_time',$id); |
|
1000 | + if (!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])) { |
|
1001 | + $time = str_replace('h', ':', $data[0]['features']['check_out_time']); |
|
1002 | + $time = date('h:ia', strtotime($time)); |
|
1003 | + $this->save_custom_field($time, 'checkout_time', $id); |
|
1004 | 1004 | } |
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | /** |
1008 | 1008 | * Set the Video date |
1009 | 1009 | */ |
1010 | - public function set_video_data($data,$id) { |
|
1011 | - if(!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])){ |
|
1010 | + public function set_video_data($data, $id) { |
|
1011 | + if (!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])) { |
|
1012 | 1012 | $videos = false; |
1013 | 1013 | |
1014 | - foreach($data[0]['content']['youtube_videos'] as $video){ |
|
1014 | + foreach ($data[0]['content']['youtube_videos'] as $video) { |
|
1015 | 1015 | $temp_video = ''; |
1016 | - if(isset($video['label'])){ |
|
1016 | + if (isset($video['label'])) { |
|
1017 | 1017 | $temp_video['title'] = $video['label']; |
1018 | 1018 | } |
1019 | - if(isset($video['description'])){ |
|
1019 | + if (isset($video['description'])) { |
|
1020 | 1020 | $temp_video['description'] = strip_tags($video['description']); |
1021 | 1021 | } |
1022 | - if(isset($video['url'])){ |
|
1022 | + if (isset($video['url'])) { |
|
1023 | 1023 | $temp_video['url'] = $video['url']; |
1024 | 1024 | } |
1025 | 1025 | $temp_video['thumbnail'] = ''; |
1026 | 1026 | $videos[] = $temp_video; |
1027 | 1027 | } |
1028 | 1028 | |
1029 | - if(false !== $id && '0' !== $id){ |
|
1029 | + if (false !== $id && '0' !== $id) { |
|
1030 | 1030 | delete_post_meta($id, 'videos'); |
1031 | 1031 | } |
1032 | - foreach($videos as $video){ |
|
1033 | - add_post_meta($id,'videos',$video,false); |
|
1032 | + foreach ($videos as $video) { |
|
1033 | + add_post_meta($id, 'videos', $video, false); |
|
1034 | 1034 | } |
1035 | 1035 | } |
1036 | 1036 | } |
@@ -1038,7 +1038,7 @@ discard block |
||
1038 | 1038 | /** |
1039 | 1039 | * Set the Facilities |
1040 | 1040 | */ |
1041 | - public function set_facilities($data,$id) { |
|
1041 | + public function set_facilities($data, $id) { |
|
1042 | 1042 | |
1043 | 1043 | $parent_facilities = array( |
1044 | 1044 | 'available_services' => 'Available Services', |
@@ -1046,28 +1046,28 @@ discard block |
||
1046 | 1046 | 'room_facilities' => 'Room Facilities', |
1047 | 1047 | 'activities_on_site' => 'Activities on Site' |
1048 | 1048 | ); |
1049 | - foreach($parent_facilities as $key => $label){ |
|
1049 | + foreach ($parent_facilities as $key => $label) { |
|
1050 | 1050 | $terms = false; |
1051 | - if(isset($data[0]['features']) && isset($data[0]['features'][$key])){ |
|
1052 | - $parent_id = $this->set_term($id,$label,'facility'); |
|
1051 | + if (isset($data[0]['features']) && isset($data[0]['features'][$key])) { |
|
1052 | + $parent_id = $this->set_term($id, $label, 'facility'); |
|
1053 | 1053 | } |
1054 | - foreach($data[0]['features'][$key] as $child_facility){ |
|
1055 | - $this->set_term($id,$child_facility,'facility',$parent_id); |
|
1054 | + foreach ($data[0]['features'][$key] as $child_facility) { |
|
1055 | + $this->set_term($id, $child_facility, 'facility', $parent_id); |
|
1056 | 1056 | } |
1057 | 1057 | } |
1058 | 1058 | } |
1059 | 1059 | |
1060 | - function set_term($id=false,$name=false,$taxonomy=false,$parent=false){ |
|
1061 | - if(!$term = term_exists($name, $taxonomy)) |
|
1060 | + function set_term($id = false, $name = false, $taxonomy = false, $parent = false) { |
|
1061 | + if (!$term = term_exists($name, $taxonomy)) |
|
1062 | 1062 | { |
1063 | - if(false !== $parent){ $parent = array('parent'=>$parent); } |
|
1064 | - $term = wp_insert_term(trim($name), $taxonomy,$parent); |
|
1065 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
1066 | - else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); } |
|
1063 | + if (false !== $parent) { $parent = array('parent'=>$parent); } |
|
1064 | + $term = wp_insert_term(trim($name), $taxonomy, $parent); |
|
1065 | + if (is_wp_error($term)) {echo $term->get_error_message(); } |
|
1066 | + else { wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); } |
|
1067 | 1067 | } |
1068 | 1068 | else |
1069 | 1069 | { |
1070 | - wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
1070 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
1071 | 1071 | } |
1072 | 1072 | return $term['term_id']; |
1073 | 1073 | } |
@@ -1075,16 +1075,16 @@ discard block |
||
1075 | 1075 | /** |
1076 | 1076 | * Creates the main gallery data |
1077 | 1077 | */ |
1078 | - public function set_featured_image($data,$id) { |
|
1079 | - if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
|
1080 | - $this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id); |
|
1078 | + public function set_featured_image($data, $id) { |
|
1079 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
1080 | + $this->featured_image = $this->attach_image($data[0]['content']['images'][0], $id); |
|
1081 | 1081 | |
1082 | - if(false !== $this->featured_image){ |
|
1083 | - delete_post_meta($id,'_thumbnail_id'); |
|
1084 | - add_post_meta($id,'_thumbnail_id',$this->featured_image,true); |
|
1082 | + if (false !== $this->featured_image) { |
|
1083 | + delete_post_meta($id, '_thumbnail_id'); |
|
1084 | + add_post_meta($id, '_thumbnail_id', $this->featured_image, true); |
|
1085 | 1085 | |
1086 | - if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){ |
|
1087 | - add_post_meta($id,'gallery',$this->featured_image,false); |
|
1086 | + if (!empty($this->gallery_meta) && !in_array($this->featured_image, $this->gallery_meta)) { |
|
1087 | + add_post_meta($id, 'gallery', $this->featured_image, false); |
|
1088 | 1088 | $this->gallery_meta[] = $this->featured_image; |
1089 | 1089 | } |
1090 | 1090 | } |
@@ -1094,17 +1094,17 @@ discard block |
||
1094 | 1094 | /** |
1095 | 1095 | * Sets a banner image |
1096 | 1096 | */ |
1097 | - public function set_banner_image($data,$id) { |
|
1098 | - if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
|
1099 | - $this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c')); |
|
1097 | + public function set_banner_image($data, $id) { |
|
1098 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
1099 | + $this->banner_image = $this->attach_image($data[0]['content']['images'][1], $id, array('width'=>'1920', 'height'=>'800', 'cropping'=>'c')); |
|
1100 | 1100 | |
1101 | - if(false !== $this->banner_image){ |
|
1102 | - delete_post_meta($id,'image_group'); |
|
1101 | + if (false !== $this->banner_image) { |
|
1102 | + delete_post_meta($id, 'image_group'); |
|
1103 | 1103 | $new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image)); |
1104 | - add_post_meta($id,'image_group',$new_banner,true); |
|
1104 | + add_post_meta($id, 'image_group', $new_banner, true); |
|
1105 | 1105 | |
1106 | - if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){ |
|
1107 | - add_post_meta($id,'gallery',$this->banner_image,false); |
|
1106 | + if (!empty($this->gallery_meta) && !in_array($this->banner_image, $this->gallery_meta)) { |
|
1107 | + add_post_meta($id, 'gallery', $this->banner_image, false); |
|
1108 | 1108 | $this->gallery_meta[] = $this->banner_image; |
1109 | 1109 | } |
1110 | 1110 | } |
@@ -1114,24 +1114,24 @@ discard block |
||
1114 | 1114 | /** |
1115 | 1115 | * Creates the main gallery data |
1116 | 1116 | */ |
1117 | - public function create_main_gallery($data,$id) { |
|
1117 | + public function create_main_gallery($data, $id) { |
|
1118 | 1118 | |
1119 | - if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
|
1119 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
1120 | 1120 | |
1121 | 1121 | $counter = 0; |
1122 | - foreach($data[0]['content']['images'] as $image_data){ |
|
1123 | - if($counter === 0 && false !== $this->featured_image){continue;} |
|
1124 | - if($counter === 1 && false !== $this->banner_image){continue;} |
|
1122 | + foreach ($data[0]['content']['images'] as $image_data) { |
|
1123 | + if ($counter === 0 && false !== $this->featured_image) {continue; } |
|
1124 | + if ($counter === 1 && false !== $this->banner_image) {continue; } |
|
1125 | 1125 | |
1126 | - $this->gallery_meta[] = $temp_id = $this->attach_image($image_data,$id); |
|
1126 | + $this->gallery_meta[] = $temp_id = $this->attach_image($image_data, $id); |
|
1127 | 1127 | $counter++; |
1128 | 1128 | } |
1129 | 1129 | |
1130 | - if(!empty($this->gallery_meta)){ |
|
1131 | - delete_post_meta($id,'gallery'); |
|
1132 | - foreach($this->gallery_meta as $gallery_id){ |
|
1133 | - if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){ |
|
1134 | - add_post_meta($id,'gallery',$gallery_id,false); |
|
1130 | + if (!empty($this->gallery_meta)) { |
|
1131 | + delete_post_meta($id, 'gallery'); |
|
1132 | + foreach ($this->gallery_meta as $gallery_id) { |
|
1133 | + if (false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)) { |
|
1134 | + add_post_meta($id, 'gallery', $gallery_id, false); |
|
1135 | 1135 | } |
1136 | 1136 | } |
1137 | 1137 | } |
@@ -1141,53 +1141,53 @@ discard block |
||
1141 | 1141 | /** |
1142 | 1142 | * Attaches 1 image |
1143 | 1143 | */ |
1144 | - public function attach_image($v=false,$parent_id,$image_sizes=false){ |
|
1145 | - if(false !== $v){ |
|
1146 | - $temp_fragment = explode('/',$v['url_fragment']); |
|
1147 | - $url_filename = $temp_fragment[count($temp_fragment)-1]; |
|
1148 | - $url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename); |
|
1144 | + public function attach_image($v = false, $parent_id, $image_sizes = false) { |
|
1145 | + if (false !== $v) { |
|
1146 | + $temp_fragment = explode('/', $v['url_fragment']); |
|
1147 | + $url_filename = $temp_fragment[count($temp_fragment) - 1]; |
|
1148 | + $url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename); |
|
1149 | 1149 | |
1150 | - if(in_array($url_filename,$this->found_attachments)){ |
|
1151 | - return array_search($url_filename,$this->found_attachments); |
|
1150 | + if (in_array($url_filename, $this->found_attachments)) { |
|
1151 | + return array_search($url_filename, $this->found_attachments); |
|
1152 | 1152 | } |
1153 | 1153 | |
1154 | - $postdata=array(); |
|
1155 | - if(empty($v['label'])) |
|
1154 | + $postdata = array(); |
|
1155 | + if (empty($v['label'])) |
|
1156 | 1156 | { |
1157 | - $v['label']=''; |
|
1157 | + $v['label'] = ''; |
|
1158 | 1158 | } |
1159 | - if(!empty($v['description'])) |
|
1159 | + if (!empty($v['description'])) |
|
1160 | 1160 | { |
1161 | - $desc=wp_strip_all_tags($v['description']); |
|
1162 | - $posdata=array('post_excerpt'=>$desc); |
|
1161 | + $desc = wp_strip_all_tags($v['description']); |
|
1162 | + $posdata = array('post_excerpt'=>$desc); |
|
1163 | 1163 | } |
1164 | - if(!empty($v['section'])) |
|
1164 | + if (!empty($v['section'])) |
|
1165 | 1165 | { |
1166 | - $desc=wp_strip_all_tags($v['section']); |
|
1167 | - $posdata=array('post_excerpt'=>$desc); |
|
1166 | + $desc = wp_strip_all_tags($v['section']); |
|
1167 | + $posdata = array('post_excerpt'=>$desc); |
|
1168 | 1168 | } |
1169 | 1169 | |
1170 | - $attachID=NULL; |
|
1170 | + $attachID = NULL; |
|
1171 | 1171 | //Resizor - add option to setting if required |
1172 | - $fragment = str_replace(' ','%20',$v['url_fragment']); |
|
1172 | + $fragment = str_replace(' ', '%20', $v['url_fragment']); |
|
1173 | 1173 | $url = $this->get_scaling_url($image_sizes).$fragment; |
1174 | - $attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata); |
|
1174 | + $attachID = $this->attach_external_image2($url, $parent_id, '', $v['label'], $postdata); |
|
1175 | 1175 | |
1176 | 1176 | //echo($attachID.' add image'); |
1177 | - if($attachID!=NULL) |
|
1177 | + if ($attachID != NULL) |
|
1178 | 1178 | { |
1179 | 1179 | return $attachID; |
1180 | 1180 | } |
1181 | 1181 | } |
1182 | 1182 | return false; |
1183 | 1183 | } |
1184 | - public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) { |
|
1184 | + public function attach_external_image2($url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array()) { |
|
1185 | 1185 | |
1186 | - if ( !$url || !$post_id ) { return new WP_Error('missing', "Need a valid URL and post ID..."); } |
|
1186 | + if (!$url || !$post_id) { return new WP_Error('missing', "Need a valid URL and post ID..."); } |
|
1187 | 1187 | |
1188 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
1189 | - require_once(ABSPATH . 'wp-admin/includes/media.php'); |
|
1190 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
1188 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
1189 | + require_once(ABSPATH.'wp-admin/includes/media.php'); |
|
1190 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
1191 | 1191 | // Download file to temp location, returns full server path to temp file |
1192 | 1192 | //$tmp = download_url( $url ); |
1193 | 1193 | |
@@ -1196,53 +1196,53 @@ discard block |
||
1196 | 1196 | |
1197 | 1197 | $image = file_get_contents($url); |
1198 | 1198 | file_put_contents($tmp, $image); |
1199 | - chmod($tmp,'777'); |
|
1199 | + chmod($tmp, '777'); |
|
1200 | 1200 | |
1201 | - preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches); // fix file filename for query strings |
|
1201 | + preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches); // fix file filename for query strings |
|
1202 | 1202 | $url_filename = basename($matches[0]); |
1203 | - $url_filename=str_replace('%20','_',$url_filename); |
|
1203 | + $url_filename = str_replace('%20', '_', $url_filename); |
|
1204 | 1204 | // extract filename from url for title |
1205 | - $url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type) |
|
1205 | + $url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type) |
|
1206 | 1206 | |
1207 | 1207 | // override filename if given, reconstruct server path |
1208 | - if ( !empty( $filename ) && " " != $filename ) |
|
1208 | + if (!empty($filename) && " " != $filename) |
|
1209 | 1209 | { |
1210 | 1210 | $filename = sanitize_file_name($filename); |
1211 | - $tmppath = pathinfo( $tmp ); |
|
1211 | + $tmppath = pathinfo($tmp); |
|
1212 | 1212 | |
1213 | 1213 | $extension = ''; |
1214 | - if(isset($tmppath['extension'])){ |
|
1214 | + if (isset($tmppath['extension'])) { |
|
1215 | 1215 | $extension = $tmppath['extension']; |
1216 | 1216 | } |
1217 | 1217 | |
1218 | - $new = $tmppath['dirname'] . "/". $filename . "." . $extension; |
|
1219 | - rename($tmp, $new); // renames temp file on server |
|
1220 | - $tmp = $new; // push new filename (in path) to be used in file array later |
|
1218 | + $new = $tmppath['dirname']."/".$filename.".".$extension; |
|
1219 | + rename($tmp, $new); // renames temp file on server |
|
1220 | + $tmp = $new; // push new filename (in path) to be used in file array later |
|
1221 | 1221 | } |
1222 | 1222 | |
1223 | 1223 | // assemble file data (should be built like $_FILES since wp_handle_sideload() will be using) |
1224 | - $file_array['tmp_name'] = $tmp; // full server path to temp file |
|
1224 | + $file_array['tmp_name'] = $tmp; // full server path to temp file |
|
1225 | 1225 | |
1226 | - if ( !empty( $filename) && " " != $filename ) |
|
1226 | + if (!empty($filename) && " " != $filename) |
|
1227 | 1227 | { |
1228 | - $file_array['name'] = $filename . "." . $url_type['ext']; // user given filename for title, add original URL extension |
|
1228 | + $file_array['name'] = $filename.".".$url_type['ext']; // user given filename for title, add original URL extension |
|
1229 | 1229 | } |
1230 | 1230 | else |
1231 | 1231 | { |
1232 | - $file_array['name'] = $url_filename; // just use original URL filename |
|
1232 | + $file_array['name'] = $url_filename; // just use original URL filename |
|
1233 | 1233 | } |
1234 | 1234 | |
1235 | 1235 | // set additional wp_posts columns |
1236 | - if ( empty( $post_data['post_title'] ) ) |
|
1236 | + if (empty($post_data['post_title'])) |
|
1237 | 1237 | { |
1238 | 1238 | |
1239 | - $url_filename=str_replace('%20',' ',$url_filename); |
|
1239 | + $url_filename = str_replace('%20', ' ', $url_filename); |
|
1240 | 1240 | |
1241 | - $post_data['post_title'] = basename($url_filename, "." . $url_type['ext']); // just use the original filename (no extension) |
|
1241 | + $post_data['post_title'] = basename($url_filename, ".".$url_type['ext']); // just use the original filename (no extension) |
|
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | // make sure gets tied to parent |
1245 | - if ( empty( $post_data['post_parent'] ) ) |
|
1245 | + if (empty($post_data['post_parent'])) |
|
1246 | 1246 | { |
1247 | 1247 | $post_data['post_parent'] = $post_id; |
1248 | 1248 | } |
@@ -1250,12 +1250,12 @@ discard block |
||
1250 | 1250 | // required libraries for media_handle_sideload |
1251 | 1251 | |
1252 | 1252 | // do the validation and storage stuff |
1253 | - $att_id = media_handle_sideload( $file_array, $post_id, null, $post_data ); // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status |
|
1253 | + $att_id = media_handle_sideload($file_array, $post_id, null, $post_data); // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status |
|
1254 | 1254 | |
1255 | 1255 | // If error storing permanently, unlink |
1256 | - if ( is_wp_error($att_id) ) |
|
1256 | + if (is_wp_error($att_id)) |
|
1257 | 1257 | { |
1258 | - unlink($file_array['tmp_name']); // clean up |
|
1258 | + unlink($file_array['tmp_name']); // clean up |
|
1259 | 1259 | return false; // output wp_error |
1260 | 1260 | //return $att_id; // output wp_error |
1261 | 1261 | } |
@@ -55,16 +55,16 @@ discard block |
||
55 | 55 | public function __construct() { |
56 | 56 | $this->set_variables(); |
57 | 57 | |
58 | - add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') ); |
|
58 | + add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page')); |
|
59 | 59 | |
60 | - add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search')); |
|
61 | - add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search')); |
|
60 | + add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
61 | + add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
62 | 62 | |
63 | - add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import')); |
|
64 | - add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import')); |
|
63 | + add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import')); |
|
64 | + add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import')); |
|
65 | 65 | |
66 | - $temp_options = get_option('_lsx-to_settings',false); |
|
67 | - if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){ |
|
66 | + $temp_options = get_option('_lsx-to_settings', false); |
|
67 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
68 | 68 | $this->options = $temp_options[$this->plugin_slug]; |
69 | 69 | } |
70 | 70 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | // $this->url = 'https://wetu.com/API/Pins/'; |
82 | 82 | // $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
83 | 83 | //} elseif ( false !== $this->api_key ) { |
84 | - $this->url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
84 | + $this->url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
85 | 85 | $this->url_qs = ''; |
86 | 86 | //} |
87 | 87 | } |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | <form method="get" action="" id="posts-filter"> |
100 | 100 | <input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" /> |
101 | 101 | |
102 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
103 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
102 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
103 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
104 | 104 | </p> |
105 | 105 | |
106 | 106 | <table class="wp-list-table widefat fixed posts"> |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | <tbody id="the-list"> |
110 | 110 | <tr class="post-0 type-tour status-none" id="post-0"> |
111 | 111 | <th class="check-column" scope="row"> |
112 | - <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label> |
|
112 | + <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label> |
|
113 | 113 | </th> |
114 | 114 | <td class="post-title page-title column-title"> |
115 | 115 | <strong> |
116 | - <?php _e('Enter a title to search for','wetu-importer'); ?> |
|
116 | + <?php _e('Enter a title to search for', 'wetu-importer'); ?> |
|
117 | 117 | </strong> |
118 | 118 | </td> |
119 | 119 | <td class="date column-date"> |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | |
128 | 128 | </table> |
129 | 129 | |
130 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
131 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
130 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
131 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
132 | 132 | </p> |
133 | 133 | </form> |
134 | 134 | |
@@ -140,15 +140,15 @@ discard block |
||
140 | 140 | <div style="width:30%;display:block;float:left;"> |
141 | 141 | <h3><?php _e('What content to Sync from WETU'); ?></h3> |
142 | 142 | <ul> |
143 | - <li><input class="content" type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
144 | - <li><input class="content" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li> |
|
143 | + <li><input class="content" type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
144 | + <li><input class="content" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li> |
|
145 | 145 | |
146 | - <?php if(class_exists('TO_Maps')){ ?> |
|
147 | - <li><input class="content" type="checkbox" name="content[]" value="location" /> <?php _e('Location','wetu-importer'); ?></li> |
|
146 | + <?php if (class_exists('TO_Maps')) { ?> |
|
147 | + <li><input class="content" type="checkbox" name="content[]" value="location" /> <?php _e('Location', 'wetu-importer'); ?></li> |
|
148 | 148 | <?php } ?> |
149 | 149 | |
150 | - <?php if(class_exists('TO_Videos')){ ?> |
|
151 | - <li><input class="content" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos','wetu-importer'); ?></li> |
|
150 | + <?php if (class_exists('TO_Videos')) { ?> |
|
151 | + <li><input class="content" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos', 'wetu-importer'); ?></li> |
|
152 | 152 | <?php } ?> |
153 | 153 | |
154 | 154 | </ul> |
@@ -156,16 +156,16 @@ discard block |
||
156 | 156 | <div style="width:30%;display:block;float:left;"> |
157 | 157 | <h3><?php _e('Travel Information'); ?></h3> |
158 | 158 | <ul> |
159 | - <li><input class="content" type="checkbox" name="content[]" value="electricity" /> <?php _e('Electricity','wetu-importer'); ?></li> |
|
160 | - <li><input class="content" type="checkbox" name="content[]" value="banking" /> <?php _e('Banking','wetu-importer'); ?></li> |
|
161 | - <li><input class="content" type="checkbox" name="content[]" value="cuisine" /> <?php _e('Cuisine','wetu-importer'); ?></li> |
|
162 | - <li><input class="content" type="checkbox" name="content[]" value="climate" /> <?php _e('Climate','wetu-importer'); ?></li> |
|
163 | - <li><input class="content" type="checkbox" name="content[]" value="transport" /> <?php _e('Transport','wetu-importer'); ?></li> |
|
164 | - <li><input class="content" type="checkbox" name="content[]" value="dress" /> <?php _e('Dress','wetu-importer'); ?></li> |
|
159 | + <li><input class="content" type="checkbox" name="content[]" value="electricity" /> <?php _e('Electricity', 'wetu-importer'); ?></li> |
|
160 | + <li><input class="content" type="checkbox" name="content[]" value="banking" /> <?php _e('Banking', 'wetu-importer'); ?></li> |
|
161 | + <li><input class="content" type="checkbox" name="content[]" value="cuisine" /> <?php _e('Cuisine', 'wetu-importer'); ?></li> |
|
162 | + <li><input class="content" type="checkbox" name="content[]" value="climate" /> <?php _e('Climate', 'wetu-importer'); ?></li> |
|
163 | + <li><input class="content" type="checkbox" name="content[]" value="transport" /> <?php _e('Transport', 'wetu-importer'); ?></li> |
|
164 | + <li><input class="content" type="checkbox" name="content[]" value="dress" /> <?php _e('Dress', 'wetu-importer'); ?></li> |
|
165 | 165 | </ul> |
166 | 166 | </div> |
167 | 167 | |
168 | - <?php if(class_exists('TO_Team')){ ?> |
|
168 | + <?php if (class_exists('TO_Team')) { ?> |
|
169 | 169 | <div style="width:30%;display:block;float:left;"> |
170 | 170 | <h3><?php _e('Assign a Team Member'); ?></h3> |
171 | 171 | <?php $this->team_member_checkboxes(); ?> |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | |
179 | 179 | <h3><?php _e('Your List'); ?></h3> |
180 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
180 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
181 | 181 | <table class="wp-list-table widefat fixed posts"> |
182 | 182 | <?php $this->table_header(); ?> |
183 | 183 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | |
190 | 190 | </table> |
191 | 191 | |
192 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
192 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
193 | 193 | </form> |
194 | 194 | </div> |
195 | 195 | |
@@ -210,31 +210,31 @@ discard block |
||
210 | 210 | <form class="ajax-form" id="<?php echo $this->plugin_slug; ?>-search-form" method="get" action="tools.php" data-type="<?php echo $this->tab_slug; ?>"> |
211 | 211 | <input type="hidden" name="page" value="<?php echo $this->tab_slug; ?>" /> |
212 | 212 | |
213 | - <h3><span class="dashicons dashicons-search"></span> <?php _e('Search','wetu-importer'); ?></h3> |
|
213 | + <h3><span class="dashicons dashicons-search"></span> <?php _e('Search', 'wetu-importer'); ?></h3> |
|
214 | 214 | <div class="normal-search"> |
215 | - <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" /> |
|
215 | + <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" /> |
|
216 | 216 | </div> |
217 | 217 | |
218 | 218 | |
219 | 219 | <div class="advanced-search hidden" style="display:none;"> |
220 | - <p><?php _e('Enter several keywords, each on a new line.','wetu-importer'); ?></p> |
|
220 | + <p><?php _e('Enter several keywords, each on a new line.', 'wetu-importer'); ?></p> |
|
221 | 221 | <textarea rows="10" cols="40" name="bulk-keywords"></textarea> |
222 | - <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" /> |
|
222 | + <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" /> |
|
223 | 223 | </div> |
224 | 224 | |
225 | 225 | <p> |
226 | - <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search','wetu-importer'); ?></a> | |
|
227 | - <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published','wetu-importer'); ?></a> | |
|
228 | - <a class="pending search-toggle" href="#pending"><?php esc_attr_e('Pending','wetu-importer'); ?></a> | |
|
229 | - <a class="draft search-toggle" href="#draft"><?php esc_attr_e('Draft','wetu-importer'); ?></a> |
|
226 | + <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search', 'wetu-importer'); ?></a> | |
|
227 | + <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published', 'wetu-importer'); ?></a> | |
|
228 | + <a class="pending search-toggle" href="#pending"><?php esc_attr_e('Pending', 'wetu-importer'); ?></a> | |
|
229 | + <a class="draft search-toggle" href="#draft"><?php esc_attr_e('Draft', 'wetu-importer'); ?></a> |
|
230 | 230 | </p> |
231 | 231 | |
232 | 232 | <div class="ajax-loader" style="display:none;width:100%;text-align:center;"> |
233 | - <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" /> |
|
233 | + <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" /> |
|
234 | 234 | </div> |
235 | 235 | |
236 | 236 | <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;"> |
237 | - <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" /> |
|
237 | + <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" /> |
|
238 | 238 | </div> |
239 | 239 | </form> |
240 | 240 | <?php |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | /** |
271 | 271 | * Grab all the current destination posts via the lsx_wetu_id field. |
272 | 272 | */ |
273 | - public function find_current_destination($post_type='destination') { |
|
273 | + public function find_current_destination($post_type = 'destination') { |
|
274 | 274 | global $wpdb; |
275 | 275 | $return = array(); |
276 | 276 | |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | |
287 | 287 | LIMIT 0,500 |
288 | 288 | "); |
289 | - if(null !== $current_destination && !empty($current_destination)){ |
|
290 | - foreach($current_destination as $accom){ |
|
289 | + if (null !== $current_destination && !empty($current_destination)) { |
|
290 | + foreach ($current_destination as $accom) { |
|
291 | 291 | $return[$accom->meta_value] = $accom; |
292 | 292 | } |
293 | 293 | } |
@@ -299,32 +299,32 @@ discard block |
||
299 | 299 | */ |
300 | 300 | public function process_ajax_search() { |
301 | 301 | $return = false; |
302 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'destination'){ |
|
302 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'destination') { |
|
303 | 303 | |
304 | - if ( isset($_POST['keyword'] )) { |
|
304 | + if (isset($_POST['keyword'])) { |
|
305 | 305 | $searched_items = false; |
306 | 306 | |
307 | - if(isset($_POST['keyword'] )) { |
|
307 | + if (isset($_POST['keyword'])) { |
|
308 | 308 | $keyphrases = $_POST['keyword']; |
309 | - }else{ |
|
309 | + }else { |
|
310 | 310 | $keyphrases = array(0); |
311 | 311 | } |
312 | 312 | |
313 | - if(!is_array($keyphrases)){ |
|
313 | + if (!is_array($keyphrases)) { |
|
314 | 314 | $keyphrases = array($keyphrases); |
315 | 315 | } |
316 | - foreach($keyphrases as &$keyword){ |
|
316 | + foreach ($keyphrases as &$keyword) { |
|
317 | 317 | $keyword = ltrim(rtrim($keyword)); |
318 | 318 | } |
319 | 319 | |
320 | 320 | $post_status = false; |
321 | - if(in_array('publish',$keyphrases)){ |
|
321 | + if (in_array('publish', $keyphrases)) { |
|
322 | 322 | $post_status = 'publish'; |
323 | 323 | } |
324 | - if(in_array('pending',$keyphrases)){ |
|
324 | + if (in_array('pending', $keyphrases)) { |
|
325 | 325 | $post_status = 'pending'; |
326 | 326 | } |
327 | - if(in_array('draft',$keyphrases)){ |
|
327 | + if (in_array('draft', $keyphrases)) { |
|
328 | 328 | $post_status = 'draft'; |
329 | 329 | } |
330 | 330 | |
@@ -332,29 +332,29 @@ discard block |
||
332 | 332 | |
333 | 333 | if (!empty($destination)) { |
334 | 334 | |
335 | - foreach($destination as $row){ |
|
335 | + foreach ($destination as $row) { |
|
336 | 336 | |
337 | 337 | //If we are searching for |
338 | - if(false !== $post_status){ |
|
338 | + if (false !== $post_status) { |
|
339 | 339 | |
340 | 340 | $current_status = get_post_status($row->post_id); |
341 | - if($current_status !== $post_status){ |
|
341 | + if ($current_status !== $post_status) { |
|
342 | 342 | continue; |
343 | 343 | } |
344 | 344 | $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row); |
345 | 345 | |
346 | 346 | |
347 | - }else{ |
|
347 | + }else { |
|
348 | 348 | //Search through each keyword. |
349 | - foreach($keyphrases as $keyphrase){ |
|
349 | + foreach ($keyphrases as $keyphrase) { |
|
350 | 350 | |
351 | 351 | //Make sure the keyphrase is turned into an array |
352 | - $keywords = explode(" ",$keyphrase); |
|
353 | - if(!is_array($keywords)){ |
|
352 | + $keywords = explode(" ", $keyphrase); |
|
353 | + if (!is_array($keywords)) { |
|
354 | 354 | $keywords = array($keywords); |
355 | 355 | } |
356 | 356 | |
357 | - if($this->multineedle_stripos(ltrim(rtrim($row->name)), $keywords) !== false){ |
|
357 | + if ($this->multineedle_stripos(ltrim(rtrim($row->name)), $keywords) !== false) { |
|
358 | 358 | $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row); |
359 | 359 | } |
360 | 360 | } |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | } |
363 | 363 | } |
364 | 364 | |
365 | - if(false !== $searched_items){ |
|
365 | + if (false !== $searched_items) { |
|
366 | 366 | ksort($searched_items); |
367 | 367 | $return = implode($searched_items); |
368 | 368 | } |
@@ -375,11 +375,11 @@ discard block |
||
375 | 375 | /** |
376 | 376 | * Formats the row for output on the screen. |
377 | 377 | */ |
378 | - public function format_row($row = false){ |
|
379 | - if(false !== $row){ |
|
378 | + public function format_row($row = false) { |
|
379 | + if (false !== $row) { |
|
380 | 380 | |
381 | 381 | $status = 'import'; |
382 | - if(0 !== $row->post_id){ |
|
382 | + if (0 !== $row->post_id) { |
|
383 | 383 | $status = '<a href="'.admin_url('/post.php?post='.$row->post_id.'&action=edit').'" target="_blank">'.get_post_status($row->post_id).'</a>'; |
384 | 384 | } |
385 | 385 | |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | <strong>'.$row->name.'</strong> - '.$status.' |
394 | 394 | </td> |
395 | 395 | <td class="date column-date"> |
396 | - <abbr title="'.date('Y/m/d',strtotime($row->last_modified)).'">'.date('Y/m/d',strtotime($row->last_modified)).'</abbr><br>Last Modified |
|
396 | + <abbr title="'.date('Y/m/d', strtotime($row->last_modified)).'">'.date('Y/m/d', strtotime($row->last_modified)).'</abbr><br>Last Modified |
|
397 | 397 | </td> |
398 | 398 | <td class="ssid column-ssid"> |
399 | 399 | '.$row->meta_value.' |
@@ -408,36 +408,36 @@ discard block |
||
408 | 408 | */ |
409 | 409 | public function process_ajax_import() { |
410 | 410 | $return = false; |
411 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'destination' && isset($_POST['wetu_id'])){ |
|
411 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'destination' && isset($_POST['wetu_id'])) { |
|
412 | 412 | |
413 | 413 | $wetu_id = $_POST['wetu_id']; |
414 | - if(isset($_POST['post_id'])){ |
|
414 | + if (isset($_POST['post_id'])) { |
|
415 | 415 | $post_id = $_POST['post_id']; |
416 | - }else{ |
|
416 | + }else { |
|
417 | 417 | $post_id = 0; |
418 | 418 | } |
419 | 419 | |
420 | - if(isset($_POST['team_members'])){ |
|
420 | + if (isset($_POST['team_members'])) { |
|
421 | 421 | $team_members = $_POST['team_members']; |
422 | - }else{ |
|
422 | + }else { |
|
423 | 423 | $team_members = false; |
424 | 424 | } |
425 | 425 | |
426 | 426 | $safari_brands = false; |
427 | 427 | |
428 | - if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
|
428 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
429 | 429 | $content = $_POST['content']; |
430 | - }else{ |
|
430 | + }else { |
|
431 | 431 | $content = false; |
432 | 432 | } |
433 | 433 | |
434 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
435 | - if($jdata) |
|
434 | + $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id); |
|
435 | + if ($jdata) |
|
436 | 436 | { |
437 | - $adata=json_decode($jdata,true); |
|
438 | - if(!empty($adata)) |
|
437 | + $adata = json_decode($jdata, true); |
|
438 | + if (!empty($adata)) |
|
439 | 439 | { |
440 | - $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
440 | + $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
|
441 | 441 | $this->format_completed_row($return); |
442 | 442 | } |
443 | 443 | } |
@@ -450,9 +450,9 @@ discard block |
||
450 | 450 | /** |
451 | 451 | * Connect to wetu |
452 | 452 | */ |
453 | - public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) { |
|
453 | + public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false) { |
|
454 | 454 | |
455 | - if(trim($data[0]['type'])=='Destination') |
|
455 | + if (trim($data[0]['type']) == 'Destination') |
|
456 | 456 | { |
457 | 457 | $post_name = $data_post_content = $data_post_excerpt = ''; |
458 | 458 | $post = array( |
@@ -462,46 +462,46 @@ discard block |
||
462 | 462 | $content_used_general_description = false; |
463 | 463 | |
464 | 464 | //Set the post_content |
465 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
466 | - if(isset($data[0]['content']['extended_description'])) |
|
465 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
466 | + if (isset($data[0]['content']['extended_description'])) |
|
467 | 467 | { |
468 | 468 | $data_post_content = $data[0]['content']['extended_description']; |
469 | - }elseif(isset($data[0]['content']['general_description'])){ |
|
469 | + }elseif (isset($data[0]['content']['general_description'])) { |
|
470 | 470 | $data_post_content = $data[0]['content']['general_description']; |
471 | 471 | $content_used_general_description = true; |
472 | - }elseif(isset($data[0]['content']['teaser_description'])){ |
|
472 | + }elseif (isset($data[0]['content']['teaser_description'])) { |
|
473 | 473 | $data_post_content = $data[0]['content']['teaser_description']; |
474 | 474 | } |
475 | 475 | $post['post_content'] = wp_strip_all_tags($data_post_content); |
476 | 476 | } |
477 | 477 | |
478 | 478 | //set the post_excerpt |
479 | - if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
480 | - if(isset($data[0]['content']['teaser_description'])){ |
|
479 | + if (false !== $importable_content && in_array('excerpt', $importable_content)) { |
|
480 | + if (isset($data[0]['content']['teaser_description'])) { |
|
481 | 481 | $data_post_excerpt = $data[0]['content']['teaser_description']; |
482 | - }elseif(isset($data[0]['content']['extended_description'])){ |
|
482 | + }elseif (isset($data[0]['content']['extended_description'])) { |
|
483 | 483 | $data_post_excerpt = $data[0]['content']['extended_description']; |
484 | - }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
484 | + }elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) { |
|
485 | 485 | $data_post_excerpt = $data[0]['content']['general_description']; |
486 | 486 | } |
487 | 487 | $post['post_excerpt'] = $data_post_excerpt; |
488 | 488 | } |
489 | 489 | |
490 | - if(false !== $id && '0' !== $id){ |
|
490 | + if (false !== $id && '0' !== $id) { |
|
491 | 491 | $post['ID'] = $id; |
492 | - if(isset($data[0]['name'])){ |
|
492 | + if (isset($data[0]['name'])) { |
|
493 | 493 | $post['post_title'] = $data[0]['name']; |
494 | 494 | $post['post_status'] = 'publish'; |
495 | - $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0); |
|
495 | + $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0); |
|
496 | 496 | } |
497 | 497 | $id = wp_update_post($post); |
498 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
499 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
500 | - }else{ |
|
498 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
499 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date); |
|
500 | + }else { |
|
501 | 501 | |
502 | 502 | //Set the name |
503 | - if(isset($data[0]['name'])){ |
|
504 | - $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0); |
|
503 | + if (isset($data[0]['name'])) { |
|
504 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0); |
|
505 | 505 | } |
506 | 506 | $post['post_name'] = $post_name; |
507 | 507 | $post['post_title'] = $data[0]['name']; |
@@ -509,49 +509,49 @@ discard block |
||
509 | 509 | $id = wp_insert_post($post); |
510 | 510 | |
511 | 511 | //Save the WETU ID and the Last date it was modified. |
512 | - if(false !== $id){ |
|
513 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
514 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
512 | + if (false !== $id) { |
|
513 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
514 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified'])); |
|
515 | 515 | } |
516 | 516 | } |
517 | 517 | |
518 | 518 | //Set the team member if it is there |
519 | - if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
520 | - $this->set_team_member($id,$team_members); |
|
519 | + if (post_type_exists('team') && false !== $team_members && '' !== $team_members) { |
|
520 | + $this->set_team_member($id, $team_members); |
|
521 | 521 | } |
522 | 522 | |
523 | - if(false !== $importable_content && in_array('location',$importable_content)){ |
|
524 | - $this->set_map_data($data,$id); |
|
523 | + if (false !== $importable_content && in_array('location', $importable_content)) { |
|
524 | + $this->set_map_data($data, $id); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | //Set the Room Data |
528 | - if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
529 | - $this->set_video_data($data,$id); |
|
528 | + if (false !== $importable_content && in_array('videos', $importable_content)) { |
|
529 | + $this->set_video_data($data, $id); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | //Set the Electricity |
533 | - if(false !== $importable_content && in_array('electricity',$importable_content)){ |
|
534 | - $this->set_travel_info($data,$id,'electricity'); |
|
533 | + if (false !== $importable_content && in_array('electricity', $importable_content)) { |
|
534 | + $this->set_travel_info($data, $id, 'electricity'); |
|
535 | 535 | } |
536 | 536 | //Set the cuisine |
537 | - if(false !== $importable_content && in_array('cuisine',$importable_content)){ |
|
538 | - $this->set_travel_info($data,$id,'cuisine'); |
|
537 | + if (false !== $importable_content && in_array('cuisine', $importable_content)) { |
|
538 | + $this->set_travel_info($data, $id, 'cuisine'); |
|
539 | 539 | } |
540 | 540 | //Set the banking |
541 | - if(false !== $importable_content && in_array('banking',$importable_content)){ |
|
542 | - $this->set_travel_info($data,$id,'banking'); |
|
541 | + if (false !== $importable_content && in_array('banking', $importable_content)) { |
|
542 | + $this->set_travel_info($data, $id, 'banking'); |
|
543 | 543 | } |
544 | 544 | //Set the transport |
545 | - if(false !== $importable_content && in_array('transport',$importable_content)){ |
|
546 | - $this->set_travel_info($data,$id,'transport'); |
|
545 | + if (false !== $importable_content && in_array('transport', $importable_content)) { |
|
546 | + $this->set_travel_info($data, $id, 'transport'); |
|
547 | 547 | } |
548 | 548 | //Set the dress |
549 | - if(false !== $importable_content && in_array('dress',$importable_content)){ |
|
550 | - $this->set_travel_info($data,$id,'dress'); |
|
549 | + if (false !== $importable_content && in_array('dress', $importable_content)) { |
|
550 | + $this->set_travel_info($data, $id, 'dress'); |
|
551 | 551 | } |
552 | 552 | //Set the climate |
553 | - if(false !== $importable_content && in_array('climate',$importable_content)){ |
|
554 | - $this->set_travel_info($data,$id,'climate'); |
|
553 | + if (false !== $importable_content && in_array('climate', $importable_content)) { |
|
554 | + $this->set_travel_info($data, $id, 'climate'); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | } |
@@ -561,54 +561,54 @@ discard block |
||
561 | 561 | /** |
562 | 562 | * Set the team memberon each item. |
563 | 563 | */ |
564 | - public function set_team_member($id,$team_members) { |
|
564 | + public function set_team_member($id, $team_members) { |
|
565 | 565 | |
566 | 566 | delete_post_meta($id, 'team_to_'.$this->tab_slug); |
567 | - foreach($team_members as $team){ |
|
568 | - add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
567 | + foreach ($team_members as $team) { |
|
568 | + add_post_meta($id, 'team_to_'.$this->tab_slug, $team); |
|
569 | 569 | } |
570 | 570 | } |
571 | 571 | |
572 | 572 | /** |
573 | 573 | * Saves the longitude and lattitude, as well as sets the map marker. |
574 | 574 | */ |
575 | - public function set_map_data($data,$id) { |
|
575 | + public function set_map_data($data, $id) { |
|
576 | 576 | $longitude = $latitude = $address = false; |
577 | 577 | $zoom = '15'; |
578 | 578 | |
579 | - if(isset($data[0]['position'])){ |
|
579 | + if (isset($data[0]['position'])) { |
|
580 | 580 | |
581 | - if(isset($data[0]['position']['driving_latitude'])){ |
|
581 | + if (isset($data[0]['position']['driving_latitude'])) { |
|
582 | 582 | $latitude = $data[0]['position']['driving_latitude']; |
583 | - }elseif(isset($data[0]['position']['latitude'])){ |
|
583 | + }elseif (isset($data[0]['position']['latitude'])) { |
|
584 | 584 | $latitude = $data[0]['position']['latitude']; |
585 | 585 | } |
586 | 586 | |
587 | - if(isset($data[0]['position']['driving_longitude'])){ |
|
587 | + if (isset($data[0]['position']['driving_longitude'])) { |
|
588 | 588 | $longitude = $data[0]['position']['driving_longitude']; |
589 | - }elseif(isset($data[0]['position']['longitude'])){ |
|
589 | + }elseif (isset($data[0]['position']['longitude'])) { |
|
590 | 590 | $longitude = $data[0]['position']['longitude']; |
591 | 591 | } |
592 | 592 | |
593 | 593 | } |
594 | - if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){ |
|
595 | - if(isset($data[0]['content']['contact_information']['address'])){ |
|
594 | + if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) { |
|
595 | + if (isset($data[0]['content']['contact_information']['address'])) { |
|
596 | 596 | $address = strip_tags($data[0]['content']['contact_information']['address']); |
597 | 597 | |
598 | - $address = explode("\n",$address); |
|
599 | - foreach($address as $bitkey => $bit){ |
|
598 | + $address = explode("\n", $address); |
|
599 | + foreach ($address as $bitkey => $bit) { |
|
600 | 600 | $bit = ltrim(rtrim($bit)); |
601 | - if(false === $bit || '' === $bit || null === $bit or empty($bit)){ |
|
601 | + if (false === $bit || '' === $bit || null === $bit or empty($bit)) { |
|
602 | 602 | unset($address[$bitkey]); |
603 | 603 | } |
604 | 604 | } |
605 | - $address = implode(', ',$address); |
|
605 | + $address = implode(', ', $address); |
|
606 | 606 | $address = str_replace(', , ', ', ', $address); |
607 | 607 | } |
608 | 608 | } |
609 | 609 | |
610 | 610 | |
611 | - if(false !== $longitude){ |
|
611 | + if (false !== $longitude) { |
|
612 | 612 | $location_data = array( |
613 | 613 | 'address' => $address, |
614 | 614 | 'lat' => $latitude, |
@@ -616,11 +616,11 @@ discard block |
||
616 | 616 | 'zoom' => $zoom, |
617 | 617 | 'elevation' => '', |
618 | 618 | ); |
619 | - if(false !== $id && '0' !== $id){ |
|
620 | - $prev = get_post_meta($id,'location',true); |
|
621 | - update_post_meta($id,'location',$location_data,$prev); |
|
622 | - }else{ |
|
623 | - add_post_meta($id,'location',$location_data,true); |
|
619 | + if (false !== $id && '0' !== $id) { |
|
620 | + $prev = get_post_meta($id, 'location', true); |
|
621 | + update_post_meta($id, 'location', $location_data, $prev); |
|
622 | + }else { |
|
623 | + add_post_meta($id, 'location', $location_data, true); |
|
624 | 624 | } |
625 | 625 | } |
626 | 626 | } |
@@ -628,11 +628,11 @@ discard block |
||
628 | 628 | /** |
629 | 629 | * Saves the room data |
630 | 630 | */ |
631 | - public function set_travel_info($data,$id,$meta_key) { |
|
631 | + public function set_travel_info($data, $id, $meta_key) { |
|
632 | 632 | |
633 | - if(!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])){ |
|
633 | + if (!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])) { |
|
634 | 634 | $content = strip_tags($data[0]['travel_information'][$meta_key]); |
635 | - $this->save_custom_field($content,$meta_key,$id); |
|
635 | + $this->save_custom_field($content, $meta_key, $id); |
|
636 | 636 | } |
637 | 637 | } |
638 | 638 |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * Display the importer administration screen |
107 | 107 | */ |
108 | 108 | public function display_page() { |
109 | - ?> |
|
109 | + ?> |
|
110 | 110 | <div class="wrap"> |
111 | 111 | <?php screen_icon(); ?> |
112 | 112 | |
@@ -233,13 +233,13 @@ discard block |
||
233 | 233 | $result = $this->update_options(); |
234 | 234 | |
235 | 235 | if(true === $result){ |
236 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
237 | - }else{ |
|
238 | - echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
239 | - } |
|
236 | + echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
237 | + }else{ |
|
238 | + echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
239 | + } |
|
240 | 240 | }else{ |
241 | 241 | echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
242 | - } |
|
242 | + } |
|
243 | 243 | echo '</h3></div>'; |
244 | 244 | } |
245 | 245 | |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | $tours = json_decode($data, true); |
252 | 252 | |
253 | 253 | if(isset($tours['error'])){ |
254 | - return $tours['error']; |
|
255 | - }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
254 | + return $tours['error']; |
|
255 | + }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
256 | 256 | set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2); |
257 | 257 | return true; |
258 | 258 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | $keyphrases = $_POST['keyword']; |
302 | 302 | }else{ |
303 | 303 | $keyphrases = array(0); |
304 | - } |
|
304 | + } |
|
305 | 305 | |
306 | 306 | if(!is_array($keyphrases)){ |
307 | 307 | $keyphrases = array($keyphrases); |
@@ -330,15 +330,15 @@ discard block |
||
330 | 330 | |
331 | 331 | foreach($tours as $row_key => $row){ |
332 | 332 | |
333 | - if(isset($row['is_disabled']) && true === $row['is_disabled']){ |
|
334 | - continue; |
|
335 | - } |
|
333 | + if(isset($row['is_disabled']) && true === $row['is_disabled']){ |
|
334 | + continue; |
|
335 | + } |
|
336 | 336 | |
337 | - /*if('Sample' === $row['type']){ |
|
337 | + /*if('Sample' === $row['type']){ |
|
338 | 338 | continue; |
339 | 339 | }*/ |
340 | 340 | |
341 | - //If this is a current tour, add its ID to the row. |
|
341 | + //If this is a current tour, add its ID to the row. |
|
342 | 342 | $row['post_id'] = 0; |
343 | 343 | if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){ |
344 | 344 | $row['post_id'] = $current_tours[$row['identifier']]->post_id; |
@@ -347,31 +347,31 @@ discard block |
||
347 | 347 | //If we are searching for |
348 | 348 | if(false !== $post_status){ |
349 | 349 | |
350 | - if('import' === $post_status){ |
|
350 | + if('import' === $post_status){ |
|
351 | 351 | |
352 | 352 | if(0 !== $row['post_id']){ |
353 | - continue; |
|
353 | + continue; |
|
354 | 354 | }else{ |
355 | 355 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
356 | - } |
|
356 | + } |
|
357 | 357 | |
358 | 358 | |
359 | - }else{ |
|
359 | + }else{ |
|
360 | 360 | |
361 | 361 | if(0 === $row['post_id']){ |
362 | 362 | continue; |
363 | 363 | }else{ |
364 | 364 | $current_status = get_post_status($row['post_id']); |
365 | 365 | if($current_status !== $post_status){ |
366 | - continue; |
|
367 | - } |
|
366 | + continue; |
|
367 | + } |
|
368 | 368 | |
369 | 369 | } |
370 | 370 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
371 | 371 | |
372 | - } |
|
372 | + } |
|
373 | 373 | |
374 | - }else{ |
|
374 | + }else{ |
|
375 | 375 | //Search through each keyword. |
376 | 376 | foreach($keyphrases as $keyphrase){ |
377 | 377 | |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
386 | 386 | } |
387 | 387 | } |
388 | - } |
|
388 | + } |
|
389 | 389 | } |
390 | 390 | } |
391 | 391 | |
@@ -450,17 +450,17 @@ discard block |
||
450 | 450 | $content = false; |
451 | 451 | } |
452 | 452 | |
453 | - $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
453 | + $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
454 | 454 | |
455 | - if($jdata) |
|
456 | - { |
|
455 | + if($jdata) |
|
456 | + { |
|
457 | 457 | $jdata=json_decode($jdata,true); |
458 | - if(!empty($jdata)) |
|
459 | - { |
|
460 | - $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
461 | - $this->format_completed_row($return); |
|
462 | - } |
|
463 | - } |
|
458 | + if(!empty($jdata)) |
|
459 | + { |
|
460 | + $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
461 | + $this->format_completed_row($return); |
|
462 | + } |
|
463 | + } |
|
464 | 464 | die(); |
465 | 465 | } |
466 | 466 | |
@@ -468,61 +468,61 @@ discard block |
||
468 | 468 | |
469 | 469 | /** |
470 | 470 | * Connect to wetu |
471 | - * |
|
472 | - * @param $data array |
|
473 | - * @param $wetu_id string |
|
471 | + * |
|
472 | + * @param $data array |
|
473 | + * @param $wetu_id string |
|
474 | 474 | */ |
475 | 475 | public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) { |
476 | - $post_name = $data_post_content = $data_post_excerpt = ''; |
|
477 | - $post = array( |
|
478 | - 'post_type' => 'tour', |
|
479 | - ); |
|
476 | + $post_name = $data_post_content = $data_post_excerpt = ''; |
|
477 | + $post = array( |
|
478 | + 'post_type' => 'tour', |
|
479 | + ); |
|
480 | 480 | |
481 | - //Set the post_content |
|
481 | + //Set the post_content |
|
482 | 482 | $content_used_general_description = false; |
483 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
484 | - $data_post_content = ''; |
|
485 | - |
|
486 | - if(isset($data['description'])){ |
|
487 | - $data_post_content = $data['description']; |
|
488 | - }elseif(isset($data['summary'])){ |
|
489 | - $data_post_content = $data['summary']; |
|
490 | - $content_used_general_description = true; |
|
491 | - } |
|
492 | - $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
493 | - } |
|
494 | - |
|
495 | - //set the post_excerpt |
|
496 | - if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
497 | - if(isset($data['summary']) && false === $content_used_general_description){ |
|
498 | - $post['post_excerpt'] = $data['summary']; |
|
499 | - } |
|
500 | - } |
|
501 | - |
|
502 | - //Create or update the post |
|
503 | - if(false !== $id && '0' !== $id){ |
|
504 | - $post['ID'] = $id; |
|
505 | - $post['post_status'] = 'publish'; |
|
506 | - $id = wp_update_post($post); |
|
507 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
508 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
509 | - }else{ |
|
510 | - |
|
511 | - //Set the name |
|
512 | - if(isset($data['name'])){ |
|
513 | - $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
514 | - } |
|
515 | - $post['post_name'] = $post_name; |
|
516 | - $post['post_title'] = $data['name']; |
|
517 | - $post['post_status'] = 'publish'; |
|
518 | - $id = wp_insert_post($post); |
|
519 | - |
|
520 | - //Save the WETU ID and the Last date it was modified. |
|
521 | - if(false !== $id){ |
|
522 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
523 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
524 | - } |
|
525 | - } |
|
483 | + if(false !== $importable_content && in_array('description',$importable_content)){ |
|
484 | + $data_post_content = ''; |
|
485 | + |
|
486 | + if(isset($data['description'])){ |
|
487 | + $data_post_content = $data['description']; |
|
488 | + }elseif(isset($data['summary'])){ |
|
489 | + $data_post_content = $data['summary']; |
|
490 | + $content_used_general_description = true; |
|
491 | + } |
|
492 | + $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
493 | + } |
|
494 | + |
|
495 | + //set the post_excerpt |
|
496 | + if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
497 | + if(isset($data['summary']) && false === $content_used_general_description){ |
|
498 | + $post['post_excerpt'] = $data['summary']; |
|
499 | + } |
|
500 | + } |
|
501 | + |
|
502 | + //Create or update the post |
|
503 | + if(false !== $id && '0' !== $id){ |
|
504 | + $post['ID'] = $id; |
|
505 | + $post['post_status'] = 'publish'; |
|
506 | + $id = wp_update_post($post); |
|
507 | + $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
508 | + update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
509 | + }else{ |
|
510 | + |
|
511 | + //Set the name |
|
512 | + if(isset($data['name'])){ |
|
513 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
514 | + } |
|
515 | + $post['post_name'] = $post_name; |
|
516 | + $post['post_title'] = $data['name']; |
|
517 | + $post['post_status'] = 'publish'; |
|
518 | + $id = wp_insert_post($post); |
|
519 | + |
|
520 | + //Save the WETU ID and the Last date it was modified. |
|
521 | + if(false !== $id){ |
|
522 | + add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
523 | + add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
524 | + } |
|
525 | + } |
|
526 | 526 | |
527 | 527 | |
528 | 528 | //Set the price |
@@ -535,9 +535,9 @@ discard block |
||
535 | 535 | $this->set_duration($data,$id); |
536 | 536 | } |
537 | 537 | |
538 | - if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
539 | - $this->process_itineraries($data,$id,$importable_content); |
|
540 | - } |
|
538 | + if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
539 | + $this->process_itineraries($data,$id,$importable_content); |
|
540 | + } |
|
541 | 541 | |
542 | 542 | if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){ |
543 | 543 | $this->process_map_points($data,$id); |
@@ -548,24 +548,24 @@ discard block |
||
548 | 548 | 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))){ |
549 | 549 | $this->find_attachments($id); |
550 | 550 | } |
551 | - //Set the featured image |
|
552 | - //TODO Test These |
|
553 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
554 | - $this->set_featured_image($data,$id); |
|
555 | - } |
|
551 | + //Set the featured image |
|
552 | + //TODO Test These |
|
553 | + if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
554 | + $this->set_featured_image($data,$id); |
|
555 | + } |
|
556 | 556 | |
557 | 557 | //TODO Test These |
558 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
559 | - $this->set_banner_image($data,$id); |
|
560 | - } |
|
558 | + if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
559 | + $this->set_banner_image($data,$id); |
|
560 | + } |
|
561 | 561 | |
562 | 562 | //TODO Test These |
563 | - //Import the main gallery |
|
564 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
565 | - $this->create_main_gallery($data,$id); |
|
566 | - } |
|
563 | + //Import the main gallery |
|
564 | + if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
565 | + $this->create_main_gallery($data,$id); |
|
566 | + } |
|
567 | 567 | |
568 | - return $id; |
|
568 | + return $id; |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
@@ -677,31 +677,31 @@ discard block |
||
677 | 677 | */ |
678 | 678 | public function process_map_points($data,$id) { |
679 | 679 | |
680 | - if(!empty($data['routes'])){ |
|
680 | + if(!empty($data['routes'])){ |
|
681 | 681 | |
682 | - delete_post_meta($id,'wetu_map_points'); |
|
682 | + delete_post_meta($id,'wetu_map_points'); |
|
683 | 683 | |
684 | - $points = array(); |
|
684 | + $points = array(); |
|
685 | 685 | |
686 | - foreach($data['routes'] as $route){ |
|
686 | + foreach($data['routes'] as $route){ |
|
687 | 687 | |
688 | 688 | |
689 | - if(isset($route['points']) && '' !== $route['points']){ |
|
689 | + if(isset($route['points']) && '' !== $route['points']){ |
|
690 | 690 | |
691 | - $temp_points = explode(';',$route['points']); |
|
692 | - $point_counter = count($temp_points); |
|
691 | + $temp_points = explode(';',$route['points']); |
|
692 | + $point_counter = count($temp_points); |
|
693 | 693 | |
694 | 694 | for ($x = 0; $x <= $point_counter; $x++) { |
695 | - $y = $x+1; |
|
695 | + $y = $x+1; |
|
696 | 696 | $points[] = $temp_points[$x].','.$temp_points[$y]; |
697 | 697 | $x++; |
698 | 698 | } |
699 | 699 | } |
700 | - } |
|
701 | - if(!empty($points)){ |
|
700 | + } |
|
701 | + if(!empty($points)){ |
|
702 | 702 | $this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true); |
703 | - } |
|
704 | - } |
|
703 | + } |
|
704 | + } |
|
705 | 705 | |
706 | 706 | } |
707 | 707 | |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | * Set the Itinerary Day |
710 | 710 | */ |
711 | 711 | public function set_itinerary_day($day,$id) { |
712 | - $this->save_custom_field($day,'itinerary',$id,false,false); |
|
712 | + $this->save_custom_field($day,'itinerary',$id,false,false); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | /** |
@@ -717,8 +717,8 @@ discard block |
||
717 | 717 | */ |
718 | 718 | public function set_price($data,$id) { |
719 | 719 | if(isset($data['price']) && ''!== $data['price']){ |
720 | - $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
|
721 | - $this->save_custom_field($price,'price',$id); |
|
720 | + $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
|
721 | + $this->save_custom_field($price,'price',$id); |
|
722 | 722 | } |
723 | 723 | } |
724 | 724 | |
@@ -739,35 +739,35 @@ discard block |
||
739 | 739 | */ |
740 | 740 | public function set_accommodation($day,$id) { |
741 | 741 | |
742 | - $ac_id = false; |
|
742 | + $ac_id = false; |
|
743 | 743 | $this->current_accommodation = $this->find_current_accommodation(); |
744 | 744 | |
745 | 745 | if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){ |
746 | 746 | |
747 | 747 | if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
748 | - $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
748 | + $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
749 | 749 | }else{ |
750 | 750 | $ac_id = wp_insert_post(array( |
751 | - 'post_type' => 'accommodation', |
|
752 | - 'post_status' => 'draft', |
|
753 | - 'post_title' => $day['content_entity_id'] |
|
754 | - )); |
|
751 | + 'post_type' => 'accommodation', |
|
752 | + 'post_status' => 'draft', |
|
753 | + 'post_title' => $day['content_entity_id'] |
|
754 | + )); |
|
755 | 755 | $this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id); |
756 | 756 | } |
757 | 757 | |
758 | 758 | if('' !== $ac_id && false !== $ac_id){ |
759 | - $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
759 | + $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
760 | 760 | $this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false); |
761 | - } |
|
761 | + } |
|
762 | 762 | } |
763 | 763 | return $ac_id; |
764 | 764 | } |
765 | 765 | |
766 | 766 | /** |
767 | 767 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
768 | - * |
|
769 | - * @param $post_type string |
|
770 | - * @return boolean / array |
|
768 | + * |
|
769 | + * @param $post_type string |
|
770 | + * @return boolean / array |
|
771 | 771 | */ |
772 | 772 | public function find_current_accommodation($post_type='accommodation') { |
773 | 773 | global $wpdb; |
@@ -775,16 +775,16 @@ discard block |
||
775 | 775 | |
776 | 776 | $return = false; |
777 | 777 | if(!empty($accommodation)){ |
778 | - foreach($accommodation as $key => $acc){ |
|
778 | + foreach($accommodation as $key => $acc){ |
|
779 | 779 | $return[$acc->meta_value] = $acc->post_id; |
780 | - } |
|
781 | - } |
|
780 | + } |
|
781 | + } |
|
782 | 782 | return $return; |
783 | 783 | } |
784 | 784 | |
785 | 785 | /** |
786 | 786 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
787 | - * @return boolean / array |
|
787 | + * @return boolean / array |
|
788 | 788 | */ |
789 | 789 | public function find_current_destinations() { |
790 | 790 | return $this->find_current_accommodation('destination'); |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | $country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true); |
812 | 812 | if(false !== $country_wetu_id){ |
813 | 813 | $this->set_country($country_wetu_id, $id); |
814 | - } |
|
814 | + } |
|
815 | 815 | |
816 | 816 | }else { |
817 | 817 | |
@@ -822,27 +822,27 @@ discard block |
||
822 | 822 | |
823 | 823 | if (!empty($destination_data) && !isset($destination_data['error'])) { |
824 | 824 | |
825 | - $destination_title = $day['destination_content_entity_id']; |
|
825 | + $destination_title = $day['destination_content_entity_id']; |
|
826 | 826 | |
827 | - if(isset($destination_data[0]['name'])){ |
|
827 | + if(isset($destination_data[0]['name'])){ |
|
828 | 828 | $destination_title = $destination_data[0]['name']; |
829 | - } |
|
829 | + } |
|
830 | 830 | |
831 | - if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
832 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
831 | + if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
832 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
833 | 833 | |
834 | 834 | $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
835 | - } |
|
835 | + } |
|
836 | 836 | |
837 | - $dest_post = array( |
|
837 | + $dest_post = array( |
|
838 | 838 | 'post_type' => 'destination', |
839 | 839 | 'post_status' => 'draft', |
840 | 840 | 'post_title' => $destination_title |
841 | 841 | ); |
842 | 842 | |
843 | - if(false !== $country_id){ |
|
843 | + if(false !== $country_id){ |
|
844 | 844 | $dest_post['post_parent'] = $country_id; |
845 | - } |
|
845 | + } |
|
846 | 846 | $dest_id = wp_insert_post($dest_post); |
847 | 847 | |
848 | 848 | //Make sure we register the |
@@ -864,50 +864,50 @@ discard block |
||
864 | 864 | * Connects the destinations post type |
865 | 865 | * |
866 | 866 | * @param $dest_id string |
867 | - * @param $country_id array |
|
867 | + * @param $country_id array |
|
868 | 868 | * @param $id string |
869 | 869 | */ |
870 | 870 | public function set_country($country_wetu_id, $id) { |
871 | - $country_id = false; |
|
871 | + $country_id = false; |
|
872 | 872 | $this->current_destinations = $this->find_current_destinations(); |
873 | 873 | |
874 | - if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
875 | - $country_id = $this->current_destinations[$country_wetu_id]; |
|
876 | - } else { |
|
874 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
875 | + $country_id = $this->current_destinations[$country_wetu_id]; |
|
876 | + } else { |
|
877 | 877 | |
878 | - $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
878 | + $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
879 | 879 | |
880 | - if ($country_json) { |
|
881 | - $country_data = json_decode($country_json, true); |
|
880 | + if ($country_json) { |
|
881 | + $country_data = json_decode($country_json, true); |
|
882 | 882 | |
883 | - if (!empty($country_data) && !isset($country_data['error'])) { |
|
883 | + if (!empty($country_data) && !isset($country_data['error'])) { |
|
884 | 884 | |
885 | 885 | //Format the title of the destination if its available, otherwise default to the WETU ID. |
886 | - $country_title = $country_wetu_id; |
|
887 | - if (isset($country_data[0]['name'])) { |
|
886 | + $country_title = $country_wetu_id; |
|
887 | + if (isset($country_data[0]['name'])) { |
|
888 | 888 | $country_title = $country_data[0]['name']; |
889 | - } |
|
889 | + } |
|
890 | 890 | |
891 | 891 | $country_id = wp_insert_post(array( |
892 | - 'post_type' => 'destination', |
|
893 | - 'post_status' => 'draft', |
|
894 | - 'post_title' => $country_title |
|
895 | - )); |
|
892 | + 'post_type' => 'destination', |
|
893 | + 'post_status' => 'draft', |
|
894 | + 'post_title' => $country_title |
|
895 | + )); |
|
896 | 896 | //add the country to the current destination stack |
897 | 897 | $this->current_destinations[$country_wetu_id] = $country_id; |
898 | 898 | |
899 | 899 | //Save the wetu field |
900 | - $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
901 | - } |
|
902 | - } |
|
903 | - } |
|
900 | + $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
901 | + } |
|
902 | + } |
|
903 | + } |
|
904 | 904 | |
905 | - if ('' !== $country_id && false !== $country_id) { |
|
906 | - $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
907 | - $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
905 | + if ('' !== $country_id && false !== $country_id) { |
|
906 | + $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
907 | + $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
908 | 908 | |
909 | - return $country_id; |
|
910 | - } |
|
909 | + return $country_id; |
|
910 | + } |
|
911 | 911 | } |
912 | 912 | } |
913 | 913 | $wetu_importer_tours = new WETU_Importer_Tours(); |
914 | 914 | \ No newline at end of file |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | public function __construct() { |
74 | 74 | $this->set_variables(); |
75 | 75 | |
76 | - add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') ); |
|
77 | - add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search')); |
|
78 | - add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search')); |
|
76 | + add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page')); |
|
77 | + add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
78 | + add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
79 | 79 | |
80 | - add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import')); |
|
81 | - add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import')); |
|
80 | + add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import')); |
|
81 | + add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import')); |
|
82 | 82 | |
83 | - $temp_options = get_option('_lsx-to_settings',false); |
|
84 | - if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){ |
|
83 | + $temp_options = get_option('_lsx-to_settings', false); |
|
84 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
85 | 85 | $this->options = $temp_options[$this->plugin_slug]; |
86 | 86 | } |
87 | 87 | } |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | { |
94 | 94 | parent::set_variables(); |
95 | 95 | |
96 | - if ( false !== $this->api_username && false !== $this->api_password ) { |
|
96 | + if (false !== $this->api_username && false !== $this->api_password) { |
|
97 | 97 | $this->url = 'https://wetu.com/API/Itinerary/'; |
98 | - $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
|
99 | - } elseif ( false !== $this->api_key ) { |
|
100 | - $this->url = 'https://wetu.com/API/Itinerary/' . $this->api_key; |
|
98 | + $this->url_qs = 'username='.$this->api_username.'&password='.$this->api_password; |
|
99 | + } elseif (false !== $this->api_key) { |
|
100 | + $this->url = 'https://wetu.com/API/Itinerary/'.$this->api_key; |
|
101 | 101 | $this->url_qs = ''; |
102 | 102 | } |
103 | 103 | } |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | <form method="get" action="" id="posts-filter"> |
118 | 118 | <input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" /> |
119 | 119 | |
120 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
121 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
120 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
121 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
122 | 122 | </p> |
123 | 123 | |
124 | 124 | <table class="wp-list-table widefat fixed posts"> |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | <tbody id="the-list"> |
128 | 128 | <tr class="post-0 type-tour status-none" id="post-0"> |
129 | 129 | <th class="check-column" scope="row"> |
130 | - <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label> |
|
130 | + <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label> |
|
131 | 131 | </th> |
132 | 132 | <td class="post-title page-title column-title"> |
133 | 133 | <strong> |
134 | - <?php _e('Enter a title to search for','wetu-importer'); ?> |
|
134 | + <?php _e('Enter a title to search for', 'wetu-importer'); ?> |
|
135 | 135 | </strong> |
136 | 136 | </td> |
137 | 137 | <td class="date column-date"> |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | |
146 | 146 | </table> |
147 | 147 | |
148 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
149 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
148 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
149 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
150 | 150 | </p> |
151 | 151 | </form> |
152 | 152 | |
@@ -158,35 +158,35 @@ discard block |
||
158 | 158 | <div style="width:30%;display:block;float:left;"> |
159 | 159 | <h3><?php _e('What content to Sync from WETU'); ?></h3> |
160 | 160 | <ul> |
161 | - <li><input class="content" type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
162 | - <li><input class="content" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li> |
|
161 | + <li><input class="content" type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
162 | + <li><input class="content" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li> |
|
163 | 163 | |
164 | - <li><input class="content" type="checkbox" name="content[]" value="price" /> <?php _e('Price','wetu-importer'); ?></li> |
|
165 | - <li><input class="content" type="checkbox" name="content[]" value="duration" /> <?php _e('Duration','wetu-importer'); ?></li> |
|
164 | + <li><input class="content" type="checkbox" name="content[]" value="price" /> <?php _e('Price', 'wetu-importer'); ?></li> |
|
165 | + <li><input class="content" type="checkbox" name="content[]" value="duration" /> <?php _e('Duration', 'wetu-importer'); ?></li> |
|
166 | 166 | |
167 | - <li><input class="content" type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li> |
|
167 | + <li><input class="content" type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li> |
|
168 | 168 | |
169 | - <li><input class="content" type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days','wetu-importer'); ?></li> |
|
169 | + <li><input class="content" type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days', 'wetu-importer'); ?></li> |
|
170 | 170 | |
171 | - <?php if(class_exists('TO_Maps')){ ?> |
|
172 | - <li><input class="content" type="checkbox" name="content[]" value="map" /> <?php _e('Map Coordinates (generates a KML file)','wetu-importer'); ?></li> |
|
171 | + <?php if (class_exists('TO_Maps')) { ?> |
|
172 | + <li><input class="content" type="checkbox" name="content[]" value="map" /> <?php _e('Map Coordinates (generates a KML file)', 'wetu-importer'); ?></li> |
|
173 | 173 | <?php } ?> |
174 | 174 | </ul> |
175 | 175 | </div> |
176 | 176 | <div style="width:30%;display:block;float:left;"> |
177 | 177 | <h3><?php _e('Itinerary Info'); ?></h3> |
178 | 178 | <ul> |
179 | - <li><input class="content" type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
180 | - <li><input class="content" type="checkbox" name="content[]" value="itinerary_gallery" /> <?php _e('Gallery','wetu-importer'); ?></li> |
|
179 | + <li><input class="content" type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
180 | + <li><input class="content" type="checkbox" name="content[]" value="itinerary_gallery" /> <?php _e('Gallery', 'wetu-importer'); ?></li> |
|
181 | 181 | </ul> |
182 | 182 | |
183 | 183 | <h4><?php _e('Additional Content'); ?></h4> |
184 | 184 | <ul> |
185 | - <li><input class="content" type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation','wetu-importer'); ?></li> |
|
186 | - <li><input class="content" type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations','wetu-importer'); ?></li> |
|
185 | + <li><input class="content" type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation', 'wetu-importer'); ?></li> |
|
186 | + <li><input class="content" type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations', 'wetu-importer'); ?></li> |
|
187 | 187 | </ul> |
188 | 188 | </div> |
189 | - <?php if(class_exists('TO_Team')){ ?> |
|
189 | + <?php if (class_exists('TO_Team')) { ?> |
|
190 | 190 | <div style="width:30%;display:block;float:left;"> |
191 | 191 | <h3><?php _e('Assign a Team Member'); ?></h3> |
192 | 192 | <?php $this->team_member_checkboxes(); ?> |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | |
200 | 200 | <h3><?php _e('Your List'); ?></h3> |
201 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
201 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
202 | 202 | <table class="wp-list-table widefat fixed posts"> |
203 | 203 | <?php $this->table_header(); ?> |
204 | 204 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | |
211 | 211 | </table> |
212 | 212 | |
213 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
213 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
214 | 214 | </form> |
215 | 215 | </div> |
216 | 216 | |
@@ -228,17 +228,17 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function update_options_form() { |
230 | 230 | $tours = get_transient('lsx_ti_tours'); |
231 | - echo '<div class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').' - '; |
|
232 | - if('' === $tours || false === $tours || isset($_GET['refresh_tours'])){ |
|
231 | + echo '<div class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').' - '; |
|
232 | + if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) { |
|
233 | 233 | $result = $this->update_options(); |
234 | 234 | |
235 | - if(true === $result){ |
|
236 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
237 | - }else{ |
|
235 | + if (true === $result) { |
|
236 | + echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>'; |
|
237 | + }else { |
|
238 | 238 | echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
239 | 239 | } |
240 | - }else{ |
|
241 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
240 | + }else { |
|
241 | + echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>'; |
|
242 | 242 | } |
243 | 243 | echo '</h3></div>'; |
244 | 244 | } |
@@ -247,13 +247,13 @@ discard block |
||
247 | 247 | * Save the list of Tours into an option |
248 | 248 | */ |
249 | 249 | public function update_options() { |
250 | - $data = file_get_contents( $this->url . '/V7/List?' . $this->url_qs . '&own=true&type=All' ); |
|
250 | + $data = file_get_contents($this->url.'/V7/List?'.$this->url_qs.'&own=true&type=All'); |
|
251 | 251 | $tours = json_decode($data, true); |
252 | 252 | |
253 | - if(isset($tours['error'])){ |
|
253 | + if (isset($tours['error'])) { |
|
254 | 254 | return $tours['error']; |
255 | 255 | }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
256 | - set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2); |
|
256 | + set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2); |
|
257 | 257 | return true; |
258 | 258 | } |
259 | 259 | } |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | |
278 | 278 | LIMIT 0,500 |
279 | 279 | "); |
280 | - if(null !== $current_tours && !empty($current_tours)){ |
|
281 | - foreach($current_tours as $tour){ |
|
280 | + if (null !== $current_tours && !empty($current_tours)) { |
|
281 | + foreach ($current_tours as $tour) { |
|
282 | 282 | $return[$tour->meta_value] = $tour; |
283 | 283 | } |
284 | 284 | } |
@@ -291,36 +291,36 @@ discard block |
||
291 | 291 | public function process_ajax_search() { |
292 | 292 | $return = false; |
293 | 293 | |
294 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug){ |
|
294 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) { |
|
295 | 295 | $tours = get_transient('lsx_ti_tours'); |
296 | - if ( false !== $tours) { |
|
296 | + if (false !== $tours) { |
|
297 | 297 | |
298 | 298 | $searched_items = false; |
299 | 299 | |
300 | - if(isset($_POST['keyword'] )) { |
|
300 | + if (isset($_POST['keyword'])) { |
|
301 | 301 | $keyphrases = $_POST['keyword']; |
302 | - }else{ |
|
302 | + }else { |
|
303 | 303 | $keyphrases = array(0); |
304 | 304 | } |
305 | 305 | |
306 | - if(!is_array($keyphrases)){ |
|
306 | + if (!is_array($keyphrases)) { |
|
307 | 307 | $keyphrases = array($keyphrases); |
308 | 308 | } |
309 | - foreach($keyphrases as &$keyword){ |
|
309 | + foreach ($keyphrases as &$keyword) { |
|
310 | 310 | $keyword = ltrim(rtrim($keyword)); |
311 | 311 | } |
312 | 312 | |
313 | 313 | $post_status = false; |
314 | - if(in_array('publish',$keyphrases)){ |
|
314 | + if (in_array('publish', $keyphrases)) { |
|
315 | 315 | $post_status = 'publish'; |
316 | 316 | } |
317 | - if(in_array('pending',$keyphrases)){ |
|
317 | + if (in_array('pending', $keyphrases)) { |
|
318 | 318 | $post_status = 'pending'; |
319 | 319 | } |
320 | - if(in_array('draft',$keyphrases)){ |
|
320 | + if (in_array('draft', $keyphrases)) { |
|
321 | 321 | $post_status = 'draft'; |
322 | 322 | } |
323 | - if(in_array('import',$keyphrases)){ |
|
323 | + if (in_array('import', $keyphrases)) { |
|
324 | 324 | $post_status = 'import'; |
325 | 325 | } |
326 | 326 | |
@@ -328,9 +328,9 @@ discard block |
||
328 | 328 | if (!empty($tours)) { |
329 | 329 | $current_tours = $this->find_current_tours(); |
330 | 330 | |
331 | - foreach($tours as $row_key => $row){ |
|
331 | + foreach ($tours as $row_key => $row) { |
|
332 | 332 | |
333 | - if(isset($row['is_disabled']) && true === $row['is_disabled']){ |
|
333 | + if (isset($row['is_disabled']) && true === $row['is_disabled']) { |
|
334 | 334 | continue; |
335 | 335 | } |
336 | 336 | |
@@ -340,29 +340,29 @@ discard block |
||
340 | 340 | |
341 | 341 | //If this is a current tour, add its ID to the row. |
342 | 342 | $row['post_id'] = 0; |
343 | - if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){ |
|
343 | + if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) { |
|
344 | 344 | $row['post_id'] = $current_tours[$row['identifier']]->post_id; |
345 | 345 | } |
346 | 346 | |
347 | 347 | //If we are searching for |
348 | - if(false !== $post_status){ |
|
348 | + if (false !== $post_status) { |
|
349 | 349 | |
350 | - if('import' === $post_status){ |
|
350 | + if ('import' === $post_status) { |
|
351 | 351 | |
352 | - if(0 !== $row['post_id']){ |
|
352 | + if (0 !== $row['post_id']) { |
|
353 | 353 | continue; |
354 | - }else{ |
|
354 | + }else { |
|
355 | 355 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
356 | 356 | } |
357 | 357 | |
358 | 358 | |
359 | - }else{ |
|
359 | + }else { |
|
360 | 360 | |
361 | - if(0 === $row['post_id']){ |
|
361 | + if (0 === $row['post_id']) { |
|
362 | 362 | continue; |
363 | - }else{ |
|
363 | + }else { |
|
364 | 364 | $current_status = get_post_status($row['post_id']); |
365 | - if($current_status !== $post_status){ |
|
365 | + if ($current_status !== $post_status) { |
|
366 | 366 | continue; |
367 | 367 | } |
368 | 368 | |
@@ -371,17 +371,17 @@ discard block |
||
371 | 371 | |
372 | 372 | } |
373 | 373 | |
374 | - }else{ |
|
374 | + }else { |
|
375 | 375 | //Search through each keyword. |
376 | - foreach($keyphrases as $keyphrase){ |
|
376 | + foreach ($keyphrases as $keyphrase) { |
|
377 | 377 | |
378 | 378 | //Make sure the keyphrase is turned into an array |
379 | - $keywords = explode(" ",$keyphrase); |
|
380 | - if(!is_array($keywords)){ |
|
379 | + $keywords = explode(" ", $keyphrase); |
|
380 | + if (!is_array($keywords)) { |
|
381 | 381 | $keywords = array($keywords); |
382 | 382 | } |
383 | 383 | |
384 | - if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){ |
|
384 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
385 | 385 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
386 | 386 | } |
387 | 387 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | } |
390 | 390 | } |
391 | 391 | |
392 | - if(false !== $searched_items){ |
|
392 | + if (false !== $searched_items) { |
|
393 | 393 | ksort($searched_items); |
394 | 394 | $return = implode($searched_items); |
395 | 395 | } |
@@ -402,11 +402,11 @@ discard block |
||
402 | 402 | /** |
403 | 403 | * Formats the row for output on the screen. |
404 | 404 | */ |
405 | - public function format_row($row = false){ |
|
406 | - if(false !== $row){ |
|
405 | + public function format_row($row = false) { |
|
406 | + if (false !== $row) { |
|
407 | 407 | |
408 | 408 | $status = 'import'; |
409 | - if(0 !== $row['post_id']){ |
|
409 | + if (0 !== $row['post_id']) { |
|
410 | 410 | $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
411 | 411 | } |
412 | 412 | |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | <strong>'.$row['name'].'</strong> - '.$status.' |
421 | 421 | </td> |
422 | 422 | <td class="date column-date"> |
423 | - <abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
423 | + <abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
424 | 424 | </td> |
425 | 425 | <td class="ssid column-ssid"> |
426 | 426 | '.$row['identifier'].' |
@@ -435,29 +435,29 @@ discard block |
||
435 | 435 | */ |
436 | 436 | public function process_ajax_import($force = false) { |
437 | 437 | $return = false; |
438 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])){ |
|
438 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) { |
|
439 | 439 | |
440 | 440 | $wetu_id = $_POST['wetu_id']; |
441 | - if(isset($_POST['post_id'])){ |
|
441 | + if (isset($_POST['post_id'])) { |
|
442 | 442 | $post_id = $_POST['post_id']; |
443 | - }else{ |
|
443 | + }else { |
|
444 | 444 | $post_id = 0; |
445 | 445 | } |
446 | 446 | |
447 | - if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
|
447 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
448 | 448 | $content = $_POST['content']; |
449 | - }else{ |
|
449 | + }else { |
|
450 | 450 | $content = false; |
451 | 451 | } |
452 | 452 | |
453 | - $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
453 | + $jdata = file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
454 | 454 | |
455 | - if($jdata) |
|
455 | + if ($jdata) |
|
456 | 456 | { |
457 | - $jdata=json_decode($jdata,true); |
|
458 | - if(!empty($jdata)) |
|
457 | + $jdata = json_decode($jdata, true); |
|
458 | + if (!empty($jdata)) |
|
459 | 459 | { |
460 | - $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
460 | + $return = $this->import_row($jdata, $wetu_id, $post_id, $content); |
|
461 | 461 | $this->format_completed_row($return); |
462 | 462 | } |
463 | 463 | } |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | * @param $data array |
473 | 473 | * @param $wetu_id string |
474 | 474 | */ |
475 | - public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) { |
|
475 | + public function import_row($data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false) { |
|
476 | 476 | $post_name = $data_post_content = $data_post_excerpt = ''; |
477 | 477 | $post = array( |
478 | 478 | 'post_type' => 'tour', |
@@ -480,12 +480,12 @@ discard block |
||
480 | 480 | |
481 | 481 | //Set the post_content |
482 | 482 | $content_used_general_description = false; |
483 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
483 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
484 | 484 | $data_post_content = ''; |
485 | 485 | |
486 | - if(isset($data['description'])){ |
|
486 | + if (isset($data['description'])) { |
|
487 | 487 | $data_post_content = $data['description']; |
488 | - }elseif(isset($data['summary'])){ |
|
488 | + }elseif (isset($data['summary'])) { |
|
489 | 489 | $data_post_content = $data['summary']; |
490 | 490 | $content_used_general_description = true; |
491 | 491 | } |
@@ -493,24 +493,24 @@ discard block |
||
493 | 493 | } |
494 | 494 | |
495 | 495 | //set the post_excerpt |
496 | - if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
497 | - if(isset($data['summary']) && false === $content_used_general_description){ |
|
496 | + if (false !== $importable_content && in_array('excerpt', $importable_content)) { |
|
497 | + if (isset($data['summary']) && false === $content_used_general_description) { |
|
498 | 498 | $post['post_excerpt'] = $data['summary']; |
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
502 | 502 | //Create or update the post |
503 | - if(false !== $id && '0' !== $id){ |
|
503 | + if (false !== $id && '0' !== $id) { |
|
504 | 504 | $post['ID'] = $id; |
505 | 505 | $post['post_status'] = 'publish'; |
506 | 506 | $id = wp_update_post($post); |
507 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
508 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
509 | - }else{ |
|
507 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
508 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']), $prev_date); |
|
509 | + }else { |
|
510 | 510 | |
511 | 511 | //Set the name |
512 | - if(isset($data['name'])){ |
|
513 | - $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
512 | + if (isset($data['name'])) { |
|
513 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0); |
|
514 | 514 | } |
515 | 515 | $post['post_name'] = $post_name; |
516 | 516 | $post['post_title'] = $data['name']; |
@@ -518,51 +518,51 @@ discard block |
||
518 | 518 | $id = wp_insert_post($post); |
519 | 519 | |
520 | 520 | //Save the WETU ID and the Last date it was modified. |
521 | - if(false !== $id){ |
|
522 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
523 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
521 | + if (false !== $id) { |
|
522 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
523 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified'])); |
|
524 | 524 | } |
525 | 525 | } |
526 | 526 | |
527 | 527 | |
528 | 528 | //Set the price |
529 | - if(false !== $importable_content && in_array('price',$importable_content)){ |
|
530 | - $this->set_price($data,$id); |
|
529 | + if (false !== $importable_content && in_array('price', $importable_content)) { |
|
530 | + $this->set_price($data, $id); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | //Set the Duration |
534 | - if(false !== $importable_content && in_array('duration',$importable_content)){ |
|
535 | - $this->set_duration($data,$id); |
|
534 | + if (false !== $importable_content && in_array('duration', $importable_content)) { |
|
535 | + $this->set_duration($data, $id); |
|
536 | 536 | } |
537 | 537 | |
538 | - if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
539 | - $this->process_itineraries($data,$id,$importable_content); |
|
538 | + if (in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) { |
|
539 | + $this->process_itineraries($data, $id, $importable_content); |
|
540 | 540 | } |
541 | 541 | |
542 | - if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){ |
|
543 | - $this->process_map_points($data,$id); |
|
542 | + if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) { |
|
543 | + $this->process_map_points($data, $id); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | //TODO Test These |
547 | 547 | //Setup some default for use in the import |
548 | - 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))){ |
|
548 | + 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))) { |
|
549 | 549 | $this->find_attachments($id); |
550 | 550 | } |
551 | 551 | //Set the featured image |
552 | 552 | //TODO Test These |
553 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
554 | - $this->set_featured_image($data,$id); |
|
553 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
554 | + $this->set_featured_image($data, $id); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | //TODO Test These |
558 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
559 | - $this->set_banner_image($data,$id); |
|
558 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
559 | + $this->set_banner_image($data, $id); |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | //TODO Test These |
563 | 563 | //Import the main gallery |
564 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
565 | - $this->create_main_gallery($data,$id); |
|
564 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
565 | + $this->create_main_gallery($data, $id); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | return $id; |
@@ -571,135 +571,135 @@ discard block |
||
571 | 571 | /** |
572 | 572 | * A loop which runs through each leg on the tour. |
573 | 573 | */ |
574 | - public function process_itineraries($data,$id,$importable_content) { |
|
574 | + public function process_itineraries($data, $id, $importable_content) { |
|
575 | 575 | $day_counter = 1; |
576 | 576 | $leg_counter = 0; |
577 | 577 | |
578 | - delete_post_meta($id,'itinerary'); |
|
578 | + delete_post_meta($id, 'itinerary'); |
|
579 | 579 | |
580 | - if(false !== $importable_content && in_array('accommodation',$importable_content)){ |
|
581 | - delete_post_meta($id,'accommodation_to_tour'); |
|
580 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
581 | + delete_post_meta($id, 'accommodation_to_tour'); |
|
582 | 582 | } |
583 | - if(false !== $importable_content && in_array('destination',$importable_content)){ |
|
584 | - delete_post_meta($id,'destination_to_tour'); |
|
585 | - delete_post_meta($id,'departs_from'); |
|
586 | - delete_post_meta($id,'ends_in'); |
|
583 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
584 | + delete_post_meta($id, 'destination_to_tour'); |
|
585 | + delete_post_meta($id, 'departs_from'); |
|
586 | + delete_post_meta($id, 'ends_in'); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | $departs_from = false; |
590 | 590 | $ends_in = false; |
591 | 591 | |
592 | - foreach($data['legs'] as $leg){ |
|
592 | + foreach ($data['legs'] as $leg) { |
|
593 | 593 | |
594 | - if(isset($leg['days']) && !empty($leg['days'])){ |
|
594 | + if (isset($leg['days']) && !empty($leg['days'])) { |
|
595 | 595 | |
596 | 596 | //Itinerary Accommodation |
597 | 597 | $current_accommodation = false; |
598 | - if(false !== $importable_content && in_array('accommodation',$importable_content)){ |
|
599 | - $current_accommodation = $this->set_accommodation($leg,$id); |
|
598 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
599 | + $current_accommodation = $this->set_accommodation($leg, $id); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | //Itinerary Destination |
603 | 603 | $current_destination = false; |
604 | - if(false !== $importable_content && in_array('destination',$importable_content)){ |
|
605 | - $current_destination = $this->set_destination($leg,$id); |
|
604 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
605 | + $current_destination = $this->set_destination($leg, $id); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | //If the Nights are the same mount of days in the array, then it isnt "By Destination" |
609 | - if($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']){ |
|
609 | + if ($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']) { |
|
610 | 610 | |
611 | - foreach($leg['days'] as $day){ |
|
611 | + foreach ($leg['days'] as $day) { |
|
612 | 612 | |
613 | 613 | $current_day = array(); |
614 | 614 | |
615 | - $current_day['title'] = esc_attr('Day ','wetu-importer').$day_counter; |
|
615 | + $current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter; |
|
616 | 616 | |
617 | 617 | //Description |
618 | - if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes']) && '' !== $day['notes']){ |
|
618 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes']) && '' !== $day['notes']) { |
|
619 | 619 | $current_day['description'] = strip_tags($day['notes']); |
620 | - }else{ |
|
620 | + }else { |
|
621 | 621 | $current_day['description'] = ''; |
622 | 622 | } |
623 | 623 | |
624 | 624 | //Itinerary Gallery |
625 | - if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){ |
|
625 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) { |
|
626 | 626 | $current_day['featured_image'] = ''; |
627 | - }else{ |
|
627 | + }else { |
|
628 | 628 | $current_day['featured_image'] = ''; |
629 | 629 | } |
630 | 630 | |
631 | 631 | //Accommodation |
632 | - if(false !== $current_accommodation){ |
|
632 | + if (false !== $current_accommodation) { |
|
633 | 633 | $current_day['accommodation_to_tour'] = array($current_accommodation); |
634 | - }else{ |
|
634 | + }else { |
|
635 | 635 | $current_day['accommodation_to_tour'] = array(); |
636 | 636 | } |
637 | 637 | |
638 | 638 | //Destination |
639 | - if(false !== $current_destination){ |
|
639 | + if (false !== $current_destination) { |
|
640 | 640 | $current_day['destination_to_tour'] = array($current_destination); |
641 | - }else{ |
|
641 | + }else { |
|
642 | 642 | $current_day['destination_to_tour'] = array(); |
643 | 643 | } |
644 | 644 | |
645 | - $this->set_itinerary_day($current_day,$id); |
|
645 | + $this->set_itinerary_day($current_day, $id); |
|
646 | 646 | $day_counter++; |
647 | 647 | } |
648 | 648 | |
649 | - }else{ |
|
650 | - $day_counter = $day_counter + (int)$leg['nights']; |
|
649 | + }else { |
|
650 | + $day_counter = $day_counter + (int) $leg['nights']; |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | } |
654 | 654 | |
655 | 655 | //If we are in the first leg, and the destination was attached then save it as the departure field. |
656 | - if( 0 === $leg_counter && false !== $current_destination){ |
|
656 | + if (0 === $leg_counter && false !== $current_destination) { |
|
657 | 657 | $departs_from = $current_destination; |
658 | 658 | } |
659 | 659 | |
660 | 660 | //If its the last leg then save it as the ends in. |
661 | - if( $leg_counter === (count($data['legs'])-2) && false !== $current_destination){ |
|
661 | + if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) { |
|
662 | 662 | $ends_in = $current_destination; |
663 | 663 | } |
664 | 664 | $leg_counter++; |
665 | 665 | } |
666 | 666 | |
667 | - if(false !== $departs_from){ |
|
668 | - add_post_meta($id,'departs_from',$departs_from,true); |
|
667 | + if (false !== $departs_from) { |
|
668 | + add_post_meta($id, 'departs_from', $departs_from, true); |
|
669 | 669 | } |
670 | - if(false !== $ends_in){ |
|
671 | - add_post_meta($id,'ends_in',$ends_in,true); |
|
670 | + if (false !== $ends_in) { |
|
671 | + add_post_meta($id, 'ends_in', $ends_in, true); |
|
672 | 672 | } |
673 | 673 | } |
674 | 674 | |
675 | 675 | /** |
676 | 676 | * Run through your routes and save the points as a KML file. |
677 | 677 | */ |
678 | - public function process_map_points($data,$id) { |
|
678 | + public function process_map_points($data, $id) { |
|
679 | 679 | |
680 | - if(!empty($data['routes'])){ |
|
680 | + if (!empty($data['routes'])) { |
|
681 | 681 | |
682 | - delete_post_meta($id,'wetu_map_points'); |
|
682 | + delete_post_meta($id, 'wetu_map_points'); |
|
683 | 683 | |
684 | 684 | $points = array(); |
685 | 685 | |
686 | - foreach($data['routes'] as $route){ |
|
686 | + foreach ($data['routes'] as $route) { |
|
687 | 687 | |
688 | 688 | |
689 | - if(isset($route['points']) && '' !== $route['points']){ |
|
689 | + if (isset($route['points']) && '' !== $route['points']) { |
|
690 | 690 | |
691 | - $temp_points = explode(';',$route['points']); |
|
691 | + $temp_points = explode(';', $route['points']); |
|
692 | 692 | $point_counter = count($temp_points); |
693 | 693 | |
694 | 694 | for ($x = 0; $x <= $point_counter; $x++) { |
695 | - $y = $x+1; |
|
695 | + $y = $x + 1; |
|
696 | 696 | $points[] = $temp_points[$x].','.$temp_points[$y]; |
697 | 697 | $x++; |
698 | 698 | } |
699 | 699 | } |
700 | 700 | } |
701 | - if(!empty($points)){ |
|
702 | - $this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true); |
|
701 | + if (!empty($points)) { |
|
702 | + $this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true); |
|
703 | 703 | } |
704 | 704 | } |
705 | 705 | |
@@ -708,28 +708,28 @@ discard block |
||
708 | 708 | /** |
709 | 709 | * Set the Itinerary Day |
710 | 710 | */ |
711 | - public function set_itinerary_day($day,$id) { |
|
712 | - $this->save_custom_field($day,'itinerary',$id,false,false); |
|
711 | + public function set_itinerary_day($day, $id) { |
|
712 | + $this->save_custom_field($day, 'itinerary', $id, false, false); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | /** |
716 | 716 | * Set the price |
717 | 717 | */ |
718 | - public function set_price($data,$id) { |
|
719 | - if(isset($data['price']) && ''!== $data['price']){ |
|
718 | + public function set_price($data, $id) { |
|
719 | + if (isset($data['price']) && '' !== $data['price']) { |
|
720 | 720 | $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
721 | - $this->save_custom_field($price,'price',$id); |
|
721 | + $this->save_custom_field($price, 'price', $id); |
|
722 | 722 | } |
723 | 723 | } |
724 | 724 | |
725 | 725 | /** |
726 | 726 | * Set the duration |
727 | 727 | */ |
728 | - public function set_duration($data,$id) { |
|
729 | - if(isset($data['days']) && !empty($data['days'])){ |
|
728 | + public function set_duration($data, $id) { |
|
729 | + if (isset($data['days']) && !empty($data['days'])) { |
|
730 | 730 | $price = $data['days']; |
731 | 731 | $price = preg_replace("/[^0-9,.]/", "", $price); |
732 | - $this->save_custom_field($price,'duration',$id); |
|
732 | + $this->save_custom_field($price, 'duration', $id); |
|
733 | 733 | } |
734 | 734 | } |
735 | 735 | |
@@ -737,27 +737,27 @@ discard block |
||
737 | 737 | /** |
738 | 738 | * Connects the Accommodation if its available |
739 | 739 | */ |
740 | - public function set_accommodation($day,$id) { |
|
740 | + public function set_accommodation($day, $id) { |
|
741 | 741 | |
742 | 742 | $ac_id = false; |
743 | 743 | $this->current_accommodation = $this->find_current_accommodation(); |
744 | 744 | |
745 | - if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){ |
|
745 | + if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) { |
|
746 | 746 | |
747 | - if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
|
747 | + if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) { |
|
748 | 748 | $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
749 | - }else{ |
|
749 | + }else { |
|
750 | 750 | $ac_id = wp_insert_post(array( |
751 | 751 | 'post_type' => 'accommodation', |
752 | 752 | 'post_status' => 'draft', |
753 | 753 | 'post_title' => $day['content_entity_id'] |
754 | 754 | )); |
755 | - $this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id); |
|
755 | + $this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id); |
|
756 | 756 | } |
757 | 757 | |
758 | - if('' !== $ac_id && false !== $ac_id){ |
|
759 | - $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
760 | - $this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false); |
|
758 | + if ('' !== $ac_id && false !== $ac_id) { |
|
759 | + $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false); |
|
760 | + $this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false); |
|
761 | 761 | } |
762 | 762 | } |
763 | 763 | return $ac_id; |
@@ -769,13 +769,13 @@ discard block |
||
769 | 769 | * @param $post_type string |
770 | 770 | * @return boolean / array |
771 | 771 | */ |
772 | - public function find_current_accommodation($post_type='accommodation') { |
|
772 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
773 | 773 | global $wpdb; |
774 | 774 | $accommodation = parent::find_current_accommodation($post_type); |
775 | 775 | |
776 | 776 | $return = false; |
777 | - if(!empty($accommodation)){ |
|
778 | - foreach($accommodation as $key => $acc){ |
|
777 | + if (!empty($accommodation)) { |
|
778 | + foreach ($accommodation as $key => $acc) { |
|
779 | 779 | $return[$acc->meta_value] = $acc->post_id; |
780 | 780 | } |
781 | 781 | } |
@@ -797,25 +797,25 @@ discard block |
||
797 | 797 | * @param $id string |
798 | 798 | * @return boolean / string |
799 | 799 | */ |
800 | - public function set_destination($day,$id) { |
|
800 | + public function set_destination($day, $id) { |
|
801 | 801 | $dest_id = false; |
802 | 802 | $country_id = false; |
803 | 803 | $this->current_destinations = $this->find_current_destinations(); |
804 | 804 | |
805 | - if(isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])){ |
|
805 | + if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) { |
|
806 | 806 | |
807 | - if(false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'],$this->current_destinations)){ |
|
807 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) { |
|
808 | 808 | $dest_id = $this->current_destinations[$day['destination_content_entity_id']]; |
809 | 809 | |
810 | 810 | $potential_id = wp_get_post_parent_id($dest_id); |
811 | - $country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true); |
|
812 | - if(false !== $country_wetu_id){ |
|
811 | + $country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true); |
|
812 | + if (false !== $country_wetu_id) { |
|
813 | 813 | $this->set_country($country_wetu_id, $id); |
814 | 814 | } |
815 | 815 | |
816 | 816 | }else { |
817 | 817 | |
818 | - $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']); |
|
818 | + $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$day['destination_content_entity_id']); |
|
819 | 819 | |
820 | 820 | if ($destination_json) { |
821 | 821 | $destination_data = json_decode($destination_json, true); |
@@ -824,12 +824,12 @@ discard block |
||
824 | 824 | |
825 | 825 | $destination_title = $day['destination_content_entity_id']; |
826 | 826 | |
827 | - if(isset($destination_data[0]['name'])){ |
|
827 | + if (isset($destination_data[0]['name'])) { |
|
828 | 828 | $destination_title = $destination_data[0]['name']; |
829 | 829 | } |
830 | 830 | |
831 | - if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
832 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
831 | + if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
832 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) { |
|
833 | 833 | |
834 | 834 | $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
835 | 835 | } |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | 'post_title' => $destination_title |
841 | 841 | ); |
842 | 842 | |
843 | - if(false !== $country_id){ |
|
843 | + if (false !== $country_id) { |
|
844 | 844 | $dest_post['post_parent'] = $country_id; |
845 | 845 | } |
846 | 846 | $dest_id = wp_insert_post($dest_post); |
@@ -873,9 +873,9 @@ discard block |
||
873 | 873 | |
874 | 874 | if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
875 | 875 | $country_id = $this->current_destinations[$country_wetu_id]; |
876 | - } else { |
|
876 | + }else { |
|
877 | 877 | |
878 | - $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
878 | + $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$country_wetu_id); |
|
879 | 879 | |
880 | 880 | if ($country_json) { |
881 | 881 | $country_data = json_decode($country_json, true); |