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