Completed
Push — master ( 3704f2...8a71c5 )
by Warwick
03:20
created
classes/class-admin.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * Display the importer administration screen
87 87
 	 */
88 88
 	public function display_page() {
89
-        ?>
89
+		?>
90 90
         <div class="wrap">
91 91
             <?php screen_icon(); ?>
92 92
 
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 		            </ul> 
109 109
 	             	            
110 110
             <?php } else {
111
-            	do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']);
112
-            } ?>
111
+				do_action('lsx_tour_importer_admin_tab_'.$_GET['tab']);
112
+			} ?>
113 113
         </div>
114 114
         <?php
115 115
 	}
@@ -156,37 +156,37 @@  discard block
 block discarded – undo
156 156
 	 * set_taxonomy with some terms
157 157
 	 */
158 158
 	public function set_taxonomy($taxonomy,$terms,$id) {
159
-        $result=array();
160
-        if(!empty($data))
161
-        {
162
-            foreach($data as $k)
163
-            {
164
-                if($id)
165
-                {
166
-                    if(!$term = term_exists(trim($k), $tax))
167
-                    {
168
-                        $term = wp_insert_term(trim($k), $tax);
169
-                        if ( is_wp_error($term) )
170
-                        {
171
-                            echo $term->get_error_message();
172
-                        }
173
-                        else
174
-                        {
175
-                            wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
176
-                        }
177
-                    }
178
-                    else
179
-                    {
180
-                        wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
181
-                    }
182
-                }
183
-                else
184
-                {
185
-                    $result[]=trim($k);
186
-                }
187
-            }
188
-        }
189
-        return $result;
159
+		$result=array();
160
+		if(!empty($data))
161
+		{
162
+			foreach($data as $k)
163
+			{
164
+				if($id)
165
+				{
166
+					if(!$term = term_exists(trim($k), $tax))
167
+					{
168
+						$term = wp_insert_term(trim($k), $tax);
169
+						if ( is_wp_error($term) )
170
+						{
171
+							echo $term->get_error_message();
172
+						}
173
+						else
174
+						{
175
+							wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
176
+						}
177
+					}
178
+					else
179
+					{
180
+						wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
181
+					}
182
+				}
183
+				else
184
+				{
185
+					$result[]=trim($k);
186
+				}
187
+			}
188
+		}
189
+		return $result;
190 190
 	}
191 191
 
192 192
 	/**
@@ -196,21 +196,21 @@  discard block
 block discarded – undo
196 196
 		if(post_type_exists('team')) { ?>
197 197
     		<ul>
198 198
     			<?php
199
-    				$team_args=array(
200
-    					'post_type'	=>	'team',
201
-    					'post_status' => 'publish',
202
-    					'nopagin' => true,
203
-    					'fields' => 'ids'
204
-    				);
205
-    				$team_members = new WP_Query($team_args);
206
-    					if($team_members->have_posts()){
207
-    						foreach($team_members->posts as $member){ ?>
199
+					$team_args=array(
200
+						'post_type'	=>	'team',
201
+						'post_status' => 'publish',
202
+						'nopagin' => true,
203
+						'fields' => 'ids'
204
+					);
205
+					$team_members = new WP_Query($team_args);
206
+						if($team_members->have_posts()){
207
+							foreach($team_members->posts as $member){ ?>
208 208
     							<li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
209 209
     						<?php }
210
-    					}else{ ?>
210
+						}else{ ?>
211 211
     							<li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
212 212
     					<?php }
213
-    				?>
213
+					?>
214 214
     		</ul>
215 215
     	<?php }		
216 216
 	}
@@ -262,36 +262,36 @@  discard block
 block discarded – undo
262 262
 		if(false !== $id){
263 263
 			if(empty($this->found_attachments)){
264 264
 
265
-		    	$attachments_args = array(
266
-		    			'post_parent' => $id,
267
-		    			'post_status' => 'inherit',
268
-		    			'post_type' => 'attachment',
269
-		    			'order' => 'ASC',
270
-                        'nopagin' => 'true',
271
-                        'posts_per_page' => '-1'
272
-		    	);   	
265
+				$attachments_args = array(
266
+						'post_parent' => $id,
267
+						'post_status' => 'inherit',
268
+						'post_type' => 'attachment',
269
+						'order' => 'ASC',
270
+						'nopagin' => 'true',
271
+						'posts_per_page' => '-1'
272
+				);   	
273 273
 		    	 
274
-		    	$attachments = new WP_Query($attachments_args);
275
-		    	if($attachments->have_posts()){
276
-		    		foreach($attachments->posts as $attachment){
277
-		    			$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
278
-		    			$this->gallery_meta[] = $attachment->ID;
279
-		    		}
280
-		    	}
274
+				$attachments = new WP_Query($attachments_args);
275
+				if($attachments->have_posts()){
276
+					foreach($attachments->posts as $attachment){
277
+						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
278
+						$this->gallery_meta[] = $attachment->ID;
279
+					}
280
+				}
281 281
 			}
282 282
 		}
283 283
 	}
284 284
 
285 285
 	/**
286 286
 	 * Checks to see if an item is checked.
287
-     *
288
-     * @param $haystack array|string
289
-     * @param $needle string
290
-     * @param $echo bool
287
+	 *
288
+	 * @param $haystack array|string
289
+	 * @param $needle string
290
+	 * @param $echo bool
291 291
 	 */
