Completed
Push — master ( dd8510...c954ea )
by Warwick
03:09
created
classes/class-connect-accommodation.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 	 */
52 52
 	public function display_page() {
53 53
 		global $post;
54
-        ?>
54
+		?>
55 55
         <div class="wrap">
56 56
 
57 57
             <h3><span class="dashicons dashicons-admin-multisite"></span> <?php _e('Connect your Accommodation','wetu-importer'); ?></h3>
Please login to merge, or discard this patch.
classes/lsx-banners-integration.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * Display the importer administration screen
38 38
 	 */
39 39
 	public function display_page() {
40
-        ?>
40
+		?>
41 41
         <div class="wrap">
42 42
 			
43 43
             <h2><?php _e('Download new banners straight from WETU','wetu-importer'); ?></h2>
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
 		$base = rawurlencode($base);
212 212
 	  $type = get_post_mime_type($post_id);
213 213
 	  switch ($type) {
214
-	    case 'image/jpeg':
215
-	    	return $base . ".jpg"; break;
216
-	    case 'image/png':
217
-	    	return $base . ".png"; break;
218
-	    case 'image/gif':
219
-	      	return $base . ".gif"; break;
220
-	    default:
221
-	      return false;
214
+		case 'image/jpeg':
215
+			return $base . ".jpg"; break;
216
+		case 'image/png':
217
+			return $base . ".png"; break;
218
+		case 'image/gif':
219
+		  	return $base . ".gif"; break;
220
+		default:
221
+		  return false;
222 222
 	  }
223 223
 	}	
224 224
 
Please login to merge, or discard this patch.
classes/class-accommodation.php 1 patch
Indentation   +213 added lines, -213 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
 	/**
@@ -433,18 +433,18 @@  discard block
 block discarded – undo
433 433
 				$content = false;
434 434
 			}
435 435
 
436
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
437
-            if($jdata)
438
-            {
439
-                $adata=json_decode($jdata,true);
440
-                if(!empty($adata))
441
-                {
442
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
443
-                	$this->format_completed_row($return);
444
-                	$this->remove_from_queue($return);
436
+			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
437
+			if($jdata)
438
+			{
439
+				$adata=json_decode($jdata,true);
440
+				if(!empty($adata))
441
+				{
442
+					$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
443
+					$this->format_completed_row($return);
444
+					$this->remove_from_queue($return);
445 445
 					$this->cleanup_posts();
446
-                }
447
-            }
446
+				}
447
+			}
448 448
 		}
449 449
 	}
450 450
 
@@ -453,147 +453,147 @@  discard block
 block discarded – undo
453 453
 	 */
454 454
 	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
455 455
 
456
-        if(trim($data[0]['type'])=='Accommodation')
457
-        {
458
-	        $post_name = $data_post_content = $data_post_excerpt = '';
459
-	        $post = array(
460
-	          'post_type'		=> 'accommodation',
461
-	        );
462
-
463
-	        $content_used_general_description = false;
464
-
465
-	        //Set the post_content
466
-	        if(false !== $importable_content && in_array('description',$importable_content)){
467
-		        if(isset($data[0]['content']['extended_description']))
468
-		        {
469
-		            $data_post_content = $data[0]['content']['extended_description'];
470
-		        }elseif(isset($data[0]['content']['general_description'])){
471
-		            $data_post_content = $data[0]['content']['general_description'];
472
-		            $content_used_general_description = true;
473
-		        }elseif(isset($data[0]['content']['teaser_description'])){
474
-		        	$data_post_content = $data[0]['content']['teaser_description'];
475
-		        }
476
-	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
477
-	        }
478
-
479
-	        //set the post_excerpt
480
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
481
-		        if(isset($data[0]['content']['teaser_description'])){
482
-		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
483
-		        }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
484
-		            $data_post_excerpt = $data[0]['content']['general_description'];
485
-		        }	   
486
-		        $post['post_excerpt'] = $data_post_excerpt;     	
487
-	        }
488
-
489
-	        if(false !== $id && '0' !== $id){
490
-	        	$post['ID'] = $id;
456
+		if(trim($data[0]['type'])=='Accommodation')
457
+		{
458
+			$post_name = $data_post_content = $data_post_excerpt = '';
459
+			$post = array(
460
+			  'post_type'		=> 'accommodation',
461
+			);
462
+
463
+			$content_used_general_description = false;
464
+
465
+			//Set the post_content
466
+			if(false !== $importable_content && in_array('description',$importable_content)){
467
+				if(isset($data[0]['content']['extended_description']))
468
+				{
469
+					$data_post_content = $data[0]['content']['extended_description'];
470
+				}elseif(isset($data[0]['content']['general_description'])){
471
+					$data_post_content = $data[0]['content']['general_description'];
472
+					$content_used_general_description = true;
473
+				}elseif(isset($data[0]['content']['teaser_description'])){
474
+					$data_post_content = $data[0]['content']['teaser_description'];
475
+				}
476
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
477
+			}
478
+
479
+			//set the post_excerpt
480
+			if(false !== $importable_content && in_array('excerpt',$importable_content)){
481
+				if(isset($data[0]['content']['teaser_description'])){
482
+					$data_post_excerpt = $data[0]['content']['teaser_description'];
483
+				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
484
+					$data_post_excerpt = $data[0]['content']['general_description'];
485
+				}	   
486
+				$post['post_excerpt'] = $data_post_excerpt;     	
487
+			}
488
+
489
+			if(false !== $id && '0' !== $id){
490
+				$post['ID'] = $id;
491 491
 				if(isset($data[0]['name'])){
492 492
 					$post['post_title'] = $data[0]['name'];
493
-	        		$post['post_status'] = 'publish';
493
+					$post['post_status'] = 'publish';
494 494
 					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
495 495
 				}
496
-	        	$id = wp_update_post($post);
497
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
498
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
499
-	        }else{
500
-
501
-		        //Set the name
502
-		        if(isset($data[0]['name'])){
503
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
504
-		        }
505
-	        	$post['post_name'] = $post_name;
506
-	        	$post['post_title'] = $data[0]['name'];
507
-	        	$post['post_status'] = 'publish';
508
-	        	$id = wp_insert_post($post);
509
-
510
-	        	//Save the WETU ID and the Last date it was modified.
511
-	        	if(false !== $id){
512
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
513
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
514
-	        	}
515
-	        }
516
-	        //Setup some default for use in the import
517
-	        if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
496
+				$id = wp_update_post($post);
497
+				$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
498
+				update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
499
+			}else{
500
+
501
+				//Set the name
502
+				if(isset($data[0]['name'])){
503
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
504
+				}
505
+				$post['post_name'] = $post_name;
506
+				$post['post_title'] = $data[0]['name'];
507
+				$post['post_status'] = 'publish';
508
+				$id = wp_insert_post($post);
509
+
510
+				//Save the WETU ID and the Last date it was modified.
511
+				if(false !== $id){
512
+					add_post_meta($id,'lsx_wetu_id',$wetu_id);
513
+					add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
514
+				}
515
+			}
516
+			//Setup some default for use in the import
517
+			if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
518 518
 				$this->find_attachments($id);
519 519
 			}
