@@ -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 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | // $this->url = 'https://wetu.com/API/Pins/'; |
79 | 79 | // $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
80 | 80 | //} elseif ( false !== $this->api_key ) { |
81 | - $this->url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
81 | + $this->url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
82 | 82 | $this->url_qs = ''; |
83 | 83 | //} |
84 | 84 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | |
323 | 323 | if (isset($_POST['keyword'])) { |
324 | 324 | $keyphrases = $_POST['keyword']; |
325 | - } else { |
|
325 | + }else { |
|
326 | 326 | $keyphrases = array(0); |
327 | 327 | } |
328 | 328 | |
@@ -354,10 +354,10 @@ discard block |
||
354 | 354 | foreach ($destination as $row) { |
355 | 355 | |
356 | 356 | //If we are searching for |
357 | - if('import' === $post_status) { |
|
358 | - if(is_array($this->queued_imports) && in_array($row->post_id,$this->queued_imports)){ |
|
359 | - $searched_items[sanitize_title($row->name) . '-' . $row->meta_value] = $this->format_row($row); |
|
360 | - }else{ |
|
357 | + if ('import' === $post_status) { |
|
358 | + if (is_array($this->queued_imports) && in_array($row->post_id, $this->queued_imports)) { |
|
359 | + $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row); |
|
360 | + }else { |
|
361 | 361 | continue; |
362 | 362 | } |
363 | 363 | }else if (false !== $post_status) { |
@@ -366,10 +366,10 @@ discard block |
||
366 | 366 | if ($current_status !== $post_status) { |
367 | 367 | continue; |
368 | 368 | } |
369 | - $searched_items[sanitize_title($row->name) . '-' . $row->meta_value] = $this->format_row($row); |
|
369 | + $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row); |
|
370 | 370 | |
371 | 371 | |
372 | - } else { |
|
372 | + }else { |
|
373 | 373 | //Search through each keyword. |
374 | 374 | foreach ($keyphrases as $keyphrase) { |
375 | 375 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | } |
381 | 381 | |
382 | 382 | if ($this->multineedle_stripos(ltrim(rtrim($row->name)), $keywords) !== false) { |
383 | - $searched_items[sanitize_title($row->name) . '-' . $row->meta_value] = $this->format_row($row); |
|
383 | + $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row); |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | } |
@@ -406,23 +406,23 @@ discard block |
||
406 | 406 | |
407 | 407 | $status = 'import'; |
408 | 408 | if (0 !== $row->post_id) { |
409 | - $status = '<a href="' . admin_url('/post.php?post=' . $row->post_id . '&action=edit') . '" target="_blank">' . get_post_status($row->post_id) . '</a>'; |
|
409 | + $status = '<a href="'.admin_url('/post.php?post='.$row->post_id.'&action=edit').'" target="_blank">'.get_post_status($row->post_id).'</a>'; |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | $row_html = ' |
413 | - <tr class="post-' . $row->post_id . ' type-tour" id="post-' . $row->post_id . '"> |
|
413 | + <tr class="post-' . $row->post_id.' type-tour" id="post-'.$row->post_id.'"> |
|
414 | 414 | <th class="check-column" scope="row"> |
415 | - <label for="cb-select-' . $row->meta_value . '" class="screen-reader-text">' . $row->name . '</label> |
|
416 | - <input type="checkbox" data-identifier="' . $row->meta_value . '" value="' . $row->post_id . '" name="post[]" id="cb-select-' . $row->meta_value . '"> |
|
415 | + <label for="cb-select-' . $row->meta_value.'" class="screen-reader-text">'.$row->name.'</label> |
|
416 | + <input type="checkbox" data-identifier="' . $row->meta_value.'" value="'.$row->post_id.'" name="post[]" id="cb-select-'.$row->meta_value.'"> |
|
417 | 417 | </th> |
418 | 418 | <td class="post-title page-title column-title"> |
419 | - <strong>' . $row->name . '</strong> - ' . $status . ' |
|
419 | + <strong>' . $row->name.'</strong> - '.$status.' |
|
420 | 420 | </td> |
421 | 421 | <td class="date column-date"> |
422 | - <abbr title="' . date('Y/m/d', strtotime($row->last_modified)) . '">' . date('Y/m/d', strtotime($row->last_modified)) . '</abbr><br>Last Modified |
|
422 | + <abbr title="' . date('Y/m/d', strtotime($row->last_modified)).'">'.date('Y/m/d', strtotime($row->last_modified)).'</abbr><br>Last Modified |
|
423 | 423 | </td> |
424 | 424 | <td class="ssid column-ssid"> |
425 | - ' . $row->meta_value . ' |
|
425 | + ' . $row->meta_value.' |
|
426 | 426 | </td> |
427 | 427 | </tr>'; |
428 | 428 | return $row_html; |
@@ -440,13 +440,13 @@ discard block |
||
440 | 440 | $wetu_id = $_POST['wetu_id']; |
441 | 441 | if (isset($_POST['post_id'])) { |
442 | 442 | $post_id = $_POST['post_id']; |
443 | - } else { |
|
443 | + }else { |
|
444 | 444 | $post_id = 0; |
445 | 445 | } |
446 | 446 | |
447 | 447 | if (isset($_POST['team_members'])) { |
448 | 448 | $team_members = $_POST['team_members']; |
449 | - } else { |
|
449 | + }else { |
|
450 | 450 | $team_members = false; |
451 | 451 | } |
452 | 452 | |
@@ -456,11 +456,11 @@ discard block |
||
456 | 456 | if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
457 | 457 | $content = $_POST['content']; |
458 | 458 | add_option('wetu_importer_destination_settings', $content); |
459 | - } else { |
|
459 | + }else { |
|
460 | 460 | $content = false; |
461 | 461 | } |
462 | 462 | |
463 | - $jdata = file_get_contents($this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id); |
|
463 | + $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id); |
|
464 | 464 | if ($jdata) { |
465 | 465 | $adata = json_decode($jdata, true); |
466 | 466 | |
@@ -468,11 +468,11 @@ discard block |
||
468 | 468 | $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
469 | 469 | $this->remove_from_queue($return); |
470 | 470 | $this->format_completed_row($return); |
471 | - }else{ |
|
472 | - if(isset($adata['error'])){ |
|
471 | + }else { |
|
472 | + if (isset($adata['error'])) { |
|
473 | 473 | $this->format_error($adata['error']); |
474 | - }else{ |
|
475 | - $this->format_error(esc_html__('There was a problem importing your destination, please try refreshing the page.','wetu-importer')); |
|
474 | + }else { |
|
475 | + $this->format_error(esc_html__('There was a problem importing your destination, please try refreshing the page.', 'wetu-importer')); |
|
476 | 476 | } |
477 | 477 | } |
478 | 478 | } |
@@ -485,11 +485,11 @@ discard block |
||
485 | 485 | public function remove_from_queue($id) { |
486 | 486 | if (!empty($this->queued_imports)) { |
487 | 487 | |
488 | - if(($key = array_search($id, $this->queued_imports)) !== false) { |
|
488 | + if (($key = array_search($id, $this->queued_imports)) !== false) { |
|
489 | 489 | unset($this->queued_imports[$key]); |
490 | 490 | |
491 | 491 | delete_option('wetu_importer_que'); |
492 | - update_option('wetu_importer_que',$this->queued_imports); |
|
492 | + update_option('wetu_importer_que', $this->queued_imports); |
|
493 | 493 | } |
494 | 494 | } |
495 | 495 | } |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | $id = wp_update_post($post); |
545 | 545 | $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
546 | 546 | update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date); |
547 | - } else { |
|
547 | + }else { |
|
548 | 548 | |
549 | 549 | //Set the name |
550 | 550 | if (isset($data[0]['name'])) { |
@@ -646,9 +646,9 @@ discard block |
||
646 | 646 | public function set_team_member($id, $team_members) |
647 | 647 | { |
648 | 648 | |
649 | - delete_post_meta($id, 'team_to_' . $this->tab_slug); |
|
649 | + delete_post_meta($id, 'team_to_'.$this->tab_slug); |
|
650 | 650 | foreach ($team_members as $team) { |
651 | - add_post_meta($id, 'team_to_' . $this->tab_slug, $team); |
|
651 | + add_post_meta($id, 'team_to_'.$this->tab_slug, $team); |
|
652 | 652 | } |
653 | 653 | } |
654 | 654 |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | if('import' === $post_status) { |
358 | 358 | if(is_array($this->queued_imports) && in_array($row->post_id,$this->queued_imports)){ |
359 | 359 | $searched_items[sanitize_title($row->name) . '-' . $row->meta_value] = $this->format_row($row); |
360 | - }else{ |
|
360 | + } else{ |
|
361 | 361 | continue; |
362 | 362 | } |
363 | - }else if (false !== $post_status) { |
|
363 | + } else if (false !== $post_status) { |
|
364 | 364 | |
365 | 365 | $current_status = get_post_status($row->post_id); |
366 | 366 | if ($current_status !== $post_status) { |
@@ -468,10 +468,10 @@ discard block |
||
468 | 468 | $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
469 | 469 | $this->remove_from_queue($return); |
470 | 470 | $this->format_completed_row($return); |
471 | - }else{ |
|
471 | + } else{ |
|
472 | 472 | if(isset($adata['error'])){ |
473 | 473 | $this->format_error($adata['error']); |
474 | - }else{ |
|
474 | + } else{ |
|
475 | 475 | $this->format_error(esc_html__('There was a problem importing your destination, please try refreshing the page.','wetu-importer')); |
476 | 476 | } |
477 | 477 | } |
@@ -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 |
@@ -76,17 +76,17 @@ discard block |
||
76 | 76 | // $this->url = 'https://wetu.com/API/Pins/'; |
77 | 77 | // $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
78 | 78 | //} elseif ( false !== $this->api_key ) { |
79 | - $this->url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
79 | + $this->url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
80 | 80 | $this->url_qs = 'all=include'; |
81 | 81 | //} |
82 | 82 | |
83 | - $temp_options = get_option('_lsx-to_settings',false); |
|
84 | - if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){ |
|
83 | + $temp_options = get_option('_lsx-to_settings', false); |
|
84 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
85 | 85 | $this->options = $temp_options[$this->plugin_slug]; |
86 | 86 | } |
87 | 87 | |
88 | - $accommodation_options = get_option('wetu_importer_accommodation_settings',false); |
|
89 | - if(false !== $accommodation_options){ |
|
88 | + $accommodation_options = get_option('wetu_importer_accommodation_settings', false); |
|
89 | + if (false !== $accommodation_options) { |
|
90 | 90 | $this->accommodation_options = $accommodation_options; |
91 | 91 | } |
92 | 92 | } |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | <form method="get" action="" id="posts-filter"> |
107 | 107 | <input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" /> |
108 | 108 | |
109 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
110 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
109 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
110 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
111 | 111 | </p> |
112 | 112 | |
113 | 113 | <table class="wp-list-table widefat fixed posts"> |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | <tbody id="the-list"> |
117 | 117 | <tr class="post-0 type-tour status-none" id="post-0"> |
118 | 118 | <th class="check-column" scope="row"> |
119 | - <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label> |
|
119 | + <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label> |
|
120 | 120 | </th> |
121 | 121 | <td class="post-title page-title column-title"> |
122 | 122 | <strong> |
123 | - <?php _e('Enter a title to search for','wetu-importer'); ?> |
|
123 | + <?php _e('Enter a title to search for', 'wetu-importer'); ?> |
|
124 | 124 | </strong> |
125 | 125 | </td> |
126 | 126 | <td class="date column-date"> |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | |
135 | 135 | </table> |
136 | 136 | |
137 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
138 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
137 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
138 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
139 | 139 | </p> |
140 | 140 | </form> |
141 | 141 | |
@@ -147,32 +147,32 @@ discard block |
||
147 | 147 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
148 | 148 | <h3><?php _e('What content to Sync from WETU'); ?></h3> |
149 | 149 | <ul> |
150 | - <li><input class="content select-all" <?php $this->checked($this->accommodation_options,'all'); ?> type="checkbox"name="content[]" value="all" /> <?php _e('Select All','wetu-importer'); ?></li> |
|
151 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
152 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li> |
|
153 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery','wetu-importer'); ?></li> |
|
154 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li> |
|
155 | - <?php if(class_exists('LSX_TO_Maps')){ ?> |
|
156 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php _e('Location','wetu-importer'); ?></li> |
|
150 | + <li><input class="content select-all" <?php $this->checked($this->accommodation_options, 'all'); ?> type="checkbox"name="content[]" value="all" /> <?php _e('Select All', 'wetu-importer'); ?></li> |
|
151 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
152 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li> |
|
153 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery', 'wetu-importer'); ?></li> |
|
154 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li> |
|
155 | + <?php if (class_exists('LSX_TO_Maps')) { ?> |
|
156 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php _e('Location', 'wetu-importer'); ?></li> |
|
157 | 157 | <?php } ?> |
158 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php _e('Connect Destinations','wetu-importer'); ?></li> |
|
159 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php _e('Check In / Check Out','wetu-importer'); ?></li> |
|
160 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php _e('Facilities','wetu-importer'); ?></li> |
|
161 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php _e('Friendly','wetu-importer'); ?></li> |
|
162 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php _e('Rating','wetu-importer'); ?></li> |
|
163 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php _e('Rooms','wetu-importer'); ?></li> |
|
164 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php _e('Special Interests','wetu-importer'); ?></li> |
|
165 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php _e('Spoken Languages','wetu-importer'); ?></li> |
|
166 | - |
|
167 | - <?php if(class_exists('LSX_TO_Videos')){ ?> |
|
168 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos','wetu-importer'); ?></li> |
|
158 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php _e('Connect Destinations', 'wetu-importer'); ?></li> |
|
159 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php _e('Check In / Check Out', 'wetu-importer'); ?></li> |
|
160 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php _e('Facilities', 'wetu-importer'); ?></li> |
|
161 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php _e('Friendly', 'wetu-importer'); ?></li> |
|
162 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php _e('Rating', 'wetu-importer'); ?></li> |
|
163 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php _e('Rooms', 'wetu-importer'); ?></li> |
|
164 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php _e('Special Interests', 'wetu-importer'); ?></li> |
|
165 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php _e('Spoken Languages', 'wetu-importer'); ?></li> |
|
166 | + |
|
167 | + <?php if (class_exists('LSX_TO_Videos')) { ?> |
|
168 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos', 'wetu-importer'); ?></li> |
|
169 | 169 | <?php } ?> |
170 | 170 | </ul> |
171 | 171 | <h4><?php _e('Additional Content'); ?></h4> |
172 | 172 | <ul> |
173 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image','wetu-importer'); ?></li> |
|
174 | - <?php if(class_exists('LSX_Banners')){ ?> |
|
175 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image','wetu-importer'); ?></li> |
|
173 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image', 'wetu-importer'); ?></li> |
|
174 | + <?php if (class_exists('LSX_Banners')) { ?> |
|
175 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image', 'wetu-importer'); ?></li> |
|
176 | 176 | <?php } ?> |
177 | 177 | </ul> |
178 | 178 | </div> |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | <div style="width:30%;display:block;float:left;"> |
185 | 185 | <h3><?php _e('Assign a Safari Brand'); ?></h3> |
186 | - <?php echo $this->taxonomy_checkboxes('accommodation-brand',$this->accommodation_options); ?> |
|
186 | + <?php echo $this->taxonomy_checkboxes('accommodation-brand', $this->accommodation_options); ?> |
|
187 | 187 | </div> |
188 | 188 | |
189 | 189 | <br clear="both" /> |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | |
193 | 193 | <h3><?php _e('Your List'); ?></h3> |
194 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
194 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
195 | 195 | <table class="wp-list-table widefat fixed posts"> |
196 | 196 | <?php $this->table_header(); ?> |
197 | 197 | |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | |
204 | 204 | </table> |
205 | 205 | |
206 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
206 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
207 | 207 | </form> |
208 | 208 | </div> |
209 | 209 | |
210 | 210 | <div style="display:none;" class="completed-list-wrapper"> |
211 | - <h3><?php _e('Completed'); ?> - <small><?php _e('Import your','wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations'); ?></a> <?php _e('next','wetu-importer'); ?></small></h3> |
|
211 | + <h3><?php _e('Completed'); ?> - <small><?php _e('Import your', 'wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations'); ?></a> <?php _e('next', 'wetu-importer'); ?></small></h3> |
|
212 | 212 | <ul> |
213 | 213 | </ul> |
214 | 214 | </div> |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | * search_form |
221 | 221 | */ |
222 | 222 | public function update_options_form() { |
223 | - echo '<div style="display:none;" class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').'</h3>'; |
|
223 | + echo '<div style="display:none;" class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').'</h3>'; |
|
224 | 224 | $accommodation = get_transient('lsx_ti_accommodation'); |
225 | - if('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])){ |
|
225 | + if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) { |
|
226 | 226 | $this->update_options(); |
227 | 227 | } |
228 | 228 | echo '</div>'; |
@@ -232,13 +232,13 @@ discard block |
||
232 | 232 | * Save the list of Accommodation into an option |
233 | 233 | */ |
234 | 234 | public function update_options() { |
235 | - $data = file_get_contents( $this->url . '/List?' . $this->url_qs ); |
|
235 | + $data = file_get_contents($this->url.'/List?'.$this->url_qs); |
|
236 | 236 | $accommodation = json_decode($data, true); |
237 | 237 | |
238 | - if(isset($accommodation['error'])){ |
|
238 | + if (isset($accommodation['error'])) { |
|
239 | 239 | return $accommodation['error']; |
240 | 240 | }elseif (isset($accommodation) && !empty($accommodation)) { |
241 | - set_transient('lsx_ti_accommodation',$accommodation,60*60*2); |
|
241 | + set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2); |
|
242 | 242 | return true; |
243 | 243 | } |
244 | 244 | } |
@@ -249,41 +249,41 @@ discard block |
||
249 | 249 | public function process_ajax_search() { |
250 | 250 | $return = false; |
251 | 251 | |
252 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation'){ |
|
252 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation') { |
|
253 | 253 | $accommodation = get_transient('lsx_ti_accommodation'); |
254 | 254 | |
255 | - if(false === $accommodation){ |
|
255 | + if (false === $accommodation) { |
|
256 | 256 | $this->update_options(); |
257 | 257 | } |
258 | 258 | |
259 | - if ( false !== $accommodation ) { |
|
259 | + if (false !== $accommodation) { |
|
260 | 260 | $searched_items = false; |
261 | 261 | |
262 | - if(isset($_POST['keyword'] )) { |
|
262 | + if (isset($_POST['keyword'])) { |
|
263 | 263 | $keyphrases = $_POST['keyword']; |
264 | - }else{ |
|
264 | + }else { |
|
265 | 265 | $keyphrases = array(0); |
266 | 266 | } |
267 | 267 | |
268 | - if(!is_array($keyphrases)){ |
|
268 | + if (!is_array($keyphrases)) { |
|
269 | 269 | $keyphrases = array($keyphrases); |
270 | 270 | } |
271 | - foreach($keyphrases as &$keyword){ |
|
271 | + foreach ($keyphrases as &$keyword) { |
|
272 | 272 | $keyword = ltrim(rtrim($keyword)); |
273 | 273 | } |
274 | 274 | |
275 | 275 | |
276 | 276 | $post_status = false; |
277 | - if(in_array('publish',$keyphrases)){ |
|
277 | + if (in_array('publish', $keyphrases)) { |
|
278 | 278 | $post_status = 'publish'; |
279 | 279 | } |
280 | - if(in_array('pending',$keyphrases)){ |
|
280 | + if (in_array('pending', $keyphrases)) { |
|
281 | 281 | $post_status = 'pending'; |
282 | 282 | } |
283 | - if(in_array('draft',$keyphrases)){ |
|
283 | + if (in_array('draft', $keyphrases)) { |
|
284 | 284 | $post_status = 'draft'; |
285 | 285 | } |
286 | - if(in_array('import',$keyphrases)){ |
|
286 | + if (in_array('import', $keyphrases)) { |
|
287 | 287 | $post_status = 'import'; |
288 | 288 | } |
289 | 289 | |
@@ -291,32 +291,32 @@ discard block |
||
291 | 291 | |
292 | 292 | $current_accommodation = $this->find_current_accommodation(); |
293 | 293 | |
294 | - foreach($accommodation as $row_key => $row){ |
|
294 | + foreach ($accommodation as $row_key => $row) { |
|
295 | 295 | |
296 | 296 | //If this is a current tour, add its ID to the row. |
297 | 297 | $row['post_id'] = 0; |
298 | - if(false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)){ |
|
298 | + if (false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)) { |
|
299 | 299 | $row['post_id'] = $current_accommodation[$row['id']]->post_id; |
300 | 300 | } |
301 | 301 | |
302 | 302 | //If we are searching for |
303 | - if(false !== $post_status){ |
|
303 | + if (false !== $post_status) { |
|
304 | 304 | |
305 | - if('import' === $post_status){ |
|
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{ |
|
309 | + }else { |
|
310 | 310 | continue; |
311 | 311 | } |
312 | 312 | |
313 | - }else{ |
|
313 | + }else { |
|
314 | 314 | |
315 | - if(0 === $row['post_id']){ |
|
315 | + if (0 === $row['post_id']) { |
|
316 | 316 | continue; |
317 | - }else{ |
|
317 | + }else { |
|
318 | 318 | $current_status = get_post_status($row['post_id']); |
319 | - if($current_status !== $post_status){ |
|
319 | + if ($current_status !== $post_status) { |
|
320 | 320 | continue; |
321 | 321 | } |
322 | 322 | |
@@ -324,17 +324,17 @@ discard block |
||
324 | 324 | $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
325 | 325 | } |
326 | 326 | |
327 | - }else{ |
|
327 | + }else { |
|
328 | 328 | //Search through each keyword. |
329 | - foreach($keyphrases as $keyphrase){ |
|
329 | + foreach ($keyphrases as $keyphrase) { |
|
330 | 330 | |
331 | 331 | //Make sure the keyphrase is turned into an array |
332 | - $keywords = explode(" ",$keyphrase); |
|
333 | - if(!is_array($keywords)){ |
|
332 | + $keywords = explode(" ", $keyphrase); |
|
333 | + if (!is_array($keywords)) { |
|
334 | 334 | $keywords = array($keywords); |
335 | 335 | } |
336 | 336 | |
337 | - if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){ |
|
337 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
338 | 338 | $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
339 | 339 | } |
340 | 340 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | } |
344 | 344 | |
345 | 345 | |
346 | - if(false !== $searched_items){ |
|
346 | + if (false !== $searched_items) { |
|
347 | 347 | ksort($searched_items); |
348 | 348 | $return = implode($searched_items); |
349 | 349 | } |
@@ -355,11 +355,11 @@ discard block |
||
355 | 355 | /** |
356 | 356 | * Formats the row for output on the screen. |
357 | 357 | */ |
358 | - public function format_row($row = false){ |
|
359 | - if(false !== $row){ |
|
358 | + public function format_row($row = false) { |
|
359 | + if (false !== $row) { |
|
360 | 360 | |
361 | 361 | $status = 'import'; |
362 | - if(0 !== $row['post_id']){ |
|
362 | + if (0 !== $row['post_id']) { |
|
363 | 363 | $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
364 | 364 | } |
365 | 365 | |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | <strong>'.$row['name'].'</strong> - '.$status.' |
374 | 374 | </td> |
375 | 375 | <td class="date column-date"> |
376 | - <abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
376 | + <abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
377 | 377 | </td> |
378 | 378 | <td class="ssid column-ssid"> |
379 | 379 | '.$row['id'].' |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | public function remove_from_queue($id) { |
390 | 390 | if (!empty($this->queued_imports)) { |
391 | 391 | |
392 | - if(($key = array_search($id, $this->queued_imports)) !== false) { |
|
392 | + if (($key = array_search($id, $this->queued_imports)) !== false) { |
|
393 | 393 | unset($this->queued_imports[$key]); |
394 | 394 | |
395 | 395 | delete_option('wetu_importer_que'); |
396 | - update_option('wetu_importer_que',$this->queued_imports); |
|
396 | + update_option('wetu_importer_que', $this->queued_imports); |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | } |
@@ -404,50 +404,50 @@ discard block |
||
404 | 404 | public function process_ajax_import() { |
405 | 405 | $return = false; |
406 | 406 | |
407 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])){ |
|
407 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])) { |
|
408 | 408 | |
409 | 409 | $wetu_id = $_POST['wetu_id']; |
410 | - if(isset($_POST['post_id'])){ |
|
410 | + if (isset($_POST['post_id'])) { |
|
411 | 411 | $post_id = $_POST['post_id']; |
412 | - }else{ |
|
412 | + }else { |
|
413 | 413 | $post_id = 0; |
414 | 414 | } |
415 | 415 | |
416 | - if(isset($_POST['team_members'])){ |
|
416 | + if (isset($_POST['team_members'])) { |
|
417 | 417 | $team_members = $_POST['team_members']; |
418 | - }else{ |
|
418 | + }else { |
|
419 | 419 | $team_members = false; |
420 | 420 | } |
421 | 421 | |
422 | - if(isset($_POST['safari_brands'])){ |
|
422 | + if (isset($_POST['safari_brands'])) { |
|
423 | 423 | $safari_brands = $_POST['safari_brands']; |
424 | - }else{ |
|
424 | + }else { |
|
425 | 425 | $safari_brands = false; |
426 | 426 | } |
427 | 427 | |
428 | 428 | delete_option('wetu_importer_accommodation_settings'); |
429 | - if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
|
429 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
430 | 430 | $content = $_POST['content']; |
431 | - add_option('wetu_importer_accommodation_settings',$content); |
|
432 | - }else{ |
|
431 | + add_option('wetu_importer_accommodation_settings', $content); |
|
432 | + }else { |
|
433 | 433 | |
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) |
|
437 | + $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id); |
|
438 | + if ($jdata) |
|
439 | 439 | { |
440 | - $adata=json_decode($jdata,true); |
|
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); |
|
442 | + $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
|
443 | 443 | $this->format_completed_row($return); |
444 | 444 | $this->remove_from_queue($return); |
445 | 445 | $this->cleanup_posts(); |
446 | - }else{ |
|
447 | - if(isset($adata['error'])){ |
|
446 | + }else { |
|
447 | + if (isset($adata['error'])) { |
|
448 | 448 | $this->format_error($adata['error']); |
449 | - }else{ |
|
450 | - $this->format_error(esc_html__('There was a problem importing your accommodation, please try refreshing the page.','wetu-importer')); |
|
449 | + }else { |
|
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 | } |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | /** |
458 | 458 | * Connect to wetu |
459 | 459 | */ |
460 | - public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) { |
|
460 | + public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false) { |
|
461 | 461 | |
462 | 462 | $post_name = $data_post_content = $data_post_excerpt = ''; |
463 | 463 | $post = array( |
@@ -467,44 +467,44 @@ discard block |
||
467 | 467 | $content_used_general_description = false; |
468 | 468 | |
469 | 469 | //Set the post_content |
470 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
471 | - if(isset($data[0]['content']['extended_description'])) |
|
470 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
471 | + if (isset($data[0]['content']['extended_description'])) |
|
472 | 472 | { |
473 | 473 | $data_post_content = $data[0]['content']['extended_description']; |
474 | - }elseif(isset($data[0]['content']['general_description'])){ |
|
474 | + }elseif (isset($data[0]['content']['general_description'])) { |
|
475 | 475 | $data_post_content = $data[0]['content']['general_description']; |
476 | 476 | $content_used_general_description = true; |
477 | - }elseif(isset($data[0]['content']['teaser_description'])){ |
|
477 | + }elseif (isset($data[0]['content']['teaser_description'])) { |
|
478 | 478 | $data_post_content = $data[0]['content']['teaser_description']; |
479 | 479 | } |
480 | 480 | $post['post_content'] = wp_strip_all_tags($data_post_content); |
481 | 481 | } |
482 | 482 | |
483 | 483 | //set the post_excerpt |
484 | - if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
485 | - if(isset($data[0]['content']['teaser_description'])){ |
|
484 | + if (false !== $importable_content && in_array('excerpt', $importable_content)) { |
|
485 | + if (isset($data[0]['content']['teaser_description'])) { |
|
486 | 486 | $data_post_excerpt = $data[0]['content']['teaser_description']; |
487 | - }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
487 | + }elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) { |
|
488 | 488 | $data_post_excerpt = $data[0]['content']['general_description']; |
489 | 489 | } |
490 | 490 | $post['post_excerpt'] = $data_post_excerpt; |
491 | 491 | } |
492 | 492 | |
493 | - if(false !== $id && '0' !== $id){ |
|
493 | + if (false !== $id && '0' !== $id) { |
|
494 | 494 | $post['ID'] = $id; |
495 | - if(isset($data[0]['name'])){ |
|
495 | + if (isset($data[0]['name'])) { |
|
496 | 496 | $post['post_title'] = $data[0]['name']; |
497 | 497 | $post['post_status'] = 'publish'; |
498 | - $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
498 | + $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0); |
|
499 | 499 | } |
500 | 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{ |
|
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 | 504 | |
505 | 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); |
|
506 | + if (isset($data[0]['name'])) { |
|
507 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0); |
|
508 | 508 | } |
509 | 509 | $post['post_name'] = $post_name; |
510 | 510 | $post['post_title'] = $data[0]['name']; |
@@ -512,89 +512,89 @@ discard block |
||
512 | 512 | $id = wp_insert_post($post); |
513 | 513 | |
514 | 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'])); |
|
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 | 518 | } |
519 | 519 | } |
520 | 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))){ |
|
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 | 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); |
|
526 | + if (post_type_exists('team') && false !== $team_members && '' !== $team_members) { |
|
527 | + $this->set_team_member($id, $team_members); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | //Set the safari brand |
531 | - if(false !== $safari_brands && '' !== $safari_brands){ |
|
532 | - $this->set_safari_brands($id,$safari_brands); |
|
531 | + if (false !== $safari_brands && '' !== $safari_brands) { |
|
532 | + $this->set_safari_brands($id, $safari_brands); |
|
533 | 533 | |
534 | 534 | } |
535 | 535 | |
536 | - if(class_exists('LSX_TO_Maps')){ |
|
537 | - $this->set_map_data($data,$id,9); |
|
536 | + if (class_exists('LSX_TO_Maps')) { |
|
537 | + $this->set_map_data($data, $id, 9); |
|
538 | 538 | } |
539 | 539 | |
540 | - if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){ |
|
541 | - $this->connect_destinations($data,$id); |
|
540 | + if (post_type_exists('destination') && false !== $importable_content && in_array('destination', $importable_content)) { |
|
541 | + $this->connect_destinations($data, $id); |
|
542 | 542 | } |
543 | 543 | |
544 | - if(false !== $importable_content && in_array('category',$importable_content)){ |
|
545 | - $this->set_taxonomy_style($data,$id); |
|
544 | + if (false !== $importable_content && in_array('category', $importable_content)) { |
|
545 | + $this->set_taxonomy_style($data, $id); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | //Set the Room Data |
549 | - if(false !== $importable_content && in_array('rooms',$importable_content)){ |
|
550 | - $this->set_room_data($data,$id); |
|
549 | + if (false !== $importable_content && in_array('rooms', $importable_content)) { |
|
550 | + $this->set_room_data($data, $id); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | //Set the rating |
554 | - if(false !== $importable_content && in_array('rating',$importable_content)){ |
|
555 | - $this->set_rating($data,$id); |
|
554 | + if (false !== $importable_content && in_array('rating', $importable_content)) { |
|
555 | + $this->set_rating($data, $id); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | //Set the checkin checkout data |
559 | - if(false !== $importable_content && in_array('checkin',$importable_content)){ |
|
560 | - $this->set_checkin_checkout($data,$id); |
|
559 | + if (false !== $importable_content && in_array('checkin', $importable_content)) { |
|
560 | + $this->set_checkin_checkout($data, $id); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | //Set the Spoken Languages |
564 | - if(false !== $importable_content && in_array('spoken_languages',$importable_content)){ |
|
565 | - $this->set_spoken_languages($data,$id); |
|
564 | + if (false !== $importable_content && in_array('spoken_languages', $importable_content)) { |
|
565 | + $this->set_spoken_languages($data, $id); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | //Set the friendly options |
569 | - if(false !== $importable_content && in_array('friendly',$importable_content)){ |
|
570 | - $this->set_friendly($data,$id); |
|
569 | + if (false !== $importable_content && in_array('friendly', $importable_content)) { |
|
570 | + $this->set_friendly($data, $id); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | //Set the special_interests |
574 | - if(false !== $importable_content && in_array('special_interests',$importable_content)){ |
|
575 | - $this->set_special_interests($data,$id); |
|
574 | + if (false !== $importable_content && in_array('special_interests', $importable_content)) { |
|
575 | + $this->set_special_interests($data, $id); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | //Import the videos |
579 | - if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
580 | - $this->set_video_data($data,$id); |
|
579 | + if (false !== $importable_content && in_array('videos', $importable_content)) { |
|
580 | + $this->set_video_data($data, $id); |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | //Import the facilities |
584 | - if(false !== $importable_content && in_array('facilities',$importable_content)){ |
|
585 | - $this->set_facilities($data,$id); |
|
584 | + if (false !== $importable_content && in_array('facilities', $importable_content)) { |
|
585 | + $this->set_facilities($data, $id); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | //Set the featured image |
589 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
590 | - $this->set_featured_image($data,$id); |
|
589 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
590 | + $this->set_featured_image($data, $id); |
|
591 | 591 | } |
592 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
593 | - $this->set_banner_image($data,$id); |
|
592 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
593 | + $this->set_banner_image($data, $id); |
|
594 | 594 | } |
595 | 595 | //Import the main gallery |
596 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
597 | - $this->create_main_gallery($data,$id); |
|
596 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
597 | + $this->create_main_gallery($data, $id); |
|
598 | 598 | } |
599 | 599 | return $id; |
600 | 600 | } |
@@ -602,50 +602,50 @@ discard block |
||
602 | 602 | /** |
603 | 603 | * Set the team memberon each item. |
604 | 604 | */ |
605 | - public function set_team_member($id,$team_members) { |
|
605 | + public function set_team_member($id, $team_members) { |
|
606 | 606 | |
607 | 607 | delete_post_meta($id, 'team_to_'.$this->tab_slug); |
608 | - foreach($team_members as $team){ |
|
609 | - add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
608 | + foreach ($team_members as $team) { |
|
609 | + add_post_meta($id, 'team_to_'.$this->tab_slug, $team); |
|
610 | 610 | } |
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
614 | 614 | * Set the safari brand |
615 | 615 | */ |
616 | - public function set_safari_brands($id,$safari_brands) { |
|
617 | - foreach($safari_brands as $safari_brand){ |
|
618 | - wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true); |
|
616 | + public function set_safari_brands($id, $safari_brands) { |
|
617 | + foreach ($safari_brands as $safari_brand) { |
|
618 | + wp_set_object_terms($id, intval($safari_brand), 'accommodation-brand', true); |
|
619 | 619 | } |
620 | 620 | } |
621 | 621 | |
622 | 622 | /** |
623 | 623 | * Connects the destinations post type |
624 | 624 | */ |
625 | - public function connect_destinations($data,$id) { |
|
626 | - if(isset($data[0]['position'])){ |
|
625 | + public function connect_destinations($data, $id) { |
|
626 | + if (isset($data[0]['position'])) { |
|
627 | 627 | $destinations = false; |
628 | - if(isset($data[0]['position']['country'])){ |
|
628 | + if (isset($data[0]['position']['country'])) { |
|
629 | 629 | $destinations['country'] = $data[0]['position']['country']; |
630 | 630 | } |
631 | - if(isset($data[0]['position']['destination'])){ |
|
631 | + if (isset($data[0]['position']['destination'])) { |
|
632 | 632 | $destinations['destination'] = $data[0]['position']['destination']; |
633 | 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)){ |
|
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 | 638 | $prev_values = array(); |
639 | 639 | } |
640 | 640 | //print_r($destinations); |
641 | 641 | $destinations = array_unique($destinations); |
642 | 642 | //print_r($destinations); |
643 | - foreach($destinations as $key => $value){ |
|
643 | + foreach ($destinations as $key => $value) { |
|
644 | 644 | $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
645 | 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); |
|
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 | 650 | } |
651 | 651 | } |
@@ -657,18 +657,18 @@ discard block |
||
657 | 657 | /** |
658 | 658 | * Set the Travel Style |
659 | 659 | */ |
660 | - public function set_taxonomy_style($data,$id) { |
|
660 | + public function set_taxonomy_style($data, $id) { |
|
661 | 661 | $terms = false; |
662 | - if(isset($data[0]['category'])){ |
|
663 | - if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) |
|
662 | + if (isset($data[0]['category'])) { |
|
663 | + if (!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) |
|
664 | 664 | { |
665 | 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); } |
|
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 | 668 | } |
669 | 669 | else |
670 | 670 | { |
671 | - wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); |
|
671 | + wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true); |
|
672 | 672 | } |
673 | 673 | } |
674 | 674 | } |
@@ -676,23 +676,23 @@ discard block |
||
676 | 676 | /** |
677 | 677 | * Saves the room data |
678 | 678 | */ |
679 | - public function set_room_data($data,$id) { |
|
680 | - if(!empty($data[0]['rooms']) && is_array($data[0]['rooms'])){ |
|
679 | + public function set_room_data($data, $id) { |
|
680 | + if (!empty($data[0]['rooms']) && is_array($data[0]['rooms'])) { |
|
681 | 681 | $rooms = false; |
682 | 682 | |
683 | - foreach($data[0]['rooms'] as $room){ |
|
683 | + foreach ($data[0]['rooms'] as $room) { |
|
684 | 684 | |
685 | 685 | $temp_room = array(); |
686 | - if(isset($room['name'])){ |
|
686 | + if (isset($room['name'])) { |
|
687 | 687 | $temp_room['title'] = $room['name']; |
688 | 688 | } |
689 | - if(isset($room['description'])){ |
|
689 | + if (isset($room['description'])) { |
|
690 | 690 | $temp_room['description'] = strip_tags($room['description']); |
691 | 691 | } |
692 | 692 | $temp_room['price'] = 0; |
693 | 693 | $temp_room['type'] = 'room'; |
694 | 694 | |
695 | - if(!empty($room['images']) && is_array($room['images'])){ |
|
695 | + if (!empty($room['images']) && is_array($room['images'])) { |
|
696 | 696 | $attachments_args = array( |
697 | 697 | 'post_parent' => $id, |
698 | 698 | 'post_status' => 'inherit', |
@@ -702,38 +702,38 @@ discard block |
||
702 | 702 | $attachments = new WP_Query($attachments_args); |
703 | 703 | $found_attachments = array(); |
704 | 704 | |
705 | - if($attachments->have_posts()){ |
|
706 | - foreach($attachments->posts as $attachment){ |
|
707 | - $found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
705 | + if ($attachments->have_posts()) { |
|
706 | + foreach ($attachments->posts as $attachment) { |
|
707 | + $found_attachments[] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title); |
|
708 | 708 | } |
709 | 709 | } |
710 | 710 | |
711 | 711 | $temp_room['gallery'] = array(); |
712 | - foreach($room['images'] as $image_data){ |
|
713 | - $temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments); |
|
712 | + foreach ($room['images'] as $image_data) { |
|
713 | + $temp_room['gallery'][] = $this->attach_image($image_data, $id, $found_attachments); |
|
714 | 714 | } |
715 | 715 | } |
716 | 716 | $rooms[] = $temp_room; |
717 | 717 | } |
718 | 718 | |
719 | - if(false !== $id && '0' !== $id){ |
|
719 | + if (false !== $id && '0' !== $id) { |
|
720 | 720 | delete_post_meta($id, 'units'); |
721 | 721 | } |
722 | - foreach($rooms as $room){ |
|
723 | - add_post_meta($id,'units',$room,false); |
|
722 | + foreach ($rooms as $room) { |
|
723 | + add_post_meta($id, 'units', $room, false); |
|
724 | 724 | } |
725 | 725 | |
726 | - if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){ |
|
726 | + if (isset($data[0]['features']) && isset($data[0]['features']['rooms'])) { |
|
727 | 727 | $room_count = $data[0]['features']['rooms']; |
728 | - }else{ |
|
728 | + }else { |
|
729 | 729 | $room_count = count($data[0]['rooms']); |
730 | 730 | } |
731 | 731 | |
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); |
|
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 | 737 | } |
738 | 738 | } |
739 | 739 | } |
@@ -741,31 +741,31 @@ discard block |
||
741 | 741 | /** |
742 | 742 | * Set the ratings |
743 | 743 | */ |
744 | - public function set_rating($data,$id) { |
|
744 | + public function set_rating($data, $id) { |
|
745 | 745 | |
746 | - if(!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])){ |
|
746 | + if (!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])) { |
|
747 | 747 | $rating_type = $data[0]['features']['star_authority']; |
748 | - }else{ |
|
748 | + }else { |
|
749 | 749 | $rating_type = 'Unspecified2'; |
750 | 750 | } |
751 | - $this->save_custom_field($rating_type,'rating_type',$id); |
|
751 | + $this->save_custom_field($rating_type, 'rating_type', $id); |
|
752 | 752 | |
753 | - if(!empty($data[0]['features']) && isset($data[0]['features']['stars'])){ |
|
754 | - $this->save_custom_field($data[0]['features']['stars'],'rating',$id,true); |
|
753 | + if (!empty($data[0]['features']) && isset($data[0]['features']['stars'])) { |
|
754 | + $this->save_custom_field($data[0]['features']['stars'], 'rating', $id, true); |
|
755 | 755 | } |
756 | 756 | } |
757 | 757 | |
758 | 758 | /** |
759 | 759 | * Set the spoken_languages |
760 | 760 | */ |
761 | - public function set_spoken_languages($data,$id) { |
|
762 | - if(!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])){ |
|
761 | + public function set_spoken_languages($data, $id) { |
|
762 | + if (!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])) { |
|
763 | 763 | $languages = false; |
764 | - foreach($data[0]['features']['spoken_languages'] as $spoken_language){ |
|
764 | + foreach ($data[0]['features']['spoken_languages'] as $spoken_language) { |
|
765 | 765 | $languages[] = sanitize_title($spoken_language); |
766 | 766 | } |
767 | - if(false !== $languages){ |
|
768 | - $this->save_custom_field($languages,'spoken_languages',$id); |
|
767 | + if (false !== $languages) { |
|
768 | + $this->save_custom_field($languages, 'spoken_languages', $id); |
|
769 | 769 | } |
770 | 770 | } |
771 | 771 | } |
@@ -773,14 +773,14 @@ discard block |
||
773 | 773 | /** |
774 | 774 | * Set the friendly |
775 | 775 | */ |
776 | - public function set_friendly($data,$id) { |
|
777 | - if(!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])){ |
|
776 | + public function set_friendly($data, $id) { |
|
777 | + if (!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])) { |
|
778 | 778 | $friendly_options = false; |
779 | - foreach($data[0]['features']['suggested_visitor_types'] as $visitor_type){ |
|
779 | + foreach ($data[0]['features']['suggested_visitor_types'] as $visitor_type) { |
|
780 | 780 | $friendly_options[] = sanitize_title($visitor_type); |
781 | 781 | } |
782 | - if(false !== $friendly_options){ |
|
783 | - $this->save_custom_field($friendly_options,'suggested_visitor_types',$id); |
|
782 | + if (false !== $friendly_options) { |
|
783 | + $this->save_custom_field($friendly_options, 'suggested_visitor_types', $id); |
|
784 | 784 | } |
785 | 785 | } |
786 | 786 | } |
@@ -788,14 +788,14 @@ discard block |
||
788 | 788 | /** |
789 | 789 | * Set the special interests |
790 | 790 | */ |
791 | - public function set_special_interests($data,$id) { |
|
792 | - if(!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])){ |
|
791 | + public function set_special_interests($data, $id) { |
|
792 | + if (!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])) { |
|
793 | 793 | $interests = false; |
794 | - foreach($data[0]['features']['special_interests'] as $special_interest){ |
|
794 | + foreach ($data[0]['features']['special_interests'] as $special_interest) { |
|
795 | 795 | $interests[] = sanitize_title($special_interest); |
796 | 796 | } |
797 | - if(false !== $interests){ |
|
798 | - $this->save_custom_field($interests,'special_interests',$id); |
|
797 | + if (false !== $interests) { |
|
798 | + $this->save_custom_field($interests, 'special_interests', $id); |
|
799 | 799 | } |
800 | 800 | } |
801 | 801 | } |
@@ -803,24 +803,24 @@ discard block |
||
803 | 803 | /** |
804 | 804 | * Set the Check in and Check out Date |
805 | 805 | */ |
806 | - public function set_checkin_checkout($data,$id) { |
|
806 | + public function set_checkin_checkout($data, $id) { |
|
807 | 807 | |
808 | - if(!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])){ |
|
809 | - $time = str_replace('h',':',$data[0]['features']['check_in_time']); |
|
810 | - $time = date('h:ia',strtotime($time)); |
|
811 | - $this->save_custom_field($time,'checkin_time',$id); |
|
808 | + if (!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])) { |
|
809 | + $time = str_replace('h', ':', $data[0]['features']['check_in_time']); |
|
810 | + $time = date('h:ia', strtotime($time)); |
|
811 | + $this->save_custom_field($time, 'checkin_time', $id); |
|
812 | 812 | } |
813 | - if(!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])){ |
|
814 | - $time = str_replace('h',':',$data[0]['features']['check_out_time']); |
|
815 | - $time = date('h:ia',strtotime($time)); |
|
816 | - $this->save_custom_field($time,'checkout_time',$id); |
|
813 | + if (!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])) { |
|
814 | + $time = str_replace('h', ':', $data[0]['features']['check_out_time']); |
|
815 | + $time = date('h:ia', strtotime($time)); |
|
816 | + $this->save_custom_field($time, 'checkout_time', $id); |
|
817 | 817 | } |
818 | 818 | } |
819 | 819 | |
820 | 820 | /** |
821 | 821 | * Set the Facilities |
822 | 822 | */ |
823 | - public function set_facilities($data,$id) { |
|
823 | + public function set_facilities($data, $id) { |
|
824 | 824 | |
825 | 825 | $parent_facilities = array( |
826 | 826 | 'available_services' => 'Available Services', |
@@ -828,13 +828,13 @@ discard block |
||
828 | 828 | 'room_facilities' => 'Room Facilities', |
829 | 829 | 'activities_on_site' => 'Activities on Site' |
830 | 830 | ); |
831 | - foreach($parent_facilities as $key => $label){ |
|
831 | + foreach ($parent_facilities as $key => $label) { |
|
832 | 832 | $terms = false; |
833 | - if(isset($data[0]['features']) && isset($data[0]['features'][$key])){ |
|
834 | - $parent_id = $this->set_term($id,$label,'facility'); |
|
833 | + if (isset($data[0]['features']) && isset($data[0]['features'][$key])) { |
|
834 | + $parent_id = $this->set_term($id, $label, 'facility'); |
|
835 | 835 | } |
836 | - foreach($data[0]['features'][$key] as $child_facility){ |
|
837 | - $this->set_term($id,$child_facility,'facility',$parent_id); |
|
836 | + foreach ($data[0]['features'][$key] as $child_facility) { |
|
837 | + $this->set_term($id, $child_facility, 'facility', $parent_id); |
|
838 | 838 | } |
839 | 839 | } |
840 | 840 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | |
238 | 238 | if(isset($accommodation['error'])){ |
239 | 239 | return $accommodation['error']; |
240 | - }elseif (isset($accommodation) && !empty($accommodation)) { |
|
240 | + } elseif (isset($accommodation) && !empty($accommodation)) { |
|
241 | 241 | set_transient('lsx_ti_accommodation',$accommodation,60*60*2); |
242 | 242 | return true; |
243 | 243 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | if(isset($_POST['keyword'] )) { |
263 | 263 | $keyphrases = $_POST['keyword']; |
264 | - }else{ |
|
264 | + } else{ |
|
265 | 265 | $keyphrases = array(0); |
266 | 266 | } |
267 | 267 | |
@@ -306,15 +306,15 @@ discard block |
||
306 | 306 | |
307 | 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{ |
|
309 | + } else{ |
|
310 | 310 | continue; |
311 | 311 | } |
312 | 312 | |
313 | - }else{ |
|
313 | + } else{ |
|
314 | 314 | |
315 | 315 | if(0 === $row['post_id']){ |
316 | 316 | continue; |
317 | - }else{ |
|
317 | + } else{ |
|
318 | 318 | $current_status = get_post_status($row['post_id']); |
319 | 319 | if($current_status !== $post_status){ |
320 | 320 | continue; |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
325 | 325 | } |
326 | 326 | |
327 | - }else{ |
|
327 | + } else{ |
|
328 | 328 | //Search through each keyword. |
329 | 329 | foreach($keyphrases as $keyphrase){ |
330 | 330 | |
@@ -409,19 +409,19 @@ discard block |
||
409 | 409 | $wetu_id = $_POST['wetu_id']; |
410 | 410 | if(isset($_POST['post_id'])){ |
411 | 411 | $post_id = $_POST['post_id']; |
412 | - }else{ |
|
412 | + } else{ |
|
413 | 413 | $post_id = 0; |
414 | 414 | } |
415 | 415 | |
416 | 416 | if(isset($_POST['team_members'])){ |
417 | 417 | $team_members = $_POST['team_members']; |
418 | - }else{ |
|
418 | + } else{ |
|
419 | 419 | $team_members = false; |
420 | 420 | } |
421 | 421 | |
422 | 422 | if(isset($_POST['safari_brands'])){ |
423 | 423 | $safari_brands = $_POST['safari_brands']; |
424 | - }else{ |
|
424 | + } else{ |
|
425 | 425 | $safari_brands = false; |
426 | 426 | } |
427 | 427 | |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
430 | 430 | $content = $_POST['content']; |
431 | 431 | add_option('wetu_importer_accommodation_settings',$content); |
432 | - }else{ |
|
432 | + } else{ |
|
433 | 433 | |
434 | 434 | $content = false; |
435 | 435 | } |
@@ -443,10 +443,10 @@ discard block |
||
443 | 443 | $this->format_completed_row($return); |
444 | 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 | - }else{ |
|
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 | } |
@@ -471,10 +471,10 @@ discard block |
||
471 | 471 | if(isset($data[0]['content']['extended_description'])) |
472 | 472 | { |
473 | 473 | $data_post_content = $data[0]['content']['extended_description']; |
474 | - }elseif(isset($data[0]['content']['general_description'])){ |
|
474 | + } elseif(isset($data[0]['content']['general_description'])){ |
|
475 | 475 | $data_post_content = $data[0]['content']['general_description']; |
476 | 476 | $content_used_general_description = true; |
477 | - }elseif(isset($data[0]['content']['teaser_description'])){ |
|
477 | + } elseif(isset($data[0]['content']['teaser_description'])){ |
|
478 | 478 | $data_post_content = $data[0]['content']['teaser_description']; |
479 | 479 | } |
480 | 480 | $post['post_content'] = wp_strip_all_tags($data_post_content); |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
485 | 485 | if(isset($data[0]['content']['teaser_description'])){ |
486 | 486 | $data_post_excerpt = $data[0]['content']['teaser_description']; |
487 | - }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
487 | + } elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
488 | 488 | $data_post_excerpt = $data[0]['content']['general_description']; |
489 | 489 | } |
490 | 490 | $post['post_excerpt'] = $data_post_excerpt; |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | $id = wp_update_post($post); |
501 | 501 | $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
502 | 502 | update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
503 | - }else{ |
|
503 | + } else{ |
|
504 | 504 | |
505 | 505 | //Set the name |
506 | 506 | if(isset($data[0]['name'])){ |
@@ -663,10 +663,8 @@ discard block |
||
663 | 663 | if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) |
664 | 664 | { |
665 | 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 |
|
666 | + if ( is_wp_error($term) ){echo $term->get_error_message();} else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); } |
|
667 | + } else |
|
670 | 668 | { |
671 | 669 | wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); |
672 | 670 | } |
@@ -725,14 +723,14 @@ discard block |
||
725 | 723 | |
726 | 724 | if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){ |
727 | 725 | $room_count = $data[0]['features']['rooms']; |
728 | - }else{ |
|
726 | + } else{ |
|
729 | 727 | $room_count = count($data[0]['rooms']); |
730 | 728 | } |
731 | 729 | |
732 | 730 | if(false !== $id && '0' !== $id){ |
733 | 731 | $prev_rooms = get_post_meta($id,'number_of_rooms',true); |
734 | 732 | update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms); |
735 | - }else{ |
|
733 | + } else{ |
|
736 | 734 | add_post_meta($id,'number_of_rooms',$room_count,true); |
737 | 735 | } |
738 | 736 | } |
@@ -745,7 +743,7 @@ discard block |
||
745 | 743 | |
746 | 744 | if(!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])){ |
747 | 745 | $rating_type = $data[0]['features']['star_authority']; |
748 | - }else{ |
|
746 | + } else{ |
|
749 | 747 | $rating_type = 'Unspecified2'; |
750 | 748 | } |
751 | 749 | $this->save_custom_field($rating_type,'rating_type',$id); |
@@ -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 | /** |
@@ -99,21 +99,21 @@ discard block |
||
99 | 99 | { |
100 | 100 | parent::set_variables(); |
101 | 101 | |
102 | - if ( false !== $this->api_username && false !== $this->api_password ) { |
|
102 | + if (false !== $this->api_username && false !== $this->api_password) { |
|
103 | 103 | $this->url = 'https://wetu.com/API/Itinerary/'; |
104 | - $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
|
105 | - } elseif ( false !== $this->api_key ) { |
|
106 | - $this->url = 'https://wetu.com/API/Itinerary/' . $this->api_key; |
|
104 | + $this->url_qs = 'username='.$this->api_username.'&password='.$this->api_password; |
|
105 | + } elseif (false !== $this->api_key) { |
|
106 | + $this->url = 'https://wetu.com/API/Itinerary/'.$this->api_key; |
|
107 | 107 | $this->url_qs = ''; |
108 | 108 | } |
109 | 109 | |
110 | - $temp_options = get_option('_lsx-to_settings',false); |
|
111 | - if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){ |
|
110 | + $temp_options = get_option('_lsx-to_settings', false); |
|
111 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
112 | 112 | $this->options = $temp_options[$this->plugin_slug]; |
113 | 113 | } |
114 | 114 | |
115 | - $tour_options = get_option('wetu_importer_tour_settings',false); |
|
116 | - if(false !== $tour_options){ |
|
115 | + $tour_options = get_option('wetu_importer_tour_settings', false); |
|
116 | + if (false !== $tour_options) { |
|
117 | 117 | $this->tour_options = $tour_options; |
118 | 118 | } |
119 | 119 | } |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | <form method="get" action="" id="posts-filter"> |
134 | 134 | <input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" /> |
135 | 135 | |
136 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
137 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
136 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
137 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
138 | 138 | </p> |
139 | 139 | |
140 | 140 | <table class="wp-list-table widefat fixed posts"> |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | <tbody id="the-list"> |
144 | 144 | <tr class="post-0 type-tour status-none" id="post-0"> |
145 | 145 | <th class="check-column" scope="row"> |
146 | - <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label> |
|
146 | + <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label> |
|
147 | 147 | </th> |
148 | 148 | <td class="post-title page-title column-title"> |
149 | 149 | <strong> |
150 | - <?php _e('Enter a title to search for','wetu-importer'); ?> |
|
150 | + <?php _e('Enter a title to search for', 'wetu-importer'); ?> |
|
151 | 151 | </strong> |
152 | 152 | </td> |
153 | 153 | <td class="date column-date"> |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | |
162 | 162 | </table> |
163 | 163 | |
164 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
165 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
164 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
165 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
166 | 166 | </p> |
167 | 167 | </form> |
168 | 168 | |
@@ -174,16 +174,16 @@ discard block |
||
174 | 174 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
175 | 175 | <h3><?php _e('What content to Sync from WETU'); ?></h3> |
176 | 176 | <ul> |
177 | - <li><input class="content select-all" <?php $this->checked($this->tour_options,'all'); ?> type="checkbox"name="content[]" value="all" /> <?php _e('Select All','wetu-importer'); ?></li> |
|
178 | - <li><input class="content" <?php $this->checked($this->tour_options,'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
179 | - <li><input class="content" <?php $this->checked($this->tour_options,'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li> |
|
177 | + <li><input class="content select-all" <?php $this->checked($this->tour_options, 'all'); ?> type="checkbox"name="content[]" value="all" /> <?php _e('Select All', 'wetu-importer'); ?></li> |
|
178 | + <li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
179 | + <li><input class="content" <?php $this->checked($this->tour_options, 'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li> |
|
180 | 180 | |
181 | - <li><input class="content" <?php $this->checked($this->tour_options,'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price','wetu-importer'); ?></li> |
|
182 | - <li><input class="content" <?php $this->checked($this->tour_options,'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration','wetu-importer'); ?></li> |
|
181 | + <li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price', 'wetu-importer'); ?></li> |
|
182 | + <li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration', 'wetu-importer'); ?></li> |
|
183 | 183 | |
184 | - <li><input class="content" <?php $this->checked($this->tour_options,'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li> |
|
184 | + <li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li> |
|
185 | 185 | |
186 | - <li><input class="content" <?php $this->checked($this->tour_options,'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days','wetu-importer'); ?></li> |
|
186 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days', 'wetu-importer'); ?></li> |
|
187 | 187 | |
188 | 188 | <?php /*if(class_exists('LSX_TO_Maps')){ ?> |
189 | 189 | <li><input class="content" <?php $this->checked($this->tour_options,'map'); ?> type="checkbox" name="content[]" value="map" /> <?php _e('Map Coordinates (generates a KML file)','wetu-importer'); ?></li> |
@@ -193,20 +193,20 @@ discard block |
||
193 | 193 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
194 | 194 | <h3><?php _e('Itinerary Info'); ?></h3> |
195 | 195 | <ul> |
196 | - <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
197 | - <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included','wetu-importer'); ?></li> |
|
198 | - <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded','wetu-importer'); ?></li> |
|
196 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
197 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included', 'wetu-importer'); ?></li> |
|
198 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded', 'wetu-importer'); ?></li> |
|
199 | 199 | </ul> |
200 | 200 | |
201 | 201 | <h4><?php _e('Additional Content'); ?></h4> |
202 | 202 | <ul> |
203 | - <li><input class="content" <?php $this->checked($this->tour_options,'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation','wetu-importer'); ?></li> |
|
204 | - <li><input class="content" <?php $this->checked($this->tour_options,'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations','wetu-importer'); ?></li> |
|
205 | - <li><input class="content" <?php $this->checked($this->tour_options,'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php _e('Featured Image','wetu-importer'); ?></li> |
|
206 | - <li><input class="content" <?php $this->checked($this->tour_options,'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php _e('Banner Image','wetu-importer'); ?></li> |
|
203 | + <li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation', 'wetu-importer'); ?></li> |
|
204 | + <li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations', 'wetu-importer'); ?></li> |
|
205 | + <li><input class="content" <?php $this->checked($this->tour_options, 'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php _e('Featured Image', 'wetu-importer'); ?></li> |
|
206 | + <li><input class="content" <?php $this->checked($this->tour_options, 'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php _e('Banner Image', 'wetu-importer'); ?></li> |
|
207 | 207 | </ul> |
208 | 208 | </div> |
209 | - <?php if(class_exists('LSX_TO_Team')){ ?> |
|
209 | + <?php if (class_exists('LSX_TO_Team')) { ?> |
|
210 | 210 | <div style="width:30%;display:block;float:left;"> |
211 | 211 | <h3><?php _e('Assign a Team Member'); ?></h3> |
212 | 212 | <?php $this->team_member_checkboxes($this->tour_options); ?> |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | |
219 | 219 | |
220 | 220 | <h3><?php _e('Your List'); ?></h3> |
221 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
221 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
222 | 222 | <table class="wp-list-table widefat fixed posts"> |
223 | 223 | <?php $this->table_header(); ?> |
224 | 224 | |
@@ -230,12 +230,12 @@ discard block |
||
230 | 230 | |
231 | 231 | </table> |
232 | 232 | |
233 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
233 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
234 | 234 | </form> |
235 | 235 | </div> |
236 | 236 | |
237 | 237 | <div style="display:none;" class="completed-list-wrapper"> |
238 | - <h3><?php _e('Completed','wetu-importer'); ?> - <small><?php _e('Import your','wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next','wetu-importer'); ?></small></h3> |
|
238 | + <h3><?php _e('Completed', 'wetu-importer'); ?> - <small><?php _e('Import your', 'wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next', 'wetu-importer'); ?></small></h3> |
|
239 | 239 | <ul> |
240 | 240 | </ul> |
241 | 241 | </div> |
@@ -249,23 +249,23 @@ discard block |
||
249 | 249 | public function update_options_form() { |
250 | 250 | $tours = get_transient('lsx_ti_tours'); |
251 | 251 | |
252 | - echo '<div class="wetu-status tour-wetu-status"><h3>'.__('Wetu Status','wetu-importer').' - '; |
|
253 | - if('' === $tours || false === $tours || isset($_GET['refresh_tours'])){ |
|
252 | + echo '<div class="wetu-status tour-wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').' - '; |
|
253 | + if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) { |
|
254 | 254 | $result = $this->update_options(); |
255 | 255 | |
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{ |
|
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 | 260 | echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
261 | 261 | } |
262 | - }else{ |
|
263 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
262 | + }else { |
|
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 | - if(false === $form_options){ |
|
268 | + if (false === $form_options) { |
|
269 | 269 | $form_options = array(0); |
270 | 270 | } |
271 | 271 | ?> |
@@ -276,16 +276,16 @@ discard block |
||
276 | 276 | <input type="hidden" name="refresh_tours" value="true" /> |
277 | 277 | |
278 | 278 | <p class="tour-search-options"> |
279 | - <label for="own"><input class="content" <?php if(in_array('own',$form_options)){ echo 'checked'; } ?> type="checkbox" name="own" value="true" /> <?php esc_html_e('Own Tours','wetu-importer'); ?> </label> |
|
279 | + <label for="own"><input class="content" <?php if (in_array('own', $form_options)) { echo 'checked'; } ?> type="checkbox" name="own" value="true" /> <?php esc_html_e('Own Tours', 'wetu-importer'); ?> </label> |
|
280 | 280 | </p> |
281 | 281 | |
282 | 282 | <p class="tour-search-options"> |
283 | - <label for="type"><input class="content" <?php if(in_array('allitineraries',$form_options)){ echo 'checked'; } ?> type="radio" name="type[]" value="allitineraries" /> <?php _e('All','wetu-importer'); ?></label> |
|
284 | - <label for="type"><input class="content" <?php if(in_array('sample',$form_options)){ echo 'checked'; } ?> type="radio" name="type[]" value="sample" /> <?php _e('Sample','wetu-importer'); ?></label> |
|
285 | - <label for="type"><input class="content" <?php if(in_array('personal',$form_options)){ echo 'checked'; } ?> type="radio" name="type[]" value="personal" /> <?php _e('Personal','wetu-importer'); ?></label> |
|
283 | + <label for="type"><input class="content" <?php if (in_array('allitineraries', $form_options)) { echo 'checked'; } ?> type="radio" name="type[]" value="allitineraries" /> <?php _e('All', 'wetu-importer'); ?></label> |
|
284 | + <label for="type"><input class="content" <?php if (in_array('sample', $form_options)) { echo 'checked'; } ?> type="radio" name="type[]" value="sample" /> <?php _e('Sample', 'wetu-importer'); ?></label> |
|
285 | + <label for="type"><input class="content" <?php if (in_array('personal', $form_options)) { echo 'checked'; } ?> type="radio" name="type[]" value="personal" /> <?php _e('Personal', 'wetu-importer'); ?></label> |
|
286 | 286 | </p> |
287 | 287 | |
288 | - <p><input class="button button-primary submit" type="submit" value="<?php echo esc_attr('Refresh Tours','wetu-importer'); ?>"></p> |
|
288 | + <p><input class="button button-primary submit" type="submit" value="<?php echo esc_attr('Refresh Tours', 'wetu-importer'); ?>"></p> |
|
289 | 289 | </form> |
290 | 290 | <br /> |
291 | 291 | <?php |
@@ -302,28 +302,28 @@ discard block |
||
302 | 302 | |
303 | 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 | - if(isset($_GET['type'])){ |
|
311 | - $this->url_qs .= '&type='.implode('',$_GET['type']); |
|
312 | - $options[] = implode('',$_GET['type']); |
|
310 | + if (isset($_GET['type'])) { |
|
311 | + $this->url_qs .= '&type='.implode('', $_GET['type']); |
|
312 | + $options[] = implode('', $_GET['type']); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | $this->url_qs .= '&results=2000'; |
316 | 316 | |
317 | - add_option('lsx_ti_tours_api_options',$options); |
|
317 | + add_option('lsx_ti_tours_api_options', $options); |
|
318 | 318 | |
319 | - $data = file_get_contents( $this->url . '/V7/List?' . $this->url_qs ); |
|
319 | + $data = file_get_contents($this->url.'/V7/List?'.$this->url_qs); |
|
320 | 320 | |
321 | 321 | $tours = json_decode($data, true); |
322 | 322 | |
323 | - if(isset($tours['error'])){ |
|
323 | + if (isset($tours['error'])) { |
|
324 | 324 | return $tours['error']; |
325 | 325 | }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
326 | - set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2); |
|
326 | + set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2); |
|
327 | 327 | return true; |
328 | 328 | } |
329 | 329 | } |
@@ -347,8 +347,8 @@ discard block |
||
347 | 347 | |
348 | 348 | LIMIT 0,500 |
349 | 349 | "); |
350 | - if(null !== $current_tours && !empty($current_tours)){ |
|
351 | - foreach($current_tours as $tour){ |
|
350 | + if (null !== $current_tours && !empty($current_tours)) { |
|
351 | + foreach ($current_tours as $tour) { |
|
352 | 352 | $return[$tour->meta_value] = $tour; |
353 | 353 | } |
354 | 354 | } |
@@ -361,38 +361,38 @@ discard block |
||
361 | 361 | public function process_ajax_search() { |
362 | 362 | $return = false; |
363 | 363 | |
364 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug){ |
|
364 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) { |
|
365 | 365 | |
366 | 366 | |
367 | 367 | $tours = get_transient('lsx_ti_tours'); |
368 | - if ( false !== $tours) { |
|
368 | + if (false !== $tours) { |
|
369 | 369 | |
370 | 370 | $searched_items = false; |
371 | 371 | |
372 | - if(isset($_POST['keyword'] )) { |
|
372 | + if (isset($_POST['keyword'])) { |
|
373 | 373 | $keyphrases = $_POST['keyword']; |
374 | - }else{ |
|
374 | + }else { |
|
375 | 375 | $keyphrases = array(0); |
376 | 376 | } |
377 | 377 | |
378 | - if(!is_array($keyphrases)){ |
|
378 | + if (!is_array($keyphrases)) { |
|
379 | 379 | $keyphrases = array($keyphrases); |
380 | 380 | } |
381 | - foreach($keyphrases as &$keyword){ |
|
381 | + foreach ($keyphrases as &$keyword) { |
|
382 | 382 | $keyword = ltrim(rtrim($keyword)); |
383 | 383 | } |
384 | 384 | |
385 | 385 | $post_status = false; |
386 | - if(in_array('publish',$keyphrases)){ |
|
386 | + if (in_array('publish', $keyphrases)) { |
|
387 | 387 | $post_status = 'publish'; |
388 | 388 | } |
389 | - if(in_array('pending',$keyphrases)){ |
|
389 | + if (in_array('pending', $keyphrases)) { |
|
390 | 390 | $post_status = 'pending'; |
391 | 391 | } |
392 | - if(in_array('draft',$keyphrases)){ |
|
392 | + if (in_array('draft', $keyphrases)) { |
|
393 | 393 | $post_status = 'draft'; |
394 | 394 | } |
395 | - if(in_array('import',$keyphrases)){ |
|
395 | + if (in_array('import', $keyphrases)) { |
|
396 | 396 | $post_status = 'import'; |
397 | 397 | } |
398 | 398 | |
@@ -400,9 +400,9 @@ discard block |
||
400 | 400 | if (!empty($tours)) { |
401 | 401 | $current_tours = $this->find_current_tours(); |
402 | 402 | |
403 | - foreach($tours as $row_key => $row){ |
|
403 | + foreach ($tours as $row_key => $row) { |
|
404 | 404 | |
405 | - if(isset($row['is_disabled']) && true === $row['is_disabled']){ |
|
405 | + if (isset($row['is_disabled']) && true === $row['is_disabled']) { |
|
406 | 406 | continue; |
407 | 407 | } |
408 | 408 | |
@@ -412,29 +412,29 @@ discard block |
||
412 | 412 | |
413 | 413 | //If this is a current tour, add its ID to the row. |
414 | 414 | $row['post_id'] = 0; |
415 | - if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){ |
|
415 | + if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) { |
|
416 | 416 | $row['post_id'] = $current_tours[$row['identifier']]->post_id; |
417 | 417 | } |
418 | 418 | |
419 | 419 | //If we are searching for |
420 | - if(false !== $post_status){ |
|
420 | + if (false !== $post_status) { |
|
421 | 421 | |
422 | - if('import' === $post_status){ |
|
422 | + if ('import' === $post_status) { |
|
423 | 423 | |
424 | - if(0 !== $row['post_id']){ |
|
424 | + if (0 !== $row['post_id']) { |
|
425 | 425 | continue; |
426 | - }else{ |
|
426 | + }else { |
|
427 | 427 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
428 | 428 | } |
429 | 429 | |
430 | 430 | |
431 | - }else{ |
|
431 | + }else { |
|
432 | 432 | |
433 | - if(0 === $row['post_id']){ |
|
433 | + if (0 === $row['post_id']) { |
|
434 | 434 | continue; |
435 | - }else{ |
|
435 | + }else { |
|
436 | 436 | $current_status = get_post_status($row['post_id']); |
437 | - if($current_status !== $post_status){ |
|
437 | + if ($current_status !== $post_status) { |
|
438 | 438 | continue; |
439 | 439 | } |
440 | 440 | |
@@ -443,17 +443,17 @@ discard block |
||
443 | 443 | |
444 | 444 | } |
445 | 445 | |
446 | - }else{ |
|
446 | + }else { |
|
447 | 447 | //Search through each keyword. |
448 | - foreach($keyphrases as $keyphrase){ |
|
448 | + foreach ($keyphrases as $keyphrase) { |
|
449 | 449 | |
450 | 450 | //Make sure the keyphrase is turned into an array |
451 | - $keywords = explode(" ",$keyphrase); |
|
452 | - if(!is_array($keywords)){ |
|
451 | + $keywords = explode(" ", $keyphrase); |
|
452 | + if (!is_array($keywords)) { |
|
453 | 453 | $keywords = array($keywords); |
454 | 454 | } |
455 | 455 | |
456 | - if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){ |
|
456 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
457 | 457 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
458 | 458 | } |
459 | 459 | } |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | } |
462 | 462 | } |
463 | 463 | |
464 | - if(false !== $searched_items){ |
|
464 | + if (false !== $searched_items) { |
|
465 | 465 | ksort($searched_items); |
466 | 466 | $return = implode($searched_items); |
467 | 467 | } |
@@ -474,11 +474,11 @@ discard block |
||
474 | 474 | /** |
475 | 475 | * Formats the row for output on the screen. |
476 | 476 | */ |
477 | - public function format_row($row = false){ |
|
478 | - if(false !== $row){ |
|
477 | + public function format_row($row = false) { |
|
478 | + if (false !== $row) { |
|
479 | 479 | |
480 | 480 | $status = 'import'; |
481 | - if(0 !== $row['post_id']){ |
|
481 | + if (0 !== $row['post_id']) { |
|
482 | 482 | $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
483 | 483 | } |
484 | 484 | |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | <strong>'.$row['name'].'</strong> - '.$status.' |
493 | 493 | </td> |
494 | 494 | <td class="date column-date"> |
495 | - <abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
495 | + <abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
496 | 496 | </td> |
497 | 497 | <td class="ssid column-ssid"> |
498 | 498 | '.$row['identifier'].' |
@@ -508,39 +508,39 @@ discard block |
||
508 | 508 | public function process_ajax_import($force = false) { |
509 | 509 | $return = false; |
510 | 510 | |
511 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])){ |
|
511 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) { |
|
512 | 512 | |
513 | 513 | $wetu_id = $_POST['wetu_id']; |
514 | - if(isset($_POST['post_id'])){ |
|
514 | + if (isset($_POST['post_id'])) { |
|
515 | 515 | $post_id = $_POST['post_id']; |
516 | - }else{ |
|
516 | + }else { |
|
517 | 517 | $post_id = 0; |
518 | 518 | } |
519 | 519 | |
520 | 520 | delete_option('wetu_importer_tour_settings'); |
521 | - if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
|
521 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
522 | 522 | $content = $_POST['content']; |
523 | - add_option('wetu_importer_tour_settings',$content); |
|
524 | - }else{ |
|
523 | + add_option('wetu_importer_tour_settings', $content); |
|
524 | + }else { |
|
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) |
|
530 | + if ($jdata) |
|
531 | 531 | { |
532 | - $jdata=json_decode($jdata,true); |
|
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); |
|
534 | + $return = $this->import_row($jdata, $wetu_id, $post_id, $content); |
|
535 | 535 | $this->format_completed_row($return); |
536 | 536 | $this->save_queue(); |
537 | 537 | $this->cleanup_posts(); |
538 | 538 | $this->attach_destination_images($content); |
539 | - }else{ |
|
540 | - if(isset($adata['error'])){ |
|
539 | + }else { |
|
540 | + if (isset($adata['error'])) { |
|
541 | 541 | $this->format_error($adata['error']); |
542 | - }else{ |
|
543 | - $this->format_error(esc_html__('There was a problem importing your tour, please try refreshing the page.','wetu-importer')); |
|
542 | + }else { |
|
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 | } |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | * @param $data array |
554 | 554 | * @param $wetu_id string |
555 | 555 | */ |
556 | - public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) { |
|
556 | + public function import_row($data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false) { |
|
557 | 557 | $post_name = $data_post_content = $data_post_excerpt = ''; |
558 | 558 | $post = array( |
559 | 559 | 'post_type' => 'tour', |
@@ -561,29 +561,29 @@ discard block |
||
561 | 561 | |
562 | 562 | //Set the post_content |
563 | 563 | $content_used_general_description = false; |
564 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
564 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
565 | 565 | $data_post_content = ''; |
566 | 566 | |
567 | - if(isset($data['description'])){ |
|
567 | + if (isset($data['description'])) { |
|
568 | 568 | $data_post_content = $data['description']; |
569 | - }elseif(isset($data['summary'])){ |
|
569 | + }elseif (isset($data['summary'])) { |
|
570 | 570 | $data_post_content = $data['summary']; |
571 | 571 | } |
572 | 572 | $post['post_content'] = $data_post_content; |
573 | 573 | } |
574 | 574 | |
575 | 575 | //Create or update the post |
576 | - if(false !== $id && '0' !== $id){ |
|
576 | + if (false !== $id && '0' !== $id) { |
|
577 | 577 | $post['ID'] = $id; |
578 | 578 | $post['post_status'] = 'publish'; |
579 | 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{ |
|
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 | 583 | |
584 | 584 | //Set the name |
585 | - if(isset($data['name'])){ |
|
586 | - $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
585 | + if (isset($data['name'])) { |
|
586 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0); |
|
587 | 587 | } |
588 | 588 | $post['post_name'] = $post_name; |
589 | 589 | $post['post_title'] = $data['name']; |
@@ -591,29 +591,29 @@ discard block |
||
591 | 591 | $id = wp_insert_post($post); |
592 | 592 | |
593 | 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'])); |
|
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 | 597 | } |
598 | 598 | } |
599 | 599 | |
600 | 600 | |
601 | 601 | //Set the price |
602 | - if(false !== $importable_content && in_array('price',$importable_content)){ |
|
603 | - $this->set_price($data,$id); |
|
602 | + if (false !== $importable_content && in_array('price', $importable_content)) { |
|
603 | + $this->set_price($data, $id); |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | //Set the Duration |
607 | - if(false !== $importable_content && in_array('duration',$importable_content)){ |
|
608 | - $this->set_duration($data,$id); |
|
607 | + if (false !== $importable_content && in_array('duration', $importable_content)) { |
|
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); |
|
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 | 613 | } |
614 | 614 | |
615 | - if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){ |
|
616 | - $this->set_map_data($data,$id); |
|
615 | + if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) { |
|
616 | + $this->set_map_data($data, $id); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | return $id; |
@@ -622,151 +622,151 @@ discard block |
||
622 | 622 | /** |
623 | 623 | * A loop which runs through each leg on the tour. |
624 | 624 | */ |
625 | - public function process_itineraries($data,$id,$importable_content) { |
|
625 | + public function process_itineraries($data, $id, $importable_content) { |
|
626 | 626 | $day_counter = 1; |
627 | 627 | $leg_counter = 0; |
628 | 628 | |
629 | - delete_post_meta($id,'itinerary'); |
|
629 | + delete_post_meta($id, 'itinerary'); |
|
630 | 630 | |
631 | - if(false !== $importable_content && in_array('accommodation',$importable_content)){ |
|
632 | - delete_post_meta($id,'accommodation_to_tour'); |
|
631 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
632 | + delete_post_meta($id, 'accommodation_to_tour'); |
|
633 | 633 | } |
634 | - if(false !== $importable_content && in_array('destination',$importable_content)){ |
|
635 | - delete_post_meta($id,'destination_to_tour'); |
|
636 | - delete_post_meta($id,'departs_from'); |
|
637 | - delete_post_meta($id,'ends_in'); |
|
634 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
635 | + delete_post_meta($id, 'destination_to_tour'); |
|
636 | + delete_post_meta($id, 'departs_from'); |
|
637 | + delete_post_meta($id, 'ends_in'); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | $departs_from = false; |
641 | 641 | $ends_in = false; |
642 | 642 | |
643 | - foreach($data['legs'] as $leg){ |
|
643 | + foreach ($data['legs'] as $leg) { |
|
644 | 644 | |
645 | - if(isset($leg['days']) && !empty($leg['days'])){ |
|
645 | + if (isset($leg['days']) && !empty($leg['days'])) { |
|
646 | 646 | |
647 | 647 | //Itinerary Accommodation |
648 | 648 | $current_accommodation = false; |
649 | - if(false !== $importable_content && in_array('accommodation',$importable_content)){ |
|
650 | - $current_accommodation = $this->set_accommodation($leg,$id); |
|
649 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
650 | + $current_accommodation = $this->set_accommodation($leg, $id); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | //Itinerary Destination |
654 | 654 | $current_destination = false; |
655 | - if(false !== $importable_content && in_array('destination',$importable_content)){ |
|
656 | - $current_destination = $this->set_destination($leg,$id,$leg_counter); |
|
655 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
656 | + $current_destination = $this->set_destination($leg, $id, $leg_counter); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | //If the Nights are the same mount of days in the array, then it isnt "By Destination" |
660 | - if($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']){ |
|
660 | + if ($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']) { |
|
661 | 661 | |
662 | - foreach($leg['days'] as $day){ |
|
662 | + foreach ($leg['days'] as $day) { |
|
663 | 663 | |
664 | 664 | $current_day = array(); |
665 | 665 | |
666 | - $current_day['title'] = esc_attr('Day ','wetu-importer').$day_counter; |
|
666 | + $current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter; |
|
667 | 667 | |
668 | 668 | //print_r('<pre>');print_r($day['notes']);print_r('</pre>'); |
669 | 669 | |
670 | 670 | //Description |
671 | - if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){ |
|
671 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) { |
|
672 | 672 | $current_day['description'] = $day['notes']; |
673 | - }else{ |
|
673 | + }else { |
|
674 | 674 | $current_day['description'] = ''; |
675 | 675 | } |
676 | 676 | |
677 | 677 | //Itinerary Gallery |
678 | - if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){ |
|
678 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) { |
|
679 | 679 | $current_day['featured_image'] = ''; |
680 | - }else{ |
|
680 | + }else { |
|
681 | 681 | $current_day['featured_image'] = ''; |
682 | 682 | } |
683 | 683 | |
684 | 684 | //Accommodation |
685 | - if(false !== $current_accommodation){ |
|
685 | + if (false !== $current_accommodation) { |
|
686 | 686 | $current_day['accommodation_to_tour'] = array($current_accommodation); |
687 | - }else{ |
|
687 | + }else { |
|
688 | 688 | $current_day['accommodation_to_tour'] = array(); |
689 | 689 | } |
690 | 690 | |
691 | 691 | //Destination |
692 | - if(false !== $current_destination){ |
|
692 | + if (false !== $current_destination) { |
|
693 | 693 | $current_day['destination_to_tour'] = array($current_destination); |
694 | - }else{ |
|
694 | + }else { |
|
695 | 695 | $current_day['destination_to_tour'] = array(); |
696 | 696 | } |
697 | 697 | |
698 | 698 | //Included |
699 | - if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){ |
|
699 | + if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) { |
|
700 | 700 | $current_day['included'] = $day['included']; |
701 | - }else{ |
|
701 | + }else { |
|
702 | 702 | $current_day['included'] = ''; |
703 | 703 | } |
704 | 704 | |
705 | 705 | //Excluded |
706 | - if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){ |
|
706 | + if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) { |
|
707 | 707 | $current_day['excluded'] = $day['excluded']; |
708 | - }else{ |
|
708 | + }else { |
|
709 | 709 | $current_day['excluded'] = ''; |
710 | 710 | } |
711 | 711 | |
712 | - $this->set_itinerary_day($current_day,$id); |
|
712 | + $this->set_itinerary_day($current_day, $id); |
|
713 | 713 | $day_counter++; |
714 | 714 | } |
715 | 715 | |
716 | - }else{ |
|
717 | - $day_counter = $day_counter + (int)$leg['nights']; |
|
716 | + }else { |
|
717 | + $day_counter = $day_counter + (int) $leg['nights']; |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | } |
721 | 721 | |
722 | 722 | //If we are in the first leg, and the destination was attached then save it as the departure field. |
723 | - if( 0 === $leg_counter && false !== $current_destination){ |
|
723 | + if (0 === $leg_counter && false !== $current_destination) { |
|
724 | 724 | $departs_from = $current_destination; |
725 | 725 | } |
726 | 726 | |
727 | 727 | //If its the last leg then save it as the ends in. |
728 | - if( $leg_counter === (count($data['legs'])-2) && false !== $current_destination){ |
|
728 | + if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) { |
|
729 | 729 | $ends_in = $current_destination; |
730 | 730 | } |
731 | 731 | $leg_counter++; |
732 | 732 | } |
733 | 733 | |
734 | - if(false !== $departs_from){ |
|
735 | - add_post_meta($id,'departs_from',$departs_from,true); |
|
734 | + if (false !== $departs_from) { |
|
735 | + add_post_meta($id, 'departs_from', $departs_from, true); |
|
736 | 736 | } |
737 | - if(false !== $ends_in){ |
|
738 | - add_post_meta($id,'ends_in',$ends_in,true); |
|
737 | + if (false !== $ends_in) { |
|
738 | + add_post_meta($id, 'ends_in', $ends_in, true); |
|
739 | 739 | } |
740 | 740 | } |
741 | 741 | |
742 | 742 | /** |
743 | 743 | * Run through your routes and save the points as a KML file. |
744 | 744 | */ |
745 | - public function set_map_data($data,$id,$zoom=9) { |
|
745 | + public function set_map_data($data, $id, $zoom = 9) { |
|
746 | 746 | |
747 | - if(!empty($data['routes'])){ |
|
747 | + if (!empty($data['routes'])) { |
|
748 | 748 | |
749 | - delete_post_meta($id,'wetu_map_points'); |
|
749 | + delete_post_meta($id, 'wetu_map_points'); |
|
750 | 750 | |
751 | 751 | $points = array(); |
752 | 752 | |
753 | - foreach($data['routes'] as $route){ |
|
753 | + foreach ($data['routes'] as $route) { |
|
754 | 754 | |
755 | 755 | |
756 | - if(isset($route['points']) && '' !== $route['points']){ |
|
756 | + if (isset($route['points']) && '' !== $route['points']) { |
|
757 | 757 | |
758 | - $temp_points = explode(';',$route['points']); |
|
758 | + $temp_points = explode(';', $route['points']); |
|
759 | 759 | $point_counter = count($temp_points); |
760 | 760 | |
761 | 761 | for ($x = 0; $x <= $point_counter; $x++) { |
762 | - $y = $x+1; |
|
762 | + $y = $x + 1; |
|
763 | 763 | $points[] = $temp_points[$x].','.$temp_points[$y]; |
764 | 764 | $x++; |
765 | 765 | } |
766 | 766 | } |
767 | 767 | } |
768 | - if(!empty($points)){ |
|
769 | - $this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true); |
|
768 | + if (!empty($points)) { |
|
769 | + $this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true); |
|
770 | 770 | } |
771 | 771 | } |
772 | 772 | |
@@ -777,28 +777,28 @@ discard block |
||
777 | 777 | /** |
778 | 778 | * Set the Itinerary Day |
779 | 779 | */ |
780 | - public function set_itinerary_day($day,$id) { |
|
781 | - $this->save_custom_field($day,'itinerary',$id,false,false); |
|
780 | + public function set_itinerary_day($day, $id) { |
|
781 | + $this->save_custom_field($day, 'itinerary', $id, false, false); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | /** |
785 | 785 | * Set the price |
786 | 786 | */ |
787 | - public function set_price($data,$id) { |
|
787 | + public function set_price($data, $id) { |
|
788 | 788 | //Price |
789 | - if(isset($data['price']) && ''!== $data['price']){ |
|
789 | + if (isset($data['price']) && '' !== $data['price']) { |
|
790 | 790 | $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
791 | - $this->save_custom_field($price,'price',$id); |
|
791 | + $this->save_custom_field($price, 'price', $id); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | //Price includes |
795 | - if(isset($data['price_includes']) && ''!== $data['price_includes']){ |
|
796 | - $this->save_custom_field($data['price_includes'],'included',$id); |
|
795 | + if (isset($data['price_includes']) && '' !== $data['price_includes']) { |
|
796 | + $this->save_custom_field($data['price_includes'], 'included', $id); |
|
797 | 797 | } |
798 | 798 | |
799 | 799 | //Price Excludes |
800 | - if(isset($data['price_excludes']) && ''!== $data['price_excludes']){ |
|
801 | - $this->save_custom_field($data['price_excludes'],'not_included',$id); |
|
800 | + if (isset($data['price_excludes']) && '' !== $data['price_excludes']) { |
|
801 | + $this->save_custom_field($data['price_excludes'], 'not_included', $id); |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | } |
@@ -806,38 +806,38 @@ discard block |
||
806 | 806 | /** |
807 | 807 | * Set the duration |
808 | 808 | */ |
809 | - public function set_duration($data,$id) { |
|
810 | - if(isset($data['days']) && !empty($data['days'])){ |
|
809 | + public function set_duration($data, $id) { |
|
810 | + if (isset($data['days']) && !empty($data['days'])) { |
|
811 | 811 | $price = $data['days']; |
812 | 812 | $price = preg_replace("/[^0-9,.]/", "", $price); |
813 | - $this->save_custom_field($price,'duration',$id); |
|
813 | + $this->save_custom_field($price, 'duration', $id); |
|
814 | 814 | } |
815 | 815 | } |
816 | 816 | |
817 | 817 | /** |
818 | 818 | * Connects the Accommodation if its available |
819 | 819 | */ |
820 | - public function set_accommodation($day,$id) { |
|
820 | + public function set_accommodation($day, $id) { |
|
821 | 821 | |
822 | 822 | $ac_id = false; |
823 | 823 | $this->current_accommodation = $this->find_current_accommodation(); |
824 | 824 | |
825 | - if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){ |
|
825 | + if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) { |
|
826 | 826 | |
827 | - if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
|
827 | + if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) { |
|
828 | 828 | $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
829 | - }else{ |
|
829 | + }else { |
|
830 | 830 | $ac_id = wp_insert_post(array( |
831 | 831 | 'post_type' => 'accommodation', |
832 | 832 | 'post_status' => 'draft', |
833 | 833 | 'post_title' => $day['content_entity_id'] |
834 | 834 | )); |
835 | - $this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id); |
|
835 | + $this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id); |
|
836 | 836 | } |
837 | 837 | |
838 | - if('' !== $ac_id && false !== $ac_id){ |
|
839 | - $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
840 | - $this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false); |
|
838 | + if ('' !== $ac_id && false !== $ac_id) { |
|
839 | + $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false); |
|
840 | + $this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false); |
|
841 | 841 | |
842 | 842 | $this->queue_item($ac_id); |
843 | 843 | } |
@@ -851,13 +851,13 @@ discard block |
||
851 | 851 | * @param $post_type string |
852 | 852 | * @return boolean / array |
853 | 853 | */ |
854 | - public function find_current_accommodation($post_type='accommodation') { |
|
854 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
855 | 855 | global $wpdb; |
856 | 856 | $accommodation = parent::find_current_accommodation($post_type); |
857 | 857 | |
858 | 858 | $return = false; |
859 | - if(!empty($accommodation)){ |
|
860 | - foreach($accommodation as $key => $acc){ |
|
859 | + if (!empty($accommodation)) { |
|
860 | + foreach ($accommodation as $key => $acc) { |
|
861 | 861 | $return[$acc->meta_value] = $acc->post_id; |
862 | 862 | } |
863 | 863 | } |
@@ -879,26 +879,26 @@ discard block |
||
879 | 879 | * @param $id string |
880 | 880 | * @return boolean / string |
881 | 881 | */ |
882 | - public function set_destination($day,$id,$leg_counter) { |
|
882 | + public function set_destination($day, $id, $leg_counter) { |
|
883 | 883 | $dest_id = false; |
884 | 884 | $country_id = false; |
885 | 885 | $this->current_destinations = $this->find_current_destinations(); |
886 | 886 | |
887 | - if(isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])){ |
|
887 | + if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) { |
|
888 | 888 | |
889 | - if(false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'],$this->current_destinations)){ |
|
889 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) { |
|
890 | 890 | $dest_id = $this->current_destinations[$day['destination_content_entity_id']]; |
891 | 891 | |
892 | 892 | //Check if there is a country asigned. |
893 | 893 | $potential_id = wp_get_post_parent_id($dest_id); |
894 | - $country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true); |
|
895 | - if(false !== $country_wetu_id){ |
|
894 | + $country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true); |
|
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 | |
901 | - $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']); |
|
901 | + $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$day['destination_content_entity_id']); |
|
902 | 902 | |
903 | 903 | if ($destination_json) { |
904 | 904 | $destination_data = json_decode($destination_json, true); |
@@ -907,12 +907,12 @@ discard block |
||
907 | 907 | |
908 | 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 | } |
@@ -923,7 +923,7 @@ discard block |
||
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); |
@@ -947,15 +947,15 @@ discard block |
||
947 | 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 | - if(0 === $leg_counter){ |
|
951 | - $this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']); |
|
950 | + if (0 === $leg_counter) { |
|
951 | + $this->destination_images[$id] = array($dest_id, $day['destination_content_entity_id']); |
|
952 | 952 | } |
953 | 953 | |
954 | 954 | //Add this relation info so we can make sure certain items are set as countries. |
955 | - if(0 !== $country_id && false !== $country_id){ |
|
955 | + if (0 !== $country_id && false !== $country_id) { |
|
956 | 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 | } |
@@ -978,9 +978,9 @@ discard block |
||
978 | 978 | |
979 | 979 | if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
980 | 980 | $country_id = $this->current_destinations[$country_wetu_id]; |
981 | - } else { |
|
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 | 985 | if ($country_json) { |
986 | 986 | $country_data = json_decode($country_json, true); |
@@ -1026,15 +1026,15 @@ discard block |
||
1026 | 1026 | * |
1027 | 1027 | * @return string |
1028 | 1028 | */ |
1029 | - public function attach_destination_images($importable_content=array()) { |
|
1030 | - if(false !== $this->destination_images){ |
|
1029 | + public function attach_destination_images($importable_content = array()) { |
|
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 | - $url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
1034 | + $url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
1035 | 1035 | $url_qs = ''; |
1036 | 1036 | |
1037 | - $jdata = file_get_contents($url . '/Get?' . $url_qs . '&ids=' . $destination[1]); |
|
1037 | + $jdata = file_get_contents($url.'/Get?'.$url_qs.'&ids='.$destination[1]); |
|
1038 | 1038 | if ($jdata) { |
1039 | 1039 | $adata = json_decode($jdata, true); |
1040 | 1040 | |
@@ -1060,9 +1060,9 @@ discard block |
||
1060 | 1060 | * @param $id int |
1061 | 1061 | */ |
1062 | 1062 | public function queue_item($id) { |
1063 | - if(is_array($this->import_queue) && !in_array($id,$this->import_queue)){ |
|
1063 | + if (is_array($this->import_queue) && !in_array($id, $this->import_queue)) { |
|
1064 | 1064 | $this->import_queue[] = $id; |
1065 | - }else{ |
|
1065 | + }else { |
|
1066 | 1066 | $this->import_queue[] = $id; |
1067 | 1067 | } |
1068 | 1068 | } |
@@ -1072,17 +1072,17 @@ discard block |
||
1072 | 1072 | */ |
1073 | 1073 | public function save_queue() { |
1074 | 1074 | |
1075 | - if(!empty($this->import_queue)) { |
|
1075 | + if (!empty($this->import_queue)) { |
|
1076 | 1076 | if (!empty($this->queued_imports)) { |
1077 | - $saved_imports = array_merge($this->queued_imports,$this->import_queue); |
|
1077 | + $saved_imports = array_merge($this->queued_imports, $this->import_queue); |
|
1078 | 1078 | |
1079 | - }else{ |
|
1079 | + }else { |
|
1080 | 1080 | $saved_imports = $this->import_queue; |
1081 | 1081 | } |
1082 | 1082 | delete_option('wetu_importer_que'); |
1083 | - if(!empty($saved_imports)){ |
|
1083 | + if (!empty($saved_imports)) { |
|
1084 | 1084 | $saved_imports = array_unique($saved_imports); |
1085 | - update_option('wetu_importer_que',$saved_imports); |
|
1085 | + update_option('wetu_importer_que', $saved_imports); |
|
1086 | 1086 | } |
1087 | 1087 | } |
1088 | 1088 | } |
@@ -256,10 +256,10 @@ discard block |
||
256 | 256 | if(true === $result){ |
257 | 257 | echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
258 | 258 | echo ' - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
259 | - }else{ |
|
259 | + } else{ |
|
260 | 260 | echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
261 | 261 | } |
262 | - }else{ |
|
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>'; |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | |
323 | 323 | if(isset($tours['error'])){ |
324 | 324 | return $tours['error']; |
325 | - }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
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 | } |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | |
372 | 372 | if(isset($_POST['keyword'] )) { |
373 | 373 | $keyphrases = $_POST['keyword']; |
374 | - }else{ |
|
374 | + } else{ |
|
375 | 375 | $keyphrases = array(0); |
376 | 376 | } |
377 | 377 | |
@@ -423,16 +423,16 @@ discard block |
||
423 | 423 | |
424 | 424 | if(0 !== $row['post_id']){ |
425 | 425 | continue; |
426 | - }else{ |
|
426 | + } else{ |
|
427 | 427 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
428 | 428 | } |
429 | 429 | |
430 | 430 | |
431 | - }else{ |
|
431 | + } else{ |
|
432 | 432 | |
433 | 433 | if(0 === $row['post_id']){ |
434 | 434 | continue; |
435 | - }else{ |
|
435 | + } else{ |
|
436 | 436 | $current_status = get_post_status($row['post_id']); |
437 | 437 | if($current_status !== $post_status){ |
438 | 438 | continue; |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | |
444 | 444 | } |
445 | 445 | |
446 | - }else{ |
|
446 | + } else{ |
|
447 | 447 | //Search through each keyword. |
448 | 448 | foreach($keyphrases as $keyphrase){ |
449 | 449 | |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | $wetu_id = $_POST['wetu_id']; |
514 | 514 | if(isset($_POST['post_id'])){ |
515 | 515 | $post_id = $_POST['post_id']; |
516 | - }else{ |
|
516 | + } else{ |
|
517 | 517 | $post_id = 0; |
518 | 518 | } |
519 | 519 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
522 | 522 | $content = $_POST['content']; |
523 | 523 | add_option('wetu_importer_tour_settings',$content); |
524 | - }else{ |
|
524 | + } else{ |
|
525 | 525 | $content = false; |
526 | 526 | } |
527 | 527 | |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | $this->save_queue(); |
537 | 537 | $this->cleanup_posts(); |
538 | 538 | $this->attach_destination_images($content); |
539 | - }else{ |
|
539 | + } else{ |
|
540 | 540 | if(isset($adata['error'])){ |
541 | 541 | $this->format_error($adata['error']); |
542 | - }else{ |
|
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 | } |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | |
567 | 567 | if(isset($data['description'])){ |
568 | 568 | $data_post_content = $data['description']; |
569 | - }elseif(isset($data['summary'])){ |
|
569 | + } elseif(isset($data['summary'])){ |
|
570 | 570 | $data_post_content = $data['summary']; |
571 | 571 | } |
572 | 572 | $post['post_content'] = $data_post_content; |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | $id = wp_update_post($post); |
580 | 580 | $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
581 | 581 | update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
582 | - }else{ |
|
582 | + } else{ |
|
583 | 583 | |
584 | 584 | //Set the name |
585 | 585 | if(isset($data['name'])){ |
@@ -670,42 +670,42 @@ discard block |
||
670 | 670 | //Description |
671 | 671 | if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){ |
672 | 672 | $current_day['description'] = $day['notes']; |
673 | - }else{ |
|
673 | + } else{ |
|
674 | 674 | $current_day['description'] = ''; |
675 | 675 | } |
676 | 676 | |
677 | 677 | //Itinerary Gallery |
678 | 678 | if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){ |
679 | 679 | $current_day['featured_image'] = ''; |
680 | - }else{ |
|
680 | + } else{ |
|
681 | 681 | $current_day['featured_image'] = ''; |
682 | 682 | } |
683 | 683 | |
684 | 684 | //Accommodation |
685 | 685 | if(false !== $current_accommodation){ |
686 | 686 | $current_day['accommodation_to_tour'] = array($current_accommodation); |
687 | - }else{ |
|
687 | + } else{ |
|
688 | 688 | $current_day['accommodation_to_tour'] = array(); |
689 | 689 | } |
690 | 690 | |
691 | 691 | //Destination |
692 | 692 | if(false !== $current_destination){ |
693 | 693 | $current_day['destination_to_tour'] = array($current_destination); |
694 | - }else{ |
|
694 | + } else{ |
|
695 | 695 | $current_day['destination_to_tour'] = array(); |
696 | 696 | } |
697 | 697 | |
698 | 698 | //Included |
699 | 699 | if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){ |
700 | 700 | $current_day['included'] = $day['included']; |
701 | - }else{ |
|
701 | + } else{ |
|
702 | 702 | $current_day['included'] = ''; |
703 | 703 | } |
704 | 704 | |
705 | 705 | //Excluded |
706 | 706 | if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){ |
707 | 707 | $current_day['excluded'] = $day['excluded']; |
708 | - }else{ |
|
708 | + } else{ |
|
709 | 709 | $current_day['excluded'] = ''; |
710 | 710 | } |
711 | 711 | |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | $day_counter++; |
714 | 714 | } |
715 | 715 | |
716 | - }else{ |
|
716 | + } else{ |
|
717 | 717 | $day_counter = $day_counter + (int)$leg['nights']; |
718 | 718 | } |
719 | 719 | |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | |
827 | 827 | if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
828 | 828 | $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
829 | - }else{ |
|
829 | + } else{ |
|
830 | 830 | $ac_id = wp_insert_post(array( |
831 | 831 | 'post_type' => 'accommodation', |
832 | 832 | 'post_status' => 'draft', |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | $country_id = $this->set_country($country_wetu_id, $id); |
897 | 897 | } |
898 | 898 | |
899 | - }else { |
|
899 | + } else { |
|
900 | 900 | |
901 | 901 | $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']); |
902 | 902 | |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | if(0 !== $country_id && false !== $country_id){ |
956 | 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 | } |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | public function queue_item($id) { |
1063 | 1063 | if(is_array($this->import_queue) && !in_array($id,$this->import_queue)){ |
1064 | 1064 | $this->import_queue[] = $id; |
1065 | - }else{ |
|
1065 | + } else{ |
|
1066 | 1066 | $this->import_queue[] = $id; |
1067 | 1067 | } |
1068 | 1068 | } |
@@ -1076,7 +1076,7 @@ discard block |
||
1076 | 1076 | if (!empty($this->queued_imports)) { |
1077 | 1077 | $saved_imports = array_merge($this->queued_imports,$this->import_queue); |
1078 | 1078 | |
1079 | - }else{ |
|
1079 | + } else{ |
|
1080 | 1080 | $saved_imports = $this->import_queue; |
1081 | 1081 | } |
1082 | 1082 | delete_option('wetu_importer_que'); |