292 292
 	public function checked($haystack=false,$needle='',$echo=true) {
293
-	    $return = $this->itemd($haystack,$needle,'checked');
294
-	    if('' !== $return) {
293
+		$return = $this->itemd($haystack,$needle,'checked');
294
+		if('' !== $return) {
295 295
 			if (true === $echo) {
296 296
 				echo $return;
297 297
 			} else {
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	 *
306 306
 	 * @param $haystack array|string
307 307
 	 * @param $needle string
308
-     * @param $echo bool
308
+	 * @param $echo bool
309 309
 	 */
310 310
 	public function selected($haystack=false,$needle='',$echo=true) {
311 311
 		$return = $this->itemd($haystack,$needle,'selected');
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
 	 *
324 324
 	 * @param $haystack array|string
325 325
 	 * @param $needle string
326
-     * @param $type string
327
-     * @param $wrap bool
328
-     * @return $html string
326
+	 * @param $type string
327
+	 * @param $wrap bool
328
+	 * @return $html string
329 329
 	 */
330 330
 	public function itemd($haystack=false,$needle='',$type='',$wrap=true) {
331 331
 		$html = '';
@@ -334,14 +334,14 @@  discard block
 block discarded – undo
334 334
 				$haystack = array($haystack);
335 335
 			}
336 336
 			if (in_array($needle, $haystack)) {
337
-			    if(true === $wrap || 'true' === $wrap) {
337
+				if(true === $wrap || 'true' === $wrap) {
338 338
 					$html = $type . '"' . $type . '"';
339 339
 				}else{
340 340
 					$html = $type;
341
-                }
341
+				}
342 342
 			}
343 343
 		}
344
-        return $html;
344
+		return $html;
345 345
 
346 346
 	}
347 347
 
@@ -351,26 +351,26 @@  discard block
 block discarded – undo
351 351
 	 * @param $tab string
352 352
 	 */
353 353
 	public function navigation($tab='') {
354
-        $post_types = array(
355
-            'tour'              => esc_attr('Tours','wetu-importer'),
356
-            'accommodation'     => esc_attr('Accommodation','wetu-importer'),
357
-            'destination'       => esc_attr('Destinations','wetu-importer'),
358
-        );
354
+		$post_types = array(
355
+			'tour'              => esc_attr('Tours','wetu-importer'),
356
+			'accommodation'     => esc_attr('Accommodation','wetu-importer'),
357
+			'destination'       => esc_attr('Destinations','wetu-importer'),
358
+		);
359 359
 
360 360
 
361 361
 		echo '<div class="wet-navigation"><div class="subsubsub"><a class="'.$this->itemd($tab,'','current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'">'.esc_attr('Home','wetu-importer').'</a>';
362 362
 		foreach($post_types as $post_type => $label){
363
-		    echo ' | <a class="'.$this->itemd($tab,$post_type,'current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>';
364
-        }
365
-        echo '</div><br clear="both"/></div>';
363
+			echo ' | <a class="'.$this->itemd($tab,$post_type,'current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>';
364
+		}
365
+		echo '</div><br clear="both"/></div>';
366 366
 	}
367 367
 
368 368
 	/**
369 369
 	 * Grabs the custom fields,  and resaves an array of unique items.
370 370
 	 */
371 371
 	public function cleanup_posts() {
372
-	    if(!empty($this->cleanup_posts)){
373
-	        foreach($this->cleanup_posts as $id => $key) {
372
+		if(!empty($this->cleanup_posts)){
373
+			foreach($this->cleanup_posts as $id => $key) {
374 374
 				$prev_items = get_post_meta($id, $key, false);
375 375
 				$new_items = array_unique($prev_items);
376 376
 				delete_post_meta($id, $key);
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 					add_post_meta($id, $key, $new_item, false);
379 379
 				}
380 380
 			}
381
-        }
381
+		}
382 382
 	}
383 383
 }
384 384
 $wetu_importer_admin = new WETU_Importer_Admin();
385 385
\ No newline at end of file
Please login to merge, or discard this patch.
classes/class-tours.php 1 patch
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		$tour_options = get_option('wetu_importer_tour_settings',false);
98 98
 		if(false !== $tour_options){
99 99
 			$this->tour_options = $tour_options;
100
-        }
100
+		}
101 101
 	}
102 102
 
103 103
 	/**
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 * Display the importer administration screen
121 121
 	 */
122 122
 	public function display_page() {
123
-        ?>
123
+		?>
124 124
         <div class="wrap">
125 125
 			<?php $this->navigation('tour'); ?>
126 126
 
@@ -249,16 +249,16 @@  discard block
 block discarded – undo
249 249
 			$result = $this->update_options();
250 250
 
251 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
-                }
256
-            }else{
257
-			    echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
258
-            }
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
+				}
256
+			}else{
257
+				echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
258
+			}
259 259
 		}else{
260 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
 	}
264 264
 
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 		$tours = json_decode($data, true);
271 271
 
272 272
 		if(isset($tours['error'])){
273
-		    return $tours['error'];
274
-        }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
273
+			return $tours['error'];
274
+		}elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
275 275
 			set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2);
276 276
 			return true;
277 277
 		}
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 					$keyphrases = $_POST['keyword'];
321 321
 				}else{
322 322
 					$keyphrases = array(0);
323
-                }
323
+				}
324 324
 
325 325
 				if(!is_array($keyphrases)){
326 326
 					$keyphrases = array($keyphrases);
@@ -349,15 +349,15 @@  discard block
 block discarded – undo
349 349
 
350 350
 					foreach($tours as $row_key => $row){
351 351
 
352
-					    if(isset($row['is_disabled']) && true === $row['is_disabled']){
353
-                            continue;
354
-                        }
352
+						if(isset($row['is_disabled']) && true === $row['is_disabled']){
353
+							continue;
354
+						}
355 355
 
356
-                        /*if('Sample' === $row['type']){
356
+						/*if('Sample' === $row['type']){
357 357
                             continue;
358 358
                         }*/
359 359
 
360
-                        //If this is a current tour, add its ID to the row.
360
+						//If this is a current tour, add its ID to the row.
361 361
 						$row['post_id'] = 0;
362 362
 						if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){
363 363
 							$row['post_id'] = $current_tours[$row['identifier']]->post_id;
@@ -366,31 +366,31 @@  discard block
 block discarded – undo
366 366
 						//If we are searching for
367 367
 						if(false !== $post_status){
368 368
 
369
-                            if('import' === $post_status){
369
+							if('import' === $post_status){
370 370
 
371 371
 								if(0 !== $row['post_id']){
372
-								    continue;
372
+									continue;
373 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 380
 								if(0 === $row['post_id']){
381 381
 									continue;
382 382
 								}else{
383 383
 									$current_status = get_post_status($row['post_id']);
384 384
 									if($current_status !== $post_status){
385
-									    continue;
386
-                                    }
385
+										continue;
386
+									}
387 387
 
388 388
 								}
389 389
 								$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
390 390
 
391
-                            }
391
+							}
392 392
 
393
-                        }else{
393
+						}else{
394 394
 							//Search through each keyword.
395 395
 							foreach($keyphrases as $keyphrase){
396 396
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
405 405
 								}
406 406
 							}
407
-                        }
407
+						}
408 408
 					}		
409 409
 				}
410 410
 
@@ -471,18 +471,18 @@  discard block
 block discarded – undo
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)
477
-            {
476
+			if($jdata)
477
+			{
478 478
 				$jdata=json_decode($jdata,true);
479
-                if(!empty($jdata))
480
-                {
481
-                	$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
482
-                	$this->format_completed_row($return);
483
-                	$this->cleanup_posts();
484
-                }
485
-            }
479
+				if(!empty($jdata))
480
+				{
481
+					$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
482
+					$this->format_completed_row($return);
483
+					$this->cleanup_posts();
484
+				}
485
+			}
486 486
 			die();
487 487
 		}
488 488
 
@@ -490,53 +490,53 @@  discard block
 block discarded – undo
490 490
 
491 491
 	/**
492 492
 	 * Connect to wetu
493
-     *
494
-     * @param $data array
495
-     * @param $wetu_id string
493
+	 *
494
+	 * @param $data array
495
+	 * @param $wetu_id string
496 496
 	 */
