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