Completed
Push — master ( 59f15b...3574d6 )
by Warwick
03:27
created
classes/class-accommodation.php 2 patches
Indentation   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	public function set_variables()
72 72
 	{
73
-	    parent::set_variables();
73
+		parent::set_variables();
74 74
 		// ** This request only works with API KEY **
75 75
 		//if ( false !== $this->api_username && false !== $this->api_password ) {
76 76
 		//	$this->url    = 'https://wetu.com/API/Pins/';
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * Display the importer administration screen
96 96
 	 */
97 97
 	public function display_page() {
98
-        ?>
98
+		?>
99 99
         <div class="wrap">
100 100
             <?php $this->navigation('accommodation'); ?>
101 101
 
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 		$accommodation = json_decode($data, true);
237 237
 
238 238
 		if(isset($accommodation['error'])){
239
-		    return $accommodation['error'];
240
-        }elseif (isset($accommodation) && !empty($accommodation)) {
239
+			return $accommodation['error'];
240
+		}elseif (isset($accommodation) && !empty($accommodation)) {
241 241
 			set_transient('lsx_ti_accommodation',$accommodation,60*60*2);
242 242
 			return true;
243 243
 		}
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 			$accommodation = get_transient('lsx_ti_accommodation');
254 254
 
255 255
 			if(false === $accommodation){
256
-			    $this->update_options();
257
-            }
256
+				$this->update_options();
257
+			}
258 258
 
259 259
 			if ( false !== $accommodation ) {
260 260
 				$searched_items = false;
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 					$keyphrases = $_POST['keyword'];
264 264
 				}else{
265 265
 					$keyphrases = array(0);
266
-                }
266
+				}
267 267
 
268 268
 				if(!is_array($keyphrases)){
269 269
 					$keyphrases = array($keyphrases);
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
 
305 305
 							if('import' === $post_status){
306 306
 
307
-							    if(is_array($this->queued_imports) && in_array($row['post_id'],$this->queued_imports)){
307
+								if(is_array($this->queued_imports) && in_array($row['post_id'],$this->queued_imports)){
308 308
 									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
309
-                                }else{
310
-							        continue;
311
-                                }
309
+								}else{
310
+									continue;
311
+								}
312 312
 
313 313
 							}else{
314 314
 
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	 * Saves the queue to the option.
388 388
 	 */
389 389
 	public function remove_from_queue($id) {
390
-        if (!empty($this->queued_imports)) {
390
+		if (!empty($this->queued_imports)) {
391 391
 
392 392
 			if(($key = array_search($id, $this->queued_imports)) !== false) {
393 393
 				unset($this->queued_imports[$key]);
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 				delete_option('wetu_importer_que');
396 396
 				update_option('wetu_importer_que',$this->queued_imports);
397 397
 			}
398
-        }
398
+		}
399 399
 	}
400 400
 
401 401
 	/**
@@ -434,18 +434,18 @@  discard block
 block discarded – undo
434 434
 				$content = false;
435 435
 			}
436 436
 
437
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
438
-            if($jdata)
439
-            {
440
-                $adata=json_decode($jdata,true);
441
-                if(!empty($adata))
442
-                {
443
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
444
-                	$this->format_completed_row($return);
445
-                	$this->remove_from_queue($return);
437
+			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
438
+			if($jdata)
439
+			{
440
+				$adata=json_decode($jdata,true);
441
+				if(!empty($adata))
442
+				{
443
+					$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
444
+					$this->format_completed_row($return);
445
+					$this->remove_from_queue($return);
446 446
 					$this->cleanup_posts();
447
-                }
448
-            }
447
+				}
448
+			}
449 449
 		}
450 450
 	}
451 451
 
@@ -454,144 +454,144 @@  discard block
 block discarded – undo
454 454
 	 */
455 455
 	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
456 456
 
457
-	        $post_name = $data_post_content = $data_post_excerpt = '';
458
-	        $post = array(
459
-	          'post_type'		=> 'accommodation',
460
-	        );
461
-
462
-	        $content_used_general_description = false;
463
-
464
-	        //Set the post_content
465
-	        if(false !== $importable_content && in_array('description',$importable_content)){
466
-		        if(isset($data[0]['content']['extended_description']))
467
-		        {
468
-		            $data_post_content = $data[0]['content']['extended_description'];
469
-		        }elseif(isset($data[0]['content']['general_description'])){
470
-		            $data_post_content = $data[0]['content']['general_description'];
471
-		            $content_used_general_description = true;
472
-		        }elseif(isset($data[0]['content']['teaser_description'])){
473
-		        	$data_post_content = $data[0]['content']['teaser_description'];
474
-		        }
475
-	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
476
-	        }
477
-
478
-	        //set the post_excerpt
479
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
480
-		        if(isset($data[0]['content']['teaser_description'])){
481
-		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
482
-		        }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
483
-		            $data_post_excerpt = $data[0]['content']['general_description'];
484
-		        }	   
485
-		        $post['post_excerpt'] = $data_post_excerpt;     	
486
-	        }
487
-
488
-	        if(false !== $id && '0' !== $id){
489
-	        	$post['ID'] = $id;
457
+			$post_name = $data_post_content = $data_post_excerpt = '';
458
+			$post = array(
459
+			  'post_type'		=> 'accommodation',
460
+			);
461
+
462
+			$content_used_general_description = false;
463
+
464
+			//Set the post_content
465
+			if(false !== $importable_content && in_array('description',$importable_content)){
466
+				if(isset($data[0]['content']['extended_description']))
467
+				{
468
+					$data_post_content = $data[0]['content']['extended_description'];
469
+				}elseif(isset($data[0]['content']['general_description'])){
470
+					$data_post_content = $data[0]['content']['general_description'];
471
+					$content_used_general_description = true;
472
+				}elseif(isset($data[0]['content']['teaser_description'])){
473
+					$data_post_content = $data[0]['content']['teaser_description'];
474
+				}
475
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
476
+			}
477
+
478
+			//set the post_excerpt
479
+			if(false !== $importable_content && in_array('excerpt',$importable_content)){
480
+				if(isset($data[0]['content']['teaser_description'])){
481
+					$data_post_excerpt = $data[0]['content']['teaser_description'];
482
+				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
483
+					$data_post_excerpt = $data[0]['content']['general_description'];
484
+				}	   
485
+				$post['post_excerpt'] = $data_post_excerpt;     	
486
+			}
487
+
488
+			if(false !== $id && '0' !== $id){
489
+				$post['ID'] = $id;
490 490
 				if(isset($data[0]['name'])){
491 491
 					$post['post_title'] = $data[0]['name'];
492
-	        		$post['post_status'] = 'publish';
492
+					$post['post_status'] = 'publish';
493 493
 					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
494 494
 				}
495
-	        	$id = wp_update_post($post);
496
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
497
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
498
-	        }else{
499
-
500
-		        //Set the name
501
-		        if(isset($data[0]['name'])){
502
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
503
-		        }
504
-	        	$post['post_name'] = $post_name;
505
-	        	$post['post_title'] = $data[0]['name'];
506
-	        	$post['post_status'] = 'publish';
507
-	        	$id = wp_insert_post($post);
508
-
509
-	        	//Save the WETU ID and the Last date it was modified.
510
-	        	if(false !== $id){
511
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
512
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
513
-	        	}
514
-	        }
515
-	        //Setup some default for use in the import
516
-	        if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
495
+				$id = wp_update_post($post);
496
+				$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
497
+				update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
498
+			}else{
499
+
500
+				//Set the name
501
+				if(isset($data[0]['name'])){
502
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
503
+				}
504
+				$post['post_name'] = $post_name;
505
+				$post['post_title'] = $data[0]['name'];
506
+				$post['post_status'] = 'publish';
507
+				$id = wp_insert_post($post);
508
+
509
+				//Save the WETU ID and the Last date it was modified.
510
+				if(false !== $id){
511
+					add_post_meta($id,'lsx_wetu_id',$wetu_id);
512
+					add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
513
+				}
514
+			}
515
+			//Setup some default for use in the import
516
+			if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
517 517
 				$this->find_attachments($id);
518 518
 			}
519 519
 
520
-	        //Set the team member if it is there
521
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
522
-	        	$this->set_team_member($id,$team_members);
523
-	    	}
524
-
525
-	        //Set the safari brand
526
-	        if(false !== $safari_brands && '' !== $safari_brands){
527
-	        	$this->set_safari_brands($id,$safari_brands);
528
-
529
-	    	}	    	
530
-
531
-	        if(class_exists('LSX_TO_Maps')){
532
-	        	$this->set_map_data($data,$id,9);
533
-	        }
534
-
535
-	        if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
536
-	        	$this->connect_destinations($data,$id);
537
-	        }
538
-
539
-	        if(false !== $importable_content && in_array('category',$importable_content)){
540
-	        	$this->set_taxonomy_style($data,$id);
541
-	        }
542
-
543
-	        //Set the Room Data
544
-	        if(false !== $importable_content && in_array('rooms',$importable_content)){
545
-	        	$this->set_room_data($data,$id);
546
-	    	}
547
-
548
-	    	//Set the rating
549
-	    	if(false !== $importable_content && in_array('rating',$importable_content)){
550
-	       		$this->set_rating($data,$id);
551
-	    	}
552
-
553
-	    	//Set the checkin checkout data
554
-	    	if(false !== $importable_content && in_array('checkin',$importable_content)){
555
-	        	$this->set_checkin_checkout($data,$id);
556
-	        }
557
-
558
-	    	//Set the Spoken Languages
559
-	    	if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
560
-	       		$this->set_spoken_languages($data,$id);
561
-	    	}
562
-
563
-	    	//Set the friendly options
564
-	    	if(false !== $importable_content && in_array('friendly',$importable_content)){
565
-	       		$this->set_friendly($data,$id);
566
-	    	}
567
-
568
-	    	//Set the special_interests
569
-	    	if(false !== $importable_content && in_array('special_interests',$importable_content)){
570
-	       		$this->set_special_interests($data,$id);
571
-	    	}	    		    		        
572
-
573
-	        //Import the videos
574
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
575
-	        	$this->set_video_data($data,$id);
576
-	        }
577
-
578
-	        //Import the facilities
579
-	        if(false !== $importable_content && in_array('facilities',$importable_content)){
580
-	        	$this->set_facilities($data,$id);
581
-	        }	        
582
-
583
-	        //Set the featured image
584
-	        if(false !== $importable_content && in_array('featured_image',$importable_content)){
585
-	        	$this->set_featured_image($data,$id);
586
-	        }
587
-	        if(false !== $importable_content && in_array('banner_image',$importable_content)){
588
-	        	$this->set_banner_image($data,$id);
589
-	        }	        
590
-	        //Import the main gallery
591
-	        if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
592
-	    		$this->create_main_gallery($data,$id);
593
-	        }
594
-        return $id;
520
+			//Set the team member if it is there
521
+			if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
522
+				$this->set_team_member($id,$team_members);
523
+			}
524
+
525
+			//Set the safari brand
526
+			if(false !== $safari_brands && '' !== $safari_brands){
527
+				$this->set_safari_brands($id,$safari_brands);
528
+
529
+			}	    	
530
+
531
+			if(class_exists('LSX_TO_Maps')){
532
+				$this->set_map_data($data,$id,9);
533
+			}
534
+
535
+			if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
536
+				$this->connect_destinations($data,$id);
537
+			}
538
+
539
+			if(false !== $importable_content && in_array('category',$importable_content)){
540
+				$this->set_taxonomy_style($data,$id);
541
+			}
542
+
543
+			//Set the Room Data
544
+			if(false !== $importable_content && in_array('rooms',$importable_content)){
545
+				$this->set_room_data($data,$id);
546
+			}
547
+
548
+			//Set the rating
549
+			if(false !== $importable_content && in_array('rating',$importable_content)){
550
+		   		$this->set_rating($data,$id);
551
+			}
552
+
553
+			//Set the checkin checkout data
554
+			if(false !== $importable_content && in_array('checkin',$importable_content)){
555
+				$this->set_checkin_checkout($data,$id);
556
+			}
557
+
558
+			//Set the Spoken Languages
559
+			if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
560
+		   		$this->set_spoken_languages($data,$id);
561
+			}
562
+
563
+			//Set the friendly options
564
+			if(false !== $importable_content && in_array('friendly',$importable_content)){
565
+		   		$this->set_friendly($data,$id);
566
+			}
567
+
568
+			//Set the special_interests
569
+			if(false !== $importable_content && in_array('special_interests',$importable_content)){
570
+		   		$this->set_special_interests($data,$id);
571
+			}	    		    		        
572
+
573
+			//Import the videos
574
+			if(false !== $importable_content && in_array('videos',$importable_content)){
575
+				$this->set_video_data($data,$id);
576
+			}
577
+
578
+			//Import the facilities
579
+			if(false !== $importable_content && in_array('facilities',$importable_content)){
580
+				$this->set_facilities($data,$id);
581
+			}	        
582
+
583
+			//Set the featured image
584
+			if(false !== $importable_content && in_array('featured_image',$importable_content)){
585
+				$this->set_featured_image($data,$id);
586
+			}
587
+			if(false !== $importable_content && in_array('banner_image',$importable_content)){
588
+				$this->set_banner_image($data,$id);
589
+			}	        
590
+			//Import the main gallery
591
+			if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
592
+				$this->create_main_gallery($data,$id);
593
+			}
594
+		return $id;
595 595
 	}
596 596
 
597 597
 	/**
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 
602 602
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
603 603
 		foreach($team_members as $team){
604
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
604
+			add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
605 605
 		}
606 606
 	}
607 607
 
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 	 */
611 611
 	public function set_safari_brands($id,$safari_brands) {
612 612
 		foreach($safari_brands as $safari_brand){
613
-        	wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
613
+			wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
614 614
 		}
615 615
 	}
616 616
 
@@ -619,32 +619,32 @@  discard block
 block discarded – undo
619 619
 	 */
620 620
 	public function connect_destinations($data,$id) {
621 621
 		if(isset($data[0]['position'])){
622
-		    $destinations = false;
623
-		    if(isset($data[0]['position']['country'])){
624
-		    	$destinations['country'] = $data[0]['position']['country'];
625
-		    }
626
-		    if(isset($data[0]['position']['destination'])){
627
-		    	$destinations['destination'] = $data[0]['position']['destination'];
628
-		    }
622
+			$destinations = false;
623
+			if(isset($data[0]['position']['country'])){
624
+				$destinations['country'] = $data[0]['position']['country'];
625
+			}
626
+			if(isset($data[0]['position']['destination'])){
627
+				$destinations['destination'] = $data[0]['position']['destination'];
628
+			}
629 629
 		    
630
-		    if(false !== $destinations){	
631
-		    	$prev_values = get_post_meta($id,'destination_to_accommodation',false);
632
-		    	if(false === $prev_values || !is_array($prev_values)){
633
-		    		$prev_values = array();
634
-		    	}
635
-		    	//print_r($destinations);
630
+			if(false !== $destinations){	
631
+				$prev_values = get_post_meta($id,'destination_to_accommodation',false);
632
+				if(false === $prev_values || !is_array($prev_values)){
633
+					$prev_values = array();
634
+				}
635
+				//print_r($destinations);
636 636
 				$destinations = array_unique($destinations);
637 637
 				//print_r($destinations);
638
-			    foreach($destinations as $key => $value){
639
-				    $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
640
-	                if (null !== $destination) {
641
-	                	if(!in_array($destination->ID,$prev_values)){
642
-	                   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
643
-	                   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
638
+				foreach($destinations as $key => $value){
639
+					$destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
640
+					if (null !== $destination) {
641
+						if(!in_array($destination->ID,$prev_values)){
642
+					   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
643
+					   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
644 644
 							$this->cleanup_posts[$destination->ID] = 'accommodation_to_destination';
645
-	                	}
646
-	                } 		    	
647
-			    }	
645
+						}
646
+					} 		    	
647
+				}	
648 648
 			}
649 649
 		}
650 650
 	}	
@@ -656,15 +656,15 @@  discard block
 block discarded – undo
656 656
 		$terms = false;
657 657
 		if(isset($data[0]['category'])){
658 658
 			if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
659
-	        {
660
-	            $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
661
-	            if ( is_wp_error($term) ){echo $term->get_error_message();}
662
-	            else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
663
-	        }
664
-	        else
665
-	        {
666
-	            wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
667
-	        }				
659
+			{
660
+				$term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
661
+				if ( is_wp_error($term) ){echo $term->get_error_message();}
662
+				else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
663
+			}
664
+			else
665
+			{
666
+				wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
667
+			}				
668 668
 		}
669 669
 	}		
