@@ -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 |
@@ -210,15 +210,15 @@ discard block |
||
210 | 210 | $this->api_username = false; |
211 | 211 | $this->api_password = false; |
212 | 212 | |
213 | - if (isset($temp_options['api']['wetu_api_key']) && '' !== $temp_options['api']['wetu_api_key']) { |
|
214 | - $this->api_key = $temp_options['api']['wetu_api_key']; |
|
215 | - } |
|
216 | - if (isset($temp_options['api']['wetu_api_username']) && '' !== $temp_options['api']['wetu_api_username']) { |
|
217 | - $this->api_username = $temp_options['api']['wetu_api_username']; |
|
218 | - } |
|
219 | - if (isset($temp_options['api']['wetu_api_password']) && '' !== $temp_options['api']['wetu_api_password']) { |
|
220 | - $this->api_password = $temp_options['api']['wetu_api_password']; |
|
221 | - } |
|
213 | + if (isset($temp_options['api']['wetu_api_key']) && '' !== $temp_options['api']['wetu_api_key']) { |
|
214 | + $this->api_key = $temp_options['api']['wetu_api_key']; |
|
215 | + } |
|
216 | + if (isset($temp_options['api']['wetu_api_username']) && '' !== $temp_options['api']['wetu_api_username']) { |
|
217 | + $this->api_username = $temp_options['api']['wetu_api_username']; |
|
218 | + } |
|
219 | + if (isset($temp_options['api']['wetu_api_password']) && '' !== $temp_options['api']['wetu_api_password']) { |
|
220 | + $this->api_password = $temp_options['api']['wetu_api_password']; |
|
221 | + } |
|
222 | 222 | |
223 | 223 | //Set the tab slug |
224 | 224 | if(isset($_GET['tab']) || isset($_POST['type'])) { |
@@ -234,22 +234,22 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | //Set the scaling options |
237 | - if (isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug]) && isset($this->options['image_scaling'])) { |
|
238 | - $this->scale_images = true; |
|
239 | - $width = '800'; |
|
240 | - if (isset($this->options['width']) && '' !== $this->options['width']) { |
|
241 | - $width = $this->options['width']; |
|
242 | - } |
|
243 | - $height = '600'; |
|
244 | - if (isset($this->options['height']) && '' !== $this->options['height']) { |
|
245 | - $height = $this->options['height']; |
|
246 | - } |
|
247 | - $cropping = 'raw'; |
|
248 | - if (isset($this->options['cropping']) && '' !== $this->options['cropping']) { |
|
249 | - $cropping = $this->options['cropping']; |
|
250 | - } |
|
251 | - $this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/'; |
|
252 | - } |
|
237 | + if (isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug]) && isset($this->options['image_scaling'])) { |
|
238 | + $this->scale_images = true; |
|
239 | + $width = '800'; |
|
240 | + if (isset($this->options['width']) && '' !== $this->options['width']) { |
|
241 | + $width = $this->options['width']; |
|
242 | + } |
|
243 | + $height = '600'; |
|
244 | + if (isset($this->options['height']) && '' !== $this->options['height']) { |
|
245 | + $height = $this->options['height']; |
|
246 | + } |
|
247 | + $cropping = 'raw'; |
|
248 | + if (isset($this->options['cropping']) && '' !== $this->options['cropping']) { |
|
249 | + $cropping = $this->options['cropping']; |
|
250 | + } |
|
251 | + $this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/'; |
|
252 | + } |
|
253 | 253 | |
254 | 254 | } |
255 | 255 | } |
@@ -323,10 +323,10 @@ discard block |
||
323 | 323 | |
324 | 324 | // DISPLAY FUNCTIONS |
325 | 325 | |
326 | - /* |
|
326 | + /* |
|
327 | 327 | * Load the importer class you want to use |
328 | 328 | */ |
329 | - public function load_class(){ |
|
329 | + public function load_class(){ |
|
330 | 330 | |
331 | 331 | switch($this->tab_slug){ |
332 | 332 | case 'accommodation': |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | break; |
347 | 347 | } |
348 | 348 | |
349 | - } |
|
349 | + } |
|
350 | 350 | |
351 | 351 | /** |
352 | 352 | * Registers the admin page which will house the importer form. |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | <?php*/ |
403 | 403 | }else{ |
404 | 404 | $this->current_importer->display_page(); |
405 | - }; ?> |
|
405 | + }; ?> |
|
406 | 406 | </div> |
407 | 407 | <?php |
408 | 408 | } |
@@ -802,12 +802,12 @@ discard block |
||
802 | 802 | */ |
803 | 803 | public function set_featured_image($data,$id) { |
804 | 804 | if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
805 | - if('tour' === $this->tab_slug){ |
|
806 | - $key = array_rand($data[0]['content']['images']); |
|
807 | - $this->featured_image = $this->attach_image($data[0]['content']['images'][$key],$id); |
|
808 | - }else{ |
|
805 | + if('tour' === $this->tab_slug){ |
|
806 | + $key = array_rand($data[0]['content']['images']); |
|
807 | + $this->featured_image = $this->attach_image($data[0]['content']['images'][$key],$id); |
|
808 | + }else{ |
|
809 | 809 | $this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id); |
810 | - } |
|
810 | + } |
|
811 | 811 | |
812 | 812 | |
813 | 813 | if(false !== $this->featured_image){ |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | */ |
828 | 828 | public function set_banner_image($data,$id) { |
829 | 829 | if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
830 | - if(isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) { |
|
830 | + if(isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) { |
|
831 | 831 | $temp_banner = $this->attach_image($data[0]['destination_image'], $id, array('width' => '1920', 'height' => '600', 'cropping' => 'c')); |
832 | 832 | }else{ |
833 | 833 | if ('tour' === $this->tab_slug) { |
@@ -836,7 +836,7 @@ discard block |
||
836 | 836 | } else { |
837 | 837 | $temp_banner = $this->attach_image($data[0]['content']['images'][1], $id, array('width' => '1920', 'height' => '600', 'cropping' => 'c')); |
838 | 838 | } |
839 | - } |
|
839 | + } |
|
840 | 840 | |
841 | 841 | |
842 | 842 | if(false !== $temp_banner){ |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | * Run through the accommodation grabbed from the DB. |
1049 | 1049 | */ |
1050 | 1050 | public function process_ajax_search() { |
1051 | - $this->current_importer->process_ajax_search(); |
|
1051 | + $this->current_importer->process_ajax_search(); |
|
1052 | 1052 | die(); |
1053 | 1053 | } |
1054 | 1054 |
@@ -469,12 +469,12 @@ |
||
469 | 469 | $this->remove_from_queue($return); |
470 | 470 | $this->format_completed_row($return); |
471 | 471 | }else{ |
472 | - if(isset($adata['error'])){ |
|
473 | - $this->format_error($adata['error']); |
|
474 | - }else{ |
|
472 | + if(isset($adata['error'])){ |
|
473 | + $this->format_error($adata['error']); |
|
474 | + }else{ |
|
475 | 475 | $this->format_error(esc_html__('There was a problem importing your destination, please try refreshing the page.','wetu-importer')); |
476 | - } |
|
477 | - } |
|
476 | + } |
|
477 | + } |
|
478 | 478 | } |
479 | 479 | } |
480 | 480 | } |
@@ -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); |
@@ -304,11 +304,11 @@ discard block |
||
304 | 304 | |
305 | 305 | if('import' === $post_status){ |
306 | 306 | |
307 | - if(is_array($this->queued_imports) && in_array($row['post_id'],$this->queued_imports)){ |
|
307 | + if(is_array($this->queued_imports) && in_array($row['post_id'],$this->queued_imports)){ |
|
308 | 308 | $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
309 | - }else{ |
|
310 | - continue; |
|
311 | - } |
|
309 | + }else{ |
|
310 | + continue; |
|
311 | + } |
|
312 | 312 | |
313 | 313 | }else{ |
314 | 314 | |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * Saves the queue to the option. |
388 | 388 | */ |
389 | 389 | public function remove_from_queue($id) { |
390 | - if (!empty($this->queued_imports)) { |
|
390 | + if (!empty($this->queued_imports)) { |
|
391 | 391 | |
392 | 392 | if(($key = array_search($id, $this->queued_imports)) !== false) { |
393 | 393 | unset($this->queued_imports[$key]); |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | delete_option('wetu_importer_que'); |
396 | 396 | update_option('wetu_importer_que',$this->queued_imports); |
397 | 397 | } |
398 | - } |
|
398 | + } |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
@@ -434,23 +434,23 @@ discard block |
||
434 | 434 | $content = false; |
435 | 435 | } |
436 | 436 | |
437 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
438 | - if($jdata) |
|
439 | - { |
|
440 | - $adata=json_decode($jdata,true); |
|
437 | + $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
438 | + if($jdata) |
|
439 | + { |
|
440 | + $adata=json_decode($jdata,true); |
|
441 | 441 | if (!empty($adata) && !isset($adata['error'])) { |
442 | - $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
443 | - $this->format_completed_row($return); |
|
444 | - $this->remove_from_queue($return); |
|
442 | + $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
443 | + $this->format_completed_row($return); |
|
444 | + $this->remove_from_queue($return); |
|
445 | 445 | $this->cleanup_posts(); |
446 | - }else{ |
|
446 | + }else{ |
|
447 | 447 | if(isset($adata['error'])){ |
448 | 448 | $this->format_error($adata['error']); |
449 | 449 | }else{ |
450 | 450 | $this->format_error(esc_html__('There was a problem importing your accommodation, please try refreshing the page.','wetu-importer')); |
451 | 451 | } |
452 | 452 | } |
453 | - } |
|
453 | + } |
|
454 | 454 | } |
455 | 455 | } |
456 | 456 | |
@@ -459,144 +459,144 @@ discard block |
||
459 | 459 | */ |
460 | 460 | public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) { |
461 | 461 | |
462 | - $post_name = $data_post_content = $data_post_excerpt = ''; |
|
463 | - $post = array( |
|
464 | - 'post_type' => 'accommodation', |
|
465 | - ); |
|
466 | - |
|
467 | - $content_used_general_description = false; |
|
468 | - |
|
469 | - //Set the post_content |
|
470 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
471 | - if(isset($data[0]['content']['extended_description'])) |
|
472 | - { |
|
473 | - $data_post_content = $data[0]['content']['extended_description']; |
|
474 | - }elseif(isset($data[0]['content']['general_description'])){ |
|
475 | - $data_post_content = $data[0]['content']['general_description']; |
|
476 | - $content_used_general_description = true; |
|
477 | - }elseif(isset($data[0]['content']['teaser_description'])){ |
|
478 | - $data_post_content = $data[0]['content']['teaser_description']; |
|
479 | - } |
|
480 | - $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
481 | - } |
|
482 | - |
|
483 | - //set the post_excerpt |
|
484 | - if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
485 | - if(isset($data[0]['content']['teaser_description'])){ |
|
486 | - $data_post_excerpt = $data[0]['content']['teaser_description']; |
|
487 | - }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
488 | - $data_post_excerpt = $data[0]['content']['general_description']; |
|
489 | - } |
|
490 | - $post['post_excerpt'] = $data_post_excerpt; |
|
491 | - } |
|
492 | - |
|
493 | - if(false !== $id && '0' !== $id){ |
|
494 | - $post['ID'] = $id; |
|
462 | + $post_name = $data_post_content = $data_post_excerpt = ''; |
|
463 | + $post = array( |
|
464 | + 'post_type' => 'accommodation', |
|
465 | + ); |
|
466 | + |
|
467 | + $content_used_general_description = false; |
|
468 | + |
|
469 | + //Set the post_content |
|
470 | + if(false !== $importable_content && in_array('description',$importable_content)){ |
|
471 | + if(isset($data[0]['content']['extended_description'])) |
|
472 | + { |
|
473 | + $data_post_content = $data[0]['content']['extended_description']; |
|
474 | + }elseif(isset($data[0]['content']['general_description'])){ |
|
475 | + $data_post_content = $data[0]['content']['general_description']; |
|
476 | + $content_used_general_description = true; |
|
477 | + }elseif(isset($data[0]['content']['teaser_description'])){ |
|
478 | + $data_post_content = $data[0]['content']['teaser_description']; |
|
479 | + } |
|
480 | + $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
481 | + } |
|
482 | + |
|
483 | + //set the post_excerpt |
|
484 | + if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
485 | + if(isset($data[0]['content']['teaser_description'])){ |
|
486 | + $data_post_excerpt = $data[0]['content']['teaser_description']; |
|
487 | + }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
488 | + $data_post_excerpt = $data[0]['content']['general_description']; |
|
489 | + } |
|
490 | + $post['post_excerpt'] = $data_post_excerpt; |
|
491 | + } |
|
492 | + |
|
493 | + if(false !== $id && '0' !== $id){ |
|
494 | + $post['ID'] = $id; |
|
495 | 495 | if(isset($data[0]['name'])){ |
496 | 496 | $post['post_title'] = $data[0]['name']; |
497 | - $post['post_status'] = 'publish'; |
|
497 | + $post['post_status'] = 'publish'; |
|
498 | 498 | $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
499 | 499 | } |
500 | - $id = wp_update_post($post); |
|
501 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
502 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
503 | - }else{ |
|
504 | - |
|
505 | - //Set the name |
|
506 | - if(isset($data[0]['name'])){ |
|
507 | - $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
508 | - } |
|
509 | - $post['post_name'] = $post_name; |
|
510 | - $post['post_title'] = $data[0]['name']; |
|
511 | - $post['post_status'] = 'publish'; |
|
512 | - $id = wp_insert_post($post); |
|
513 | - |
|
514 | - //Save the WETU ID and the Last date it was modified. |
|
515 | - if(false !== $id){ |
|
516 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
517 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
518 | - } |
|
519 | - } |
|
520 | - //Setup some default for use in the import |
|
521 | - if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
|
500 | + $id = wp_update_post($post); |
|
501 | + $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
502 | + update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
503 | + }else{ |
|
504 | + |
|
505 | + //Set the name |
|
506 | + if(isset($data[0]['name'])){ |
|
507 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
508 | + } |
|
509 | + $post['post_name'] = $post_name; |
|
510 | + $post['post_title'] = $data[0]['name']; |
|
511 | + $post['post_status'] = 'publish'; |
|
512 | + $id = wp_insert_post($post); |
|
513 | + |
|
514 | + //Save the WETU ID and the Last date it was modified. |
|
515 | + if(false !== $id){ |
|
516 | + add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
517 | + add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
518 | + } |
|
519 | + } |
|
520 | + //Setup some default for use in the import |
|
521 | + if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
|
522 | 522 | $this->find_attachments($id); |
523 | 523 | } |
524 | 524 | |
525 | - //Set the team member if it is there |
|
526 | - if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
527 | - $this->set_team_member($id,$team_members); |
|
528 | - } |
|
529 | - |
|
530 | - //Set the safari brand |
|
531 | - if(false !== $safari_brands && '' !== $safari_brands){ |
|
532 | - $this->set_safari_brands($id,$safari_brands); |
|
533 | - |
|
534 | - } |
|
535 | - |
|
536 | - if(class_exists('LSX_TO_Maps')){ |
|
537 | - $this->set_map_data($data,$id,9); |
|
538 | - } |
|
539 | - |
|
540 | - if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){ |
|
541 | - $this->connect_destinations($data,$id); |
|
542 | - } |
|
543 | - |
|
544 | - if(false !== $importable_content && in_array('category',$importable_content)){ |
|
545 | - $this->set_taxonomy_style($data,$id); |
|
546 | - } |
|
547 | - |
|
548 | - //Set the Room Data |
|
549 | - if(false !== $importable_content && in_array('rooms',$importable_content)){ |
|
550 | - $this->set_room_data($data,$id); |
|
551 | - } |
|
552 | - |
|
553 | - //Set the rating |
|
554 | - if(false !== $importable_content && in_array('rating',$importable_content)){ |
|
555 | - $this->set_rating($data,$id); |
|
556 | - } |
|
557 | - |
|
558 | - //Set the checkin checkout data |
|
559 | - if(false !== $importable_content && in_array('checkin',$importable_content)){ |
|
560 | - $this->set_checkin_checkout($data,$id); |
|
561 | - } |
|
562 | - |
|
563 | - //Set the Spoken Languages |
|
564 | - if(false !== $importable_content && in_array('spoken_languages',$importable_content)){ |
|
565 | - $this->set_spoken_languages($data,$id); |
|
566 | - } |
|
567 | - |
|
568 | - //Set the friendly options |
|
569 | - if(false !== $importable_content && in_array('friendly',$importable_content)){ |
|
570 | - $this->set_friendly($data,$id); |
|
571 | - } |
|
572 | - |
|
573 | - //Set the special_interests |
|
574 | - if(false !== $importable_content && in_array('special_interests',$importable_content)){ |
|
575 | - $this->set_special_interests($data,$id); |
|
576 | - } |
|
577 | - |
|
578 | - //Import the videos |
|
579 | - if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
580 | - $this->set_video_data($data,$id); |
|
581 | - } |
|
582 | - |
|
583 | - //Import the facilities |
|
584 | - if(false !== $importable_content && in_array('facilities',$importable_content)){ |
|
585 | - $this->set_facilities($data,$id); |
|
586 | - } |
|
587 | - |
|
588 | - //Set the featured image |
|
589 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
590 | - $this->set_featured_image($data,$id); |
|
591 | - } |
|
592 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
593 | - $this->set_banner_image($data,$id); |
|
594 | - } |
|
595 | - //Import the main gallery |
|
596 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
597 | - $this->create_main_gallery($data,$id); |
|
598 | - } |
|
599 | - return $id; |
|
525 | + //Set the team member if it is there |
|
526 | + if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
527 | + $this->set_team_member($id,$team_members); |
|
528 | + } |
|
529 | + |
|
530 | + //Set the safari brand |
|
531 | + if(false !== $safari_brands && '' !== $safari_brands){ |
|
532 | + $this->set_safari_brands($id,$safari_brands); |
|
533 | + |
|
534 | + } |
|
535 | + |
|
536 | + if(class_exists('LSX_TO_Maps')){ |
|
537 | + $this->set_map_data($data,$id,9); |
|
538 | + } |
|
539 | + |
|
540 | + if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){ |
|
541 | + $this->connect_destinations($data,$id); |
|
542 | + } |
|
543 | + |
|
544 | + if(false !== $importable_content && in_array('category',$importable_content)){ |
|
545 | + $this->set_taxonomy_style($data,$id); |
|
546 | + } |
|
547 | + |
|
548 | + //Set the Room Data |
|
549 | + if(false !== $importable_content && in_array('rooms',$importable_content)){ |
|
550 | + $this->set_room_data($data,$id); |
|
551 | + } |
|
552 | + |
|
553 | + //Set the rating |
|
554 | + if(false !== $importable_content && in_array('rating',$importable_content)){ |
|
555 | + $this->set_rating($data,$id); |
|
556 | + } |
|
557 | + |
|
558 | + //Set the checkin checkout data |
|
559 | + if(false !== $importable_content && in_array('checkin',$importable_content)){ |
|
560 | + $this->set_checkin_checkout($data,$id); |
|
561 | + } |
|
562 | + |
|
563 | + //Set the Spoken Languages |
|
564 | + if(false !== $importable_content && in_array('spoken_languages',$importable_content)){ |
|
565 | + $this->set_spoken_languages($data,$id); |
|
566 | + } |
|
567 | + |
|
568 | + //Set the friendly options |
|
569 | + if(false !== $importable_content && in_array('friendly',$importable_content)){ |
|
570 | + $this->set_friendly($data,$id); |
|
571 | + } |
|
572 | + |
|
573 | + //Set the special_interests |
|
574 | + if(false !== $importable_content && in_array('special_interests',$importable_content)){ |
|
575 | + $this->set_special_interests($data,$id); |
|
576 | + } |
|
577 | + |
|
578 | + //Import the videos |
|
579 | + if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
580 | + $this->set_video_data($data,$id); |
|
581 | + } |
|
582 | + |
|
583 | + //Import the facilities |
|
584 | + if(false !== $importable_content && in_array('facilities',$importable_content)){ |
|
585 | + $this->set_facilities($data,$id); |
|
586 | + } |
|
587 | + |
|
588 | + //Set the featured image |
|
589 | + if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
590 | + $this->set_featured_image($data,$id); |
|
591 | + } |
|
592 | + if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
593 | + $this->set_banner_image($data,$id); |
|
594 | + } |
|
595 | + //Import the main gallery |
|
596 | + if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
597 | + $this->create_main_gallery($data,$id); |
|
598 | + } |
|
599 | + return $id; |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | /** |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | |
607 | 607 | delete_post_meta($id, 'team_to_'.$this->tab_slug); |
608 | 608 | foreach($team_members as $team){ |
609 | - add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
609 | + add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
610 | 610 | } |
611 | 611 | } |
612 | 612 | |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | */ |
616 | 616 | public function set_safari_brands($id,$safari_brands) { |
617 | 617 | foreach($safari_brands as $safari_brand){ |
618 | - wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true); |
|
618 | + wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true); |
|
619 | 619 | } |
620 | 620 | } |
621 | 621 | |
@@ -624,32 +624,32 @@ discard block |
||
624 | 624 | */ |
625 | 625 | public function connect_destinations($data,$id) { |
626 | 626 | if(isset($data[0]['position'])){ |
627 | - $destinations = false; |
|
628 | - if(isset($data[0]['position']['country'])){ |
|
629 | - $destinations['country'] = $data[0]['position']['country']; |
|
630 | - } |
|
631 | - if(isset($data[0]['position']['destination'])){ |
|
632 | - $destinations['destination'] = $data[0]['position']['destination']; |
|
633 | - } |
|
627 | + $destinations = false; |
|
628 | + if(isset($data[0]['position']['country'])){ |
|
629 | + $destinations['country'] = $data[0]['position']['country']; |
|
630 | + } |
|
631 | + if(isset($data[0]['position']['destination'])){ |
|
632 | + $destinations['destination'] = $data[0]['position']['destination']; |
|
633 | + } |
|
634 | 634 | |
635 | - if(false !== $destinations){ |
|
636 | - $prev_values = get_post_meta($id,'destination_to_accommodation',false); |
|
637 | - if(false === $prev_values || !is_array($prev_values)){ |
|
638 | - $prev_values = array(); |
|
639 | - } |
|
640 | - //print_r($destinations); |
|
635 | + if(false !== $destinations){ |
|
636 | + $prev_values = get_post_meta($id,'destination_to_accommodation',false); |
|
637 | + if(false === $prev_values || !is_array($prev_values)){ |
|
638 | + $prev_values = array(); |
|
639 | + } |
|
640 | + //print_r($destinations); |
|
641 | 641 | $destinations = array_unique($destinations); |
642 | 642 | //print_r($destinations); |
643 | - foreach($destinations as $key => $value){ |
|
644 | - $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
|
645 | - if (null !== $destination) { |
|
646 | - if(!in_array($destination->ID,$prev_values)){ |
|
647 | - add_post_meta($id,'destination_to_accommodation',$destination->ID,false); |
|
648 | - add_post_meta($destination->ID,'accommodation_to_destination',$id,false); |
|
643 | + foreach($destinations as $key => $value){ |
|
644 | + $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
|
645 | + if (null !== $destination) { |
|
646 | + if(!in_array($destination->ID,$prev_values)){ |
|
647 | + add_post_meta($id,'destination_to_accommodation',$destination->ID,false); |
|
648 | + add_post_meta($destination->ID,'accommodation_to_destination',$id,false); |
|
649 | 649 | $this->cleanup_posts[$destination->ID] = 'accommodation_to_destination'; |
650 | - } |
|
651 | - } |
|
652 | - } |
|
650 | + } |
|
651 | + } |
|
652 | + } |
|
653 | 653 | } |
654 | 654 | } |
655 | 655 | } |
@@ -661,15 +661,15 @@ discard block |
||
661 | 661 | $terms = false; |
662 | 662 | if(isset($data[0]['category'])){ |
663 | 663 | if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) |
664 | - { |
|
665 | - $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type'); |
|
666 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
667 | - else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); } |
|
668 | - } |
|
669 | - else |
|
670 | - { |
|
671 | - wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); |
|
672 | - } |
|
664 | + { |
|
665 | + $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type'); |
|
666 | + if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
667 | + else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); } |
|
668 | + } |
|
669 | + else |
|
670 | + { |
|
671 | + wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); |
|
672 | + } |
|
673 | 673 | } |
674 | 674 | } |
675 | 675 | |
@@ -693,25 +693,25 @@ discard block |
||
693 | 693 | $temp_room['type'] = 'room'; |
694 | 694 | |
695 | 695 | if(!empty($room['images']) && is_array($room['images'])){ |
696 | - $attachments_args = array( |
|
697 | - 'post_parent' => $id, |
|
698 | - 'post_status' => 'inherit', |
|
699 | - 'post_type' => 'attachment', |
|
700 | - 'order' => 'ASC', |
|
701 | - ); |
|
702 | - $attachments = new WP_Query($attachments_args); |
|
703 | - $found_attachments = array(); |
|
704 | - |
|
705 | - if($attachments->have_posts()){ |
|
706 | - foreach($attachments->posts as $attachment){ |
|
707 | - $found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
708 | - } |
|
709 | - } |
|
696 | + $attachments_args = array( |
|
697 | + 'post_parent' => $id, |
|
698 | + 'post_status' => 'inherit', |
|
699 | + 'post_type' => 'attachment', |
|
700 | + 'order' => 'ASC', |
|
701 | + ); |
|
702 | + $attachments = new WP_Query($attachments_args); |
|
703 | + $found_attachments = array(); |
|
704 | + |
|
705 | + if($attachments->have_posts()){ |
|
706 | + foreach($attachments->posts as $attachment){ |
|
707 | + $found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
708 | + } |
|
709 | + } |
|
710 | 710 | |
711 | 711 | $temp_room['gallery'] = array(); |
712 | 712 | foreach($room['images'] as $image_data){ |
713 | - $temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments); |
|
714 | - } |
|
713 | + $temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments); |
|
714 | + } |
|
715 | 715 | } |
716 | 716 | $rooms[] = $temp_room; |
717 | 717 | } |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | delete_post_meta($id, 'units'); |
721 | 721 | } |
722 | 722 | foreach($rooms as $room){ |
723 | - add_post_meta($id,'units',$room,false); |
|
723 | + add_post_meta($id,'units',$room,false); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){ |
@@ -730,11 +730,11 @@ discard block |
||
730 | 730 | } |
731 | 731 | |
732 | 732 | if(false !== $id && '0' !== $id){ |
733 | - $prev_rooms = get_post_meta($id,'number_of_rooms',true); |
|
734 | - update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms); |
|
735 | - }else{ |
|
736 | - add_post_meta($id,'number_of_rooms',$room_count,true); |
|
737 | - } |
|
733 | + $prev_rooms = get_post_meta($id,'number_of_rooms',true); |
|
734 | + update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms); |
|
735 | + }else{ |
|
736 | + add_post_meta($id,'number_of_rooms',$room_count,true); |
|
737 | + } |
|
738 | 738 | } |
739 | 739 | } |
740 | 740 |
@@ -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 | |
@@ -254,20 +254,20 @@ discard block |
||
254 | 254 | $result = $this->update_options(); |
255 | 255 | |
256 | 256 | if(true === $result){ |
257 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
258 | - echo ' - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
259 | - }else{ |
|
260 | - echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
261 | - } |
|
257 | + echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
258 | + echo ' - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
259 | + }else{ |
|
260 | + echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
261 | + } |
|
262 | 262 | }else{ |
263 | 263 | echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
264 | - } |
|
264 | + } |
|
265 | 265 | echo '</h3>'; |
266 | 266 | |
267 | 267 | $form_options = get_option('lsx_ti_tours_api_options'); |
268 | 268 | if(false === $form_options){ |
269 | 269 | $form_options = array(0); |
270 | - } |
|
270 | + } |
|
271 | 271 | ?> |
272 | 272 | <form method="get" class="tour-refresh-form" action="<?php echo admin_url('admin.php'); ?>"> |
273 | 273 | |
@@ -297,15 +297,15 @@ discard block |
||
297 | 297 | */ |
298 | 298 | public function update_options() { |
299 | 299 | |
300 | - $own = ''; |
|
301 | - $options = array(); |
|
300 | + $own = ''; |
|
301 | + $options = array(); |
|
302 | 302 | |
303 | - delete_option('lsx_ti_tours_api_options'); |
|
303 | + delete_option('lsx_ti_tours_api_options'); |
|
304 | 304 | |
305 | - if(isset($_GET['own'])){ |
|
305 | + if(isset($_GET['own'])){ |
|
306 | 306 | $this->url_qs .= '&own=true'; |
307 | 307 | $options[] = 'own'; |
308 | - } |
|
308 | + } |
|
309 | 309 | |
310 | 310 | if(isset($_GET['type'])){ |
311 | 311 | $this->url_qs .= '&type='.implode('',$_GET['type']); |
@@ -321,8 +321,8 @@ discard block |
||
321 | 321 | $tours = json_decode($data, true); |
322 | 322 | |
323 | 323 | if(isset($tours['error'])){ |
324 | - return $tours['error']; |
|
325 | - }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
324 | + return $tours['error']; |
|
325 | + }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
326 | 326 | set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2); |
327 | 327 | return true; |
328 | 328 | } |
@@ -525,77 +525,77 @@ discard block |
||
525 | 525 | $content = false; |
526 | 526 | } |
527 | 527 | |
528 | - $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
528 | + $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
529 | 529 | |
530 | - if($jdata) |
|
531 | - { |
|
530 | + if($jdata) |
|
531 | + { |
|
532 | 532 | $jdata=json_decode($jdata,true); |
533 | 533 | if (!empty($jdata) && !isset($jdata['error'])) { |
534 | - $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
535 | - $this->format_completed_row($return); |
|
534 | + $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
535 | + $this->format_completed_row($return); |
|
536 | 536 | $this->save_queue(); |
537 | - $this->cleanup_posts(); |
|
538 | - $this->attach_destination_images($content); |
|
539 | - }else{ |
|
537 | + $this->cleanup_posts(); |
|
538 | + $this->attach_destination_images($content); |
|
539 | + }else{ |
|
540 | 540 | if(isset($adata['error'])){ |
541 | 541 | $this->format_error($adata['error']); |
542 | 542 | }else{ |
543 | 543 | $this->format_error(esc_html__('There was a problem importing your tour, please try refreshing the page.','wetu-importer')); |
544 | 544 | } |
545 | 545 | } |
546 | - } |
|
546 | + } |
|
547 | 547 | } |
548 | 548 | } |
549 | 549 | |
550 | 550 | /** |
551 | 551 | * Connect to wetu |
552 | - * |
|
553 | - * @param $data array |
|
554 | - * @param $wetu_id string |
|
552 | + * |
|
553 | + * @param $data array |
|
554 | + * @param $wetu_id string |
|
555 | 555 | */ |
556 | 556 | public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) { |
557 | - $post_name = $data_post_content = $data_post_excerpt = ''; |
|
558 | - $post = array( |
|
559 | - 'post_type' => 'tour', |
|
560 | - ); |
|
557 | + $post_name = $data_post_content = $data_post_excerpt = ''; |
|
558 | + $post = array( |
|
559 | + 'post_type' => 'tour', |
|
560 | + ); |
|
561 | 561 | |
562 | - //Set the post_content |
|
562 | + //Set the post_content |
|
563 | 563 | $content_used_general_description = false; |
564 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
565 | - $data_post_content = ''; |
|
566 | - |
|
567 | - if(isset($data['description'])){ |
|
568 | - $data_post_content = $data['description']; |
|
569 | - }elseif(isset($data['summary'])){ |
|
570 | - $data_post_content = $data['summary']; |
|
571 | - } |
|
572 | - $post['post_content'] = $data_post_content; |
|
573 | - } |
|
574 | - |
|
575 | - //Create or update the post |
|
576 | - if(false !== $id && '0' !== $id){ |
|
577 | - $post['ID'] = $id; |
|
578 | - $post['post_status'] = 'publish'; |
|
579 | - $id = wp_update_post($post); |
|
580 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
581 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
582 | - }else{ |
|
583 | - |
|
584 | - //Set the name |
|
585 | - if(isset($data['name'])){ |
|
586 | - $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
587 | - } |
|
588 | - $post['post_name'] = $post_name; |
|
589 | - $post['post_title'] = $data['name']; |
|
590 | - $post['post_status'] = 'publish'; |
|
591 | - $id = wp_insert_post($post); |
|
592 | - |
|
593 | - //Save the WETU ID and the Last date it was modified. |
|
594 | - if(false !== $id){ |
|
595 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
596 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
597 | - } |
|
598 | - } |
|
564 | + if(false !== $importable_content && in_array('description',$importable_content)){ |
|
565 | + $data_post_content = ''; |
|
566 | + |
|
567 | + if(isset($data['description'])){ |
|
568 | + $data_post_content = $data['description']; |
|
569 | + }elseif(isset($data['summary'])){ |
|
570 | + $data_post_content = $data['summary']; |
|
571 | + } |
|
572 | + $post['post_content'] = $data_post_content; |
|
573 | + } |
|
574 | + |
|
575 | + //Create or update the post |
|
576 | + if(false !== $id && '0' !== $id){ |
|
577 | + $post['ID'] = $id; |
|
578 | + $post['post_status'] = 'publish'; |
|
579 | + $id = wp_update_post($post); |
|
580 | + $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
581 | + update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
582 | + }else{ |
|
583 | + |
|
584 | + //Set the name |
|
585 | + if(isset($data['name'])){ |
|
586 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
587 | + } |
|
588 | + $post['post_name'] = $post_name; |
|
589 | + $post['post_title'] = $data['name']; |
|
590 | + $post['post_status'] = 'publish'; |
|
591 | + $id = wp_insert_post($post); |
|
592 | + |
|
593 | + //Save the WETU ID and the Last date it was modified. |
|
594 | + if(false !== $id){ |
|
595 | + add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
596 | + add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
597 | + } |
|
598 | + } |
|
599 | 599 | |
600 | 600 | |
601 | 601 | //Set the price |
@@ -608,15 +608,15 @@ discard block |
||
608 | 608 | $this->set_duration($data,$id); |
609 | 609 | } |
610 | 610 | |
611 | - if(false !== $importable_content && in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
612 | - $this->process_itineraries($data,$id,$importable_content); |
|
613 | - } |
|
611 | + if(false !== $importable_content && in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
612 | + $this->process_itineraries($data,$id,$importable_content); |
|
613 | + } |
|
614 | 614 | |
615 | 615 | if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){ |
616 | 616 | $this->set_map_data($data,$id); |
617 | 617 | } |
618 | 618 | |
619 | - return $id; |
|
619 | + return $id; |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
@@ -778,17 +778,17 @@ discard block |
||
778 | 778 | * Set the Itinerary Day |
779 | 779 | */ |
780 | 780 | public function set_itinerary_day($day,$id) { |
781 | - $this->save_custom_field($day,'itinerary',$id,false,false); |
|
781 | + $this->save_custom_field($day,'itinerary',$id,false,false); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | /** |
785 | 785 | * Set the price |
786 | 786 | */ |
787 | 787 | public function set_price($data,$id) { |
788 | - //Price |
|
788 | + //Price |
|
789 | 789 | if(isset($data['price']) && ''!== $data['price']){ |
790 | - $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
|
791 | - $this->save_custom_field($price,'price',$id); |
|
790 | + $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
|
791 | + $this->save_custom_field($price,'price',$id); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | //Price includes |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | $this->save_custom_field($data['price_includes'],'included',$id); |
797 | 797 | } |
798 | 798 | |
799 | - //Price Excludes |
|
799 | + //Price Excludes |
|
800 | 800 | if(isset($data['price_excludes']) && ''!== $data['price_excludes']){ |
801 | 801 | $this->save_custom_field($data['price_excludes'],'not_included',$id); |
802 | 802 | } |
@@ -819,37 +819,37 @@ discard block |
||
819 | 819 | */ |
820 | 820 | public function set_accommodation($day,$id) { |
821 | 821 | |
822 | - $ac_id = false; |
|
822 | + $ac_id = false; |
|
823 | 823 | $this->current_accommodation = $this->find_current_accommodation(); |
824 | 824 | |
825 | 825 | if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){ |
826 | 826 | |
827 | 827 | if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
828 | - $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
828 | + $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
829 | 829 | }else{ |
830 | 830 | $ac_id = wp_insert_post(array( |
831 | - 'post_type' => 'accommodation', |
|
832 | - 'post_status' => 'draft', |
|
833 | - 'post_title' => $day['content_entity_id'] |
|
834 | - )); |
|
831 | + 'post_type' => 'accommodation', |
|
832 | + 'post_status' => 'draft', |
|
833 | + 'post_title' => $day['content_entity_id'] |
|
834 | + )); |
|
835 | 835 | $this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id); |
836 | 836 | } |
837 | 837 | |
838 | 838 | if('' !== $ac_id && false !== $ac_id){ |
839 | - $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
839 | + $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
840 | 840 | $this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false); |
841 | 841 | |
842 | 842 | $this->queue_item($ac_id); |
843 | - } |
|
843 | + } |
|
844 | 844 | } |
845 | 845 | return $ac_id; |
846 | 846 | } |
847 | 847 | |
848 | 848 | /** |
849 | 849 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
850 | - * |
|
851 | - * @param $post_type string |
|
852 | - * @return boolean / array |
|
850 | + * |
|
851 | + * @param $post_type string |
|
852 | + * @return boolean / array |
|
853 | 853 | */ |
854 | 854 | public function find_current_accommodation($post_type='accommodation') { |
855 | 855 | global $wpdb; |
@@ -857,16 +857,16 @@ discard block |
||
857 | 857 | |
858 | 858 | $return = false; |
859 | 859 | if(!empty($accommodation)){ |
860 | - foreach($accommodation as $key => $acc){ |
|
860 | + foreach($accommodation as $key => $acc){ |
|
861 | 861 | $return[$acc->meta_value] = $acc->post_id; |
862 | - } |
|
863 | - } |
|
862 | + } |
|
863 | + } |
|
864 | 864 | return $return; |
865 | 865 | } |
866 | 866 | |
867 | 867 | /** |
868 | 868 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
869 | - * @return boolean / array |
|
869 | + * @return boolean / array |
|
870 | 870 | */ |
871 | 871 | public function find_current_destinations() { |
872 | 872 | return $this->find_current_accommodation('destination'); |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | $country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true); |
895 | 895 | if(false !== $country_wetu_id){ |
896 | 896 | $country_id = $this->set_country($country_wetu_id, $id); |
897 | - } |
|
897 | + } |
|
898 | 898 | |
899 | 899 | }else { |
900 | 900 | |
@@ -905,27 +905,27 @@ discard block |
||
905 | 905 | |
906 | 906 | if (!empty($destination_data) && !isset($destination_data['error'])) { |
907 | 907 | |
908 | - $destination_title = $day['destination_content_entity_id']; |
|
908 | + $destination_title = $day['destination_content_entity_id']; |
|
909 | 909 | |
910 | - if(isset($destination_data[0]['name'])){ |
|
910 | + if(isset($destination_data[0]['name'])){ |
|
911 | 911 | $destination_title = $destination_data[0]['name']; |
912 | - } |
|
912 | + } |
|
913 | 913 | |
914 | - if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
915 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
914 | + if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
915 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
916 | 916 | |
917 | 917 | $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
918 | - } |
|
918 | + } |
|
919 | 919 | |
920 | - $dest_post = array( |
|
920 | + $dest_post = array( |
|
921 | 921 | 'post_type' => 'destination', |
922 | 922 | 'post_status' => 'draft', |
923 | 923 | 'post_title' => $destination_title |
924 | 924 | ); |
925 | 925 | |
926 | - if(false !== $country_id){ |
|
926 | + if(false !== $country_id){ |
|
927 | 927 | $dest_post['post_parent'] = $country_id; |
928 | - } |
|
928 | + } |
|
929 | 929 | $dest_id = wp_insert_post($dest_post); |
930 | 930 | |
931 | 931 | //Make sure we register the |
@@ -944,20 +944,20 @@ discard block |
||
944 | 944 | $this->queue_item($dest_id); |
945 | 945 | |
946 | 946 | //Save the item to clean up the amount of connections. |
947 | - $this->cleanup_posts[$dest_id] = 'tour_to_destination'; |
|
947 | + $this->cleanup_posts[$dest_id] = 'tour_to_destination'; |
|
948 | 948 | |
949 | 949 | // Save the first destination so we can grab the tour featured image and banner |
950 | 950 | if(0 === $leg_counter){ |
951 | - $this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']); |
|
952 | - } |
|
951 | + $this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']); |
|
952 | + } |
|
953 | 953 | |
954 | 954 | //Add this relation info so we can make sure certain items are set as countries. |
955 | 955 | if(0 !== $country_id && false !== $country_id){ |
956 | - $this->relation_meta[$dest_id] = $country_id; |
|
956 | + $this->relation_meta[$dest_id] = $country_id; |
|
957 | 957 | $this->relation_meta[$country_id] = 0; |
958 | - }else{ |
|
958 | + }else{ |
|
959 | 959 | $this->relation_meta[$dest_id] = 0; |
960 | - } |
|
960 | + } |
|
961 | 961 | } |
962 | 962 | } |
963 | 963 | return $dest_id; |
@@ -967,54 +967,54 @@ discard block |
||
967 | 967 | * Connects the destinations post type |
968 | 968 | * |
969 | 969 | * @param $dest_id string |
970 | - * @param $country_id array |
|
970 | + * @param $country_id array |
|
971 | 971 | * @param $id string |
972 | - * |
|
973 | - * @return string |
|
972 | + * |
|
973 | + * @return string |
|
974 | 974 | */ |
975 | 975 | public function set_country($country_wetu_id, $id) { |
976 | - $country_id = false; |
|
976 | + $country_id = false; |
|
977 | 977 | $this->current_destinations = $this->find_current_destinations(); |
978 | 978 | |
979 | - if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
980 | - $country_id = $this->current_destinations[$country_wetu_id]; |
|
981 | - } else { |
|
979 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
980 | + $country_id = $this->current_destinations[$country_wetu_id]; |
|
981 | + } else { |
|
982 | 982 | |
983 | - $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
983 | + $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
984 | 984 | |
985 | - if ($country_json) { |
|
986 | - $country_data = json_decode($country_json, true); |
|
985 | + if ($country_json) { |
|
986 | + $country_data = json_decode($country_json, true); |
|
987 | 987 | |
988 | - if (!empty($country_data) && !isset($country_data['error'])) { |
|
988 | + if (!empty($country_data) && !isset($country_data['error'])) { |
|
989 | 989 | |
990 | 990 | //Format the title of the destination if its available, otherwise default to the WETU ID. |
991 | - $country_title = $country_wetu_id; |
|
992 | - if (isset($country_data[0]['name'])) { |
|
991 | + $country_title = $country_wetu_id; |
|
992 | + if (isset($country_data[0]['name'])) { |
|
993 | 993 | $country_title = $country_data[0]['name']; |
994 | - } |
|
994 | + } |
|
995 | 995 | |
996 | 996 | $country_id = wp_insert_post(array( |
997 | - 'post_type' => 'destination', |
|
998 | - 'post_status' => 'draft', |
|
999 | - 'post_title' => $country_title |
|
1000 | - )); |
|
997 | + 'post_type' => 'destination', |
|
998 | + 'post_status' => 'draft', |
|
999 | + 'post_title' => $country_title |
|
1000 | + )); |
|
1001 | 1001 | //add the country to the current destination stack |
1002 | 1002 | $this->current_destinations[$country_wetu_id] = $country_id; |
1003 | 1003 | |
1004 | 1004 | //Save the wetu field |
1005 | - $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
1006 | - } |
|
1007 | - } |
|
1008 | - } |
|
1009 | - |
|
1010 | - if ('' !== $country_id && false !== $country_id) { |
|
1011 | - $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
1012 | - $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
1005 | + $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
1006 | + } |
|
1007 | + } |
|
1008 | + } |
|
1009 | + |
|
1010 | + if ('' !== $country_id && false !== $country_id) { |
|
1011 | + $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
1012 | + $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
1013 | 1013 | $this->queue_item($country_id); |
1014 | 1014 | $this->cleanup_posts[$country_id] = 'tour_to_destination'; |
1015 | 1015 | |
1016 | - return $country_id; |
|
1017 | - } |
|
1016 | + return $country_id; |
|
1017 | + } |
|
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | /** |
@@ -1027,9 +1027,9 @@ discard block |
||
1027 | 1027 | * @return string |
1028 | 1028 | */ |
1029 | 1029 | public function attach_destination_images($importable_content=array()) { |
1030 | - if(false !== $this->destination_images){ |
|
1030 | + if(false !== $this->destination_images){ |
|
1031 | 1031 | |
1032 | - foreach($this->destination_images as $tour => $destination){ |
|
1032 | + foreach($this->destination_images as $tour => $destination){ |
|
1033 | 1033 | |
1034 | 1034 | $url = 'https://wetu.com/API/Pins/' . $this->api_key; |
1035 | 1035 | $url_qs = ''; |
@@ -1050,8 +1050,8 @@ discard block |
||
1050 | 1050 | } |
1051 | 1051 | } |
1052 | 1052 | } |
1053 | - } |
|
1054 | - } |
|
1053 | + } |
|
1054 | + } |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | /** |