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