520 520
 
521
-	        //Set the team member if it is there
522
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
523
-	        	$this->set_team_member($id,$team_members);
524
-	    	}
525
-
526
-	        //Set the safari brand
527
-	        if(false !== $safari_brands && '' !== $safari_brands){
528
-	        	$this->set_safari_brands($id,$safari_brands);
529
-
530
-	    	}	    	
531
-
532
-	        if(class_exists('LSX_TO_Maps')){
533
-	        	$this->set_map_data($data,$id,9);
534
-	        }
535
-
536
-	        if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
537
-	        	$this->connect_destinations($data,$id);
538
-	        }
539
-
540
-	        if(false !== $importable_content && in_array('category',$importable_content)){
541
-	        	$this->set_taxonomy_style($data,$id);
542
-	        }
543
-
544
-	        //Set the Room Data
545
-	        if(false !== $importable_content && in_array('rooms',$importable_content)){
546
-	        	$this->set_room_data($data,$id);
547
-	    	}
548
-
549
-	    	//Set the rating
550
-	    	if(false !== $importable_content && in_array('rating',$importable_content)){
551
-	       		$this->set_rating($data,$id);
552
-	    	}
553
-
554
-	    	//Set the checkin checkout data
555
-	    	if(false !== $importable_content && in_array('checkin',$importable_content)){
556
-	        	$this->set_checkin_checkout($data,$id);
557
-	        }
558
-
559
-	    	//Set the Spoken Languages
560
-	    	if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
561
-	       		$this->set_spoken_languages($data,$id);
562
-	    	}
563
-
564
-	    	//Set the friendly options
565
-	    	if(false !== $importable_content && in_array('friendly',$importable_content)){
566
-	       		$this->set_friendly($data,$id);
567
-	    	}
568
-
569
-	    	//Set the special_interests
570
-	    	if(false !== $importable_content && in_array('special_interests',$importable_content)){
571
-	       		$this->set_special_interests($data,$id);
572
-	    	}	    		    		        
573
-
574
-	        //Import the videos
575
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
576
-	        	$this->set_video_data($data,$id);
577
-	        }
578
-
579
-	        //Import the facilities
580
-	        if(false !== $importable_content && in_array('facilities',$importable_content)){
581
-	        	$this->set_facilities($data,$id);
582
-	        }	        
583
-
584
-	        //Set the featured image
585
-	        if(false !== $importable_content && in_array('featured_image',$importable_content)){
586
-	        	$this->set_featured_image($data,$id);
587
-	        }
588
-	        if(false !== $importable_content && in_array('banner_image',$importable_content)){
589
-	        	$this->set_banner_image($data,$id);
590
-	        }	        
591
-	        //Import the main gallery
592
-	        if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
593
-	    		$this->create_main_gallery($data,$id);
594
-	        }	        	        	        
595
-        }
596
-        return $id;
521
+			//Set the team member if it is there
522
+			if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
523
+				$this->set_team_member($id,$team_members);
524
+			}
525
+
526
+			//Set the safari brand
527
+			if(false !== $safari_brands && '' !== $safari_brands){
528
+				$this->set_safari_brands($id,$safari_brands);
529
+
530
+			}	    	
531
+
532
+			if(class_exists('LSX_TO_Maps')){
533
+				$this->set_map_data($data,$id,9);
534
+			}
535
+
536
+			if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
537
+				$this->connect_destinations($data,$id);
538
+			}
539
+
540
+			if(false !== $importable_content && in_array('category',$importable_content)){
541
+				$this->set_taxonomy_style($data,$id);
542
+			}
543
+
544
+			//Set the Room Data
545
+			if(false !== $importable_content && in_array('rooms',$importable_content)){
546
+				$this->set_room_data($data,$id);
547
+			}
548
+
549
+			//Set the rating
550
+			if(false !== $importable_content && in_array('rating',$importable_content)){
551
+		   		$this->set_rating($data,$id);
552
+			}
553
+
554
+			//Set the checkin checkout data
555
+			if(false !== $importable_content && in_array('checkin',$importable_content)){
556
+				$this->set_checkin_checkout($data,$id);
557
+			}
558
+
559
+			//Set the Spoken Languages
560
+			if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
561
+		   		$this->set_spoken_languages($data,$id);
562
+			}
563
+
564
+			//Set the friendly options
565
+			if(false !== $importable_content && in_array('friendly',$importable_content)){
566
+		   		$this->set_friendly($data,$id);
567
+			}
568
+
569
+			//Set the special_interests
570
+			if(false !== $importable_content && in_array('special_interests',$importable_content)){
571
+		   		$this->set_special_interests($data,$id);
572
+			}	    		    		        
573
+
574
+			//Import the videos
575
+			if(false !== $importable_content && in_array('videos',$importable_content)){
576
+				$this->set_video_data($data,$id);
577
+			}
578
+
579
+			//Import the facilities
580
+			if(false !== $importable_content && in_array('facilities',$importable_content)){
581
+				$this->set_facilities($data,$id);
582
+			}	        
583
+
584
+			//Set the featured image
585
+			if(false !== $importable_content && in_array('featured_image',$importable_content)){
586
+				$this->set_featured_image($data,$id);
587
+			}
588
+			if(false !== $importable_content && in_array('banner_image',$importable_content)){
589
+				$this->set_banner_image($data,$id);
590
+			}	        
591
+			//Import the main gallery
592
+			if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
593
+				$this->create_main_gallery($data,$id);
594
+			}	        	        	        
595
+		}
596
+		return $id;
597 597
 	}
