Completed
Push — master ( 57ccf2...ddd6e9 )
by Warwick
15:53
created
classes/class-destination.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * Display the importer administration screen
105 105
 	 */
106 106
 	public function display_page() {
107
-        ?>
107
+		?>
108 108
         <div class="wrap">
109 109
             <?php screen_icon(); ?>
110 110
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 					$keyphrases = $_POST['keyword'];
330 330
 				}else{
331 331
 					$keyphrases = array(0);
332
-                }
332
+				}
333 333
 
334 334
 				if(!is_array($keyphrases)){
335 335
 					$keyphrases = array($keyphrases);
@@ -358,11 +358,11 @@  discard block
 block discarded – undo
358 358
 						//If we are searching for
359 359
 						if(false !== $post_status){
360 360
 
361
-                            $current_status = get_post_status($row->post_id);
362
-                            if($current_status !== $post_status){
363
-                                continue;
364
-                            }
365
-                            $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
361
+							$current_status = get_post_status($row->post_id);
362
+							if($current_status !== $post_status){
363
+								continue;
364
+							}
365
+							$searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
366 366
 
367 367
 
368 368
 						}else{
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 				$team_members = false;
445 445
 			}
446 446
 
447
-            $safari_brands = false;
447
+			$safari_brands = false;
448 448
 
449 449
 			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
450 450
 				$content = $_POST['content'];
@@ -454,16 +454,16 @@  discard block
 block discarded – undo
454 454
 				$content = false;
455 455
 			}
456 456
 
457
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
458
-            if($jdata)
459
-            {
460
-                $adata=json_decode($jdata,true);
461
-                if(!empty($adata))
462
-                {
463
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
464
-                	$this->format_completed_row($return);
465
-                }
466
-            }
457
+			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
458
+			if($jdata)
459
+			{
460
+				$adata=json_decode($jdata,true);
461
+				if(!empty($adata))
462
+				{
463
+					$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
464
+					$this->format_completed_row($return);
465
+				}
466
+			}
467 467
 
468 468
 			die();
469 469
 		}
@@ -475,82 +475,82 @@  discard block
 block discarded – undo
475 475
 	 */
476 476
 	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
477 477
 
