@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * Display the importer administration screen |
105 | 105 | */ |
106 | 106 | public function display_page() { |
107 | - ?> |
|
107 | + ?> |
|
108 | 108 | <div class="wrap"> |
109 | 109 | <?php screen_icon(); ?> |
110 | 110 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $keyphrases = $_POST['keyword']; |
330 | 330 | }else{ |
331 | 331 | $keyphrases = array(0); |
332 | - } |
|
332 | + } |
|
333 | 333 | |
334 | 334 | if(!is_array($keyphrases)){ |
335 | 335 | $keyphrases = array($keyphrases); |
@@ -358,11 +358,11 @@ discard block |
||
358 | 358 | //If we are searching for |
359 | 359 | if(false !== $post_status){ |
360 | 360 | |
361 | - $current_status = get_post_status($row->post_id); |
|
362 | - if($current_status !== $post_status){ |
|
363 | - continue; |
|
364 | - } |
|
365 | - $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row); |
|
361 | + $current_status = get_post_status($row->post_id); |
|
362 | + if($current_status !== $post_status){ |
|
363 | + continue; |
|
364 | + } |
|
365 | + $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row); |
|
366 | 366 | |
367 | 367 | |
368 | 368 | }else{ |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | $team_members = false; |
445 | 445 | } |
446 | 446 | |
447 | - $safari_brands = false; |
|
447 | + $safari_brands = false; |
|
448 | 448 | |
449 | 449 | if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
450 | 450 | $content = $_POST['content']; |
@@ -454,16 +454,16 @@ discard block |
||
454 | 454 | $content = false; |
455 | 455 | } |
456 | 456 | |
457 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
458 | - if($jdata) |
|
459 | - { |
|
460 | - $adata=json_decode($jdata,true); |
|
461 | - if(!empty($adata)) |
|
462 | - { |
|
463 | - $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
464 | - $this->format_completed_row($return); |
|
465 | - } |
|
466 | - } |
|
457 | + $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
458 | + if($jdata) |
|
459 | + { |
|
460 | + $adata=json_decode($jdata,true); |
|
461 | + if(!empty($adata)) |
|
462 | + { |
|
463 | + $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
464 | + $this->format_completed_row($return); |
|
465 | + } |
|
466 | + } |
|
467 | 467 | |
468 | 468 | die(); |
469 | 469 | } |
@@ -475,82 +475,82 @@ discard block |
||
475 | 475 | */ |
476 | 476 | public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) { |
477 | 477 | |
478 | - if(trim($data[0]['type'])=='Destination') |
|
479 | - { |
|
480 | - $post_name = $data_post_content = $data_post_excerpt = ''; |
|
481 | - $post = array( |
|
482 | - 'post_type' => 'destination', |
|
483 | - ); |
|
484 | - |
|
485 | - $content_used_general_description = false; |
|
486 | - |
|
487 | - //Set the post_content |
|
488 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
489 | - if(isset($data[0]['content']['extended_description'])) |
|
490 | - { |
|
491 | - $data_post_content = $data[0]['content']['extended_description']; |
|
492 | - }elseif(isset($data[0]['content']['general_description'])){ |
|
493 | - $data_post_content = $data[0]['content']['general_description']; |
|
494 | - $content_used_general_description = true; |
|
495 | - }elseif(isset($data[0]['content']['teaser_description'])){ |
|
496 | - $data_post_content = $data[0]['content']['teaser_description']; |
|
497 | - } |
|
498 | - $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
499 | - } |
|
500 | - |
|
501 | - //set the post_excerpt |
|
502 | - if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
503 | - if(isset($data[0]['content']['teaser_description'])){ |
|
504 | - $data_post_excerpt = $data[0]['content']['teaser_description']; |
|
505 | - }elseif(isset($data[0]['content']['extended_description'])){ |
|
478 | + if(trim($data[0]['type'])=='Destination') |
|
479 | + { |
|
480 | + $post_name = $data_post_content = $data_post_excerpt = ''; |
|
481 | + $post = array( |
|
482 | + 'post_type' => 'destination', |
|
483 | + ); |
|
484 | + |
|
485 | + $content_used_general_description = false; |
|
486 | + |
|
487 | + //Set the post_content |
|
488 | + if(false !== $importable_content && in_array('description',$importable_content)){ |
|
489 | + if(isset($data[0]['content']['extended_description'])) |
|
490 | + { |
|
491 | + $data_post_content = $data[0]['content']['extended_description']; |
|
492 | + }elseif(isset($data[0]['content']['general_description'])){ |
|
493 | + $data_post_content = $data[0]['content']['general_description']; |
|
494 | + $content_used_general_description = true; |
|
495 | + }elseif(isset($data[0]['content']['teaser_description'])){ |
|
496 | + $data_post_content = $data[0]['content']['teaser_description']; |
|
497 | + } |
|
498 | + $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
499 | + } |
|
500 | + |
|
501 | + //set the post_excerpt |
|
502 | + if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
503 | + if(isset($data[0]['content']['teaser_description'])){ |
|
504 | + $data_post_excerpt = $data[0]['content']['teaser_description']; |
|
505 | + }elseif(isset($data[0]['content']['extended_description'])){ |
|
506 | 506 | $data_post_excerpt = $data[0]['content']['extended_description']; |
507 | 507 | }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
508 | - $data_post_excerpt = $data[0]['content']['general_description']; |
|
509 | - } |
|
510 | - $post['post_excerpt'] = $data_post_excerpt; |
|
511 | - } |
|
508 | + $data_post_excerpt = $data[0]['content']['general_description']; |
|
509 | + } |
|
510 | + $post['post_excerpt'] = $data_post_excerpt; |
|
511 | + } |
|
512 | 512 | |
513 | - if(false !== $id && '0' !== $id){ |
|
514 | - $post['ID'] = $id; |
|
513 | + if(false !== $id && '0' !== $id){ |
|
514 | + $post['ID'] = $id; |
|
515 | 515 | if(isset($data[0]['name'])){ |
516 | 516 | $post['post_title'] = $data[0]['name']; |
517 | 517 | $post['post_status'] = 'publish'; |
518 | 518 | $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0); |
519 | 519 | } |
520 | - $id = wp_update_post($post); |
|
521 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
522 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
523 | - }else{ |
|
524 | - |
|
525 | - //Set the name |
|
526 | - if(isset($data[0]['name'])){ |
|
527 | - $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0); |
|
528 | - } |
|
529 | - $post['post_name'] = $post_name; |
|
530 | - $post['post_title'] = $data[0]['name']; |
|
531 | - $post['post_status'] = 'publish'; |
|
532 | - $id = wp_insert_post($post); |
|
533 | - |
|
534 | - //Save the WETU ID and the Last date it was modified. |
|
535 | - if(false !== $id){ |
|
536 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
537 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
538 | - } |
|
539 | - } |
|
540 | - |
|
541 | - //Set the team member if it is there |
|
542 | - if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
543 | - $this->set_team_member($id,$team_members); |
|
544 | - } |
|
545 | - |
|
546 | - if(class_exists('LSX_TO_Maps')){ |
|
547 | - $this->set_map_data($data,$id); |
|
548 | - } |
|
549 | - |
|
550 | - //Set the Room Data |
|
551 | - if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
552 | - $this->set_video_data($data,$id); |
|
553 | - } |
|
520 | + $id = wp_update_post($post); |
|
521 | + $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
522 | + update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
523 | + }else{ |
|
524 | + |
|
525 | + //Set the name |
|
526 | + if(isset($data[0]['name'])){ |
|
527 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0); |
|
528 | + } |
|
529 | + $post['post_name'] = $post_name; |
|
530 | + $post['post_title'] = $data[0]['name']; |
|
531 | + $post['post_status'] = 'publish'; |
|
532 | + $id = wp_insert_post($post); |
|
533 | + |
|
534 | + //Save the WETU ID and the Last date it was modified. |
|
535 | + if(false !== $id){ |
|
536 | + add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
537 | + add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
538 | + } |
|
539 | + } |
|
540 | + |
|
541 | + //Set the team member if it is there |
|
542 | + if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
543 | + $this->set_team_member($id,$team_members); |
|
544 | + } |
|
545 | + |
|
546 | + if(class_exists('LSX_TO_Maps')){ |
|
547 | + $this->set_map_data($data,$id); |
|
548 | + } |
|
549 | + |
|
550 | + //Set the Room Data |
|
551 | + if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
552 | + $this->set_video_data($data,$id); |
|
553 | + } |
|
554 | 554 | |
555 | 555 | //Set the Electricity |
556 | 556 | if(false !== $importable_content && in_array('electricity',$importable_content)){ |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | $this->create_main_gallery($data,$id); |
590 | 590 | } |
591 | 591 | } |
592 | - return $id; |
|
592 | + return $id; |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | |
600 | 600 | delete_post_meta($id, 'team_to_'.$this->tab_slug); |
601 | 601 | foreach($team_members as $team){ |
602 | - add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
602 | + add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
603 | 603 | } |
604 | 604 | } |
605 | 605 | |
@@ -651,11 +651,11 @@ discard block |
||
651 | 651 | 'elevation' => '', |
652 | 652 | ); |
653 | 653 | if(false !== $id && '0' !== $id){ |
654 | - $prev = get_post_meta($id,'location',true); |
|
655 | - update_post_meta($id,'location',$location_data,$prev); |
|
656 | - }else{ |
|
657 | - add_post_meta($id,'location',$location_data,true); |
|
658 | - } |
|
654 | + $prev = get_post_meta($id,'location',true); |
|
655 | + update_post_meta($id,'location',$location_data,$prev); |
|
656 | + }else{ |
|
657 | + add_post_meta($id,'location',$location_data,true); |
|
658 | + } |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 |
@@ -64,21 +64,21 @@ discard block |
||
64 | 64 | public function __construct() { |
65 | 65 | $this->set_variables(); |
66 | 66 | |
67 | - add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') ); |
|
67 | + add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page')); |
|
68 | 68 | |
69 | - add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search')); |
|
70 | - add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search')); |
|
69 | + add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
70 | + add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
71 | 71 | |
72 | - add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import')); |
|
73 | - add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import')); |
|
72 | + add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import')); |
|
73 | + add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import')); |
|
74 | 74 | |
75 | - $temp_options = get_option('_lsx-to_settings',false); |
|
76 | - if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){ |
|
75 | + $temp_options = get_option('_lsx-to_settings', false); |
|
76 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
77 | 77 | $this->options = $temp_options[$this->plugin_slug]; |
78 | 78 | } |
79 | 79 | |
80 | - $destination_options = get_option('wetu_importer_destination_settings',false); |
|
81 | - if(false !== $destination_options){ |
|
80 | + $destination_options = get_option('wetu_importer_destination_settings', false); |
|
81 | + if (false !== $destination_options) { |
|
82 | 82 | $this->destination_options = $destination_options; |
83 | 83 | } |
84 | 84 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | // $this->url = 'https://wetu.com/API/Pins/'; |
96 | 96 | // $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
97 | 97 | //} elseif ( false !== $this->api_key ) { |
98 | - $this->url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
98 | + $this->url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
99 | 99 | $this->url_qs = ''; |
100 | 100 | //} |
101 | 101 | } |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | <form method="get" action="" id="posts-filter"> |
114 | 114 | <input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" /> |
115 | 115 | |
116 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
117 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
116 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
117 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
118 | 118 | </p> |
119 | 119 | |
120 | 120 | <table class="wp-list-table widefat fixed posts"> |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | <tbody id="the-list"> |
124 | 124 | <tr class="post-0 type-tour status-none" id="post-0"> |
125 | 125 | <th class="check-column" scope="row"> |
126 | - <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label> |
|
126 | + <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label> |
|
127 | 127 | </th> |
128 | 128 | <td class="post-title page-title column-title"> |
129 | 129 | <strong> |
130 | - <?php _e('Enter a title to search for','wetu-importer'); ?> |
|
130 | + <?php _e('Enter a title to search for', 'wetu-importer'); ?> |
|
131 | 131 | </strong> |
132 | 132 | </td> |
133 | 133 | <td class="date column-date"> |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | |
142 | 142 | </table> |
143 | 143 | |
144 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
145 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
144 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
145 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
146 | 146 | </p> |
147 | 147 | </form> |
148 | 148 | |
@@ -154,39 +154,39 @@ discard block |
||
154 | 154 | <div style="width:30%;display:block;float:left;"> |
155 | 155 | <h3><?php _e('What content to Sync from WETU'); ?></h3> |
156 | 156 | <ul> |
157 | - <li><input class="content" <?php $this->checked($this->destination_options,'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
158 | - <li><input class="content" <?php $this->checked($this->destination_options,'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li> |
|
159 | - <li><input class="content" <?php $this->checked($this->destination_options,'gallery'); ?> type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery','wetu-importer'); ?></li> |
|
160 | - <?php if(class_exists('TO_Maps')){ ?> |
|
161 | - <li><input class="content" <?php $this->checked($this->destination_options,'location'); ?> type="checkbox" name="content[]" value="location" /> <?php _e('Location','wetu-importer'); ?></li> |
|
157 | + <li><input class="content" <?php $this->checked($this->destination_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
158 | + <li><input class="content" <?php $this->checked($this->destination_options, 'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li> |
|
159 | + <li><input class="content" <?php $this->checked($this->destination_options, 'gallery'); ?> type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery', 'wetu-importer'); ?></li> |
|
160 | + <?php if (class_exists('TO_Maps')) { ?> |
|
161 | + <li><input class="content" <?php $this->checked($this->destination_options, 'location'); ?> type="checkbox" name="content[]" value="location" /> <?php _e('Location', 'wetu-importer'); ?></li> |
|
162 | 162 | <?php } ?> |
163 | 163 | |
164 | - <?php if(class_exists('TO_Videos')){ ?> |
|
165 | - <li><input class="content" <?php $this->checked($this->destination_options,'videos'); ?> type="checkbox" name="content[]" value="videos" /> <?php _e('Videos','wetu-importer'); ?></li> |
|
164 | + <?php if (class_exists('TO_Videos')) { ?> |
|
165 | + <li><input class="content" <?php $this->checked($this->destination_options, 'videos'); ?> type="checkbox" name="content[]" value="videos" /> <?php _e('Videos', 'wetu-importer'); ?></li> |
|
166 | 166 | <?php } ?> |
167 | 167 | |
168 | 168 | </ul> |
169 | 169 | <h4><?php _e('Additional Content'); ?></h4> |
170 | 170 | <ul> |
171 | - <li><input class="content" <?php $this->checked($this->destination_options,'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image','wetu-importer'); ?></li> |
|
172 | - <?php if(class_exists('LSX_Banners')){ ?> |
|
173 | - <li><input class="content" <?php $this->checked($this->destination_options,'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image','wetu-importer'); ?></li> |
|
171 | + <li><input class="content" <?php $this->checked($this->destination_options, 'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image', 'wetu-importer'); ?></li> |
|
172 | + <?php if (class_exists('LSX_Banners')) { ?> |
|
173 | + <li><input class="content" <?php $this->checked($this->destination_options, 'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image', 'wetu-importer'); ?></li> |
|
174 | 174 | <?php } ?> |
175 | 175 | </ul> |
176 | 176 | </div> |
177 | 177 | <div style="width:30%;display:block;float:left;"> |
178 | 178 | <h3><?php _e('Travel Information'); ?></h3> |
179 | 179 | <ul> |
180 | - <li><input class="content" <?php $this->checked($this->destination_options,'electricity'); ?> type="checkbox" name="content[]" value="electricity" /> <?php _e('Electricity','wetu-importer'); ?></li> |
|
181 | - <li><input class="content" <?php $this->checked($this->destination_options,'banking'); ?> type="checkbox" name="content[]" value="banking" /> <?php _e('Banking','wetu-importer'); ?></li> |
|
182 | - <li><input class="content" <?php $this->checked($this->destination_options,'cuisine'); ?> type="checkbox" name="content[]" value="cuisine" /> <?php _e('Cuisine','wetu-importer'); ?></li> |
|
183 | - <li><input class="content" <?php $this->checked($this->destination_options,'climate'); ?> type="checkbox" name="content[]" value="climate" /> <?php _e('Climate','wetu-importer'); ?></li> |
|
184 | - <li><input class="content" <?php $this->checked($this->destination_options,'transport'); ?> type="checkbox" name="content[]" value="transport" /> <?php _e('Transport','wetu-importer'); ?></li> |
|
185 | - <li><input class="content" <?php $this->checked($this->destination_options,'dress'); ?> type="checkbox" name="content[]" value="dress" /> <?php _e('Dress','wetu-importer'); ?></li> |
|
180 | + <li><input class="content" <?php $this->checked($this->destination_options, 'electricity'); ?> type="checkbox" name="content[]" value="electricity" /> <?php _e('Electricity', 'wetu-importer'); ?></li> |
|
181 | + <li><input class="content" <?php $this->checked($this->destination_options, 'banking'); ?> type="checkbox" name="content[]" value="banking" /> <?php _e('Banking', 'wetu-importer'); ?></li> |
|
182 | + <li><input class="content" <?php $this->checked($this->destination_options, 'cuisine'); ?> type="checkbox" name="content[]" value="cuisine" /> <?php _e('Cuisine', 'wetu-importer'); ?></li> |
|
183 | + <li><input class="content" <?php $this->checked($this->destination_options, 'climate'); ?> type="checkbox" name="content[]" value="climate" /> <?php _e('Climate', 'wetu-importer'); ?></li> |
|
184 | + <li><input class="content" <?php $this->checked($this->destination_options, 'transport'); ?> type="checkbox" name="content[]" value="transport" /> <?php _e('Transport', 'wetu-importer'); ?></li> |
|
185 | + <li><input class="content" <?php $this->checked($this->destination_options, 'dress'); ?> type="checkbox" name="content[]" value="dress" /> <?php _e('Dress', 'wetu-importer'); ?></li> |
|
186 | 186 | </ul> |
187 | 187 | </div> |
188 | 188 | |
189 | - <?php if(class_exists('TO_Team')){ ?> |
|
189 | + <?php if (class_exists('TO_Team')) { ?> |
|
190 | 190 | <div style="width:30%;display:block;float:left;"> |
191 | 191 | <h3><?php _e('Assign a Team Member'); ?></h3> |
192 | 192 | <?php $this->team_member_checkboxes($this->destination_options); ?> |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | |
200 | 200 | <h3><?php _e('Your List'); ?></h3> |
201 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
201 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
202 | 202 | <table class="wp-list-table widefat fixed posts"> |
203 | 203 | <?php $this->table_header(); ?> |
204 | 204 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | |
211 | 211 | </table> |
212 | 212 | |
213 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
213 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
214 | 214 | </form> |
215 | 215 | </div> |
216 | 216 | |
@@ -231,31 +231,31 @@ discard block |
||
231 | 231 | <form class="ajax-form" id="<?php echo $this->plugin_slug; ?>-search-form" method="get" action="tools.php" data-type="<?php echo $this->tab_slug; ?>"> |
232 | 232 | <input type="hidden" name="page" value="<?php echo $this->tab_slug; ?>" /> |
233 | 233 | |
234 | - <h3><span class="dashicons dashicons-search"></span> <?php _e('Search','wetu-importer'); ?></h3> |
|
234 | + <h3><span class="dashicons dashicons-search"></span> <?php _e('Search', 'wetu-importer'); ?></h3> |
|
235 | 235 | <div class="normal-search"> |
236 | - <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" /> |
|
236 | + <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" /> |
|
237 | 237 | </div> |
238 | 238 | |
239 | 239 | |
240 | 240 | <div class="advanced-search hidden" style="display:none;"> |
241 | - <p><?php _e('Enter several keywords, each on a new line.','wetu-importer'); ?></p> |
|
241 | + <p><?php _e('Enter several keywords, each on a new line.', 'wetu-importer'); ?></p> |
|
242 | 242 | <textarea rows="10" cols="40" name="bulk-keywords"></textarea> |
243 | - <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" /> |
|
243 | + <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" /> |
|
244 | 244 | </div> |
245 | 245 | |
246 | 246 | <p> |
247 | - <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search','wetu-importer'); ?></a> | |
|
248 | - <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published','wetu-importer'); ?></a> | |
|
249 | - <a class="pending search-toggle" href="#pending"><?php esc_attr_e('Pending','wetu-importer'); ?></a> | |
|
250 | - <a class="draft search-toggle" href="#draft"><?php esc_attr_e('Draft','wetu-importer'); ?></a> |
|
247 | + <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search', 'wetu-importer'); ?></a> | |
|
248 | + <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published', 'wetu-importer'); ?></a> | |
|
249 | + <a class="pending search-toggle" href="#pending"><?php esc_attr_e('Pending', 'wetu-importer'); ?></a> | |
|
250 | + <a class="draft search-toggle" href="#draft"><?php esc_attr_e('Draft', 'wetu-importer'); ?></a> |
|
251 | 251 | </p> |
252 | 252 | |
253 | 253 | <div class="ajax-loader" style="display:none;width:100%;text-align:center;"> |
254 | - <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" /> |
|
254 | + <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" /> |
|
255 | 255 | </div> |
256 | 256 | |
257 | 257 | <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;"> |
258 | - <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" /> |
|
258 | + <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" /> |
|
259 | 259 | </div> |
260 | 260 | </form> |
261 | 261 | <?php |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | /** |
292 | 292 | * Grab all the current destination posts via the lsx_wetu_id field. |
293 | 293 | */ |
294 | - public function find_current_destination($post_type='destination') { |
|
294 | + public function find_current_destination($post_type = 'destination') { |
|
295 | 295 | global $wpdb; |
296 | 296 | $return = array(); |
297 | 297 | |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | |
308 | 308 | LIMIT 0,500 |
309 | 309 | "); |
310 | - if(null !== $current_destination && !empty($current_destination)){ |
|
311 | - foreach($current_destination as $accom){ |
|
310 | + if (null !== $current_destination && !empty($current_destination)) { |
|
311 | + foreach ($current_destination as $accom) { |
|
312 | 312 | $return[$accom->meta_value] = $accom; |
313 | 313 | } |
314 | 314 | } |
@@ -320,32 +320,32 @@ discard block |
||
320 | 320 | */ |
321 | 321 | public function process_ajax_search() { |
322 | 322 | $return = false; |
323 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'destination'){ |
|
323 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'destination') { |
|
324 | 324 | |
325 | - if ( isset($_POST['keyword'] )) { |
|
325 | + if (isset($_POST['keyword'])) { |
|
326 | 326 | $searched_items = false; |
327 | 327 | |
328 | - if(isset($_POST['keyword'] )) { |
|
328 | + if (isset($_POST['keyword'])) { |
|
329 | 329 | $keyphrases = $_POST['keyword']; |
330 | - }else{ |
|
330 | + }else { |
|
331 | 331 | $keyphrases = array(0); |
332 | 332 | } |
333 | 333 | |
334 | - if(!is_array($keyphrases)){ |
|
334 | + if (!is_array($keyphrases)) { |
|
335 | 335 | $keyphrases = array($keyphrases); |
336 | 336 | } |
337 | - foreach($keyphrases as &$keyword){ |
|
337 | + foreach ($keyphrases as &$keyword) { |
|
338 | 338 | $keyword = ltrim(rtrim($keyword)); |
339 | 339 | } |
340 | 340 | |
341 | 341 | $post_status = false; |
342 | - if(in_array('publish',$keyphrases)){ |
|
342 | + if (in_array('publish', $keyphrases)) { |
|
343 | 343 | $post_status = 'publish'; |
344 | 344 | } |
345 | - if(in_array('pending',$keyphrases)){ |
|
345 | + if (in_array('pending', $keyphrases)) { |
|
346 | 346 | $post_status = 'pending'; |
347 | 347 | } |
348 | - if(in_array('draft',$keyphrases)){ |
|
348 | + if (in_array('draft', $keyphrases)) { |
|
349 | 349 | $post_status = 'draft'; |
350 | 350 | } |
351 | 351 | |
@@ -353,29 +353,29 @@ discard block |
||
353 | 353 | |
354 | 354 | if (!empty($destination)) { |
355 | 355 | |
356 | - foreach($destination as $row){ |
|
356 | + foreach ($destination as $row) { |
|
357 | 357 | |
358 | 358 | //If we are searching for |
359 | - if(false !== $post_status){ |
|
359 | + if (false !== $post_status) { |
|
360 | 360 | |
361 | 361 | $current_status = get_post_status($row->post_id); |
362 | - if($current_status !== $post_status){ |
|
362 | + if ($current_status !== $post_status) { |
|
363 | 363 | continue; |
364 | 364 | } |
365 | 365 | $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row); |
366 | 366 | |
367 | 367 | |
368 | - }else{ |
|
368 | + }else { |
|
369 | 369 | //Search through each keyword. |
370 | - foreach($keyphrases as $keyphrase){ |
|
370 | + foreach ($keyphrases as $keyphrase) { |
|
371 | 371 | |
372 | 372 | //Make sure the keyphrase is turned into an array |
373 | - $keywords = explode(" ",$keyphrase); |
|
374 | - if(!is_array($keywords)){ |
|
373 | + $keywords = explode(" ", $keyphrase); |
|
374 | + if (!is_array($keywords)) { |
|
375 | 375 | $keywords = array($keywords); |
376 | 376 | } |
377 | 377 | |
378 | - if($this->multineedle_stripos(ltrim(rtrim($row->name)), $keywords) !== false){ |
|
378 | + if ($this->multineedle_stripos(ltrim(rtrim($row->name)), $keywords) !== false) { |
|
379 | 379 | $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row); |
380 | 380 | } |
381 | 381 | } |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | } |
384 | 384 | } |
385 | 385 | |
386 | - if(false !== $searched_items){ |
|
386 | + if (false !== $searched_items) { |
|
387 | 387 | ksort($searched_items); |
388 | 388 | $return = implode($searched_items); |
389 | 389 | } |
@@ -396,11 +396,11 @@ discard block |
||
396 | 396 | /** |
397 | 397 | * Formats the row for output on the screen. |
398 | 398 | */ |
399 | - public function format_row($row = false){ |
|
400 | - if(false !== $row){ |
|
399 | + public function format_row($row = false) { |
|
400 | + if (false !== $row) { |
|
401 | 401 | |
402 | 402 | $status = 'import'; |
403 | - if(0 !== $row->post_id){ |
|
403 | + if (0 !== $row->post_id) { |
|
404 | 404 | $status = '<a href="'.admin_url('/post.php?post='.$row->post_id.'&action=edit').'" target="_blank">'.get_post_status($row->post_id).'</a>'; |
405 | 405 | } |
406 | 406 | |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | <strong>'.$row->name.'</strong> - '.$status.' |
415 | 415 | </td> |
416 | 416 | <td class="date column-date"> |
417 | - <abbr title="'.date('Y/m/d',strtotime($row->last_modified)).'">'.date('Y/m/d',strtotime($row->last_modified)).'</abbr><br>Last Modified |
|
417 | + <abbr title="'.date('Y/m/d', strtotime($row->last_modified)).'">'.date('Y/m/d', strtotime($row->last_modified)).'</abbr><br>Last Modified |
|
418 | 418 | </td> |
419 | 419 | <td class="ssid column-ssid"> |
420 | 420 | '.$row->meta_value.' |
@@ -429,38 +429,38 @@ discard block |
||
429 | 429 | */ |
430 | 430 | public function process_ajax_import() { |
431 | 431 | $return = false; |
432 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'destination' && isset($_POST['wetu_id'])){ |
|
432 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'destination' && isset($_POST['wetu_id'])) { |
|
433 | 433 | |
434 | 434 | $wetu_id = $_POST['wetu_id']; |
435 | - if(isset($_POST['post_id'])){ |
|
435 | + if (isset($_POST['post_id'])) { |
|
436 | 436 | $post_id = $_POST['post_id']; |
437 | - }else{ |
|
437 | + }else { |
|
438 | 438 | $post_id = 0; |
439 | 439 | } |
440 | 440 | |
441 | - if(isset($_POST['team_members'])){ |
|
441 | + if (isset($_POST['team_members'])) { |
|
442 | 442 | $team_members = $_POST['team_members']; |
443 | - }else{ |
|
443 | + }else { |
|
444 | 444 | $team_members = false; |
445 | 445 | } |
446 | 446 | |
447 | 447 | $safari_brands = false; |
448 | 448 | |
449 | - if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
|
449 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
450 | 450 | $content = $_POST['content']; |
451 | - add_option('wetu_importer_destination_settings',$content); |
|
452 | - }else{ |
|
451 | + add_option('wetu_importer_destination_settings', $content); |
|
452 | + }else { |
|
453 | 453 | delete_option('wetu_importer_destination_settings'); |
454 | 454 | $content = false; |
455 | 455 | } |
456 | 456 | |
457 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
458 | - if($jdata) |
|
457 | + $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id); |
|
458 | + if ($jdata) |
|
459 | 459 | { |
460 | - $adata=json_decode($jdata,true); |
|
461 | - if(!empty($adata)) |
|
460 | + $adata = json_decode($jdata, true); |
|
461 | + if (!empty($adata)) |
|
462 | 462 | { |
463 | - $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
463 | + $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
|
464 | 464 | $this->format_completed_row($return); |
465 | 465 | } |
466 | 466 | } |
@@ -473,9 +473,9 @@ discard block |
||
473 | 473 | /** |
474 | 474 | * Connect to wetu |
475 | 475 | */ |
476 | - public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) { |
|
476 | + public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false) { |
|
477 | 477 | |
478 | - if(trim($data[0]['type'])=='Destination') |
|
478 | + if (trim($data[0]['type']) == 'Destination') |
|
479 | 479 | { |
480 | 480 | $post_name = $data_post_content = $data_post_excerpt = ''; |
481 | 481 | $post = array( |
@@ -485,46 +485,46 @@ discard block |
||
485 | 485 | $content_used_general_description = false; |
486 | 486 | |
487 | 487 | //Set the post_content |
488 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
489 | - if(isset($data[0]['content']['extended_description'])) |
|
488 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
489 | + if (isset($data[0]['content']['extended_description'])) |
|
490 | 490 | { |
491 | 491 | $data_post_content = $data[0]['content']['extended_description']; |
492 | - }elseif(isset($data[0]['content']['general_description'])){ |
|
492 | + }elseif (isset($data[0]['content']['general_description'])) { |
|
493 | 493 | $data_post_content = $data[0]['content']['general_description']; |
494 | 494 | $content_used_general_description = true; |
495 | - }elseif(isset($data[0]['content']['teaser_description'])){ |
|
495 | + }elseif (isset($data[0]['content']['teaser_description'])) { |
|
496 | 496 | $data_post_content = $data[0]['content']['teaser_description']; |
497 | 497 | } |
498 | 498 | $post['post_content'] = wp_strip_all_tags($data_post_content); |
499 | 499 | } |
500 | 500 | |
501 | 501 | //set the post_excerpt |
502 | - if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
503 | - if(isset($data[0]['content']['teaser_description'])){ |
|
502 | + if (false !== $importable_content && in_array('excerpt', $importable_content)) { |
|
503 | + if (isset($data[0]['content']['teaser_description'])) { |
|
504 | 504 | $data_post_excerpt = $data[0]['content']['teaser_description']; |
505 | - }elseif(isset($data[0]['content']['extended_description'])){ |
|
505 | + }elseif (isset($data[0]['content']['extended_description'])) { |
|
506 | 506 | $data_post_excerpt = $data[0]['content']['extended_description']; |
507 | - }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
507 | + }elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) { |
|
508 | 508 | $data_post_excerpt = $data[0]['content']['general_description']; |
509 | 509 | } |
510 | 510 | $post['post_excerpt'] = $data_post_excerpt; |
511 | 511 | } |
512 | 512 | |
513 | - if(false !== $id && '0' !== $id){ |
|
513 | + if (false !== $id && '0' !== $id) { |
|
514 | 514 | $post['ID'] = $id; |
515 | - if(isset($data[0]['name'])){ |
|
515 | + if (isset($data[0]['name'])) { |
|
516 | 516 | $post['post_title'] = $data[0]['name']; |
517 | 517 | $post['post_status'] = 'publish'; |
518 | - $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0); |
|
518 | + $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0); |
|
519 | 519 | } |
520 | 520 | $id = wp_update_post($post); |
521 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
522 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
523 | - }else{ |
|
521 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
522 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date); |
|
523 | + }else { |
|
524 | 524 | |
525 | 525 | //Set the name |
526 | - if(isset($data[0]['name'])){ |
|
527 | - $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0); |
|
526 | + if (isset($data[0]['name'])) { |
|
527 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0); |
|
528 | 528 | } |
529 | 529 | $post['post_name'] = $post_name; |
530 | 530 | $post['post_title'] = $data[0]['name']; |
@@ -532,61 +532,61 @@ discard block |
||
532 | 532 | $id = wp_insert_post($post); |
533 | 533 | |
534 | 534 | //Save the WETU ID and the Last date it was modified. |
535 | - if(false !== $id){ |
|
536 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
537 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
535 | + if (false !== $id) { |
|
536 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
537 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified'])); |
|
538 | 538 | } |
539 | 539 | } |
540 | 540 | |
541 | 541 | //Set the team member if it is there |
542 | - if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
543 | - $this->set_team_member($id,$team_members); |
|
542 | + if (post_type_exists('team') && false !== $team_members && '' !== $team_members) { |
|
543 | + $this->set_team_member($id, $team_members); |
|
544 | 544 | } |
545 | 545 | |
546 | - if(class_exists('LSX_TO_Maps')){ |
|
547 | - $this->set_map_data($data,$id); |
|
546 | + if (class_exists('LSX_TO_Maps')) { |
|
547 | + $this->set_map_data($data, $id); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | //Set the Room Data |
551 | - if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
552 | - $this->set_video_data($data,$id); |
|
551 | + if (false !== $importable_content && in_array('videos', $importable_content)) { |
|
552 | + $this->set_video_data($data, $id); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | //Set the Electricity |
556 | - if(false !== $importable_content && in_array('electricity',$importable_content)){ |
|
557 | - $this->set_travel_info($data,$id,'electricity'); |
|
556 | + if (false !== $importable_content && in_array('electricity', $importable_content)) { |
|
557 | + $this->set_travel_info($data, $id, 'electricity'); |
|
558 | 558 | } |
559 | 559 | //Set the cuisine |
560 | - if(false !== $importable_content && in_array('cuisine',$importable_content)){ |
|
561 | - $this->set_travel_info($data,$id,'cuisine'); |
|
560 | + if (false !== $importable_content && in_array('cuisine', $importable_content)) { |
|
561 | + $this->set_travel_info($data, $id, 'cuisine'); |
|
562 | 562 | } |
563 | 563 | //Set the banking |
564 | - if(false !== $importable_content && in_array('banking',$importable_content)){ |
|
565 | - $this->set_travel_info($data,$id,'banking'); |
|
564 | + if (false !== $importable_content && in_array('banking', $importable_content)) { |
|
565 | + $this->set_travel_info($data, $id, 'banking'); |
|
566 | 566 | } |
567 | 567 | //Set the transport |
568 | - if(false !== $importable_content && in_array('transport',$importable_content)){ |
|
569 | - $this->set_travel_info($data,$id,'transport'); |
|
568 | + if (false !== $importable_content && in_array('transport', $importable_content)) { |
|
569 | + $this->set_travel_info($data, $id, 'transport'); |
|
570 | 570 | } |
571 | 571 | //Set the dress |
572 | - if(false !== $importable_content && in_array('dress',$importable_content)){ |
|
573 | - $this->set_travel_info($data,$id,'dress'); |
|
572 | + if (false !== $importable_content && in_array('dress', $importable_content)) { |
|
573 | + $this->set_travel_info($data, $id, 'dress'); |
|
574 | 574 | } |
575 | 575 | //Set the climate |
576 | - if(false !== $importable_content && in_array('climate',$importable_content)){ |
|
577 | - $this->set_travel_info($data,$id,'climate'); |
|
576 | + if (false !== $importable_content && in_array('climate', $importable_content)) { |
|
577 | + $this->set_travel_info($data, $id, 'climate'); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | //Set the featured image |
581 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
582 | - $this->set_featured_image($data,$id); |
|
581 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
582 | + $this->set_featured_image($data, $id); |
|
583 | 583 | } |
584 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
585 | - $this->set_banner_image($data,$id); |
|
584 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
585 | + $this->set_banner_image($data, $id); |
|
586 | 586 | } |
587 | 587 | //Import the main gallery |
588 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
589 | - $this->create_main_gallery($data,$id); |
|
588 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
589 | + $this->create_main_gallery($data, $id); |
|
590 | 590 | } |
591 | 591 | } |
592 | 592 | return $id; |
@@ -595,54 +595,54 @@ discard block |
||
595 | 595 | /** |
596 | 596 | * Set the team memberon each item. |
597 | 597 | */ |
598 | - public function set_team_member($id,$team_members) { |
|
598 | + public function set_team_member($id, $team_members) { |
|
599 | 599 | |
600 | 600 | delete_post_meta($id, 'team_to_'.$this->tab_slug); |
601 | - foreach($team_members as $team){ |
|
602 | - add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
601 | + foreach ($team_members as $team) { |
|
602 | + add_post_meta($id, 'team_to_'.$this->tab_slug, $team); |
|
603 | 603 | } |
604 | 604 | } |
605 | 605 | |
606 | 606 | /** |
607 | 607 | * Saves the longitude and lattitude, as well as sets the map marker. |
608 | 608 | */ |
609 | - public function set_map_data($data,$id) { |
|
609 | + public function set_map_data($data, $id) { |
|
610 | 610 | $longitude = $latitude = $address = false; |
611 | 611 | $zoom = '15'; |
612 | 612 | |
613 | - if(isset($data[0]['position'])){ |
|
613 | + if (isset($data[0]['position'])) { |
|
614 | 614 | |
615 | - if(isset($data[0]['position']['driving_latitude'])){ |
|
615 | + if (isset($data[0]['position']['driving_latitude'])) { |
|
616 | 616 | $latitude = $data[0]['position']['driving_latitude']; |
617 | - }elseif(isset($data[0]['position']['latitude'])){ |
|
617 | + }elseif (isset($data[0]['position']['latitude'])) { |
|
618 | 618 | $latitude = $data[0]['position']['latitude']; |
619 | 619 | } |
620 | 620 | |
621 | - if(isset($data[0]['position']['driving_longitude'])){ |
|
621 | + if (isset($data[0]['position']['driving_longitude'])) { |
|
622 | 622 | $longitude = $data[0]['position']['driving_longitude']; |
623 | - }elseif(isset($data[0]['position']['longitude'])){ |
|
623 | + }elseif (isset($data[0]['position']['longitude'])) { |
|
624 | 624 | $longitude = $data[0]['position']['longitude']; |
625 | 625 | } |
626 | 626 | |
627 | 627 | } |
628 | - if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){ |
|
629 | - if(isset($data[0]['content']['contact_information']['address'])){ |
|
628 | + if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) { |
|
629 | + if (isset($data[0]['content']['contact_information']['address'])) { |
|
630 | 630 | $address = strip_tags($data[0]['content']['contact_information']['address']); |
631 | 631 | |
632 | - $address = explode("\n",$address); |
|
633 | - foreach($address as $bitkey => $bit){ |
|
632 | + $address = explode("\n", $address); |
|
633 | + foreach ($address as $bitkey => $bit) { |
|
634 | 634 | $bit = ltrim(rtrim($bit)); |
635 | - if(false === $bit || '' === $bit || null === $bit or empty($bit)){ |
|
635 | + if (false === $bit || '' === $bit || null === $bit or empty($bit)) { |
|
636 | 636 | unset($address[$bitkey]); |
637 | 637 | } |
638 | 638 | } |
639 | - $address = implode(', ',$address); |
|
639 | + $address = implode(', ', $address); |
|
640 | 640 | $address = str_replace(', , ', ', ', $address); |
641 | 641 | } |
642 | 642 | } |
643 | 643 | |
644 | 644 | |
645 | - if(false !== $longitude){ |
|
645 | + if (false !== $longitude) { |
|
646 | 646 | $location_data = array( |
647 | 647 | 'address' => $address, |
648 | 648 | 'lat' => $latitude, |
@@ -650,11 +650,11 @@ discard block |
||
650 | 650 | 'zoom' => $zoom, |
651 | 651 | 'elevation' => '', |
652 | 652 | ); |
653 | - if(false !== $id && '0' !== $id){ |
|
654 | - $prev = get_post_meta($id,'location',true); |
|
655 | - update_post_meta($id,'location',$location_data,$prev); |
|
656 | - }else{ |
|
657 | - add_post_meta($id,'location',$location_data,true); |
|
653 | + if (false !== $id && '0' !== $id) { |
|
654 | + $prev = get_post_meta($id, 'location', true); |
|
655 | + update_post_meta($id, 'location', $location_data, $prev); |
|
656 | + }else { |
|
657 | + add_post_meta($id, 'location', $location_data, true); |
|
658 | 658 | } |
659 | 659 | } |
660 | 660 | } |
@@ -662,11 +662,11 @@ discard block |
||
662 | 662 | /** |
663 | 663 | * Saves the room data |
664 | 664 | */ |
665 | - public function set_travel_info($data,$id,$meta_key) { |
|
665 | + public function set_travel_info($data, $id, $meta_key) { |
|
666 | 666 | |
667 | - if(!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])){ |
|
667 | + if (!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])) { |
|
668 | 668 | $content = $data[0]['travel_information'][$meta_key]; |
669 | - $this->save_custom_field($content,$meta_key,$id); |
|
669 | + $this->save_custom_field($content, $meta_key, $id); |
|
670 | 670 | } |
671 | 671 | } |
672 | 672 |
@@ -82,20 +82,20 @@ discard block |
||
82 | 82 | public function __construct() { |
83 | 83 | $this->set_variables(); |
84 | 84 | |
85 | - add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') ); |
|
86 | - add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search')); |
|
87 | - add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search')); |
|
85 | + add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page')); |
|
86 | + add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
87 | + add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
88 | 88 | |
89 | - add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import')); |
|
90 | - add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import')); |
|
89 | + add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import')); |
|
90 | + add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import')); |
|
91 | 91 | |
92 | - $temp_options = get_option('_lsx-to_settings',false); |
|
93 | - if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){ |
|
92 | + $temp_options = get_option('_lsx-to_settings', false); |
|
93 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
94 | 94 | $this->options = $temp_options[$this->plugin_slug]; |
95 | 95 | } |
96 | 96 | |
97 | - $tour_options = get_option('wetu_importer_tour_settings',false); |
|
98 | - if(false !== $tour_options){ |
|
97 | + $tour_options = get_option('wetu_importer_tour_settings', false); |
|
98 | + if (false !== $tour_options) { |
|
99 | 99 | $this->tour_options = $tour_options; |
100 | 100 | } |
101 | 101 | } |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | { |
108 | 108 | parent::set_variables(); |
109 | 109 | |
110 | - if ( false !== $this->api_username && false !== $this->api_password ) { |
|
110 | + if (false !== $this->api_username && false !== $this->api_password) { |
|
111 | 111 | $this->url = 'https://wetu.com/API/Itinerary/'; |
112 | - $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
|
113 | - } elseif ( false !== $this->api_key ) { |
|
114 | - $this->url = 'https://wetu.com/API/Itinerary/' . $this->api_key; |
|
112 | + $this->url_qs = 'username='.$this->api_username.'&password='.$this->api_password; |
|
113 | + } elseif (false !== $this->api_key) { |
|
114 | + $this->url = 'https://wetu.com/API/Itinerary/'.$this->api_key; |
|
115 | 115 | $this->url_qs = ''; |
116 | 116 | } |
117 | 117 | } |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | <form method="get" action="" id="posts-filter"> |
132 | 132 | <input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" /> |
133 | 133 | |
134 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
135 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
134 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
135 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
136 | 136 | </p> |
137 | 137 | |
138 | 138 | <table class="wp-list-table widefat fixed posts"> |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | <tbody id="the-list"> |
142 | 142 | <tr class="post-0 type-tour status-none" id="post-0"> |
143 | 143 | <th class="check-column" scope="row"> |
144 | - <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label> |
|
144 | + <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label> |
|
145 | 145 | </th> |
146 | 146 | <td class="post-title page-title column-title"> |
147 | 147 | <strong> |
148 | - <?php _e('Enter a title to search for','wetu-importer'); ?> |
|
148 | + <?php _e('Enter a title to search for', 'wetu-importer'); ?> |
|
149 | 149 | </strong> |
150 | 150 | </td> |
151 | 151 | <td class="date column-date"> |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | |
160 | 160 | </table> |
161 | 161 | |
162 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
163 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
162 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
163 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
164 | 164 | </p> |
165 | 165 | </form> |
166 | 166 | |
@@ -172,36 +172,36 @@ discard block |
||
172 | 172 | <div style="width:30%;display:block;float:left;"> |
173 | 173 | <h3><?php _e('What content to Sync from WETU'); ?></h3> |
174 | 174 | <ul> |
175 | - <li><input class="content" <?php $this->checked($this->tour_options,'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
176 | - <li><input class="content" <?php $this->checked($this->tour_options,'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li> |
|
175 | + <li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
176 | + <li><input class="content" <?php $this->checked($this->tour_options, 'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li> |
|
177 | 177 | |
178 | - <li><input class="content" <?php $this->checked($this->tour_options,'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price','wetu-importer'); ?></li> |
|
179 | - <li><input class="content" <?php $this->checked($this->tour_options,'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration','wetu-importer'); ?></li> |
|
178 | + <li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price', 'wetu-importer'); ?></li> |
|
179 | + <li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration', 'wetu-importer'); ?></li> |
|
180 | 180 | |
181 | - <li><input class="content" <?php $this->checked($this->tour_options,'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li> |
|
181 | + <li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li> |
|
182 | 182 | |
183 | - <li><input class="content" <?php $this->checked($this->tour_options,'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days','wetu-importer'); ?></li> |
|
183 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days', 'wetu-importer'); ?></li> |
|
184 | 184 | |
185 | - <?php if(class_exists('TO_Maps')){ ?> |
|
186 | - <li><input class="content" <?php $this->checked($this->tour_options,'map'); ?> type="checkbox" name="content[]" value="map" /> <?php _e('Map Coordinates (generates a KML file)','wetu-importer'); ?></li> |
|
185 | + <?php if (class_exists('TO_Maps')) { ?> |
|
186 | + <li><input class="content" <?php $this->checked($this->tour_options, 'map'); ?> type="checkbox" name="content[]" value="map" /> <?php _e('Map Coordinates (generates a KML file)', 'wetu-importer'); ?></li> |
|
187 | 187 | <?php } ?> |
188 | 188 | </ul> |
189 | 189 | </div> |
190 | 190 | <div style="width:30%;display:block;float:left;"> |
191 | 191 | <h3><?php _e('Itinerary Info'); ?></h3> |
192 | 192 | <ul> |
193 | - <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
194 | - <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included','wetu-importer'); ?></li> |
|
195 | - <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded','wetu-importer'); ?></li> |
|
193 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
194 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included', 'wetu-importer'); ?></li> |
|
195 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded', 'wetu-importer'); ?></li> |
|
196 | 196 | </ul> |
197 | 197 | |
198 | 198 | <h4><?php _e('Additional Content'); ?></h4> |
199 | 199 | <ul> |
200 | - <li><input class="content" <?php $this->checked($this->tour_options,'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation','wetu-importer'); ?></li> |
|
201 | - <li><input class="content" <?php $this->checked($this->tour_options,'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations','wetu-importer'); ?></li> |
|
200 | + <li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation', 'wetu-importer'); ?></li> |
|
201 | + <li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations', 'wetu-importer'); ?></li> |
|
202 | 202 | </ul> |
203 | 203 | </div> |
204 | - <?php if(class_exists('TO_Team')){ ?> |
|
204 | + <?php if (class_exists('TO_Team')) { ?> |
|
205 | 205 | <div style="width:30%;display:block;float:left;"> |
206 | 206 | <h3><?php _e('Assign a Team Member'); ?></h3> |
207 | 207 | <?php $this->team_member_checkboxes($this->tour_options); ?> |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | |
215 | 215 | <h3><?php _e('Your List'); ?></h3> |
216 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
216 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
217 | 217 | <table class="wp-list-table widefat fixed posts"> |
218 | 218 | <?php $this->table_header(); ?> |
219 | 219 | |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | |
226 | 226 | </table> |
227 | 227 | |
228 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
228 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
229 | 229 | </form> |
230 | 230 | </div> |
231 | 231 | |
232 | 232 | <div style="display:none;" class="completed-list-wrapper"> |
233 | - <h3><?php _e('Completed','wetu-importer'); ?> - <small><?php _e('Import your','wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next','wetu-importer'); ?></small></h3> |
|
233 | + <h3><?php _e('Completed', 'wetu-importer'); ?> - <small><?php _e('Import your', 'wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next', 'wetu-importer'); ?></small></h3> |
|
234 | 234 | <ul> |
235 | 235 | </ul> |
236 | 236 | </div> |
@@ -243,17 +243,17 @@ discard block |
||
243 | 243 | */ |
244 | 244 | public function update_options_form() { |
245 | 245 | $tours = get_transient('lsx_ti_tours'); |
246 | - echo '<div class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').' - '; |
|
247 | - if('' === $tours || false === $tours || isset($_GET['refresh_tours'])){ |
|
246 | + echo '<div class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').' - '; |
|
247 | + if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) { |
|
248 | 248 | $result = $this->update_options(); |
249 | 249 | |
250 | - if(true === $result){ |
|
251 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
252 | - }else{ |
|
250 | + if (true === $result) { |
|
251 | + echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>'; |
|
252 | + }else { |
|
253 | 253 | echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
254 | 254 | } |
255 | - }else{ |
|
256 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
255 | + }else { |
|
256 | + echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>'; |
|
257 | 257 | } |
258 | 258 | echo '</h3></div>'; |
259 | 259 | } |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | * Save the list of Tours into an option |
263 | 263 | */ |
264 | 264 | public function update_options() { |
265 | - $data = file_get_contents( $this->url . '/V7/List?' . $this->url_qs . '&own=true&type=All' ); |
|
265 | + $data = file_get_contents($this->url.'/V7/List?'.$this->url_qs.'&own=true&type=All'); |
|
266 | 266 | $tours = json_decode($data, true); |
267 | 267 | |
268 | - if(isset($tours['error'])){ |
|
268 | + if (isset($tours['error'])) { |
|
269 | 269 | return $tours['error']; |
270 | 270 | }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
271 | - set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2); |
|
271 | + set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2); |
|
272 | 272 | return true; |
273 | 273 | } |
274 | 274 | } |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | |
293 | 293 | LIMIT 0,500 |
294 | 294 | "); |
295 | - if(null !== $current_tours && !empty($current_tours)){ |
|
296 | - foreach($current_tours as $tour){ |
|
295 | + if (null !== $current_tours && !empty($current_tours)) { |
|
296 | + foreach ($current_tours as $tour) { |
|
297 | 297 | $return[$tour->meta_value] = $tour; |
298 | 298 | } |
299 | 299 | } |
@@ -306,36 +306,36 @@ discard block |
||
306 | 306 | public function process_ajax_search() { |
307 | 307 | $return = false; |
308 | 308 | |
309 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug){ |
|
309 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) { |
|
310 | 310 | $tours = get_transient('lsx_ti_tours'); |
311 | - if ( false !== $tours) { |
|
311 | + if (false !== $tours) { |
|
312 | 312 | |
313 | 313 | $searched_items = false; |
314 | 314 | |
315 | - if(isset($_POST['keyword'] )) { |
|
315 | + if (isset($_POST['keyword'])) { |
|
316 | 316 | $keyphrases = $_POST['keyword']; |
317 | - }else{ |
|
317 | + }else { |
|
318 | 318 | $keyphrases = array(0); |
319 | 319 | } |
320 | 320 | |
321 | - if(!is_array($keyphrases)){ |
|
321 | + if (!is_array($keyphrases)) { |
|
322 | 322 | $keyphrases = array($keyphrases); |
323 | 323 | } |
324 | - foreach($keyphrases as &$keyword){ |
|
324 | + foreach ($keyphrases as &$keyword) { |
|
325 | 325 | $keyword = ltrim(rtrim($keyword)); |
326 | 326 | } |
327 | 327 | |
328 | 328 | $post_status = false; |
329 | - if(in_array('publish',$keyphrases)){ |
|
329 | + if (in_array('publish', $keyphrases)) { |
|
330 | 330 | $post_status = 'publish'; |
331 | 331 | } |
332 | - if(in_array('pending',$keyphrases)){ |
|
332 | + if (in_array('pending', $keyphrases)) { |
|
333 | 333 | $post_status = 'pending'; |
334 | 334 | } |
335 | - if(in_array('draft',$keyphrases)){ |
|
335 | + if (in_array('draft', $keyphrases)) { |
|
336 | 336 | $post_status = 'draft'; |
337 | 337 | } |
338 | - if(in_array('import',$keyphrases)){ |
|
338 | + if (in_array('import', $keyphrases)) { |
|
339 | 339 | $post_status = 'import'; |
340 | 340 | } |
341 | 341 | |
@@ -343,9 +343,9 @@ discard block |
||
343 | 343 | if (!empty($tours)) { |
344 | 344 | $current_tours = $this->find_current_tours(); |
345 | 345 | |
346 | - foreach($tours as $row_key => $row){ |
|
346 | + foreach ($tours as $row_key => $row) { |
|
347 | 347 | |
348 | - if(isset($row['is_disabled']) && true === $row['is_disabled']){ |
|
348 | + if (isset($row['is_disabled']) && true === $row['is_disabled']) { |
|
349 | 349 | continue; |
350 | 350 | } |
351 | 351 | |
@@ -355,29 +355,29 @@ discard block |
||
355 | 355 | |
356 | 356 | //If this is a current tour, add its ID to the row. |
357 | 357 | $row['post_id'] = 0; |
358 | - if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){ |
|
358 | + if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) { |
|
359 | 359 | $row['post_id'] = $current_tours[$row['identifier']]->post_id; |
360 | 360 | } |
361 | 361 | |
362 | 362 | //If we are searching for |
363 | - if(false !== $post_status){ |
|
363 | + if (false !== $post_status) { |
|
364 | 364 | |
365 | - if('import' === $post_status){ |
|
365 | + if ('import' === $post_status) { |
|
366 | 366 | |
367 | - if(0 !== $row['post_id']){ |
|
367 | + if (0 !== $row['post_id']) { |
|
368 | 368 | continue; |
369 | - }else{ |
|
369 | + }else { |
|
370 | 370 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
371 | 371 | } |
372 | 372 | |
373 | 373 | |
374 | - }else{ |
|
374 | + }else { |
|
375 | 375 | |
376 | - if(0 === $row['post_id']){ |
|
376 | + if (0 === $row['post_id']) { |
|
377 | 377 | continue; |
378 | - }else{ |
|
378 | + }else { |
|
379 | 379 | $current_status = get_post_status($row['post_id']); |
380 | - if($current_status !== $post_status){ |
|
380 | + if ($current_status !== $post_status) { |
|
381 | 381 | continue; |
382 | 382 | } |
383 | 383 | |
@@ -386,17 +386,17 @@ discard block |
||
386 | 386 | |
387 | 387 | } |
388 | 388 | |
389 | - }else{ |
|
389 | + }else { |
|
390 | 390 | //Search through each keyword. |
391 | - foreach($keyphrases as $keyphrase){ |
|
391 | + foreach ($keyphrases as $keyphrase) { |
|
392 | 392 | |
393 | 393 | //Make sure the keyphrase is turned into an array |
394 | - $keywords = explode(" ",$keyphrase); |
|
395 | - if(!is_array($keywords)){ |
|
394 | + $keywords = explode(" ", $keyphrase); |
|
395 | + if (!is_array($keywords)) { |
|
396 | 396 | $keywords = array($keywords); |
397 | 397 | } |
398 | 398 | |
399 | - if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){ |
|
399 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
400 | 400 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
401 | 401 | } |
402 | 402 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
407 | - if(false !== $searched_items){ |
|
407 | + if (false !== $searched_items) { |
|
408 | 408 | ksort($searched_items); |
409 | 409 | $return = implode($searched_items); |
410 | 410 | } |
@@ -417,11 +417,11 @@ discard block |
||
417 | 417 | /** |
418 | 418 | * Formats the row for output on the screen. |
419 | 419 | */ |
420 | - public function format_row($row = false){ |
|
421 | - if(false !== $row){ |
|
420 | + public function format_row($row = false) { |
|
421 | + if (false !== $row) { |
|
422 | 422 | |
423 | 423 | $status = 'import'; |
424 | - if(0 !== $row['post_id']){ |
|
424 | + if (0 !== $row['post_id']) { |
|
425 | 425 | $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
426 | 426 | } |
427 | 427 | |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | <strong>'.$row['name'].'</strong> - '.$status.' |
436 | 436 | </td> |
437 | 437 | <td class="date column-date"> |
438 | - <abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
438 | + <abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
439 | 439 | </td> |
440 | 440 | <td class="ssid column-ssid"> |
441 | 441 | '.$row['identifier'].' |
@@ -450,31 +450,31 @@ discard block |
||
450 | 450 | */ |
451 | 451 | public function process_ajax_import($force = false) { |
452 | 452 | $return = false; |
453 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])){ |
|
453 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) { |
|
454 | 454 | |
455 | 455 | $wetu_id = $_POST['wetu_id']; |
456 | - if(isset($_POST['post_id'])){ |
|
456 | + if (isset($_POST['post_id'])) { |
|
457 | 457 | $post_id = $_POST['post_id']; |
458 | - }else{ |
|
458 | + }else { |
|
459 | 459 | $post_id = 0; |
460 | 460 | } |
461 | 461 | |
462 | - if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
|
462 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
463 | 463 | $content = $_POST['content']; |
464 | - add_option('wetu_importer_tour_settings',$content); |
|
465 | - }else{ |
|
464 | + add_option('wetu_importer_tour_settings', $content); |
|
465 | + }else { |
|
466 | 466 | delete_option('wetu_importer_tour_settings'); |
467 | 467 | $content = false; |
468 | 468 | } |
469 | 469 | |
470 | - $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
470 | + $jdata = file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
471 | 471 | |
472 | - if($jdata) |
|
472 | + if ($jdata) |
|
473 | 473 | { |
474 | - $jdata=json_decode($jdata,true); |
|
475 | - if(!empty($jdata)) |
|
474 | + $jdata = json_decode($jdata, true); |
|
475 | + if (!empty($jdata)) |
|
476 | 476 | { |
477 | - $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
477 | + $return = $this->import_row($jdata, $wetu_id, $post_id, $content); |
|
478 | 478 | $this->format_completed_row($return); |
479 | 479 | } |
480 | 480 | } |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | * @param $data array |
490 | 490 | * @param $wetu_id string |
491 | 491 | */ |
492 | - public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) { |
|
492 | + public function import_row($data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false) { |
|
493 | 493 | $post_name = $data_post_content = $data_post_excerpt = ''; |
494 | 494 | $post = array( |
495 | 495 | 'post_type' => 'tour', |
@@ -497,29 +497,29 @@ discard block |
||
497 | 497 | |
498 | 498 | //Set the post_content |
499 | 499 | $content_used_general_description = false; |
500 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
500 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
501 | 501 | $data_post_content = ''; |
502 | 502 | |
503 | - if(isset($data['description'])){ |
|
503 | + if (isset($data['description'])) { |
|
504 | 504 | $data_post_content = $data['description']; |
505 | - }elseif(isset($data['summary'])){ |
|
505 | + }elseif (isset($data['summary'])) { |
|
506 | 506 | $data_post_content = $data['summary']; |
507 | 507 | } |
508 | 508 | $post['post_content'] = $data_post_content; |
509 | 509 | } |
510 | 510 | |
511 | 511 | //Create or update the post |
512 | - if(false !== $id && '0' !== $id){ |
|
512 | + if (false !== $id && '0' !== $id) { |
|
513 | 513 | $post['ID'] = $id; |
514 | 514 | $post['post_status'] = 'publish'; |
515 | 515 | $id = wp_update_post($post); |
516 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
517 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
518 | - }else{ |
|
516 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
517 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']), $prev_date); |
|
518 | + }else { |
|
519 | 519 | |
520 | 520 | //Set the name |
521 | - if(isset($data['name'])){ |
|
522 | - $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
521 | + if (isset($data['name'])) { |
|
522 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0); |
|
523 | 523 | } |
524 | 524 | $post['post_name'] = $post_name; |
525 | 525 | $post['post_title'] = $data['name']; |
@@ -527,51 +527,51 @@ discard block |
||
527 | 527 | $id = wp_insert_post($post); |
528 | 528 | |
529 | 529 | //Save the WETU ID and the Last date it was modified. |
530 | - if(false !== $id){ |
|
531 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
532 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
530 | + if (false !== $id) { |
|
531 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
532 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified'])); |
|
533 | 533 | } |
534 | 534 | } |
535 | 535 | |
536 | 536 | |
537 | 537 | //Set the price |
538 | - if(false !== $importable_content && in_array('price',$importable_content)){ |
|
539 | - $this->set_price($data,$id); |
|
538 | + if (false !== $importable_content && in_array('price', $importable_content)) { |
|
539 | + $this->set_price($data, $id); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | //Set the Duration |
543 | - if(false !== $importable_content && in_array('duration',$importable_content)){ |
|
544 | - $this->set_duration($data,$id); |
|
543 | + if (false !== $importable_content && in_array('duration', $importable_content)) { |
|
544 | + $this->set_duration($data, $id); |
|
545 | 545 | } |
546 | 546 | |
547 | - if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
548 | - $this->process_itineraries($data,$id,$importable_content); |
|
547 | + if (in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) { |
|
548 | + $this->process_itineraries($data, $id, $importable_content); |
|
549 | 549 | } |
550 | 550 | |
551 | - if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){ |
|
552 | - $this->process_map_points($data,$id); |
|
551 | + if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) { |
|
552 | + $this->process_map_points($data, $id); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | //TODO Test These |
556 | 556 | //Setup some default for use in the import |
557 | - if(false !== $importable_content && (in_array('itinerary_gallery',$importable_content) || in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
|
557 | + if (false !== $importable_content && (in_array('itinerary_gallery', $importable_content) || in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) { |
|
558 | 558 | $this->find_attachments($id); |
559 | 559 | } |
560 | 560 | //Set the featured image |
561 | 561 | //TODO Test These |
562 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
563 | - $this->set_featured_image($data,$id); |
|
562 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
563 | + $this->set_featured_image($data, $id); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | //TODO Test These |
567 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
568 | - $this->set_banner_image($data,$id); |
|
567 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
568 | + $this->set_banner_image($data, $id); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | //TODO Test These |
572 | 572 | //Import the main gallery |
573 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
574 | - $this->create_main_gallery($data,$id); |
|
573 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
574 | + $this->create_main_gallery($data, $id); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | return $id; |
@@ -580,149 +580,149 @@ discard block |
||
580 | 580 | /** |
581 | 581 | * A loop which runs through each leg on the tour. |
582 | 582 | */ |
583 | - public function process_itineraries($data,$id,$importable_content) { |
|
583 | + public function process_itineraries($data, $id, $importable_content) { |
|
584 | 584 | $day_counter = 1; |
585 | 585 | $leg_counter = 0; |
586 | 586 | |
587 | - delete_post_meta($id,'itinerary'); |
|
587 | + delete_post_meta($id, 'itinerary'); |
|
588 | 588 | |
589 | - if(false !== $importable_content && in_array('accommodation',$importable_content)){ |
|
590 | - delete_post_meta($id,'accommodation_to_tour'); |
|
589 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
590 | + delete_post_meta($id, 'accommodation_to_tour'); |
|
591 | 591 | } |
592 | - if(false !== $importable_content && in_array('destination',$importable_content)){ |
|
593 | - delete_post_meta($id,'destination_to_tour'); |
|
594 | - delete_post_meta($id,'departs_from'); |
|
595 | - delete_post_meta($id,'ends_in'); |
|
592 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
593 | + delete_post_meta($id, 'destination_to_tour'); |
|
594 | + delete_post_meta($id, 'departs_from'); |
|
595 | + delete_post_meta($id, 'ends_in'); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | $departs_from = false; |
599 | 599 | $ends_in = false; |
600 | 600 | |
601 | - foreach($data['legs'] as $leg){ |
|
601 | + foreach ($data['legs'] as $leg) { |
|
602 | 602 | |
603 | - if(isset($leg['days']) && !empty($leg['days'])){ |
|
603 | + if (isset($leg['days']) && !empty($leg['days'])) { |
|
604 | 604 | |
605 | 605 | //Itinerary Accommodation |
606 | 606 | $current_accommodation = false; |
607 | - if(false !== $importable_content && in_array('accommodation',$importable_content)){ |
|
608 | - $current_accommodation = $this->set_accommodation($leg,$id); |
|
607 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
608 | + $current_accommodation = $this->set_accommodation($leg, $id); |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | //Itinerary Destination |
612 | 612 | $current_destination = false; |
613 | - if(false !== $importable_content && in_array('destination',$importable_content)){ |
|
614 | - $current_destination = $this->set_destination($leg,$id); |
|
613 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
614 | + $current_destination = $this->set_destination($leg, $id); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | //If the Nights are the same mount of days in the array, then it isnt "By Destination" |
618 | - if($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']){ |
|
618 | + if ($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']) { |
|
619 | 619 | |
620 | - foreach($leg['days'] as $day){ |
|
620 | + foreach ($leg['days'] as $day) { |
|
621 | 621 | |
622 | 622 | $current_day = array(); |
623 | 623 | |
624 | - $current_day['title'] = esc_attr('Day ','wetu-importer').$day_counter; |
|
624 | + $current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter; |
|
625 | 625 | |
626 | 626 | //Description |
627 | - if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes']) && '' !== $day['notes']){ |
|
627 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes']) && '' !== $day['notes']) { |
|
628 | 628 | $current_day['description'] = strip_tags($day['notes']); |
629 | - }else{ |
|
629 | + }else { |
|
630 | 630 | $current_day['description'] = ''; |
631 | 631 | } |
632 | 632 | |
633 | 633 | //Itinerary Gallery |
634 | - if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){ |
|
634 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) { |
|
635 | 635 | $current_day['featured_image'] = ''; |
636 | - }else{ |
|
636 | + }else { |
|
637 | 637 | $current_day['featured_image'] = ''; |
638 | 638 | } |
639 | 639 | |
640 | 640 | //Accommodation |
641 | - if(false !== $current_accommodation){ |
|
641 | + if (false !== $current_accommodation) { |
|
642 | 642 | $current_day['accommodation_to_tour'] = array($current_accommodation); |
643 | - }else{ |
|
643 | + }else { |
|
644 | 644 | $current_day['accommodation_to_tour'] = array(); |
645 | 645 | } |
646 | 646 | |
647 | 647 | //Destination |
648 | - if(false !== $current_destination){ |
|
648 | + if (false !== $current_destination) { |
|
649 | 649 | $current_day['destination_to_tour'] = array($current_destination); |
650 | - }else{ |
|
650 | + }else { |
|
651 | 651 | $current_day['destination_to_tour'] = array(); |
652 | 652 | } |
653 | 653 | |
654 | 654 | //Included |
655 | - if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){ |
|
655 | + if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) { |
|
656 | 656 | $current_day['included'] = strip_tags($day['included']); |
657 | - }else{ |
|
657 | + }else { |
|
658 | 658 | $current_day['description'] = ''; |
659 | 659 | } |
660 | 660 | |
661 | 661 | //Excluded |
662 | - if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){ |
|
662 | + if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) { |
|
663 | 663 | $current_day['excluded'] = strip_tags($day['excluded']); |
664 | - }else{ |
|
664 | + }else { |
|
665 | 665 | $current_day['excluded'] = ''; |
666 | 666 | } |
667 | 667 | |
668 | - $this->set_itinerary_day($current_day,$id); |
|
668 | + $this->set_itinerary_day($current_day, $id); |
|
669 | 669 | $day_counter++; |
670 | 670 | } |
671 | 671 | |
672 | - }else{ |
|
673 | - $day_counter = $day_counter + (int)$leg['nights']; |
|
672 | + }else { |
|
673 | + $day_counter = $day_counter + (int) $leg['nights']; |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | } |
677 | 677 | |
678 | 678 | //If we are in the first leg, and the destination was attached then save it as the departure field. |
679 | - if( 0 === $leg_counter && false !== $current_destination){ |
|
679 | + if (0 === $leg_counter && false !== $current_destination) { |
|
680 | 680 | $departs_from = $current_destination; |
681 | 681 | } |
682 | 682 | |
683 | 683 | //If its the last leg then save it as the ends in. |
684 | - if( $leg_counter === (count($data['legs'])-2) && false !== $current_destination){ |
|
684 | + if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) { |
|
685 | 685 | $ends_in = $current_destination; |
686 | 686 | } |
687 | 687 | $leg_counter++; |
688 | 688 | } |
689 | 689 | |
690 | - if(false !== $departs_from){ |
|
691 | - add_post_meta($id,'departs_from',$departs_from,true); |
|
690 | + if (false !== $departs_from) { |
|
691 | + add_post_meta($id, 'departs_from', $departs_from, true); |
|
692 | 692 | } |
693 | - if(false !== $ends_in){ |
|
694 | - add_post_meta($id,'ends_in',$ends_in,true); |
|
693 | + if (false !== $ends_in) { |
|
694 | + add_post_meta($id, 'ends_in', $ends_in, true); |
|
695 | 695 | } |
696 | 696 | } |
697 | 697 | |
698 | 698 | /** |
699 | 699 | * Run through your routes and save the points as a KML file. |
700 | 700 | */ |
701 | - public function process_map_points($data,$id) { |
|
701 | + public function process_map_points($data, $id) { |
|
702 | 702 | |
703 | - if(!empty($data['routes'])){ |
|
703 | + if (!empty($data['routes'])) { |
|
704 | 704 | |
705 | - delete_post_meta($id,'wetu_map_points'); |
|
705 | + delete_post_meta($id, 'wetu_map_points'); |
|
706 | 706 | |
707 | 707 | $points = array(); |
708 | 708 | |
709 | - foreach($data['routes'] as $route){ |
|
709 | + foreach ($data['routes'] as $route) { |
|
710 | 710 | |
711 | 711 | |
712 | - if(isset($route['points']) && '' !== $route['points']){ |
|
712 | + if (isset($route['points']) && '' !== $route['points']) { |
|
713 | 713 | |
714 | - $temp_points = explode(';',$route['points']); |
|
714 | + $temp_points = explode(';', $route['points']); |
|
715 | 715 | $point_counter = count($temp_points); |
716 | 716 | |
717 | 717 | for ($x = 0; $x <= $point_counter; $x++) { |
718 | - $y = $x+1; |
|
718 | + $y = $x + 1; |
|
719 | 719 | $points[] = $temp_points[$x].','.$temp_points[$y]; |
720 | 720 | $x++; |
721 | 721 | } |
722 | 722 | } |
723 | 723 | } |
724 | - if(!empty($points)){ |
|
725 | - $this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true); |
|
724 | + if (!empty($points)) { |
|
725 | + $this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true); |
|
726 | 726 | } |
727 | 727 | } |
728 | 728 | |
@@ -731,28 +731,28 @@ discard block |
||
731 | 731 | /** |
732 | 732 | * Set the Itinerary Day |
733 | 733 | */ |
734 | - public function set_itinerary_day($day,$id) { |
|
735 | - $this->save_custom_field($day,'itinerary',$id,false,false); |
|
734 | + public function set_itinerary_day($day, $id) { |
|
735 | + $this->save_custom_field($day, 'itinerary', $id, false, false); |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | /** |
739 | 739 | * Set the price |
740 | 740 | */ |
741 | - public function set_price($data,$id) { |
|
741 | + public function set_price($data, $id) { |
|
742 | 742 | //Price |
743 | - if(isset($data['price']) && ''!== $data['price']){ |
|
743 | + if (isset($data['price']) && '' !== $data['price']) { |
|
744 | 744 | $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
745 | - $this->save_custom_field($price,'price',$id); |
|
745 | + $this->save_custom_field($price, 'price', $id); |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | //Price includes |
749 | - if(isset($data['price_includes']) && ''!== $data['price_includes']){ |
|
750 | - $this->save_custom_field($data['price_includes'],'included',$id); |
|
749 | + if (isset($data['price_includes']) && '' !== $data['price_includes']) { |
|
750 | + $this->save_custom_field($data['price_includes'], 'included', $id); |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | //Price Excludes |
754 | - if(isset($data['price_excludes']) && ''!== $data['price_excludes']){ |
|
755 | - $this->save_custom_field($data['price_excludes'],'not_included',$id); |
|
754 | + if (isset($data['price_excludes']) && '' !== $data['price_excludes']) { |
|
755 | + $this->save_custom_field($data['price_excludes'], 'not_included', $id); |
|
756 | 756 | } |
757 | 757 | |
758 | 758 | } |
@@ -760,11 +760,11 @@ discard block |
||
760 | 760 | /** |
761 | 761 | * Set the duration |
762 | 762 | */ |
763 | - public function set_duration($data,$id) { |
|
764 | - if(isset($data['days']) && !empty($data['days'])){ |
|
763 | + public function set_duration($data, $id) { |
|
764 | + if (isset($data['days']) && !empty($data['days'])) { |
|
765 | 765 | $price = $data['days']; |
766 | 766 | $price = preg_replace("/[^0-9,.]/", "", $price); |
767 | - $this->save_custom_field($price,'duration',$id); |
|
767 | + $this->save_custom_field($price, 'duration', $id); |
|
768 | 768 | } |
769 | 769 | } |
770 | 770 | |
@@ -772,27 +772,27 @@ discard block |
||
772 | 772 | /** |
773 | 773 | * Connects the Accommodation if its available |
774 | 774 | */ |
775 | - public function set_accommodation($day,$id) { |
|
775 | + public function set_accommodation($day, $id) { |
|
776 | 776 | |
777 | 777 | $ac_id = false; |
778 | 778 | $this->current_accommodation = $this->find_current_accommodation(); |
779 | 779 | |
780 | - if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){ |
|
780 | + if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) { |
|
781 | 781 | |
782 | - if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
|
782 | + if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) { |
|
783 | 783 | $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
784 | - }else{ |
|
784 | + }else { |
|
785 | 785 | $ac_id = wp_insert_post(array( |
786 | 786 | 'post_type' => 'accommodation', |
787 | 787 | 'post_status' => 'draft', |
788 | 788 | 'post_title' => $day['content_entity_id'] |
789 | 789 | )); |
790 | - $this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id); |
|
790 | + $this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id); |
|
791 | 791 | } |
792 | 792 | |
793 | - if('' !== $ac_id && false !== $ac_id){ |
|
794 | - $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
795 | - $this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false); |
|
793 | + if ('' !== $ac_id && false !== $ac_id) { |
|
794 | + $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false); |
|
795 | + $this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false); |
|
796 | 796 | } |
797 | 797 | } |
798 | 798 | return $ac_id; |
@@ -804,13 +804,13 @@ discard block |
||
804 | 804 | * @param $post_type string |
805 | 805 | * @return boolean / array |
806 | 806 | */ |
807 | - public function find_current_accommodation($post_type='accommodation') { |
|
807 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
808 | 808 | global $wpdb; |
809 | 809 | $accommodation = parent::find_current_accommodation($post_type); |
810 | 810 | |
811 | 811 | $return = false; |
812 | - if(!empty($accommodation)){ |
|
813 | - foreach($accommodation as $key => $acc){ |
|
812 | + if (!empty($accommodation)) { |
|
813 | + foreach ($accommodation as $key => $acc) { |
|
814 | 814 | $return[$acc->meta_value] = $acc->post_id; |
815 | 815 | } |
816 | 816 | } |
@@ -832,25 +832,25 @@ discard block |
||
832 | 832 | * @param $id string |
833 | 833 | * @return boolean / string |
834 | 834 | */ |
835 | - public function set_destination($day,$id) { |
|
835 | + public function set_destination($day, $id) { |
|
836 | 836 | $dest_id = false; |
837 | 837 | $country_id = false; |
838 | 838 | $this->current_destinations = $this->find_current_destinations(); |
839 | 839 | |
840 | - if(isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])){ |
|
840 | + if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) { |
|
841 | 841 | |
842 | - if(false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'],$this->current_destinations)){ |
|
842 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) { |
|
843 | 843 | $dest_id = $this->current_destinations[$day['destination_content_entity_id']]; |
844 | 844 | |
845 | 845 | $potential_id = wp_get_post_parent_id($dest_id); |
846 | - $country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true); |
|
847 | - if(false !== $country_wetu_id){ |
|
846 | + $country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true); |
|
847 | + if (false !== $country_wetu_id) { |
|
848 | 848 | $this->set_country($country_wetu_id, $id); |
849 | 849 | } |
850 | 850 | |
851 | 851 | }else { |
852 | 852 | |
853 | - $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']); |
|
853 | + $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$day['destination_content_entity_id']); |
|
854 | 854 | |
855 | 855 | if ($destination_json) { |
856 | 856 | $destination_data = json_decode($destination_json, true); |
@@ -859,12 +859,12 @@ discard block |
||
859 | 859 | |
860 | 860 | $destination_title = $day['destination_content_entity_id']; |
861 | 861 | |
862 | - if(isset($destination_data[0]['name'])){ |
|
862 | + if (isset($destination_data[0]['name'])) { |
|
863 | 863 | $destination_title = $destination_data[0]['name']; |
864 | 864 | } |
865 | 865 | |
866 | - if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
867 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
866 | + if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
867 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) { |
|
868 | 868 | |
869 | 869 | $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
870 | 870 | } |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | 'post_title' => $destination_title |
876 | 876 | ); |
877 | 877 | |
878 | - if(false !== $country_id){ |
|
878 | + if (false !== $country_id) { |
|
879 | 879 | $dest_post['post_parent'] = $country_id; |
880 | 880 | } |
881 | 881 | $dest_id = wp_insert_post($dest_post); |
@@ -908,9 +908,9 @@ discard block |
||
908 | 908 | |
909 | 909 | if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
910 | 910 | $country_id = $this->current_destinations[$country_wetu_id]; |
911 | - } else { |
|
911 | + }else { |
|
912 | 912 | |
913 | - $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
913 | + $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$country_wetu_id); |
|
914 | 914 | |
915 | 915 | if ($country_json) { |
916 | 916 | $country_data = json_decode($country_json, true); |