598 598
 
599 599
 	/**
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
 
604 604
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
605 605
 		foreach($team_members as $team){
606
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
606
+			add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
607 607
 		}
608 608
 	}
609 609
 
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 	 */
613 613
 	public function set_safari_brands($id,$safari_brands) {
614 614
 		foreach($safari_brands as $safari_brand){
615
-        	wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
615
+			wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
616 616
 		}
617 617
 	}
618 618
 
@@ -621,32 +621,32 @@  discard block
 block discarded – undo
621 621
 	 */
622 622
 	public function connect_destinations($data,$id) {
623 623
 		if(isset($data[0]['position'])){
624
-		    $destinations = false;
625
-		    if(isset($data[0]['position']['country'])){
626
-		    	$destinations['country'] = $data[0]['position']['country'];
627
-		    }
628
-		    if(isset($data[0]['position']['destination'])){
629
-		    	$destinations['destination'] = $data[0]['position']['destination'];
630
-		    }
624
+			$destinations = false;
625
+			if(isset($data[0]['position']['country'])){
626
+				$destinations['country'] = $data[0]['position']['country'];
627
+			}
628
+			if(isset($data[0]['position']['destination'])){
629
+				$destinations['destination'] = $data[0]['position']['destination'];
630
+			}
631 631
 		    
632
-		    if(false !== $destinations){	
633
-		    	$prev_values = get_post_meta($id,'destination_to_accommodation',false);
634
-		    	if(false === $prev_values || !is_array($prev_values)){
635
-		    		$prev_values = array();
636
-		    	}
637
-		    	//print_r($destinations);
632
+			if(false !== $destinations){	
633
+				$prev_values = get_post_meta($id,'destination_to_accommodation',false);
634
+				if(false === $prev_values || !is_array($prev_values)){
635
+					$prev_values = array();
636
+				}
637
+				//print_r($destinations);
638 638
 				$destinations = array_unique($destinations);
639 639
 				//print_r($destinations);
640
-			    foreach($destinations as $key => $value){
641
-				    $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
642
-	                if (null !== $destination) {
643
-	                	if(!in_array($destination->ID,$prev_values)){
644
-	                   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
645
-	                   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
640
+				foreach($destinations as $key => $value){
641
+					$destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
642
+					if (null !== $destination) {
643
+						if(!in_array($destination->ID,$prev_values)){
644
+					   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
645
+					   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
646 646
 							$this->cleanup_posts[$destination->ID] = 'accommodation_to_destination';
647
-	                	}
648
-	                } 		    	
649
-			    }	
647
+						}
648
+					} 		    	
649
+				}	
650 650
 			}
651 651
 		}
652 652
 	}	
@@ -658,15 +658,15 @@  discard block
 block discarded – undo
658 658
 		$terms = false;
659 659
 		if(isset($data[0]['category'])){
660 660
 			if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
661
-	        {
662
-	            $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
663
-	            if ( is_wp_error($term) ){echo $term->get_error_message();}
664
-	            else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
665
-	        }
666
-	        else
667
-	        {
668
-	            wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
669
-	        }				
661
+			{
662
+				$term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
663
+				if ( is_wp_error($term) ){echo $term->get_error_message();}
664
+				else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
665
+			}
666
+			else
667
+			{
668
+				wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
669
+			}				
670 670
 		}
671 671
 	}		