670 670
 
@@ -688,25 +688,25 @@  discard block
 block discarded – undo
688 688
 				$temp_room['type'] = 'room';
689 689
 
690 690
 				if(!empty($room['images']) && is_array($room['images'])){
691
-			    	$attachments_args = array(
692
-			    			'post_parent' => $id,
693
-			    			'post_status' => 'inherit',
694
-			    			'post_type' => 'attachment',
695
-			    			'order' => 'ASC',
696
-			    	);   	
697
-			    	$attachments = new WP_Query($attachments_args);
698
-			    	$found_attachments = array();
699
-
700
-			    	if($attachments->have_posts()){
701
-			    		foreach($attachments->posts as $attachment){
702
-			    			$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
703
-			    		}
704
-			    	}
691
+					$attachments_args = array(
692
+							'post_parent' => $id,
693
+							'post_status' => 'inherit',
694
+							'post_type' => 'attachment',
695
+							'order' => 'ASC',
696
+					);   	
697
+					$attachments = new WP_Query($attachments_args);
698
+					$found_attachments = array();
699
+
700
+					if($attachments->have_posts()){
701
+						foreach($attachments->posts as $attachment){
702
+							$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
703
+						}
704
+					}
705 705
 
706 706
 					$temp_room['gallery'] = array();
707 707
 					foreach($room['images'] as $image_data){
708
-			    		$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
709
-			    	}
708
+						$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
709
+					}
710 710
 				}
711 711
 				$rooms[] = $temp_room;
712 712
 			}
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 				delete_post_meta($id, 'units');				
716 716
 			}
717 717
 			foreach($rooms as $room){
718
-		        add_post_meta($id,'units',$room,false);			
718
+				add_post_meta($id,'units',$room,false);			
719 719
 			}
720 720
 
721 721
 			if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){
@@ -725,11 +725,11 @@  discard block
 block discarded – undo
725 725
 			}
726 726
 
727 727
 			if(false !== $id && '0' !== $id){
728
-	        	$prev_rooms = get_post_meta($id,'number_of_rooms',true);
729
-	        	update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
730
-	        }else{
731
-	        	add_post_meta($id,'number_of_rooms',$room_count,true);
732
-	        }
728
+				$prev_rooms = get_post_meta($id,'number_of_rooms',true);
729
+				update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
730
+			}else{
731
+				add_post_meta($id,'number_of_rooms',$room_count,true);
732
+			}
733 733
 		}
734 734
 	}
735 735
 
Please login to merge, or discard this patch.
Spacing   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -76,17 +76,17 @@  discard block
 block discarded – undo
76 76
 		//	$this->url    = 'https://wetu.com/API/Pins/';
77 77
 		//	$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
78 78
 		//} elseif ( false !== $this->api_key ) {
79
-			$this->url    = 'https://wetu.com/API/Pins/' . $this->api_key;
79
+			$this->url    = 'https://wetu.com/API/Pins/'.$this->api_key;
80 80
 			$this->url_qs = 'all=include';
81 81
 		//}
82 82
 
83
-		$temp_options = get_option('_lsx-to_settings',false);
84
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){
83
+		$temp_options = get_option('_lsx-to_settings', false);
84
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
85 85
 			$this->options = $temp_options[$this->plugin_slug];
86 86
 		}
87 87
 
88
-		$accommodation_options = get_option('wetu_importer_accommodation_settings',false);
89
-		if(false !== $accommodation_options){
88
+		$accommodation_options = get_option('wetu_importer_accommodation_settings', false);
89
+		if (false !== $accommodation_options) {
90 90
 			$this->accommodation_options = $accommodation_options;
91 91
 		}
92 92
 	}
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 			<form method="get" action="" id="posts-filter">
107 107
 				<input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" />
108 108
 				
109
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
110
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
109
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
110
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
111 111
 				</p>				
112 112
 
113 113
 				<table class="wp-list-table widefat fixed posts">
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 					<tbody id="the-list">
117 117
 						<tr class="post-0 type-tour status-none" id="post-0">
118 118
 							<th class="check-column" scope="row">
119
-								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label>
119
+								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label>
120 120
 							</th>
121 121
 							<td class="post-title page-title column-title">
122 122
 								<strong>
123
-									<?php _e('Enter a title to search for','wetu-importer'); ?>
123
+									<?php _e('Enter a title to search for', 'wetu-importer'); ?>
124 124
 								</strong>
125 125
 							</td>
126 126
 							<td class="date column-date">							
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 
135 135
 				</table>
136 136
 
137
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
138
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
137
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
138
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
139 139
 				</p>
140 140
 			</form> 
141 141
 
@@ -147,32 +147,32 @@  discard block
 block discarded – undo
147 147
 						<div class="settings-all" style="width:30%;display:block;float:left;">
148 148
 							<h3><?php _e('What content to Sync from WETU'); ?></h3>
149 149
 							<ul>
