@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * Display the importer administration screen |
105 | 105 | */ |
106 | 106 | public function display_page() { |
107 | - ?> |
|
107 | + ?> |
|
108 | 108 | <div class="wrap"> |
109 | 109 | <?php screen_icon(); ?> |
110 | 110 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $keyphrases = $_POST['keyword']; |
323 | 323 | }else{ |
324 | 324 | $keyphrases = array(0); |
325 | - } |
|
325 | + } |
|
326 | 326 | |
327 | 327 | if(!is_array($keyphrases)){ |
328 | 328 | $keyphrases = array($keyphrases); |
@@ -351,11 +351,11 @@ discard block |
||
351 | 351 | //If we are searching for |
352 | 352 | if(false !== $post_status){ |
353 | 353 | |
354 | - $current_status = get_post_status($row->post_id); |
|
355 | - if($current_status !== $post_status){ |
|
356 | - continue; |
|
357 | - } |
|
358 | - $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row); |
|
354 | + $current_status = get_post_status($row->post_id); |
|
355 | + if($current_status !== $post_status){ |
|
356 | + continue; |
|
357 | + } |
|
358 | + $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row); |
|
359 | 359 | |
360 | 360 | |
361 | 361 | }else{ |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | $team_members = false; |
438 | 438 | } |
439 | 439 | |
440 | - $safari_brands = false; |
|
440 | + $safari_brands = false; |
|
441 | 441 | |
442 | 442 | if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
443 | 443 | $content = $_POST['content']; |
@@ -447,16 +447,16 @@ discard block |
||
447 | 447 | $content = false; |
448 | 448 | } |
449 | 449 | |
450 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
451 | - if($jdata) |
|
452 | - { |
|
453 | - $adata=json_decode($jdata,true); |
|
454 | - if(!empty($adata)) |
|
455 | - { |
|
456 | - $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
457 | - $this->format_completed_row($return); |
|
458 | - } |
|
459 | - } |
|
450 | + $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
451 | + if($jdata) |
|
452 | + { |
|
453 | + $adata=json_decode($jdata,true); |
|
454 | + if(!empty($adata)) |
|
455 | + { |
|
456 | + $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
457 | + $this->format_completed_row($return); |
|
458 | + } |
|
459 | + } |
|
460 | 460 | |
461 | 461 | die(); |
462 | 462 | } |
@@ -468,82 +468,82 @@ discard block |
||
468 | 468 | */ |
469 | 469 | public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) { |
470 | 470 | |
471 | - if(trim($data[0]['type'])=='Destination') |
|
472 | - { |
|
473 | - $post_name = $data_post_content = $data_post_excerpt = ''; |
|
474 | - $post = array( |
|
475 | - 'post_type' => 'destination', |
|
476 | - ); |
|
477 | - |
|
478 | - $content_used_general_description = false; |
|
479 | - |
|
480 | - //Set the post_content |
|
481 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
482 | - if(isset($data[0]['content']['extended_description'])) |
|
483 | - { |
|
484 | - $data_post_content = $data[0]['content']['extended_description']; |
|
485 | - }elseif(isset($data[0]['content']['general_description'])){ |
|
486 | - $data_post_content = $data[0]['content']['general_description']; |
|
487 | - $content_used_general_description = true; |
|
488 | - }elseif(isset($data[0]['content']['teaser_description'])){ |
|
489 | - $data_post_content = $data[0]['content']['teaser_description']; |
|
490 | - } |
|
491 | - $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
492 | - } |
|
493 | - |
|
494 | - //set the post_excerpt |
|
495 | - if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
496 | - if(isset($data[0]['content']['teaser_description'])){ |
|
497 | - $data_post_excerpt = $data[0]['content']['teaser_description']; |
|
498 | - }elseif(isset($data[0]['content']['extended_description'])){ |
|
471 | + if(trim($data[0]['type'])=='Destination') |
|
472 | + { |
|
473 | + $post_name = $data_post_content = $data_post_excerpt = ''; |
|
474 | + $post = array( |
|
475 | + 'post_type' => 'destination', |
|
476 | + ); |
|
477 | + |
|
478 | + $content_used_general_description = false; |
|
479 | + |
|
480 | + //Set the post_content |
|
481 | + if(false !== $importable_content && in_array('description',$importable_content)){ |
|
482 | + if(isset($data[0]['content']['extended_description'])) |
|
483 | + { |
|
484 | + $data_post_content = $data[0]['content']['extended_description']; |
|
485 | + }elseif(isset($data[0]['content']['general_description'])){ |
|
486 | + $data_post_content = $data[0]['content']['general_description']; |
|
487 | + $content_used_general_description = true; |
|
488 | + }elseif(isset($data[0]['content']['teaser_description'])){ |
|
489 | + $data_post_content = $data[0]['content']['teaser_description']; |
|
490 | + } |
|
491 | + $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
492 | + } |
|
493 | + |
|
494 | + //set the post_excerpt |
|
495 | + if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
496 | + if(isset($data[0]['content']['teaser_description'])){ |
|
497 | + $data_post_excerpt = $data[0]['content']['teaser_description']; |
|
498 | + }elseif(isset($data[0]['content']['extended_description'])){ |
|
499 | 499 | $data_post_excerpt = $data[0]['content']['extended_description']; |
500 | 500 | }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
501 | - $data_post_excerpt = $data[0]['content']['general_description']; |
|
502 | - } |
|
503 | - $post['post_excerpt'] = $data_post_excerpt; |
|
504 | - } |
|
501 | + $data_post_excerpt = $data[0]['content']['general_description']; |
|
502 | + } |
|
503 | + $post['post_excerpt'] = $data_post_excerpt; |
|
504 | + } |
|
505 | 505 | |
506 | - if(false !== $id && '0' !== $id){ |
|
507 | - $post['ID'] = $id; |
|
506 | + if(false !== $id && '0' !== $id){ |
|
507 | + $post['ID'] = $id; |
|
508 | 508 | if(isset($data[0]['name'])){ |
509 | 509 | $post['post_title'] = $data[0]['name']; |
510 | 510 | $post['post_status'] = 'publish'; |
511 | 511 | $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0); |
512 | 512 | } |
513 | - $id = wp_update_post($post); |
|
514 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
515 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
516 | - }else{ |
|
517 | - |
|
518 | - //Set the name |
|
519 | - if(isset($data[0]['name'])){ |
|
520 | - $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0); |
|
521 | - } |
|
522 | - $post['post_name'] = $post_name; |
|
523 | - $post['post_title'] = $data[0]['name']; |
|
524 | - $post['post_status'] = 'publish'; |
|
525 | - $id = wp_insert_post($post); |
|
526 | - |
|
527 | - //Save the WETU ID and the Last date it was modified. |
|
528 | - if(false !== $id){ |
|
529 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
530 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
531 | - } |
|
532 | - } |
|
533 | - |
|
534 | - //Set the team member if it is there |
|
535 | - if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
536 | - $this->set_team_member($id,$team_members); |
|
537 | - } |
|
538 | - |
|
539 | - if(class_exists('LSX_TO_Maps')){ |
|
540 | - $this->set_map_data($data,$id); |
|
541 | - } |
|
542 | - |
|
543 | - //Set the Room Data |
|
544 | - if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
545 | - $this->set_video_data($data,$id); |
|
546 | - } |
|
513 | + $id = wp_update_post($post); |
|
514 | + $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
515 | + update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
516 | + }else{ |
|
517 | + |
|
518 | + //Set the name |
|
519 | + if(isset($data[0]['name'])){ |
|
520 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0); |
|
521 | + } |
|
522 | + $post['post_name'] = $post_name; |
|
523 | + $post['post_title'] = $data[0]['name']; |
|
524 | + $post['post_status'] = 'publish'; |
|
525 | + $id = wp_insert_post($post); |
|
526 | + |
|
527 | + //Save the WETU ID and the Last date it was modified. |
|
528 | + if(false !== $id){ |
|
529 | + add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
530 | + add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
531 | + } |
|
532 | + } |
|
533 | + |
|
534 | + //Set the team member if it is there |
|
535 | + if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
536 | + $this->set_team_member($id,$team_members); |
|
537 | + } |
|
538 | + |
|
539 | + if(class_exists('LSX_TO_Maps')){ |
|
540 | + $this->set_map_data($data,$id); |
|
541 | + } |
|
542 | + |
|
543 | + //Set the Room Data |
|
544 | + if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
545 | + $this->set_video_data($data,$id); |
|
546 | + } |
|
547 | 547 | |
548 | 548 | //Set the Electricity |
549 | 549 | if(false !== $importable_content && in_array('electricity',$importable_content)){ |
@@ -570,8 +570,8 @@ discard block |
||
570 | 570 | $this->set_travel_info($data,$id,'climate'); |
571 | 571 | } |
572 | 572 | |
573 | - } |
|
574 | - return $id; |
|
573 | + } |
|
574 | + return $id; |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | |
582 | 582 | delete_post_meta($id, 'team_to_'.$this->tab_slug); |
583 | 583 | foreach($team_members as $team){ |
584 | - add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
584 | + add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
585 | 585 | } |
586 | 586 | } |
587 | 587 | |
@@ -633,11 +633,11 @@ discard block |
||
633 | 633 | 'elevation' => '', |
634 | 634 | ); |
635 | 635 | if(false !== $id && '0' !== $id){ |
636 | - $prev = get_post_meta($id,'location',true); |
|
637 | - update_post_meta($id,'location',$location_data,$prev); |
|
638 | - }else{ |
|
639 | - add_post_meta($id,'location',$location_data,true); |
|
640 | - } |
|
636 | + $prev = get_post_meta($id,'location',true); |
|
637 | + update_post_meta($id,'location',$location_data,$prev); |
|
638 | + }else{ |
|
639 | + add_post_meta($id,'location',$location_data,true); |
|
640 | + } |
|
641 | 641 | } |
642 | 642 | } |
643 | 643 |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * Display the importer administration screen |
79 | 79 | */ |
80 | 80 | public function display_page() { |
81 | - ?> |
|
81 | + ?> |
|
82 | 82 | <div class="wrap"> |
83 | 83 | <?php screen_icon(); ?> |
84 | 84 | |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | </ul> |
101 | 101 | |
102 | 102 | <?php } else { |
103 | - do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']); |
|
104 | - } ?> |
|
103 | + do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']); |
|
104 | + } ?> |
|
105 | 105 | </div> |
106 | 106 | <?php |
107 | 107 | } |
@@ -148,37 +148,37 @@ discard block |
||
148 | 148 | * set_taxonomy with some terms |
149 | 149 | */ |
150 | 150 | public function set_taxonomy($taxonomy,$terms,$id) { |
151 | - $result=array(); |
|
152 | - if(!empty($data)) |
|
153 | - { |
|
154 | - foreach($data as $k) |
|
155 | - { |
|
156 | - if($id) |
|
157 | - { |
|
158 | - if(!$term = term_exists(trim($k), $tax)) |
|
159 | - { |
|
160 | - $term = wp_insert_term(trim($k), $tax); |
|
161 | - if ( is_wp_error($term) ) |
|
162 | - { |
|
163 | - echo $term->get_error_message(); |
|
164 | - } |
|
165 | - else |
|
166 | - { |
|
167 | - wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
168 | - } |
|
169 | - } |
|
170 | - else |
|
171 | - { |
|
172 | - wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
173 | - } |
|
174 | - } |
|
175 | - else |
|
176 | - { |
|
177 | - $result[]=trim($k); |
|
178 | - } |
|
179 | - } |
|
180 | - } |
|
181 | - return $result; |
|
151 | + $result=array(); |
|
152 | + if(!empty($data)) |
|
153 | + { |
|
154 | + foreach($data as $k) |
|
155 | + { |
|
156 | + if($id) |
|
157 | + { |
|
158 | + if(!$term = term_exists(trim($k), $tax)) |
|
159 | + { |
|
160 | + $term = wp_insert_term(trim($k), $tax); |
|
161 | + if ( is_wp_error($term) ) |
|
162 | + { |
|
163 | + echo $term->get_error_message(); |
|
164 | + } |
|
165 | + else |
|
166 | + { |
|
167 | + wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
168 | + } |
|
169 | + } |
|
170 | + else |
|
171 | + { |
|
172 | + wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
173 | + } |
|
174 | + } |
|
175 | + else |
|
176 | + { |
|
177 | + $result[]=trim($k); |
|
178 | + } |
|
179 | + } |
|
180 | + } |
|
181 | + return $result; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -188,21 +188,21 @@ discard block |
||
188 | 188 | if(post_type_exists('team')) { ?> |
189 | 189 | <ul> |
190 | 190 | <?php |
191 | - $team_args=array( |
|
192 | - 'post_type' => 'team', |
|
193 | - 'post_status' => 'publish', |
|
194 | - 'nopagin' => true, |
|
195 | - 'fields' => 'ids' |
|
196 | - ); |
|
197 | - $team_members = new WP_Query($team_args); |
|
198 | - if($team_members->have_posts()){ |
|
199 | - foreach($team_members->posts as $member){ ?> |
|
191 | + $team_args=array( |
|
192 | + 'post_type' => 'team', |
|
193 | + 'post_status' => 'publish', |
|
194 | + 'nopagin' => true, |
|
195 | + 'fields' => 'ids' |
|
196 | + ); |
|
197 | + $team_members = new WP_Query($team_args); |
|
198 | + if($team_members->have_posts()){ |
|
199 | + foreach($team_members->posts as $member){ ?> |
|
200 | 200 | <li><input class="team" checked="<?php $this->checked($selected,$member); ?>" type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li> |
201 | 201 | <?php } |
202 | - }else{ ?> |
|
202 | + }else{ ?> |
|
203 | 203 | <li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li> |
204 | 204 | <?php } |
205 | - ?> |
|
205 | + ?> |
|
206 | 206 | </ul> |
207 | 207 | <?php } |
208 | 208 | } |
@@ -253,40 +253,40 @@ discard block |
||
253 | 253 | if(false !== $id){ |
254 | 254 | if(empty($this->found_attachments)){ |
255 | 255 | |
256 | - $attachments_args = array( |
|
257 | - 'post_parent' => $id, |
|
258 | - 'post_status' => 'inherit', |
|
259 | - 'post_type' => 'attachment', |
|
260 | - 'order' => 'ASC', |
|
261 | - ); |
|
256 | + $attachments_args = array( |
|
257 | + 'post_parent' => $id, |
|
258 | + 'post_status' => 'inherit', |
|
259 | + 'post_type' => 'attachment', |
|
260 | + 'order' => 'ASC', |
|
261 | + ); |
|
262 | 262 | |
263 | - $attachments = new WP_Query($attachments_args); |
|
264 | - if($attachments->have_posts()){ |
|
265 | - foreach($attachments->posts as $attachment){ |
|
266 | - $this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
267 | - $this->gallery_meta[] = $attachment->ID; |
|
268 | - } |
|
269 | - } |
|
263 | + $attachments = new WP_Query($attachments_args); |
|
264 | + if($attachments->have_posts()){ |
|
265 | + foreach($attachments->posts as $attachment){ |
|
266 | + $this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
267 | + $this->gallery_meta[] = $attachment->ID; |
|
268 | + } |
|
269 | + } |
|
270 | 270 | } |
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
275 | 275 | * Checks to see if an item is selected. |
276 | - * |
|
277 | - * @param $haystack array|string |
|
278 | - * @param $needle string |
|
279 | - * @return string |
|
276 | + * |
|
277 | + * @param $haystack array|string |
|
278 | + * @param $needle string |
|
279 | + * @return string |
|
280 | 280 | */ |
281 | 281 | public function checked($haystack=false,$needle='') { |
282 | - $return = ''; |
|
283 | - if(!is_array($haystack)){ |
|
282 | + $return = ''; |
|
283 | + if(!is_array($haystack)){ |
|
284 | 284 | $haystack = array($haystack); |
285 | - } |
|
286 | - if(in_array($needle,$haystack)){ |
|
285 | + } |
|
286 | + if(in_array($needle,$haystack)){ |
|
287 | 287 | $return = 'checked'; |
288 | - } |
|
289 | - return $return; |
|
288 | + } |
|
289 | + return $return; |
|
290 | 290 | } |
291 | 291 | } |
292 | 292 | $wetu_importer_admin = new WETU_Importer_Admin(); |
293 | 293 | \ No newline at end of file |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | $tour_options = get_option('wetu_importer_tour_settings',false); |
98 | 98 | if(false !== $tour_options){ |
99 | 99 | $this->tour_options = $tour_options; |
100 | - } |
|
100 | + } |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * Display the importer administration screen |
121 | 121 | */ |
122 | 122 | public function display_page() { |
123 | - ?> |
|
123 | + ?> |
|
124 | 124 | <div class="wrap"> |
125 | 125 | <?php screen_icon(); ?> |
126 | 126 | |
@@ -248,13 +248,13 @@ discard block |
||
248 | 248 | $result = $this->update_options(); |
249 | 249 | |
250 | 250 | if(true === $result){ |
251 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
252 | - }else{ |
|
253 | - echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
254 | - } |
|
251 | + echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
252 | + }else{ |
|
253 | + echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
254 | + } |
|
255 | 255 | }else{ |
256 | 256 | echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
257 | - } |
|
257 | + } |
|
258 | 258 | echo '</h3></div>'; |
259 | 259 | } |
260 | 260 | |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | $tours = json_decode($data, true); |
267 | 267 | |
268 | 268 | if(isset($tours['error'])){ |
269 | - return $tours['error']; |
|
270 | - }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
269 | + return $tours['error']; |
|
270 | + }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
271 | 271 | set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2); |
272 | 272 | return true; |
273 | 273 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | $keyphrases = $_POST['keyword']; |
317 | 317 | }else{ |
318 | 318 | $keyphrases = array(0); |
319 | - } |
|
319 | + } |
|
320 | 320 | |
321 | 321 | if(!is_array($keyphrases)){ |
322 | 322 | $keyphrases = array($keyphrases); |
@@ -345,15 +345,15 @@ discard block |
||
345 | 345 | |
346 | 346 | foreach($tours as $row_key => $row){ |
347 | 347 | |
348 | - if(isset($row['is_disabled']) && true === $row['is_disabled']){ |
|
349 | - continue; |
|
350 | - } |
|
348 | + if(isset($row['is_disabled']) && true === $row['is_disabled']){ |
|
349 | + continue; |
|
350 | + } |
|
351 | 351 | |
352 | - /*if('Sample' === $row['type']){ |
|
352 | + /*if('Sample' === $row['type']){ |
|
353 | 353 | continue; |
354 | 354 | }*/ |
355 | 355 | |
356 | - //If this is a current tour, add its ID to the row. |
|
356 | + //If this is a current tour, add its ID to the row. |
|
357 | 357 | $row['post_id'] = 0; |
358 | 358 | if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){ |
359 | 359 | $row['post_id'] = $current_tours[$row['identifier']]->post_id; |
@@ -362,31 +362,31 @@ discard block |
||
362 | 362 | //If we are searching for |
363 | 363 | if(false !== $post_status){ |
364 | 364 | |
365 | - if('import' === $post_status){ |
|
365 | + if('import' === $post_status){ |
|
366 | 366 | |
367 | 367 | if(0 !== $row['post_id']){ |
368 | - continue; |
|
368 | + continue; |
|
369 | 369 | }else{ |
370 | 370 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
371 | - } |
|
371 | + } |
|
372 | 372 | |
373 | 373 | |
374 | - }else{ |
|
374 | + }else{ |
|
375 | 375 | |
376 | 376 | if(0 === $row['post_id']){ |
377 | 377 | continue; |
378 | 378 | }else{ |
379 | 379 | $current_status = get_post_status($row['post_id']); |
380 | 380 | if($current_status !== $post_status){ |
381 | - continue; |
|
382 | - } |
|
381 | + continue; |
|
382 | + } |
|
383 | 383 | |
384 | 384 | } |
385 | 385 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
386 | 386 | |
387 | - } |
|
387 | + } |
|
388 | 388 | |
389 | - }else{ |
|
389 | + }else{ |
|
390 | 390 | //Search through each keyword. |
391 | 391 | foreach($keyphrases as $keyphrase){ |
392 | 392 | |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
401 | 401 | } |
402 | 402 | } |
403 | - } |
|
403 | + } |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
@@ -467,17 +467,17 @@ discard block |
||
467 | 467 | $content = false; |
468 | 468 | } |
469 | 469 | |
470 | - $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
470 | + $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
471 | 471 | |
472 | - if($jdata) |
|
473 | - { |
|
472 | + if($jdata) |
|
473 | + { |
|
474 | 474 | $jdata=json_decode($jdata,true); |
475 | - if(!empty($jdata)) |
|
476 | - { |
|
477 | - $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
478 | - $this->format_completed_row($return); |
|
479 | - } |
|
480 | - } |
|
475 | + if(!empty($jdata)) |
|
476 | + { |
|
477 | + $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
478 | + $this->format_completed_row($return); |
|
479 | + } |
|
480 | + } |
|
481 | 481 | die(); |
482 | 482 | } |
483 | 483 | |
@@ -485,53 +485,53 @@ discard block |
||
485 | 485 | |
486 | 486 | /** |
487 | 487 | * Connect to wetu |
488 | - * |
|
489 | - * @param $data array |
|
490 | - * @param $wetu_id string |
|
488 | + * |
|
489 | + * @param $data array |
|
490 | + * @param $wetu_id string |
|
491 | 491 | */ |
492 | 492 | public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) { |
493 | - $post_name = $data_post_content = $data_post_excerpt = ''; |
|
494 | - $post = array( |
|
495 | - 'post_type' => 'tour', |
|
496 | - ); |
|
493 | + $post_name = $data_post_content = $data_post_excerpt = ''; |
|
494 | + $post = array( |
|
495 | + 'post_type' => 'tour', |
|
496 | + ); |
|
497 | 497 | |
498 | - //Set the post_content |
|
498 | + //Set the post_content |
|
499 | 499 | $content_used_general_description = false; |
500 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
501 | - $data_post_content = ''; |
|
502 | - |
|
503 | - if(isset($data['description'])){ |
|
504 | - $data_post_content = $data['description']; |
|
505 | - }elseif(isset($data['summary'])){ |
|
506 | - $data_post_content = $data['summary']; |
|
507 | - } |
|
508 | - $post['post_content'] = $data_post_content; |
|
509 | - } |
|
510 | - |
|
511 | - //Create or update the post |
|
512 | - if(false !== $id && '0' !== $id){ |
|
513 | - $post['ID'] = $id; |
|
514 | - $post['post_status'] = 'publish'; |
|
515 | - $id = wp_update_post($post); |
|
516 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
517 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
518 | - }else{ |
|
519 | - |
|
520 | - //Set the name |
|
521 | - if(isset($data['name'])){ |
|
522 | - $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
523 | - } |
|
524 | - $post['post_name'] = $post_name; |
|
525 | - $post['post_title'] = $data['name']; |
|
526 | - $post['post_status'] = 'publish'; |
|
527 | - $id = wp_insert_post($post); |
|
528 | - |
|
529 | - //Save the WETU ID and the Last date it was modified. |
|
530 | - if(false !== $id){ |
|
531 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
532 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
533 | - } |
|
534 | - } |
|
500 | + if(false !== $importable_content && in_array('description',$importable_content)){ |
|
501 | + $data_post_content = ''; |
|
502 | + |
|
503 | + if(isset($data['description'])){ |
|
504 | + $data_post_content = $data['description']; |
|
505 | + }elseif(isset($data['summary'])){ |
|
506 | + $data_post_content = $data['summary']; |
|
507 | + } |
|
508 | + $post['post_content'] = $data_post_content; |
|
509 | + } |
|
510 | + |
|
511 | + //Create or update the post |
|
512 | + if(false !== $id && '0' !== $id){ |
|
513 | + $post['ID'] = $id; |
|
514 | + $post['post_status'] = 'publish'; |
|
515 | + $id = wp_update_post($post); |
|
516 | + $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
517 | + update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
518 | + }else{ |
|
519 | + |
|
520 | + //Set the name |
|
521 | + if(isset($data['name'])){ |
|
522 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
523 | + } |
|
524 | + $post['post_name'] = $post_name; |
|
525 | + $post['post_title'] = $data['name']; |
|
526 | + $post['post_status'] = 'publish'; |
|
527 | + $id = wp_insert_post($post); |
|
528 | + |
|
529 | + //Save the WETU ID and the Last date it was modified. |
|
530 | + if(false !== $id){ |
|
531 | + add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
532 | + add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
533 | + } |
|
534 | + } |
|
535 | 535 | |
536 | 536 | |
537 | 537 | //Set the price |
@@ -544,9 +544,9 @@ discard block |
||
544 | 544 | $this->set_duration($data,$id); |
545 | 545 | } |
546 | 546 | |
547 | - if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
548 | - $this->process_itineraries($data,$id,$importable_content); |
|
549 | - } |
|
547 | + if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
548 | + $this->process_itineraries($data,$id,$importable_content); |
|
549 | + } |
|
550 | 550 | |
551 | 551 | if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){ |
552 | 552 | $this->process_map_points($data,$id); |
@@ -557,24 +557,24 @@ discard block |
||
557 | 557 | if(false !== $importable_content && (in_array('itinerary_gallery',$importable_content) || in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
558 | 558 | $this->find_attachments($id); |
559 | 559 | } |
560 | - //Set the featured image |
|
561 | - //TODO Test These |
|
562 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
563 | - $this->set_featured_image($data,$id); |
|
564 | - } |
|
560 | + //Set the featured image |
|
561 | + //TODO Test These |
|
562 | + if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
563 | + $this->set_featured_image($data,$id); |
|
564 | + } |
|
565 | 565 | |
566 | 566 | //TODO Test These |
567 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
568 | - $this->set_banner_image($data,$id); |
|
569 | - } |
|
567 | + if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
568 | + $this->set_banner_image($data,$id); |
|
569 | + } |
|
570 | 570 | |
571 | 571 | //TODO Test These |
572 | - //Import the main gallery |
|
573 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
574 | - $this->create_main_gallery($data,$id); |
|
575 | - } |
|
572 | + //Import the main gallery |
|
573 | + if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
574 | + $this->create_main_gallery($data,$id); |
|
575 | + } |
|
576 | 576 | |
577 | - return $id; |
|
577 | + return $id; |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | /** |
@@ -700,31 +700,31 @@ discard block |
||
700 | 700 | */ |
701 | 701 | public function process_map_points($data,$id) { |
702 | 702 | |
703 | - if(!empty($data['routes'])){ |
|
703 | + if(!empty($data['routes'])){ |
|
704 | 704 | |
705 | - delete_post_meta($id,'wetu_map_points'); |
|
705 | + delete_post_meta($id,'wetu_map_points'); |
|
706 | 706 | |
707 | - $points = array(); |
|
707 | + $points = array(); |
|
708 | 708 | |
709 | - foreach($data['routes'] as $route){ |
|
709 | + foreach($data['routes'] as $route){ |
|
710 | 710 | |
711 | 711 | |
712 | - if(isset($route['points']) && '' !== $route['points']){ |
|
712 | + if(isset($route['points']) && '' !== $route['points']){ |
|
713 | 713 | |
714 | - $temp_points = explode(';',$route['points']); |
|
715 | - $point_counter = count($temp_points); |
|
714 | + $temp_points = explode(';',$route['points']); |
|
715 | + $point_counter = count($temp_points); |
|
716 | 716 | |
717 | 717 | for ($x = 0; $x <= $point_counter; $x++) { |
718 | - $y = $x+1; |
|
718 | + $y = $x+1; |
|
719 | 719 | $points[] = $temp_points[$x].','.$temp_points[$y]; |
720 | 720 | $x++; |
721 | 721 | } |
722 | 722 | } |
723 | - } |
|
724 | - if(!empty($points)){ |
|
723 | + } |
|
724 | + if(!empty($points)){ |
|
725 | 725 | $this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true); |
726 | - } |
|
727 | - } |
|
726 | + } |
|
727 | + } |
|
728 | 728 | |
729 | 729 | } |
730 | 730 | |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | * Set the Itinerary Day |
733 | 733 | */ |
734 | 734 | public function set_itinerary_day($day,$id) { |
735 | - $this->save_custom_field($day,'itinerary',$id,false,false); |
|
735 | + $this->save_custom_field($day,'itinerary',$id,false,false); |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | /** |
@@ -740,8 +740,8 @@ discard block |
||
740 | 740 | */ |
741 | 741 | public function set_price($data,$id) { |
742 | 742 | if(isset($data['price']) && ''!== $data['price']){ |
743 | - $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
|
744 | - $this->save_custom_field($price,'price',$id); |
|
743 | + $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
|
744 | + $this->save_custom_field($price,'price',$id); |
|
745 | 745 | } |
746 | 746 | } |
747 | 747 | |
@@ -762,35 +762,35 @@ discard block |
||
762 | 762 | */ |
763 | 763 | public function set_accommodation($day,$id) { |
764 | 764 | |
765 | - $ac_id = false; |
|
765 | + $ac_id = false; |
|
766 | 766 | $this->current_accommodation = $this->find_current_accommodation(); |
767 | 767 | |
768 | 768 | if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){ |
769 | 769 | |
770 | 770 | if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
771 | - $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
771 | + $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
772 | 772 | }else{ |
773 | 773 | $ac_id = wp_insert_post(array( |
774 | - 'post_type' => 'accommodation', |
|
775 | - 'post_status' => 'draft', |
|
776 | - 'post_title' => $day['content_entity_id'] |
|
777 | - )); |
|
774 | + 'post_type' => 'accommodation', |
|
775 | + 'post_status' => 'draft', |
|
776 | + 'post_title' => $day['content_entity_id'] |
|
777 | + )); |
|
778 | 778 | $this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id); |
779 | 779 | } |
780 | 780 | |
781 | 781 | if('' !== $ac_id && false !== $ac_id){ |
782 | - $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
782 | + $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
783 | 783 | $this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false); |
784 | - } |
|
784 | + } |
|
785 | 785 | } |
786 | 786 | return $ac_id; |
787 | 787 | } |
788 | 788 | |
789 | 789 | /** |
790 | 790 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
791 | - * |
|
792 | - * @param $post_type string |
|
793 | - * @return boolean / array |
|
791 | + * |
|
792 | + * @param $post_type string |
|
793 | + * @return boolean / array |
|
794 | 794 | */ |
795 | 795 | public function find_current_accommodation($post_type='accommodation') { |
796 | 796 | global $wpdb; |
@@ -798,16 +798,16 @@ discard block |
||
798 | 798 | |
799 | 799 | $return = false; |
800 | 800 | if(!empty($accommodation)){ |
801 | - foreach($accommodation as $key => $acc){ |
|
801 | + foreach($accommodation as $key => $acc){ |
|
802 | 802 | $return[$acc->meta_value] = $acc->post_id; |
803 | - } |
|
804 | - } |
|
803 | + } |
|
804 | + } |
|
805 | 805 | return $return; |
806 | 806 | } |
807 | 807 | |
808 | 808 | /** |
809 | 809 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
810 | - * @return boolean / array |
|
810 | + * @return boolean / array |
|
811 | 811 | */ |
812 | 812 | public function find_current_destinations() { |
813 | 813 | return $this->find_current_accommodation('destination'); |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | $country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true); |
835 | 835 | if(false !== $country_wetu_id){ |
836 | 836 | $this->set_country($country_wetu_id, $id); |
837 | - } |
|
837 | + } |
|
838 | 838 | |
839 | 839 | }else { |
840 | 840 | |
@@ -845,27 +845,27 @@ discard block |
||
845 | 845 | |
846 | 846 | if (!empty($destination_data) && !isset($destination_data['error'])) { |
847 | 847 | |
848 | - $destination_title = $day['destination_content_entity_id']; |
|
848 | + $destination_title = $day['destination_content_entity_id']; |
|
849 | 849 | |
850 | - if(isset($destination_data[0]['name'])){ |
|
850 | + if(isset($destination_data[0]['name'])){ |
|
851 | 851 | $destination_title = $destination_data[0]['name']; |
852 | - } |
|
852 | + } |
|
853 | 853 | |
854 | - if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
855 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
854 | + if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
855 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
856 | 856 | |
857 | 857 | $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
858 | - } |
|
858 | + } |
|
859 | 859 | |
860 | - $dest_post = array( |
|
860 | + $dest_post = array( |
|
861 | 861 | 'post_type' => 'destination', |
862 | 862 | 'post_status' => 'draft', |
863 | 863 | 'post_title' => $destination_title |
864 | 864 | ); |
865 | 865 | |
866 | - if(false !== $country_id){ |
|
866 | + if(false !== $country_id){ |
|
867 | 867 | $dest_post['post_parent'] = $country_id; |
868 | - } |
|
868 | + } |
|
869 | 869 | $dest_id = wp_insert_post($dest_post); |
870 | 870 | |
871 | 871 | //Make sure we register the |
@@ -887,50 +887,50 @@ discard block |
||
887 | 887 | * Connects the destinations post type |
888 | 888 | * |
889 | 889 | * @param $dest_id string |
890 | - * @param $country_id array |
|
890 | + * @param $country_id array |
|
891 | 891 | * @param $id string |
892 | 892 | */ |
893 | 893 | public function set_country($country_wetu_id, $id) { |
894 | - $country_id = false; |
|
894 | + $country_id = false; |
|
895 | 895 | $this->current_destinations = $this->find_current_destinations(); |
896 | 896 | |
897 | - if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
898 | - $country_id = $this->current_destinations[$country_wetu_id]; |
|
899 | - } else { |
|
897 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
898 | + $country_id = $this->current_destinations[$country_wetu_id]; |
|
899 | + } else { |
|
900 | 900 | |
901 | - $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
901 | + $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
902 | 902 | |
903 | - if ($country_json) { |
|
904 | - $country_data = json_decode($country_json, true); |
|
903 | + if ($country_json) { |
|
904 | + $country_data = json_decode($country_json, true); |
|
905 | 905 | |
906 | - if (!empty($country_data) && !isset($country_data['error'])) { |
|
906 | + if (!empty($country_data) && !isset($country_data['error'])) { |
|
907 | 907 | |
908 | 908 | //Format the title of the destination if its available, otherwise default to the WETU ID. |
909 | - $country_title = $country_wetu_id; |
|
910 | - if (isset($country_data[0]['name'])) { |
|
909 | + $country_title = $country_wetu_id; |
|
910 | + if (isset($country_data[0]['name'])) { |
|
911 | 911 | $country_title = $country_data[0]['name']; |
912 | - } |
|
912 | + } |
|
913 | 913 | |
914 | 914 | $country_id = wp_insert_post(array( |
915 | - 'post_type' => 'destination', |
|
916 | - 'post_status' => 'draft', |
|
917 | - 'post_title' => $country_title |
|
918 | - )); |
|
915 | + 'post_type' => 'destination', |
|
916 | + 'post_status' => 'draft', |
|
917 | + 'post_title' => $country_title |
|
918 | + )); |
|
919 | 919 | //add the country to the current destination stack |
920 | 920 | $this->current_destinations[$country_wetu_id] = $country_id; |
921 | 921 | |
922 | 922 | //Save the wetu field |
923 | - $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
924 | - } |
|
925 | - } |
|
926 | - } |
|
923 | + $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
924 | + } |
|
925 | + } |
|
926 | + } |
|
927 | 927 | |
928 | - if ('' !== $country_id && false !== $country_id) { |
|
929 | - $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
930 | - $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
928 | + if ('' !== $country_id && false !== $country_id) { |
|
929 | + $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
930 | + $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
931 | 931 | |
932 | - return $country_id; |
|
933 | - } |
|
932 | + return $country_id; |
|
933 | + } |
|
934 | 934 | } |
935 | 935 | } |
936 | 936 | $wetu_importer_tours = new WETU_Importer_Tours(); |
937 | 937 | \ No newline at end of file |