478
-        if(trim($data[0]['type'])=='Destination')
479
-        {
480
-	        $post_name = $data_post_content = $data_post_excerpt = '';
481
-	        $post = array(
482
-	          'post_type'		=> 'destination',
483
-	        );
484
-
485
-	        $content_used_general_description = false;
486
-
487
-	        //Set the post_content
488
-	        if(false !== $importable_content && in_array('description',$importable_content)){
489
-		        if(isset($data[0]['content']['extended_description']))
490
-		        {
491
-		            $data_post_content = $data[0]['content']['extended_description'];
492
-		        }elseif(isset($data[0]['content']['general_description'])){
493
-		            $data_post_content = $data[0]['content']['general_description'];
494
-		            $content_used_general_description = true;
495
-		        }elseif(isset($data[0]['content']['teaser_description'])){
496
-		        	$data_post_content = $data[0]['content']['teaser_description'];
497
-		        }
498
-	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
499
-	        }
500
-
501
-	        //set the post_excerpt
502
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
503
-		        if(isset($data[0]['content']['teaser_description'])){
504
-		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
505
-		        }elseif(isset($data[0]['content']['extended_description'])){
478
+		if(trim($data[0]['type'])=='Destination')
479
+		{
480
+			$post_name = $data_post_content = $data_post_excerpt = '';
481
+			$post = array(
482
+			  'post_type'		=> 'destination',
483
+			);
484
+
485
+			$content_used_general_description = false;
486
+
487
+			//Set the post_content
488
+			if(false !== $importable_content && in_array('description',$importable_content)){
489
+				if(isset($data[0]['content']['extended_description']))
490
+				{
491
+					$data_post_content = $data[0]['content']['extended_description'];
492
+				}elseif(isset($data[0]['content']['general_description'])){
493
+					$data_post_content = $data[0]['content']['general_description'];
494
+					$content_used_general_description = true;
495
+				}elseif(isset($data[0]['content']['teaser_description'])){
496
+					$data_post_content = $data[0]['content']['teaser_description'];
497
+				}
498
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
499
+			}
500
+
501
+			//set the post_excerpt
502
+			if(false !== $importable_content && in_array('excerpt',$importable_content)){
503
+				if(isset($data[0]['content']['teaser_description'])){
504
+					$data_post_excerpt = $data[0]['content']['teaser_description'];
505
+				}elseif(isset($data[0]['content']['extended_description'])){
506 506
 					$data_post_excerpt = $data[0]['content']['extended_description'];
507 507
 				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
508
-		            $data_post_excerpt = $data[0]['content']['general_description'];
509
-		        }	   
510
-		        $post['post_excerpt'] = $data_post_excerpt;     	
511
-	        }
508
+					$data_post_excerpt = $data[0]['content']['general_description'];
509
+				}	   
510
+				$post['post_excerpt'] = $data_post_excerpt;     	
511
+			}
512 512
 
513
-	        if(false !== $id && '0' !== $id){
514
-	        	$post['ID'] = $id;
513
+			if(false !== $id && '0' !== $id){
514
+				$post['ID'] = $id;
515 515
 				if(isset($data[0]['name'])){
516 516
 					$post['post_title'] = $data[0]['name'];
517 517
 					$post['post_status'] = 'publish';
518 518
 					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
519 519
 				}
520
-	        	$id = wp_update_post($post);
521
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
522
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
523
-	        }else{
524
-
525
-		        //Set the name
526
-		        if(isset($data[0]['name'])){
527
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
528
-		        }
529
-	        	$post['post_name'] = $post_name;
530
-	        	$post['post_title'] = $data[0]['name'];
531
-	        	$post['post_status'] = 'publish';
532
-	        	$id = wp_insert_post($post);
533
-
534
-	        	//Save the WETU ID and the Last date it was modified.
535
-	        	if(false !== $id){
536
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
537
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
538
-	        	}
539
-	        }
540
-
541
-	        //Set the team member if it is there
542
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
543
-	        	$this->set_team_member($id,$team_members);
544
-	    	}
545
-
546
-	        if(class_exists('LSX_TO_Maps')){
547
-	        	$this->set_map_data($data,$id);
548
-	        }
549
-
550
-	        //Set the Room Data
551
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
552
-	        	$this->set_video_data($data,$id);
553
-	    	}
520
+				$id = wp_update_post($post);
521
+				$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
522
+				update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
523
+			}else{
524
+
525
+				//Set the name
526
+				if(isset($data[0]['name'])){
527
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
528
+				}
529
+				$post['post_name'] = $post_name;
530
+				$post['post_title'] = $data[0]['name'];
531
+				$post['post_status'] = 'publish';
532
+				$id = wp_insert_post($post);
533
+
534
+				//Save the WETU ID and the Last date it was modified.
535
+				if(false !== $id){
536
+					add_post_meta($id,'lsx_wetu_id',$wetu_id);
537
+					add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
538
+				}
539
+			}
540
+
541
+			//Set the team member if it is there
542
+			if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
543
+				$this->set_team_member($id,$team_members);
544
+			}
545
+
546
+			if(class_exists('LSX_TO_Maps')){
547
+				$this->set_map_data($data,$id);
548
+			}
549
+
550
+			//Set the Room Data
551
+			if(false !== $importable_content && in_array('videos',$importable_content)){
552
+				$this->set_video_data($data,$id);
553
+			}
554 554
 
555 555
 			//Set the Electricity
556 556
 			if(false !== $importable_content && in_array('electricity',$importable_content)){
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 				$this->create_main_gallery($data,$id);
590 590
 			}
591 591
 		}
592
-        return $id;
592
+		return $id;
593 593
 	}
594 594
 
595 595
 	/**
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 
600 600
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
601 601
 		foreach($team_members as $team){
602
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
602
+			add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
603 603
 		}
604 604
 	}
605 605
 	
@@ -651,11 +651,11 @@  discard block
 block discarded – undo
651 651
 				'elevation'	=>	'',
652 652
 			);
653 653
 			if(false !== $id && '0' !== $id){
654
-	        	$prev = get_post_meta($id,'location',true);
655
-	        	update_post_meta($id,'location',$location_data,$prev);
656
-	        }else{
657
-	        	add_post_meta($id,'location',$location_data,true);
658
-	        }
654
+				$prev = get_post_meta($id,'location',true);
655
+				update_post_meta($id,'location',$location_data,$prev);
656
+			}else{
657
+				add_post_meta($id,'location',$location_data,true);
658
+			}
659 659
 		}
660 660
 	}
661 661
 
Please login to merge, or discard this patch.