150
-                                <li><input class="content select-all" <?php $this->checked($this->accommodation_options,'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php _e('Select All','wetu-importer'); ?></li>
151
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li>
152
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li>
153
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery','wetu-importer'); ?></li>
154
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li>
155
-		                        <?php if(class_exists('LSX_TO_Maps')){ ?>
156
-								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php _e('Location','wetu-importer'); ?></li>
150
+                                <li><input class="content select-all" <?php $this->checked($this->accommodation_options, 'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php _e('Select All', 'wetu-importer'); ?></li>
151
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li>
152
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li>
153
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery', 'wetu-importer'); ?></li>
154
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li>
155
+		                        <?php if (class_exists('LSX_TO_Maps')) { ?>
156
+								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php _e('Location', 'wetu-importer'); ?></li>
157 157
 		                        <?php } ?>
158
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php _e('Connect Destinations','wetu-importer'); ?></li>
159
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php _e('Check In / Check Out','wetu-importer'); ?></li>
160
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php _e('Facilities','wetu-importer'); ?></li>
161
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php _e('Friendly','wetu-importer'); ?></li>
162
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php _e('Rating','wetu-importer'); ?></li>
163
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php _e('Rooms','wetu-importer'); ?></li>
164
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php _e('Special Interests','wetu-importer'); ?></li>
165
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php _e('Spoken Languages','wetu-importer'); ?></li>
166
-
167
-		                        <?php if(class_exists('LSX_TO_Videos')){ ?>
168
-								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos','wetu-importer'); ?></li>
158
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php _e('Connect Destinations', 'wetu-importer'); ?></li>
159
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php _e('Check In / Check Out', 'wetu-importer'); ?></li>
160
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php _e('Facilities', 'wetu-importer'); ?></li>
161
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php _e('Friendly', 'wetu-importer'); ?></li>
162
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php _e('Rating', 'wetu-importer'); ?></li>
163
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php _e('Rooms', 'wetu-importer'); ?></li>
164
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php _e('Special Interests', 'wetu-importer'); ?></li>
165
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php _e('Spoken Languages', 'wetu-importer'); ?></li>
166
+
167
+		                        <?php if (class_exists('LSX_TO_Videos')) { ?>
168
+								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos', 'wetu-importer'); ?></li>
169 169
 		                        <?php } ?>
170 170
 							</ul>
171 171
 							<h4><?php _e('Additional Content'); ?></h4>
172 172
 							<ul>
173
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image','wetu-importer'); ?></li>
174
-		                        <?php if(class_exists('LSX_Banners')){ ?>
175
-								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image','wetu-importer'); ?></li>
173
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image', 'wetu-importer'); ?></li>
174
+		                        <?php if (class_exists('LSX_Banners')) { ?>
175
+								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image', 'wetu-importer'); ?></li>
176 176
 		                        <?php } ?>
177 177
 							</ul>
178 178
 						</div>
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
 						<div style="width:30%;display:block;float:left;">
185 185
 							<h3><?php _e('Assign a Safari Brand'); ?></h3> 
186
-							<?php echo $this->taxonomy_checkboxes('accommodation-brand',$this->accommodation_options); ?>
186
+							<?php echo $this->taxonomy_checkboxes('accommodation-brand', $this->accommodation_options); ?>
187 187
 						</div>	
188 188
 
189 189
 						<br clear="both" />			
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
 
193 193
 					<h3><?php _e('Your List'); ?></h3>
194
-                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
194
+                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
195 195
 					<table class="wp-list-table widefat fixed posts">
196 196
 						<?php $this->table_header(); ?>
197 197
 
@@ -203,12 +203,12 @@  discard block
 block discarded – undo
203 203
 
204 204
 					</table>
205 205
 
206
-					<p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
206
+					<p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
207 207
 				</form>
208 208
 			</div>
209 209
 
210 210
 			<div style="display:none;" class="completed-list-wrapper">
211
-				<h3><?php _e('Completed'); ?> - <small><?php _e('Import your','wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations'); ?></a> <?php _e('next','wetu-importer'); ?></small></h3>
211
+				<h3><?php _e('Completed'); ?> - <small><?php _e('Import your', 'wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations'); ?></a> <?php _e('next', 'wetu-importer'); ?></small></h3>
212 212
 				<ul>
213 213
 				</ul>
214 214
 			</div>
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 	 * search_form
221 221
 	 */
222 222
 	public function update_options_form() {
223
-		echo '<div style="display:none;" class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').'</h3>';
223
+		echo '<div style="display:none;" class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').'</h3>';
224 224
 		$accommodation = get_transient('lsx_ti_accommodation');
225
-		if('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])){
225
+		if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) {
226 226
 			$this->update_options();
227 227
 		}
228 228
 		echo '</div>';
@@ -232,13 +232,13 @@  discard block
 block discarded – undo
232 232
 	 * Save the list of Accommodation into an option
233 233
 	 */
234 234
 	public function update_options() {
235
-		$data = file_get_contents( $this->url . '/List?' . $this->url_qs );
235
+		$data = file_get_contents($this->url.'/List?'.$this->url_qs);
236 236
 		$accommodation = json_decode($data, true);
237 237
 
238
-		if(isset($accommodation['error'])){
238
+		if (isset($accommodation['error'])) {
239 239
 		    return $accommodation['error'];
240 240
         }elseif (isset($accommodation) && !empty($accommodation)) {
241
-			set_transient('lsx_ti_accommodation',$accommodation,60*60*2);
241
+			set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2);
242 242
 			return true;
243 243
 		}
244 244
 	}
@@ -249,41 +249,41 @@  discard block
 block discarded – undo
249 249
 	public function process_ajax_search() {
250 250
 		$return = false;
251 251
 
252
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation'){
252
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation') {
253 253
 			$accommodation = get_transient('lsx_ti_accommodation');
254 254
 
255
-			if(false === $accommodation){
255
+			if (false === $accommodation) {
256 256
 			    $this->update_options();
257 257
             }
258 258
 
259
-			if ( false !== $accommodation ) {
259
+			if (false !== $accommodation) {
260 260
 				$searched_items = false;
261 261
 
262
-				if(isset($_POST['keyword'] )) {
262
+				if (isset($_POST['keyword'])) {
263 263
 					$keyphrases = $_POST['keyword'];
264
-				}else{
264
+				}else {
265 265
 					$keyphrases = array(0);
266 266
                 }
267 267
 
268
-				if(!is_array($keyphrases)){
268
+				if (!is_array($keyphrases)) {
269 269
 					$keyphrases = array($keyphrases);
270 270
 				}
271
-				foreach($keyphrases as &$keyword){
271
+				foreach ($keyphrases as &$keyword) {
272 272
 					$keyword = ltrim(rtrim($keyword));
273 273
 				}
274 274
 
275 275
 
276 276
 				$post_status = false;
277
-				if(in_array('publish',$keyphrases)){
277
+				if (in_array('publish', $keyphrases)) {
278 278
 					$post_status = 'publish';
279 279
 				}
280
-				if(in_array('pending',$keyphrases)){
280
+				if (in_array('pending', $keyphrases)) {
281 281
 					$post_status = 'pending';
282 282
 				}
283
-				if(in_array('draft',$keyphrases)){
283
+				if (in_array('draft', $keyphrases)) {
284 284
 					$post_status = 'draft';
285 285
 				}
286
-				if(in_array('import',$keyphrases)){
286
+				if (in_array('import', $keyphrases)) {
287 287
 					$post_status = 'import';
288 288
 				}
289 289
 
@@ -291,32 +291,32 @@  discard block
 block discarded – undo
291 291
 
292 292
 					$current_accommodation = $this->find_current_accommodation();
293 293
 
294
-					foreach($accommodation as $row_key => $row){
294
+					foreach ($accommodation as $row_key => $row) {
295 295
 
296 296
 						//If this is a current tour, add its ID to the row.
297 297
 						$row['post_id'] = 0;
298
-						if(false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)){
298
+						if (false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)) {
299 299
 							$row['post_id'] = $current_accommodation[$row['id']]->post_id;
300 300
 						}
301 301
 
302 302
 						//If we are searching for
303
-						if(false !== $post_status){
303
+						if (false !== $post_status) {
304 304
 
305
-							if('import' === $post_status){
305
+							if ('import' === $post_status) {
306 306
 
307
-							    if(is_array($this->queued_imports) && in_array($row['post_id'],$this->queued_imports)){
307
+							    if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) {
308 308
 									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
309
-                                }else{
309
+                                }else {
310 310
 							        continue;
311 311
                                 }
312 312
 
313
-							}else{
313
+							}else {
314 314
 
315
-								if(0 === $row['post_id']){
315
+								if (0 === $row['post_id']) {
316 316
 									continue;
317
-								}else{
317
+								}else {
318 318
 									$current_status = get_post_status($row['post_id']);
319
-									if($current_status !== $post_status){
319
+									if ($current_status !== $post_status) {
320 320
 										continue;
321 321
 									}
322 322
 
@@ -324,17 +324,17 @@  discard block
 block discarded – undo
324 324
 								$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
325 325
 							}
326 326
 
327
-						}else{
327
+						}else {
328 328
 							//Search through each keyword.
329
-							foreach($keyphrases as $keyphrase){
329
+							foreach ($keyphrases as $keyphrase) {
330 330
 
331 331
 								//Make sure the keyphrase is turned into an array
332
-								$keywords = explode(" ",$keyphrase);
333
-								if(!is_array($keywords)){
332
+								$keywords = explode(" ", $keyphrase);
333
+								if (!is_array($keywords)) {
334 334
 									$keywords = array($keywords);
335 335
 								}
336 336
 
337
-								if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){
337
+								if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) {
338 338
 									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
339 339
 								}
340 340
 							}
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 				}
344 344
 
345 345
 
346
-				if(false !== $searched_items){
346
+				if (false !== $searched_items) {
347 347
 					ksort($searched_items);
348 348
 					$return = implode($searched_items);
349 349
 				}
@@ -355,11 +355,11 @@  discard block
 block discarded – undo
355 355
 	/**
356 356
 	 * Formats the row for output on the screen.
357 357
 	 */	
358
-	public function format_row($row = false){
359
-		if(false !== $row){
358
+	public function format_row($row = false) {
359
+		if (false !== $row) {
360 360
 
361 361
 			$status = 'import';
362
-			if(0 !== $row['post_id']){
362
+			if (0 !== $row['post_id']) {
363 363
 				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
364 364
 			}
365 365
 
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 					<strong>'.$row['name'].'</strong> - '.$status.'
374 374
 				</td>
375 375
 				<td class="date column-date">
376
-					<abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified
376
+					<abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
377 377
 				</td>
378 378
 				<td class="ssid column-ssid">
379 379
 					'.$row['id'].'
@@ -389,11 +389,11 @@  discard block
 block discarded – undo
389 389
 	public function remove_from_queue($id) {
390 390
         if (!empty($this->queued_imports)) {
391 391
 
392
-			if(($key = array_search($id, $this->queued_imports)) !== false) {
392
+			if (($key = array_search($id, $this->queued_imports)) !== false) {
393 393
 				unset($this->queued_imports[$key]);
394 394
 
395 395
 				delete_option('wetu_importer_que');
396
-				update_option('wetu_importer_que',$this->queued_imports);
396
+				update_option('wetu_importer_que', $this->queued_imports);
397 397
 			}
398 398
         }
399 399
 	}
@@ -404,43 +404,43 @@  discard block
 block discarded – undo
404 404
 	public function process_ajax_import() {
405 405
 		$return = false;
406 406
 
407
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])){
407
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])) {
408 408
 			
409 409
 			$wetu_id = $_POST['wetu_id'];
410
-			if(isset($_POST['post_id'])){
410
+			if (isset($_POST['post_id'])) {
411 411
 				$post_id = $_POST['post_id'];	
412
-			}else{
412
+			}else {
413 413
 				$post_id = 0;
414 414
 			}
415 415
 
416
-			if(isset($_POST['team_members'])){
416
+			if (isset($_POST['team_members'])) {
417 417
 				$team_members = $_POST['team_members'];	
418
-			}else{
418
+			}else {
419 419
 				$team_members = false;
420 420
 			}
421 421
 
422
-			if(isset($_POST['safari_brands'])){
422
+			if (isset($_POST['safari_brands'])) {
423 423
 				$safari_brands = $_POST['safari_brands'];	
424
-			}else{
424
+			}else {
425 425
 				$safari_brands = false;
426 426
 			}
427 427
 
428 428
 			delete_option('wetu_importer_accommodation_settings');
429
-			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
429
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
430 430
 				$content = $_POST['content'];
431
-				add_option('wetu_importer_accommodation_settings',$content);
432
-			}else{
431
+				add_option('wetu_importer_accommodation_settings', $content);
432
+			}else {
433 433
 
434 434
 				$content = false;
435 435
 			}
436 436
 
437
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
438
-            if($jdata)
437
+            $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
438
+            if ($jdata)
439 439
             {
440
-                $adata=json_decode($jdata,true);
441
-                if(!empty($adata))
440
+                $adata = json_decode($jdata, true);
441
+                if (!empty($adata))
442 442
                 {
443
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
443
+                	$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
444 444
                 	$this->format_completed_row($return);
445 445
                 	$this->remove_from_queue($return);
446 446
 					$this->cleanup_posts();
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 	/**
453 453
 	 * Connect to wetu
454 454
 	 */
455
-	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
455
+	public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false) {
456 456
 
457 457
 	        $post_name = $data_post_content = $data_post_excerpt = '';
458 458
 	        $post = array(
@@ -462,44 +462,44 @@  discard block
 block discarded – undo
462 462
 	        $content_used_general_description = false;
463 463
 
464 464
 	        //Set the post_content
465
-	        if(false !== $importable_content && in_array('description',$importable_content)){
466
-		        if(isset($data[0]['content']['extended_description']))
465
+	        if (false !== $importable_content && in_array('description', $importable_content)) {
466
+		        if (isset($data[0]['content']['extended_description']))
467 467
 		        {
468 468
 		            $data_post_content = $data[0]['content']['extended_description'];
469
-		        }elseif(isset($data[0]['content']['general_description'])){
469
+		        }elseif (isset($data[0]['content']['general_description'])) {
470 470
 		            $data_post_content = $data[0]['content']['general_description'];
471 471
 		            $content_used_general_description = true;
472
-		        }elseif(isset($data[0]['content']['teaser_description'])){
472
+		        }elseif (isset($data[0]['content']['teaser_description'])) {
473 473
 		        	$data_post_content = $data[0]['content']['teaser_description'];
474 474
 		        }
475 475
 	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
476 476
 	        }
477 477
 
478 478
 	        //set the post_excerpt
479
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
480
-		        if(isset($data[0]['content']['teaser_description'])){
479
+	        if (false !== $importable_content && in_array('excerpt', $importable_content)) {
480
+		        if (isset($data[0]['content']['teaser_description'])) {
481 481
 		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
482
-		        }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
482
+		        }elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) {
483 483
 		            $data_post_excerpt = $data[0]['content']['general_description'];
484 484
 		        }	   
485 485
 		        $post['post_excerpt'] = $data_post_excerpt;     	
486 486
 	        }
487 487
 
488
-	        if(false !== $id && '0' !== $id){
488
+	        if (false !== $id && '0' !== $id) {
489 489
 	        	$post['ID'] = $id;
490
-				if(isset($data[0]['name'])){
490
+				if (isset($data[0]['name'])) {
491 491
 					$post['post_title'] = $data[0]['name'];
492 492
 	        		$post['post_status'] = 'publish';
493
-					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
493
+					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0);
494 494
 				}
495 495
 	        	$id = wp_update_post($post);
496
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
497
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
498
-	        }else{
496
+	        	$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
497
+	        	update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
498
+	        }else {
499 499
 
500 500
 		        //Set the name
501
-		        if(isset($data[0]['name'])){
502
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
501
+		        if (isset($data[0]['name'])) {
502
+		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0);
503 503
 		        }
504 504
 	        	$post['post_name'] = $post_name;
505 505
 	        	$post['post_title'] = $data[0]['name'];
@@ -507,89 +507,89 @@  discard block
 block discarded – undo
507 507
 	        	$id = wp_insert_post($post);
508 508
 
509 509
 	        	//Save the WETU ID and the Last date it was modified.
510
-	        	if(false !== $id){
511
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
512
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
510
+	        	if (false !== $id) {
511
+	        		add_post_meta($id, 'lsx_wetu_id', $wetu_id);
512
+	        		add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']));
513 513
 	        	}
514 514
 	        }
515 515
 	        //Setup some default for use in the import
516
-	        if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
516
+	        if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) {
517 517
 				$this->find_attachments($id);
518 518
 			}
519 519
 
520 520
 	        //Set the team member if it is there
521
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
522
-	        	$this->set_team_member($id,$team_members);
521
+	        if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
522
+	        	$this->set_team_member($id, $team_members);
523 523
 	    	}
524 524
 
525 525
 	        //Set the safari brand
526
-	        if(false !== $safari_brands && '' !== $safari_brands){
527
-	        	$this->set_safari_brands($id,$safari_brands);
526
+	        if (false !== $safari_brands && '' !== $safari_brands) {
527
+	        	$this->set_safari_brands($id, $safari_brands);
528 528
 
529 529
 	    	}	    	
530 530
 
531
-	        if(class_exists('LSX_TO_Maps')){
532
-	        	$this->set_map_data($data,$id,9);
531
+	        if (class_exists('LSX_TO_Maps')) {
532
+	        	$this->set_map_data($data, $id, 9);
533 533
 	        }
534 534
 
535
-	        if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
536
-	        	$this->connect_destinations($data,$id);
535
+	        if (post_type_exists('destination') && false !== $importable_content && in_array('destination', $importable_content)) {
536
+	        	$this->connect_destinations($data, $id);
537 537
 	        }
538 538
 
539
-	        if(false !== $importable_content && in_array('category',$importable_content)){
540
-	        	$this->set_taxonomy_style($data,$id);
539
+	        if (false !== $importable_content && in_array('category', $importable_content)) {
540
+	        	$this->set_taxonomy_style($data, $id);
541 541
 	        }
542 542
 
543 543
 	        //Set the Room Data
544
-	        if(false !== $importable_content && in_array('rooms',$importable_content)){
545
-	        	$this->set_room_data($data,$id);
544
+	        if (false !== $importable_content && in_array('rooms', $importable_content)) {
545
+	        	$this->set_room_data($data, $id);
546 546
 	    	}
547 547
 
548 548
 	    	//Set the rating
549
-	    	if(false !== $importable_content && in_array('rating',$importable_content)){
550
-	       		$this->set_rating($data,$id);
549
+	    	if (false !== $importable_content && in_array('rating', $importable_content)) {
550
+	       		$this->set_rating($data, $id);
551 551
 	    	}
552 552
 
553 553
 	    	//Set the checkin checkout data
554
-	    	if(false !== $importable_content && in_array('checkin',$importable_content)){
555
-	        	$this->set_checkin_checkout($data,$id);
554
+	    	if (false !== $importable_content && in_array('checkin', $importable_content)) {
555
+	        	$this->set_checkin_checkout($data, $id);
556 556
 	        }
557 557
 
558 558
 	    	//Set the Spoken Languages
559
-	    	if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
560
-	       		$this->set_spoken_languages($data,$id);
559
+	    	if (false !== $importable_content && in_array('spoken_languages', $importable_content)) {
560
+	       		$this->set_spoken_languages($data, $id);
561 561
 	    	}
562 562
 
563 563
 	    	//Set the friendly options
564
-	    	if(false !== $importable_content && in_array('friendly',$importable_content)){
565
-	       		$this->set_friendly($data,$id);
564
+	    	if (false !== $importable_content && in_array('friendly', $importable_content)) {
565
+	       		$this->set_friendly($data, $id);
566 566
 	    	}
567 567
 
568 568
 	    	//Set the special_interests
569
-	    	if(false !== $importable_content && in_array('special_interests',$importable_content)){
570
-	       		$this->set_special_interests($data,$id);
569
+	    	if (false !== $importable_content && in_array('special_interests', $importable_content)) {
570
+	       		$this->set_special_interests($data, $id);
571 571
 	    	}	    		    		        
572 572
 
573 573
 	        //Import the videos
574
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
575
-	        	$this->set_video_data($data,$id);
574
+	        if (false !== $importable_content && in_array('videos', $importable_content)) {
575
+	        	$this->set_video_data($data, $id);
576 576
 	        }
577 577
 
578 578
 	        //Import the facilities
579
-	        if(false !== $importable_content && in_array('facilities',$importable_content)){
580
-	        	$this->set_facilities($data,$id);
579
+	        if (false !== $importable_content && in_array('facilities', $importable_content)) {
580
+	        	$this->set_facilities($data, $id);
581 581
 	        }	        
582 582
 
583 583
 	        //Set the featured image
584
-	        if(false !== $importable_content && in_array('featured_image',$importable_content)){
585
-	        	$this->set_featured_image($data,$id);
584
+	        if (false !== $importable_content && in_array('featured_image', $importable_content)) {
585
+	        	$this->set_featured_image($data, $id);
586 586
 	        }
587
-	        if(false !== $importable_content && in_array('banner_image',$importable_content)){
588
-	        	$this->set_banner_image($data,$id);
587
+	        if (false !== $importable_content && in_array('banner_image', $importable_content)) {
588
+	        	$this->set_banner_image($data, $id);
589 589
 	        }	        
590 590
 	        //Import the main gallery
591
-	        if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
592
-	    		$this->create_main_gallery($data,$id);
591
+	        if (false !== $importable_content && in_array('gallery', $importable_content)) {	    	
592
+	    		$this->create_main_gallery($data, $id);
593 593
 	        }
594 594
         return $id;
595 595
 	}
@@ -597,50 +597,50 @@  discard block
 block discarded – undo
597 597
 	/**
598 598
 	 * Set the team memberon each item.
599 599
 	 */
600
-	public function set_team_member($id,$team_members) {
600
+	public function set_team_member($id, $team_members) {
601 601
 
602 602
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
603
-		foreach($team_members as $team){
604
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
603
+		foreach ($team_members as $team) {
604
+        	add_post_meta($id, 'team_to_'.$this->tab_slug, $team);			
605 605
 		}
606 606
 	}
607 607
 
608 608
 	/**
609 609
 	 * Set the safari brand
610 610
 	 */
611
-	public function set_safari_brands($id,$safari_brands) {
612
-		foreach($safari_brands as $safari_brand){
613
-        	wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
611
+	public function set_safari_brands($id, $safari_brands) {
612
+		foreach ($safari_brands as $safari_brand) {
613
+        	wp_set_object_terms($id, intval($safari_brand), 'accommodation-brand', true);			
614 614
 		}
615 615
 	}
616 616
 
617 617
 	/**
618 618
 	 * Connects the destinations post type
619 619
 	 */
620
-	public function connect_destinations($data,$id) {
621
-		if(isset($data[0]['position'])){
620
+	public function connect_destinations($data, $id) {
621
+		if (isset($data[0]['position'])) {
622 622
 		    $destinations = false;
623
-		    if(isset($data[0]['position']['country'])){
623
+		    if (isset($data[0]['position']['country'])) {
624 624
 		    	$destinations['country'] = $data[0]['position']['country'];
625 625
 		    }
626
-		    if(isset($data[0]['position']['destination'])){
626
+		    if (isset($data[0]['position']['destination'])) {
627 627
 		    	$destinations['destination'] = $data[0]['position']['destination'];
628 628
 		    }
629 629
 		    
630
-		    if(false !== $destinations){	
631
-		    	$prev_values = get_post_meta($id,'destination_to_accommodation',false);
632
-		    	if(false === $prev_values || !is_array($prev_values)){
630
+		    if (false !== $destinations) {	
631
+		    	$prev_values = get_post_meta($id, 'destination_to_accommodation', false);
632
+		    	if (false === $prev_values || !is_array($prev_values)) {
633 633
 		    		$prev_values = array();
634 634
 		    	}
635 635
 		    	//print_r($destinations);
636 636
 				$destinations = array_unique($destinations);
637 637
 				//print_r($destinations);
638
-			    foreach($destinations as $key => $value){
638
+			    foreach ($destinations as $key => $value) {
639 639
 				    $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
640 640
 	                if (null !== $destination) {
641
-	                	if(!in_array($destination->ID,$prev_values)){
642
-	                   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
643
-	                   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
641
+	                	if (!in_array($destination->ID, $prev_values)) {
642
+	                   		add_post_meta($id, 'destination_to_accommodation', $destination->ID, false);
643
+	                   		add_post_meta($destination->ID, 'accommodation_to_destination', $id, false);
644 644
 							$this->cleanup_posts[$destination->ID] = 'accommodation_to_destination';
645 645
 	                	}
646 646
 	                } 		    	
@@ -652,18 +652,18 @@  discard block
 block discarded – undo
652 652
 	/**
653 653
 	 * Set the Travel Style
654 654
 	 */
655
-	public function set_taxonomy_style($data,$id) {
655
+	public function set_taxonomy_style($data, $id) {
656 656
 		$terms = false;
657
-		if(isset($data[0]['category'])){
658
-			if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
657
+		if (isset($data[0]['category'])) {
658
+			if (!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
659 659
 	        {
660 660
 	            $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
661
-	            if ( is_wp_error($term) ){echo $term->get_error_message();}
662
-	            else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
661
+	            if (is_wp_error($term)) {echo $term->get_error_message(); }
662
+	            else { wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true); }
663 663
 	        }
664 664
 	        else
665 665
 	        {
666
-	            wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
666
+	            wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true);
667 667
 	        }				
668 668
 		}
669 669
 	}		
@@ -671,23 +671,23 @@  discard block
 block discarded – undo
671 671
 	/**
672 672
 	 * Saves the room data
673 673
 	 */
674
-	public function set_room_data($data,$id) {
675
-		if(!empty($data[0]['rooms']) && is_array($data[0]['rooms'])){
674
+	public function set_room_data($data, $id) {
675
+		if (!empty($data[0]['rooms']) && is_array($data[0]['rooms'])) {
676 676
 			$rooms = false;
677 677
 
678
-			foreach($data[0]['rooms'] as $room){
678
+			foreach ($data[0]['rooms'] as $room) {
679 679
 
680 680
 				$temp_room = array();
681
-				if(isset($room['name'])){
681
+				if (isset($room['name'])) {
682 682
 					$temp_room['title'] = $room['name'];
683 683
 				}
684
-				if(isset($room['description'])){
684
+				if (isset($room['description'])) {
685 685
 					$temp_room['description'] = strip_tags($room['description']);
686 686
 				}			
687 687
 				$temp_room['price'] = 0;
688 688
 				$temp_room['type'] = 'room';
689 689
 
690
-				if(!empty($room['images']) && is_array($room['images'])){
690
+				if (!empty($room['images']) && is_array($room['images'])) {
691 691
 			    	$attachments_args = array(
692 692
 			    			'post_parent' => $id,
693 693
 			    			'post_status' => 'inherit',
@@ -697,38 +697,38 @@  discard block
 block discarded – undo
697 697
 			    	$attachments = new WP_Query($attachments_args);
698 698
 			    	$found_attachments = array();
699 699
 
700
-			    	if($attachments->have_posts()){
701
-			    		foreach($attachments->posts as $attachment){
702
-			    			$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
700
+			    	if ($attachments->have_posts()) {
701
+			    		foreach ($attachments->posts as $attachment) {
702
+			    			$found_attachments[] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title);
703 703
 			    		}
704 704
 			    	}
705 705
 
706 706
 					$temp_room['gallery'] = array();
707
-					foreach($room['images'] as $image_data){
708
-			    		$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
707
+					foreach ($room['images'] as $image_data) {
708
+			    		$temp_room['gallery'][] = $this->attach_image($image_data, $id, $found_attachments);
709 709
 			    	}
710 710
 				}
711 711
 				$rooms[] = $temp_room;
712 712
 			}
713 713
 
714
-			if(false !== $id && '0' !== $id){
714
+			if (false !== $id && '0' !== $id) {
715 715
 				delete_post_meta($id, 'units');				
716 716
 			}
717
-			foreach($rooms as $room){
718
-		        add_post_meta($id,'units',$room,false);			
717
+			foreach ($rooms as $room) {
718
+		        add_post_meta($id, 'units', $room, false);			
719 719
 			}
720 720
 
721
-			if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){
721
+			if (isset($data[0]['features']) && isset($data[0]['features']['rooms'])) {
722 722
 				$room_count = $data[0]['features']['rooms'];
723
-			}else{
723
+			}else {
724 724
 				$room_count = count($data[0]['rooms']);
725 725
 			}
726 726
 
727
-			if(false !== $id && '0' !== $id){
728
-	        	$prev_rooms = get_post_meta($id,'number_of_rooms',true);
729
-	        	update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
730
-	        }else{
731
-	        	add_post_meta($id,'number_of_rooms',$room_count,true);
727
+			if (false !== $id && '0' !== $id) {
728
+	        	$prev_rooms = get_post_meta($id, 'number_of_rooms', true);
729
+	        	update_post_meta($id, 'number_of_rooms', $room_count, $prev_rooms);
730
+	        }else {
731
+	        	add_post_meta($id, 'number_of_rooms', $room_count, true);
732 732
 	        }
733 733
 		}
734 734
 	}
@@ -736,31 +736,31 @@  discard block
 block discarded – undo
736 736
 	/**
737 737
 	 * Set the ratings
738 738
 	 */
739
-	public function set_rating($data,$id) {
739
+	public function set_rating($data, $id) {
740 740
 
741
-		if(!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])){
741
+		if (!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])) {
742 742
 			$rating_type = $data[0]['features']['star_authority'];	
743
-		}else{
743
+		}else {
744 744
 			$rating_type = 'Unspecified2';
745 745
 		}
746
-		$this->save_custom_field($rating_type,'rating_type',$id);
746
+		$this->save_custom_field($rating_type, 'rating_type', $id);
747 747
 
748
-		if(!empty($data[0]['features']) && isset($data[0]['features']['stars'])){
749
-			$this->save_custom_field($data[0]['features']['stars'],'rating',$id,true);	
748
+		if (!empty($data[0]['features']) && isset($data[0]['features']['stars'])) {
749
+			$this->save_custom_field($data[0]['features']['stars'], 'rating', $id, true);	
750 750
 		}
751 751
 	}
752 752
 
753 753
 	/**
754 754
 	 * Set the spoken_languages
755 755
 	 */
756
-	public function set_spoken_languages($data,$id) {
757
-		if(!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])){
756
+	public function set_spoken_languages($data, $id) {
757
+		if (!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])) {
758 758
 			$languages = false;
759
-			foreach($data[0]['features']['spoken_languages'] as $spoken_language){
759
+			foreach ($data[0]['features']['spoken_languages'] as $spoken_language) {
760 760
 				$languages[] = sanitize_title($spoken_language);
761 761
 			}
762
-			if(false !== $languages){
763
-				$this->save_custom_field($languages,'spoken_languages',$id);
762
+			if (false !== $languages) {
763
+				$this->save_custom_field($languages, 'spoken_languages', $id);
764 764
 			}
765 765
 		}
766 766
 	}
@@ -768,14 +768,14 @@  discard block
 block discarded – undo
768 768
 	/**
769 769
 	 * Set the friendly
770 770
 	 */
771
-	public function set_friendly($data,$id) {
772
-		if(!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])){
771
+	public function set_friendly($data, $id) {
772
+		if (!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])) {
773 773
 			$friendly_options = false;
774
-			foreach($data[0]['features']['suggested_visitor_types'] as $visitor_type){
774
+			foreach ($data[0]['features']['suggested_visitor_types'] as $visitor_type) {
775 775
 				$friendly_options[] = sanitize_title($visitor_type);
776 776
 			}
777
-			if(false !== $friendly_options){
778
-				$this->save_custom_field($friendly_options,'suggested_visitor_types',$id);
777
+			if (false !== $friendly_options) {
778
+				$this->save_custom_field($friendly_options, 'suggested_visitor_types', $id);
779 779
 			}
780 780
 		}		
781 781
 	}
@@ -783,14 +783,14 @@  discard block
 block discarded – undo
783 783
 	/**
784 784
 	 * Set the special interests
785 785
 	 */
786
-	public function set_special_interests($data,$id) {
787
-		if(!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])){
786
+	public function set_special_interests($data, $id) {
787
+		if (!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])) {
788 788
 			$interests = false;
789
-			foreach($data[0]['features']['special_interests'] as $special_interest){
789
+			foreach ($data[0]['features']['special_interests'] as $special_interest) {
790 790
 				$interests[] = sanitize_title($special_interest);
791 791
 			}
792
-			if(false !== $interests){
793
-				$this->save_custom_field($interests,'special_interests',$id);
792
+			if (false !== $interests) {
793
+				$this->save_custom_field($interests, 'special_interests', $id);
794 794
 			}
795 795
 		}		
796 796
 	}				
@@ -798,24 +798,24 @@  discard block
 block discarded – undo
798 798
 	/**
799 799
 	 * Set the Check in and Check out Date
800 800
 	 */
801
-	public function set_checkin_checkout($data,$id) {
801
+	public function set_checkin_checkout($data, $id) {
802 802
 
803
-		if(!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])){
804
-			$time = str_replace('h',':',$data[0]['features']['check_in_time']);
805
-			$time = date('h:ia',strtotime($time));
806
-			$this->save_custom_field($time,'checkin_time',$id);
803
+		if (!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])) {
804
+			$time = str_replace('h', ':', $data[0]['features']['check_in_time']);
805
+			$time = date('h:ia', strtotime($time));
806
+			$this->save_custom_field($time, 'checkin_time', $id);
807 807
 		}
808
-		if(!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])){
809
-			$time = str_replace('h',':',$data[0]['features']['check_out_time']);
810
-			$time = date('h:ia',strtotime($time));
811
-			$this->save_custom_field($time,'checkout_time',$id);
808
+		if (!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])) {
809
+			$time = str_replace('h', ':', $data[0]['features']['check_out_time']);
810
+			$time = date('h:ia', strtotime($time));
811
+			$this->save_custom_field($time, 'checkout_time', $id);
812 812
 		}
813 813
 	}	
814 814
 
815 815
 	/**
816 816
 	 * Set the Facilities
817 817
 	 */
818
-	public function set_facilities($data,$id) {
818
+	public function set_facilities($data, $id) {
819 819
 
820 820
 		$parent_facilities = array(
821 821
 			'available_services' => 'Available Services',
@@ -823,13 +823,13 @@  discard block
 block discarded – undo
823 823
 			'room_facilities' => 'Room Facilities',
824 824
 			'activities_on_site' => 'Activities on Site'
825 825
 		);
826
-		foreach($parent_facilities as $key => $label){
826
+		foreach ($parent_facilities as $key => $label) {
827 827
 			$terms = false;
828
-			if(isset($data[0]['features']) && isset($data[0]['features'][$key])){
829
-				$parent_id = $this->set_term($id,$label,'facility');	
828
+			if (isset($data[0]['features']) && isset($data[0]['features'][$key])) {
829
+				$parent_id = $this->set_term($id, $label, 'facility');	
830 830
 			}
831
-			foreach($data[0]['features'][$key] as $child_facility){
832
-				$this->set_term($id,$child_facility,'facility',$parent_id);
831
+			foreach ($data[0]['features'][$key] as $child_facility) {
832
+				$this->set_term($id, $child_facility, 'facility', $parent_id);
833 833
 			}
834 834
 		}
835 835
 	}
Please login to merge, or discard this patch.
classes/class-destination.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -469,12 +469,12 @@
 block discarded – undo
469 469
 					$this->remove_from_queue($return);
470 470
 					$this->format_completed_row($return);
471 471
 				}else{
472
-				    if(isset($adata['error'])){
473
-				        $this->format_error($adata['error']);
474
-                    }else{
472
+					if(isset($adata['error'])){
473
+						$this->format_error($adata['error']);
474
+					}else{
475 475
 						$this->format_error(esc_html__('There was a problem importing your destination.','wet-importer'));
476
-                    }
477
-                }
476
+					}
477
+				}
478 478
 			}
479 479
 		}
480 480
 	}
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		//	$this->url    = 'https://wetu.com/API/Pins/';
79 79
 		//	$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
80 80
 		//} elseif ( false !== $this->api_key ) {
81
-		$this->url = 'https://wetu.com/API/Pins/' . $this->api_key;
81
+		$this->url = 'https://wetu.com/API/Pins/'.$this->api_key;
82 82
 		$this->url_qs = '';
83 83
 		//}
84 84
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 
323 323
 				if (isset($_POST['keyword'])) {
324 324
 					$keyphrases = $_POST['keyword'];
325
-				} else {
325
+				}else {
326 326
 					$keyphrases = array(0);
327 327
 				}
328 328
 
@@ -354,10 +354,10 @@  discard block
 block discarded – undo
354 354
 					foreach ($destination as $row) {
355 355
 
356 356
 						//If we are searching for
357
-						if('import' === $post_status) {
358
-							if(is_array($this->queued_imports) && in_array($row->post_id,$this->queued_imports)){
359
-								$searched_items[sanitize_title($row->name) . '-' . $row->meta_value] = $this->format_row($row);
360
-							}else{
357
+						if ('import' === $post_status) {
358
+							if (is_array($this->queued_imports) && in_array($row->post_id, $this->queued_imports)) {
359
+								$searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
360
+							}else {
361 361
 								continue;
362 362
 							}
363 363
 						}else if (false !== $post_status) {
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
 							if ($current_status !== $post_status) {
367 367
 								continue;
368 368
 							}
369
-							$searched_items[sanitize_title($row->name) . '-' . $row->meta_value] = $this->format_row($row);
369
+							$searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
370 370
 
371 371
 
372
-						} else {
372
+						}else {
373 373
 							//Search through each keyword.
374 374
 							foreach ($keyphrases as $keyphrase) {
375 375
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 								}
381 381
 
382 382
 								if ($this->multineedle_stripos(ltrim(rtrim($row->name)), $keywords) !== false) {
383
-									$searched_items[sanitize_title($row->name) . '-' . $row->meta_value] = $this->format_row($row);
383
+									$searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
384 384
 								}
385 385
 							}
386 386
 						}
@@ -406,23 +406,23 @@  discard block
 block discarded – undo
406 406
 
407 407
 			$status = 'import';
408 408
 			if (0 !== $row->post_id) {
409
-				$status = '<a href="' . admin_url('/post.php?post=' . $row->post_id . '&action=edit') . '" target="_blank">' . get_post_status($row->post_id) . '</a>';
409
+				$status = '<a href="'.admin_url('/post.php?post='.$row->post_id.'&action=edit').'" target="_blank">'.get_post_status($row->post_id).'</a>';
410 410
 			}
411 411
 
412 412
 			$row_html = '
413
-			<tr class="post-' . $row->post_id . ' type-tour" id="post-' . $row->post_id . '">
413
+			<tr class="post-' . $row->post_id.' type-tour" id="post-'.$row->post_id.'">
414 414
 				<th class="check-column" scope="row">
415
-					<label for="cb-select-' . $row->meta_value . '" class="screen-reader-text">' . $row->name . '</label>
416
-					<input type="checkbox" data-identifier="' . $row->meta_value . '" value="' . $row->post_id . '" name="post[]" id="cb-select-' . $row->meta_value . '">
415
+					<label for="cb-select-' . $row->meta_value.'" class="screen-reader-text">'.$row->name.'</label>
416
+					<input type="checkbox" data-identifier="' . $row->meta_value.'" value="'.$row->post_id.'" name="post[]" id="cb-select-'.$row->meta_value.'">
417 417
 				</th>
418 418
 				<td class="post-title page-title column-title">
419
-					<strong>' . $row->name . '</strong> - ' . $status . '
419
+					<strong>' . $row->name.'</strong> - '.$status.'
420 420
 				</td>
421 421
 				<td class="date column-date">
422
-					<abbr title="' . date('Y/m/d', strtotime($row->last_modified)) . '">' . date('Y/m/d', strtotime($row->last_modified)) . '</abbr><br>Last Modified
422
+					<abbr title="' . date('Y/m/d', strtotime($row->last_modified)).'">'.date('Y/m/d', strtotime($row->last_modified)).'</abbr><br>Last Modified
423 423
 				</td>
424 424
 				<td class="ssid column-ssid">
425
-					' . $row->meta_value . '
425
+					' . $row->meta_value.'
426 426
 				</td>
427 427
 			</tr>';
428 428
 			return $row_html;
@@ -440,13 +440,13 @@  discard block
 block discarded – undo
440 440
 			$wetu_id = $_POST['wetu_id'];
441 441
 			if (isset($_POST['post_id'])) {
442 442
 				$post_id = $_POST['post_id'];
443
-			} else {
443
+			}else {
444 444
 				$post_id = 0;
445 445
 			}
446 446
 
447 447
 			if (isset($_POST['team_members'])) {
448 448
 				$team_members = $_POST['team_members'];
449
-			} else {
449
+			}else {
450 450
 				$team_members = false;
451 451
 			}
452 452
 
@@ -456,11 +456,11 @@  discard block
 block discarded – undo
456 456
 			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
457 457
 				$content = $_POST['content'];
458 458
 				add_option('wetu_importer_destination_settings', $content);
459
-			} else {
459
+			}else {
460 460
 				$content = false;
461 461
 			}
462 462
 
463
-			$jdata = file_get_contents($this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id);
463
+			$jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
464 464
 			if ($jdata) {
465 465
 				$adata = json_decode($jdata, true);
466 466
 
@@ -468,11 +468,11 @@  discard block
 block discarded – undo
468 468
 					$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
469 469
 					$this->remove_from_queue($return);
470 470
 					$this->format_completed_row($return);
471
-				}else{
472
-				    if(isset($adata['error'])){
471
+				}else {
472
+				    if (isset($adata['error'])) {
473 473
 				        $this->format_error($adata['error']);
474
-                    }else{
475
-						$this->format_error(esc_html__('There was a problem importing your destination.','wet-importer'));
474
+                    }else {
475
+						$this->format_error(esc_html__('There was a problem importing your destination.', 'wet-importer'));
476 476
                     }
477 477
                 }
478 478
 			}
@@ -485,11 +485,11 @@  discard block
 block discarded – undo
485 485
 	public function remove_from_queue($id) {
486 486
 		if (!empty($this->queued_imports)) {
487 487
 
488
-			if(($key = array_search($id, $this->queued_imports)) !== false) {
488
+			if (($key = array_search($id, $this->queued_imports)) !== false) {
489 489
 				unset($this->queued_imports[$key]);
490 490
 
491 491
 				delete_option('wetu_importer_que');
492
-				update_option('wetu_importer_que',$this->queued_imports);
492
+				update_option('wetu_importer_que', $this->queued_imports);
493 493
 			}
494 494
 		}
495 495
 	}
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 				$id = wp_update_post($post);
545 545
 				$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
546 546
 				update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
547
-			} else {
547
+			}else {
548 548
 
549 549
 				//Set the name
550 550
 				if (isset($data[0]['name'])) {
@@ -646,9 +646,9 @@  discard block
 block discarded – undo
646 646
 	public function set_team_member($id, $team_members)
647 647
 	{
648 648
 
649
-		delete_post_meta($id, 'team_to_' . $this->tab_slug);
649
+		delete_post_meta($id, 'team_to_'.$this->tab_slug);
650 650
 		foreach ($team_members as $team) {
651
-			add_post_meta($id, 'team_to_' . $this->tab_slug, $team);
651
+			add_post_meta($id, 'team_to_'.$this->tab_slug, $team);
652 652
 		}
653 653
 	}
654 654
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -357,10 +357,10 @@  discard block
 block discarded – undo
357 357
 						if('import' === $post_status) {
358 358
 							if(is_array($this->queued_imports) && in_array($row->post_id,$this->queued_imports)){
359 359
 								$searched_items[sanitize_title($row->name) . '-' . $row->meta_value] = $this->format_row($row);
360
-							}else{
360
+							} else{
361 361
 								continue;
362 362
 							}
363
-						}else if (false !== $post_status) {
363
+						} else if (false !== $post_status) {
364 364
 
365 365
 							$current_status = get_post_status($row->post_id);
366 366
 							if ($current_status !== $post_status) {
@@ -468,10 +468,10 @@  discard block
 block discarded – undo
468 468
 					$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
469 469
 					$this->remove_from_queue($return);
470 470
 					$this->format_completed_row($return);
471
-				}else{
471
+				} else{
472 472
 				    if(isset($adata['error'])){
473 473
 				        $this->format_error($adata['error']);
474
-                    }else{
474
+                    } else{
475 475
 						$this->format_error(esc_html__('There was a problem importing your destination.','wet-importer'));
476 476
                     }
477 477
                 }
Please login to merge, or discard this patch.
classes/class-importer.php 3 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -210,15 +210,15 @@  discard block
 block discarded – undo
210 210
 			$this->api_username = false;
211 211
 			$this->api_password = false;
212 212
 
213
-            if (isset($temp_options['api']['wetu_api_key']) && '' !== $temp_options['api']['wetu_api_key']) {
214
-                $this->api_key = $temp_options['api']['wetu_api_key'];
215
-            }
216
-            if (isset($temp_options['api']['wetu_api_username']) && '' !== $temp_options['api']['wetu_api_username']) {
217
-                $this->api_username = $temp_options['api']['wetu_api_username'];
218
-            }
219
-            if (isset($temp_options['api']['wetu_api_password']) && '' !== $temp_options['api']['wetu_api_password']) {
220
-                $this->api_password = $temp_options['api']['wetu_api_password'];
221
-            }
213
+			if (isset($temp_options['api']['wetu_api_key']) && '' !== $temp_options['api']['wetu_api_key']) {
214
+				$this->api_key = $temp_options['api']['wetu_api_key'];
215
+			}
216
+			if (isset($temp_options['api']['wetu_api_username']) && '' !== $temp_options['api']['wetu_api_username']) {
217
+				$this->api_username = $temp_options['api']['wetu_api_username'];
218
+			}
219
+			if (isset($temp_options['api']['wetu_api_password']) && '' !== $temp_options['api']['wetu_api_password']) {
220
+				$this->api_password = $temp_options['api']['wetu_api_password'];
221
+			}
222 222
 
223 223
 			//Set the tab slug
224 224
 			if(isset($_GET['tab']) || isset($_POST['type'])) {
@@ -234,22 +234,22 @@  discard block
 block discarded – undo
234 234
 			}
235 235
 
236 236
 			//Set the scaling options
237
-            if (isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug]) && isset($this->options['image_scaling'])) {
238
-                $this->scale_images = true;
239
-                $width = '800';
240
-                if (isset($this->options['width']) && '' !== $this->options['width']) {
241
-                    $width = $this->options['width'];
242
-                }
243
-                $height = '600';
244
-                if (isset($this->options['height']) && '' !== $this->options['height']) {
245
-                    $height = $this->options['height'];
246
-                }
247
-                $cropping = 'raw';
248
-                if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
249
-                    $cropping = $this->options['cropping'];
250
-                }
251
-                $this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
252
-            }
237
+			if (isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug]) && isset($this->options['image_scaling'])) {
238
+				$this->scale_images = true;
239
+				$width = '800';
240
+				if (isset($this->options['width']) && '' !== $this->options['width']) {
241
+					$width = $this->options['width'];
242
+				}
243
+				$height = '600';
244
+				if (isset($this->options['height']) && '' !== $this->options['height']) {
245
+					$height = $this->options['height'];
246
+				}
247
+				$cropping = 'raw';
248
+				if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
249
+					$cropping = $this->options['cropping'];
250
+				}
251
+				$this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
252
+			}
253 253
 
254 254
 		}
255 255
 	}
@@ -323,10 +323,10 @@  discard block
 block discarded – undo
323 323
 
324 324
 	// DISPLAY FUNCTIONS
325 325
 
326
-    /*
326
+	/*
327 327
      * Load the importer class you want to use
328 328
      */
329
-    public function load_class(){
329
+	public function load_class(){
330 330
 
331 331
 		switch($this->tab_slug){
332 332
 			case 'accommodation':
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 				break;
347 347
 		}
348 348
 
349
-    }
349
+	}
350 350
 
351 351
 	/**
352 352
 	 * Registers the admin page which will house the importer form.
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 				<?php*/
403 403
 			}else{
404 404
 			   $this->current_importer->display_page();
405
-            }; ?>
405
+			}; ?>
406 406
         </div>
407 407
 		<?php
408 408
 	}
@@ -802,12 +802,12 @@  discard block
 block discarded – undo
802 802
 	 */
803 803
 	public function set_featured_image($data,$id) {
804 804
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
805
-		    if('tour' === $this->tab_slug){
806
-		        $key = array_rand($data[0]['content']['images']);
807
-                $this->featured_image = $this->attach_image($data[0]['content']['images'][$key],$id);
808
-            }else{
805
+			if('tour' === $this->tab_slug){
806
+				$key = array_rand($data[0]['content']['images']);
807
+				$this->featured_image = $this->attach_image($data[0]['content']['images'][$key],$id);
808
+			}else{
809 809
 				$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
810
-            }
810
+			}
811 811
 
812 812
 
813 813
 			if(false !== $this->featured_image){
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 	 */
828 828
 	public function set_banner_image($data,$id) {
829 829
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
830
-		    if(isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) {
830
+			if(isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) {
831 831
 				$temp_banner = $this->attach_image($data[0]['destination_image'], $id, array('width' => '1920', 'height' => '600', 'cropping' => 'c'));
832 832
 			}else{
833 833
 				if ('tour' === $this->tab_slug) {
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 				} else {
837 837
 					$temp_banner = $this->attach_image($data[0]['content']['images'][1], $id, array('width' => '1920', 'height' => '600', 'cropping' => 'c'));
838 838
 				}
839
-            }
839
+			}
840 840
 
841 841
 
842 842
 			if(false !== $temp_banner){
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
 	 * Run through the accommodation grabbed from the DB.
1049 1049
 	 */
1050 1050
 	public function process_ajax_search() {
1051
-	    $this->current_importer->process_ajax_search();
1051
+		$this->current_importer->process_ajax_search();
1052 1052
 		die();
1053 1053
 	}
1054 1054
 
Please login to merge, or discard this patch.
Spacing   +257 added lines, -257 removed lines patch added patch discarded remove patch
@@ -156,31 +156,31 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	public function __construct() {
158 158
 
159
-		add_action( 'admin_init', array( $this, 'compatible_version_check' ) );
159
+		add_action('admin_init', array($this, 'compatible_version_check'));
160 160
 
161 161
 		// Don't run anything else in the plugin, if we're on an incompatible PHP version
162
-		if ( ! self::compatible_version() ) {
162
+		if (!self::compatible_version()) {
163 163
 			return;
164 164
 		}
165 165
 
166 166
 		$this->set_variables();
167 167
 
168
-		add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
169
-		add_action( 'admin_enqueue_scripts', array($this,'admin_scripts') ,11 );
170
-		add_action( 'admin_menu', array( $this, 'register_importer_page' ),20 );
168
+		add_action('init', array($this, 'load_plugin_textdomain'));
169
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts'), 11);
170
+		add_action('admin_menu', array($this, 'register_importer_page'), 20);
171 171
 
172 172
 		require_once(WETU_IMPORTER_PATH.'classes/class-accommodation.php');
173 173
 		require_once(WETU_IMPORTER_PATH.'classes/class-destination.php');
174 174
 		require_once(WETU_IMPORTER_PATH.'classes/class-tours.php');
175 175
 
176
-		add_action( 'init', array( $this, 'load_class' ) );
176
+		add_action('init', array($this, 'load_class'));
177 177
 
178
-		if('default' !== $this->tab_slug){
179
-			add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search'));
180
-			add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search'));
178
+		if ('default' !== $this->tab_slug) {
179
+			add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search'));
180
+			add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search'));
181 181
 
182
-			add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import'));
183
-			add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import'));
182
+			add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import'));
183
+			add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import'));
184 184
 		}
185 185
 	}
186 186
 
@@ -192,18 +192,18 @@  discard block
 block discarded – undo
192 192
 	 * @since 1.0.0
193 193
 	 */
194 194
 	public function load_plugin_textdomain() {
195
-		load_plugin_textdomain( 'wetu-importer', FALSE, basename( WETU_IMPORTER_PATH ) . '/languages');
195
+		load_plugin_textdomain('wetu-importer', FALSE, basename(WETU_IMPORTER_PATH).'/languages');
196 196
 	}
197 197
 
198 198
 	/**
199 199
 	 * Sets the variables used throughout the plugin.
200 200
 	 */
201 201
 	public function set_variables() {
202
-		$this->post_types = array('accommodation','destination','tour');
203
-		$temp_options = get_option('_lsx-to_settings',false);
202
+		$this->post_types = array('accommodation', 'destination', 'tour');
203
+		$temp_options = get_option('_lsx-to_settings', false);
204 204
 
205 205
 		//Set the options.
206
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug])) {
206
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug])) {
207 207
 			$this->options = $temp_options[$this->plugin_slug];
208 208
 
209 209
 			$this->api_key = false;
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
             }
222 222
 
223 223
 			//Set the tab slug
224
-			if(isset($_GET['tab']) || isset($_POST['type'])) {
224
+			if (isset($_GET['tab']) || isset($_POST['type'])) {
225 225
 				if (isset($_GET['tab'])) {
226 226
 					$this->tab_slug = $_GET['tab'];
227
-				} else {
227
+				}else {
228 228
 					$this->tab_slug = $_POST['type'];
229 229
 				}
230 230
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
                 if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
249 249
                     $cropping = $this->options['cropping'];
250 250
                 }
251
-                $this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
251
+                $this->image_scaling_url = 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/';
252 252
             }
253 253
 
254 254
 		}
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 * @since 1.0.0
272 272
 	 */
273 273
 	public static function compatible_version() {
274
-		if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
274
+		if (version_compare(PHP_VERSION, '5.6', '<')) {
275 275
 			return false;
276 276
 		}
277 277
 
@@ -285,13 +285,13 @@  discard block
 block discarded – undo
285 285
 	 * @since 1.0.0
286 286
 	 */
287 287
 	public function compatible_version_check() {
288
-		if ( ! self::compatible_version() ) {
289
-			if ( is_plugin_active( plugin_basename( WETU_IMPORTER_CORE ) ) ) {
290
-				deactivate_plugins( plugin_basename( WETU_IMPORTER_CORE ) );
291
-				add_action( 'admin_notices', array( $this, 'compatible_version_notice' ) );
288
+		if (!self::compatible_version()) {
289
+			if (is_plugin_active(plugin_basename(WETU_IMPORTER_CORE))) {
290
+				deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE));
291
+				add_action('admin_notices', array($this, 'compatible_version_notice'));
292 292
 				
293
-				if ( isset( $_GET['activate'] ) ) {
294
-					unset( $_GET['activate'] );
293
+				if (isset($_GET['activate'])) {
294
+					unset($_GET['activate']);
295 295
 				}
296 296
 			}
297 297
 		}
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
 	 */
305 305
 	public function compatible_version_notice() {
306 306
 		$class = 'notice notice-error';
307
-		$message = esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' );
308
-		printf( '<div class="%1$s"><p>%2$s</p></div>', esc_html( $class ), esc_html( $message ) );
307
+		$message = esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer');
308
+		printf('<div class="%1$s"><p>%2$s</p></div>', esc_html($class), esc_html($message));
309 309
 	}
310 310
 	
311 311
 	/**
@@ -315,9 +315,9 @@  discard block
 block discarded – undo
315 315
 	 * @since 1.0.0
316 316
 	 */
317 317
 	public static function compatible_version_check_on_activation() {
318
-		if ( ! self::compatible_version() ) {
319
-			deactivate_plugins( plugin_basename( WETU_IMPORTER_CORE ) );
320
-			wp_die( esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' ) );
318
+		if (!self::compatible_version()) {
319
+			deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE));
320
+			wp_die(esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer'));
321 321
 		}
322 322
 	}
323 323
 
@@ -326,9 +326,9 @@  discard block
 block discarded – undo
326 326
     /*
327 327
      * Load the importer class you want to use
328 328
      */
329
-    public function load_class(){
329
+    public function load_class() {
330 330
 
331
-		switch($this->tab_slug){
331
+		switch ($this->tab_slug) {
332 332
 			case 'accommodation':
333 333
 				$this->current_importer = new WETU_Importer_Accommodation();
334 334
 				break;
@@ -352,25 +352,25 @@  discard block
 block discarded – undo
352 352
 	 * Registers the admin page which will house the importer form.
353 353
 	 */
354 354
 	public function register_importer_page() {
355
-		add_submenu_page( 'tour-operator',esc_html__( 'Importer', 'tour-operator' ), esc_html__( 'Importer', 'tour-operator' ), 'manage_options', 'wetu-importer', array( $this, 'display_page' ) );
355
+		add_submenu_page('tour-operator', esc_html__('Importer', 'tour-operator'), esc_html__('Importer', 'tour-operator'), 'manage_options', 'wetu-importer', array($this, 'display_page'));
356 356
 	}
357 357
 
358 358
 	/**
359 359
 	 * Enqueue the JS needed to contact wetu and return your result.
360 360
 	 */
361 361
 	public function admin_scripts() {
362
-		if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) {
362
+		if (defined('WP_DEBUG') && true === WP_DEBUG) {
363 363
 			$min = '';
364
-		} else {
364
+		}else {
365 365
 			$min = '.min';
366 366
 		}
367 367
 		$min = '';
368 368
 
369
-		if(is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']){
370
-			wp_enqueue_script( 'wetu-importers-script', WETU_IMPORTER_URL . 'assets/js/wetu-importer' . $min . '.js', array( 'jquery' ), WETU_IMPORTER_VER, true );
371
-			wp_localize_script( 'wetu-importers-script', 'lsx_tour_importer_params', array(
369
+		if (is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']) {
370
+			wp_enqueue_script('wetu-importers-script', WETU_IMPORTER_URL.'assets/js/wetu-importer'.$min.'.js', array('jquery'), WETU_IMPORTER_VER, true);
371
+			wp_localize_script('wetu-importers-script', 'lsx_tour_importer_params', array(
372 372
 				'ajax_url' => admin_url('admin-ajax.php'),
373
-			) );
373
+			));
374 374
 		}
375 375
 	}
376 376
 
@@ -382,14 +382,14 @@  discard block
 block discarded – undo
382 382
         <div class="wrap">
383 383
 			<?php screen_icon(); ?>
384 384
 
385
-			<?php if(!is_object($this->current_importer)){
385
+			<?php if (!is_object($this->current_importer)) {
386 386
 				?>
387
-                <h2><?php _e('Welcome to the LSX Wetu Importer','wetu-importer'); ?></h2>
387
+                <h2><?php _e('Welcome to the LSX Wetu Importer', 'wetu-importer'); ?></h2>
388 388
                 <p>If this is the first time you are running the import, then follow the steps below.</p>
389 389
                 <ul>
390
-                    <li>Step 1 - Import your <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=tour"><?php _e('Tours','wetu-importer'); ?></a></li>
391
-                    <li>Step 2 - The tour import will have created draft <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation','wetu-importer'); ?></a> that will need to be imported.</li>
392
-                    <li>Step 3 - Lastly import the <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations','wetu-importer'); ?></a> draft posts created during the previous two steps.</li>
390
+                    <li>Step 1 - Import your <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=tour"><?php _e('Tours', 'wetu-importer'); ?></a></li>
391
+                    <li>Step 2 - The tour import will have created draft <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation', 'wetu-importer'); ?></a> that will need to be imported.</li>
392
+                    <li>Step 3 - Lastly import the <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations', 'wetu-importer'); ?></a> draft posts created during the previous two steps.</li>
393 393
                 </ul>
394 394
 
395 395
                 <?php /*<h3><?php _e('Additional Tools','wetu-importer'); ?></h3>
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 					<?php } ?>
401 401
                 </ul>
402 402
 				<?php*/
403
-			}else{
403
+			}else {
404 404
 			   $this->current_importer->display_page();
405 405
             }; ?>
406 406
         </div>
@@ -415,38 +415,38 @@  discard block
 block discarded – undo
415 415
         <form class="ajax-form" id="<?php echo $this->plugin_slug; ?>-search-form" method="get" action="tools.php" data-type="<?php echo $this->tab_slug; ?>">
416 416
             <input type="hidden" name="page" value="<?php echo $this->tab_slug; ?>" />
417 417
 
418
-            <h3><span class="dashicons dashicons-search"></span> <?php _e('Search','wetu-importer'); ?></h3>
418
+            <h3><span class="dashicons dashicons-search"></span> <?php _e('Search', 'wetu-importer'); ?></h3>
419 419
 
420
-			<?php do_action('wetu_importer_search_form',$this); ?>
420
+			<?php do_action('wetu_importer_search_form', $this); ?>
421 421
 
422 422
             <div class="normal-search">
423
-                <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" />
423
+                <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" />
424 424
             </div>
425 425
             <div class="advanced-search hidden" style="display:none;">
426
-                <p><?php _e('Enter several keywords, each on a new line.','wetu-importer'); ?></p>
426
+                <p><?php _e('Enter several keywords, each on a new line.', 'wetu-importer'); ?></p>
427 427
                 <textarea rows="10" cols="40" name="bulk-keywords"></textarea>
428
-                <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" />
428
+                <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" />
429 429
             </div>
430 430
 
431 431
             <p>
432
-                <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search','wetu-importer'); ?></a> |
433
-                <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published','wetu-importer'); ?></a> |
434
-                <a class="pending search-toggle"  href="#pending"><?php esc_attr_e('Pending','wetu-importer'); ?></a> |
435
-                <a class="draft search-toggle"  href="#draft"><?php esc_attr_e('Draft','wetu-importer'); ?></a>
436
-
437
-                <?php if('tour'===$this->tab_slug){ ?>
438
-                    | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU','wetu-importer'); ?></a>
439
-                <?php }else if(!empty($this->queued_imports)) { ?>
440
-                    | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU Queue','wetu-importer'); ?></a>
432
+                <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search', 'wetu-importer'); ?></a> |
433
+                <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published', 'wetu-importer'); ?></a> |
434
+                <a class="pending search-toggle"  href="#pending"><?php esc_attr_e('Pending', 'wetu-importer'); ?></a> |
435
+                <a class="draft search-toggle"  href="#draft"><?php esc_attr_e('Draft', 'wetu-importer'); ?></a>
436
+
437
+                <?php if ('tour' === $this->tab_slug) { ?>
438
+                    | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU', 'wetu-importer'); ?></a>
439
+                <?php }else if (!empty($this->queued_imports)) { ?>
440
+                    | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU Queue', 'wetu-importer'); ?></a>
441 441
                 <?php } ?>
442 442
             </p>
443 443
 
444 444
             <div class="ajax-loader" style="display:none;width:100%;text-align:center;">
445
-                <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
445
+                <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
446 446
             </div>
447 447
 
448 448
             <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
449
-                <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
449
+                <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
450 450
             </div>
451 451
         </form> 
452 452
 		<?php
@@ -495,15 +495,15 @@  discard block
 block discarded – undo
495 495
 	 *
496 496
 	 * @param $tab string
497 497
 	 */
498
-	public function navigation($tab='') {
498
+	public function navigation($tab = '') {
499 499
 		$post_types = array(
500
-			'tour'              => esc_attr('Tours','wetu-importer'),
501
-			'accommodation'     => esc_attr('Accommodation','wetu-importer'),
502
-			'destination'       => esc_attr('Destinations','wetu-importer'),
500
+			'tour'              => esc_attr('Tours', 'wetu-importer'),
501
+			'accommodation'     => esc_attr('Accommodation', 'wetu-importer'),
502
+			'destination'       => esc_attr('Destinations', 'wetu-importer'),
503 503
 		);
504
-		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>';
505
-		foreach($post_types as $post_type => $label){
506
-			echo ' | <a class="'.$this->itemd($tab,$post_type,'current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>';
504
+		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>';
505
+		foreach ($post_types as $post_type => $label) {
506
+			echo ' | <a class="'.$this->itemd($tab, $post_type, 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>';
507 507
 		}
508 508
 		echo '</div><br clear="both"/></div>';
509 509
 	}
@@ -511,23 +511,23 @@  discard block
 block discarded – undo
511 511
 	/**
512 512
 	 * set_taxonomy with some terms
513 513
 	 */
514
-	public function team_member_checkboxes($selected=array()) {
515
-		if(post_type_exists('team')) { ?>
514
+	public function team_member_checkboxes($selected = array()) {
515
+		if (post_type_exists('team')) { ?>
516 516
             <ul>
517 517
 				<?php
518
-				$team_args=array(
518
+				$team_args = array(
519 519
 					'post_type'	=>	'team',
520 520
 					'post_status' => 'publish',
521 521
 					'nopagin' => true,
522 522
 					'fields' => 'ids'
523 523
 				);
524 524
 				$team_members = new WP_Query($team_args);
525
-				if($team_members->have_posts()){
526
-					foreach($team_members->posts as $member){ ?>
527
-                        <li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
525
+				if ($team_members->have_posts()) {
526
+					foreach ($team_members->posts as $member) { ?>
527
+                        <li><input class="team" <?php $this->checked($selected, $member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
528 528
 					<?php }
529
-				}else{ ?>
530
-                    <li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
529
+				}else { ?>
530
+                    <li><input class="team" type="checkbox" value="0" /> <?php _e('None', 'wetu-importer'); ?></li>
531 531
 				<?php }
532 532
 				?>
533 533
             </ul>
@@ -544,12 +544,12 @@  discard block
 block discarded – undo
544 544
 	 * @param $needle string
545 545
 	 * @param $echo bool
546 546
 	 */
547
-	public function checked($haystack=false,$needle='',$echo=true) {
548
-		$return = $this->itemd($haystack,$needle,'checked');
549
-		if('' !== $return) {
547
+	public function checked($haystack = false, $needle = '', $echo = true) {
548
+		$return = $this->itemd($haystack, $needle, 'checked');
549
+		if ('' !== $return) {
550 550
 			if (true === $echo) {
551 551
 				echo $return;
552
-			} else {
552
+			}else {
553 553
 				return $return;
554 554
 			}
555 555
 		}
@@ -562,12 +562,12 @@  discard block
 block discarded – undo
562 562
 	 * @param $needle string
563 563
 	 * @param $echo bool
564 564
 	 */
565
-	public function selected($haystack=false,$needle='',$echo=true) {
566
-		$return = $this->itemd($haystack,$needle,'selected');
567
-		if('' !== $return) {
565
+	public function selected($haystack = false, $needle = '', $echo = true) {
566
+		$return = $this->itemd($haystack, $needle, 'selected');
567
+		if ('' !== $return) {
568 568
 			if (true === $echo) {
569 569
 				echo $return;
570
-			} else {
570
+			}else {
571 571
 				return $return;
572 572
 			}
573 573
 		}
@@ -582,16 +582,16 @@  discard block
 block discarded – undo
582 582
 	 * @param $wrap bool
583 583
 	 * @return $html string
584 584
 	 */
585
-	public function itemd($haystack=false,$needle='',$type='',$wrap=true) {
585
+	public function itemd($haystack = false, $needle = '', $type = '', $wrap = true) {
586 586
 		$html = '';
587
-		if('' !== $type) {
587
+		if ('' !== $type) {
588 588
 			if (!is_array($haystack)) {
589 589
 				$haystack = array($haystack);
590 590
 			}
591 591
 			if (in_array($needle, $haystack)) {
592
-				if(true === $wrap || 'true' === $wrap) {
593
-					$html = $type . '="' . $type . '"';
594
-				}else{
592
+				if (true === $wrap || 'true' === $wrap) {
593
+					$html = $type.'="'.$type.'"';
594
+				}else {
595 595
 					$html = $type;
596 596
 				}
597 597
 			}
@@ -603,9 +603,9 @@  discard block
 block discarded – undo
603 603
 	/**
604 604
 	 * grabs any attachments for the current item
605 605
 	 */
606
-	public function find_attachments($id=false) {
607
-		if(false !== $id){
608
-			if(empty($this->found_attachments)){
606
+	public function find_attachments($id = false) {
607
+		if (false !== $id) {
608
+			if (empty($this->found_attachments)) {
609 609
 
610 610
 				$attachments_args = array(
611 611
 					'post_parent' => $id,
@@ -617,9 +617,9 @@  discard block
 block discarded – undo
617 617
 				);
618 618
 
619 619
 				$attachments = new WP_Query($attachments_args);
620
-				if($attachments->have_posts()){
621
-					foreach($attachments->posts as $attachment){
622
-						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
620
+				if ($attachments->have_posts()) {
621
+					foreach ($attachments->posts as $attachment) {
622
+						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title);
623 623
 						$this->gallery_meta[] = $attachment->ID;
624 624
 					}
625 625
 				}
@@ -633,18 +633,18 @@  discard block
 block discarded – undo
633 633
 	/**
634 634
 	 * Saves the room data
635 635
 	 */
636
-	public function save_custom_field($value=false,$meta_key,$id,$decrease=false,$unique=true) {
637
-		if(false !== $value){
638
-			if(false !== $decrease){
636
+	public function save_custom_field($value = false, $meta_key, $id, $decrease = false, $unique = true) {
637
+		if (false !== $value) {
638
+			if (false !== $decrease) {
639 639
 				$value = intval($value);
640 640
 				$value--;
641 641
 			}
642
-			$prev = get_post_meta($id,$meta_key,true);
642
+			$prev = get_post_meta($id, $meta_key, true);
643 643
 
644
-			if(false !== $id && '0' !== $id && false !== $prev && true === $unique){
645
-				update_post_meta($id,$meta_key,$value,$prev);
646
-			}else{
647
-				add_post_meta($id,$meta_key,$value,$unique);
644
+			if (false !== $id && '0' !== $id && false !== $prev && true === $unique) {
645
+				update_post_meta($id, $meta_key, $value, $prev);
646
+			}else {
647
+				add_post_meta($id, $meta_key, $value, $unique);
648 648
 			}
649 649
 		}
650 650
 	}
@@ -653,12 +653,12 @@  discard block
 block discarded – undo
653 653
 	 * Grabs the custom fields,  and resaves an array of unique items.
654 654
 	 */
655 655
 	public function cleanup_posts() {
656
-		if(!empty($this->cleanup_posts)){
657
-			foreach($this->cleanup_posts as $id => $key) {
656
+		if (!empty($this->cleanup_posts)) {
657
+			foreach ($this->cleanup_posts as $id => $key) {
658 658
 				$prev_items = get_post_meta($id, $key, false);
659 659
 				$new_items = array_unique($prev_items);
660 660
 				delete_post_meta($id, $key);
661
-				foreach($new_items as $new_item) {
661
+				foreach ($new_items as $new_item) {
662 662
 					add_post_meta($id, $key, $new_item, false);
663 663
 				}
664 664
 			}
@@ -670,51 +670,51 @@  discard block
 block discarded – undo
670 670
 	/**
671 671
 	 * set_taxonomy with some terms
672 672
 	 */
673
-	public function set_taxonomy($taxonomy,$terms,$id) {
674
-		$result=array();
675
-		if(!empty($data))
673
+	public function set_taxonomy($taxonomy, $terms, $id) {
674
+		$result = array();
675
+		if (!empty($data))
676 676
 		{
677
-			foreach($data as $k)
677
+			foreach ($data as $k)
678 678
 			{
679
-				if($id)
679
+				if ($id)
680 680
 				{
681
-					if(!$term = term_exists(trim($k), $tax))
681
+					if (!$term = term_exists(trim($k), $tax))
682 682
 					{
683 683
 						$term = wp_insert_term(trim($k), $tax);
684
-						if ( is_wp_error($term) )
684
+						if (is_wp_error($term))
685 685
 						{
686 686
 							echo $term->get_error_message();
687 687
 						}
688 688
 						else
689 689
 						{
690
-							wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
690
+							wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
691 691
 						}
692 692
 					}
693 693
 					else
694 694
 					{
695
-						wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
695
+						wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
696 696
 					}
697 697
 				}
698 698
 				else
699 699
 				{
700
-					$result[]=trim($k);
700
+					$result[] = trim($k);
701 701
 				}
702 702
 			}
703 703
 		}
704 704
 		return $result;
705 705
 	}
706 706
 
707
-	public function set_term($id=false,$name=false,$taxonomy=false,$parent=false){
708
-		if(!$term = term_exists($name, $taxonomy))
707
+	public function set_term($id = false, $name = false, $taxonomy = false, $parent = false) {
708
+		if (!$term = term_exists($name, $taxonomy))
709 709
 		{
710
-			if(false !== $parent){ $parent = array('parent'=>$parent); }
711
-			$term = wp_insert_term(trim($name), $taxonomy,$parent);
712
-			if ( is_wp_error($term) ){echo $term->get_error_message();}
713
-			else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
710
+			if (false !== $parent) { $parent = array('parent'=>$parent); }
711
+			$term = wp_insert_term(trim($name), $taxonomy, $parent);
712
+			if (is_wp_error($term)) {echo $term->get_error_message(); }
713
+			else { wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); }
714 714
 		}
715 715
 		else
716 716
 		{
717
-			wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
717
+			wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
718 718
 		}
719 719
 		return $term['term_id'];
720 720
 	}
@@ -722,18 +722,18 @@  discard block
 block discarded – undo
722 722
 	/**
723 723
 	 * set_taxonomy with some terms
724 724
 	 */
725
-	public function taxonomy_checkboxes($taxonomy=false,$selected=array()) {
725
+	public function taxonomy_checkboxes($taxonomy = false, $selected = array()) {
726 726
 		$return = '';
727
-		if(false !== $taxonomy){
727
+		if (false !== $taxonomy) {
728 728
 			$return .= '<ul>';
729
-			$terms = get_terms(array('taxonomy'=>$taxonomy,'hide_empty'=>false));
729
+			$terms = get_terms(array('taxonomy'=>$taxonomy, 'hide_empty'=>false));
730 730
 
731
-			if(!is_wp_error($terms)){
732
-				foreach($terms as $term){
733
-					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected,$term->term_id,false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
731
+			if (!is_wp_error($terms)) {
732
+				foreach ($terms as $term) {
733
+					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected, $term->term_id, false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
734 734
 				}
735
-			}else{
736
-				$return .= '<li><input type="checkbox" value="" /> '.__('None','wetu-importer').'</li>';
735
+			}else {
736
+				$return .= '<li><input type="checkbox" value="" /> '.__('None', 'wetu-importer').'</li>';
737 737
 			}
738 738
 			$return .= '</ul>';
739 739
 		}
@@ -744,53 +744,53 @@  discard block
 block discarded – undo
744 744
 	/**
745 745
 	 * Saves the longitude and lattitude, as well as sets the map marker.
746 746
 	 */
747
-	public function set_map_data($data,$id,$zoom = '10') {
747
+	public function set_map_data($data, $id, $zoom = '10') {
748 748
 		$longitude = $latitude = $address = false;
749 749
 
750
-		if(isset($data[0]['position'])){
750
+		if (isset($data[0]['position'])) {
751 751
 
752
-			if(isset($data[0]['position']['driving_latitude'])){
752
+			if (isset($data[0]['position']['driving_latitude'])) {
753 753
 				$latitude = $data[0]['position']['driving_latitude'];
754
-			}elseif(isset($data[0]['position']['latitude'])){
754
+			}elseif (isset($data[0]['position']['latitude'])) {
755 755
 				$latitude = $data[0]['position']['latitude'];
756 756
 			}
757 757
 
758
-			if(isset($data[0]['position']['driving_longitude'])){
758
+			if (isset($data[0]['position']['driving_longitude'])) {
759 759
 				$longitude = $data[0]['position']['driving_longitude'];
760
-			}elseif(isset($data[0]['position']['longitude'])){
760
+			}elseif (isset($data[0]['position']['longitude'])) {
761 761
 				$longitude = $data[0]['position']['longitude'];
762 762
 			}
763 763
 
764 764
 		}
765
-		if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){
766
-			if(isset($data[0]['content']['contact_information']['address'])){
765
+		if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) {
766
+			if (isset($data[0]['content']['contact_information']['address'])) {
767 767
 				$address = strip_tags($data[0]['content']['contact_information']['address']);
768 768
 
769
-				$address = explode("\n",$address);
770
-				foreach($address as $bitkey => $bit){
769
+				$address = explode("\n", $address);
770
+				foreach ($address as $bitkey => $bit) {
771 771
 					$bit = ltrim(rtrim($bit));
772
-					if(false === $bit || '' === $bit || null === $bit or empty($bit)){
772
+					if (false === $bit || '' === $bit || null === $bit or empty($bit)) {
773 773
 						unset($address[$bitkey]);
774 774
 					}
775 775
 				}
776
-				$address = implode(', ',$address);
776
+				$address = implode(', ', $address);
777 777
 				$address = str_replace(', , ', ', ', $address);
778 778
 			}
779 779
 		}
780 780
 
781
-		if(false !== $longitude){
781
+		if (false !== $longitude) {
782 782
 			$location_data = array(
783
-				'address'	=>	(string)$address,
784
-				'lat'		=>	(string)$latitude,
785
-				'long'		=>	(string)$longitude,
786
-				'zoom'		=>	(string)$zoom,
783
+				'address'	=>	(string) $address,
784
+				'lat'		=>	(string) $latitude,
785
+				'long'		=>	(string) $longitude,
786
+				'zoom'		=>	(string) $zoom,
787 787
 				'elevation'	=>	'',
788 788
 			);
789
-			if(false !== $id && '0' !== $id){
790
-				$prev = get_post_meta($id,'location',true);
791
-				update_post_meta($id,'location',$location_data,$prev);
792
-			}else{
793
-				add_post_meta($id,'location',$location_data,true);
789
+			if (false !== $id && '0' !== $id) {
790
+				$prev = get_post_meta($id, 'location', true);
791
+				update_post_meta($id, 'location', $location_data, $prev);
792
+			}else {
793
+				add_post_meta($id, 'location', $location_data, true);
794 794
 			}
795 795
 		}
796 796
 	}
@@ -800,22 +800,22 @@  discard block
 block discarded – undo
800 800
 	/**
801 801
 	 * Creates the main gallery data
802 802
 	 */
803
-	public function set_featured_image($data,$id) {
804
-		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
805
-		    if('tour' === $this->tab_slug){
803
+	public function set_featured_image($data, $id) {
804
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
805
+		    if ('tour' === $this->tab_slug) {
806 806
 		        $key = array_rand($data[0]['content']['images']);
807
-                $this->featured_image = $this->attach_image($data[0]['content']['images'][$key],$id);
808
-            }else{
809
-				$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
807
+                $this->featured_image = $this->attach_image($data[0]['content']['images'][$key], $id);
808
+            }else {
809
+				$this->featured_image = $this->attach_image($data[0]['content']['images'][0], $id);
810 810
             }
811 811
 
812 812
 
813
-			if(false !== $this->featured_image){
814
-				delete_post_meta($id,'_thumbnail_id');
815
-				add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
813
+			if (false !== $this->featured_image) {
814
+				delete_post_meta($id, '_thumbnail_id');
815
+				add_post_meta($id, '_thumbnail_id', $this->featured_image, true);
816 816
 
817
-				if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
818
-					add_post_meta($id,'gallery',$this->featured_image,false);
817
+				if (!empty($this->gallery_meta) && !in_array($this->featured_image, $this->gallery_meta)) {
818
+					add_post_meta($id, 'gallery', $this->featured_image, false);
819 819
 					$this->gallery_meta[] = $this->featured_image;
820 820
 				}
821 821
 			}
@@ -825,29 +825,29 @@  discard block
 block discarded – undo
825 825
 	/**
826 826
 	 * Sets a banner image
827 827
 	 */
828
-	public function set_banner_image($data,$id) {
829
-		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
830
-		    if(isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) {
828
+	public function set_banner_image($data, $id) {
829
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
830
+		    if (isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) {
831 831
 				$temp_banner = $this->attach_image($data[0]['destination_image'], $id, array('width' => '1920', 'height' => '600', 'cropping' => 'c'));
832
-			}else{
832
+			}else {
833 833
 				if ('tour' === $this->tab_slug) {
834 834
 					$key = array_rand($data[0]['content']['images']);
835 835
 					$temp_banner = $this->attach_image($data[0]['content']['images'][$key], $id, array('width' => '1920', 'height' => '600', 'cropping' => 'c'));
836
-				} else {
836
+				}else {
837 837
 					$temp_banner = $this->attach_image($data[0]['content']['images'][1], $id, array('width' => '1920', 'height' => '600', 'cropping' => 'c'));
838 838
 				}
839 839
             }
840 840
 
841 841
 
842
-			if(false !== $temp_banner){
842
+			if (false !== $temp_banner) {
843 843
 				$this->banner_image = $temp_banner;
844 844
 
845
-				delete_post_meta($id,'image_group');
845
+				delete_post_meta($id, 'image_group');
846 846
 				$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
847
-				add_post_meta($id,'image_group',$new_banner,true);
847
+				add_post_meta($id, 'image_group', $new_banner, true);
848 848
 
849
-				if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
850
-					add_post_meta($id,'gallery',$this->banner_image,false);
849
+				if (!empty($this->gallery_meta) && !in_array($this->banner_image, $this->gallery_meta)) {
850
+					add_post_meta($id, 'gallery', $this->banner_image, false);
851 851
 					$this->gallery_meta[] = $this->banner_image;
852 852
 				}
853 853
 			}
@@ -857,24 +857,24 @@  discard block
 block discarded – undo
857 857
 	/**
858 858
 	 * Creates the main gallery data
859 859
 	 */
860
-	public function create_main_gallery($data,$id) {
860
+	public function create_main_gallery($data, $id) {
861 861
 
862
-		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
862
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
863 863
 			$counter = 0;
864
-			foreach($data[0]['content']['images'] as $image_data){
865
-				if($counter === 0 && false !== $this->featured_image){$counter++;continue;}
866
-				if($counter === 1 && false !== $this->banner_image){$counter++;continue;}
864
+			foreach ($data[0]['content']['images'] as $image_data) {
865
+				if ($counter === 0 && false !== $this->featured_image) {$counter++; continue; }
866
+				if ($counter === 1 && false !== $this->banner_image) {$counter++; continue; }
867 867
 
868
-				$this->gallery_meta[] = $this->attach_image($image_data,$id);
868
+				$this->gallery_meta[] = $this->attach_image($image_data, $id);
869 869
 				$counter++;
870 870
 			}
871 871
 
872
-			if(!empty($this->gallery_meta)){
873
-				delete_post_meta($id,'gallery');
872
+			if (!empty($this->gallery_meta)) {
873
+				delete_post_meta($id, 'gallery');
874 874
 				$this->gallery_meta = array_unique($this->gallery_meta);
875
-				foreach($this->gallery_meta as $gallery_id){
876
-					if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
877
-						add_post_meta($id,'gallery',$gallery_id,false);
875
+				foreach ($this->gallery_meta as $gallery_id) {
876
+					if (false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)) {
877
+						add_post_meta($id, 'gallery', $gallery_id, false);
878 878
 					}
879 879
 				}
880 880
 			}
@@ -884,27 +884,27 @@  discard block
 block discarded – undo
884 884
 	/**
885 885
 	 * search_form
886 886
 	 */
887
-	public function get_scaling_url($args=array()) {
887
+	public function get_scaling_url($args = array()) {
888 888
 
889 889
 		$defaults = array(
890 890
 			'width' => '640',
891 891
 			'height' => '480',
892 892
 			'cropping' => 'c'
893 893
 		);
894
-		if(false !== $this->options){
895
-			if(isset($this->options['width']) && '' !== $this->options['width']){
894
+		if (false !== $this->options) {
895
+			if (isset($this->options['width']) && '' !== $this->options['width']) {
896 896
 				$defaults['width'] = $this->options['width'];
897 897
 			}
898 898
 
899
-			if(isset($this->options['height']) && '' !== $this->options['height']){
899
+			if (isset($this->options['height']) && '' !== $this->options['height']) {
900 900
 				$defaults['height'] = $this->options['height'];
901 901
 			}
902 902
 
903
-			if(isset($this->options['cropping']) && '' !== $this->options['cropping']){
903
+			if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
904 904
 				$defaults['cropping'] = $this->options['cropping'];
905 905
 			}
906 906
 		}
907
-		$args = wp_parse_args($args,$defaults);
907
+		$args = wp_parse_args($args, $defaults);
908 908
 
909 909
 		$cropping = $args['cropping'];
910 910
 		$width = $args['width'];
@@ -917,42 +917,42 @@  discard block
 block discarded – undo
917 917
 	/**
918 918
 	 * Attaches 1 image
919 919
 	 */
920
-	public function attach_image($v=false,$parent_id,$image_sizes=false){
921
-		if(false !== $v){
922
-			$temp_fragment = explode('/',$v['url_fragment']);
923
-			$url_filename = $temp_fragment[count($temp_fragment)-1];
924
-			$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
920
+	public function attach_image($v = false, $parent_id, $image_sizes = false) {
921
+		if (false !== $v) {
922
+			$temp_fragment = explode('/', $v['url_fragment']);
923
+			$url_filename = $temp_fragment[count($temp_fragment) - 1];
924
+			$url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename);
925 925
 			$url_filename = trim($url_filename);
926
-			$url_filename = str_replace(" ",'_',$url_filename);
926
+			$url_filename = str_replace(" ", '_', $url_filename);
927 927
 
928
-			if(in_array($url_filename,$this->found_attachments)){
929
-				return array_search($url_filename,$this->found_attachments);
928
+			if (in_array($url_filename, $this->found_attachments)) {
929
+				return array_search($url_filename, $this->found_attachments);
930 930
 			}
931 931
 
932
-			$postdata=array();
933
-			if(empty($v['label']))
932
+			$postdata = array();
933
+			if (empty($v['label']))
934 934
 			{
935
-				$v['label']='';
935
+				$v['label'] = '';
936 936
 			}
937
-			if(!empty($v['description']))
937
+			if (!empty($v['description']))
938 938
 			{
939
-				$desc=wp_strip_all_tags($v['description']);
940
-				$posdata=array('post_excerpt'=>$desc);
939
+				$desc = wp_strip_all_tags($v['description']);
940
+				$posdata = array('post_excerpt'=>$desc);
941 941
 			}
942
-			if(!empty($v['section']))
942
+			if (!empty($v['section']))
943 943
 			{
944
-				$desc=wp_strip_all_tags($v['section']);
945
-				$posdata=array('post_excerpt'=>$desc);
944
+				$desc = wp_strip_all_tags($v['section']);
945
+				$posdata = array('post_excerpt'=>$desc);
946 946
 			}
947 947
 
948
-			$attachID=NULL;
948
+			$attachID = NULL;
949 949
 			//Resizor - add option to setting if required
950
-			$fragment = str_replace(' ','%20',$v['url_fragment']);
950
+			$fragment = str_replace(' ', '%20', $v['url_fragment']);
951 951
 			$url = $this->get_scaling_url($image_sizes).$fragment;
952
-			$attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
952
+			$attachID = $this->attach_external_image2($url, $parent_id, '', $v['label'], $postdata);
953 953
 
954 954
 			//echo($attachID.' add image');
955
-			if($attachID!=NULL)
955
+			if ($attachID != NULL)
956 956
 			{
957 957
 				return $attachID;
958 958
 			}
@@ -960,13 +960,13 @@  discard block
 block discarded – undo
960 960
 		return 	false;
961 961
 	}
962 962
 
963
-	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
963
+	public function attach_external_image2($url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array()) {
964 964
 
965
-		if ( !$url || !$post_id ) { return new WP_Error('missing', "Need a valid URL and post ID..."); }
965
+		if (!$url || !$post_id) { return new WP_Error('missing', "Need a valid URL and post ID..."); }
966 966
 
967
-		require_once(ABSPATH . 'wp-admin/includes/file.php');
968
-		require_once(ABSPATH . 'wp-admin/includes/media.php');
969
-		require_once(ABSPATH . 'wp-admin/includes/image.php');
967
+		require_once(ABSPATH.'wp-admin/includes/file.php');
968
+		require_once(ABSPATH.'wp-admin/includes/media.php');
969
+		require_once(ABSPATH.'wp-admin/includes/image.php');
970 970
 		// Download file to temp location, returns full server path to temp file
971 971
 		//$tmp = download_url( $url );
972 972
 
@@ -975,53 +975,53 @@  discard block
 block discarded – undo
975 975
 
976 976
 		$image = file_get_contents($url);
977 977
 		file_put_contents($tmp, $image);
978
-		chmod($tmp,'777');
978
+		chmod($tmp, '777');
979 979
 
980
-		preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches);    // fix file filename for query strings
980
+		preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches); // fix file filename for query strings
981 981
 		$url_filename = basename($matches[0]);
982
-		$url_filename=str_replace('%20','_',$url_filename);
982
+		$url_filename = str_replace('%20', '_', $url_filename);
983 983
 		// extract filename from url for title
984
-		$url_type = wp_check_filetype($url_filename);                                           // determine file type (ext and mime/type)
984
+		$url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type)
985 985
 
986 986
 		// override filename if given, reconstruct server path
987
-		if ( !empty( $filename ) && " " != $filename )
987
+		if (!empty($filename) && " " != $filename)
988 988
 		{
989 989
 			$filename = sanitize_file_name($filename);
990
-			$tmppath = pathinfo( $tmp );
990
+			$tmppath = pathinfo($tmp);
991 991
 
992 992
 			$extension = '';
993
-			if(isset($tmppath['extension'])){
993
+			if (isset($tmppath['extension'])) {
994 994
 				$extension = $tmppath['extension'];
995 995
 			}
996 996
 
997
-			$new = $tmppath['dirname'] . "/". $filename . "." . $extension;
998
-			rename($tmp, $new);                                                                 // renames temp file on server
999
-			$tmp = $new;                                                                        // push new filename (in path) to be used in file array later
997
+			$new = $tmppath['dirname']."/".$filename.".".$extension;
998
+			rename($tmp, $new); // renames temp file on server
999
+			$tmp = $new; // push new filename (in path) to be used in file array later
1000 1000
 		}
1001 1001
 
1002 1002
 		// assemble file data (should be built like $_FILES since wp_handle_sideload() will be using)
1003
-		$file_array['tmp_name'] = $tmp;                                                         // full server path to temp file
1003
+		$file_array['tmp_name'] = $tmp; // full server path to temp file
1004 1004
 
1005
-		if ( !empty( $filename) && " " != $filename )
1005
+		if (!empty($filename) && " " != $filename)
1006 1006
 		{
1007
-			$file_array['name'] = $filename . "." . $url_type['ext'];                           // user given filename for title, add original URL extension
1007
+			$file_array['name'] = $filename.".".$url_type['ext']; // user given filename for title, add original URL extension
1008 1008
 		}
1009 1009
 		else
1010 1010
 		{
1011
-			$file_array['name'] = $url_filename;                                                // just use original URL filename
1011
+			$file_array['name'] = $url_filename; // just use original URL filename
1012 1012
 		}
1013 1013
 
1014 1014
 		// set additional wp_posts columns
1015
-		if ( empty( $post_data['post_title'] ) )
1015
+		if (empty($post_data['post_title']))
1016 1016
 		{
1017 1017
 
1018
-			$url_filename=str_replace('%20',' ',$url_filename);
1018
+			$url_filename = str_replace('%20', ' ', $url_filename);
1019 1019
 
1020
-			$post_data['post_title'] = basename($url_filename, "." . $url_type['ext']);         // just use the original filename (no extension)
1020
+			$post_data['post_title'] = basename($url_filename, ".".$url_type['ext']); // just use the original filename (no extension)
1021 1021
 		}
1022 1022
 
1023 1023
 		// make sure gets tied to parent
1024
-		if ( empty( $post_data['post_parent'] ) )
1024
+		if (empty($post_data['post_parent']))
1025 1025
 		{
1026 1026
 			$post_data['post_parent'] = $post_id;
1027 1027
 		}
@@ -1029,12 +1029,12 @@  discard block
 block discarded – undo
1029 1029
 		// required libraries for media_handle_sideload
1030 1030
 
1031 1031
 		// do the validation and storage stuff
1032
-		$att_id = media_handle_sideload( $file_array, $post_id, null, $post_data );             // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status
1032
+		$att_id = media_handle_sideload($file_array, $post_id, null, $post_data); // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status
1033 1033
 
1034 1034
 		// If error storing permanently, unlink
1035
-		if ( is_wp_error($att_id) )
1035
+		if (is_wp_error($att_id))
1036 1036
 		{
1037
-			unlink($file_array['tmp_name']);   // clean up
1037
+			unlink($file_array['tmp_name']); // clean up
1038 1038
 			return false; // output wp_error
1039 1039
 			//return $att_id; // output wp_error
1040 1040
 		}
@@ -1063,31 +1063,31 @@  discard block
 block discarded – undo
1063 1063
 	/**
1064 1064
 	 * Formats the row for the completed list.
1065 1065
 	 */
1066
-	public function format_completed_row($response){
1066
+	public function format_completed_row($response) {
1067 1067
 		echo '<li class="post-'.$response.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($response).'">'.get_the_title($response).'</a></li>';
1068 1068
 	}
1069 1069
 
1070 1070
 	/**
1071 1071
 	 * Formats the error.
1072 1072
 	 */
1073
-	public function format_error($response){
1073
+	public function format_error($response) {
1074 1074
 		echo '<li class="post-error"><span class="dashicons dashicons-no"></span>'.$response.'</li>';
1075 1075
 	}
1076 1076
 
1077 1077
 	/**
1078 1078
 	 * Does a multine search
1079 1079
 	 */
1080
-	public function multineedle_stripos($haystack, $needles, $offset=0) {
1080
+	public function multineedle_stripos($haystack, $needles, $offset = 0) {
1081 1081
 		$found = false;
1082 1082
 		$needle_count = count($needles);
1083
-		foreach($needles as $needle) {
1084
-			if(false !== stripos($haystack, $needle, $offset)){
1083
+		foreach ($needles as $needle) {
1084
+			if (false !== stripos($haystack, $needle, $offset)) {
1085 1085
 				$found[] = true;
1086 1086
 			}
1087 1087
 		}
1088
-		if(false !== $found && $needle_count === count($found)){
1088
+		if (false !== $found && $needle_count === count($found)) {
1089 1089
 			return true;
1090
-		}else{
1090
+		}else {
1091 1091
 			return false;
1092 1092
 		}
1093 1093
 	}
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
 	/**
1096 1096
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
1097 1097
 	 */
1098
-	public function find_current_accommodation($post_type='accommodation') {
1098
+	public function find_current_accommodation($post_type = 'accommodation') {
1099 1099
 		global $wpdb;
1100 1100
 		$return = array();
1101 1101
 
@@ -1111,8 +1111,8 @@  discard block
 block discarded – undo
1111 1111
 
1112 1112
 					LIMIT 0,5000
1113 1113
 		");
1114
-		if(null !== $current_accommodation && !empty($current_accommodation)){
1115
-			foreach($current_accommodation as $accom){
1114
+		if (null !== $current_accommodation && !empty($current_accommodation)) {
1115
+			foreach ($current_accommodation as $accom) {
1116 1116
 				$return[$accom->meta_value] = $accom;
1117 1117
 			}
1118 1118
 		}
@@ -1122,31 +1122,31 @@  discard block
 block discarded – undo
1122 1122
 	/**
1123 1123
 	 * Set the Video date
1124 1124
 	 */
1125
-	public function set_video_data($data,$id) {
1126
-		if(!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])){
1125
+	public function set_video_data($data, $id) {
1126
+		if (!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])) {
1127 1127
 			$videos = false;
1128 1128
 
1129
-			foreach($data[0]['content']['youtube_videos'] as $video){
1129
+			foreach ($data[0]['content']['youtube_videos'] as $video) {
1130 1130
 				$temp_video = array();
1131 1131
 
1132
-				if(isset($video['label'])){
1132
+				if (isset($video['label'])) {
1133 1133
 					$temp_video['title'] = $video['label'];
1134 1134
 				}
1135
-				if(isset($video['description'])){
1135
+				if (isset($video['description'])) {
1136 1136
 					$temp_video['description'] = strip_tags($video['description']);
1137 1137
 				}
1138
-				if(isset($video['url'])){
1138
+				if (isset($video['url'])) {
1139 1139
 					$temp_video['url'] = $video['url'];
1140 1140
 				}
1141 1141
 				$temp_video['thumbnail'] = '';
1142 1142
 				$videos[] = $temp_video;
1143 1143
 			}
1144 1144
 
1145
-			if(false !== $id && '0' !== $id){
1145
+			if (false !== $id && '0' !== $id) {
1146 1146
 				delete_post_meta($id, 'videos');
1147 1147
 			}
1148
-			foreach($videos as $video){
1149
-				add_post_meta($id,'videos',$video,false);
1148
+			foreach ($videos as $video) {
1149
+				add_post_meta($id, 'videos', $video, false);
1150 1150
 			}
1151 1151
 		}
1152 1152
 	}
Please login to merge, or discard this patch.
Braces   +18 added lines, -24 removed lines patch added patch discarded remove patch
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 					<?php } ?>
401 401
                 </ul>
402 402
 				<?php*/
403
-			}else{
403
+			} else{
404 404
 			   $this->current_importer->display_page();
405 405
             }; ?>
406 406
         </div>
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 
437 437
                 <?php if('tour'===$this->tab_slug){ ?>
438 438
                     | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU','wetu-importer'); ?></a>
439
-                <?php }else if(!empty($this->queued_imports)) { ?>
439
+                <?php } else if(!empty($this->queued_imports)) { ?>
440 440
                     | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU Queue','wetu-importer'); ?></a>
441 441
                 <?php } ?>
442 442
             </p>
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 					foreach($team_members->posts as $member){ ?>
527 527
                         <li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
528 528
 					<?php }
529
-				}else{ ?>
529
+				} else{ ?>
530 530
                     <li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
531 531
 				<?php }
532 532
 				?>
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 			if (in_array($needle, $haystack)) {
592 592
 				if(true === $wrap || 'true' === $wrap) {
593 593
 					$html = $type . '="' . $type . '"';
594
-				}else{
594
+				} else{
595 595
 					$html = $type;
596 596
 				}
597 597
 			}
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 
644 644
 			if(false !== $id && '0' !== $id && false !== $prev && true === $unique){
645 645
 				update_post_meta($id,$meta_key,$value,$prev);
646
-			}else{
646
+			} else{
647 647
 				add_post_meta($id,$meta_key,$value,$unique);
648 648
 			}
649 649
 		}
@@ -684,18 +684,15 @@  discard block
 block discarded – undo
684 684
 						if ( is_wp_error($term) )
685 685
 						{
686 686
 							echo $term->get_error_message();
687
-						}
688
-						else
687
+						} else
689 688
 						{
690 689
 							wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
691 690
 						}
692
-					}
693
-					else
691
+					} else
694 692
 					{
695 693
 						wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
696 694
 					}
697
-				}
698
-				else
695
+				} else
699 696
 				{
700 697
 					$result[]=trim($k);
701 698
 				}
@@ -709,10 +706,8 @@  discard block
 block discarded – undo
709 706
 		{
710 707
 			if(false !== $parent){ $parent = array('parent'=>$parent); }
711 708
 			$term = wp_insert_term(trim($name), $taxonomy,$parent);
712
-			if ( is_wp_error($term) ){echo $term->get_error_message();}
713
-			else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
714
-		}
715
-		else
709
+			if ( is_wp_error($term) ){echo $term->get_error_message();} else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
710
+		} else
716 711
 		{
717 712
 			wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
718 713
 		}
@@ -732,7 +727,7 @@  discard block
 block discarded – undo
732 727
 				foreach($terms as $term){
733 728
 					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected,$term->term_id,false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
734 729
 				}
735
-			}else{
730
+			} else{
736 731
 				$return .= '<li><input type="checkbox" value="" /> '.__('None','wetu-importer').'</li>';
737 732
 			}
738 733
 			$return .= '</ul>';
@@ -751,13 +746,13 @@  discard block
 block discarded – undo
751 746
 
752 747
 			if(isset($data[0]['position']['driving_latitude'])){
753 748
 				$latitude = $data[0]['position']['driving_latitude'];
754
-			}elseif(isset($data[0]['position']['latitude'])){
749
+			} elseif(isset($data[0]['position']['latitude'])){
755 750
 				$latitude = $data[0]['position']['latitude'];
756 751
 			}
757 752
 
758 753
 			if(isset($data[0]['position']['driving_longitude'])){
759 754
 				$longitude = $data[0]['position']['driving_longitude'];
760
-			}elseif(isset($data[0]['position']['longitude'])){
755
+			} elseif(isset($data[0]['position']['longitude'])){
761 756
 				$longitude = $data[0]['position']['longitude'];
762 757
 			}
763 758
 
@@ -789,7 +784,7 @@  discard block
 block discarded – undo
789 784
 			if(false !== $id && '0' !== $id){
790 785
 				$prev = get_post_meta($id,'location',true);
791 786
 				update_post_meta($id,'location',$location_data,$prev);
792
-			}else{
787
+			} else{
793 788
 				add_post_meta($id,'location',$location_data,true);
794 789
 			}
795 790
 		}
@@ -805,7 +800,7 @@  discard block
 block discarded – undo
805 800
 		    if('tour' === $this->tab_slug){
806 801
 		        $key = array_rand($data[0]['content']['images']);
807 802
                 $this->featured_image = $this->attach_image($data[0]['content']['images'][$key],$id);
808
-            }else{
803
+            } else{
809 804
 				$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
810 805
             }
811 806
 
@@ -829,7 +824,7 @@  discard block
 block discarded – undo
829 824
 		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
830 825
 		    if(isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) {
831 826
 				$temp_banner = $this->attach_image($data[0]['destination_image'], $id, array('width' => '1920', 'height' => '600', 'cropping' => 'c'));
832
-			}else{
827
+			} else{
833 828
 				if ('tour' === $this->tab_slug) {
834 829
 					$key = array_rand($data[0]['content']['images']);
835 830
 					$temp_banner = $this->attach_image($data[0]['content']['images'][$key], $id, array('width' => '1920', 'height' => '600', 'cropping' => 'c'));
@@ -1005,8 +1000,7 @@  discard block
 block discarded – undo
1005 1000
 		if ( !empty( $filename) && " " != $filename )
1006 1001
 		{
1007 1002
 			$file_array['name'] = $filename . "." . $url_type['ext'];                           // user given filename for title, add original URL extension
1008
-		}
1009
-		else
1003
+		} else
1010 1004
 		{
1011 1005
 			$file_array['name'] = $url_filename;                                                // just use original URL filename
1012 1006
 		}
@@ -1087,7 +1081,7 @@  discard block
 block discarded – undo
1087 1081
 		}
1088 1082
 		if(false !== $found && $needle_count === count($found)){
1089 1083
 			return true;
1090
-		}else{
1084
+		} else{
1091 1085
 			return false;
1092 1086
 		}
1093 1087
 	}
Please login to merge, or discard this patch.