497 497
 	public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) {
498
-        $post_name = $data_post_content = $data_post_excerpt = '';
499
-        $post = array(
500
-          'post_type'		=> 'tour',
501
-        );
498
+		$post_name = $data_post_content = $data_post_excerpt = '';
499
+		$post = array(
500
+		  'post_type'		=> 'tour',
501
+		);
502 502
 
503
-        //Set the post_content
503
+		//Set the post_content
504 504
 		$content_used_general_description = false;
505
-        if(false !== $importable_content && in_array('description',$importable_content)){
506
-            $data_post_content = '';
507
-
508
-            if(isset($data['description'])){
509
-                $data_post_content = $data['description'];
510
-            }elseif(isset($data['summary'])){
511
-                $data_post_content = $data['summary'];
512
-            }
513
-            $post['post_content'] = $data_post_content;
514
-        }
515
-
516
-        //Create or update the post
517
-        if(false !== $id && '0' !== $id){
518
-            $post['ID'] = $id;
519
-	        $post['post_status'] = 'publish';
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{
524
-
525
-            //Set the name
526
-            if(isset($data['name'])){
527
-                $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
528
-            }
529
-            $post['post_name'] = $post_name;
530
-            $post['post_title'] = $data['name'];
531
-            $post['post_status'] = 'publish';
532
-            $id = wp_insert_post($post);
533
-
534
-            //Save the WETU ID and the Last date it was modified.
535
-            if(false !== $id){
536
-                add_post_meta($id,'lsx_wetu_id',$wetu_id);
537
-                add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
538
-            }
539
-        }
505
+		if(false !== $importable_content && in_array('description',$importable_content)){
506
+			$data_post_content = '';
507
+
508
+			if(isset($data['description'])){
509
+				$data_post_content = $data['description'];
510
+			}elseif(isset($data['summary'])){
511
+				$data_post_content = $data['summary'];
512
+			}
513
+			$post['post_content'] = $data_post_content;
514
+		}
515
+
516
+		//Create or update the post
517
+		if(false !== $id && '0' !== $id){
518
+			$post['ID'] = $id;
519
+			$post['post_status'] = 'publish';
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{
524
+
525
+			//Set the name
526
+			if(isset($data['name'])){
527
+				$post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
528
+			}
529
+			$post['post_name'] = $post_name;
530
+			$post['post_title'] = $data['name'];
531
+			$post['post_status'] = 'publish';
532
+			$id = wp_insert_post($post);
533
+
534
+			//Save the WETU ID and the Last date it was modified.
535
+			if(false !== $id){
536
+				add_post_meta($id,'lsx_wetu_id',$wetu_id);
537
+				add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
538
+			}
539
+		}
540 540
 
541 541
 
542 542
 		//Set the price
@@ -549,9 +549,9 @@  discard block
 block discarded – undo
549 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);
554
-        }
552
+		if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
553
+			$this->process_itineraries($data,$id,$importable_content);
554
+		}
555 555
 
556 556
 		if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){
557 557
 			$this->process_map_points($data,$id);
@@ -562,24 +562,24 @@  discard block
 block discarded – undo
562 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
-        //Set the featured image
566
-        //TODO Test These
567
-        if(false !== $importable_content && in_array('featured_image',$importable_content)){
568
-            $this->set_featured_image($data,$id);
569
-        }
565
+		//Set the featured image
566
+		//TODO Test These
567
+		if(false !== $importable_content && in_array('featured_image',$importable_content)){
568
+			$this->set_featured_image($data,$id);
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);
574
-        }
572
+		if(false !== $importable_content && in_array('banner_image',$importable_content)){
573
+			$this->set_banner_image($data,$id);
574
+		}
575 575
 
576 576
 		//TODO Test These
577
-        //Import the main gallery
578
-        if(false !== $importable_content && in_array('gallery',$importable_content)){
579
-            $this->create_main_gallery($data,$id);
580
-        }
577
+		//Import the main gallery
578
+		if(false !== $importable_content && in_array('gallery',$importable_content)){
579
+			$this->create_main_gallery($data,$id);
580
+		}
581 581
 
582
-        return $id;
582
+		return $id;
583 583
 	}
584 584
 
585 585
 	/**
@@ -707,31 +707,31 @@  discard block
 block discarded – undo
707 707
 	 */
708 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
-	        $points = array();
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']);
722
-	                $point_counter = count($temp_points);
721
+					$temp_points = explode(';',$route['points']);
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
-            }
731
-            if(!empty($points)){
730
+			}
731
+			if(!empty($points)){
732 732
 				$this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true);
733
-            }
734
-        }
733
+			}
734
+		}
735 735
 
736 736
 	}
737 737
 
@@ -739,17 +739,17 @@  discard block
 block discarded – undo
739 739
 	 * Set the Itinerary Day
740 740
 	 */
741 741
 	public function set_itinerary_day($day,$id) {
742
-        $this->save_custom_field($day,'itinerary',$id,false,false);
742
+		$this->save_custom_field($day,'itinerary',$id,false,false);
743 743
 	}
744 744
 
745 745
 	/**
746 746
 	 * Set the price
747 747
 	 */
748 748
 	public function set_price($data,$id) {
749
-	    //Price
749
+		//Price
750 750
 		if(isset($data['price']) && ''!== $data['price']){
751
-            $price = preg_replace("/[^0-9,.]/", "", $data['price']);
752
-            $this->save_custom_field($price,'price',$id);
751
+			$price = preg_replace("/[^0-9,.]/", "", $data['price']);
752
+			$this->save_custom_field($price,'price',$id);
753 753
 		}
754 754
 
755 755
 		//Price includes
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 			$this->save_custom_field($data['price_includes'],'included',$id);
758 758
 		}
759 759
 
760
-        //Price Excludes
760
+		//Price Excludes
761 761
 		if(isset($data['price_excludes']) && ''!== $data['price_excludes']){
762 762
 			$this->save_custom_field($data['price_excludes'],'not_included',$id);
763 763
 		}
@@ -780,35 +780,35 @@  discard block
 block discarded – undo
780 780
 	 */
781 781
 	public function set_accommodation($day,$id) {
782 782
 
783
-	    $ac_id = false;
783
+		$ac_id = false;
784 784
 		$this->current_accommodation = $this->find_current_accommodation();
785 785
 		
786 786
 		if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){
787 787
 
788 788
 			if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){
789
-                $ac_id = $this->current_accommodation[$day['content_entity_id']];
789
+				$ac_id = $this->current_accommodation[$day['content_entity_id']];
790 790
 			}else{
791 791
 				$ac_id = wp_insert_post(array(
792
-                    'post_type' => 'accommodation',
793
-                    'post_status' => 'draft',
794
-                    'post_title' => $day['content_entity_id']
795
-                ));
792
+					'post_type' => 'accommodation',
793
+					'post_status' => 'draft',
794
+					'post_title' => $day['content_entity_id']
795
+				));
796 796
 				$this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id);
797 797
 			}
798 798
 
799 799
 			if('' !== $ac_id && false !== $ac_id){
800
-			    $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
800
+				$this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
801 801
 				$this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false);
802
-            }
802
+			}
803 803
 		}
804 804
 		return $ac_id;
805 805
 	}
806 806
 
807 807
 	/**
808 808
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
809
-     *
810
-     * @param $post_type string
811
-     * @return boolean / array
809
+	 *
810
+	 * @param $post_type string
811
+	 * @return boolean / array
812 812
 	 */