672 672
 
@@ -690,25 +690,25 @@  discard block
 block discarded – undo
690 690
 				$temp_room['type'] = 'room';
691 691
 
692 692
 				if(!empty($room['images']) && is_array($room['images'])){
693
-			    	$attachments_args = array(
694
-			    			'post_parent' => $id,
695
-			    			'post_status' => 'inherit',
696
-			    			'post_type' => 'attachment',
697
-			    			'order' => 'ASC',
698
-			    	);   	
699
-			    	$attachments = new WP_Query($attachments_args);
700
-			    	$found_attachments = array();
701
-
702
-			    	if($attachments->have_posts()){
703
-			    		foreach($attachments->posts as $attachment){
704
-			    			$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
705
-			    		}
706
-			    	}
693
+					$attachments_args = array(
694
+							'post_parent' => $id,
695
+							'post_status' => 'inherit',
696
+							'post_type' => 'attachment',
697
+							'order' => 'ASC',
698
+					);   	
699
+					$attachments = new WP_Query($attachments_args);
700
+					$found_attachments = array();
701
+
702
+					if($attachments->have_posts()){
703
+						foreach($attachments->posts as $attachment){
704
+							$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
705
+						}
706
+					}
707 707
 
708 708
 					$temp_room['gallery'] = array();
709 709
 					foreach($room['images'] as $image_data){
710
-			    		$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
711
-			    	}
710
+						$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
711
+					}
712 712
 				}
713 713
 				$rooms[] = $temp_room;
714 714
 			}
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 				delete_post_meta($id, 'units');				
718 718
 			}
719 719
 			foreach($rooms as $room){
720
-		        add_post_meta($id,'units',$room,false);			
720
+				add_post_meta($id,'units',$room,false);			
721 721
 			}
722 722
 
723 723
 			if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){
@@ -727,11 +727,11 @@  discard block
 block discarded – undo
727 727
 			}
728 728
 
