Completed
Push — master ( 8a71c5...21aee9 )
by Warwick
02:52
created
classes/class-tours.php 1 patch
Spacing   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -82,20 +82,20 @@  discard block
 block discarded – undo
82 82
 	public function __construct() {
83 83
 		$this->set_variables();
84 84
 
85
-		add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') );
86
-		add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search'));	
87
-		add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search'));		
85
+		add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page'));
86
+		add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search'));	
87
+		add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search'));		
88 88
 
89
-		add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import'));	
90
-		add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import'));
89
+		add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import'));	
90
+		add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import'));
91 91
 
92
-		$temp_options = get_option('_lsx-to_settings',false);
93
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){
92
+		$temp_options = get_option('_lsx-to_settings', false);
93
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
94 94
 			$this->options = $temp_options[$this->plugin_slug];
95 95
 		}
96 96
 
97
-		$tour_options = get_option('wetu_importer_tour_settings',false);
98
-		if(false !== $tour_options){
97
+		$tour_options = get_option('wetu_importer_tour_settings', false);
98
+		if (false !== $tour_options) {
99 99
 			$this->tour_options = $tour_options;
100 100
         }
101 101
 	}
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 	{
108 108
 		parent::set_variables();
109 109
 
110
-		if ( false !== $this->api_username && false !== $this->api_password ) {
110
+		if (false !== $this->api_username && false !== $this->api_password) {
111 111
 			$this->url    = 'https://wetu.com/API/Itinerary/';
112
-			$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
113
-		} elseif ( false !== $this->api_key ) {
114
-			$this->url    = 'https://wetu.com/API/Itinerary/' . $this->api_key;
112
+			$this->url_qs = 'username='.$this->api_username.'&password='.$this->api_password;
113
+		} elseif (false !== $this->api_key) {
114
+			$this->url    = 'https://wetu.com/API/Itinerary/'.$this->api_key;
115 115
 			$this->url_qs = '';
116 116
 		}
117 117
 	}
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 			<form method="get" action="" id="posts-filter">
132 132
 				<input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" />
133 133
 				
134
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
135
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
134
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
135
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
136 136
 				</p>				
137 137
 
138 138
 				<table class="wp-list-table widefat fixed posts">
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
 					<tbody id="the-list">
142 142
 						<tr class="post-0 type-tour status-none" id="post-0">
143 143
 							<th class="check-column" scope="row">
144
-								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label>
144
+								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label>
145 145
 							</th>
146 146
 							<td class="post-title page-title column-title">
147 147
 								<strong>
148
-									<?php _e('Enter a title to search for','wetu-importer'); ?>
148
+									<?php _e('Enter a title to search for', 'wetu-importer'); ?>
149 149
 								</strong>
150 150
 							</td>
151 151
 							<td class="date column-date">							
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 
160 160
 				</table>
161 161
 
162
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
163
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
162
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
163
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
164 164
 				</p>
165 165
 			</form> 
166 166
 
@@ -172,16 +172,16 @@  discard block
 block discarded – undo
172 172
 						<div class="settings-all" style="width:30%;display:block;float:left;">
173 173
 							<h3><?php _e('What content to Sync from WETU'); ?></h3>
174 174
 							<ul>
175
-                                <li><input class="content select-all" <?php $this->checked($this->destination_options,'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php _e('Select All','wetu-importer'); ?></li>
176
-								<li><input class="content" <?php $this->checked($this->tour_options,'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li>
177
-								<li><input class="content" <?php $this->checked($this->tour_options,'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li>
175
+                                <li><input class="content select-all" <?php $this->checked($this->destination_options, 'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php _e('Select All', 'wetu-importer'); ?></li>
176
+								<li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li>
177
+								<li><input class="content" <?php $this->checked($this->tour_options, 'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li>
178 178
 
179
-                                <li><input class="content" <?php $this->checked($this->tour_options,'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price','wetu-importer'); ?></li>
180
-                                <li><input class="content" <?php $this->checked($this->tour_options,'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration','wetu-importer'); ?></li>
179
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price', 'wetu-importer'); ?></li>
180
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration', 'wetu-importer'); ?></li>
181 181
 
182
-								<li><input class="content" <?php $this->checked($this->tour_options,'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li>
182
+								<li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li>
183 183
 
184
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days','wetu-importer'); ?></li>
184
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days', 'wetu-importer'); ?></li>
185 185
 
186 186
 								<?php /*if(class_exists('LSX_TO_Maps')){ ?>
187 187
                                     <li><input class="content" <?php $this->checked($this->tour_options,'map'); ?> type="checkbox" name="content[]" value="map" /> <?php _e('Map Coordinates (generates a KML file)','wetu-importer'); ?></li>
@@ -191,18 +191,18 @@  discard block
 block discarded – undo
191 191
                         <div class="settings-all" style="width:30%;display:block;float:left;">
192 192
                             <h3><?php _e('Itinerary Info'); ?></h3>
193 193
                             <ul>
194
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description','wetu-importer'); ?></li>
195
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included','wetu-importer'); ?></li>
196
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded','wetu-importer'); ?></li>
194
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description', 'wetu-importer'); ?></li>
195
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included', 'wetu-importer'); ?></li>
196
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded', 'wetu-importer'); ?></li>
197 197
                             </ul>
198 198
 
199 199
                             <h4><?php _e('Additional Content'); ?></h4>
200 200
                             <ul>
201
-                                <li><input class="content" <?php $this->checked($this->tour_options,'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation','wetu-importer'); ?></li>
202
-                                <li><input class="content" <?php $this->checked($this->tour_options,'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations','wetu-importer'); ?></li>
201
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation', 'wetu-importer'); ?></li>
202
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations', 'wetu-importer'); ?></li>
203 203
                             </ul>
204 204
                         </div>
205
-                        <?php if(class_exists('LSX_TO_Team')){ ?>
205
+                        <?php if (class_exists('LSX_TO_Team')) { ?>
206 206
                             <div style="width:30%;display:block;float:left;">
207 207
                                 <h3><?php _e('Assign a Team Member'); ?></h3>
208 208
                                 <?php $this->team_member_checkboxes($this->tour_options); ?>
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 
215 215
 
216 216
 					<h3><?php _e('Your List'); ?></h3>
217
-                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
217
+                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
218 218
 					<table class="wp-list-table widefat fixed posts">
219 219
 						<?php $this->table_header(); ?>
220 220
 
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
 
227 227
 					</table>
228 228
 
229
-					<p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
229
+					<p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
230 230
 				</form>
231 231
 			</div>
232 232
 
233 233
 			<div style="display:none;" class="completed-list-wrapper">
234
-				<h3><?php _e('Completed','wetu-importer'); ?> - <small><?php _e('Import your','wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next','wetu-importer'); ?></small></h3>
234
+				<h3><?php _e('Completed', 'wetu-importer'); ?> - <small><?php _e('Import your', 'wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next', 'wetu-importer'); ?></small></h3>
235 235
 				<ul>
236 236
 				</ul>
237 237
 			</div>
@@ -244,20 +244,20 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	public function update_options_form() {
246 246
 		$tours = get_transient('lsx_ti_tours');
247
-		echo '<div class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').' - ';
248
-		if('' === $tours || false === $tours || isset($_GET['refresh_tours'])){
247
+		echo '<div class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').' - ';
248
+		if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) {
249 249
 			$result = $this->update_options();
250 250
 
251
-			if(true === $result){
252
-			    echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
253
-			    if(!isset($_GET['refresh_tours'])){
254
-			        echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>';
251
+			if (true === $result) {
252
+			    echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>';
253
+			    if (!isset($_GET['refresh_tours'])) {
254
+			        echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh', 'wetu-importer').'</a></small>';
255 255
                 }
256
-            }else{
256
+            }else {
257 257
 			    echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
258 258
             }
259
-		}else{
260
-			echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>';
259
+		}else {
260
+			echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span> - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh', 'wetu-importer').'</a></small>';
261 261
         }
262 262
 		echo '</h3></div>';
263 263
 	}
@@ -266,13 +266,13 @@  discard block
 block discarded – undo
266 266
 	 * Save the list of Tours into an option
267 267
 	 */
268 268
 	public function update_options() {
269
-		$data = file_get_contents( $this->url . '/V7/List?' . $this->url_qs . '&own=true&type=All' );
269
+		$data = file_get_contents($this->url.'/V7/List?'.$this->url_qs.'&own=true&type=All');
270 270
 		$tours = json_decode($data, true);
271 271
 
272
-		if(isset($tours['error'])){
272
+		if (isset($tours['error'])) {
273 273
 		    return $tours['error'];
274 274
         }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
275
-			set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2);
275
+			set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2);
276 276
 			return true;
277 277
 		}
278 278
 	}
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
 
297 297
 					LIMIT 0,500
298 298
 		");
299
-		if(null !== $current_tours && !empty($current_tours)){
300
-			foreach($current_tours as $tour){
299
+		if (null !== $current_tours && !empty($current_tours)) {
300
+			foreach ($current_tours as $tour) {
301 301
 				$return[$tour->meta_value] = $tour;
302 302
 			}
303 303
 		}
@@ -310,36 +310,36 @@  discard block
 block discarded – undo
310 310
 	public function process_ajax_search() {
311 311
 		$return = false;
312 312
 
313
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug){
313
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) {
314 314
 			$tours = get_transient('lsx_ti_tours');
315
-			if ( false !== $tours) {
315
+			if (false !== $tours) {
316 316
 
317 317
 				$searched_items = false;
318 318
 
319
-				if(isset($_POST['keyword'] )) {
319
+				if (isset($_POST['keyword'])) {
320 320
 					$keyphrases = $_POST['keyword'];
321
-				}else{
321
+				}else {
322 322
 					$keyphrases = array(0);
323 323
                 }
324 324
 
325
-				if(!is_array($keyphrases)){
325
+				if (!is_array($keyphrases)) {
326 326
 					$keyphrases = array($keyphrases);
327 327
 				}
328
-				foreach($keyphrases as &$keyword){
328
+				foreach ($keyphrases as &$keyword) {
329 329
 					$keyword = ltrim(rtrim($keyword));
330 330
 				}
331 331
 
332 332
 				$post_status = false;
333
-				if(in_array('publish',$keyphrases)){
333
+				if (in_array('publish', $keyphrases)) {
334 334
 					$post_status = 'publish';
335 335
 				}
336
-				if(in_array('pending',$keyphrases)){
336
+				if (in_array('pending', $keyphrases)) {
337 337
 					$post_status = 'pending';
338 338
 				}
339
-				if(in_array('draft',$keyphrases)){
339
+				if (in_array('draft', $keyphrases)) {
340 340
 					$post_status = 'draft';
341 341
 				}
342
-				if(in_array('import',$keyphrases)){
342
+				if (in_array('import', $keyphrases)) {
343 343
 					$post_status = 'import';
344 344
 				}
345 345
 
@@ -347,9 +347,9 @@  discard block
 block discarded – undo
347 347
 				if (!empty($tours)) {
348 348
 					$current_tours = $this->find_current_tours();
349 349
 
350
-					foreach($tours as $row_key => $row){
350
+					foreach ($tours as $row_key => $row) {
351 351
 
352
-					    if(isset($row['is_disabled']) && true === $row['is_disabled']){
352
+					    if (isset($row['is_disabled']) && true === $row['is_disabled']) {
353 353
                             continue;
354 354
                         }
355 355
 
@@ -359,29 +359,29 @@  discard block
 block discarded – undo
359 359
 
360 360
                         //If this is a current tour, add its ID to the row.
361 361
 						$row['post_id'] = 0;
362
-						if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){
362
+						if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) {
363 363
 							$row['post_id'] = $current_tours[$row['identifier']]->post_id;
364 364
 						}
365 365
 
366 366
 						//If we are searching for
367
-						if(false !== $post_status){
367
+						if (false !== $post_status) {
368 368
 
369
-                            if('import' === $post_status){
369
+                            if ('import' === $post_status) {
370 370
 
371
-								if(0 !== $row['post_id']){
371
+								if (0 !== $row['post_id']) {
372 372
 								    continue;
373
-								}else{
373
+								}else {
374 374
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
375 375
                                 }
376 376
 
377 377
 
378
-                            }else{
378
+                            }else {
379 379
 
380
-								if(0 === $row['post_id']){
380
+								if (0 === $row['post_id']) {
381 381
 									continue;
382
-								}else{
382
+								}else {
383 383
 									$current_status = get_post_status($row['post_id']);
384
-									if($current_status !== $post_status){
384
+									if ($current_status !== $post_status) {
385 385
 									    continue;
386 386
                                     }
387 387
 
@@ -390,17 +390,17 @@  discard block
 block discarded – undo
390 390
 
391 391
                             }
392 392
 
393
-                        }else{
393
+                        }else {
394 394
 							//Search through each keyword.
395
-							foreach($keyphrases as $keyphrase){
395
+							foreach ($keyphrases as $keyphrase) {
396 396
 
397 397
 								//Make sure the keyphrase is turned into an array
398
-								$keywords = explode(" ",$keyphrase);
399
-								if(!is_array($keywords)){
398
+								$keywords = explode(" ", $keyphrase);
399
+								if (!is_array($keywords)) {
400 400
 									$keywords = array($keywords);
401 401
 								}
402 402
 
403
-								if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){
403
+								if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) {
404 404
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
405 405
 								}
406 406
 							}
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 					}		
409 409
 				}
410 410
 
411
-				if(false !== $searched_items){
411
+				if (false !== $searched_items) {
412 412
 					ksort($searched_items);
413 413
 					$return = implode($searched_items);
414 414
 				}
@@ -421,11 +421,11 @@  discard block
 block discarded – undo
421 421
 	/**
422 422
 	 * Formats the row for output on the screen.
423 423
 	 */	
424
-	public function format_row($row = false){
425
-		if(false !== $row){
424
+	public function format_row($row = false) {
425
+		if (false !== $row) {
426 426
 
427 427
 			$status = 'import';
428
-			if(0 !== $row['post_id']){
428
+			if (0 !== $row['post_id']) {
429 429
 				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
430 430
 			}
431 431
 
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 					<strong>'.$row['name'].'</strong> - '.$status.'
440 440
 				</td>
441 441
 				<td class="date column-date">
442
-					<abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified
442
+					<abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
443 443
 				</td>
444 444
 				<td class="ssid column-ssid">
445 445
 					'.$row['identifier'].'
@@ -454,31 +454,31 @@  discard block
 block discarded – undo
454 454
 	 */
455 455
 	public function process_ajax_import($force = false) {
456 456
 		$return = false;
457
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])){
457
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) {
458 458
 			
459 459
 			$wetu_id = $_POST['wetu_id'];
460
-			if(isset($_POST['post_id'])){
460
+			if (isset($_POST['post_id'])) {
461 461
 				$post_id = $_POST['post_id'];	
462
-			}else{
462
+			}else {
463 463
 				$post_id = 0;
464 464
 			}
465 465
 
466
-			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
466
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
467 467
 				$content = $_POST['content'];
468
-				add_option('wetu_importer_tour_settings',$content);
469
-			}else{
468
+				add_option('wetu_importer_tour_settings', $content);
469
+			}else {
470 470
 				delete_option('wetu_importer_tour_settings');
471 471
 				$content = false;
472 472
 			}
473 473
 
474
-            $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
474
+            $jdata = file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
475 475
 
476
-            if($jdata)
476
+            if ($jdata)
477 477
             {
478
-				$jdata=json_decode($jdata,true);
479
-                if(!empty($jdata))
478
+				$jdata = json_decode($jdata, true);
479
+                if (!empty($jdata))
480 480
                 {
481
-                	$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
481
+                	$return = $this->import_row($jdata, $wetu_id, $post_id, $content);
482 482
                 	$this->format_completed_row($return);
483 483
                 	$this->cleanup_posts();
484 484
                 }
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
      * @param $data array
495 495
      * @param $wetu_id string
496 496
 	 */
497
-	public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) {
497
+	public function import_row($data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false) {
498 498
         $post_name = $data_post_content = $data_post_excerpt = '';
499 499
         $post = array(
500 500
           'post_type'		=> 'tour',
@@ -502,29 +502,29 @@  discard block
 block discarded – undo
502 502
 
503 503
         //Set the post_content
504 504
 		$content_used_general_description = false;
505
-        if(false !== $importable_content && in_array('description',$importable_content)){
505
+        if (false !== $importable_content && in_array('description', $importable_content)) {
506 506
             $data_post_content = '';
507 507
 
508
-            if(isset($data['description'])){
508
+            if (isset($data['description'])) {
509 509
                 $data_post_content = $data['description'];
510
-            }elseif(isset($data['summary'])){
510
+            }elseif (isset($data['summary'])) {
511 511
                 $data_post_content = $data['summary'];
512 512
             }
513 513
             $post['post_content'] = $data_post_content;
514 514
         }
515 515
 
516 516
         //Create or update the post
517
-        if(false !== $id && '0' !== $id){
517
+        if (false !== $id && '0' !== $id) {
518 518
             $post['ID'] = $id;
519 519
 	        $post['post_status'] = 'publish';
520 520
             $id = wp_update_post($post);
521
-            $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
522
-            update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
523
-        }else{
521
+            $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
522
+            update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']), $prev_date);
523
+        }else {
524 524
 
525 525
             //Set the name
526
-            if(isset($data['name'])){
527
-                $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
526
+            if (isset($data['name'])) {
527
+                $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0);
528 528
             }
529 529
             $post['post_name'] = $post_name;
530 530
             $post['post_title'] = $data['name'];
@@ -532,51 +532,51 @@  discard block
 block discarded – undo
532 532
             $id = wp_insert_post($post);
533 533
 
534 534
             //Save the WETU ID and the Last date it was modified.
535
-            if(false !== $id){
536
-                add_post_meta($id,'lsx_wetu_id',$wetu_id);
537
-                add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
535
+            if (false !== $id) {
536
+                add_post_meta($id, 'lsx_wetu_id', $wetu_id);
537
+                add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']));
538 538
             }
539 539
         }
540 540
 
541 541
 
542 542
 		//Set the price
543
-		if(false !== $importable_content && in_array('price',$importable_content)){
544
-			$this->set_price($data,$id);
543
+		if (false !== $importable_content && in_array('price', $importable_content)) {
544
+			$this->set_price($data, $id);
545 545
 		}
546 546
 
547 547
 		//Set the Duration
548
-		if(false !== $importable_content && in_array('duration',$importable_content)){
549
-			$this->set_duration($data,$id);
548
+		if (false !== $importable_content && in_array('duration', $importable_content)) {
549
+			$this->set_duration($data, $id);
550 550
 		}
551 551
 
552
-        if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
553
-            $this->process_itineraries($data,$id,$importable_content);
552
+        if (in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) {
553
+            $this->process_itineraries($data, $id, $importable_content);
554 554
         }
555 555
 
556
-		if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){
557
-			$this->process_map_points($data,$id);
556
+		if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) {
557
+			$this->process_map_points($data, $id);
558 558
 		}
559 559
 
560 560
 		//TODO Test These
561 561
 		//Setup some default for use in the import
562
-		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))){
562
+		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))) {
563 563
 			$this->find_attachments($id);
564 564
 		}
565 565
         //Set the featured image
566 566
         //TODO Test These
567
-        if(false !== $importable_content && in_array('featured_image',$importable_content)){
568
-            $this->set_featured_image($data,$id);
567
+        if (false !== $importable_content && in_array('featured_image', $importable_content)) {
568
+            $this->set_featured_image($data, $id);
569 569
         }
570 570
 
571 571
 		//TODO Test These
572
-        if(false !== $importable_content && in_array('banner_image',$importable_content)){
573
-            $this->set_banner_image($data,$id);
572
+        if (false !== $importable_content && in_array('banner_image', $importable_content)) {
573
+            $this->set_banner_image($data, $id);
574 574
         }
575 575
 
576 576
 		//TODO Test These
577 577
         //Import the main gallery
578
-        if(false !== $importable_content && in_array('gallery',$importable_content)){
579
-            $this->create_main_gallery($data,$id);
578
+        if (false !== $importable_content && in_array('gallery', $importable_content)) {
579
+            $this->create_main_gallery($data, $id);
580 580
         }
581 581
 
582 582
         return $id;
@@ -585,151 +585,151 @@  discard block
 block discarded – undo
585 585
 	/**
586 586
 	 * A loop which runs through each leg on the tour.
587 587
 	 */
588
-	public function process_itineraries($data,$id,$importable_content) {
588
+	public function process_itineraries($data, $id, $importable_content) {
589 589
 		$day_counter = 1;
590 590
 		$leg_counter = 0;
591 591
 
592
-		delete_post_meta($id,'itinerary');
592
+		delete_post_meta($id, 'itinerary');
593 593
 
594
-		if(false !== $importable_content && in_array('accommodation',$importable_content)){
595
-			delete_post_meta($id,'accommodation_to_tour');
594
+		if (false !== $importable_content && in_array('accommodation', $importable_content)) {
595
+			delete_post_meta($id, 'accommodation_to_tour');
596 596
 		}
597
-		if(false !== $importable_content && in_array('destination',$importable_content)){
598
-			delete_post_meta($id,'destination_to_tour');
599
-			delete_post_meta($id,'departs_from');
600
-			delete_post_meta($id,'ends_in');
597
+		if (false !== $importable_content && in_array('destination', $importable_content)) {
598
+			delete_post_meta($id, 'destination_to_tour');
599
+			delete_post_meta($id, 'departs_from');
600
+			delete_post_meta($id, 'ends_in');
601 601
 		}
602 602
 
603 603
 		$departs_from = false;
604 604
 		$ends_in = false;
605 605
 
606
-		foreach($data['legs'] as $leg){
606
+		foreach ($data['legs'] as $leg) {
607 607
 
608
-			if(isset($leg['days']) && !empty($leg['days'])){
608
+			if (isset($leg['days']) && !empty($leg['days'])) {
609 609
 
610 610
 				//Itinerary Accommodation
611 611
 				$current_accommodation = false;
612
-				if(false !== $importable_content && in_array('accommodation',$importable_content)){
613
-					$current_accommodation = $this->set_accommodation($leg,$id);
612
+				if (false !== $importable_content && in_array('accommodation', $importable_content)) {
613
+					$current_accommodation = $this->set_accommodation($leg, $id);
614 614
 				}
615 615
 
616 616
 				//Itinerary Destination
617 617
 				$current_destination = false;
618
-				if(false !== $importable_content && in_array('destination',$importable_content)){
619
-					$current_destination = $this->set_destination($leg,$id);
618
+				if (false !== $importable_content && in_array('destination', $importable_content)) {
619
+					$current_destination = $this->set_destination($leg, $id);
620 620
 				}
621 621
 
622 622
 				//If the Nights are the same mount of days in the array,  then it isnt "By Destination"
623
-				if($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']){
623
+				if ($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']) {
624 624
 
625
-					foreach($leg['days'] as $day){
625
+					foreach ($leg['days'] as $day) {
626 626
 
627 627
 						$current_day = array();
628 628
 
629
-						$current_day['title'] =  esc_attr('Day ','wetu-importer').$day_counter;
629
+						$current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter;
630 630
 
631 631
 						//print_r('<pre>');print_r($day['notes']);print_r('</pre>');
632 632
 
633 633
 						//Description
634
-						if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){
634
+						if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) {
635 635
 							$current_day['description'] = $day['notes'];
636
-						}else{
636
+						}else {
637 637
 							$current_day['description'] = '';
638 638
 						}
639 639
 
640 640
 						//Itinerary Gallery
641
-						if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){
641
+						if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) {
642 642
 							$current_day['featured_image'] = '';
643
-						}else{
643
+						}else {
644 644
 							$current_day['featured_image'] = '';
645 645
 						}
646 646
 
647 647
 						//Accommodation
648
-						if(false !== $current_accommodation){
648
+						if (false !== $current_accommodation) {
649 649
 							$current_day['accommodation_to_tour'] = array($current_accommodation);
650
-						}else{
650
+						}else {
651 651
 							$current_day['accommodation_to_tour'] = array();
652 652
 						}
653 653
 
654 654
 						//Destination
655
-						if(false !== $current_destination){
655
+						if (false !== $current_destination) {
656 656
 							$current_day['destination_to_tour'] = array($current_destination);
657
-						}else{
657
+						}else {
658 658
 							$current_day['destination_to_tour'] = array();
659 659
 						}
660 660
 
661 661
 						//Included
662
-						if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){
662
+						if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) {
663 663
 							$current_day['included'] = $day['included'];
664
-						}else{
664
+						}else {
665 665
 							$current_day['included'] = '';
666 666
 						}
667 667
 
668 668
 						//Excluded
669
-						if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){
669
+						if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) {
670 670
 							$current_day['excluded'] = $day['excluded'];
671
-						}else{
671
+						}else {
672 672
 							$current_day['excluded'] = '';
673 673
 						}
674 674
 
675
-						$this->set_itinerary_day($current_day,$id);
675
+						$this->set_itinerary_day($current_day, $id);
676 676
 						$day_counter++;
677 677
 					}
678 678
 
679
-				}else{
680
-					$day_counter = $day_counter + (int)$leg['nights'];
679
+				}else {
680
+					$day_counter = $day_counter + (int) $leg['nights'];
681 681
 				}
682 682
 
683 683
 			}
684 684
 
685 685
 			//If we are in the first leg,  and the destination was attached then save it as the departure field.
686
-			if( 0 === $leg_counter && false !== $current_destination){
686
+			if (0 === $leg_counter && false !== $current_destination) {
687 687
 				$departs_from = $current_destination;
688 688
 			}
689 689
 
690 690
 			//If its the last leg then save it as the ends in.
691
-			if( $leg_counter === (count($data['legs'])-2) && false !== $current_destination){
691
+			if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) {
692 692
 				$ends_in = $current_destination;
693 693
 			}
694 694
 			$leg_counter++;
695 695
 		}
696 696
 
697
-		if(false !== $departs_from){
698
-			add_post_meta($id,'departs_from',$departs_from,true);
697
+		if (false !== $departs_from) {
698
+			add_post_meta($id, 'departs_from', $departs_from, true);
699 699
 		}
700
-		if(false !== $ends_in){
701
-			add_post_meta($id,'ends_in',$ends_in,true);
700
+		if (false !== $ends_in) {
701
+			add_post_meta($id, 'ends_in', $ends_in, true);
702 702
 		}
703 703
 	}
704 704
 
705 705
 	/**
706 706
 	 * Run through your routes and save the points as a KML file.
707 707
 	 */
708
-	public function process_map_points($data,$id) {
708
+	public function process_map_points($data, $id) {
709 709
 
710
-	    if(!empty($data['routes'])){
710
+	    if (!empty($data['routes'])) {
711 711
 
712
-	        delete_post_meta($id,'wetu_map_points');
712
+	        delete_post_meta($id, 'wetu_map_points');
713 713
 
714 714
 	        $points = array();
715 715
 
716
-	        foreach($data['routes'] as $route){
716
+	        foreach ($data['routes'] as $route) {
717 717
 
718 718
 
719
-	            if(isset($route['points']) && '' !== $route['points']){
719
+	            if (isset($route['points']) && '' !== $route['points']) {
720 720
 
721
-	                $temp_points = explode(';',$route['points']);
721
+	                $temp_points = explode(';', $route['points']);
722 722
 	                $point_counter = count($temp_points);
723 723
 
724 724
 					for ($x = 0; $x <= $point_counter; $x++) {
725
-					    $y = $x+1;
725
+					    $y = $x + 1;
726 726
 						$points[] = $temp_points[$x].','.$temp_points[$y];
727 727
 						$x++;
728 728
 					}
729 729
 				}
730 730
             }
731
-            if(!empty($points)){
732
-				$this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true);
731
+            if (!empty($points)) {
732
+				$this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true);
733 733
             }
734 734
         }
735 735
 
@@ -738,28 +738,28 @@  discard block
 block discarded – undo
738 738
 	/**
739 739
 	 * Set the Itinerary Day
740 740
 	 */
741
-	public function set_itinerary_day($day,$id) {
742
-        $this->save_custom_field($day,'itinerary',$id,false,false);
741
+	public function set_itinerary_day($day, $id) {
742
+        $this->save_custom_field($day, 'itinerary', $id, false, false);
743 743
 	}
744 744
 
745 745
 	/**
746 746
 	 * Set the price
747 747
 	 */
748
-	public function set_price($data,$id) {
748
+	public function set_price($data, $id) {
749 749
 	    //Price
750
-		if(isset($data['price']) && ''!== $data['price']){
750
+		if (isset($data['price']) && '' !== $data['price']) {
751 751
             $price = preg_replace("/[^0-9,.]/", "", $data['price']);
752
-            $this->save_custom_field($price,'price',$id);
752
+            $this->save_custom_field($price, 'price', $id);
753 753
 		}
754 754
 
755 755
 		//Price includes
756
-		if(isset($data['price_includes']) && ''!== $data['price_includes']){
757
-			$this->save_custom_field($data['price_includes'],'included',$id);
756
+		if (isset($data['price_includes']) && '' !== $data['price_includes']) {
757
+			$this->save_custom_field($data['price_includes'], 'included', $id);
758 758
 		}
759 759
 
760 760
         //Price Excludes
761
-		if(isset($data['price_excludes']) && ''!== $data['price_excludes']){
762
-			$this->save_custom_field($data['price_excludes'],'not_included',$id);
761
+		if (isset($data['price_excludes']) && '' !== $data['price_excludes']) {
762
+			$this->save_custom_field($data['price_excludes'], 'not_included', $id);
763 763
 		}
764 764
 
765 765
 	}
@@ -767,38 +767,38 @@  discard block
 block discarded – undo
767 767
 	/**
768 768
 	 * Set the duration
769 769
 	 */
770
-	public function set_duration($data,$id) {
771
-		if(isset($data['days']) && !empty($data['days'])){
770
+	public function set_duration($data, $id) {
771
+		if (isset($data['days']) && !empty($data['days'])) {
772 772
 			$price = $data['days'];
773 773
 			$price = preg_replace("/[^0-9,.]/", "", $price);
774
-			$this->save_custom_field($price,'duration',$id);
774
+			$this->save_custom_field($price, 'duration', $id);
775 775
 		}
776 776
 	}
777 777
 
778 778
 	/**
779 779
 	 * Connects the Accommodation if its available
780 780
 	 */
781
-	public function set_accommodation($day,$id) {
781
+	public function set_accommodation($day, $id) {
782 782
 
783 783
 	    $ac_id = false;
784 784
 		$this->current_accommodation = $this->find_current_accommodation();
785 785
 		
786
-		if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){
786
+		if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) {
787 787
 
788
-			if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){
788
+			if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) {
789 789
                 $ac_id = $this->current_accommodation[$day['content_entity_id']];
790
-			}else{
790
+			}else {
791 791
 				$ac_id = wp_insert_post(array(
792 792
                     'post_type' => 'accommodation',
793 793
                     'post_status' => 'draft',
794 794
                     'post_title' => $day['content_entity_id']
795 795
                 ));
796
-				$this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id);
796
+				$this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id);
797 797
 			}
798 798
 
799
-			if('' !== $ac_id && false !== $ac_id){
800
-			    $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
801
-				$this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false);
799
+			if ('' !== $ac_id && false !== $ac_id) {
800
+			    $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false);
801
+				$this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false);
802 802
             }
803 803
 		}
804 804
 		return $ac_id;
@@ -810,13 +810,13 @@  discard block
 block discarded – undo
810 810
      * @param $post_type string
811 811
      * @return boolean / array
812 812
 	 */
813
-	public function find_current_accommodation($post_type='accommodation') {
813
+	public function find_current_accommodation($post_type = 'accommodation') {
814 814
 		global $wpdb;
815 815
 		$accommodation = parent::find_current_accommodation($post_type);
816 816
 
817 817
 		$return = false;
818
-		if(!empty($accommodation)){
819
-		    foreach($accommodation as $key => $acc){
818
+		if (!empty($accommodation)) {
819
+		    foreach ($accommodation as $key => $acc) {
820 820
 				$return[$acc->meta_value] = $acc->post_id;
821 821
             }
822 822
         }
@@ -838,26 +838,26 @@  discard block
 block discarded – undo
838 838
 	 * @param $id string
839 839
 	 * @return boolean / string
840 840
 	 */
841
-	public function set_destination($day,$id) {
841
+	public function set_destination($day, $id) {
842 842
 		$dest_id = false;
843 843
 		$country_id = false;
844 844
 		$this->current_destinations = $this->find_current_destinations();
845 845
 
846
-		if(isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])){
846
+		if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) {
847 847
 
848
-			if(false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'],$this->current_destinations)){
848
+			if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) {
849 849
 				$dest_id = $this->current_destinations[$day['destination_content_entity_id']];
850 850
 
851 851
 				//Check if there is a country asigned.
852 852
 				$potential_id = wp_get_post_parent_id($dest_id);
853
-				$country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true);
854
-				if(false !== $country_wetu_id){
853
+				$country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true);
854
+				if (false !== $country_wetu_id) {
855 855
 					$country_id = $this->set_country($country_wetu_id, $id);
856 856
                 }
857 857
 
858 858
 			}else {
859 859
 
860
-				$destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']);
860
+				$destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$day['destination_content_entity_id']);
861 861
 
862 862
 				if ($destination_json) {
863 863
 					$destination_data = json_decode($destination_json, true);
@@ -866,12 +866,12 @@  discard block
 block discarded – undo
866 866
 
867 867
 					    $destination_title = $day['destination_content_entity_id'];
868 868
 
869
-					    if(isset($destination_data[0]['name'])){
869
+					    if (isset($destination_data[0]['name'])) {
870 870
 							$destination_title = $destination_data[0]['name'];
871 871
                         }
872 872
 
873
-					    if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
874
-                            && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
873
+					    if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
874
+                            && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) {
875 875
 
876 876
 							$country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id);
877 877
                         }
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 							'post_title' => $destination_title
883 883
 						);
884 884
 
885
-					    if(false !== $country_id){
885
+					    if (false !== $country_id) {
886 886
 							$dest_post['post_parent'] = $country_id;
887 887
                         }
888 888
 						$dest_id = wp_insert_post($dest_post);
@@ -901,10 +901,10 @@  discard block
 block discarded – undo
901 901
 				$this->cleanup_posts[$dest_id] = 'tour_to_destination';
902 902
 
903 903
 				//Add this relation info so we can make sure certain items are set as countries.
904
-				if(0 !== $country_id && false !== $country_id){
904
+				if (0 !== $country_id && false !== $country_id) {
905 905
                     $this->relation_meta[$dest_id] = $country_id;
906 906
 					$this->relation_meta[$country_id] = 0;
907
-                }else{
907
+                }else {
908 908
 					$this->relation_meta[$dest_id] = 0;
909 909
                 }
910 910
 			}
@@ -925,9 +925,9 @@  discard block
 block discarded – undo
925 925
 
926 926
         if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
927 927
             $country_id = $this->current_destinations[$country_wetu_id];
928
-        } else {
928
+        }else {
929 929
 
930
-            $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
930
+            $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$country_wetu_id);
931 931
 
932 932
             if ($country_json) {
933 933
                 $country_data = json_decode($country_json, true);
Please login to merge, or discard this patch.