813 813
 	public function find_current_accommodation($post_type='accommodation') {
814 814
 		global $wpdb;
@@ -816,16 +816,16 @@  discard block
 block discarded – undo
816 816
 
817 817
 		$return = false;
818 818
 		if(!empty($accommodation)){
819
-		    foreach($accommodation as $key => $acc){
819
+			foreach($accommodation as $key => $acc){
820 820
 				$return[$acc->meta_value] = $acc->post_id;
821
-            }
822
-        }
821
+			}
822
+		}
823 823
 		return $return;
824 824
 	}
825 825
 
826 826
 	/**
827 827
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
828
-     * @return boolean / array
828
+	 * @return boolean / array
829 829
 	 */
830 830
 	public function find_current_destinations() {
831 831
 		return $this->find_current_accommodation('destination');
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
 				$country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true);
853 853
 				if(false !== $country_wetu_id){
854 854
 					$this->set_country($country_wetu_id, $id);
855
-                }
855
+				}
856 856
 
857 857
 			}else {
858 858
 
@@ -863,27 +863,27 @@  discard block
 block discarded – undo
863 863
 
864 864
 					if (!empty($destination_data) && !isset($destination_data['error'])) {
865 865
 
866
-					    $destination_title = $day['destination_content_entity_id'];
866
+						$destination_title = $day['destination_content_entity_id'];
867 867
 
868
-					    if(isset($destination_data[0]['name'])){
868
+						if(isset($destination_data[0]['name'])){
869 869
 							$destination_title = $destination_data[0]['name'];
870
-                        }
870
+						}
871 871
 
872
-					    if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
873
-                            && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
872
+						if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
873
+							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
874 874
 
875 875
 							$country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id);
876
-                        }
876
+						}
877 877
 
878
-                        $dest_post = array(
878
+						$dest_post = array(
879 879
 							'post_type' => 'destination',
880 880
 							'post_status' => 'draft',
881 881
 							'post_title' => $destination_title
882 882
 						);
883 883
 
884
-					    if(false !== $country_id){
884
+						if(false !== $country_id){
885 885
 							$dest_post['post_parent'] = $country_id;
886
-                        }
886
+						}
887 887
 						$dest_id = wp_insert_post($dest_post);
888 888
 
889 889
 						//Make sure we register the
@@ -907,51 +907,51 @@  discard block
 block discarded – undo
907 907
 	 * Connects the destinations post type
908 908
 	 *
909 909
 	 * @param $dest_id string
910
-     * @param $country_id array
910
+	 * @param $country_id array
911 911
 	 * @param $id string
912 912
 	 */
913 913
 	public function set_country($country_wetu_id, $id) {
914
-	    $country_id = false;
914
+		$country_id = false;
915 915
 		$this->current_destinations = $this->find_current_destinations();
916 916
 
917
-        if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
918
-            $country_id = $this->current_destinations[$country_wetu_id];
919
-        } else {
917
+		if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
918
+			$country_id = $this->current_destinations[$country_wetu_id];
919
+		} else {
920 920
 
921
-            $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
921
+			$country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
922 922
 
923
-            if ($country_json) {
924
-                $country_data = json_decode($country_json, true);
923
+			if ($country_json) {
924
+				$country_data = json_decode($country_json, true);
925 925
 
926
-                if (!empty($country_data) && !isset($country_data['error'])) {
926
+				if (!empty($country_data) && !isset($country_data['error'])) {
927 927
 
928 928
 					//Format the title of the destination if its available,  otherwise default to the WETU ID.
929
-                    $country_title = $country_wetu_id;
930
-                    if (isset($country_data[0]['name'])) {
929
+					$country_title = $country_wetu_id;
930
+					if (isset($country_data[0]['name'])) {
931 931
 						$country_title = $country_data[0]['name'];
932
-                    }
932
+					}
933 933
 
934 934
 					$country_id = wp_insert_post(array(
935
-                        'post_type' => 'destination',
936
-                        'post_status' => 'draft',
937
-                        'post_title' => $country_title
938
-                    ));
935
+						'post_type' => 'destination',
936
+						'post_status' => 'draft',
937
+						'post_title' => $country_title
938
+					));
939 939
 					//add the country to the current destination stack
940 940
 					$this->current_destinations[$country_wetu_id] = $country_id;
941 941
 
942 942
 					//Save the wetu field
943
-                    $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
944
-                }
945
-            }
946
-        }
947
-
948
-        if ('' !== $country_id && false !== $country_id) {
949
-            $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
950
-            $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
943
+					$this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
944
+				}
945
+			}
946
+		}
947
+
948
+		if ('' !== $country_id && false !== $country_id) {
949
+			$this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
950
+			$this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
951 951
 			$this->cleanup_posts[$country_id] = 'tour_to_destination';
952 952
 
953
-            return $country_id;
954
-        }
953
+			return $country_id;
954
+		}
955 955
 	}
956 956
 }
957 957
 $wetu_importer_tours = new WETU_Importer_Tours();
958 958
\ No newline at end of file
Please login to merge, or discard this patch.
classes/class-accommodation.php 1 patch
Indentation   +323 added lines, -323 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 * Display the importer administration screen
137 137
 	 */
138 138
 	public function display_page() {
139
-        ?>
139
+		?>
140 140
         <div class="wrap">
141 141
             <?php $this->navigation('accommodation'); ?>
142 142
 
@@ -315,8 +315,8 @@  discard block
 block discarded – undo
315 315
 		$accommodation = json_decode($data, true);
316 316
 
317 317
 		if(isset($accommodation['error'])){
318
-		    return $accommodation['error'];
319
-        }elseif (isset($accommodation) && !empty($accommodation)) {
318
+			return $accommodation['error'];
319
+		}elseif (isset($accommodation) && !empty($accommodation)) {
320 320
 			set_transient('lsx_ti_accommodation',$accommodation,60*60*2);
321 321
 			return true;
322 322
 		}
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 					$keyphrases = $_POST['keyword'];
365 365
 				}else{
366 366
 					$keyphrases = array(0);
367
-                }
367
+				}
368 368
 