729 729
 			if(false !== $id && '0' !== $id){
730
-	        	$prev_rooms = get_post_meta($id,'number_of_rooms',true);
731
-	        	update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
732
-	        }else{
733
-	        	add_post_meta($id,'number_of_rooms',$room_count,true);
734
-	        }
730
+				$prev_rooms = get_post_meta($id,'number_of_rooms',true);
731
+				update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
732
+			}else{
733
+				add_post_meta($id,'number_of_rooms',$room_count,true);
734
+			}
735 735
 		}
736 736
 	}
737 737
 
Please login to merge, or discard this patch.
classes/class-tours.php 1 patch
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function set_variables()
99 99
 	{
100
-	    parent::set_variables();
100
+		parent::set_variables();
101 101
 
102 102
 		if ( false !== $this->api_username && false !== $this->api_password ) {
103 103
 			$this->url    = 'https://wetu.com/API/Itinerary/';
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 * Display the importer administration screen
123 123
 	 */
124 124
 	public function display_page() {
125
-        ?>
125
+		?>
126 126
         <div class="wrap">
127 127
 			<?php $this->navigation('tour'); ?>
128 128
 
@@ -254,20 +254,20 @@  discard block
 block discarded – undo
254 254
 			$result = $this->update_options();
255 255
 
256 256
 			if(true === $result){
257
-			    echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
258
-                echo ' - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>';
259
-            }else{
260
-			    echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
261
-            }
257
+				echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
258
+				echo ' - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>';
259
+			}else{
260
+				echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
261
+			}
262 262
 		}else{
263 263
 			echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>';
264
-        }
264
+		}
265 265
 		echo '</h3>';
266 266
 
267 267
 		$form_options = get_option('lsx_ti_tours_api_options');
268 268
 		if(false === $form_options){
269 269
 			$form_options = array(0);
270
-        }
270
+		}
271 271
 		?>
272 272
         <form method="get" class="tour-refresh-form" action="<?php echo admin_url('admin.php'); ?>">
273 273
 
@@ -297,15 +297,15 @@  discard block
 block discarded – undo
297 297
 	 */
298 298
 	public function update_options() {
299 299
 
300
-	    $own = '';
301
-	    $options = array();
300
+		$own = '';
301
+		$options = array();
302 302
 
303
-	    delete_option('lsx_ti_tours_api_options');
303
+		delete_option('lsx_ti_tours_api_options');
304 304
 
305
-	    if(isset($_GET['own'])){
305
+		if(isset($_GET['own'])){
306 306
 			$this->url_qs .= '&own=true';
307 307
 			$options[] = 'own';
308
-        }
308
+		}
309 309
 
310 310
 		if(isset($_GET['type'])){
311 311
 			$this->url_qs .= '&type='.implode('',$_GET['type']);
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
 		$tours = json_decode($data, true);
322 322
 
323 323
 		if(isset($tours['error'])){
324
-		    return $tours['error'];
325
-        }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
324
+			return $tours['error'];
325
+		}elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
326 326
 			set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2);
327 327
 			return true;
328 328
 		}
@@ -525,72 +525,72 @@  discard block
 block discarded – undo
525 525
 				$content = false;
526 526
 			}
527 527
 
528
-            $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
528
+			$jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
529 529
 
530
-            if($jdata)
531
-            {
530
+			if($jdata)
531
+			{
532 532
 				$jdata=json_decode($jdata,true);
533
-                if(!empty($jdata))
534
-                {
535
-                	$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
536
-                	$this->format_completed_row($return);
533
+				if(!empty($jdata))
534
+				{
535
+					$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
536
+					$this->format_completed_row($return);
537 537
 					$this->save_queue();
538
-                	$this->cleanup_posts();
539
-                	$this->attach_destination_images($content);
540
-                }
541
-            }
538
+					$this->cleanup_posts();
539
+					$this->attach_destination_images($content);
540
+				}
541
+			}
542 542
 		}
543 543
 	}
544 544
 
545 545
 	/**
546 546
 	 * Connect to wetu
547
-     *
548
-     * @param $data array
549
-     * @param $wetu_id string
547
+	 *
548
+	 * @param $data array
549
+	 * @param $wetu_id string
550 550
 	 */
