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