369 369
 				if(!is_array($keyphrases)){
370 370
 					$keyphrases = array($keyphrases);
@@ -461,13 +461,13 @@  discard block
 block discarded – undo
461 461
 	public function multineedle_stripos($haystack, $needles, $offset=0) {
462 462
 		$found = false;
463 463
 		$needle_count = count($needles);
464
-	    foreach($needles as $needle) {
465
-	    	if(false !== stripos($haystack, $needle, $offset)){
466
-	        	$found[] = true;
467
-	    	}
468
-	    }
469
-	    if(false !== $found && $needle_count === count($found)){ 
470
-	    	return true;
464
+		foreach($needles as $needle) {
465
+			if(false !== stripos($haystack, $needle, $offset)){
466
+				$found[] = true;
467
+			}
468
+		}
469
+		if(false !== $found && $needle_count === count($found)){ 
470
+			return true;
471 471
 		}else{
472 472
 			return false;
473 473
 		}
@@ -538,17 +538,17 @@  discard block
 block discarded – undo
538 538
 				$content = false;
539 539
 			}
540 540
 
541
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
542
-            if($jdata)
543
-            {
544
-                $adata=json_decode($jdata,true);
545
-                if(!empty($adata))
546
-                {
547
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
548
-                	$this->format_completed_row($return);
541
+			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
542
+			if($jdata)
543
+			{
544
+				$adata=json_decode($jdata,true);
545
+				if(!empty($adata))
546
+				{
547
+					$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
548
+					$this->format_completed_row($return);
549 549
 					$this->cleanup_posts();
550
-                }
551
-            }
550
+				}
551
+			}
552 552
 
553 553
 			die();
554 554
 		}
@@ -565,148 +565,148 @@  discard block
 block discarded – undo
565 565
 	 */
566 566
 	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
567 567
 
568
-        if(trim($data[0]['type'])=='Accommodation')
569
-        {
570
-	        $post_name = $data_post_content = $data_post_excerpt = '';
571
-	        $post = array(
572
-	          'post_type'		=> 'accommodation',
573
-	        );
574
-
575
-	        $content_used_general_description = false;
576
-
577
-	        //Set the post_content
578
-	        if(false !== $importable_content && in_array('description',$importable_content)){
579
-		        if(isset($data[0]['content']['extended_description']))
580
-		        {
581
-		            $data_post_content = $data[0]['content']['extended_description'];
582
-		        }elseif(isset($data[0]['content']['general_description'])){
583
-		            $data_post_content = $data[0]['content']['general_description'];
584
-		            $content_used_general_description = true;
585
-		        }elseif(isset($data[0]['content']['teaser_description'])){
586
-		        	$data_post_content = $data[0]['content']['teaser_description'];
587
-		        }
588
-	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
589
-	        }
590
-
591
-	        //set the post_excerpt
592
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
593
-		        if(isset($data[0]['content']['teaser_description'])){
594
-		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
595
-		        }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
596
-		            $data_post_excerpt = $data[0]['content']['general_description'];
597
-		        }	   
598
-		        $post['post_excerpt'] = $data_post_excerpt;     	
599
-	        }
600
-
601
-	        if(false !== $id && '0' !== $id){
602
-	        	$post['ID'] = $id;
568
+		if(trim($data[0]['type'])=='Accommodation')
569
+		{
570
+			$post_name = $data_post_content = $data_post_excerpt = '';
571
+			$post = array(
572
+			  'post_type'		=> 'accommodation',
573
+			);
574
+
575
+			$content_used_general_description = false;
576
+
577
+			//Set the post_content
578
+			if(false !== $importable_content && in_array('description',$importable_content)){
579
+				if(isset($data[0]['content']['extended_description']))
580
+				{
581
+					$data_post_content = $data[0]['content']['extended_description'];
582
+				}elseif(isset($data[0]['content']['general_description'])){
583
+					$data_post_content = $data[0]['content']['general_description'];
584
+					$content_used_general_description = true;
585
+				}elseif(isset($data[0]['content']['teaser_description'])){
586
+					$data_post_content = $data[0]['content']['teaser_description'];
587
+				}
588
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
589
+			}
590
+
591
+			//set the post_excerpt
592
+			if(false !== $importable_content && in_array('excerpt',$importable_content)){
593
+				if(isset($data[0]['content']['teaser_description'])){
594
+					$data_post_excerpt = $data[0]['content']['teaser_description'];
595
+				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
596
+					$data_post_excerpt = $data[0]['content']['general_description'];
597
+				}	   
598
+				$post['post_excerpt'] = $data_post_excerpt;     	
599
+			}
600
+
601
+			if(false !== $id && '0' !== $id){
602
+				$post['ID'] = $id;
603 603
 				if(isset($data[0]['name'])){
604 604
 					$post['post_title'] = $data[0]['name'];
605
-	        		$post['post_status'] = 'publish';
605
+					$post['post_status'] = 'publish';
606 606
 					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
607 607
 				}
608
-	        	$id = wp_update_post($post);
609
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
610
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
611
-	        }else{
612
-
613
-		        //Set the name
614
-		        if(isset($data[0]['name'])){
615
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
616
-		        }
617
-	        	$post['post_name'] = $post_name;
618
-	        	$post['post_title'] = $data[0]['name'];
619
-	        	$post['post_status'] = 'publish';
620
-	        	$id = wp_insert_post($post);
621
-
622
-	        	//Save the WETU ID and the Last date it was modified.
623
-	        	if(false !== $id){
624
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
625
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
626
-	        	}
627
-	        }
628
-	        //Setup some default for use in the import
629
-	        if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
608
+				$id = wp_update_post($post);
609
+				$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
610
+				update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
611
+			}else{
612
+
613
+				//Set the name
614
+				if(isset($data[0]['name'])){
615
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
616
+				}
617
+				$post['post_name'] = $post_name;
618
+				$post['post_title'] = $data[0]['name'];
619
+				$post['post_status'] = 'publish';
620
+				$id = wp_insert_post($post);
621
+
622
+				//Save the WETU ID and the Last date it was modified.
623
+				if(false !== $id){
624
+					add_post_meta($id,'lsx_wetu_id',$wetu_id);
625
+					add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
626
+				}
627
+			}
628
+			//Setup some default for use in the import
629
+			if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
630 630
 				$this->find_attachments($id);
631 631
 			}
632 632
 