551 551
 	public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) {
552
-        $post_name = $data_post_content = $data_post_excerpt = '';
553
-        $post = array(
554
-          'post_type'		=> 'tour',
555
-        );
552
+		$post_name = $data_post_content = $data_post_excerpt = '';
553
+		$post = array(
554
+		  'post_type'		=> 'tour',
555
+		);
556 556
 
557
-        //Set the post_content
557
+		//Set the post_content
558 558
 		$content_used_general_description = false;
559
-        if(false !== $importable_content && in_array('description',$importable_content)){
560
-            $data_post_content = '';
561
-
562
-            if(isset($data['description'])){
563
-                $data_post_content = $data['description'];
564
-            }elseif(isset($data['summary'])){
565
-                $data_post_content = $data['summary'];
566
-            }
567
-            $post['post_content'] = $data_post_content;
568
-        }
569
-
570
-        //Create or update the post
571
-        if(false !== $id && '0' !== $id){
572
-            $post['ID'] = $id;
573
-	        $post['post_status'] = 'publish';
574
-            $id = wp_update_post($post);
575
-            $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
576
-            update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
577
-        }else{
578
-
579
-            //Set the name
580
-            if(isset($data['name'])){
581
-                $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
582
-            }
583
-            $post['post_name'] = $post_name;
584
-            $post['post_title'] = $data['name'];
585
-            $post['post_status'] = 'publish';
586
-            $id = wp_insert_post($post);
587
-
588
-            //Save the WETU ID and the Last date it was modified.
589
-            if(false !== $id){
590
-                add_post_meta($id,'lsx_wetu_id',$wetu_id);
591
-                add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
592
-            }
593
-        }
559
+		if(false !== $importable_content && in_array('description',$importable_content)){
560
+			$data_post_content = '';
561
+
562
+			if(isset($data['description'])){
563
+				$data_post_content = $data['description'];
564
+			}elseif(isset($data['summary'])){
565
+				$data_post_content = $data['summary'];
566
+			}
567
+			$post['post_content'] = $data_post_content;
568
+		}
569
+
570
+		//Create or update the post
571
+		if(false !== $id && '0' !== $id){
572
+			$post['ID'] = $id;
573
+			$post['post_status'] = 'publish';
574
+			$id = wp_update_post($post);
575
+			$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
576
+			update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
577
+		}else{
578
+
579
+			//Set the name
580
+			if(isset($data['name'])){
581
+				$post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
582
+			}
583
+			$post['post_name'] = $post_name;
584
+			$post['post_title'] = $data['name'];
585
+			$post['post_status'] = 'publish';
586
+			$id = wp_insert_post($post);
587
+
588
+			//Save the WETU ID and the Last date it was modified.
589
+			if(false !== $id){
590
+				add_post_meta($id,'lsx_wetu_id',$wetu_id);
591
+				add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
592
+			}
593
+		}
594 594
 
595 595
 
596 596
 		//Set the price
@@ -603,15 +603,15 @@  discard block
 block discarded – undo
603 603
 			$this->set_duration($data,$id);
604 604
 		}
605 605
 
606
-        if(false !== $importable_content && in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
607
-            $this->process_itineraries($data,$id,$importable_content);
608
-        }
606
+		if(false !== $importable_content && in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
607
+			$this->process_itineraries($data,$id,$importable_content);
608
+		}
609 609
 
610 610
 		if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){
611 611
 			$this->set_map_data($data,$id);
612 612
 		}
613 613
 
614
-        return $id;
614
+		return $id;
615 615
 	}
616 616
 
617 617
 	/**
@@ -773,17 +773,17 @@  discard block
 block discarded – undo
773 773
 	 * Set the Itinerary Day
774 774
 	 */
775 775
 	public function set_itinerary_day($day,$id) {
776
-        $this->save_custom_field($day,'itinerary',$id,false,false);
776
+		$this->save_custom_field($day,'itinerary',$id,false,false);
777 777
 	}
778 778
 
779 779
 	/**
780 780
 	 * Set the price
781 781
 	 */
782 782
 	public function set_price($data,$id) {
783
-	    //Price
783
+		//Price
784 784
 		if(isset($data['price']) && ''!== $data['price']){
785
-            $price = preg_replace("/[^0-9,.]/", "", $data['price']);
786
-            $this->save_custom_field($price,'price',$id);
785
+			$price = preg_replace("/[^0-9,.]/", "", $data['price']);
786
+			$this->save_custom_field($price,'price',$id);
787 787
 		}
788 788
 
789 789
 		//Price includes
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 			$this->save_custom_field($data['price_includes'],'included',$id);
792 792
 		}
793 793
 
794
-        //Price Excludes
794
+		//Price Excludes
795 795
 		if(isset($data['price_excludes']) && ''!== $data['price_excludes']){
796 796
 			$this->save_custom_field($data['price_excludes'],'not_included',$id);
797 797
 		}
@@ -814,37 +814,37 @@  discard block
 block discarded – undo
814 814
 	 */
