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