633
-	        //Set the team member if it is there
634
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
635
-	        	$this->set_team_member($id,$team_members);
636
-	    	}
637
-
638
-	        //Set the safari brand
639
-	        if(false !== $safari_brands && '' !== $safari_brands){
640
-	        	$this->set_safari_brands($id,$safari_brands);
641
-
642
-	    	}	    	
643
-
644
-	        if(class_exists('LSX_TO_Maps')){
645
-	        	$this->set_map_data($data,$id,9);
646
-	        	$this->set_location_taxonomy($data,$id);
647
-	        }
648
-
649
-	        if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
650
-	        	$this->connect_destinations($data,$id);
651
-	        }
652
-
653
-	        if(false !== $importable_content && in_array('category',$importable_content)){
654
-	        	$this->set_taxonomy_style($data,$id);
655
-	        }
656
-
657
-	        //Set the Room Data
658
-	        if(false !== $importable_content && in_array('rooms',$importable_content)){
659
-	        	$this->set_room_data($data,$id);
660
-	    	}
661
-
662
-	    	//Set the rating
663
-	    	if(false !== $importable_content && in_array('rating',$importable_content)){
664
-	       		$this->set_rating($data,$id);
665
-	    	}
666
-
667
-	    	//Set the checkin checkout data
668
-	    	if(false !== $importable_content && in_array('checkin',$importable_content)){
669
-	        	$this->set_checkin_checkout($data,$id);
670
-	        }
671
-
672
-	    	//Set the Spoken Languages
673
-	    	if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
674
-	       		$this->set_spoken_languages($data,$id);
675
-	    	}
676
-
677
-	    	//Set the friendly options
678
-	    	if(false !== $importable_content && in_array('friendly',$importable_content)){
679
-	       		$this->set_friendly($data,$id);
680
-	    	}
681
-
682
-	    	//Set the special_interests
683
-	    	if(false !== $importable_content && in_array('special_interests',$importable_content)){
684
-	       		$this->set_special_interests($data,$id);
685
-	    	}	    		    		        
686
-
687
-	        //Import the videos
688
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
689
-	        	$this->set_video_data($data,$id);
690
-	        }
691
-
692
-	        //Import the facilities
693
-	        if(false !== $importable_content && in_array('facilities',$importable_content)){
694
-	        	$this->set_facilities($data,$id);
695
-	        }	        
696
-
697
-	        //Set the featured image
698
-	        if(false !== $importable_content && in_array('featured_image',$importable_content)){
699
-	        	$this->set_featured_image($data,$id);
700
-	        }
701
-	        if(false !== $importable_content && in_array('banner_image',$importable_content)){
702
-	        	$this->set_banner_image($data,$id);
703
-	        }	        
704
-	        //Import the main gallery
705
-	        if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
706
-	    		$this->create_main_gallery($data,$id);
707
-	        }	        	        	        
708
-        }
709
-        return $id;
633
+			//Set the team member if it is there
634
+			if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
635
+				$this->set_team_member($id,$team_members);
636
+			}
637
+
638
+			//Set the safari brand
639
+			if(false !== $safari_brands && '' !== $safari_brands){
640
+				$this->set_safari_brands($id,$safari_brands);
641
+
642
+			}	    	
643
+
644
+			if(class_exists('LSX_TO_Maps')){
645
+				$this->set_map_data($data,$id,9);
646
+				$this->set_location_taxonomy($data,$id);
647
+			}
648
+
649
+			if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
650
+				$this->connect_destinations($data,$id);
651
+			}
652
+
653
+			if(false !== $importable_content && in_array('category',$importable_content)){
654
+				$this->set_taxonomy_style($data,$id);
655
+			}
656
+
657
+			//Set the Room Data
658
+			if(false !== $importable_content && in_array('rooms',$importable_content)){
659
+				$this->set_room_data($data,$id);
660
+			}
661
+
662
+			//Set the rating
663
+			if(false !== $importable_content && in_array('rating',$importable_content)){
664
+		   		$this->set_rating($data,$id);
665
+			}
666
+
667
+			//Set the checkin checkout data
668
+			if(false !== $importable_content && in_array('checkin',$importable_content)){
669
+				$this->set_checkin_checkout($data,$id);
670
+			}
671
+
672
+			//Set the Spoken Languages
673
+			if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
674
+		   		$this->set_spoken_languages($data,$id);
675
+			}
676
+
677
+			//Set the friendly options
678
+			if(false !== $importable_content && in_array('friendly',$importable_content)){
679
+		   		$this->set_friendly($data,$id);
680
+			}
681
+
682
+			//Set the special_interests
683
+			if(false !== $importable_content && in_array('special_interests',$importable_content)){
684
+		   		$this->set_special_interests($data,$id);
685
+			}	    		    		        
686
+
687
+			//Import the videos
688
+			if(false !== $importable_content && in_array('videos',$importable_content)){
689
+				$this->set_video_data($data,$id);
690
+			}
691
+
692
+			//Import the facilities
693
+			if(false !== $importable_content && in_array('facilities',$importable_content)){
694
+				$this->set_facilities($data,$id);
695
+			}	        
696
+
697
+			//Set the featured image
698
+			if(false !== $importable_content && in_array('featured_image',$importable_content)){
699
+				$this->set_featured_image($data,$id);
700
+			}
701
+			if(false !== $importable_content && in_array('banner_image',$importable_content)){
702
+				$this->set_banner_image($data,$id);
703
+			}	        
704
+			//Import the main gallery
705
+			if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
706
+				$this->create_main_gallery($data,$id);
707
+			}	        	        	        
708
+		}
709
+		return $id;
710 710
 	}
711 711
 
712 712
 	/**
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 
717 717
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
718 718
 		foreach($team_members as $team){
719
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
719
+			add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
720 720
 		}
721 721
 	}
722 722
 
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 	 */
726 726
 	public function set_safari_brands($id,$safari_brands) {
727 727
 		foreach($safari_brands as $safari_brand){
728
-        	wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
728
+			wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
729 729
 		}
730 730
 	}	
731 731
 	
@@ -775,11 +775,11 @@  discard block
 block discarded – undo
775 775
 				'elevation'	=>	'',
776 776
 			);
777 777
 			if(false !== $id && '0' !== $id){
778
-	        	$prev = get_post_meta($id,'location',true);
779
-	        	update_post_meta($id,'location',$location_data,$prev);
780
-	        }else{
781
-	        	add_post_meta($id,'location',$location_data,true);
782
-	        }
778
+				$prev = get_post_meta($id,'location',true);
779
+				update_post_meta($id,'location',$location_data,$prev);
780
+			}else{
781
+				add_post_meta($id,'location',$location_data,true);
782
+			}
783 783
 		}
784 784
 	}
785 785
 	/**
@@ -793,35 +793,35 @@  discard block
 block discarded – undo
793 793
 			if(isset($data[0]['position']['country'])){
794 794
 
795 795
 				if(!$term = term_exists(trim($data[0]['position']['country']), 'location'))
796
-		        {
797
-		            $term = wp_insert_term(trim($data[0]['position']['country']), 'location');
798
-		            if ( is_wp_error($term) ){
799
-		            	echo $term->get_error_message();
800
-		            }
801
-		            else {
802
-		            	wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
803
-		            }
804
-		        }
805
-		        else
806
-		        {
807
-		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
808
-		        }
809
-		        $country_id = intval($term['term_id']);
810
-		    }
796
+				{
797
+					$term = wp_insert_term(trim($data[0]['position']['country']), 'location');
798
+					if ( is_wp_error($term) ){
799
+						echo $term->get_error_message();
800
+					}
801
+					else {
802
+						wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
803
+					}
804
+				}
805
+				else
806
+				{
807
+					wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
808
+				}
809
+				$country_id = intval($term['term_id']);
810
+			}
811 811
 
812 812
 			if(isset($data[0]['position']['destination'])){
813 813
 
814 814
 				$tax_args = array('parent'=>$country_id);
815 815
 				if(!$term = term_exists(trim($data[0]['position']['destination']), 'location'))
816
-		        {
817
-		            $term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args);
818
-		            if ( is_wp_error($term) ){echo $term->get_error_message();}
819
-		            else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); }
820
-		        }
821
-		        else
822
-		        {
823
-		            wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
824
-		        }				
816
+				{
817
+					$term = wp_insert_term(trim($data[0]['position']['destination']), 'location', $tax_args);
818
+					if ( is_wp_error($term) ){echo $term->get_error_message();}
819
+					else { wp_set_object_terms( $id, intval($term['term_id']), 'location',true); }
820
+				}
821
+				else
822
+				{
823
+					wp_set_object_terms( $id, intval($term['term_id']), 'location',true);
824
+				}				
825 825
 			}		
826 826
 		}
827 827
 	}
@@ -831,32 +831,32 @@  discard block
 block discarded – undo
831 831
 	 */