815 815
 	public function set_accommodation($day,$id) {
816 816
 
817
-	    $ac_id = false;
817
+		$ac_id = false;
818 818
 		$this->current_accommodation = $this->find_current_accommodation();
819 819
 		
820 820
 		if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){
821 821
 
822 822
 			if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){
823
-                $ac_id = $this->current_accommodation[$day['content_entity_id']];
823
+				$ac_id = $this->current_accommodation[$day['content_entity_id']];
824 824
 			}else{
825 825
 				$ac_id = wp_insert_post(array(
826
-                    'post_type' => 'accommodation',
827
-                    'post_status' => 'draft',
828
-                    'post_title' => $day['content_entity_id']
829
-                ));
826
+					'post_type' => 'accommodation',
827
+					'post_status' => 'draft',
828
+					'post_title' => $day['content_entity_id']
829
+				));
830 830
 				$this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id);
831 831
 			}
832 832
 
833 833
 			if('' !== $ac_id && false !== $ac_id){
834
-			    $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
834
+				$this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
835 835
 				$this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false);
836 836
 
837 837
 				$this->queue_item($ac_id);
838
-            }
838
+			}
839 839
 		}
840 840
 		return $ac_id;
841 841
 	}
842 842
 
843 843
 	/**
844 844
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
845
-     *
846
-     * @param $post_type string
847
-     * @return boolean / array
845
+	 *
846
+	 * @param $post_type string
847
+	 * @return boolean / array
848 848
 	 */
849 849
 	public function find_current_accommodation($post_type='accommodation') {
850 850
 		global $wpdb;
@@ -852,16 +852,16 @@  discard block
 block discarded – undo
852 852
 
853 853
 		$return = false;
854 854
 		if(!empty($accommodation)){
855
-		    foreach($accommodation as $key => $acc){
855
+			foreach($accommodation as $key => $acc){
856 856
 				$return[$acc->meta_value] = $acc->post_id;
857
-            }
858
-        }
857
+			}
858
+		}
859 859
 		return $return;
860 860
 	}
861 861
 
862 862
 	/**
863 863
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
864
-     * @return boolean / array
864
+	 * @return boolean / array
865 865
 	 */
866 866
 	public function find_current_destinations() {
867 867
 		return $this->find_current_accommodation('destination');
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 				$country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true);
890 890
 				if(false !== $country_wetu_id){
891 891
 					$country_id = $this->set_country($country_wetu_id, $id);
892
-                }
892
+				}
893 893
 
894 894
 			}else {
895 895
 
@@ -900,27 +900,27 @@  discard block
 block discarded – undo
900 900
 
901 901
 					if (!empty($destination_data) && !isset($destination_data['error'])) {
902 902
 
903
-					    $destination_title = $day['destination_content_entity_id'];
903
+						$destination_title = $day['destination_content_entity_id'];
904 904
 
905
-					    if(isset($destination_data[0]['name'])){
905
+						if(isset($destination_data[0]['name'])){
906 906
 							$destination_title = $destination_data[0]['name'];
907
-                        }
907
+						}
908 908
 
909
-					    if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
910
-                            && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
909
+						if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
910
+							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
911 911
 
912 912
 							$country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id);
913
-                        }
913
+						}
914 914
 
915
-                        $dest_post = array(
915
+						$dest_post = array(
916 916
 							'post_type' => 'destination',
917 917
 							'post_status' => 'draft',
918 918
 							'post_title' => $destination_title
919 919
 						);
920 920
 
921
-					    if(false !== $country_id){
921
+						if(false !== $country_id){
922 922
 							$dest_post['post_parent'] = $country_id;
923
-                        }
923
+						}
924 924
 						$dest_id = wp_insert_post($dest_post);
925 925
 
926 926
 						//Make sure we register the
@@ -939,20 +939,20 @@  discard block
 block discarded – undo
939 939
 				$this->queue_item($dest_id);
940 940
 
941 941
 				//Save the item to clean up the amount of connections.
942
-                $this->cleanup_posts[$dest_id] = 'tour_to_destination';
942
+				$this->cleanup_posts[$dest_id] = 'tour_to_destination';
943 943
 
944 944
 				// Save the first destination so we can grab the tour featured image and banner
945 945
 				if(0 === $leg_counter){
946
-				    $this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']);
947
-                }
946
+					$this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']);
947
+				}
948 948
 
949 949
 				//Add this relation info so we can make sure certain items are set as countries.
