@@ -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> |
@@ -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 |
@@ -188,11 +188,11 @@ discard block |
||
188 | 188 | $temp_options = get_option('_lsx-to_settings',false); |
189 | 189 | |
190 | 190 | if(isset($_GET['tab']) || isset($_POST['type'])) { |
191 | - if(isset($_GET['tab'])) { |
|
191 | + if(isset($_GET['tab'])) { |
|
192 | 192 | $this->tab_slug = $_GET['tab']; |
193 | 193 | }else{ |
194 | 194 | $this->tab_slug = $_POST['type']; |
195 | - } |
|
195 | + } |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | if(isset($temp_options[$this->plugin_slug])) { |
@@ -301,10 +301,10 @@ discard block |
||
301 | 301 | |
302 | 302 | // DISPLAY FUNCTIONS |
303 | 303 | |
304 | - /* |
|
304 | + /* |
|
305 | 305 | * Load the importer class you want to use |
306 | 306 | */ |
307 | - public function load_class(){ |
|
307 | + public function load_class(){ |
|
308 | 308 | |
309 | 309 | switch($this->tab_slug){ |
310 | 310 | case 'accommodation': |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | break; |
325 | 325 | } |
326 | 326 | |
327 | - } |
|
327 | + } |
|
328 | 328 | |
329 | 329 | /** |
330 | 330 | * Registers the admin page which will house the importer form. |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | <?php |
381 | 381 | }else{ |
382 | 382 | $this->current_importer->display_page(); |
383 | - }; ?> |
|
383 | + }; ?> |
|
384 | 384 | </div> |
385 | 385 | <?php |
386 | 386 | } |
@@ -998,7 +998,7 @@ discard block |
||
998 | 998 | * Run through the accommodation grabbed from the DB. |
999 | 999 | */ |
1000 | 1000 | public function process_ajax_search() { |
1001 | - $this->current_importer->process_ajax_search(); |
|
1001 | + $this->current_importer->process_ajax_search(); |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function set_variables() |
72 | 72 | { |
73 | - parent::set_variables(); |
|
73 | + parent::set_variables(); |
|
74 | 74 | // ** This request only works with API KEY ** |
75 | 75 | //if ( false !== $this->api_username && false !== $this->api_password ) { |
76 | 76 | // $this->url = 'https://wetu.com/API/Pins/'; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * Display the importer administration screen |
96 | 96 | */ |
97 | 97 | public function display_page() { |
98 | - ?> |
|
98 | + ?> |
|
99 | 99 | <div class="wrap"> |
100 | 100 | <?php $this->navigation('accommodation'); ?> |
101 | 101 | |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | $accommodation = json_decode($data, true); |
237 | 237 | |
238 | 238 | if(isset($accommodation['error'])){ |
239 | - return $accommodation['error']; |
|
240 | - }elseif (isset($accommodation) && !empty($accommodation)) { |
|
239 | + return $accommodation['error']; |
|
240 | + }elseif (isset($accommodation) && !empty($accommodation)) { |
|
241 | 241 | set_transient('lsx_ti_accommodation',$accommodation,60*60*2); |
242 | 242 | return true; |
243 | 243 | } |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | $accommodation = get_transient('lsx_ti_accommodation'); |
254 | 254 | |
255 | 255 | if(false === $accommodation){ |
256 | - $this->update_options(); |
|
257 | - } |
|
256 | + $this->update_options(); |
|
257 | + } |
|
258 | 258 | |
259 | 259 | if ( false !== $accommodation ) { |
260 | 260 | $searched_items = false; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | $keyphrases = $_POST['keyword']; |
264 | 264 | }else{ |
265 | 265 | $keyphrases = array(0); |
266 | - } |
|
266 | + } |
|
267 | 267 | |
268 | 268 | if(!is_array($keyphrases)){ |
269 | 269 | $keyphrases = array($keyphrases); |
@@ -420,17 +420,17 @@ discard block |
||
420 | 420 | $content = false; |
421 | 421 | } |
422 | 422 | |
423 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
424 | - if($jdata) |
|
425 | - { |
|
426 | - $adata=json_decode($jdata,true); |
|
427 | - if(!empty($adata)) |
|
428 | - { |
|
429 | - $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
430 | - $this->format_completed_row($return); |
|
423 | + $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
424 | + if($jdata) |
|
425 | + { |
|
426 | + $adata=json_decode($jdata,true); |
|
427 | + if(!empty($adata)) |
|
428 | + { |
|
429 | + $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
430 | + $this->format_completed_row($return); |
|
431 | 431 | $this->cleanup_posts(); |
432 | - } |
|
433 | - } |
|
432 | + } |
|
433 | + } |
|
434 | 434 | } |
435 | 435 | } |
436 | 436 | |
@@ -439,147 +439,147 @@ discard block |
||
439 | 439 | */ |
440 | 440 | public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) { |
441 | 441 | |
442 | - if(trim($data[0]['type'])=='Accommodation') |
|
443 | - { |
|
444 | - $post_name = $data_post_content = $data_post_excerpt = ''; |
|
445 | - $post = array( |
|
446 | - 'post_type' => 'accommodation', |
|
447 | - ); |
|
448 | - |
|
449 | - $content_used_general_description = false; |
|
450 | - |
|
451 | - //Set the post_content |
|
452 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
453 | - if(isset($data[0]['content']['extended_description'])) |
|
454 | - { |
|
455 | - $data_post_content = $data[0]['content']['extended_description']; |
|
456 | - }elseif(isset($data[0]['content']['general_description'])){ |
|
457 | - $data_post_content = $data[0]['content']['general_description']; |
|
458 | - $content_used_general_description = true; |
|
459 | - }elseif(isset($data[0]['content']['teaser_description'])){ |
|
460 | - $data_post_content = $data[0]['content']['teaser_description']; |
|
461 | - } |
|
462 | - $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
463 | - } |
|
464 | - |
|
465 | - //set the post_excerpt |
|
466 | - if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
467 | - if(isset($data[0]['content']['teaser_description'])){ |
|
468 | - $data_post_excerpt = $data[0]['content']['teaser_description']; |
|
469 | - }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
470 | - $data_post_excerpt = $data[0]['content']['general_description']; |
|
471 | - } |
|
472 | - $post['post_excerpt'] = $data_post_excerpt; |
|
473 | - } |
|
474 | - |
|
475 | - if(false !== $id && '0' !== $id){ |
|
476 | - $post['ID'] = $id; |
|
442 | + if(trim($data[0]['type'])=='Accommodation') |
|
443 | + { |
|
444 | + $post_name = $data_post_content = $data_post_excerpt = ''; |
|
445 | + $post = array( |
|
446 | + 'post_type' => 'accommodation', |
|
447 | + ); |
|
448 | + |
|
449 | + $content_used_general_description = false; |
|
450 | + |
|
451 | + //Set the post_content |
|
452 | + if(false !== $importable_content && in_array('description',$importable_content)){ |
|
453 | + if(isset($data[0]['content']['extended_description'])) |
|
454 | + { |
|
455 | + $data_post_content = $data[0]['content']['extended_description']; |
|
456 | + }elseif(isset($data[0]['content']['general_description'])){ |
|
457 | + $data_post_content = $data[0]['content']['general_description']; |
|
458 | + $content_used_general_description = true; |
|
459 | + }elseif(isset($data[0]['content']['teaser_description'])){ |
|
460 | + $data_post_content = $data[0]['content']['teaser_description']; |
|
461 | + } |
|
462 | + $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
463 | + } |
|
464 | + |
|
465 | + //set the post_excerpt |
|
466 | + if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
467 | + if(isset($data[0]['content']['teaser_description'])){ |
|
468 | + $data_post_excerpt = $data[0]['content']['teaser_description']; |
|
469 | + }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
470 | + $data_post_excerpt = $data[0]['content']['general_description']; |
|
471 | + } |
|
472 | + $post['post_excerpt'] = $data_post_excerpt; |
|
473 | + } |
|
474 | + |
|
475 | + if(false !== $id && '0' !== $id){ |
|
476 | + $post['ID'] = $id; |
|
477 | 477 | if(isset($data[0]['name'])){ |
478 | 478 | $post['post_title'] = $data[0]['name']; |
479 | - $post['post_status'] = 'publish'; |
|
479 | + $post['post_status'] = 'publish'; |
|
480 | 480 | $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
481 | 481 | } |
482 | - $id = wp_update_post($post); |
|
483 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
484 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
485 | - }else{ |
|
486 | - |
|
487 | - //Set the name |
|
488 | - if(isset($data[0]['name'])){ |
|
489 | - $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
490 | - } |
|
491 | - $post['post_name'] = $post_name; |
|
492 | - $post['post_title'] = $data[0]['name']; |
|
493 | - $post['post_status'] = 'publish'; |
|
494 | - $id = wp_insert_post($post); |
|
495 | - |
|
496 | - //Save the WETU ID and the Last date it was modified. |
|
497 | - if(false !== $id){ |
|
498 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
499 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
500 | - } |
|
501 | - } |
|
502 | - //Setup some default for use in the import |
|
503 | - if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
|
482 | + $id = wp_update_post($post); |
|
483 | + $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
484 | + update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
485 | + }else{ |
|
486 | + |
|
487 | + //Set the name |
|
488 | + if(isset($data[0]['name'])){ |
|
489 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
490 | + } |
|
491 | + $post['post_name'] = $post_name; |
|
492 | + $post['post_title'] = $data[0]['name']; |
|
493 | + $post['post_status'] = 'publish'; |
|
494 | + $id = wp_insert_post($post); |
|
495 | + |
|
496 | + //Save the WETU ID and the Last date it was modified. |
|
497 | + if(false !== $id){ |
|
498 | + add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
499 | + add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
500 | + } |
|
501 | + } |
|
502 | + //Setup some default for use in the import |
|
503 | + if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
|
504 | 504 | $this->find_attachments($id); |
505 | 505 | } |
506 | 506 | |
507 | - //Set the team member if it is there |
|
508 | - if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
509 | - $this->set_team_member($id,$team_members); |
|
510 | - } |
|
511 | - |
|
512 | - //Set the safari brand |
|
513 | - if(false !== $safari_brands && '' !== $safari_brands){ |
|
514 | - $this->set_safari_brands($id,$safari_brands); |
|
515 | - |
|
516 | - } |
|
517 | - |
|
518 | - if(class_exists('LSX_TO_Maps')){ |
|
519 | - $this->set_map_data($data,$id,9); |
|
520 | - } |
|
521 | - |
|
522 | - if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){ |
|
523 | - $this->connect_destinations($data,$id); |
|
524 | - } |
|
525 | - |
|
526 | - if(false !== $importable_content && in_array('category',$importable_content)){ |
|
527 | - $this->set_taxonomy_style($data,$id); |
|
528 | - } |
|
529 | - |
|
530 | - //Set the Room Data |
|
531 | - if(false !== $importable_content && in_array('rooms',$importable_content)){ |
|
532 | - $this->set_room_data($data,$id); |
|
533 | - } |
|
534 | - |
|
535 | - //Set the rating |
|
536 | - if(false !== $importable_content && in_array('rating',$importable_content)){ |
|
537 | - $this->set_rating($data,$id); |
|
538 | - } |
|
539 | - |
|
540 | - //Set the checkin checkout data |
|
541 | - if(false !== $importable_content && in_array('checkin',$importable_content)){ |
|
542 | - $this->set_checkin_checkout($data,$id); |
|
543 | - } |
|
544 | - |
|
545 | - //Set the Spoken Languages |
|
546 | - if(false !== $importable_content && in_array('spoken_languages',$importable_content)){ |
|
547 | - $this->set_spoken_languages($data,$id); |
|
548 | - } |
|
549 | - |
|
550 | - //Set the friendly options |
|
551 | - if(false !== $importable_content && in_array('friendly',$importable_content)){ |
|
552 | - $this->set_friendly($data,$id); |
|
553 | - } |
|
554 | - |
|
555 | - //Set the special_interests |
|
556 | - if(false !== $importable_content && in_array('special_interests',$importable_content)){ |
|
557 | - $this->set_special_interests($data,$id); |
|
558 | - } |
|
559 | - |
|
560 | - //Import the videos |
|
561 | - if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
562 | - $this->set_video_data($data,$id); |
|
563 | - } |
|
564 | - |
|
565 | - //Import the facilities |
|
566 | - if(false !== $importable_content && in_array('facilities',$importable_content)){ |
|
567 | - $this->set_facilities($data,$id); |
|
568 | - } |
|
569 | - |
|
570 | - //Set the featured image |
|
571 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
572 | - $this->set_featured_image($data,$id); |
|
573 | - } |
|
574 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
575 | - $this->set_banner_image($data,$id); |
|
576 | - } |
|
577 | - //Import the main gallery |
|
578 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
579 | - $this->create_main_gallery($data,$id); |
|
580 | - } |
|
581 | - } |
|
582 | - return $id; |
|
507 | + //Set the team member if it is there |
|
508 | + if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
509 | + $this->set_team_member($id,$team_members); |
|
510 | + } |
|
511 | + |
|
512 | + //Set the safari brand |
|
513 | + if(false !== $safari_brands && '' !== $safari_brands){ |
|
514 | + $this->set_safari_brands($id,$safari_brands); |
|
515 | + |
|
516 | + } |
|
517 | + |
|
518 | + if(class_exists('LSX_TO_Maps')){ |
|
519 | + $this->set_map_data($data,$id,9); |
|
520 | + } |
|
521 | + |
|
522 | + if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){ |
|
523 | + $this->connect_destinations($data,$id); |
|
524 | + } |
|
525 | + |
|
526 | + if(false !== $importable_content && in_array('category',$importable_content)){ |
|
527 | + $this->set_taxonomy_style($data,$id); |
|
528 | + } |
|
529 | + |
|
530 | + //Set the Room Data |
|
531 | + if(false !== $importable_content && in_array('rooms',$importable_content)){ |
|
532 | + $this->set_room_data($data,$id); |
|
533 | + } |
|
534 | + |
|
535 | + //Set the rating |
|
536 | + if(false !== $importable_content && in_array('rating',$importable_content)){ |
|
537 | + $this->set_rating($data,$id); |
|
538 | + } |
|
539 | + |
|
540 | + //Set the checkin checkout data |
|
541 | + if(false !== $importable_content && in_array('checkin',$importable_content)){ |
|
542 | + $this->set_checkin_checkout($data,$id); |
|
543 | + } |
|
544 | + |
|
545 | + //Set the Spoken Languages |
|
546 | + if(false !== $importable_content && in_array('spoken_languages',$importable_content)){ |
|
547 | + $this->set_spoken_languages($data,$id); |
|
548 | + } |
|
549 | + |
|
550 | + //Set the friendly options |
|
551 | + if(false !== $importable_content && in_array('friendly',$importable_content)){ |
|
552 | + $this->set_friendly($data,$id); |
|
553 | + } |
|
554 | + |
|
555 | + //Set the special_interests |
|
556 | + if(false !== $importable_content && in_array('special_interests',$importable_content)){ |
|
557 | + $this->set_special_interests($data,$id); |
|
558 | + } |
|
559 | + |
|
560 | + //Import the videos |
|
561 | + if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
562 | + $this->set_video_data($data,$id); |
|
563 | + } |
|
564 | + |
|
565 | + //Import the facilities |
|
566 | + if(false !== $importable_content && in_array('facilities',$importable_content)){ |
|
567 | + $this->set_facilities($data,$id); |
|
568 | + } |
|
569 | + |
|
570 | + //Set the featured image |
|
571 | + if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
572 | + $this->set_featured_image($data,$id); |
|
573 | + } |
|
574 | + if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
575 | + $this->set_banner_image($data,$id); |
|
576 | + } |
|
577 | + //Import the main gallery |
|
578 | + if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
579 | + $this->create_main_gallery($data,$id); |
|
580 | + } |
|
581 | + } |
|
582 | + return $id; |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | /** |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | |
590 | 590 | delete_post_meta($id, 'team_to_'.$this->tab_slug); |
591 | 591 | foreach($team_members as $team){ |
592 | - add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
592 | + add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
593 | 593 | } |
594 | 594 | } |
595 | 595 | |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | */ |
599 | 599 | public function set_safari_brands($id,$safari_brands) { |
600 | 600 | foreach($safari_brands as $safari_brand){ |
601 | - wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true); |
|
601 | + wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true); |
|
602 | 602 | } |
603 | 603 | } |
604 | 604 | |
@@ -607,32 +607,32 @@ discard block |
||
607 | 607 | */ |
608 | 608 | public function connect_destinations($data,$id) { |
609 | 609 | if(isset($data[0]['position'])){ |
610 | - $destinations = false; |
|
611 | - if(isset($data[0]['position']['country'])){ |
|
612 | - $destinations['country'] = $data[0]['position']['country']; |
|
613 | - } |
|
614 | - if(isset($data[0]['position']['destination'])){ |
|
615 | - $destinations['destination'] = $data[0]['position']['destination']; |
|
616 | - } |
|
610 | + $destinations = false; |
|
611 | + if(isset($data[0]['position']['country'])){ |
|
612 | + $destinations['country'] = $data[0]['position']['country']; |
|
613 | + } |
|
614 | + if(isset($data[0]['position']['destination'])){ |
|
615 | + $destinations['destination'] = $data[0]['position']['destination']; |
|
616 | + } |
|
617 | 617 | |
618 | - if(false !== $destinations){ |
|
619 | - $prev_values = get_post_meta($id,'destination_to_accommodation',false); |
|
620 | - if(false === $prev_values || !is_array($prev_values)){ |
|
621 | - $prev_values = array(); |
|
622 | - } |
|
623 | - //print_r($destinations); |
|
618 | + if(false !== $destinations){ |
|
619 | + $prev_values = get_post_meta($id,'destination_to_accommodation',false); |
|
620 | + if(false === $prev_values || !is_array($prev_values)){ |
|
621 | + $prev_values = array(); |
|
622 | + } |
|
623 | + //print_r($destinations); |
|
624 | 624 | $destinations = array_unique($destinations); |
625 | 625 | //print_r($destinations); |
626 | - foreach($destinations as $key => $value){ |
|
627 | - $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
|
628 | - if (null !== $destination) { |
|
629 | - if(!in_array($destination->ID,$prev_values)){ |
|
630 | - add_post_meta($id,'destination_to_accommodation',$destination->ID,false); |
|
631 | - add_post_meta($destination->ID,'accommodation_to_destination',$id,false); |
|
626 | + foreach($destinations as $key => $value){ |
|
627 | + $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
|
628 | + if (null !== $destination) { |
|
629 | + if(!in_array($destination->ID,$prev_values)){ |
|
630 | + add_post_meta($id,'destination_to_accommodation',$destination->ID,false); |
|
631 | + add_post_meta($destination->ID,'accommodation_to_destination',$id,false); |
|
632 | 632 | $this->cleanup_posts[$destination->ID] = 'accommodation_to_destination'; |
633 | - } |
|
634 | - } |
|
635 | - } |
|
633 | + } |
|
634 | + } |
|
635 | + } |
|
636 | 636 | } |
637 | 637 | } |
638 | 638 | } |
@@ -644,15 +644,15 @@ discard block |
||
644 | 644 | $terms = false; |
645 | 645 | if(isset($data[0]['category'])){ |
646 | 646 | if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) |
647 | - { |
|
648 | - $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type'); |
|
649 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
650 | - else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); } |
|
651 | - } |
|
652 | - else |
|
653 | - { |
|
654 | - wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); |
|
655 | - } |
|
647 | + { |
|
648 | + $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type'); |
|
649 | + if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
650 | + else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); } |
|
651 | + } |
|
652 | + else |
|
653 | + { |
|
654 | + wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); |
|
655 | + } |
|
656 | 656 | } |
657 | 657 | } |
658 | 658 | |
@@ -676,25 +676,25 @@ discard block |
||
676 | 676 | $temp_room['type'] = 'room'; |
677 | 677 | |
678 | 678 | if(!empty($room['images']) && is_array($room['images'])){ |
679 | - $attachments_args = array( |
|
680 | - 'post_parent' => $id, |
|
681 | - 'post_status' => 'inherit', |
|
682 | - 'post_type' => 'attachment', |
|
683 | - 'order' => 'ASC', |
|
684 | - ); |
|
685 | - $attachments = new WP_Query($attachments_args); |
|
686 | - $found_attachments = array(); |
|
687 | - |
|
688 | - if($attachments->have_posts()){ |
|
689 | - foreach($attachments->posts as $attachment){ |
|
690 | - $found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
691 | - } |
|
692 | - } |
|
679 | + $attachments_args = array( |
|
680 | + 'post_parent' => $id, |
|
681 | + 'post_status' => 'inherit', |
|
682 | + 'post_type' => 'attachment', |
|
683 | + 'order' => 'ASC', |
|
684 | + ); |
|
685 | + $attachments = new WP_Query($attachments_args); |
|
686 | + $found_attachments = array(); |
|
687 | + |
|
688 | + if($attachments->have_posts()){ |
|
689 | + foreach($attachments->posts as $attachment){ |
|
690 | + $found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
691 | + } |
|
692 | + } |
|
693 | 693 | |
694 | 694 | $temp_room['gallery'] = array(); |
695 | 695 | foreach($room['images'] as $image_data){ |
696 | - $temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments); |
|
697 | - } |
|
696 | + $temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments); |
|
697 | + } |
|
698 | 698 | } |
699 | 699 | $rooms[] = $temp_room; |
700 | 700 | } |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | delete_post_meta($id, 'units'); |
704 | 704 | } |
705 | 705 | foreach($rooms as $room){ |
706 | - add_post_meta($id,'units',$room,false); |
|
706 | + add_post_meta($id,'units',$room,false); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){ |
@@ -713,11 +713,11 @@ discard block |
||
713 | 713 | } |
714 | 714 | |
715 | 715 | if(false !== $id && '0' !== $id){ |
716 | - $prev_rooms = get_post_meta($id,'number_of_rooms',true); |
|
717 | - update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms); |
|
718 | - }else{ |
|
719 | - add_post_meta($id,'number_of_rooms',$room_count,true); |
|
720 | - } |
|
716 | + $prev_rooms = get_post_meta($id,'number_of_rooms',true); |
|
717 | + update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms); |
|
718 | + }else{ |
|
719 | + add_post_meta($id,'number_of_rooms',$room_count,true); |
|
720 | + } |
|
721 | 721 | } |
722 | 722 | } |
723 | 723 | |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | delete_post_meta($id, 'videos'); |
828 | 828 | } |
829 | 829 | foreach($videos as $video){ |
830 | - add_post_meta($id,'videos',$video,false); |
|
830 | + add_post_meta($id,'videos',$video,false); |
|
831 | 831 | } |
832 | 832 | } |
833 | 833 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function set_variables() |
99 | 99 | { |
100 | - parent::set_variables(); |
|
100 | + parent::set_variables(); |
|
101 | 101 | |
102 | 102 | if ( false !== $this->api_username && false !== $this->api_password ) { |
103 | 103 | $this->url = 'https://wetu.com/API/Itinerary/'; |
@@ -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 $this->navigation('tour'); ?> |
128 | 128 | |
@@ -253,16 +253,16 @@ discard block |
||
253 | 253 | $result = $this->update_options(); |
254 | 254 | |
255 | 255 | if(true === $result){ |
256 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
257 | - if(!isset($_GET['refresh_tours'])){ |
|
258 | - echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
259 | - } |
|
260 | - }else{ |
|
261 | - echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
262 | - } |
|
256 | + echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
257 | + if(!isset($_GET['refresh_tours'])){ |
|
258 | + echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
259 | + } |
|
260 | + }else{ |
|
261 | + echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
262 | + } |
|
263 | 263 | }else{ |
264 | 264 | echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
265 | - } |
|
265 | + } |
|
266 | 266 | echo '</h3></div>'; |
267 | 267 | } |
268 | 268 | |
@@ -274,8 +274,8 @@ discard block |
||
274 | 274 | $tours = json_decode($data, true); |
275 | 275 | |
276 | 276 | if(isset($tours['error'])){ |
277 | - return $tours['error']; |
|
278 | - }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
277 | + return $tours['error']; |
|
278 | + }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
279 | 279 | set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2); |
280 | 280 | return true; |
281 | 281 | } |
@@ -478,71 +478,71 @@ discard block |
||
478 | 478 | $content = false; |
479 | 479 | } |
480 | 480 | |
481 | - $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
481 | + $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
482 | 482 | |
483 | - if($jdata) |
|
484 | - { |
|
483 | + if($jdata) |
|
484 | + { |
|
485 | 485 | $jdata=json_decode($jdata,true); |
486 | - if(!empty($jdata)) |
|
487 | - { |
|
488 | - $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
489 | - $this->format_completed_row($return); |
|
490 | - $this->cleanup_posts(); |
|
491 | - $this->attach_destination_images($content); |
|
492 | - } |
|
493 | - } |
|
486 | + if(!empty($jdata)) |
|
487 | + { |
|
488 | + $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
489 | + $this->format_completed_row($return); |
|
490 | + $this->cleanup_posts(); |
|
491 | + $this->attach_destination_images($content); |
|
492 | + } |
|
493 | + } |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | 497 | /** |
498 | 498 | * Connect to wetu |
499 | - * |
|
500 | - * @param $data array |
|
501 | - * @param $wetu_id string |
|
499 | + * |
|
500 | + * @param $data array |
|
501 | + * @param $wetu_id string |
|
502 | 502 | */ |
503 | 503 | public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) { |
504 | - $post_name = $data_post_content = $data_post_excerpt = ''; |
|
505 | - $post = array( |
|
506 | - 'post_type' => 'tour', |
|
507 | - ); |
|
504 | + $post_name = $data_post_content = $data_post_excerpt = ''; |
|
505 | + $post = array( |
|
506 | + 'post_type' => 'tour', |
|
507 | + ); |
|
508 | 508 | |
509 | - //Set the post_content |
|
509 | + //Set the post_content |
|
510 | 510 | $content_used_general_description = false; |
511 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
512 | - $data_post_content = ''; |
|
513 | - |
|
514 | - if(isset($data['description'])){ |
|
515 | - $data_post_content = $data['description']; |
|
516 | - }elseif(isset($data['summary'])){ |
|
517 | - $data_post_content = $data['summary']; |
|
518 | - } |
|
519 | - $post['post_content'] = $data_post_content; |
|
520 | - } |
|
521 | - |
|
522 | - //Create or update the post |
|
523 | - if(false !== $id && '0' !== $id){ |
|
524 | - $post['ID'] = $id; |
|
525 | - $post['post_status'] = 'publish'; |
|
526 | - $id = wp_update_post($post); |
|
527 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
528 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
529 | - }else{ |
|
530 | - |
|
531 | - //Set the name |
|
532 | - if(isset($data['name'])){ |
|
533 | - $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
534 | - } |
|
535 | - $post['post_name'] = $post_name; |
|
536 | - $post['post_title'] = $data['name']; |
|
537 | - $post['post_status'] = 'publish'; |
|
538 | - $id = wp_insert_post($post); |
|
539 | - |
|
540 | - //Save the WETU ID and the Last date it was modified. |
|
541 | - if(false !== $id){ |
|
542 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
543 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
544 | - } |
|
545 | - } |
|
511 | + if(false !== $importable_content && in_array('description',$importable_content)){ |
|
512 | + $data_post_content = ''; |
|
513 | + |
|
514 | + if(isset($data['description'])){ |
|
515 | + $data_post_content = $data['description']; |
|
516 | + }elseif(isset($data['summary'])){ |
|
517 | + $data_post_content = $data['summary']; |
|
518 | + } |
|
519 | + $post['post_content'] = $data_post_content; |
|
520 | + } |
|
521 | + |
|
522 | + //Create or update the post |
|
523 | + if(false !== $id && '0' !== $id){ |
|
524 | + $post['ID'] = $id; |
|
525 | + $post['post_status'] = 'publish'; |
|
526 | + $id = wp_update_post($post); |
|
527 | + $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
528 | + update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
529 | + }else{ |
|
530 | + |
|
531 | + //Set the name |
|
532 | + if(isset($data['name'])){ |
|
533 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
534 | + } |
|
535 | + $post['post_name'] = $post_name; |
|
536 | + $post['post_title'] = $data['name']; |
|
537 | + $post['post_status'] = 'publish'; |
|
538 | + $id = wp_insert_post($post); |
|
539 | + |
|
540 | + //Save the WETU ID and the Last date it was modified. |
|
541 | + if(false !== $id){ |
|
542 | + add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
543 | + add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
544 | + } |
|
545 | + } |
|
546 | 546 | |
547 | 547 | |
548 | 548 | //Set the price |
@@ -555,15 +555,15 @@ discard block |
||
555 | 555 | $this->set_duration($data,$id); |
556 | 556 | } |
557 | 557 | |
558 | - if(false !== $importable_content && in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
559 | - $this->process_itineraries($data,$id,$importable_content); |
|
560 | - } |
|
558 | + if(false !== $importable_content && in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
559 | + $this->process_itineraries($data,$id,$importable_content); |
|
560 | + } |
|
561 | 561 | |
562 | 562 | if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){ |
563 | 563 | $this->set_map_data($data,$id); |
564 | 564 | } |
565 | 565 | |
566 | - return $id; |
|
566 | + return $id; |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | /** |
@@ -725,17 +725,17 @@ discard block |
||
725 | 725 | * Set the Itinerary Day |
726 | 726 | */ |
727 | 727 | public function set_itinerary_day($day,$id) { |
728 | - $this->save_custom_field($day,'itinerary',$id,false,false); |
|
728 | + $this->save_custom_field($day,'itinerary',$id,false,false); |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | /** |
732 | 732 | * Set the price |
733 | 733 | */ |
734 | 734 | public function set_price($data,$id) { |
735 | - //Price |
|
735 | + //Price |
|
736 | 736 | if(isset($data['price']) && ''!== $data['price']){ |
737 | - $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
|
738 | - $this->save_custom_field($price,'price',$id); |
|
737 | + $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
|
738 | + $this->save_custom_field($price,'price',$id); |
|
739 | 739 | } |
740 | 740 | |
741 | 741 | //Price includes |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | $this->save_custom_field($data['price_includes'],'included',$id); |
744 | 744 | } |
745 | 745 | |
746 | - //Price Excludes |
|
746 | + //Price Excludes |
|
747 | 747 | if(isset($data['price_excludes']) && ''!== $data['price_excludes']){ |
748 | 748 | $this->save_custom_field($data['price_excludes'],'not_included',$id); |
749 | 749 | } |
@@ -766,35 +766,35 @@ discard block |
||
766 | 766 | */ |
767 | 767 | public function set_accommodation($day,$id) { |
768 | 768 | |
769 | - $ac_id = false; |
|
769 | + $ac_id = false; |
|
770 | 770 | $this->current_accommodation = $this->find_current_accommodation(); |
771 | 771 | |
772 | 772 | if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){ |
773 | 773 | |
774 | 774 | if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
775 | - $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
775 | + $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
776 | 776 | }else{ |
777 | 777 | $ac_id = wp_insert_post(array( |
778 | - 'post_type' => 'accommodation', |
|
779 | - 'post_status' => 'draft', |
|
780 | - 'post_title' => $day['content_entity_id'] |
|
781 | - )); |
|
778 | + 'post_type' => 'accommodation', |
|
779 | + 'post_status' => 'draft', |
|
780 | + 'post_title' => $day['content_entity_id'] |
|
781 | + )); |
|
782 | 782 | $this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id); |
783 | 783 | } |
784 | 784 | |
785 | 785 | if('' !== $ac_id && false !== $ac_id){ |
786 | - $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
786 | + $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
787 | 787 | $this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false); |
788 | - } |
|
788 | + } |
|
789 | 789 | } |
790 | 790 | return $ac_id; |
791 | 791 | } |
792 | 792 | |
793 | 793 | /** |
794 | 794 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
795 | - * |
|
796 | - * @param $post_type string |
|
797 | - * @return boolean / array |
|
795 | + * |
|
796 | + * @param $post_type string |
|
797 | + * @return boolean / array |
|
798 | 798 | */ |
799 | 799 | public function find_current_accommodation($post_type='accommodation') { |
800 | 800 | global $wpdb; |
@@ -802,16 +802,16 @@ discard block |
||
802 | 802 | |
803 | 803 | $return = false; |
804 | 804 | if(!empty($accommodation)){ |
805 | - foreach($accommodation as $key => $acc){ |
|
805 | + foreach($accommodation as $key => $acc){ |
|
806 | 806 | $return[$acc->meta_value] = $acc->post_id; |
807 | - } |
|
808 | - } |
|
807 | + } |
|
808 | + } |
|
809 | 809 | return $return; |
810 | 810 | } |
811 | 811 | |
812 | 812 | /** |
813 | 813 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
814 | - * @return boolean / array |
|
814 | + * @return boolean / array |
|
815 | 815 | */ |
816 | 816 | public function find_current_destinations() { |
817 | 817 | return $this->find_current_accommodation('destination'); |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | $country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true); |
840 | 840 | if(false !== $country_wetu_id){ |
841 | 841 | $country_id = $this->set_country($country_wetu_id, $id); |
842 | - } |
|
842 | + } |
|
843 | 843 | |
844 | 844 | }else { |
845 | 845 | |
@@ -850,27 +850,27 @@ discard block |
||
850 | 850 | |
851 | 851 | if (!empty($destination_data) && !isset($destination_data['error'])) { |
852 | 852 | |
853 | - $destination_title = $day['destination_content_entity_id']; |
|
853 | + $destination_title = $day['destination_content_entity_id']; |
|
854 | 854 | |
855 | - if(isset($destination_data[0]['name'])){ |
|
855 | + if(isset($destination_data[0]['name'])){ |
|
856 | 856 | $destination_title = $destination_data[0]['name']; |
857 | - } |
|
857 | + } |
|
858 | 858 | |
859 | - if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
860 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
859 | + if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
860 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
861 | 861 | |
862 | 862 | $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
863 | - } |
|
863 | + } |
|
864 | 864 | |
865 | - $dest_post = array( |
|
865 | + $dest_post = array( |
|
866 | 866 | 'post_type' => 'destination', |
867 | 867 | 'post_status' => 'draft', |
868 | 868 | 'post_title' => $destination_title |
869 | 869 | ); |
870 | 870 | |
871 | - if(false !== $country_id){ |
|
871 | + if(false !== $country_id){ |
|
872 | 872 | $dest_post['post_parent'] = $country_id; |
873 | - } |
|
873 | + } |
|
874 | 874 | $dest_id = wp_insert_post($dest_post); |
875 | 875 | |
876 | 876 | //Make sure we register the |
@@ -888,16 +888,16 @@ discard block |
||
888 | 888 | |
889 | 889 | // Save the first destination so we can grab the tour featured image and banner |
890 | 890 | if(0 === $leg_counter){ |
891 | - $this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']); |
|
892 | - } |
|
891 | + $this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']); |
|
892 | + } |
|
893 | 893 | |
894 | 894 | //Add this relation info so we can make sure certain items are set as countries. |
895 | 895 | if(0 !== $country_id && false !== $country_id){ |
896 | - $this->relation_meta[$dest_id] = $country_id; |
|
896 | + $this->relation_meta[$dest_id] = $country_id; |
|
897 | 897 | $this->relation_meta[$country_id] = 0; |
898 | - }else{ |
|
898 | + }else{ |
|
899 | 899 | $this->relation_meta[$dest_id] = 0; |
900 | - } |
|
900 | + } |
|
901 | 901 | } |
902 | 902 | } |
903 | 903 | return $dest_id; |
@@ -907,53 +907,53 @@ discard block |
||
907 | 907 | * Connects the destinations post type |
908 | 908 | * |
909 | 909 | * @param $dest_id string |
910 | - * @param $country_id array |
|
910 | + * @param $country_id array |
|
911 | 911 | * @param $id string |
912 | - * |
|
913 | - * @return string |
|
912 | + * |
|
913 | + * @return string |
|
914 | 914 | */ |
915 | 915 | public function set_country($country_wetu_id, $id) { |
916 | - $country_id = false; |
|
916 | + $country_id = false; |
|
917 | 917 | $this->current_destinations = $this->find_current_destinations(); |
918 | 918 | |
919 | - if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
920 | - $country_id = $this->current_destinations[$country_wetu_id]; |
|
921 | - } else { |
|
919 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
920 | + $country_id = $this->current_destinations[$country_wetu_id]; |
|
921 | + } else { |
|
922 | 922 | |
923 | - $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
923 | + $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
924 | 924 | |
925 | - if ($country_json) { |
|
926 | - $country_data = json_decode($country_json, true); |
|
925 | + if ($country_json) { |
|
926 | + $country_data = json_decode($country_json, true); |
|
927 | 927 | |
928 | - if (!empty($country_data) && !isset($country_data['error'])) { |
|
928 | + if (!empty($country_data) && !isset($country_data['error'])) { |
|
929 | 929 | |
930 | 930 | //Format the title of the destination if its available, otherwise default to the WETU ID. |
931 | - $country_title = $country_wetu_id; |
|
932 | - if (isset($country_data[0]['name'])) { |
|
931 | + $country_title = $country_wetu_id; |
|
932 | + if (isset($country_data[0]['name'])) { |
|
933 | 933 | $country_title = $country_data[0]['name']; |
934 | - } |
|
934 | + } |
|
935 | 935 | |
936 | 936 | $country_id = wp_insert_post(array( |
937 | - 'post_type' => 'destination', |
|
938 | - 'post_status' => 'draft', |
|
939 | - 'post_title' => $country_title |
|
940 | - )); |
|
937 | + 'post_type' => 'destination', |
|
938 | + 'post_status' => 'draft', |
|
939 | + 'post_title' => $country_title |
|
940 | + )); |
|
941 | 941 | //add the country to the current destination stack |
942 | 942 | $this->current_destinations[$country_wetu_id] = $country_id; |
943 | 943 | |
944 | 944 | //Save the wetu field |
945 | - $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
946 | - } |
|
947 | - } |
|
948 | - } |
|
949 | - |
|
950 | - if ('' !== $country_id && false !== $country_id) { |
|
951 | - $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
952 | - $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
945 | + $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
946 | + } |
|
947 | + } |
|
948 | + } |
|
949 | + |
|
950 | + if ('' !== $country_id && false !== $country_id) { |
|
951 | + $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
952 | + $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
953 | 953 | $this->cleanup_posts[$country_id] = 'tour_to_destination'; |
954 | 954 | |
955 | - return $country_id; |
|
956 | - } |
|
955 | + return $country_id; |
|
956 | + } |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | /** |
@@ -966,9 +966,9 @@ discard block |
||
966 | 966 | * @return string |
967 | 967 | */ |
968 | 968 | public function attach_destination_images($importable_content=array()) { |
969 | - if(false !== $this->destination_images){ |
|
969 | + if(false !== $this->destination_images){ |
|
970 | 970 | |
971 | - foreach($this->destination_images as $tour => $destination){ |
|
971 | + foreach($this->destination_images as $tour => $destination){ |
|
972 | 972 | |
973 | 973 | $url = 'https://wetu.com/API/Pins/' . $this->api_key; |
974 | 974 | $url_qs = ''; |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | } |
990 | 990 | } |
991 | 991 | } |
992 | - } |
|
993 | - } |
|
992 | + } |
|
993 | + } |
|
994 | 994 | } |
995 | 995 | } |
996 | 996 | \ No newline at end of file |