832 832
 	public function connect_destinations($data,$id) {
833 833
 		if(isset($data[0]['position'])){
834
-		    $destinations = false;
835
-		    if(isset($data[0]['position']['country'])){
836
-		    	$destinations['country'] = $data[0]['position']['country'];
837
-		    }
838
-		    if(isset($data[0]['position']['destination'])){
839
-		    	$destinations['destination'] = $data[0]['position']['destination'];
840
-		    }
834
+			$destinations = false;
835
+			if(isset($data[0]['position']['country'])){
836
+				$destinations['country'] = $data[0]['position']['country'];
837
+			}
838
+			if(isset($data[0]['position']['destination'])){
839
+				$destinations['destination'] = $data[0]['position']['destination'];
840
+			}
841 841
 		    
842
-		    if(false !== $destinations){	
843
-		    	$prev_values = get_post_meta($id,'destination_to_accommodation',false);
844
-		    	if(false === $prev_values || !is_array($prev_values)){
845
-		    		$prev_values = array();
846
-		    	}
847
-		    	//print_r($destinations);
842
+			if(false !== $destinations){	
843
+				$prev_values = get_post_meta($id,'destination_to_accommodation',false);
844
+				if(false === $prev_values || !is_array($prev_values)){
845
+					$prev_values = array();
846
+				}
847
+				//print_r($destinations);
848 848
 				$destinations = array_unique($destinations);
849 849
 				//print_r($destinations);
850
-			    foreach($destinations as $key => $value){
851
-				    $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
852
-	                if (null !== $destination) {
853
-	                	if(!in_array($destination->ID,$prev_values)){
854
-	                   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
855
-	                   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
850
+				foreach($destinations as $key => $value){
851
+					$destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
852
+					if (null !== $destination) {
853
+						if(!in_array($destination->ID,$prev_values)){
854
+					   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
855
+					   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
856 856
 							$this->cleanup_posts[$destination->ID] = 'accommodation_to_destination';
857
-	                	}
858
-	                } 		    	
859
-			    }	
857
+						}
858
+					} 		    	
859
+				}	
860 860
 			}
861 861
 		}
862 862
 	}	
@@ -868,15 +868,15 @@  discard block
 block discarded – undo
868 868
 		$terms = false;
869 869
 		if(isset($data[0]['category'])){
870 870
 			if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
871
-	        {
872
-	            $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
873
-	            if ( is_wp_error($term) ){echo $term->get_error_message();}
874
-	            else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
875
-	        }
876
-	        else
877
-	        {
878
-	            wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
879
-	        }				
871
+			{
872
+				$term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
873
+				if ( is_wp_error($term) ){echo $term->get_error_message();}
874
+				else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
875
+			}
876
+			else
877
+			{
878
+				wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
879
+			}				
880 880
 		}
881 881
 	}		
882 882
 
@@ -900,25 +900,25 @@  discard block
 block discarded – undo
900 900
 				$temp_room['type'] = 'room';
901 901
 
902 902
 				if(!empty($room['images']) && is_array($room['images'])){
903
-			    	$attachments_args = array(
904
-			    			'post_parent' => $id,
905
-			    			'post_status' => 'inherit',
906
-			    			'post_type' => 'attachment',
907
-			    			'order' => 'ASC',
908
-			    	);   	
909
-			    	$attachments = new WP_Query($attachments_args);
910
-			    	$found_attachments = array();
911
-
912
-			    	if($attachments->have_posts()){
913
-			    		foreach($attachments->posts as $attachment){
914
-			    			$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
915
-			    		}
916
-			    	}
903
+					$attachments_args = array(
904
+							'post_parent' => $id,
905
+							'post_status' => 'inherit',
906
+							'post_type' => 'attachment',
907
+							'order' => 'ASC',
908
+					);   	
909
+					$attachments = new WP_Query($attachments_args);
910
+					$found_attachments = array();
911
+
912
+					if($attachments->have_posts()){
913
+						foreach($attachments->posts as $attachment){
914
+							$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
915
+						}
916
+					}
917 917
 
918 918
 					$temp_room['gallery'] = array();
919 919
 					foreach($room['images'] as $image_data){
920
-			    		$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
921
-			    	}
920
+						$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
921
+					}
922 922
 				}
923 923
 				$rooms[] = $temp_room;
924 924
 			}
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 				delete_post_meta($id, 'units');				
928 928
 			}
929 929
 			foreach($rooms as $room){
930
-		        add_post_meta($id,'units',$room,false);			
930
+				add_post_meta($id,'units',$room,false);			
931 931
 			}
932 932
 
933 933
 			if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){
@@ -937,11 +937,11 @@  discard block
 block discarded – undo
937 937
 			}
938 938
 
939 939
 			if(false !== $id && '0' !== $id){
940
-	        	$prev_rooms = get_post_meta($id,'number_of_rooms',true);
941
-	        	update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
942
-	        }else{
943
-	        	add_post_meta($id,'number_of_rooms',$room_count,true);
944
-	        }
940
+				$prev_rooms = get_post_meta($id,'number_of_rooms',true);
941
+				update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
942
+			}else{
943
+				add_post_meta($id,'number_of_rooms',$room_count,true);
944
+			}
945 945
 		}
946 946
 	}
947 947
 
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 				delete_post_meta($id, 'videos');				
1052 1052
 			}
1053 1053
 			foreach($videos as $video){
1054
-		        add_post_meta($id,'videos',$video,false);			
1054
+				add_post_meta($id,'videos',$video,false);			
1055 1055
 			}
1056 1056
 		}
1057 1057
 	}	
@@ -1080,17 +1080,17 @@  discard block
 block discarded – undo
1080 1080
 
1081 1081
 	function set_term($id=false,$name=false,$taxonomy=false,$parent=false){
1082 1082
 		if(!$term = term_exists($name, $taxonomy))
1083
-        {
1084
-        	if(false !== $parent){ $parent = array('parent'=>$parent); }
1085
-            $term = wp_insert_term(trim($name), $taxonomy,$parent);
1086
-            if ( is_wp_error($term) ){echo $term->get_error_message();}
1087
-            else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
1088
-        }
1089
-        else
1090
-        {
1091
-            wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
1092
-        }
1093
-        return $term['term_id'];
1083
+		{
1084
+			if(false !== $parent){ $parent = array('parent'=>$parent); }
1085
+			$term = wp_insert_term(trim($name), $taxonomy,$parent);
1086
+			if ( is_wp_error($term) ){echo $term->get_error_message();}
1087
+			else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
1088
+		}
1089
+		else
1090
+		{
1091
+			wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
1092
+		}
1093
+		return $term['term_id'];
1094 1094
 	}	
1095 1095
 
1096 1096
 	/**
@@ -1098,17 +1098,17 @@  discard block
 block discarded – undo
1098 1098
 	 */