950 950
 				if(0 !== $country_id && false !== $country_id){
951
-                    $this->relation_meta[$dest_id] = $country_id;
951
+					$this->relation_meta[$dest_id] = $country_id;
952 952
 					$this->relation_meta[$country_id] = 0;
953
-                }else{
953
+				}else{
954 954
 					$this->relation_meta[$dest_id] = 0;
955
-                }
955
+				}
956 956
 			}
957 957
 		}
958 958
 		return $dest_id;
@@ -962,54 +962,54 @@  discard block
 block discarded – undo
962 962
 	 * Connects the destinations post type
963 963
 	 *
964 964
 	 * @param $dest_id string
965
-     * @param $country_id array
965
+	 * @param $country_id array
966 966
 	 * @param $id string
967
-     *
968
-     * @return string
967
+	 *
968
+	 * @return string
969 969
 	 */
970 970
 	public function set_country($country_wetu_id, $id) {
971
-	    $country_id = false;
971
+		$country_id = false;
972 972
 		$this->current_destinations = $this->find_current_destinations();
973 973
 
974
-        if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
975
-            $country_id = $this->current_destinations[$country_wetu_id];
976
-        } else {
974
+		if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
975
+			$country_id = $this->current_destinations[$country_wetu_id];
976
+		} else {
977 977
 
978
-            $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
978
+			$country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
979 979
 
980
-            if ($country_json) {
981
-                $country_data = json_decode($country_json, true);
980
+			if ($country_json) {
981
+				$country_data = json_decode($country_json, true);
982 982
 
983
-                if (!empty($country_data) && !isset($country_data['error'])) {
983
+				if (!empty($country_data) && !isset($country_data['error'])) {
984 984
 
985 985
 					//Format the title of the destination if its available,  otherwise default to the WETU ID.
986
-                    $country_title = $country_wetu_id;
987
-                    if (isset($country_data[0]['name'])) {
986
+					$country_title = $country_wetu_id;
987
+					if (isset($country_data[0]['name'])) {
988 988
 						$country_title = $country_data[0]['name'];
989
-                    }
989
+					}
990 990
 
991 991
 					$country_id = wp_insert_post(array(
992
-                        'post_type' => 'destination',
993
-                        'post_status' => 'draft',
994
-                        'post_title' => $country_title
995
-                    ));
992
+						'post_type' => 'destination',
993
+						'post_status' => 'draft',
994
+						'post_title' => $country_title
995
+					));
996 996
 					//add the country to the current destination stack
997 997
 					$this->current_destinations[$country_wetu_id] = $country_id;
998 998
 
999 999
 					//Save the wetu field
1000
-                    $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
1001
-                }
1002
-            }
1003
-        }
1004
-
1005
-        if ('' !== $country_id && false !== $country_id) {
1006
-            $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
1007
-            $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
1000
+					$this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
1001
+				}
1002
+			}
1003
+		}
1004
+
1005
+		if ('' !== $country_id && false !== $country_id) {
1006
+			$this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
1007
+			$this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
1008 1008
 			$this->queue_item($country_id);
1009 1009
 			$this->cleanup_posts[$country_id] = 'tour_to_destination';
1010 1010
 
1011
-            return $country_id;
1012
-        }
1011
+			return $country_id;
1012
+		}
1013 1013
 	}
1014 1014
 
1015 1015
 	/**
@@ -1022,9 +1022,9 @@  discard block
 block discarded – undo
1022 1022
 	 * @return string
1023 1023
 	 */
1024 1024
 	public function attach_destination_images($importable_content=array()) {
1025
-	    if(false !== $this->destination_images){
1025
+		if(false !== $this->destination_images){
1026 1026
 
1027
-	        foreach($this->destination_images as $tour => $destination){
1027
+			foreach($this->destination_images as $tour => $destination){
1028 1028
 
1029 1029
 				$url = 'https://wetu.com/API/Pins/' . $this->api_key;
1030 1030
 				$url_qs = '';
@@ -1045,8 +1045,8 @@  discard block
 block discarded – undo
1045 1045
 						}
1046 1046
 					}
1047 1047
 				}
1048
-            }
1049
-        }
1048
+			}
1049
+		}
1050 1050
 	}
1051 1051
 
1052 1052
 	/**
Please login to merge, or discard this patch.
classes/class-importer.php 1 patch
Indentation   +35 added lines, -35 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){
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 	 * Run through the accommodation grabbed from the DB.
1041 1041
 	 */
1042 1042
 	public function process_ajax_search() {
1043
-	    $this->current_importer->process_ajax_search();
1043
+		$this->current_importer->process_ajax_search();
1044 1044
 		die();
1045 1045
 	}
1046 1046
 
Please login to merge, or discard this patch.