Completed
Push — master ( 0094c4...4775bf )
by Warwick
02:42
created
classes/class-tours.php 1 patch
Spacing   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -99,21 +99,21 @@  discard block
 block discarded – undo
99 99
 	{
100 100
 	    parent::set_variables();
101 101
 
102
-		if ( false !== $this->api_username && false !== $this->api_password ) {
102
+		if (false !== $this->api_username && false !== $this->api_password) {
103 103
 			$this->url    = 'https://wetu.com/API/Itinerary/';
104
-			$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
105
-		} elseif ( false !== $this->api_key ) {
106
-			$this->url    = 'https://wetu.com/API/Itinerary/' . $this->api_key;
104
+			$this->url_qs = 'username='.$this->api_username.'&password='.$this->api_password;
105
+		} elseif (false !== $this->api_key) {
106
+			$this->url    = 'https://wetu.com/API/Itinerary/'.$this->api_key;
107 107
 			$this->url_qs = '';
108 108
 		}
109 109
 
110
-		$temp_options = get_option('_lsx-to_settings',false);
111
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){
110
+		$temp_options = get_option('_lsx-to_settings', false);
111
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
112 112
 			$this->options = $temp_options[$this->plugin_slug];
113 113
 		}
114 114
 
115
-		$tour_options = get_option('wetu_importer_tour_settings',false);
116
-		if(false !== $tour_options){
115
+		$tour_options = get_option('wetu_importer_tour_settings', false);
116
+		if (false !== $tour_options) {
117 117
 			$this->tour_options = $tour_options;
118 118
 		}
119 119
 	}
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 			<form method="get" action="" id="posts-filter">
134 134
 				<input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" />
135 135
 				
136
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
137
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
136
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
137
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
138 138
 				</p>				
139 139
 
140 140
 				<table class="wp-list-table widefat fixed posts">
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 					<tbody id="the-list">
144 144
 						<tr class="post-0 type-tour status-none" id="post-0">
145 145
 							<th class="check-column" scope="row">
146
-								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label>
146
+								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label>
147 147
 							</th>
148 148
 							<td class="post-title page-title column-title">
149 149
 								<strong>
150
-									<?php _e('Enter a title to search for','wetu-importer'); ?>
150
+									<?php _e('Enter a title to search for', 'wetu-importer'); ?>
151 151
 								</strong>
152 152
 							</td>
153 153
 							<td class="date column-date">							
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 
162 162
 				</table>
163 163
 
164
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
165
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
164
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
165
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
166 166
 				</p>
167 167
 			</form>
168 168
 
@@ -174,16 +174,16 @@  discard block
 block discarded – undo
174 174
 						<div class="settings-all" style="width:30%;display:block;float:left;">
175 175
 							<h3><?php _e('What content to Sync from WETU'); ?></h3>
176 176
 							<ul>
177
-                                <li><input class="content select-all" <?php $this->checked($this->tour_options,'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php _e('Select All','wetu-importer'); ?></li>
178
-								<li><input class="content" <?php $this->checked($this->tour_options,'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li>
179
-								<li><input class="content" <?php $this->checked($this->tour_options,'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li>
177
+                                <li><input class="content select-all" <?php $this->checked($this->tour_options, 'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php _e('Select All', 'wetu-importer'); ?></li>
178
+								<li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li>
179
+								<li><input class="content" <?php $this->checked($this->tour_options, 'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li>
180 180
 
181
-                                <li><input class="content" <?php $this->checked($this->tour_options,'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price','wetu-importer'); ?></li>
182
-                                <li><input class="content" <?php $this->checked($this->tour_options,'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration','wetu-importer'); ?></li>
181
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price', 'wetu-importer'); ?></li>
182
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration', 'wetu-importer'); ?></li>
183 183
 
184
-								<li><input class="content" <?php $this->checked($this->tour_options,'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li>
184
+								<li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li>
185 185
 
186
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days','wetu-importer'); ?></li>
186
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days', 'wetu-importer'); ?></li>
187 187
 
188 188
 								<?php /*if(class_exists('LSX_TO_Maps')){ ?>
189 189
                                     <li><input class="content" <?php $this->checked($this->tour_options,'map'); ?> type="checkbox" name="content[]" value="map" /> <?php _e('Map Coordinates (generates a KML file)','wetu-importer'); ?></li>
@@ -193,20 +193,20 @@  discard block
 block discarded – undo
193 193
                         <div class="settings-all" style="width:30%;display:block;float:left;">
194 194
                             <h3><?php _e('Itinerary Info'); ?></h3>
195 195
                             <ul>
196
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description','wetu-importer'); ?></li>
197
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included','wetu-importer'); ?></li>
198
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded','wetu-importer'); ?></li>
196
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description', 'wetu-importer'); ?></li>
197
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included', 'wetu-importer'); ?></li>
198
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded', 'wetu-importer'); ?></li>
199 199
                             </ul>
200 200
 
201 201
                             <h4><?php _e('Additional Content'); ?></h4>
202 202
                             <ul>
203
-                                <li><input class="content" <?php $this->checked($this->tour_options,'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation','wetu-importer'); ?></li>
204
-                                <li><input class="content" <?php $this->checked($this->tour_options,'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations','wetu-importer'); ?></li>
205
-                                <li><input class="content" <?php $this->checked($this->tour_options,'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php _e('Featured Image','wetu-importer'); ?></li>
206
-                                <li><input class="content" <?php $this->checked($this->tour_options,'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php _e('Banner Image','wetu-importer'); ?></li>
203
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation', 'wetu-importer'); ?></li>
204
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations', 'wetu-importer'); ?></li>
205
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php _e('Featured Image', 'wetu-importer'); ?></li>
206
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php _e('Banner Image', 'wetu-importer'); ?></li>
207 207
                             </ul>
208 208
                         </div>
209
-                        <?php if(class_exists('LSX_TO_Team')){ ?>
209
+                        <?php if (class_exists('LSX_TO_Team')) { ?>
210 210
                             <div style="width:30%;display:block;float:left;">
211 211
                                 <h3><?php _e('Assign a Team Member'); ?></h3>
212 212
                                 <?php $this->team_member_checkboxes($this->tour_options); ?>
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 
219 219
 
220 220
 					<h3><?php _e('Your List'); ?></h3>
221
-                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
221
+                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
222 222
 					<table class="wp-list-table widefat fixed posts">
223 223
 						<?php $this->table_header(); ?>
224 224
 
@@ -230,12 +230,12 @@  discard block
 block discarded – undo
230 230
 
231 231
 					</table>
232 232
 
233
-					<p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
233
+					<p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
234 234
 				</form>
235 235
 			</div>
236 236
 
237 237
 			<div style="display:none;" class="completed-list-wrapper">
238
-				<h3><?php _e('Completed','wetu-importer'); ?> - <small><?php _e('Import your','wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next','wetu-importer'); ?></small></h3>
238
+				<h3><?php _e('Completed', 'wetu-importer'); ?> - <small><?php _e('Import your', 'wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next', 'wetu-importer'); ?></small></h3>
239 239
 				<ul>
240 240
 				</ul>
241 241
 			</div>
@@ -249,23 +249,23 @@  discard block
 block discarded – undo
249 249
 	public function update_options_form() {
250 250
 		$tours = get_transient('lsx_ti_tours');
251 251
 
252
-		echo '<div class="wetu-status tour-wetu-status"><h3>'.__('Wetu Status','wetu-importer').' - ';
253
-		if('' === $tours || false === $tours || isset($_GET['refresh_tours'])){
252
+		echo '<div class="wetu-status tour-wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').' - ';
253
+		if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) {
254 254
 			$result = $this->update_options();
255 255
 
256
-			if(true === $result){
257
-			    echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
258
-                echo ' - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>';
259
-            }else{
256
+			if (true === $result) {
257
+			    echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>';
258
+                echo ' - <small><a href="#">'.esc_attr('Refresh', 'wetu-importer').'</a></small>';
259
+            }else {
260 260
 			    echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
261 261
             }
262
-		}else{
263
-			echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>';
262
+		}else {
263
+			echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh', 'wetu-importer').'</a></small>';
264 264
         }
265 265
 		echo '</h3>';
266 266
 
267 267
 		$form_options = get_option('lsx_ti_tours_api_options');
268
-		if(false === $form_options){
268
+		if (false === $form_options) {
269 269
 			$form_options = array(0);
270 270
         }
271 271
 		?>
@@ -276,16 +276,16 @@  discard block
 block discarded – undo
276 276
             <input type="hidden" name="refresh_tours" value="true" />
277 277
 
278 278
             <p class="tour-search-options">
279
-                <label for="own"><input class="content" <?php if(in_array('own',$form_options)){ echo 'checked'; } ?> type="checkbox" name="own" value="true" /> <?php esc_html_e('Own Tours','wetu-importer'); ?> </label>
279
+                <label for="own"><input class="content" <?php if (in_array('own', $form_options)) { echo 'checked'; } ?> type="checkbox" name="own" value="true" /> <?php esc_html_e('Own Tours', 'wetu-importer'); ?> </label>
280 280
             </p>
281 281
 
282 282
             <p class="tour-search-options">
283
-                <label for="type"><input class="content" <?php if(in_array('allitineraries',$form_options)){ echo 'checked'; } ?> type="radio" name="type[]" value="allitineraries" /> <?php _e('All','wetu-importer'); ?></label>
284
-                <label for="type"><input class="content" <?php if(in_array('sample',$form_options)){ echo 'checked'; } ?> type="radio" name="type[]" value="sample" /> <?php _e('Sample','wetu-importer'); ?></label>
285
-                <label for="type"><input class="content" <?php if(in_array('personal',$form_options)){ echo 'checked'; } ?> type="radio" name="type[]" value="personal" /> <?php _e('Personal','wetu-importer'); ?></label>
283
+                <label for="type"><input class="content" <?php if (in_array('allitineraries', $form_options)) { echo 'checked'; } ?> type="radio" name="type[]" value="allitineraries" /> <?php _e('All', 'wetu-importer'); ?></label>
284
+                <label for="type"><input class="content" <?php if (in_array('sample', $form_options)) { echo 'checked'; } ?> type="radio" name="type[]" value="sample" /> <?php _e('Sample', 'wetu-importer'); ?></label>
285
+                <label for="type"><input class="content" <?php if (in_array('personal', $form_options)) { echo 'checked'; } ?> type="radio" name="type[]" value="personal" /> <?php _e('Personal', 'wetu-importer'); ?></label>
286 286
             </p>
287 287
 
288
-            <p><input class="button button-primary submit" type="submit" value="<?php echo esc_attr('Refresh Tours','wetu-importer'); ?>"></p>
288
+            <p><input class="button button-primary submit" type="submit" value="<?php echo esc_attr('Refresh Tours', 'wetu-importer'); ?>"></p>
289 289
         </form>
290 290
 <br />
291 291
 		<?php
@@ -302,28 +302,28 @@  discard block
 block discarded – undo
302 302
 
303 303
 	    delete_option('lsx_ti_tours_api_options');
304 304
 
305
-	    if(isset($_GET['own'])){
305
+	    if (isset($_GET['own'])) {
306 306
 			$this->url_qs .= '&own=true';
307 307
 			$options[] = 'own';
308 308
         }
309 309
 
310
-		if(isset($_GET['type'])){
311
-			$this->url_qs .= '&type='.implode('',$_GET['type']);
312
-			$options[] = implode('',$_GET['type']);
310
+		if (isset($_GET['type'])) {
311
+			$this->url_qs .= '&type='.implode('', $_GET['type']);
312
+			$options[] = implode('', $_GET['type']);
313 313
 		}
314 314
 
315 315
 		$this->url_qs .= '&results=2000';
316 316
 
317
-		add_option('lsx_ti_tours_api_options',$options);
317
+		add_option('lsx_ti_tours_api_options', $options);
318 318
 
319
-		$data = file_get_contents( $this->url . '/V7/List?' . $this->url_qs );
319
+		$data = file_get_contents($this->url.'/V7/List?'.$this->url_qs);
320 320
 
321 321
 		$tours = json_decode($data, true);
322 322
 
323
-		if(isset($tours['error'])){
323
+		if (isset($tours['error'])) {
324 324
 		    return $tours['error'];
325 325
         }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
326
-			set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2);
326
+			set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2);
327 327
 			return true;
328 328
 		}
329 329
 	}
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
 
348 348
 					LIMIT 0,500
349 349
 		");
350
-		if(null !== $current_tours && !empty($current_tours)){
351
-			foreach($current_tours as $tour){
350
+		if (null !== $current_tours && !empty($current_tours)) {
351
+			foreach ($current_tours as $tour) {
352 352
 				$return[$tour->meta_value] = $tour;
353 353
 			}
354 354
 		}
@@ -361,38 +361,38 @@  discard block
 block discarded – undo
361 361
 	public function process_ajax_search() {
362 362
 		$return = false;
363 363
 
364
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug){
364
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) {
365 365
 
366 366
 
367 367
 			$tours = get_transient('lsx_ti_tours');
368
-			if ( false !== $tours) {
368
+			if (false !== $tours) {
369 369
 
370 370
 				$searched_items = false;
371 371
 
372
-				if(isset($_POST['keyword'] )) {
372
+				if (isset($_POST['keyword'])) {
373 373
 					$keyphrases = $_POST['keyword'];
374
-				}else{
374
+				}else {
375 375
 					$keyphrases = array(0);
376 376
 				}
377 377
 
378
-				if(!is_array($keyphrases)){
378
+				if (!is_array($keyphrases)) {
379 379
 					$keyphrases = array($keyphrases);
380 380
 				}
381
-				foreach($keyphrases as &$keyword){
381
+				foreach ($keyphrases as &$keyword) {
382 382
 					$keyword = ltrim(rtrim($keyword));
383 383
 				}
384 384
 
385 385
 				$post_status = false;
386
-				if(in_array('publish',$keyphrases)){
386
+				if (in_array('publish', $keyphrases)) {
387 387
 					$post_status = 'publish';
388 388
 				}
389
-				if(in_array('pending',$keyphrases)){
389
+				if (in_array('pending', $keyphrases)) {
390 390
 					$post_status = 'pending';
391 391
 				}
392
-				if(in_array('draft',$keyphrases)){
392
+				if (in_array('draft', $keyphrases)) {
393 393
 					$post_status = 'draft';
394 394
 				}
395
-				if(in_array('import',$keyphrases)){
395
+				if (in_array('import', $keyphrases)) {
396 396
 					$post_status = 'import';
397 397
 				}
398 398
 
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
 				if (!empty($tours)) {
401 401
 					$current_tours = $this->find_current_tours();
402 402
 
403
-					foreach($tours as $row_key => $row){
403
+					foreach ($tours as $row_key => $row) {
404 404
 
405
-						if(isset($row['is_disabled']) && true === $row['is_disabled']){
405
+						if (isset($row['is_disabled']) && true === $row['is_disabled']) {
406 406
 							continue;
407 407
 						}
408 408
 
@@ -412,29 +412,29 @@  discard block
 block discarded – undo
412 412
 
413 413
 						//If this is a current tour, add its ID to the row.
414 414
 						$row['post_id'] = 0;
415
-						if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){
415
+						if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) {
416 416
 							$row['post_id'] = $current_tours[$row['identifier']]->post_id;
417 417
 						}
418 418
 
419 419
 						//If we are searching for
420
-						if(false !== $post_status){
420
+						if (false !== $post_status) {
421 421
 
422
-							if('import' === $post_status){
422
+							if ('import' === $post_status) {
423 423
 
424
-								if(0 !== $row['post_id']){
424
+								if (0 !== $row['post_id']) {
425 425
 									continue;
426
-								}else{
426
+								}else {
427 427
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
428 428
 								}
429 429
 
430 430
 
431
-							}else{
431
+							}else {
432 432
 
433
-								if(0 === $row['post_id']){
433
+								if (0 === $row['post_id']) {
434 434
 									continue;
435
-								}else{
435
+								}else {
436 436
 									$current_status = get_post_status($row['post_id']);
437
-									if($current_status !== $post_status){
437
+									if ($current_status !== $post_status) {
438 438
 										continue;
439 439
 									}
440 440
 
@@ -443,17 +443,17 @@  discard block
 block discarded – undo
443 443
 
444 444
 							}
445 445
 
446
-						}else{
446
+						}else {
447 447
 							//Search through each keyword.
448
-							foreach($keyphrases as $keyphrase){
448
+							foreach ($keyphrases as $keyphrase) {
449 449
 
450 450
 								//Make sure the keyphrase is turned into an array
451
-								$keywords = explode(" ",$keyphrase);
452
-								if(!is_array($keywords)){
451
+								$keywords = explode(" ", $keyphrase);
452
+								if (!is_array($keywords)) {
453 453
 									$keywords = array($keywords);
454 454
 								}
455 455
 
456
-								if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){
456
+								if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) {
457 457
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
458 458
 								}
459 459
 							}
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 					}
462 462
 				}
463 463
 
464
-				if(false !== $searched_items){
464
+				if (false !== $searched_items) {
465 465
 					ksort($searched_items);
466 466
 					$return = implode($searched_items);
467 467
 				}
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
 	/**
475 475
 	 * Formats the row for output on the screen.
476 476
 	 */	
477
-	public function format_row($row = false){
478
-		if(false !== $row){
477
+	public function format_row($row = false) {
478
+		if (false !== $row) {
479 479
 
480 480
 			$status = 'import';
481
-			if(0 !== $row['post_id']){
481
+			if (0 !== $row['post_id']) {
482 482
 				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
483 483
 			}
484 484
 
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 					<strong>'.$row['name'].'</strong> - '.$status.'
493 493
 				</td>
494 494
 				<td class="date column-date">
495
-					<abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified
495
+					<abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
496 496
 				</td>
497 497
 				<td class="ssid column-ssid">
498 498
 					'.$row['identifier'].'
@@ -508,31 +508,31 @@  discard block
 block discarded – undo
508 508
 	public function process_ajax_import($force = false) {
509 509
 		$return = false;
510 510
 
511
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])){
511
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) {
512 512
 			
513 513
 			$wetu_id = $_POST['wetu_id'];
514
-			if(isset($_POST['post_id'])){
514
+			if (isset($_POST['post_id'])) {
515 515
 				$post_id = $_POST['post_id'];	
516
-			}else{
516
+			}else {
517 517
 				$post_id = 0;
518 518
 			}
519 519
 
520 520
 			delete_option('wetu_importer_tour_settings');
521
-			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
521
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
522 522
 				$content = $_POST['content'];
523
-				add_option('wetu_importer_tour_settings',$content);
524
-			}else{
523
+				add_option('wetu_importer_tour_settings', $content);
524
+			}else {
525 525
 				$content = false;
526 526
 			}
527 527
 
528
-            $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
528
+            $jdata = file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
529 529
 
530
-            if($jdata)
530
+            if ($jdata)
531 531
             {
532
-				$jdata=json_decode($jdata,true);
533
-                if(!empty($jdata))
532
+				$jdata = json_decode($jdata, true);
533
+                if (!empty($jdata))
534 534
                 {
535
-                	$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
535
+                	$return = $this->import_row($jdata, $wetu_id, $post_id, $content);
536 536
                 	$this->format_completed_row($return);
537 537
                 	$this->cleanup_posts();
538 538
                 	$this->attach_destination_images($content);
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
      * @param $data array
548 548
      * @param $wetu_id string
549 549
 	 */
550
-	public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) {
550
+	public function import_row($data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false) {
551 551
         $post_name = $data_post_content = $data_post_excerpt = '';
552 552
         $post = array(
553 553
           'post_type'		=> 'tour',
@@ -555,29 +555,29 @@  discard block
 block discarded – undo
555 555
 
556 556
         //Set the post_content
557 557
 		$content_used_general_description = false;
558
-        if(false !== $importable_content && in_array('description',$importable_content)){
558
+        if (false !== $importable_content && in_array('description', $importable_content)) {
559 559
             $data_post_content = '';
560 560
 
561
-            if(isset($data['description'])){
561
+            if (isset($data['description'])) {
562 562
                 $data_post_content = $data['description'];
563
-            }elseif(isset($data['summary'])){
563
+            }elseif (isset($data['summary'])) {
564 564
                 $data_post_content = $data['summary'];
565 565
             }
566 566
             $post['post_content'] = $data_post_content;
567 567
         }
568 568
 
569 569
         //Create or update the post
570
-        if(false !== $id && '0' !== $id){
570
+        if (false !== $id && '0' !== $id) {
571 571
             $post['ID'] = $id;
572 572
 	        $post['post_status'] = 'publish';
573 573
             $id = wp_update_post($post);
574
-            $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
575
-            update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
576
-        }else{
574
+            $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
575
+            update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']), $prev_date);
576
+        }else {
577 577
 
578 578
             //Set the name
579
-            if(isset($data['name'])){
580
-                $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
579
+            if (isset($data['name'])) {
580
+                $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0);
581 581
             }
582 582
             $post['post_name'] = $post_name;
583 583
             $post['post_title'] = $data['name'];
@@ -585,29 +585,29 @@  discard block
 block discarded – undo
585 585
             $id = wp_insert_post($post);
586 586
 
587 587
             //Save the WETU ID and the Last date it was modified.
588
-            if(false !== $id){
589
-                add_post_meta($id,'lsx_wetu_id',$wetu_id);
590
-                add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
588
+            if (false !== $id) {
589
+                add_post_meta($id, 'lsx_wetu_id', $wetu_id);
590
+                add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']));
591 591
             }
592 592
         }
593 593
 
594 594
 
595 595
 		//Set the price
596
-		if(false !== $importable_content && in_array('price',$importable_content)){
597
-			$this->set_price($data,$id);
596
+		if (false !== $importable_content && in_array('price', $importable_content)) {
597
+			$this->set_price($data, $id);
598 598
 		}
599 599
 
600 600
 		//Set the Duration
601
-		if(false !== $importable_content && in_array('duration',$importable_content)){
602
-			$this->set_duration($data,$id);
601
+		if (false !== $importable_content && in_array('duration', $importable_content)) {
602
+			$this->set_duration($data, $id);
603 603
 		}
604 604
 
605
-        if(false !== $importable_content && in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
606
-            $this->process_itineraries($data,$id,$importable_content);
605
+        if (false !== $importable_content && in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) {
606
+            $this->process_itineraries($data, $id, $importable_content);
607 607
         }
608 608
 
609
-		if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){
610
-			$this->set_map_data($data,$id);
609
+		if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) {
610
+			$this->set_map_data($data, $id);
611 611
 		}
612 612
 
613 613
         return $id;
@@ -616,151 +616,151 @@  discard block
 block discarded – undo
616 616
 	/**
617 617
 	 * A loop which runs through each leg on the tour.
618 618
 	 */
619
-	public function process_itineraries($data,$id,$importable_content) {
619
+	public function process_itineraries($data, $id, $importable_content) {
620 620
 		$day_counter = 1;
621 621
 		$leg_counter = 0;
622 622
 
623
-		delete_post_meta($id,'itinerary');
623
+		delete_post_meta($id, 'itinerary');
624 624
 
625
-		if(false !== $importable_content && in_array('accommodation',$importable_content)){
626
-			delete_post_meta($id,'accommodation_to_tour');
625
+		if (false !== $importable_content && in_array('accommodation', $importable_content)) {
626
+			delete_post_meta($id, 'accommodation_to_tour');
627 627
 		}
628
-		if(false !== $importable_content && in_array('destination',$importable_content)){
629
-			delete_post_meta($id,'destination_to_tour');
630
-			delete_post_meta($id,'departs_from');
631
-			delete_post_meta($id,'ends_in');
628
+		if (false !== $importable_content && in_array('destination', $importable_content)) {
629
+			delete_post_meta($id, 'destination_to_tour');
630
+			delete_post_meta($id, 'departs_from');
631
+			delete_post_meta($id, 'ends_in');
632 632
 		}
633 633
 
634 634
 		$departs_from = false;
635 635
 		$ends_in = false;
636 636
 
637
-		foreach($data['legs'] as $leg){
637
+		foreach ($data['legs'] as $leg) {
638 638
 
639
-			if(isset($leg['days']) && !empty($leg['days'])){
639
+			if (isset($leg['days']) && !empty($leg['days'])) {
640 640
 
641 641
 				//Itinerary Accommodation
642 642
 				$current_accommodation = false;
643
-				if(false !== $importable_content && in_array('accommodation',$importable_content)){
644
-					$current_accommodation = $this->set_accommodation($leg,$id);
643
+				if (false !== $importable_content && in_array('accommodation', $importable_content)) {
644
+					$current_accommodation = $this->set_accommodation($leg, $id);
645 645
 				}
646 646
 
647 647
 				//Itinerary Destination
648 648
 				$current_destination = false;
649
-				if(false !== $importable_content && in_array('destination',$importable_content)){
650
-					$current_destination = $this->set_destination($leg,$id,$leg_counter);
649
+				if (false !== $importable_content && in_array('destination', $importable_content)) {
650
+					$current_destination = $this->set_destination($leg, $id, $leg_counter);
651 651
 				}
652 652
 
653 653
 				//If the Nights are the same mount of days in the array,  then it isnt "By Destination"
654
-				if($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']){
654
+				if ($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']) {
655 655
 
656
-					foreach($leg['days'] as $day){
656
+					foreach ($leg['days'] as $day) {
657 657
 
658 658
 						$current_day = array();
659 659
 
660
-						$current_day['title'] =  esc_attr('Day ','wetu-importer').$day_counter;
660
+						$current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter;
661 661
 
662 662
 						//print_r('<pre>');print_r($day['notes']);print_r('</pre>');
663 663
 
664 664
 						//Description
665
-						if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){
665
+						if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) {
666 666
 							$current_day['description'] = $day['notes'];
667
-						}else{
667
+						}else {
668 668
 							$current_day['description'] = '';
669 669
 						}
670 670
 
671 671
 						//Itinerary Gallery
672
-						if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){
672
+						if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) {
673 673
 							$current_day['featured_image'] = '';
674
-						}else{
674
+						}else {
675 675
 							$current_day['featured_image'] = '';
676 676
 						}
677 677
 
678 678
 						//Accommodation
679
-						if(false !== $current_accommodation){
679
+						if (false !== $current_accommodation) {
680 680
 							$current_day['accommodation_to_tour'] = array($current_accommodation);
681
-						}else{
681
+						}else {
682 682
 							$current_day['accommodation_to_tour'] = array();
683 683
 						}
684 684
 
685 685
 						//Destination
686
-						if(false !== $current_destination){
686
+						if (false !== $current_destination) {
687 687
 							$current_day['destination_to_tour'] = array($current_destination);
688
-						}else{
688
+						}else {
689 689
 							$current_day['destination_to_tour'] = array();
690 690
 						}
691 691
 
692 692
 						//Included
693
-						if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){
693
+						if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) {
694 694
 							$current_day['included'] = $day['included'];
695
-						}else{
695
+						}else {
696 696
 							$current_day['included'] = '';
697 697
 						}
698 698
 
699 699
 						//Excluded
700
-						if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){
700
+						if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) {
701 701
 							$current_day['excluded'] = $day['excluded'];
702
-						}else{
702
+						}else {
703 703
 							$current_day['excluded'] = '';
704 704
 						}
705 705
 
706
-						$this->set_itinerary_day($current_day,$id);
706
+						$this->set_itinerary_day($current_day, $id);
707 707
 						$day_counter++;
708 708
 					}
709 709
 
710
-				}else{
711
-					$day_counter = $day_counter + (int)$leg['nights'];
710
+				}else {
711
+					$day_counter = $day_counter + (int) $leg['nights'];
712 712
 				}
713 713
 
714 714
 			}
715 715
 
716 716
 			//If we are in the first leg,  and the destination was attached then save it as the departure field.
717
-			if( 0 === $leg_counter && false !== $current_destination){
717
+			if (0 === $leg_counter && false !== $current_destination) {
718 718
 				$departs_from = $current_destination;
719 719
 			}
720 720
 
721 721
 			//If its the last leg then save it as the ends in.
722
-			if( $leg_counter === (count($data['legs'])-2) && false !== $current_destination){
722
+			if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) {
723 723
 				$ends_in = $current_destination;
724 724
 			}
725 725
 			$leg_counter++;
726 726
 		}
727 727
 
728
-		if(false !== $departs_from){
729
-			add_post_meta($id,'departs_from',$departs_from,true);
728
+		if (false !== $departs_from) {
729
+			add_post_meta($id, 'departs_from', $departs_from, true);
730 730
 		}
731
-		if(false !== $ends_in){
732
-			add_post_meta($id,'ends_in',$ends_in,true);
731
+		if (false !== $ends_in) {
732
+			add_post_meta($id, 'ends_in', $ends_in, true);
733 733
 		}
734 734
 	}
735 735
 
736 736
 	/**
737 737
 	 * Run through your routes and save the points as a KML file.
738 738
 	 */
739
-	public function set_map_data($data,$id,$zoom=9) {
739
+	public function set_map_data($data, $id, $zoom = 9) {
740 740
 
741
-		if(!empty($data['routes'])){
741
+		if (!empty($data['routes'])) {
742 742
 
743
-			delete_post_meta($id,'wetu_map_points');
743
+			delete_post_meta($id, 'wetu_map_points');
744 744
 
745 745
 			$points = array();
746 746
 
747
-			foreach($data['routes'] as $route){
747
+			foreach ($data['routes'] as $route) {
748 748
 
749 749
 
750
-				if(isset($route['points']) && '' !== $route['points']){
750
+				if (isset($route['points']) && '' !== $route['points']) {
751 751
 
752
-					$temp_points = explode(';',$route['points']);
752
+					$temp_points = explode(';', $route['points']);
753 753
 					$point_counter = count($temp_points);
754 754
 
755 755
 					for ($x = 0; $x <= $point_counter; $x++) {
756
-						$y = $x+1;
756
+						$y = $x + 1;
757 757
 						$points[] = $temp_points[$x].','.$temp_points[$y];
758 758
 						$x++;
759 759
 					}
760 760
 				}
761 761
 			}
762
-			if(!empty($points)){
763
-				$this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true);
762
+			if (!empty($points)) {
763
+				$this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true);
764 764
 			}
765 765
 		}
766 766
 
@@ -771,28 +771,28 @@  discard block
 block discarded – undo
771 771
 	/**
772 772
 	 * Set the Itinerary Day
773 773
 	 */
774
-	public function set_itinerary_day($day,$id) {
775
-        $this->save_custom_field($day,'itinerary',$id,false,false);
774
+	public function set_itinerary_day($day, $id) {
775
+        $this->save_custom_field($day, 'itinerary', $id, false, false);
776 776
 	}
777 777
 
778 778
 	/**
779 779
 	 * Set the price
780 780
 	 */
781
-	public function set_price($data,$id) {
781
+	public function set_price($data, $id) {
782 782
 	    //Price
783
-		if(isset($data['price']) && ''!== $data['price']){
783
+		if (isset($data['price']) && '' !== $data['price']) {
784 784
             $price = preg_replace("/[^0-9,.]/", "", $data['price']);
785
-            $this->save_custom_field($price,'price',$id);
785
+            $this->save_custom_field($price, 'price', $id);
786 786
 		}
787 787
 
788 788
 		//Price includes
789
-		if(isset($data['price_includes']) && ''!== $data['price_includes']){
790
-			$this->save_custom_field($data['price_includes'],'included',$id);
789
+		if (isset($data['price_includes']) && '' !== $data['price_includes']) {
790
+			$this->save_custom_field($data['price_includes'], 'included', $id);
791 791
 		}
792 792
 
793 793
         //Price Excludes
794
-		if(isset($data['price_excludes']) && ''!== $data['price_excludes']){
795
-			$this->save_custom_field($data['price_excludes'],'not_included',$id);
794
+		if (isset($data['price_excludes']) && '' !== $data['price_excludes']) {
795
+			$this->save_custom_field($data['price_excludes'], 'not_included', $id);
796 796
 		}
797 797
 
798 798
 	}
@@ -800,38 +800,38 @@  discard block
 block discarded – undo
800 800
 	/**
801 801
 	 * Set the duration
802 802
 	 */
803
-	public function set_duration($data,$id) {
804
-		if(isset($data['days']) && !empty($data['days'])){
803
+	public function set_duration($data, $id) {
804
+		if (isset($data['days']) && !empty($data['days'])) {
805 805
 			$price = $data['days'];
806 806
 			$price = preg_replace("/[^0-9,.]/", "", $price);
807
-			$this->save_custom_field($price,'duration',$id);
807
+			$this->save_custom_field($price, 'duration', $id);
808 808
 		}
809 809
 	}
810 810
 
811 811
 	/**
812 812
 	 * Connects the Accommodation if its available
813 813
 	 */
814
-	public function set_accommodation($day,$id) {
814
+	public function set_accommodation($day, $id) {
815 815
 
816 816
 	    $ac_id = false;
817 817
 		$this->current_accommodation = $this->find_current_accommodation();
818 818
 		
819
-		if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){
819
+		if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) {
820 820
 
821
-			if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){
821
+			if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) {
822 822
                 $ac_id = $this->current_accommodation[$day['content_entity_id']];
823
-			}else{
823
+			}else {
824 824
 				$ac_id = wp_insert_post(array(
825 825
                     'post_type' => 'accommodation',
826 826
                     'post_status' => 'draft',
827 827
                     'post_title' => $day['content_entity_id']
828 828
                 ));
829
-				$this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id);
829
+				$this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id);
830 830
 			}
831 831
 
832
-			if('' !== $ac_id && false !== $ac_id){
833
-			    $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
834
-				$this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false);
832
+			if ('' !== $ac_id && false !== $ac_id) {
833
+			    $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false);
834
+				$this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false);
835 835
             }
836 836
 		}
837 837
 		return $ac_id;
@@ -843,13 +843,13 @@  discard block
 block discarded – undo
843 843
      * @param $post_type string
844 844
      * @return boolean / array
845 845
 	 */
846
-	public function find_current_accommodation($post_type='accommodation') {
846
+	public function find_current_accommodation($post_type = 'accommodation') {
847 847
 		global $wpdb;
848 848
 		$accommodation = parent::find_current_accommodation($post_type);
849 849
 
850 850
 		$return = false;
851
-		if(!empty($accommodation)){
852
-		    foreach($accommodation as $key => $acc){
851
+		if (!empty($accommodation)) {
852
+		    foreach ($accommodation as $key => $acc) {
853 853
 				$return[$acc->meta_value] = $acc->post_id;
854 854
             }
855 855
         }
@@ -871,26 +871,26 @@  discard block
 block discarded – undo
871 871
 	 * @param $id string
872 872
 	 * @return boolean / string
873 873
 	 */
874
-	public function set_destination($day,$id,$leg_counter) {
874
+	public function set_destination($day, $id, $leg_counter) {
875 875
 		$dest_id = false;
876 876
 		$country_id = false;
877 877
 		$this->current_destinations = $this->find_current_destinations();
878 878
 
879
-		if(isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])){
879
+		if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) {
880 880
 
881
-			if(false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'],$this->current_destinations)){
881
+			if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) {
882 882
 				$dest_id = $this->current_destinations[$day['destination_content_entity_id']];
883 883
 
884 884
 				//Check if there is a country asigned.
885 885
 				$potential_id = wp_get_post_parent_id($dest_id);
886
-				$country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true);
887
-				if(false !== $country_wetu_id){
886
+				$country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true);
887
+				if (false !== $country_wetu_id) {
888 888
 					$country_id = $this->set_country($country_wetu_id, $id);
889 889
                 }
890 890
 
891 891
 			}else {
892 892
 
893
-				$destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']);
893
+				$destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$day['destination_content_entity_id']);
894 894
 
895 895
 				if ($destination_json) {
896 896
 					$destination_data = json_decode($destination_json, true);
@@ -899,12 +899,12 @@  discard block
 block discarded – undo
899 899
 
900 900
 					    $destination_title = $day['destination_content_entity_id'];
901 901
 
902
-					    if(isset($destination_data[0]['name'])){
902
+					    if (isset($destination_data[0]['name'])) {
903 903
 							$destination_title = $destination_data[0]['name'];
904 904
                         }
905 905
 
906
-					    if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
907
-                            && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
906
+					    if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
907
+                            && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) {
908 908
 
909 909
 							$country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id);
910 910
                         }
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 							'post_title' => $destination_title
916 916
 						);
917 917
 
918
-					    if(false !== $country_id){
918
+					    if (false !== $country_id) {
919 919
 							$dest_post['post_parent'] = $country_id;
920 920
                         }
921 921
 						$dest_id = wp_insert_post($dest_post);
@@ -934,15 +934,15 @@  discard block
 block discarded – undo
934 934
 				$this->cleanup_posts[$dest_id] = 'tour_to_destination';
935 935
 
936 936
 				// Save the first destination so we can grab the tour featured image and banner
937
-				if(0 === $leg_counter){
938
-				    $this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']);
937
+				if (0 === $leg_counter) {
938
+				    $this->destination_images[$id] = array($dest_id, $day['destination_content_entity_id']);
939 939
                 }
940 940
 
941 941
 				//Add this relation info so we can make sure certain items are set as countries.
942
-				if(0 !== $country_id && false !== $country_id){
942
+				if (0 !== $country_id && false !== $country_id) {
943 943
                     $this->relation_meta[$dest_id] = $country_id;
944 944
 					$this->relation_meta[$country_id] = 0;
945
-                }else{
945
+                }else {
946 946
 					$this->relation_meta[$dest_id] = 0;
947 947
                 }
948 948
 			}
@@ -965,9 +965,9 @@  discard block
 block discarded – undo
965 965
 
966 966
         if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
967 967
             $country_id = $this->current_destinations[$country_wetu_id];
968
-        } else {
968
+        }else {
969 969
 
970
-            $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
970
+            $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$country_wetu_id);
971 971
 
972 972
             if ($country_json) {
973 973
                 $country_data = json_decode($country_json, true);
@@ -1012,15 +1012,15 @@  discard block
 block discarded – undo
1012 1012
 	 *
1013 1013
 	 * @return string
1014 1014
 	 */
1015
-	public function attach_destination_images($importable_content=array()) {
1016
-	    if(false !== $this->destination_images){
1015
+	public function attach_destination_images($importable_content = array()) {
1016
+	    if (false !== $this->destination_images) {
1017 1017
 
1018
-	        foreach($this->destination_images as $tour => $destination){
1018
+	        foreach ($this->destination_images as $tour => $destination) {
1019 1019
 
1020
-				$url = 'https://wetu.com/API/Pins/' . $this->api_key;
1020
+				$url = 'https://wetu.com/API/Pins/'.$this->api_key;
1021 1021
 				$url_qs = '';
1022 1022
 
1023
-				$jdata = file_get_contents($url . '/Get?' . $url_qs . '&ids=' . $destination[1]);
1023
+				$jdata = file_get_contents($url.'/Get?'.$url_qs.'&ids='.$destination[1]);
1024 1024
 				if ($jdata) {
1025 1025
 					$adata = json_decode($jdata, true);
1026 1026
 
Please login to merge, or discard this patch.