1099 1099
 	public function set_featured_image($data,$id) {
1100 1100
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1101
-	    	$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
1101
+			$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
1102 1102
 
1103
-	    	if(false !== $this->featured_image){
1104
-	    		delete_post_meta($id,'_thumbnail_id');
1105
-	    		add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
1103
+			if(false !== $this->featured_image){
1104
+				delete_post_meta($id,'_thumbnail_id');
1105
+				add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
1106 1106
 
1107
-	    		if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
1108
-	    			add_post_meta($id,'gallery',$this->featured_image,false);
1109
-	    			$this->gallery_meta[] = $this->featured_image;
1110
-	    		}
1111
-	    	}			
1107
+				if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
1108
+					add_post_meta($id,'gallery',$this->featured_image,false);
1109
+					$this->gallery_meta[] = $this->featured_image;
1110
+				}
1111
+			}			
1112 1112
 		}	
1113 1113
 	}	
1114 1114
 
@@ -1117,18 +1117,18 @@  discard block
 block discarded – undo
1117 1117
 	 */
1118 1118
 	public function set_banner_image($data,$id) {
1119 1119
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1120
-	    	$this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c'));
1121
-
1122
-	    	if(false !== $this->banner_image){
1123
-	    		delete_post_meta($id,'image_group');
1124
-	    		$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
1125
-	    		add_post_meta($id,'image_group',$new_banner,true);
1126
-
1127
-	    		if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
1128
-	    			add_post_meta($id,'gallery',$this->banner_image,false);
1129
-	    			$this->gallery_meta[] = $this->banner_image;
1130
-	    		}
1131
-	    	}			
1120
+			$this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c'));
1121
+
1122
+			if(false !== $this->banner_image){
1123
+				delete_post_meta($id,'image_group');
1124
+				$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
1125
+				add_post_meta($id,'image_group',$new_banner,true);
1126
+
1127
+				if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
1128
+					add_post_meta($id,'gallery',$this->banner_image,false);
1129
+					$this->gallery_meta[] = $this->banner_image;
1130
+				}
1131
+			}			
1132 1132
 		}	
1133 1133
 	}		
1134 1134
 
@@ -1138,25 +1138,25 @@  discard block
 block discarded – undo
1138 1138
 	public function create_main_gallery($data,$id) {
1139 1139
 
1140 1140
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
1141
-	    	$counter = 0;
1142
-	    	foreach($data[0]['content']['images'] as $image_data){
1143
-	    		if($counter === 0 && false !== $this->featured_image){$counter++;continue;}
1144
-	    		if($counter === 1 && false !== $this->banner_image){$counter++;continue;}
1141
+			$counter = 0;
1142
+			foreach($data[0]['content']['images'] as $image_data){
1143
+				if($counter === 0 && false !== $this->featured_image){$counter++;continue;}
1144
+				if($counter === 1 && false !== $this->banner_image){$counter++;continue;}
1145 1145
 
1146
-	    		$this->gallery_meta[] = $this->attach_image($image_data,$id);
1147
-	    		$counter++;
1148
-	    	}
1146
+				$this->gallery_meta[] = $this->attach_image($image_data,$id);
1147
+				$counter++;
1148
+			}
1149 1149
 
1150
-	    	if(!empty($this->gallery_meta)){
1151
-	    		delete_post_meta($id,'gallery');
1150
+			if(!empty($this->gallery_meta)){
1151
+				delete_post_meta($id,'gallery');
1152 1152
 				$this->gallery_meta = array_unique($this->gallery_meta);
1153
-	    		foreach($this->gallery_meta as $gallery_id){
1154
-	    			if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
1155
-	    				add_post_meta($id,'gallery',$gallery_id,false);
1156
-	    			}
1157
-	    		}
1158
-	    	}
1159
-    	}
1153
+				foreach($this->gallery_meta as $gallery_id){
1154
+					if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
1155
+						add_post_meta($id,'gallery',$gallery_id,false);
1156
+					}
1157
+				}
1158
+			}
1159
+		}
1160 1160
 	}	
1161 1161
 
1162 1162
 	/**
@@ -1165,42 +1165,42 @@  discard block
 block discarded – undo
1165 1165
 	public function attach_image($v=false,$parent_id,$image_sizes=false){
1166 1166
 		if(false !== $v){
1167 1167
 	   		$temp_fragment = explode('/',$v['url_fragment']);
1168
-	    	$url_filename = $temp_fragment[count($temp_fragment)-1];
1169
-	    	$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
1168
+			$url_filename = $temp_fragment[count($temp_fragment)-1];
1169
+			$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
1170 1170
 
1171
-	    	if(in_array($url_filename,$this->found_attachments)){
1172
-	    		return array_search($url_filename,$this->found_attachments);
1173
-	    	}
1171
+			if(in_array($url_filename,$this->found_attachments)){
1172
+				return array_search($url_filename,$this->found_attachments);
1173
+			}
1174 1174
 	    	               
1175
-	        $postdata=array();
1176
-	        if(empty($v['label']))
1177
-	        {
1178
-	            $v['label']='';
1179
-	        }
1180
-	        if(!empty($v['description']))
1181
-	        {
1182
-	            $desc=wp_strip_all_tags($v['description']);
1183
-	            $posdata=array('post_excerpt'=>$desc);
1184
-	        }
1185
-	        if(!empty($v['section']))
1186
-	        {
1187
-	            $desc=wp_strip_all_tags($v['section']);
1188
-	            $posdata=array('post_excerpt'=>$desc);
1189
-	        }
1190
-
1191
-	        $attachID=NULL;  
1192
-	        //Resizor - add option to setting if required
1193
-	        $fragment = str_replace(' ','%20',$v['url_fragment']);
1194
-	        $url = $this->get_scaling_url($image_sizes).$fragment;
1195
-	        $attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
1196
-
1197
-	        //echo($attachID.' add image');
1198
-	        if($attachID!=NULL)
1199
-	        {
1200
-	            return $attachID;
1201
-	        }
1202
-        }	
1203
-        return 	false;
1175
+			$postdata=array();
1176
+			if(empty($v['label']))
1177
+			{
1178
+				$v['label']='';
1179
+			}
1180
+			if(!empty($v['description']))
1181
+			{
1182
+				$desc=wp_strip_all_tags($v['description']);
1183
+				$posdata=array('post_excerpt'=>$desc);
1184
+			}
1185
+			if(!empty($v['section']))
1186
+			{
1187
+				$desc=wp_strip_all_tags($v['section']);
1188
+				$posdata=array('post_excerpt'=>$desc);
1189
+			}
1190
+
1191
+			$attachID=NULL;  
1192
+			//Resizor - add option to setting if required
1193
+			$fragment = str_replace(' ','%20',$v['url_fragment']);
1194
+			$url = $this->get_scaling_url($image_sizes).$fragment;
1195
+			$attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
1196
+
1197
+			//echo($attachID.' add image');
1198
+			if($attachID!=NULL)
1199
+			{
1200
+				return $attachID;
1201
+			}
1202
+		}	
1203
+		return 	false;
1204 1204
 	}
1205 1205
 	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
1206 1206
 	
Please login to merge, or discard this patch.