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