Completed
Push — master ( 4fede3...f4022d )
by Warwick
03:05
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'];
@@ -455,16 +455,16 @@  discard block
 block discarded – undo
455 455
 				$content = false;
456 456
 			}
457 457
 
458
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
459
-            if($jdata)
460
-            {
461
-                $adata=json_decode($jdata,true);
462
-                if(!empty($adata))
463
-                {
464
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
465
-                	$this->format_completed_row($return);
466
-                }
467
-            }
458
+			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
459
+			if($jdata)
460
+			{
461
+				$adata=json_decode($jdata,true);
462
+				if(!empty($adata))
463
+				{
464
+					$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
465
+					$this->format_completed_row($return);
466
+				}
467
+			}
468 468
 
469 469
 			die();
470 470
 		}
@@ -476,82 +476,82 @@  discard block
 block discarded – undo
476 476
 	 */
477 477
 	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
478 478
 
479
-        if(trim($data[0]['type'])=='Destination')
480
-        {
481
-	        $post_name = $data_post_content = $data_post_excerpt = '';
482
-	        $post = array(
483
-	          'post_type'		=> 'destination',
484
-	        );
485
-
486
-	        $content_used_general_description = false;
487
-
488
-	        //Set the post_content
489
-	        if(false !== $importable_content && in_array('description',$importable_content)){
490
-		        if(isset($data[0]['content']['extended_description']))
491
-		        {
492
-		            $data_post_content = $data[0]['content']['extended_description'];
493
-		        }elseif(isset($data[0]['content']['general_description'])){
494
-		            $data_post_content = $data[0]['content']['general_description'];
495
-		            $content_used_general_description = true;
496
-		        }elseif(isset($data[0]['content']['teaser_description'])){
497
-		        	$data_post_content = $data[0]['content']['teaser_description'];
498
-		        }
499
-	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
500
-	        }
501
-
502
-	        //set the post_excerpt
503
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
504
-		        if(isset($data[0]['content']['teaser_description'])){
505
-		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
506
-		        }elseif(isset($data[0]['content']['extended_description'])){
479
+		if(trim($data[0]['type'])=='Destination')
480
+		{
481
+			$post_name = $data_post_content = $data_post_excerpt = '';
482
+			$post = array(
483
+			  'post_type'		=> 'destination',
484
+			);
485
+
486
+			$content_used_general_description = false;
487
+
488
+			//Set the post_content
489
+			if(false !== $importable_content && in_array('description',$importable_content)){
490
+				if(isset($data[0]['content']['extended_description']))
491
+				{
492
+					$data_post_content = $data[0]['content']['extended_description'];
493
+				}elseif(isset($data[0]['content']['general_description'])){
494
+					$data_post_content = $data[0]['content']['general_description'];
495
+					$content_used_general_description = true;
496
+				}elseif(isset($data[0]['content']['teaser_description'])){
497
+					$data_post_content = $data[0]['content']['teaser_description'];
498
+				}
499
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
500
+			}
501
+
502
+			//set the post_excerpt
503
+			if(false !== $importable_content && in_array('excerpt',$importable_content)){
504
+				if(isset($data[0]['content']['teaser_description'])){
505
+					$data_post_excerpt = $data[0]['content']['teaser_description'];
506
+				}elseif(isset($data[0]['content']['extended_description'])){
507 507
 					$data_post_excerpt = $data[0]['content']['extended_description'];
508 508
 				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
509
-		            $data_post_excerpt = $data[0]['content']['general_description'];
510
-		        }	   
511
-		        $post['post_excerpt'] = $data_post_excerpt;     	
512
-	        }
509
+					$data_post_excerpt = $data[0]['content']['general_description'];
510
+				}	   
511
+				$post['post_excerpt'] = $data_post_excerpt;     	
512
+			}
513 513
 
514
-	        if(false !== $id && '0' !== $id){
515
-	        	$post['ID'] = $id;
514
+			if(false !== $id && '0' !== $id){
515
+				$post['ID'] = $id;
516 516
 				if(isset($data[0]['name'])){
517 517
 					$post['post_title'] = $data[0]['name'];
518 518
 					$post['post_status'] = 'publish';
519 519
 					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
520 520
 				}
521
-	        	$id = wp_update_post($post);
522
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
523
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
524
-	        }else{
525
-
526
-		        //Set the name
527
-		        if(isset($data[0]['name'])){
528
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
529
-		        }
530
-	        	$post['post_name'] = $post_name;
531
-	        	$post['post_title'] = $data[0]['name'];
532
-	        	$post['post_status'] = 'publish';
533
-	        	$id = wp_insert_post($post);
534
-
535
-	        	//Save the WETU ID and the Last date it was modified.
536
-	        	if(false !== $id){
537
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
538
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
539
-	        	}
540
-	        }
541
-
542
-	        //Set the team member if it is there
543
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
544
-	        	$this->set_team_member($id,$team_members);
545
-	    	}
546
-
547
-	        if(class_exists('LSX_TO_Maps')){
548
-	        	$this->set_map_data($data,$id,4);
549
-	        }
550
-
551
-	        //Set the Room Data
552
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
553
-	        	$this->set_video_data($data,$id);
554
-	    	}
521
+				$id = wp_update_post($post);
522
+				$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
523
+				update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
524
+			}else{
525
+
526
+				//Set the name
527
+				if(isset($data[0]['name'])){
528
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'destination', 0);
529
+				}
530
+				$post['post_name'] = $post_name;
531
+				$post['post_title'] = $data[0]['name'];
532
+				$post['post_status'] = 'publish';
533
+				$id = wp_insert_post($post);
534
+
535
+				//Save the WETU ID and the Last date it was modified.
536
+				if(false !== $id){
537
+					add_post_meta($id,'lsx_wetu_id',$wetu_id);
538
+					add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
539
+				}
540
+			}
541
+
542
+			//Set the team member if it is there
543
+			if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
544
+				$this->set_team_member($id,$team_members);
545
+			}
546
+
547
+			if(class_exists('LSX_TO_Maps')){
548
+				$this->set_map_data($data,$id,4);
549
+			}
550
+
551
+			//Set the Room Data
552
+			if(false !== $importable_content && in_array('videos',$importable_content)){
553
+				$this->set_video_data($data,$id);
554
+			}
555 555
 
556 556
 			//Set the Electricity
557 557
 			if(false !== $importable_content && in_array('electricity',$importable_content)){
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 			}
597 597
 
598 598
 		}
599
-        return $id;
599
+		return $id;
600 600
 	}
601 601
 
602 602
 	/**
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 
607 607
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
608 608
 		foreach($team_members as $team){
609
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
609
+			add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
610 610
 		}
611 611
 	}
612 612
 	
@@ -657,11 +657,11 @@  discard block
 block discarded – undo
657 657
 				'elevation'	=>	'',
658 658
 			);
659 659
 			if(false !== $id && '0' !== $id){
660
-	        	$prev = get_post_meta($id,'location',true);
661
-	        	update_post_meta($id,'location',$location_data,$prev);
662
-	        }else{
663
-	        	add_post_meta($id,'location',$location_data,true);
664
-	        }
660
+				$prev = get_post_meta($id,'location',true);
661
+				update_post_meta($id,'location',$location_data,$prev);
662
+			}else{
663
+				add_post_meta($id,'location',$location_data,true);
664
+			}
665 665
 		}
666 666
 	}
667 667
 
Please login to merge, or discard this patch.