Completed
Push — master ( ef4c1a...1aafd8 )
by Warwick
07:18
created
classes/class-connect-accommodation.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -207,6 +207,7 @@
 block discarded – undo
207 207
 
208 208
 	/**
209 209
 	 * format the array
210
+	 * @param string $key
210 211
 	 */
211 212
 	public function format_array($array,$key){
212 213
 		$new_array = array();
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
 	 */
52 52
 	public function display_page() {
53 53
 		global $post;
54
-        ?>
54
+		?>
55 55
         <div class="wrap">
56 56
 
57 57
             <h3><span class="dashicons dashicons-admin-multisite"></span> <?php _e('Connect your Accommodation','wetu-importer'); ?></h3>
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 									foreach($accommodation as $row_key => $row){
94 94
 										if(stripos(ltrim(rtrim($row->name)), $post->post_title) !== false){
95 95
 											$identifier = $row->id;
96
-										}else{
96
+										} else{
97 97
 											continue;
98 98
 										}
99 99
 									}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 			//remove the extra accommodation
197 197
 			if(null !== $current_accommodation && !empty($current_accommodation)){
198 198
 				$all_accommodation = array_diff($this->format_array($all_accommodation,'ID'), $this->format_array($current_accommodation,'post_id'));
199
-			}elseif(null !== $current_accommodation && empty($current_accommodation)){
199
+			} elseif(null !== $current_accommodation && empty($current_accommodation)){
200 200
 				$all_accommodation = $this->format_array($current_accommodation,'post_id');
201 201
 			}
202 202
 
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -35,15 +35,15 @@  discard block
 block discarded – undo
35 35
 	 * @access private
36 36
 	 */
37 37
 	public function __construct() {
38
-		$temp_options = get_option('_lsx-to_settings',false);
39
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){
38
+		$temp_options = get_option('_lsx-to_settings', false);
39
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
40 40
 			$this->options = $temp_options[$this->plugin_slug];
41 41
 		}
42 42
 		$this->url = 'http://wetu.com/API/Pins/'.$this->options['api_key'].'/List';
43 43
 
44
-		add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') );
45
-		add_action('wp_ajax_lsx_import_connect_accommodation',array($this,'process_connection'));	
46
-		add_action('wp_ajax_nopriv_lsx_import_connect_accommodation',array($this,'process_connection'));
44
+		add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page'));
45
+		add_action('wp_ajax_lsx_import_connect_accommodation', array($this, 'process_connection'));	
46
+		add_action('wp_ajax_nopriv_lsx_import_connect_accommodation', array($this, 'process_connection'));
47 47
 	}	
48 48
 
49 49
 	/**
@@ -54,30 +54,30 @@  discard block
 block discarded – undo
54 54
         ?>
55 55
         <div class="wrap">
56 56
 
57
-            <h3><span class="dashicons dashicons-admin-multisite"></span> <?php _e('Connect your Accommodation','wetu-importer'); ?></h3>
57
+            <h3><span class="dashicons dashicons-admin-multisite"></span> <?php _e('Connect your Accommodation', 'wetu-importer'); ?></h3>
58 58
 
59 59
 			<form method="get" action="" id="connect-accommodation-filter">
60 60
 				<input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" />	
61 61
 
62
-				<p><?php _e('Below is a list of your accommodation that does not contain a WETU ID, but its Title matches a name in the WETU DB. Connecting it will all you to pull through information from WETU.','wetu-importer'); ?></p>
62
+				<p><?php _e('Below is a list of your accommodation that does not contain a WETU ID, but its Title matches a name in the WETU DB. Connecting it will all you to pull through information from WETU.', 'wetu-importer'); ?></p>
63 63
 
64 64
 	            <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
65
-	            	<img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
65
+	            	<img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
66 66
 	            </div>  
67 67
 
68 68
 				<?php
69 69
 					$loose_accommodation = $this->find_current_accommodation();
70 70
 				?>
71
-				<p><input class="button button-primary connect" type="button" value="<?php _e('Connect','wetu-importer'); ?>" /></p>
71
+				<p><input class="button button-primary connect" type="button" value="<?php _e('Connect', 'wetu-importer'); ?>" /></p>
72 72
 				<table class="wp-list-table widefat fixed posts">
73 73
 					<?php $this->table_header(); ?>
74 74
 				
75 75
 					<tbody>
76
-						<?php if(false !== $loose_accommodation){ 
76
+						<?php if (false !== $loose_accommodation) { 
77 77
 
78 78
 							$loose_args = array(
79 79
 								'post_type'=>'accommodation',
80
-								'post_status' => array('publish','pending'),
80
+								'post_status' => array('publish', 'pending'),
81 81
 								'nopagin' => true,
82 82
 								'post__in' => $loose_accommodation
83 83
 							);
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
 							$accommodation = get_transient('lsx_ti_accommodation');
86 86
 							$identifier = '';
87 87
 
88
-							if($loose_accommodation_query->have_posts() && false !== $accommodation){
89
-								while($loose_accommodation_query->have_posts()){
88
+							if ($loose_accommodation_query->have_posts() && false !== $accommodation) {
89
+								while ($loose_accommodation_query->have_posts()) {
90 90
 									$loose_accommodation_query->the_post();
91 91
 
92
-									foreach($accommodation as $row_key => $row){
93
-										if(stripos(ltrim(rtrim($row->name)), $post->post_title) !== false){
92
+									foreach ($accommodation as $row_key => $row) {
93
+										if (stripos(ltrim(rtrim($row->name)), $post->post_title) !== false) {
94 94
 											$identifier = $row->id;
95
-										}else{
95
+										}else {
96 96
 											continue;
97 97
 										}
98 98
 									}
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 
119 119
 				</table>
120 120
 
121
-				<p><input class="button button-primary connect" type="button" value="<?php _e('Connect','wetu-importer'); ?>" /></p>
121
+				<p><input class="button button-primary connect" type="button" value="<?php _e('Connect', 'wetu-importer'); ?>" /></p>
122 122
 
123 123
 			</form> 
124 124
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 					FROM {$wpdb->posts}	
180 180
 					WHERE post_type = 'accommodation'
181 181
 					LIMIT 0,500
182
-		",ARRAY_A);
182
+		", ARRAY_A);
183 183
 
184 184
 		$current_accommodation = $wpdb->get_results("
185 185
 					SELECT key1.post_id
@@ -192,14 +192,14 @@  discard block
 block discarded – undo
192 192
 					AND key2.post_type = 'accommodation'
193 193
 
194 194
 					LIMIT 0,500
195
-		",ARRAY_A);
195
+		", ARRAY_A);
196 196
 
197
-		if(null !== $all_accommodation && !empty($all_accommodation)){
197
+		if (null !== $all_accommodation && !empty($all_accommodation)) {
198 198
 			//remove the extra accommodation
199
-			if(null !== $current_accommodation && !empty($current_accommodation)){
200
-				$all_accommodation = array_diff($this->format_array($all_accommodation,'ID'), $this->format_array($current_accommodation,'post_id'));
201
-			}elseif(null !== $current_accommodation && empty($current_accommodation)){
202
-				$all_accommodation = $this->format_array($current_accommodation,'post_id');
199
+			if (null !== $current_accommodation && !empty($current_accommodation)) {
200
+				$all_accommodation = array_diff($this->format_array($all_accommodation, 'ID'), $this->format_array($current_accommodation, 'post_id'));
201
+			}elseif (null !== $current_accommodation && empty($current_accommodation)) {
202
+				$all_accommodation = $this->format_array($current_accommodation, 'post_id');
203 203
 			}
204 204
 
205 205
 			$return = $all_accommodation;
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 	/**
211 211
 	 * format the array
212 212
 	 */
213
-	public function format_array($array,$key){
213
+	public function format_array($array, $key) {
214 214
 		$new_array = array();
215
-		foreach($array as $value){
215
+		foreach ($array as $value) {
216 216
 			$new_array[] = $value[$key];
217 217
 		}
218 218
 		return $new_array;
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	public function process_connection() {
225 225
 		$return = false;
226 226
 
227
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_connect_accommodation' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['post_id']) && isset($_POST['wetu_id'])){
227
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_connect_accommodation' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['post_id']) && isset($_POST['wetu_id'])) {
228 228
 
229 229
 			$post_id = false;
230 230
 			$matching_id = false;
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 			$post_id = $_POST['post_id'];
233 233
 			$matching_id = $_POST['wetu_id'];			
234 234
 
235
-			add_post_meta($post_id,'lsx_wetu_id',$matching_id);
235
+			add_post_meta($post_id, 'lsx_wetu_id', $matching_id);
236 236
 			$return = '<li class="post-'.$post_id.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($post_id).'">'.get_the_title($post_id).'</a></li>';
237 237
 		}
238 238
 		print_r($return);
Please login to merge, or discard this patch.
classes/lsx-banners-integration.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -222,6 +222,9 @@
 block discarded – undo
222 222
 	  }
223 223
 	}	
224 224
 
225
+	/**
226
+	 * @param string $url
227
+	 */
225 228
 	public function attach_external_image2( $url = null, $post_data = array() ) {
226 229
 	
227 230
 		if ( !$url ) { return new WP_Error('missing', "Need a valid URL"); }
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * Display the importer administration screen
38 38
 	 */
39 39
 	public function display_page() {
40
-        ?>
40
+		?>
41 41
         <div class="wrap">
42 42
 			
43 43
             <h2><?php _e('Download new banners straight from WETU','wetu-importer'); ?></h2>
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
 		$base = rawurlencode($base);
212 212
 	  $type = get_post_mime_type($post_id);
213 213
 	  switch ($type) {
214
-	    case 'image/jpeg':
215
-	    	return $base . ".jpg"; break;
216
-	    case 'image/png':
217
-	    	return $base . ".png"; break;
218
-	    case 'image/gif':
219
-	      	return $base . ".gif"; break;
220
-	    default:
221
-	      return false;
214
+		case 'image/jpeg':
215
+			return $base . ".jpg"; break;
216
+		case 'image/png':
217
+			return $base . ".png"; break;
218
+		case 'image/gif':
219
+		  	return $base . ".gif"; break;
220
+		default:
221
+		  return false;
222 222
 	  }
223 223
 	}	
224 224
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
 				delete_post_meta($_POST['post_id'],'image_group');
187 187
 				add_post_meta($_POST['post_id'],'image_group',$new_banner_array,true);
188 188
 				echo true;
189
-			}else{
189
+			} else{
190 190
 				echo false;
191 191
 			}		
192 192
 
193
-		}else{
193
+		} else{
194 194
 			echo false;
195 195
 		}
196 196
 		die();
@@ -250,8 +250,7 @@  discard block
 block discarded – undo
250 250
 		if ( !empty( $filename) && " " != $filename )
251 251
 		{
252 252
 			$file_array['name'] = $filename . "." . $url_type['ext'];                           // user given filename for title, add original URL extension
253
-		}
254
-		else
253
+		} else
255 254
 		{
256 255
 			$file_array['name'] = $url_filename;                                                // just use original URL filename
257 256
 		}
Please login to merge, or discard this patch.
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public function __construct() {
29 29
 
30
-		add_action('wp_ajax_lsx_import_sync_banners',array($this,'sync_new_banner'));	
31
-		add_action('wp_ajax_nopriv_lsx_import_sync_banners',array($this,'sync_new_banner'));		
30
+		add_action('wp_ajax_lsx_import_sync_banners', array($this, 'sync_new_banner'));	
31
+		add_action('wp_ajax_nopriv_lsx_import_sync_banners', array($this, 'sync_new_banner'));		
32 32
 	}	
33 33
 
34 34
 	/**
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
         ?>
39 39
         <div class="wrap">
40 40
 			
41
-            <h2><?php _e('Download new banners straight from WETU','wetu-importer'); ?></h2>
41
+            <h2><?php _e('Download new banners straight from WETU', 'wetu-importer'); ?></h2>
42 42
 
43 43
 			<form method="get" action="" id="banners-filter">
44 44
 				<input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" />
45 45
 
46 46
 	           <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
47
-	            	<img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
47
+	            	<img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
48 48
 	            </div>  				
49 49
 				
50 50
 				<table class="wp-list-table widefat fixed posts">
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 					<?php 
63 63
 						$accommodation_args = array(
64 64
 							'post_type' => 'accommodation',
65
-							'post_status' => array('publish','pending','draft','future','private'),
65
+							'post_status' => array('publish', 'pending', 'draft', 'future', 'private'),
66 66
 							'nopagin' => 'true',
67 67
 							'posts_per_page' => '1000',
68 68
 							'meta_query' => array(
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 
88 88
 					<tbody id="the-list">
89 89
 						<?php
90
-							if($accommodation->have_posts()){ 
91
-								while($accommodation->have_posts()) {
90
+							if ($accommodation->have_posts()) { 
91
+								while ($accommodation->have_posts()) {
92 92
 									$accommodation->the_post();
93 93
 								?>
94 94
 								<tr class="post-<?php the_ID(); ?> type-tour status-none" id="post-<?php the_ID(); ?>">	
@@ -97,22 +97,22 @@  discard block
 block discarded – undo
97 97
 									$min_width = '1920';
98 98
 									$min_height = '500';
99 99
 
100
-									$img_group = get_post_meta(get_the_ID(),'image_group',true);
100
+									$img_group = get_post_meta(get_the_ID(), 'image_group', true);
101 101
 
102 102
 									$thumbnails_html = false;
103 103
 
104
-									if(false !== $img_group){
105
-										foreach($img_group['banner_image'] as $banner_image){
106
-											$large = wp_get_attachment_image_src($banner_image,'full');
104
+									if (false !== $img_group) {
105
+										foreach ($img_group['banner_image'] as $banner_image) {
106
+											$large = wp_get_attachment_image_src($banner_image, 'full');
107 107
 											$real_width = $large[1];
108 108
 											$real_height = $large[2];
109 109
 
110 110
 											$status = 'optimized';
111
-											if($real_width < intval($real_width)){
111
+											if ($real_width < intval($real_width)) {
112 112
 												$status = 'width not enough.';
113 113
 											}
114 114
 
115
-											$thumbnail = wp_get_attachment_image_src($banner_image,'thumbnail');
115
+											$thumbnail = wp_get_attachment_image_src($banner_image, 'thumbnail');
116 116
 											$thumbnails_html[] = '
117 117
 												<div style="display:block;float:left;">
118 118
 													<img src="'.$thumbnail[0].'" />
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
 										<input type="checkbox" data-identifier="<?php the_ID(); ?>" value="<?php the_ID(); ?>" name="post[]" id="cb-select-<?php the_ID(); ?>">
127 127
 									</th>
128 128
 
129
-									<td class="post-title page-title column-title"><?php echo '<a href="'.admin_url('/post.php?post='.get_the_ID().'&action=edit').'" target="_blank">';the_title(); echo '</a>'; ?></td>
129
+									<td class="post-title page-title column-title"><?php echo '<a href="'.admin_url('/post.php?post='.get_the_ID().'&action=edit').'" target="_blank">'; the_title(); echo '</a>'; ?></td>
130 130
 
131 131
 									<td colspan="2" class="thumbnails column-thumbnails">
132
-										<?php if(false !== $thumbnails_html){ echo implode('',$thumbnails_html); } else { echo '<p>There was an error retrieving your images.</p>'; } ?>
132
+										<?php if (false !== $thumbnails_html) { echo implode('', $thumbnails_html); }else { echo '<p>There was an error retrieving your images.</p>'; } ?>
133 133
 									</td>
134 134
 								</tr>
135 135
 						<?php 	}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
 				</table>
152 152
 
153
-				<p><input class="button button-primary download" type="button" value="<?php _e('Download new Banners','wetu-importer'); ?>" />
153
+				<p><input class="button button-primary download" type="button" value="<?php _e('Download new Banners', 'wetu-importer'); ?>" />
154 154
 				</p>
155 155
 			</form>
156 156
         </div>
@@ -162,33 +162,33 @@  discard block
 block discarded – undo
162 162
 	 */
163 163
 	public function sync_new_banner() {
164 164
 
165
-		if(isset($_POST['action']) && 'lsx_import_sync_banners' === $_POST['action'] && isset($_POST['post_id'])){
165
+		if (isset($_POST['action']) && 'lsx_import_sync_banners' === $_POST['action'] && isset($_POST['post_id'])) {
166 166
 
167
-			$banners = get_post_meta($_POST['post_id'],'image_group',true);
168
-			$this->wetu_id = get_post_meta($_POST['post_id'],'lsx_wetu_id',true);
167
+			$banners = get_post_meta($_POST['post_id'], 'image_group', true);
168
+			$this->wetu_id = get_post_meta($_POST['post_id'], 'lsx_wetu_id', true);
169 169
 
170 170
 			$new_banner_array = false;
171 171
 			$array_index = 0;
172 172
 
173 173
 
174 174
 
175
-			foreach($banners['banner_image'] as $banner_image){
175
+			foreach ($banners['banner_image'] as $banner_image) {
176 176
 				$image_id = $this->attach_external_image2($this->format_wetu_url($banner_image));
177
-				if(null !== $image_id && '' !== $image_id){
177
+				if (null !== $image_id && '' !== $image_id) {
178 178
 					$new_banner_array['banner_image']['cmb-field-'.$array_index] = $image_id;
179 179
 					$array_index++;
180 180
 				}
181 181
 			}
182 182
 
183
-			if(false !== $new_banner_array){
184
-				delete_post_meta($_POST['post_id'],'image_group');
185
-				add_post_meta($_POST['post_id'],'image_group',$new_banner_array,true);
183
+			if (false !== $new_banner_array) {
184
+				delete_post_meta($_POST['post_id'], 'image_group');
185
+				add_post_meta($_POST['post_id'], 'image_group', $new_banner_array, true);
186 186
 				echo true;
187
-			}else{
187
+			}else {
188 188
 				echo false;
189 189
 			}		
190 190
 
191
-		}else{
191
+		}else {
192 192
 			echo false;
193 193
 		}
194 194
 		die();
@@ -205,28 +205,28 @@  discard block
 block discarded – undo
205 205
 	 * formats the filename
206 206
 	 */
207 207
 	public function format_filename($post_id) {
208
-		$base = str_replace('_',' ',get_the_title($post_id));
208
+		$base = str_replace('_', ' ', get_the_title($post_id));
209 209
 		$base = rawurlencode($base);
210 210
 	  $type = get_post_mime_type($post_id);
211 211
 	  switch ($type) {
212 212
 	    case 'image/jpeg':
213
-	    	return $base . ".jpg"; break;
213
+	    	return $base.".jpg"; break;
214 214
 	    case 'image/png':
215
-	    	return $base . ".png"; break;
215
+	    	return $base.".png"; break;
216 216
 	    case 'image/gif':
217
-	      	return $base . ".gif"; break;
217
+	      	return $base.".gif"; break;
218 218
 	    default:
219 219
 	      return false;
220 220
 	  }
221 221
 	}	
222 222
 
223
-	public function attach_external_image2( $url = null, $post_data = array() ) {
223
+	public function attach_external_image2($url = null, $post_data = array()) {
224 224
 	
225
-		if ( !$url ) { return new WP_Error('missing', "Need a valid URL"); }
225
+		if (!$url) { return new WP_Error('missing', "Need a valid URL"); }
226 226
 
227
-		require_once(ABSPATH . 'wp-admin/includes/file.php');
228
-		require_once(ABSPATH . 'wp-admin/includes/media.php');
229
-		require_once(ABSPATH . 'wp-admin/includes/image.php');
227
+		require_once(ABSPATH.'wp-admin/includes/file.php');
228
+		require_once(ABSPATH.'wp-admin/includes/media.php');
229
+		require_once(ABSPATH.'wp-admin/includes/image.php');
230 230
 
231 231
 		//var_dump($tmp);
232 232
 		$tmp = tempnam("/tmp", "FOO");
@@ -234,37 +234,37 @@  discard block
 block discarded – undo
234 234
 		$image = file_get_contents($url);
235 235
 		print_r($image);
236 236
 		file_put_contents($tmp, $image);
237
-		chmod($tmp,'777');
237
+		chmod($tmp, '777');
238 238
 
239
-		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
239
+		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
240 240
 		$url_filename = basename($matches[0]);
241
-		$url_filename=str_replace('%20','_',$url_filename);
241
+		$url_filename = str_replace('%20', '_', $url_filename);
242 242
 		// extract filename from url for title
243
-		$url_type = wp_check_filetype($url_filename);                                           // determine file type (ext and mime/type)
243
+		$url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type)
244 244
 
245 245
 		// assemble file data (should be built like $_FILES since wp_handle_sideload() will be using)
246
-		$file_array['tmp_name'] = $tmp;                                                         // full server path to temp file
246
+		$file_array['tmp_name'] = $tmp; // full server path to temp file
247 247
 
248
-		if ( !empty( $filename) && " " != $filename )
248
+		if (!empty($filename) && " " != $filename)
249 249
 		{
250
-			$file_array['name'] = $filename . "." . $url_type['ext'];                           // user given filename for title, add original URL extension
250
+			$file_array['name'] = $filename.".".$url_type['ext']; // user given filename for title, add original URL extension
251 251
 		}
252 252
 		else
253 253
 		{
254
-			$file_array['name'] = $url_filename;                                                // just use original URL filename
254
+			$file_array['name'] = $url_filename; // just use original URL filename
255 255
 		}
256 256
 
257 257
 		// set additional wp_posts columns
258
-		if ( empty( $post_data['post_title'] ) )
258
+		if (empty($post_data['post_title']))
259 259
 		{
260 260
 
261
-			$url_filename=str_replace('%20',' ',$url_filename);
261
+			$url_filename = str_replace('%20', ' ', $url_filename);
262 262
 
263
-			$post_data['post_title'] = basename($url_filename, "." . $url_type['ext']);         // just use the original filename (no extension)
263
+			$post_data['post_title'] = basename($url_filename, ".".$url_type['ext']); // just use the original filename (no extension)
264 264
 		}
265 265
 
266 266
 		// make sure gets tied to parent
267
-		if ( empty( $post_data['post_parent'] ) )
267
+		if (empty($post_data['post_parent']))
268 268
 		{
269 269
 			$post_data['post_parent'] = $_POST['post_id'];
270 270
 		}
@@ -272,12 +272,12 @@  discard block
 block discarded – undo
272 272
 		// required libraries for media_handle_sideload
273 273
 
274 274
 		// do the validation and storage stuff
275
-		$att_id = media_handle_sideload( $file_array, $_POST['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
275
+		$att_id = media_handle_sideload($file_array, $_POST['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
276 276
 		 
277 277
 		// If error storing permanently, unlink
278
-		if ( is_wp_error($att_id) )
278
+		if (is_wp_error($att_id))
279 279
 		{
280
-			unlink($file_array['tmp_name']);   // clean up
280
+			unlink($file_array['tmp_name']); // clean up
281 281
 			return false; // output wp_error
282 282
 			//return $att_id; // output wp_error
283 283
 		}
Please login to merge, or discard this patch.
classes/class-settings.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -17,24 +17,24 @@  discard block
 block discarded – undo
17 17
 	 * @access private
18 18
 	 */
19 19
 	public function __construct() {
20
-		$temp_options = get_option('_lsx-to_settings',false);
21
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){
20
+		$temp_options = get_option('_lsx-to_settings', false);
21
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
22 22
 			$this->options = $temp_options[$this->plugin_slug];
23 23
 			$this->set_variables();
24 24
 		}
25 25
 
26
-		add_filter( 'lsx_to_framework_settings_tabs', array( $this, 'settings_page_array') );
27
-		add_action('lsx_to_framework_api_tab_content',array( $this, 'api_settings'),10,1);
26
+		add_filter('lsx_to_framework_settings_tabs', array($this, 'settings_page_array'));
27
+		add_action('lsx_to_framework_api_tab_content', array($this, 'api_settings'), 10, 1);
28 28
 	}
29 29
 
30 30
 	/**
31 31
 	 * Returns the array of settings to the UIX Class in the lsx framework
32 32
 	 */
33
-	public function settings_page_array($tabs){
33
+	public function settings_page_array($tabs) {
34 34
 		$tabs[$this->plugin_slug] = array(
35
-			'page_title'        => __('Image Scaling','wetu-importer'),
36
-			'page_description'  => __('','wetu-importer'),
37
-			'menu_title'        => __('Importer','wetu-importer'),
35
+			'page_title'        => __('Image Scaling', 'wetu-importer'),
36
+			'page_description'  => __('', 'wetu-importer'),
37
+			'menu_title'        => __('Importer', 'wetu-importer'),
38 38
 			'template'          => WETU_IMPORTER_PATH.'settings/wetu.php',
39 39
 			'default'	 		=> false
40 40
 		);
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
 	/**
45 45
 	 * Adds the API key to the API Tab
46 46
 	 */
47
-	public function api_settings($tab='general') {
48
-		if('settings' === $tab){ ?>
47
+	public function api_settings($tab = 'general') {
48
+		if ('settings' === $tab) { ?>
49 49
 			<tr class="form-field-wrap">
50 50
 				<th class="tour-operator_table_heading" style="padding-bottom:0px;" scope="row" colspan="2">
51
-					<h4 style="margin-bottom:0px;"><span><?php _e( 'WETU API', 'wetu-importer' ); ?></span></h4>
51
+					<h4 style="margin-bottom:0px;"><span><?php _e('WETU API', 'wetu-importer'); ?></span></h4>
52 52
 				</th>
53 53
 			</tr>
54 54
 			<tr class="form-field">
55 55
 				<th scope="row">
56
-                    <i class="dashicons-before dashicons-admin-network"></i> <label for="wetu_api_key"> <?php _e( 'Key', 'wetu-importer' ); ?></label>
56
+                    <i class="dashicons-before dashicons-admin-network"></i> <label for="wetu_api_key"> <?php _e('Key', 'wetu-importer'); ?></label>
57 57
 				</th>
58 58
 				<td>
59 59
                     <input type="text" {{#if wetu_api_key}} value="{{wetu_api_key}}" {{/if}} name="wetu_api_key" />
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 			</tr>
62 62
 			<tr class="form-field">
63 63
 				<th scope="row">
64
-                    <i class="dashicons-before dashicons-admin-users"></i> <label for="wetu_api_username"> <?php _e( 'Username', 'wetu-importer' ); ?></label>
64
+                    <i class="dashicons-before dashicons-admin-users"></i> <label for="wetu_api_username"> <?php _e('Username', 'wetu-importer'); ?></label>
65 65
 				</th>
66 66
 				<td>
67 67
                     <input type="text" {{#if wetu_api_username}} value="{{wetu_api_username}}" {{/if}} name="wetu_api_username" />
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 			</tr>
70 70
 			<tr class="form-field">
71 71
 				<th scope="row">
72
-                    <i class="dashicons-before dashicons-lock"></i> <label for="wetu_api_password"> <?php _e( 'Password', 'wetu-importer' ); ?></label>
72
+                    <i class="dashicons-before dashicons-lock"></i> <label for="wetu_api_password"> <?php _e('Password', 'wetu-importer'); ?></label>
73 73
 				</th>
74 74
 				<td>
75 75
                     <input type="text" {{#if wetu_api_password}} value="{{wetu_api_password}}" {{/if}} name="wetu_api_password" />
Please login to merge, or discard this patch.
classes/class-accommodation.php 4 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -584,6 +584,7 @@  discard block
 block discarded – undo
584 584
 
585 585
 	/**
586 586
 	 * Set the team memberon each item.
587
+	 * @param boolean $team_members
587 588
 	 */
588 589
 	public function set_team_member($id,$team_members) {
589 590
 
@@ -595,6 +596,7 @@  discard block
 block discarded – undo
595 596
 
596 597
 	/**
597 598
 	 * Set the safari brand
599
+	 * @param boolean $safari_brands
598 600
 	 */
599 601
 	public function set_safari_brands($id,$safari_brands) {
600 602
 		foreach($safari_brands as $safari_brand){
Please login to merge, or discard this patch.
Indentation   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	public function set_variables()
72 72
 	{
73
-	    parent::set_variables();
73
+		parent::set_variables();
74 74
 		// ** This request only works with API KEY **
75 75
 		//if ( false !== $this->api_username && false !== $this->api_password ) {
76 76
 		//	$this->url    = 'https://wetu.com/API/Pins/';
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * Display the importer administration screen
96 96
 	 */
97 97
 	public function display_page() {
98
-        ?>
98
+		?>
99 99
         <div class="wrap">
100 100
             <?php $this->navigation('accommodation'); ?>
101 101
 
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 		$accommodation = json_decode($data, true);
237 237
 
238 238
 		if(isset($accommodation['error'])){
239
-		    return $accommodation['error'];
240
-        }elseif (isset($accommodation) && !empty($accommodation)) {
239
+			return $accommodation['error'];
240
+		}elseif (isset($accommodation) && !empty($accommodation)) {
241 241
 			set_transient('lsx_ti_accommodation',$accommodation,60*60*2);
242 242
 			return true;
243 243
 		}
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 			$accommodation = get_transient('lsx_ti_accommodation');
254 254
 
255 255
 			if(false === $accommodation){
256
-			    $this->update_options();
257
-            }
256
+				$this->update_options();
257
+			}
258 258
 
259 259
 			if ( false !== $accommodation ) {
260 260
 				$searched_items = false;
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 					$keyphrases = $_POST['keyword'];
264 264
 				}else{
265 265
 					$keyphrases = array(0);
266
-                }
266
+				}
267 267
 
268 268
 				if(!is_array($keyphrases)){
269 269
 					$keyphrases = array($keyphrases);
@@ -420,17 +420,17 @@  discard block
 block discarded – undo
420 420
 				$content = false;
421 421
 			}
422 422
 
423
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
424
-            if($jdata)
425
-            {
426
-                $adata=json_decode($jdata,true);
427
-                if(!empty($adata))
428
-                {
429
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
430
-                	$this->format_completed_row($return);
423
+			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
424
+			if($jdata)
425
+			{
426
+				$adata=json_decode($jdata,true);
427
+				if(!empty($adata))
428
+				{
429
+					$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
430
+					$this->format_completed_row($return);
431 431
 					$this->cleanup_posts();
432
-                }
433
-            }
432
+				}
433
+			}
434 434
 		}
435 435
 	}
436 436
 
@@ -439,147 +439,147 @@  discard block
 block discarded – undo
439 439
 	 */
440 440
 	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
441 441
 
442
-        if(trim($data[0]['type'])=='Accommodation')
443
-        {
444
-	        $post_name = $data_post_content = $data_post_excerpt = '';
445
-	        $post = array(
446
-	          'post_type'		=> 'accommodation',
447
-	        );
448
-
449
-	        $content_used_general_description = false;
450
-
451
-	        //Set the post_content
452
-	        if(false !== $importable_content && in_array('description',$importable_content)){
453
-		        if(isset($data[0]['content']['extended_description']))
454
-		        {
455
-		            $data_post_content = $data[0]['content']['extended_description'];
456
-		        }elseif(isset($data[0]['content']['general_description'])){
457
-		            $data_post_content = $data[0]['content']['general_description'];
458
-		            $content_used_general_description = true;
459
-		        }elseif(isset($data[0]['content']['teaser_description'])){
460
-		        	$data_post_content = $data[0]['content']['teaser_description'];
461
-		        }
462
-	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
463
-	        }
464
-
465
-	        //set the post_excerpt
466
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
467
-		        if(isset($data[0]['content']['teaser_description'])){
468
-		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
469
-		        }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
470
-		            $data_post_excerpt = $data[0]['content']['general_description'];
471
-		        }	   
472
-		        $post['post_excerpt'] = $data_post_excerpt;     	
473
-	        }
474
-
475
-	        if(false !== $id && '0' !== $id){
476
-	        	$post['ID'] = $id;
442
+		if(trim($data[0]['type'])=='Accommodation')
443
+		{
444
+			$post_name = $data_post_content = $data_post_excerpt = '';
445
+			$post = array(
446
+			  'post_type'		=> 'accommodation',
447
+			);
448
+
449
+			$content_used_general_description = false;
450
+
451
+			//Set the post_content
452
+			if(false !== $importable_content && in_array('description',$importable_content)){
453
+				if(isset($data[0]['content']['extended_description']))
454
+				{
455
+					$data_post_content = $data[0]['content']['extended_description'];
456
+				}elseif(isset($data[0]['content']['general_description'])){
457
+					$data_post_content = $data[0]['content']['general_description'];
458
+					$content_used_general_description = true;
459
+				}elseif(isset($data[0]['content']['teaser_description'])){
460
+					$data_post_content = $data[0]['content']['teaser_description'];
461
+				}
462
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
463
+			}
464
+
465
+			//set the post_excerpt
466
+			if(false !== $importable_content && in_array('excerpt',$importable_content)){
467
+				if(isset($data[0]['content']['teaser_description'])){
468
+					$data_post_excerpt = $data[0]['content']['teaser_description'];
469
+				}elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
470
+					$data_post_excerpt = $data[0]['content']['general_description'];
471
+				}	   
472
+				$post['post_excerpt'] = $data_post_excerpt;     	
473
+			}
474
+
475
+			if(false !== $id && '0' !== $id){
476
+				$post['ID'] = $id;
477 477
 				if(isset($data[0]['name'])){
478 478
 					$post['post_title'] = $data[0]['name'];
479
-	        		$post['post_status'] = 'publish';
479
+					$post['post_status'] = 'publish';
480 480
 					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
481 481
 				}
482
-	        	$id = wp_update_post($post);
483
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
484
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
485
-	        }else{
486
-
487
-		        //Set the name
488
-		        if(isset($data[0]['name'])){
489
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
490
-		        }
491
-	        	$post['post_name'] = $post_name;
492
-	        	$post['post_title'] = $data[0]['name'];
493
-	        	$post['post_status'] = 'publish';
494
-	        	$id = wp_insert_post($post);
495
-
496
-	        	//Save the WETU ID and the Last date it was modified.
497
-	        	if(false !== $id){
498
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
499
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
500
-	        	}
501
-	        }
502
-	        //Setup some default for use in the import
503
-	        if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
482
+				$id = wp_update_post($post);
483
+				$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
484
+				update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
485
+			}else{
486
+
487
+				//Set the name
488
+				if(isset($data[0]['name'])){
489
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
490
+				}
491
+				$post['post_name'] = $post_name;
492
+				$post['post_title'] = $data[0]['name'];
493
+				$post['post_status'] = 'publish';
494
+				$id = wp_insert_post($post);
495
+
496
+				//Save the WETU ID and the Last date it was modified.
497
+				if(false !== $id){
498
+					add_post_meta($id,'lsx_wetu_id',$wetu_id);
499
+					add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
500
+				}
501
+			}
502
+			//Setup some default for use in the import
503
+			if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
504 504
 				$this->find_attachments($id);
505 505
 			}
506 506
 
507
-	        //Set the team member if it is there
508
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
509
-	        	$this->set_team_member($id,$team_members);
510
-	    	}
511
-
512
-	        //Set the safari brand
513
-	        if(false !== $safari_brands && '' !== $safari_brands){
514
-	        	$this->set_safari_brands($id,$safari_brands);
515
-
516
-	    	}	    	
517
-
518
-	        if(class_exists('LSX_TO_Maps')){
519
-	        	$this->set_map_data($data,$id,9);
520
-	        }
521
-
522
-	        if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
523
-	        	$this->connect_destinations($data,$id);
524
-	        }
525
-
526
-	        if(false !== $importable_content && in_array('category',$importable_content)){
527
-	        	$this->set_taxonomy_style($data,$id);
528
-	        }
529
-
530
-	        //Set the Room Data
531
-	        if(false !== $importable_content && in_array('rooms',$importable_content)){
532
-	        	$this->set_room_data($data,$id);
533
-	    	}
534
-
535
-	    	//Set the rating
536
-	    	if(false !== $importable_content && in_array('rating',$importable_content)){
537
-	       		$this->set_rating($data,$id);
538
-	    	}
539
-
540
-	    	//Set the checkin checkout data
541
-	    	if(false !== $importable_content && in_array('checkin',$importable_content)){
542
-	        	$this->set_checkin_checkout($data,$id);
543
-	        }
544
-
545
-	    	//Set the Spoken Languages
546
-	    	if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
547
-	       		$this->set_spoken_languages($data,$id);
548
-	    	}
549
-
550
-	    	//Set the friendly options
551
-	    	if(false !== $importable_content && in_array('friendly',$importable_content)){
552
-	       		$this->set_friendly($data,$id);
553
-	    	}
554
-
555
-	    	//Set the special_interests
556
-	    	if(false !== $importable_content && in_array('special_interests',$importable_content)){
557
-	       		$this->set_special_interests($data,$id);
558
-	    	}	    		    		        
559
-
560
-	        //Import the videos
561
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
562
-	        	$this->set_video_data($data,$id);
563
-	        }
564
-
565
-	        //Import the facilities
566
-	        if(false !== $importable_content && in_array('facilities',$importable_content)){
567
-	        	$this->set_facilities($data,$id);
568
-	        }	        
569
-
570
-	        //Set the featured image
571
-	        if(false !== $importable_content && in_array('featured_image',$importable_content)){
572
-	        	$this->set_featured_image($data,$id);
573
-	        }
574
-	        if(false !== $importable_content && in_array('banner_image',$importable_content)){
575
-	        	$this->set_banner_image($data,$id);
576
-	        }	        
577
-	        //Import the main gallery
578
-	        if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
579
-	    		$this->create_main_gallery($data,$id);
580
-	        }	        	        	        
581
-        }
582
-        return $id;
507
+			//Set the team member if it is there
508
+			if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
509
+				$this->set_team_member($id,$team_members);
510
+			}
511
+
512
+			//Set the safari brand
513
+			if(false !== $safari_brands && '' !== $safari_brands){
514
+				$this->set_safari_brands($id,$safari_brands);
515
+
516
+			}	    	
517
+
518
+			if(class_exists('LSX_TO_Maps')){
519
+				$this->set_map_data($data,$id,9);
520
+			}
521
+
522
+			if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
523
+				$this->connect_destinations($data,$id);
524
+			}
525
+
526
+			if(false !== $importable_content && in_array('category',$importable_content)){
527
+				$this->set_taxonomy_style($data,$id);
528
+			}
529
+
530
+			//Set the Room Data
531
+			if(false !== $importable_content && in_array('rooms',$importable_content)){
532
+				$this->set_room_data($data,$id);
533
+			}
534
+
535
+			//Set the rating
536
+			if(false !== $importable_content && in_array('rating',$importable_content)){
537
+		   		$this->set_rating($data,$id);
538
+			}
539
+
540
+			//Set the checkin checkout data
541
+			if(false !== $importable_content && in_array('checkin',$importable_content)){
542
+				$this->set_checkin_checkout($data,$id);
543
+			}
544
+
545
+			//Set the Spoken Languages
546
+			if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
547
+		   		$this->set_spoken_languages($data,$id);
548
+			}
549
+
550
+			//Set the friendly options
551
+			if(false !== $importable_content && in_array('friendly',$importable_content)){
552
+		   		$this->set_friendly($data,$id);
553
+			}
554
+
555
+			//Set the special_interests
556
+			if(false !== $importable_content && in_array('special_interests',$importable_content)){
557
+		   		$this->set_special_interests($data,$id);
558
+			}	    		    		        
559
+
560
+			//Import the videos
561
+			if(false !== $importable_content && in_array('videos',$importable_content)){
562
+				$this->set_video_data($data,$id);
563
+			}
564
+
565
+			//Import the facilities
566
+			if(false !== $importable_content && in_array('facilities',$importable_content)){
567
+				$this->set_facilities($data,$id);
568
+			}	        
569
+
570
+			//Set the featured image
571
+			if(false !== $importable_content && in_array('featured_image',$importable_content)){
572
+				$this->set_featured_image($data,$id);
573
+			}
574
+			if(false !== $importable_content && in_array('banner_image',$importable_content)){
575
+				$this->set_banner_image($data,$id);
576
+			}	        
577
+			//Import the main gallery
578
+			if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
579
+				$this->create_main_gallery($data,$id);
580
+			}	        	        	        
581
+		}
582
+		return $id;
583 583
 	}
584 584
 
585 585
 	/**
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 
590 590
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
591 591
 		foreach($team_members as $team){
592
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
592
+			add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
593 593
 		}
594 594
 	}
595 595
 
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 	 */
599 599
 	public function set_safari_brands($id,$safari_brands) {
600 600
 		foreach($safari_brands as $safari_brand){
601
-        	wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
601
+			wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
602 602
 		}
603 603
 	}
604 604
 
@@ -607,32 +607,32 @@  discard block
 block discarded – undo
607 607
 	 */
608 608
 	public function connect_destinations($data,$id) {
609 609
 		if(isset($data[0]['position'])){
610
-		    $destinations = false;
611
-		    if(isset($data[0]['position']['country'])){
612
-		    	$destinations['country'] = $data[0]['position']['country'];
613
-		    }
614
-		    if(isset($data[0]['position']['destination'])){
615
-		    	$destinations['destination'] = $data[0]['position']['destination'];
616
-		    }
610
+			$destinations = false;
611
+			if(isset($data[0]['position']['country'])){
612
+				$destinations['country'] = $data[0]['position']['country'];
613
+			}
614
+			if(isset($data[0]['position']['destination'])){
615
+				$destinations['destination'] = $data[0]['position']['destination'];
616
+			}
617 617
 		    
618
-		    if(false !== $destinations){	
619
-		    	$prev_values = get_post_meta($id,'destination_to_accommodation',false);
620
-		    	if(false === $prev_values || !is_array($prev_values)){
621
-		    		$prev_values = array();
622
-		    	}
623
-		    	//print_r($destinations);
618
+			if(false !== $destinations){	
619
+				$prev_values = get_post_meta($id,'destination_to_accommodation',false);
620
+				if(false === $prev_values || !is_array($prev_values)){
621
+					$prev_values = array();
622
+				}
623
+				//print_r($destinations);
624 624
 				$destinations = array_unique($destinations);
625 625
 				//print_r($destinations);
626
-			    foreach($destinations as $key => $value){
627
-				    $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
628
-	                if (null !== $destination) {
629
-	                	if(!in_array($destination->ID,$prev_values)){
630
-	                   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
631
-	                   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
626
+				foreach($destinations as $key => $value){
627
+					$destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
628
+					if (null !== $destination) {
629
+						if(!in_array($destination->ID,$prev_values)){
630
+					   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
631
+					   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
632 632
 							$this->cleanup_posts[$destination->ID] = 'accommodation_to_destination';
633
-	                	}
634
-	                } 		    	
635
-			    }	
633
+						}
634
+					} 		    	
635
+				}	
636 636
 			}
637 637
 		}
638 638
 	}	
@@ -644,15 +644,15 @@  discard block
 block discarded – undo
644 644
 		$terms = false;
645 645
 		if(isset($data[0]['category'])){
646 646
 			if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
647
-	        {
648
-	            $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
649
-	            if ( is_wp_error($term) ){echo $term->get_error_message();}
650
-	            else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
651
-	        }
652
-	        else
653
-	        {
654
-	            wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
655
-	        }				
647
+			{
648
+				$term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
649
+				if ( is_wp_error($term) ){echo $term->get_error_message();}
650
+				else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
651
+			}
652
+			else
653
+			{
654
+				wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
655
+			}				
656 656
 		}
657 657
 	}		
658 658
 
@@ -676,25 +676,25 @@  discard block
 block discarded – undo
676 676
 				$temp_room['type'] = 'room';
677 677
 
678 678
 				if(!empty($room['images']) && is_array($room['images'])){
679
-			    	$attachments_args = array(
680
-			    			'post_parent' => $id,
681
-			    			'post_status' => 'inherit',
682
-			    			'post_type' => 'attachment',
683
-			    			'order' => 'ASC',
684
-			    	);   	
685
-			    	$attachments = new WP_Query($attachments_args);
686
-			    	$found_attachments = array();
687
-
688
-			    	if($attachments->have_posts()){
689
-			    		foreach($attachments->posts as $attachment){
690
-			    			$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
691
-			    		}
692
-			    	}
679
+					$attachments_args = array(
680
+							'post_parent' => $id,
681
+							'post_status' => 'inherit',
682
+							'post_type' => 'attachment',
683
+							'order' => 'ASC',
684
+					);   	
685
+					$attachments = new WP_Query($attachments_args);
686
+					$found_attachments = array();
687
+
688
+					if($attachments->have_posts()){
689
+						foreach($attachments->posts as $attachment){
690
+							$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
691
+						}
692
+					}
693 693
 
694 694
 					$temp_room['gallery'] = array();
695 695
 					foreach($room['images'] as $image_data){
696
-			    		$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
697
-			    	}
696
+						$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
697
+					}
698 698
 				}
699 699
 				$rooms[] = $temp_room;
700 700
 			}
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 				delete_post_meta($id, 'units');				
704 704
 			}
705 705
 			foreach($rooms as $room){
706
-		        add_post_meta($id,'units',$room,false);			
706
+				add_post_meta($id,'units',$room,false);			
707 707
 			}
708 708
 
709 709
 			if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){
@@ -713,11 +713,11 @@  discard block
 block discarded – undo
713 713
 			}
714 714
 
715 715
 			if(false !== $id && '0' !== $id){
716
-	        	$prev_rooms = get_post_meta($id,'number_of_rooms',true);
717
-	        	update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
718
-	        }else{
719
-	        	add_post_meta($id,'number_of_rooms',$room_count,true);
720
-	        }
716
+				$prev_rooms = get_post_meta($id,'number_of_rooms',true);
717
+				update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
718
+			}else{
719
+				add_post_meta($id,'number_of_rooms',$room_count,true);
720
+			}
721 721
 		}
722 722
 	}
723 723
 
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 				delete_post_meta($id, 'videos');				
828 828
 			}
829 829
 			foreach($videos as $video){
830
-		        add_post_meta($id,'videos',$video,false);			
830
+				add_post_meta($id,'videos',$video,false);			
831 831
 			}
832 832
 		}
833 833
 	}	
Please login to merge, or discard this patch.
Spacing   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -76,17 +76,17 @@  discard block
 block discarded – undo
76 76
 		//	$this->url    = 'https://wetu.com/API/Pins/';
77 77
 		//	$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
78 78
 		//} elseif ( false !== $this->api_key ) {
79
-			$this->url    = 'https://wetu.com/API/Pins/' . $this->api_key;
79
+			$this->url    = 'https://wetu.com/API/Pins/'.$this->api_key;
80 80
 			$this->url_qs = '';
81 81
 		//}
82 82
 
83
-		$temp_options = get_option('_lsx-to_settings',false);
84
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){
83
+		$temp_options = get_option('_lsx-to_settings', false);
84
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
85 85
 			$this->options = $temp_options[$this->plugin_slug];
86 86
 		}
87 87
 
88
-		$accommodation_options = get_option('wetu_importer_accommodation_settings',false);
89
-		if(false !== $accommodation_options){
88
+		$accommodation_options = get_option('wetu_importer_accommodation_settings', false);
89
+		if (false !== $accommodation_options) {
90 90
 			$this->accommodation_options = $accommodation_options;
91 91
 		}
92 92
 	}
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 			<form method="get" action="" id="posts-filter">
107 107
 				<input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" />
108 108
 				
109
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
110
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
109
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
110
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
111 111
 				</p>				
112 112
 
113 113
 				<table class="wp-list-table widefat fixed posts">
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 					<tbody id="the-list">
117 117
 						<tr class="post-0 type-tour status-none" id="post-0">
118 118
 							<th class="check-column" scope="row">
119
-								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label>
119
+								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label>
120 120
 							</th>
121 121
 							<td class="post-title page-title column-title">
122 122
 								<strong>
123
-									<?php _e('Enter a title to search for','wetu-importer'); ?>
123
+									<?php _e('Enter a title to search for', 'wetu-importer'); ?>
124 124
 								</strong>
125 125
 							</td>
126 126
 							<td class="date column-date">							
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 
135 135
 				</table>
136 136
 
137
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
138
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
137
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
138
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
139 139
 				</p>
140 140
 			</form> 
141 141
 
@@ -147,32 +147,32 @@  discard block
 block discarded – undo
147 147
 						<div class="settings-all" style="width:30%;display:block;float:left;">
148 148
 							<h3><?php _e('What content to Sync from WETU'); ?></h3>
149 149
 							<ul>
150
-                                <li><input class="content select-all" <?php $this->checked($this->accommodation_options,'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php _e('Select All','wetu-importer'); ?></li>
151
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li>
152
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li>
153
-								<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>
154
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li>
155
-		                        <?php if(class_exists('LSX_TO_Maps')){ ?>
156
-								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php _e('Location','wetu-importer'); ?></li>
150
+                                <li><input class="content select-all" <?php $this->checked($this->accommodation_options, 'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php _e('Select All', 'wetu-importer'); ?></li>
151
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li>
152
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li>
153
+								<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>
154
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li>
155
+		                        <?php if (class_exists('LSX_TO_Maps')) { ?>
156
+								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php _e('Location', 'wetu-importer'); ?></li>
157 157
 		                        <?php } ?>
158
-								<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>
159
-								<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>
160
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php _e('Facilities','wetu-importer'); ?></li>
161
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php _e('Friendly','wetu-importer'); ?></li>
162
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php _e('Rating','wetu-importer'); ?></li>
163
-								<li><input class="content" checked="<?php $this->checked($this->accommodation_options,'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php _e('Rooms','wetu-importer'); ?></li>
164
-								<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>
165
-								<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>
166
-
167
-		                        <?php if(class_exists('LSX_TO_Videos')){ ?>
168
-								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos','wetu-importer'); ?></li>
158
+								<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>
159
+								<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>
160
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php _e('Facilities', 'wetu-importer'); ?></li>
161
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php _e('Friendly', 'wetu-importer'); ?></li>
162
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php _e('Rating', 'wetu-importer'); ?></li>
163
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php _e('Rooms', 'wetu-importer'); ?></li>
164
+								<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>
165
+								<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>
166
+
167
+		                        <?php if (class_exists('LSX_TO_Videos')) { ?>
168
+								    <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos', 'wetu-importer'); ?></li>
169 169
 		                        <?php } ?>
170 170
 							</ul>
171 171
 							<h4><?php _e('Additional Content'); ?></h4>
172 172
 							<ul>
173
-								<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>
174
-		                        <?php if(class_exists('LSX_Banners')){ ?>
175
-								    <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>
173
+								<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>
174
+		                        <?php if (class_exists('LSX_Banners')) { ?>
175
+								    <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>
176 176
 		                        <?php } ?>
177 177
 							</ul>
178 178
 						</div>
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
 						<div style="width:30%;display:block;float:left;">
185 185
 							<h3><?php _e('Assign a Safari Brand'); ?></h3> 
186
-							<?php echo $this->taxonomy_checkboxes('accommodation-brand',$this->accommodation_options); ?>
186
+							<?php echo $this->taxonomy_checkboxes('accommodation-brand', $this->accommodation_options); ?>
187 187
 						</div>	
188 188
 
189 189
 						<br clear="both" />			
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
 
193 193
 					<h3><?php _e('Your List'); ?></h3>
194
-                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
194
+                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
195 195
 					<table class="wp-list-table widefat fixed posts">
196 196
 						<?php $this->table_header(); ?>
197 197
 
@@ -203,12 +203,12 @@  discard block
 block discarded – undo
203 203
 
204 204
 					</table>
205 205
 
206
-					<p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
206
+					<p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
207 207
 				</form>
208 208
 			</div>
209 209
 
210 210
 			<div style="display:none;" class="completed-list-wrapper">
211
-				<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>
211
+				<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>
212 212
 				<ul>
213 213
 				</ul>
214 214
 			</div>
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 	 * search_form
221 221
 	 */
222 222
 	public function update_options_form() {
223
-		echo '<div style="display:none;" class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').'</h3>';
223
+		echo '<div style="display:none;" class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').'</h3>';
224 224
 		$accommodation = get_transient('lsx_ti_accommodation');
225
-		if('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])){
225
+		if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) {
226 226
 			$this->update_options();
227 227
 		}
228 228
 		echo '</div>';
@@ -232,13 +232,13 @@  discard block
 block discarded – undo
232 232
 	 * Save the list of Accommodation into an option
233 233
 	 */
234 234
 	public function update_options() {
235
-		$data = file_get_contents( $this->url . '/List?' . $this->url_qs );
235
+		$data = file_get_contents($this->url.'/List?'.$this->url_qs);
236 236
 		$accommodation = json_decode($data, true);
237 237
 
238
-		if(isset($accommodation['error'])){
238
+		if (isset($accommodation['error'])) {
239 239
 		    return $accommodation['error'];
240 240
         }elseif (isset($accommodation) && !empty($accommodation)) {
241
-			set_transient('lsx_ti_accommodation',$accommodation,60*60*2);
241
+			set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2);
242 242
 			return true;
243 243
 		}
244 244
 	}
@@ -249,41 +249,41 @@  discard block
 block discarded – undo
249 249
 	public function process_ajax_search() {
250 250
 		$return = false;
251 251
 
252
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation'){
252
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation') {
253 253
 			$accommodation = get_transient('lsx_ti_accommodation');
254 254
 
255
-			if(false === $accommodation){
255
+			if (false === $accommodation) {
256 256
 			    $this->update_options();
257 257
             }
258 258
 
259
-			if ( false !== $accommodation ) {
259
+			if (false !== $accommodation) {
260 260
 				$searched_items = false;
261 261
 
262
-				if(isset($_POST['keyword'] )) {
262
+				if (isset($_POST['keyword'])) {
263 263
 					$keyphrases = $_POST['keyword'];
264
-				}else{
264
+				}else {
265 265
 					$keyphrases = array(0);
266 266
                 }
267 267
 
268
-				if(!is_array($keyphrases)){
268
+				if (!is_array($keyphrases)) {
269 269
 					$keyphrases = array($keyphrases);
270 270
 				}
271
-				foreach($keyphrases as &$keyword){
271
+				foreach ($keyphrases as &$keyword) {
272 272
 					$keyword = ltrim(rtrim($keyword));
273 273
 				}
274 274
 
275 275
 
276 276
 				$post_status = false;
277
-				if(in_array('publish',$keyphrases)){
277
+				if (in_array('publish', $keyphrases)) {
278 278
 					$post_status = 'publish';
279 279
 				}
280
-				if(in_array('pending',$keyphrases)){
280
+				if (in_array('pending', $keyphrases)) {
281 281
 					$post_status = 'pending';
282 282
 				}
283
-				if(in_array('draft',$keyphrases)){
283
+				if (in_array('draft', $keyphrases)) {
284 284
 					$post_status = 'draft';
285 285
 				}
286
-				if(in_array('import',$keyphrases)){
286
+				if (in_array('import', $keyphrases)) {
287 287
 					$post_status = 'import';
288 288
 				}
289 289
 
@@ -291,33 +291,33 @@  discard block
 block discarded – undo
291 291
 
292 292
 					$current_accommodation = $this->find_current_accommodation();
293 293
 
294
-					foreach($accommodation as $row_key => $row){
294
+					foreach ($accommodation as $row_key => $row) {
295 295
 
296 296
 						//If this is a current tour, add its ID to the row.
297 297
 						$row['post_id'] = 0;
298
-						if(false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)){
298
+						if (false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)) {
299 299
 							$row['post_id'] = $current_accommodation[$row['id']]->post_id;
300 300
 						}
301 301
 
302 302
 						//If we are searching for
303
-						if(false !== $post_status){
303
+						if (false !== $post_status) {
304 304
 
305
-							if('import' === $post_status){
305
+							if ('import' === $post_status) {
306 306
 
307
-								if(0 !== $row['post_id']){
307
+								if (0 !== $row['post_id']) {
308 308
 									continue;
309
-								}else{
309
+								}else {
310 310
 									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
311 311
 								}
312 312
 
313 313
 
314
-							}else{
314
+							}else {
315 315
 
316
-								if(0 === $row['post_id']){
316
+								if (0 === $row['post_id']) {
317 317
 									continue;
318
-								}else{
318
+								}else {
319 319
 									$current_status = get_post_status($row['post_id']);
320
-									if($current_status !== $post_status){
320
+									if ($current_status !== $post_status) {
321 321
 										continue;
322 322
 									}
323 323
 
@@ -325,17 +325,17 @@  discard block
 block discarded – undo
325 325
 								$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
326 326
 							}
327 327
 
328
-						}else{
328
+						}else {
329 329
 							//Search through each keyword.
330
-							foreach($keyphrases as $keyphrase){
330
+							foreach ($keyphrases as $keyphrase) {
331 331
 
332 332
 								//Make sure the keyphrase is turned into an array
333
-								$keywords = explode(" ",$keyphrase);
334
-								if(!is_array($keywords)){
333
+								$keywords = explode(" ", $keyphrase);
334
+								if (!is_array($keywords)) {
335 335
 									$keywords = array($keywords);
336 336
 								}
337 337
 
338
-								if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){
338
+								if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) {
339 339
 									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
340 340
 								}
341 341
 							}
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 				}
345 345
 
346 346
 
347
-				if(false !== $searched_items){
347
+				if (false !== $searched_items) {
348 348
 					ksort($searched_items);
349 349
 					$return = implode($searched_items);
350 350
 				}
@@ -357,11 +357,11 @@  discard block
 block discarded – undo
357 357
 	/**
358 358
 	 * Formats the row for output on the screen.
359 359
 	 */	
360
-	public function format_row($row = false){
361
-		if(false !== $row){
360
+	public function format_row($row = false) {
361
+		if (false !== $row) {
362 362
 
363 363
 			$status = 'import';
364
-			if(0 !== $row['post_id']){
364
+			if (0 !== $row['post_id']) {
365 365
 				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
366 366
 			}
367 367
 
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 					<strong>'.$row['name'].'</strong> - '.$status.'
376 376
 				</td>
377 377
 				<td class="date column-date">
378
-					<abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified
378
+					<abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
379 379
 				</td>
380 380
 				<td class="ssid column-ssid">
381 381
 					'.$row['id'].'
@@ -390,43 +390,43 @@  discard block
 block discarded – undo
390 390
 	 */
391 391
 	public function process_ajax_import() {
392 392
 		$return = false;
393
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])){
393
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])) {
394 394
 			
395 395
 			$wetu_id = $_POST['wetu_id'];
396
-			if(isset($_POST['post_id'])){
396
+			if (isset($_POST['post_id'])) {
397 397
 				$post_id = $_POST['post_id'];	
398
-			}else{
398
+			}else {
399 399
 				$post_id = 0;
400 400
 			}
401 401
 
402
-			if(isset($_POST['team_members'])){
402
+			if (isset($_POST['team_members'])) {
403 403
 				$team_members = $_POST['team_members'];	
404
-			}else{
404
+			}else {
405 405
 				$team_members = false;
406 406
 			}
407 407
 
408
-			if(isset($_POST['safari_brands'])){
408
+			if (isset($_POST['safari_brands'])) {
409 409
 				$safari_brands = $_POST['safari_brands'];	
410
-			}else{
410
+			}else {
411 411
 				$safari_brands = false;
412 412
 			}
413 413
 
414 414
 			delete_option('wetu_importer_accommodation_settings');
415
-			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
415
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
416 416
 				$content = $_POST['content'];
417
-				add_option('wetu_importer_accommodation_settings',$content);
418
-			}else{
417
+				add_option('wetu_importer_accommodation_settings', $content);
418
+			}else {
419 419
 
420 420
 				$content = false;
421 421
 			}
422 422
 
423
-            $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
424
-            if($jdata)
423
+            $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
424
+            if ($jdata)
425 425
             {
426
-                $adata=json_decode($jdata,true);
427
-                if(!empty($adata))
426
+                $adata = json_decode($jdata, true);
427
+                if (!empty($adata))
428 428
                 {
429
-                	$return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands);
429
+                	$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
430 430
                 	$this->format_completed_row($return);
431 431
 					$this->cleanup_posts();
432 432
                 }
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
 	/**
438 438
 	 * Connect to wetu
439 439
 	 */
440
-	public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) {
440
+	public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false) {
441 441
 
442
-        if(trim($data[0]['type'])=='Accommodation')
442
+        if (trim($data[0]['type']) == 'Accommodation')
443 443
         {
444 444
 	        $post_name = $data_post_content = $data_post_excerpt = '';
445 445
 	        $post = array(
@@ -449,44 +449,44 @@  discard block
 block discarded – undo
449 449
 	        $content_used_general_description = false;
450 450
 
451 451
 	        //Set the post_content
452
-	        if(false !== $importable_content && in_array('description',$importable_content)){
453
-		        if(isset($data[0]['content']['extended_description']))
452
+	        if (false !== $importable_content && in_array('description', $importable_content)) {
453
+		        if (isset($data[0]['content']['extended_description']))
454 454
 		        {
455 455
 		            $data_post_content = $data[0]['content']['extended_description'];
456
-		        }elseif(isset($data[0]['content']['general_description'])){
456
+		        }elseif (isset($data[0]['content']['general_description'])) {
457 457
 		            $data_post_content = $data[0]['content']['general_description'];
458 458
 		            $content_used_general_description = true;
459
-		        }elseif(isset($data[0]['content']['teaser_description'])){
459
+		        }elseif (isset($data[0]['content']['teaser_description'])) {
460 460
 		        	$data_post_content = $data[0]['content']['teaser_description'];
461 461
 		        }
462 462
 	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
463 463
 	        }
464 464
 
465 465
 	        //set the post_excerpt
466
-	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
467
-		        if(isset($data[0]['content']['teaser_description'])){
466
+	        if (false !== $importable_content && in_array('excerpt', $importable_content)) {
467
+		        if (isset($data[0]['content']['teaser_description'])) {
468 468
 		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
469
-		        }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
469
+		        }elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) {
470 470
 		            $data_post_excerpt = $data[0]['content']['general_description'];
471 471
 		        }	   
472 472
 		        $post['post_excerpt'] = $data_post_excerpt;     	
473 473
 	        }
474 474
 
475
-	        if(false !== $id && '0' !== $id){
475
+	        if (false !== $id && '0' !== $id) {
476 476
 	        	$post['ID'] = $id;
477
-				if(isset($data[0]['name'])){
477
+				if (isset($data[0]['name'])) {
478 478
 					$post['post_title'] = $data[0]['name'];
479 479
 	        		$post['post_status'] = 'publish';
480
-					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
480
+					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0);
481 481
 				}
482 482
 	        	$id = wp_update_post($post);
483
-	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
484
-	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
485
-	        }else{
483
+	        	$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
484
+	        	update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
485
+	        }else {
486 486
 
487 487
 		        //Set the name
488
-		        if(isset($data[0]['name'])){
489
-		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0);
488
+		        if (isset($data[0]['name'])) {
489
+		            $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0);
490 490
 		        }
491 491
 	        	$post['post_name'] = $post_name;
492 492
 	        	$post['post_title'] = $data[0]['name'];
@@ -494,89 +494,89 @@  discard block
 block discarded – undo
494 494
 	        	$id = wp_insert_post($post);
495 495
 
496 496
 	        	//Save the WETU ID and the Last date it was modified.
497
-	        	if(false !== $id){
498
-	        		add_post_meta($id,'lsx_wetu_id',$wetu_id);
499
-	        		add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']));
497
+	        	if (false !== $id) {
498
+	        		add_post_meta($id, 'lsx_wetu_id', $wetu_id);
499
+	        		add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']));
500 500
 	        	}
501 501
 	        }
502 502
 	        //Setup some default for use in the import
503
-	        if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){
503
+	        if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) {
504 504
 				$this->find_attachments($id);
505 505
 			}
506 506
 
507 507
 	        //Set the team member if it is there
508
-	        if(post_type_exists('team') && false !== $team_members && '' !== $team_members){
509
-	        	$this->set_team_member($id,$team_members);
508
+	        if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
509
+	        	$this->set_team_member($id, $team_members);
510 510
 	    	}
511 511
 
512 512
 	        //Set the safari brand
513
-	        if(false !== $safari_brands && '' !== $safari_brands){
514
-	        	$this->set_safari_brands($id,$safari_brands);
513
+	        if (false !== $safari_brands && '' !== $safari_brands) {
514
+	        	$this->set_safari_brands($id, $safari_brands);
515 515
 
516 516
 	    	}	    	
517 517
 
518
-	        if(class_exists('LSX_TO_Maps')){
519
-	        	$this->set_map_data($data,$id,9);
518
+	        if (class_exists('LSX_TO_Maps')) {
519
+	        	$this->set_map_data($data, $id, 9);
520 520
 	        }
521 521
 
522
-	        if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){
523
-	        	$this->connect_destinations($data,$id);
522
+	        if (post_type_exists('destination') && false !== $importable_content && in_array('destination', $importable_content)) {
523
+	        	$this->connect_destinations($data, $id);
524 524
 	        }
525 525
 
526
-	        if(false !== $importable_content && in_array('category',$importable_content)){
527
-	        	$this->set_taxonomy_style($data,$id);
526
+	        if (false !== $importable_content && in_array('category', $importable_content)) {
527
+	        	$this->set_taxonomy_style($data, $id);
528 528
 	        }
529 529
 
530 530
 	        //Set the Room Data
531
-	        if(false !== $importable_content && in_array('rooms',$importable_content)){
532
-	        	$this->set_room_data($data,$id);
531
+	        if (false !== $importable_content && in_array('rooms', $importable_content)) {
532
+	        	$this->set_room_data($data, $id);
533 533
 	    	}
534 534
 
535 535
 	    	//Set the rating
536
-	    	if(false !== $importable_content && in_array('rating',$importable_content)){
537
-	       		$this->set_rating($data,$id);
536
+	    	if (false !== $importable_content && in_array('rating', $importable_content)) {
537
+	       		$this->set_rating($data, $id);
538 538
 	    	}
539 539
 
540 540
 	    	//Set the checkin checkout data
541
-	    	if(false !== $importable_content && in_array('checkin',$importable_content)){
542
-	        	$this->set_checkin_checkout($data,$id);
541
+	    	if (false !== $importable_content && in_array('checkin', $importable_content)) {
542
+	        	$this->set_checkin_checkout($data, $id);
543 543
 	        }
544 544
 
545 545
 	    	//Set the Spoken Languages
546
-	    	if(false !== $importable_content && in_array('spoken_languages',$importable_content)){
547
-	       		$this->set_spoken_languages($data,$id);
546
+	    	if (false !== $importable_content && in_array('spoken_languages', $importable_content)) {
547
+	       		$this->set_spoken_languages($data, $id);
548 548
 	    	}
549 549
 
550 550
 	    	//Set the friendly options
551
-	    	if(false !== $importable_content && in_array('friendly',$importable_content)){
552
-	       		$this->set_friendly($data,$id);
551
+	    	if (false !== $importable_content && in_array('friendly', $importable_content)) {
552
+	       		$this->set_friendly($data, $id);
553 553
 	    	}
554 554
 
555 555
 	    	//Set the special_interests
556
-	    	if(false !== $importable_content && in_array('special_interests',$importable_content)){
557
-	       		$this->set_special_interests($data,$id);
556
+	    	if (false !== $importable_content && in_array('special_interests', $importable_content)) {
557
+	       		$this->set_special_interests($data, $id);
558 558
 	    	}	    		    		        
559 559
 
560 560
 	        //Import the videos
561
-	        if(false !== $importable_content && in_array('videos',$importable_content)){
562
-	        	$this->set_video_data($data,$id);
561
+	        if (false !== $importable_content && in_array('videos', $importable_content)) {
562
+	        	$this->set_video_data($data, $id);
563 563
 	        }
564 564
 
565 565
 	        //Import the facilities
566
-	        if(false !== $importable_content && in_array('facilities',$importable_content)){
567
-	        	$this->set_facilities($data,$id);
566
+	        if (false !== $importable_content && in_array('facilities', $importable_content)) {
567
+	        	$this->set_facilities($data, $id);
568 568
 	        }	        
569 569
 
570 570
 	        //Set the featured image
571
-	        if(false !== $importable_content && in_array('featured_image',$importable_content)){
572
-	        	$this->set_featured_image($data,$id);
571
+	        if (false !== $importable_content && in_array('featured_image', $importable_content)) {
572
+	        	$this->set_featured_image($data, $id);
573 573
 	        }
574
-	        if(false !== $importable_content && in_array('banner_image',$importable_content)){
575
-	        	$this->set_banner_image($data,$id);
574
+	        if (false !== $importable_content && in_array('banner_image', $importable_content)) {
575
+	        	$this->set_banner_image($data, $id);
576 576
 	        }	        
577 577
 	        //Import the main gallery
578
-	        if(false !== $importable_content && in_array('gallery',$importable_content)){	    	
579
-	    		$this->create_main_gallery($data,$id);
578
+	        if (false !== $importable_content && in_array('gallery', $importable_content)) {	    	
579
+	    		$this->create_main_gallery($data, $id);
580 580
 	        }	        	        	        
581 581
         }
582 582
         return $id;
@@ -585,50 +585,50 @@  discard block
 block discarded – undo
585 585
 	/**
586 586
 	 * Set the team memberon each item.
587 587
 	 */
588
-	public function set_team_member($id,$team_members) {
588
+	public function set_team_member($id, $team_members) {
589 589
 
590 590
 		delete_post_meta($id, 'team_to_'.$this->tab_slug);
591
-		foreach($team_members as $team){
592
-        	add_post_meta($id,'team_to_'.$this->tab_slug,$team);			
591
+		foreach ($team_members as $team) {
592
+        	add_post_meta($id, 'team_to_'.$this->tab_slug, $team);			
593 593
 		}
594 594
 	}
595 595
 
596 596
 	/**
597 597
 	 * Set the safari brand
598 598
 	 */
599
-	public function set_safari_brands($id,$safari_brands) {
600
-		foreach($safari_brands as $safari_brand){
601
-        	wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true);			
599
+	public function set_safari_brands($id, $safari_brands) {
600
+		foreach ($safari_brands as $safari_brand) {
601
+        	wp_set_object_terms($id, intval($safari_brand), 'accommodation-brand', true);			
602 602
 		}
603 603
 	}
604 604
 
605 605
 	/**
606 606
 	 * Connects the destinations post type
607 607
 	 */
608
-	public function connect_destinations($data,$id) {
609
-		if(isset($data[0]['position'])){
608
+	public function connect_destinations($data, $id) {
609
+		if (isset($data[0]['position'])) {
610 610
 		    $destinations = false;
611
-		    if(isset($data[0]['position']['country'])){
611
+		    if (isset($data[0]['position']['country'])) {
612 612
 		    	$destinations['country'] = $data[0]['position']['country'];
613 613
 		    }
614
-		    if(isset($data[0]['position']['destination'])){
614
+		    if (isset($data[0]['position']['destination'])) {
615 615
 		    	$destinations['destination'] = $data[0]['position']['destination'];
616 616
 		    }
617 617
 		    
618
-		    if(false !== $destinations){	
619
-		    	$prev_values = get_post_meta($id,'destination_to_accommodation',false);
620
-		    	if(false === $prev_values || !is_array($prev_values)){
618
+		    if (false !== $destinations) {	
619
+		    	$prev_values = get_post_meta($id, 'destination_to_accommodation', false);
620
+		    	if (false === $prev_values || !is_array($prev_values)) {
621 621
 		    		$prev_values = array();
622 622
 		    	}
623 623
 		    	//print_r($destinations);
624 624
 				$destinations = array_unique($destinations);
625 625
 				//print_r($destinations);
626
-			    foreach($destinations as $key => $value){
626
+			    foreach ($destinations as $key => $value) {
627 627
 				    $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
628 628
 	                if (null !== $destination) {
629
-	                	if(!in_array($destination->ID,$prev_values)){
630
-	                   		add_post_meta($id,'destination_to_accommodation',$destination->ID,false);
631
-	                   		add_post_meta($destination->ID,'accommodation_to_destination',$id,false);
629
+	                	if (!in_array($destination->ID, $prev_values)) {
630
+	                   		add_post_meta($id, 'destination_to_accommodation', $destination->ID, false);
631
+	                   		add_post_meta($destination->ID, 'accommodation_to_destination', $id, false);
632 632
 							$this->cleanup_posts[$destination->ID] = 'accommodation_to_destination';
633 633
 	                	}
634 634
 	                } 		    	
@@ -640,18 +640,18 @@  discard block
 block discarded – undo
640 640
 	/**
641 641
 	 * Set the Travel Style
642 642
 	 */
643
-	public function set_taxonomy_style($data,$id) {
643
+	public function set_taxonomy_style($data, $id) {
644 644
 		$terms = false;
645
-		if(isset($data[0]['category'])){
646
-			if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
645
+		if (isset($data[0]['category'])) {
646
+			if (!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
647 647
 	        {
648 648
 	            $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
649
-	            if ( is_wp_error($term) ){echo $term->get_error_message();}
650
-	            else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
649
+	            if (is_wp_error($term)) {echo $term->get_error_message(); }
650
+	            else { wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true); }
651 651
 	        }
652 652
 	        else
653 653
 	        {
654
-	            wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
654
+	            wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true);
655 655
 	        }				
656 656
 		}
657 657
 	}		
@@ -659,23 +659,23 @@  discard block
 block discarded – undo
659 659
 	/**
660 660
 	 * Saves the room data
661 661
 	 */
662
-	public function set_room_data($data,$id) {
663
-		if(!empty($data[0]['rooms']) && is_array($data[0]['rooms'])){
662
+	public function set_room_data($data, $id) {
663
+		if (!empty($data[0]['rooms']) && is_array($data[0]['rooms'])) {
664 664
 			$rooms = false;
665 665
 
666
-			foreach($data[0]['rooms'] as $room){
666
+			foreach ($data[0]['rooms'] as $room) {
667 667
 
668 668
 				$temp_room = array();
669
-				if(isset($room['name'])){
669
+				if (isset($room['name'])) {
670 670
 					$temp_room['title'] = $room['name'];
671 671
 				}
672
-				if(isset($room['description'])){
672
+				if (isset($room['description'])) {
673 673
 					$temp_room['description'] = strip_tags($room['description']);
674 674
 				}			
675 675
 				$temp_room['price'] = 0;
676 676
 				$temp_room['type'] = 'room';
677 677
 
678
-				if(!empty($room['images']) && is_array($room['images'])){
678
+				if (!empty($room['images']) && is_array($room['images'])) {
679 679
 			    	$attachments_args = array(
680 680
 			    			'post_parent' => $id,
681 681
 			    			'post_status' => 'inherit',
@@ -685,38 +685,38 @@  discard block
 block discarded – undo
685 685
 			    	$attachments = new WP_Query($attachments_args);
686 686
 			    	$found_attachments = array();
687 687
 
688
-			    	if($attachments->have_posts()){
689
-			    		foreach($attachments->posts as $attachment){
690
-			    			$found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
688
+			    	if ($attachments->have_posts()) {
689
+			    		foreach ($attachments->posts as $attachment) {
690
+			    			$found_attachments[] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title);
691 691
 			    		}
692 692
 			    	}
693 693
 
694 694
 					$temp_room['gallery'] = array();
695
-					foreach($room['images'] as $image_data){
696
-			    		$temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments);
695
+					foreach ($room['images'] as $image_data) {
696
+			    		$temp_room['gallery'][] = $this->attach_image($image_data, $id, $found_attachments);
697 697
 			    	}
698 698
 				}
699 699
 				$rooms[] = $temp_room;
700 700
 			}
701 701
 
702
-			if(false !== $id && '0' !== $id){
702
+			if (false !== $id && '0' !== $id) {
703 703
 				delete_post_meta($id, 'units');				
704 704
 			}
705
-			foreach($rooms as $room){
706
-		        add_post_meta($id,'units',$room,false);			
705
+			foreach ($rooms as $room) {
706
+		        add_post_meta($id, 'units', $room, false);			
707 707
 			}
708 708
 
709
-			if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){
709
+			if (isset($data[0]['features']) && isset($data[0]['features']['rooms'])) {
710 710
 				$room_count = $data[0]['features']['rooms'];
711
-			}else{
711
+			}else {
712 712
 				$room_count = count($data[0]['rooms']);
713 713
 			}
714 714
 
715
-			if(false !== $id && '0' !== $id){
716
-	        	$prev_rooms = get_post_meta($id,'number_of_rooms',true);
717
-	        	update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
718
-	        }else{
719
-	        	add_post_meta($id,'number_of_rooms',$room_count,true);
715
+			if (false !== $id && '0' !== $id) {
716
+	        	$prev_rooms = get_post_meta($id, 'number_of_rooms', true);
717
+	        	update_post_meta($id, 'number_of_rooms', $room_count, $prev_rooms);
718
+	        }else {
719
+	        	add_post_meta($id, 'number_of_rooms', $room_count, true);
720 720
 	        }
721 721
 		}
722 722
 	}
@@ -724,31 +724,31 @@  discard block
 block discarded – undo
724 724
 	/**
725 725
 	 * Set the ratings
726 726
 	 */
727
-	public function set_rating($data,$id) {
727
+	public function set_rating($data, $id) {
728 728
 
729
-		if(!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])){
729
+		if (!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])) {
730 730
 			$rating_type = $data[0]['features']['star_authority'];	
731
-		}else{
731
+		}else {
732 732
 			$rating_type = 'Unspecified2';
733 733
 		}
734
-		$this->save_custom_field($rating_type,'rating_type',$id);
734
+		$this->save_custom_field($rating_type, 'rating_type', $id);
735 735
 
736
-		if(!empty($data[0]['features']) && isset($data[0]['features']['stars'])){
737
-			$this->save_custom_field($data[0]['features']['stars'],'rating',$id,true);	
736
+		if (!empty($data[0]['features']) && isset($data[0]['features']['stars'])) {
737
+			$this->save_custom_field($data[0]['features']['stars'], 'rating', $id, true);	
738 738
 		}
739 739
 	}
740 740
 
741 741
 	/**
742 742
 	 * Set the spoken_languages
743 743
 	 */
744
-	public function set_spoken_languages($data,$id) {
745
-		if(!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])){
744
+	public function set_spoken_languages($data, $id) {
745
+		if (!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])) {
746 746
 			$languages = false;
747
-			foreach($data[0]['features']['spoken_languages'] as $spoken_language){
747
+			foreach ($data[0]['features']['spoken_languages'] as $spoken_language) {
748 748
 				$languages[] = sanitize_title($spoken_language);
749 749
 			}
750
-			if(false !== $languages){
751
-				$this->save_custom_field($languages,'spoken_languages',$id);
750
+			if (false !== $languages) {
751
+				$this->save_custom_field($languages, 'spoken_languages', $id);
752 752
 			}
753 753
 		}
754 754
 	}
@@ -756,14 +756,14 @@  discard block
 block discarded – undo
756 756
 	/**
757 757
 	 * Set the friendly
758 758
 	 */
759
-	public function set_friendly($data,$id) {
760
-		if(!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])){
759
+	public function set_friendly($data, $id) {
760
+		if (!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])) {
761 761
 			$friendly_options = false;
762
-			foreach($data[0]['features']['suggested_visitor_types'] as $visitor_type){
762
+			foreach ($data[0]['features']['suggested_visitor_types'] as $visitor_type) {
763 763
 				$friendly_options[] = sanitize_title($visitor_type);
764 764
 			}
765
-			if(false !== $friendly_options){
766
-				$this->save_custom_field($friendly_options,'suggested_visitor_types',$id);
765
+			if (false !== $friendly_options) {
766
+				$this->save_custom_field($friendly_options, 'suggested_visitor_types', $id);
767 767
 			}
768 768
 		}		
769 769
 	}
@@ -771,14 +771,14 @@  discard block
 block discarded – undo
771 771
 	/**
772 772
 	 * Set the special interests
773 773
 	 */
774
-	public function set_special_interests($data,$id) {
775
-		if(!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])){
774
+	public function set_special_interests($data, $id) {
775
+		if (!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])) {
776 776
 			$interests = false;
777
-			foreach($data[0]['features']['special_interests'] as $special_interest){
777
+			foreach ($data[0]['features']['special_interests'] as $special_interest) {
778 778
 				$interests[] = sanitize_title($special_interest);
779 779
 			}
780
-			if(false !== $interests){
781
-				$this->save_custom_field($interests,'special_interests',$id);
780
+			if (false !== $interests) {
781
+				$this->save_custom_field($interests, 'special_interests', $id);
782 782
 			}
783 783
 		}		
784 784
 	}				
@@ -786,48 +786,48 @@  discard block
 block discarded – undo
786 786
 	/**
787 787
 	 * Set the Check in and Check out Date
788 788
 	 */
789
-	public function set_checkin_checkout($data,$id) {
789
+	public function set_checkin_checkout($data, $id) {
790 790
 
791
-		if(!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])){
792
-			$time = str_replace('h',':',$data[0]['features']['check_in_time']);
793
-			$time = date('h:ia',strtotime($time));
794
-			$this->save_custom_field($time,'checkin_time',$id);
791
+		if (!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])) {
792
+			$time = str_replace('h', ':', $data[0]['features']['check_in_time']);
793
+			$time = date('h:ia', strtotime($time));
794
+			$this->save_custom_field($time, 'checkin_time', $id);
795 795
 		}
796
-		if(!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])){
797
-			$time = str_replace('h',':',$data[0]['features']['check_out_time']);
798
-			$time = date('h:ia',strtotime($time));
799
-			$this->save_custom_field($time,'checkout_time',$id);
796
+		if (!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])) {
797
+			$time = str_replace('h', ':', $data[0]['features']['check_out_time']);
798
+			$time = date('h:ia', strtotime($time));
799
+			$this->save_custom_field($time, 'checkout_time', $id);
800 800
 		}
801 801
 	}	
802 802
 
803 803
 	/**
804 804
 	 * Set the Video date
805 805
 	 */
806
-	public function set_video_data($data,$id) {
807
-		if(!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])){
806
+	public function set_video_data($data, $id) {
807
+		if (!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])) {
808 808
 			$videos = false;
809 809
 
810
-			foreach($data[0]['content']['youtube_videos'] as $video){
810
+			foreach ($data[0]['content']['youtube_videos'] as $video) {
811 811
 				$temp_video = array();
812 812
 
813
-				if(isset($video['label'])){
813
+				if (isset($video['label'])) {
814 814
 					$temp_video['title'] = $video['label'];
815 815
 				}
816
-				if(isset($video['description'])){
816
+				if (isset($video['description'])) {
817 817
 					$temp_video['description'] = strip_tags($video['description']);
818 818
 				}	
819
-				if(isset($video['url'])){
819
+				if (isset($video['url'])) {
820 820
 					$temp_video['url'] = $video['url'];
821 821
 				}						
822 822
 				$temp_video['thumbnail'] = '';
823 823
 				$videos[] = $temp_video;
824 824
 			}
825 825
 
826
-			if(false !== $id && '0' !== $id){
826
+			if (false !== $id && '0' !== $id) {
827 827
 				delete_post_meta($id, 'videos');				
828 828
 			}
829
-			foreach($videos as $video){
830
-		        add_post_meta($id,'videos',$video,false);			
829
+			foreach ($videos as $video) {
830
+		        add_post_meta($id, 'videos', $video, false);			
831 831
 			}
832 832
 		}
833 833
 	}	
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
 	/**
836 836
 	 * Set the Facilities
837 837
 	 */
838
-	public function set_facilities($data,$id) {
838
+	public function set_facilities($data, $id) {
839 839
 
840 840
 		$parent_facilities = array(
841 841
 			'available_services' => 'Available Services',
@@ -843,13 +843,13 @@  discard block
 block discarded – undo
843 843
 			'room_facilities' => 'Room Facilities',
844 844
 			'activities_on_site' => 'Activities on Site'
845 845
 		);
846
-		foreach($parent_facilities as $key => $label){
846
+		foreach ($parent_facilities as $key => $label) {
847 847
 			$terms = false;
848
-			if(isset($data[0]['features']) && isset($data[0]['features'][$key])){
849
-				$parent_id = $this->set_term($id,$label,'facility');	
848
+			if (isset($data[0]['features']) && isset($data[0]['features'][$key])) {
849
+				$parent_id = $this->set_term($id, $label, 'facility');	
850 850
 			}
851
-			foreach($data[0]['features'][$key] as $child_facility){
852
-				$this->set_term($id,$child_facility,'facility',$parent_id);
851
+			foreach ($data[0]['features'][$key] as $child_facility) {
852
+				$this->set_term($id, $child_facility, 'facility', $parent_id);
853 853
 			}
854 854
 		}
855 855
 	}
Please login to merge, or discard this patch.
Braces   +19 added lines, -21 removed lines patch added patch discarded remove patch
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
 		if(isset($accommodation['error'])){
239 239
 		    return $accommodation['error'];
240
-        }elseif (isset($accommodation) && !empty($accommodation)) {
240
+        } elseif (isset($accommodation) && !empty($accommodation)) {
241 241
 			set_transient('lsx_ti_accommodation',$accommodation,60*60*2);
242 242
 			return true;
243 243
 		}
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 
262 262
 				if(isset($_POST['keyword'] )) {
263 263
 					$keyphrases = $_POST['keyword'];
264
-				}else{
264
+				} else{
265 265
 					$keyphrases = array(0);
266 266
                 }
267 267
 
@@ -306,16 +306,16 @@  discard block
 block discarded – undo
306 306
 
307 307
 								if(0 !== $row['post_id']){
308 308
 									continue;
309
-								}else{
309
+								} else{
310 310
 									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
311 311
 								}
312 312
 
313 313
 
314
-							}else{
314
+							} else{
315 315
 
316 316
 								if(0 === $row['post_id']){
317 317
 									continue;
318
-								}else{
318
+								} else{
319 319
 									$current_status = get_post_status($row['post_id']);
320 320
 									if($current_status !== $post_status){
321 321
 										continue;
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 								$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
326 326
 							}
327 327
 
328
-						}else{
328
+						} else{
329 329
 							//Search through each keyword.
330 330
 							foreach($keyphrases as $keyphrase){
331 331
 
@@ -395,19 +395,19 @@  discard block
 block discarded – undo
395 395
 			$wetu_id = $_POST['wetu_id'];
396 396
 			if(isset($_POST['post_id'])){
397 397
 				$post_id = $_POST['post_id'];	
398
-			}else{
398
+			} else{
399 399
 				$post_id = 0;
400 400
 			}
401 401
 
402 402
 			if(isset($_POST['team_members'])){
403 403
 				$team_members = $_POST['team_members'];	
404
-			}else{
404
+			} else{
405 405
 				$team_members = false;
406 406
 			}
407 407
 
408 408
 			if(isset($_POST['safari_brands'])){
409 409
 				$safari_brands = $_POST['safari_brands'];	
410
-			}else{
410
+			} else{
411 411
 				$safari_brands = false;
412 412
 			}
413 413
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
416 416
 				$content = $_POST['content'];
417 417
 				add_option('wetu_importer_accommodation_settings',$content);
418
-			}else{
418
+			} else{
419 419
 
420 420
 				$content = false;
421 421
 			}
@@ -453,10 +453,10 @@  discard block
 block discarded – undo
453 453
 		        if(isset($data[0]['content']['extended_description']))
454 454
 		        {
455 455
 		            $data_post_content = $data[0]['content']['extended_description'];
456
-		        }elseif(isset($data[0]['content']['general_description'])){
456
+		        } elseif(isset($data[0]['content']['general_description'])){
457 457
 		            $data_post_content = $data[0]['content']['general_description'];
458 458
 		            $content_used_general_description = true;
459
-		        }elseif(isset($data[0]['content']['teaser_description'])){
459
+		        } elseif(isset($data[0]['content']['teaser_description'])){
460 460
 		        	$data_post_content = $data[0]['content']['teaser_description'];
461 461
 		        }
462 462
 	        	$post['post_content'] = wp_strip_all_tags($data_post_content);
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	        if(false !== $importable_content && in_array('excerpt',$importable_content)){
467 467
 		        if(isset($data[0]['content']['teaser_description'])){
468 468
 		        	$data_post_excerpt = $data[0]['content']['teaser_description'];
469
-		        }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
469
+		        } elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){
470 470
 		            $data_post_excerpt = $data[0]['content']['general_description'];
471 471
 		        }	   
472 472
 		        $post['post_excerpt'] = $data_post_excerpt;     	
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 	        	$id = wp_update_post($post);
483 483
 	        	$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
484 484
 	        	update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date);
485
-	        }else{
485
+	        } else{
486 486
 
487 487
 		        //Set the name
488 488
 		        if(isset($data[0]['name'])){
@@ -646,10 +646,8 @@  discard block
 block discarded – undo
646 646
 			if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type'))
647 647
 	        {
648 648
 	            $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
649
-	            if ( is_wp_error($term) ){echo $term->get_error_message();}
650
-	            else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
651
-	        }
652
-	        else
649
+	            if ( is_wp_error($term) ){echo $term->get_error_message();} else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); }
650
+	        } else
653 651
 	        {
654 652
 	            wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true);
655 653
 	        }				
@@ -708,14 +706,14 @@  discard block
 block discarded – undo
708 706
 
709 707
 			if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){
710 708
 				$room_count = $data[0]['features']['rooms'];
711
-			}else{
709
+			} else{
712 710
 				$room_count = count($data[0]['rooms']);
713 711
 			}
714 712
 
715 713
 			if(false !== $id && '0' !== $id){
716 714
 	        	$prev_rooms = get_post_meta($id,'number_of_rooms',true);
717 715
 	        	update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms);
718
-	        }else{
716
+	        } else{
719 717
 	        	add_post_meta($id,'number_of_rooms',$room_count,true);
720 718
 	        }
721 719
 		}
@@ -728,7 +726,7 @@  discard block
 block discarded – undo
728 726
 
729 727
 		if(!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])){
730 728
 			$rating_type = $data[0]['features']['star_authority'];	
731
-		}else{
729
+		} else{
732 730
 			$rating_type = 'Unspecified2';
733 731
 		}
734 732
 		$this->save_custom_field($rating_type,'rating_type',$id);
Please login to merge, or discard this patch.
classes/class-destination.php 2 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -622,6 +622,7 @@  discard block
 block discarded – undo
622 622
 
623 623
 	/**
624 624
 	 * Set the team memberon each item.
625
+	 * @param boolean $team_members
625 626
 	 */
626 627
 	public function set_team_member($id, $team_members)
627 628
 	{
@@ -634,6 +635,7 @@  discard block
 block discarded – undo
634 635
 
635 636
 	/**
636 637
 	 * Saves the room data
638
+	 * @param string $meta_key
637 639
 	 */
638 640
 	public function set_travel_info($data, $id, $meta_key)
639 641
 	{
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		//	$this->url    = 'https://wetu.com/API/Pins/';
79 79
 		//	$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
80 80
 		//} elseif ( false !== $this->api_key ) {
81
-		$this->url = 'https://wetu.com/API/Pins/' . $this->api_key;
81
+		$this->url = 'https://wetu.com/API/Pins/'.$this->api_key;
82 82
 		$this->url_qs = '';
83 83
 		//}
84 84
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 
310 310
 				if (isset($_POST['keyword'])) {
311 311
 					$keyphrases = $_POST['keyword'];
312
-				} else {
312
+				}else {
313 313
 					$keyphrases = array(0);
314 314
 				}
315 315
 
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
 							if ($current_status !== $post_status) {
345 345
 								continue;
346 346
 							}
347
-							$searched_items[sanitize_title($row->name) . '-' . $row->meta_value] = $this->format_row($row);
347
+							$searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
348 348
 
349 349
 
350
-						} else {
350
+						}else {
351 351
 							//Search through each keyword.
352 352
 							foreach ($keyphrases as $keyphrase) {
353 353
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 								}
359 359
 
360 360
 								if ($this->multineedle_stripos(ltrim(rtrim($row->name)), $keywords) !== false) {
361
-									$searched_items[sanitize_title($row->name) . '-' . $row->meta_value] = $this->format_row($row);
361
+									$searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
362 362
 								}
363 363
 							}
364 364
 						}
@@ -384,23 +384,23 @@  discard block
 block discarded – undo
384 384
 
385 385
 			$status = 'import';
386 386
 			if (0 !== $row->post_id) {
387
-				$status = '<a href="' . admin_url('/post.php?post=' . $row->post_id . '&action=edit') . '" target="_blank">' . get_post_status($row->post_id) . '</a>';
387
+				$status = '<a href="'.admin_url('/post.php?post='.$row->post_id.'&action=edit').'" target="_blank">'.get_post_status($row->post_id).'</a>';
388 388
 			}
389 389
 
390 390
 			$row_html = '
391
-			<tr class="post-' . $row->post_id . ' type-tour" id="post-' . $row->post_id . '">
391
+			<tr class="post-' . $row->post_id.' type-tour" id="post-'.$row->post_id.'">
392 392
 				<th class="check-column" scope="row">
393
-					<label for="cb-select-' . $row->meta_value . '" class="screen-reader-text">' . $row->name . '</label>
394
-					<input type="checkbox" data-identifier="' . $row->meta_value . '" value="' . $row->post_id . '" name="post[]" id="cb-select-' . $row->meta_value . '">
393
+					<label for="cb-select-' . $row->meta_value.'" class="screen-reader-text">'.$row->name.'</label>
394
+					<input type="checkbox" data-identifier="' . $row->meta_value.'" value="'.$row->post_id.'" name="post[]" id="cb-select-'.$row->meta_value.'">
395 395
 				</th>
396 396
 				<td class="post-title page-title column-title">
397
-					<strong>' . $row->name . '</strong> - ' . $status . '
397
+					<strong>' . $row->name.'</strong> - '.$status.'
398 398
 				</td>
399 399
 				<td class="date column-date">
400
-					<abbr title="' . date('Y/m/d', strtotime($row->last_modified)) . '">' . date('Y/m/d', strtotime($row->last_modified)) . '</abbr><br>Last Modified
400
+					<abbr title="' . date('Y/m/d', strtotime($row->last_modified)).'">'.date('Y/m/d', strtotime($row->last_modified)).'</abbr><br>Last Modified
401 401
 				</td>
402 402
 				<td class="ssid column-ssid">
403
-					' . $row->meta_value . '
403
+					' . $row->meta_value.'
404 404
 				</td>
405 405
 			</tr>';
406 406
 			return $row_html;
@@ -418,13 +418,13 @@  discard block
 block discarded – undo
418 418
 			$wetu_id = $_POST['wetu_id'];
419 419
 			if (isset($_POST['post_id'])) {
420 420
 				$post_id = $_POST['post_id'];
421
-			} else {
421
+			}else {
422 422
 				$post_id = 0;
423 423
 			}
424 424
 
425 425
 			if (isset($_POST['team_members'])) {
426 426
 				$team_members = $_POST['team_members'];
427
-			} else {
427
+			}else {
428 428
 				$team_members = false;
429 429
 			}
430 430
 
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
 			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
435 435
 				$content = $_POST['content'];
436 436
 				add_option('wetu_importer_destination_settings', $content);
437
-			} else {
437
+			}else {
438 438
 				$content = false;
439 439
 			}
440 440
 
441
-			$jdata = file_get_contents($this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id);
441
+			$jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
442 442
 			if ($jdata) {
443 443
 				$adata = json_decode($jdata, true);
444 444
 				if (!empty($adata)) {
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 				$id = wp_update_post($post);
499 499
 				$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
500 500
 				update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
501
-			} else {
501
+			}else {
502 502
 
503 503
 				//Set the name
504 504
 				if (isset($data[0]['name'])) {
@@ -582,9 +582,9 @@  discard block
 block discarded – undo
582 582
 	public function set_team_member($id, $team_members)
583 583
 	{
584 584
 
585
-		delete_post_meta($id, 'team_to_' . $this->tab_slug);
585
+		delete_post_meta($id, 'team_to_'.$this->tab_slug);
586 586
 		foreach ($team_members as $team) {
587
-			add_post_meta($id, 'team_to_' . $this->tab_slug, $team);
587
+			add_post_meta($id, 'team_to_'.$this->tab_slug, $team);
588 588
 		}
589 589
 	}
590 590
 
Please login to merge, or discard this patch.
classes/class-importer.php 4 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -674,6 +674,9 @@  discard block
 block discarded – undo
674 674
 		return $result;
675 675
 	}
676 676
 
677
+	/**
678
+	 * @return boolean
679
+	 */
677 680
 	public function set_term($id=false,$name=false,$taxonomy=false,$parent=false){
678 681
 		if(!$term = term_exists($name, $taxonomy))
679 682
 		{
@@ -910,6 +913,10 @@  discard block
 block discarded – undo
910 913
 		return 	false;
911 914
 	}
912 915
 
916
+	/**
917
+	 * @param string $url
918
+	 * @param string $thumb
919
+	 */
913 920
 	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
914 921
 
915 922
 		if ( !$url || !$post_id ) { return new WP_Error('missing', "Need a valid URL and post ID..."); }
@@ -1018,6 +1025,7 @@  discard block
 block discarded – undo
1018 1025
 
1019 1026
 	/**
1020 1027
 	 * Does a multine search
1028
+	 * @param string $haystack
1021 1029
 	 */
1022 1030
 	public function multineedle_stripos($haystack, $needles, $offset=0) {
1023 1031
 		$found = false;
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -202,15 +202,15 @@  discard block
 block discarded – undo
202 202
 			$this->api_username = false;
203 203
 			$this->api_password = false;
204 204
 
205
-            if (isset($temp_options['api']['wetu_api_key']) && '' !== $temp_options['api']['wetu_api_key']) {
206
-                $this->api_key = $temp_options['api']['wetu_api_key'];
207
-            }
208
-            if (isset($temp_options['api']['wetu_api_username']) && '' !== $temp_options['api']['wetu_api_username']) {
209
-                $this->api_username = $temp_options['api']['wetu_api_username'];
210
-            }
211
-            if (isset($temp_options['api']['wetu_api_password']) && '' !== $temp_options['api']['wetu_api_password']) {
212
-                $this->api_password = $temp_options['api']['wetu_api_password'];
213
-            }
205
+			if (isset($temp_options['api']['wetu_api_key']) && '' !== $temp_options['api']['wetu_api_key']) {
206
+				$this->api_key = $temp_options['api']['wetu_api_key'];
207
+			}
208
+			if (isset($temp_options['api']['wetu_api_username']) && '' !== $temp_options['api']['wetu_api_username']) {
209
+				$this->api_username = $temp_options['api']['wetu_api_username'];
210
+			}
211
+			if (isset($temp_options['api']['wetu_api_password']) && '' !== $temp_options['api']['wetu_api_password']) {
212
+				$this->api_password = $temp_options['api']['wetu_api_password'];
213
+			}
214 214
 
215 215
 			//Set the tab slug
216 216
 			if(isset($_GET['tab']) || isset($_POST['type'])) {
@@ -224,25 +224,25 @@  discard block
 block discarded – undo
224 224
 					//If any tours were queued
225 225
 					$this->queued_imports = get_option('wetu_importer_que', false);
226 226
 				}
227
-            }
227
+			}
228 228
 
229 229
 			//Set the scaling options
230
-            if (isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug]) && isset($this->options['image_scaling'])) {
231
-                $this->scale_images = true;
232
-                $width = '800';
233
-                if (isset($this->options['width']) && '' !== $this->options['width']) {
234
-                    $width = $this->options['width'];
235
-                }
236
-                $height = '600';
237
-                if (isset($this->options['height']) && '' !== $this->options['height']) {
238
-                    $height = $this->options['height'];
239
-                }
240
-                $cropping = 'raw';
241
-                if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
242
-                    $cropping = $this->options['cropping'];
243
-                }
244
-                $this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
245
-            }
230
+			if (isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug]) && isset($this->options['image_scaling'])) {
231
+				$this->scale_images = true;
232
+				$width = '800';
233
+				if (isset($this->options['width']) && '' !== $this->options['width']) {
234
+					$width = $this->options['width'];
235
+				}
236
+				$height = '600';
237
+				if (isset($this->options['height']) && '' !== $this->options['height']) {
238
+					$height = $this->options['height'];
239
+				}
240
+				$cropping = 'raw';
241
+				if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
242
+					$cropping = $this->options['cropping'];
243
+				}
244
+				$this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
245
+			}
246 246
 
247 247
 		}
248 248
 	}
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
 
317 317
 	// DISPLAY FUNCTIONS
318 318
 
319
-    /*
319
+	/*
320 320
      * Load the importer class you want to use
321 321
      */
322
-    public function load_class(){
322
+	public function load_class(){
323 323
 
324 324
 		switch($this->tab_slug){
325 325
 			case 'accommodation':
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 				break;
340 340
 		}
341 341
 
342
-    }
342
+	}
343 343
 
344 344
 	/**
345 345
 	 * Registers the admin page which will house the importer form.
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 				<?php
396 396
 			}else{
397 397
 			   $this->current_importer->display_page();
398
-            }; ?>
398
+			}; ?>
399 399
         </div>
400 400
 		<?php
401 401
 	}
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
 	 * Run through the accommodation grabbed from the DB.
1017 1017
 	 */
1018 1018
 	public function process_ajax_search() {
1019
-	    $this->current_importer->process_ajax_search();
1019
+		$this->current_importer->process_ajax_search();
1020 1020
 	}
1021 1021
 
1022 1022
 	/**
Please login to merge, or discard this patch.
Spacing   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -148,31 +148,31 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	public function __construct() {
150 150
 
151
-		add_action( 'admin_init', array( $this, 'compatible_version_check' ) );
151
+		add_action('admin_init', array($this, 'compatible_version_check'));
152 152
 
153 153
 		// Don't run anything else in the plugin, if we're on an incompatible PHP version
154
-		if ( ! self::compatible_version() ) {
154
+		if (!self::compatible_version()) {
155 155
 			return;
156 156
 		}
157 157
 
158 158
 		$this->set_variables();
159 159
 
160
-		add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
161
-		add_action( 'admin_enqueue_scripts', array($this,'admin_scripts') ,11 );
162
-		add_action( 'admin_menu', array( $this, 'register_importer_page' ),20 );
160
+		add_action('init', array($this, 'load_plugin_textdomain'));
161
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts'), 11);
162
+		add_action('admin_menu', array($this, 'register_importer_page'), 20);
163 163
 
164 164
 		require_once(WETU_IMPORTER_PATH.'classes/class-accommodation.php');
165 165
 		require_once(WETU_IMPORTER_PATH.'classes/class-destination.php');
166 166
 		require_once(WETU_IMPORTER_PATH.'classes/class-tours.php');
167 167
 
168
-		add_action( 'init', array( $this, 'load_class' ) );
168
+		add_action('init', array($this, 'load_class'));
169 169
 
170
-		if('default' !== $this->tab_slug){
171
-			add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search'));
172
-			add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search'));
170
+		if ('default' !== $this->tab_slug) {
171
+			add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search'));
172
+			add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search'));
173 173
 
174
-			add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import'));
175
-			add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import'));
174
+			add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import'));
175
+			add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import'));
176 176
 		}
177 177
 	}
178 178
 
@@ -184,18 +184,18 @@  discard block
 block discarded – undo
184 184
 	 * @since 1.0.0
185 185
 	 */
186 186
 	public function load_plugin_textdomain() {
187
-		load_plugin_textdomain( 'wetu-importer', FALSE, basename( WETU_IMPORTER_PATH ) . '/languages');
187
+		load_plugin_textdomain('wetu-importer', FALSE, basename(WETU_IMPORTER_PATH).'/languages');
188 188
 	}
189 189
 
190 190
 	/**
191 191
 	 * Sets the variables used throughout the plugin.
192 192
 	 */
193 193
 	public function set_variables() {
194
-		$this->post_types = array('accommodation','destination','tour');
195
-		$temp_options = get_option('_lsx-to_settings',false);
194
+		$this->post_types = array('accommodation', 'destination', 'tour');
195
+		$temp_options = get_option('_lsx-to_settings', false);
196 196
 
197 197
 		//Set the options.
198
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug])) {
198
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug])) {
199 199
 			$this->options = $temp_options[$this->plugin_slug];
200 200
 
201 201
 			$this->api_key = false;
@@ -213,14 +213,14 @@  discard block
 block discarded – undo
213 213
             }
214 214
 
215 215
 			//Set the tab slug
216
-			if(isset($_GET['tab']) || isset($_POST['type'])) {
217
-				if(isset($_GET['tab'])) {
216
+			if (isset($_GET['tab']) || isset($_POST['type'])) {
217
+				if (isset($_GET['tab'])) {
218 218
 					$this->tab_slug = $_GET['tab'];
219
-				}else{
219
+				}else {
220 220
 					$this->tab_slug = $_POST['type'];
221 221
 				}
222 222
 
223
-				if('tours' !== $this->tab_slug) {
223
+				if ('tours' !== $this->tab_slug) {
224 224
 					//If any tours were queued
225 225
 					$this->queued_imports = get_option('wetu_importer_que', false);
226 226
 				}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
                 if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
242 242
                     $cropping = $this->options['cropping'];
243 243
                 }
244
-                $this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
244
+                $this->image_scaling_url = 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/';
245 245
             }
246 246
 
247 247
 		}
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 	 * @since 1.0.0
265 265
 	 */
266 266
 	public static function compatible_version() {
267
-		if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
267
+		if (version_compare(PHP_VERSION, '5.6', '<')) {
268 268
 			return false;
269 269
 		}
270 270
 
@@ -278,13 +278,13 @@  discard block
 block discarded – undo
278 278
 	 * @since 1.0.0
279 279
 	 */
280 280
 	public function compatible_version_check() {
281
-		if ( ! self::compatible_version() ) {
282
-			if ( is_plugin_active( plugin_basename( WETU_IMPORTER_CORE ) ) ) {
283
-				deactivate_plugins( plugin_basename( WETU_IMPORTER_CORE ) );
284
-				add_action( 'admin_notices', array( $this, 'compatible_version_notice' ) );
281
+		if (!self::compatible_version()) {
282
+			if (is_plugin_active(plugin_basename(WETU_IMPORTER_CORE))) {
283
+				deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE));
284
+				add_action('admin_notices', array($this, 'compatible_version_notice'));
285 285
 				
286
-				if ( isset( $_GET['activate'] ) ) {
287
-					unset( $_GET['activate'] );
286
+				if (isset($_GET['activate'])) {
287
+					unset($_GET['activate']);
288 288
 				}
289 289
 			}
290 290
 		}
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
 	 */
298 298
 	public function compatible_version_notice() {
299 299
 		$class = 'notice notice-error';
300
-		$message = esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' );
301
-		printf( '<div class="%1$s"><p>%2$s</p></div>', esc_html( $class ), esc_html( $message ) );
300
+		$message = esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer');
301
+		printf('<div class="%1$s"><p>%2$s</p></div>', esc_html($class), esc_html($message));
302 302
 	}
303 303
 	
304 304
 	/**
@@ -308,9 +308,9 @@  discard block
 block discarded – undo
308 308
 	 * @since 1.0.0
309 309
 	 */
310 310
 	public static function compatible_version_check_on_activation() {
311
-		if ( ! self::compatible_version() ) {
312
-			deactivate_plugins( plugin_basename( WETU_IMPORTER_CORE ) );
313
-			wp_die( esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' ) );
311
+		if (!self::compatible_version()) {
312
+			deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE));
313
+			wp_die(esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer'));
314 314
 		}
315 315
 	}
316 316
 
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
     /*
320 320
      * Load the importer class you want to use
321 321
      */
322
-    public function load_class(){
322
+    public function load_class() {
323 323
 
324
-		switch($this->tab_slug){
324
+		switch ($this->tab_slug) {
325 325
 			case 'accommodation':
326 326
 				$this->current_importer = new WETU_Importer_Accommodation();
327 327
 				break;
@@ -345,25 +345,25 @@  discard block
 block discarded – undo
345 345
 	 * Registers the admin page which will house the importer form.
346 346
 	 */
347 347
 	public function register_importer_page() {
348
-		add_submenu_page( 'tour-operator',esc_html__( 'Importer', 'tour-operator' ), esc_html__( 'Importer', 'tour-operator' ), 'manage_options', 'wetu-importer', array( $this, 'display_page' ) );
348
+		add_submenu_page('tour-operator', esc_html__('Importer', 'tour-operator'), esc_html__('Importer', 'tour-operator'), 'manage_options', 'wetu-importer', array($this, 'display_page'));
349 349
 	}
350 350
 
351 351
 	/**
352 352
 	 * Enqueue the JS needed to contact wetu and return your result.
353 353
 	 */
354 354
 	public function admin_scripts() {
355
-		if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) {
355
+		if (defined('WP_DEBUG') && true === WP_DEBUG) {
356 356
 			$min = '';
357
-		} else {
357
+		}else {
358 358
 			$min = '.min';
359 359
 		}
360 360
 		$min = '';
361 361
 
362
-		if(is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']){
363
-			wp_enqueue_script( 'wetu-importers-script', WETU_IMPORTER_URL . 'assets/js/wetu-importer' . $min . '.js', array( 'jquery' ), WETU_IMPORTER_VER, true );
364
-			wp_localize_script( 'wetu-importers-script', 'lsx_tour_importer_params', array(
362
+		if (is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']) {
363
+			wp_enqueue_script('wetu-importers-script', WETU_IMPORTER_URL.'assets/js/wetu-importer'.$min.'.js', array('jquery'), WETU_IMPORTER_VER, true);
364
+			wp_localize_script('wetu-importers-script', 'lsx_tour_importer_params', array(
365 365
 				'ajax_url' => admin_url('admin-ajax.php'),
366
-			) );
366
+			));
367 367
 		}
368 368
 	}
369 369
 
@@ -375,25 +375,25 @@  discard block
 block discarded – undo
375 375
         <div class="wrap">
376 376
 			<?php screen_icon(); ?>
377 377
 
378
-			<?php if(!is_object($this->current_importer)){
378
+			<?php if (!is_object($this->current_importer)) {
379 379
 				?>
380
-                <h2><?php _e('Welcome to the LSX Wetu Importer','wetu-importer'); ?></h2>
380
+                <h2><?php _e('Welcome to the LSX Wetu Importer', 'wetu-importer'); ?></h2>
381 381
                 <p>If this is the first time you are running the import, then follow the steps below.</p>
382 382
                 <ul>
383
-                    <li>Step 1 - Import your <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=tour"><?php _e('Tours','wetu-importer'); ?></a></li>
384
-                    <li>Step 2 - The tour import will have created draft <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation','wetu-importer'); ?></a> that will need to be imported.</li>
385
-                    <li>Step 3 - Lastly import the <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations','wetu-importer'); ?></a> draft posts created during the previous two steps.</li>
383
+                    <li>Step 1 - Import your <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=tour"><?php _e('Tours', 'wetu-importer'); ?></a></li>
384
+                    <li>Step 2 - The tour import will have created draft <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation', 'wetu-importer'); ?></a> that will need to be imported.</li>
385
+                    <li>Step 3 - Lastly import the <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations', 'wetu-importer'); ?></a> draft posts created during the previous two steps.</li>
386 386
                 </ul>
387 387
 
388
-                <h3><?php _e('Additional Tools','wetu-importer'); ?></h3>
388
+                <h3><?php _e('Additional Tools', 'wetu-importer'); ?></h3>
389 389
                 <ul>
390
-                    <li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=connect_accommodation"><?php _e('Connect Accommodation','wetu-importer'); ?></a> <small><?php _e('If you already have accommodation, you can "connect" it with its WETU counter part, so it works with the importer.','wetu-importer'); ?></small></li>
391
-					<?php if(class_exists('Lsx_Banners')){ ?>
392
-                        <li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=banners"><?php _e('Sync High Res Banner Images','wetu-importer'); ?></a></li>
390
+                    <li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=connect_accommodation"><?php _e('Connect Accommodation', 'wetu-importer'); ?></a> <small><?php _e('If you already have accommodation, you can "connect" it with its WETU counter part, so it works with the importer.', 'wetu-importer'); ?></small></li>
391
+					<?php if (class_exists('Lsx_Banners')) { ?>
392
+                        <li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=banners"><?php _e('Sync High Res Banner Images', 'wetu-importer'); ?></a></li>
393 393
 					<?php } ?>
394 394
                 </ul>
395 395
 				<?php
396
-			}else{
396
+			}else {
397 397
 			   $this->current_importer->display_page();
398 398
             }; ?>
399 399
         </div>
@@ -408,33 +408,33 @@  discard block
 block discarded – undo
408 408
         <form class="ajax-form" id="<?php echo $this->plugin_slug; ?>-search-form" method="get" action="tools.php" data-type="<?php echo $this->tab_slug; ?>">
409 409
             <input type="hidden" name="page" value="<?php echo $this->tab_slug; ?>" />
410 410
 
411
-            <h3><span class="dashicons dashicons-search"></span> <?php _e('Search','wetu-importer'); ?></h3>
411
+            <h3><span class="dashicons dashicons-search"></span> <?php _e('Search', 'wetu-importer'); ?></h3>
412 412
 
413
-			<?php do_action('wetu_importer_search_form',$this); ?>
413
+			<?php do_action('wetu_importer_search_form', $this); ?>
414 414
 
415 415
             <div class="normal-search">
416
-                <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'); ?>" />
416
+                <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'); ?>" />
417 417
             </div>
418 418
             <div class="advanced-search hidden" style="display:none;">
419
-                <p><?php _e('Enter several keywords, each on a new line.','wetu-importer'); ?></p>
419
+                <p><?php _e('Enter several keywords, each on a new line.', 'wetu-importer'); ?></p>
420 420
                 <textarea rows="10" cols="40" name="bulk-keywords"></textarea>
421
-                <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" />
421
+                <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" />
422 422
             </div>
423 423
 
424 424
             <p>
425
-                <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search','wetu-importer'); ?></a> |
426
-                <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published','wetu-importer'); ?></a> |
427
-                <a class="pending search-toggle"  href="#pending"><?php esc_attr_e('Pending','wetu-importer'); ?></a> |
428
-                <a class="draft search-toggle"  href="#draft"><?php esc_attr_e('Draft','wetu-importer'); ?></a>
429
-                <?php if('tour'===$this->tab_slug || false !== $this->queued_imports){ ?> | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU','wetu-importer'); ?></a><?php } ?>
425
+                <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search', 'wetu-importer'); ?></a> |
426
+                <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published', 'wetu-importer'); ?></a> |
427
+                <a class="pending search-toggle"  href="#pending"><?php esc_attr_e('Pending', 'wetu-importer'); ?></a> |
428
+                <a class="draft search-toggle"  href="#draft"><?php esc_attr_e('Draft', 'wetu-importer'); ?></a>
429
+                <?php if ('tour' === $this->tab_slug || false !== $this->queued_imports) { ?> | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU', 'wetu-importer'); ?></a><?php } ?>
430 430
             </p>
431 431
 
432 432
             <div class="ajax-loader" style="display:none;width:100%;text-align:center;">
433
-                <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
433
+                <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
434 434
             </div>
435 435
 
436 436
             <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
437
-                <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" />
437
+                <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" />
438 438
             </div>
439 439
         </form> 
440 440
 		<?php
@@ -483,15 +483,15 @@  discard block
 block discarded – undo
483 483
 	 *
484 484
 	 * @param $tab string
485 485
 	 */
486
-	public function navigation($tab='') {
486
+	public function navigation($tab = '') {
487 487
 		$post_types = array(
488
-			'tour'              => esc_attr('Tours','wetu-importer'),
489
-			'accommodation'     => esc_attr('Accommodation','wetu-importer'),
490
-			'destination'       => esc_attr('Destinations','wetu-importer'),
488
+			'tour'              => esc_attr('Tours', 'wetu-importer'),
489
+			'accommodation'     => esc_attr('Accommodation', 'wetu-importer'),
490
+			'destination'       => esc_attr('Destinations', 'wetu-importer'),
491 491
 		);
492
-		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>';
493
-		foreach($post_types as $post_type => $label){
494
-			echo ' | <a class="'.$this->itemd($tab,$post_type,'current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>';
492
+		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>';
493
+		foreach ($post_types as $post_type => $label) {
494
+			echo ' | <a class="'.$this->itemd($tab, $post_type, 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>';
495 495
 		}
496 496
 		echo '</div><br clear="both"/></div>';
497 497
 	}
@@ -499,23 +499,23 @@  discard block
 block discarded – undo
499 499
 	/**
500 500
 	 * set_taxonomy with some terms
501 501
 	 */
502
-	public function team_member_checkboxes($selected=array()) {
503
-		if(post_type_exists('team')) { ?>
502
+	public function team_member_checkboxes($selected = array()) {
503
+		if (post_type_exists('team')) { ?>
504 504
             <ul>
505 505
 				<?php
506
-				$team_args=array(
506
+				$team_args = array(
507 507
 					'post_type'	=>	'team',
508 508
 					'post_status' => 'publish',
509 509
 					'nopagin' => true,
510 510
 					'fields' => 'ids'
511 511
 				);
512 512
 				$team_members = new WP_Query($team_args);
513
-				if($team_members->have_posts()){
514
-					foreach($team_members->posts as $member){ ?>
515
-                        <li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
513
+				if ($team_members->have_posts()) {
514
+					foreach ($team_members->posts as $member) { ?>
515
+                        <li><input class="team" <?php $this->checked($selected, $member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
516 516
 					<?php }
517
-				}else{ ?>
518
-                    <li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
517
+				}else { ?>
518
+                    <li><input class="team" type="checkbox" value="0" /> <?php _e('None', 'wetu-importer'); ?></li>
519 519
 				<?php }
520 520
 				?>
521 521
             </ul>
@@ -532,12 +532,12 @@  discard block
 block discarded – undo
532 532
 	 * @param $needle string
533 533
 	 * @param $echo bool
534 534
 	 */
535
-	public function checked($haystack=false,$needle='',$echo=true) {
536
-		$return = $this->itemd($haystack,$needle,'checked');
537
-		if('' !== $return) {
535
+	public function checked($haystack = false, $needle = '', $echo = true) {
536
+		$return = $this->itemd($haystack, $needle, 'checked');
537
+		if ('' !== $return) {
538 538
 			if (true === $echo) {
539 539
 				echo $return;
540
-			} else {
540
+			}else {
541 541
 				return $return;
542 542
 			}
543 543
 		}
@@ -550,12 +550,12 @@  discard block
 block discarded – undo
550 550
 	 * @param $needle string
551 551
 	 * @param $echo bool
552 552
 	 */
553
-	public function selected($haystack=false,$needle='',$echo=true) {
554
-		$return = $this->itemd($haystack,$needle,'selected');
555
-		if('' !== $return) {
553
+	public function selected($haystack = false, $needle = '', $echo = true) {
554
+		$return = $this->itemd($haystack, $needle, 'selected');
555
+		if ('' !== $return) {
556 556
 			if (true === $echo) {
557 557
 				echo $return;
558
-			} else {
558
+			}else {
559 559
 				return $return;
560 560
 			}
561 561
 		}
@@ -570,16 +570,16 @@  discard block
 block discarded – undo
570 570
 	 * @param $wrap bool
571 571
 	 * @return $html string
572 572
 	 */
573
-	public function itemd($haystack=false,$needle='',$type='',$wrap=true) {
573
+	public function itemd($haystack = false, $needle = '', $type = '', $wrap = true) {
574 574
 		$html = '';
575
-		if('' !== $type) {
575
+		if ('' !== $type) {
576 576
 			if (!is_array($haystack)) {
577 577
 				$haystack = array($haystack);
578 578
 			}
579 579
 			if (in_array($needle, $haystack)) {
580
-				if(true === $wrap || 'true' === $wrap) {
581
-					$html = $type . '="' . $type . '"';
582
-				}else{
580
+				if (true === $wrap || 'true' === $wrap) {
581
+					$html = $type.'="'.$type.'"';
582
+				}else {
583 583
 					$html = $type;
584 584
 				}
585 585
 			}
@@ -591,9 +591,9 @@  discard block
 block discarded – undo
591 591
 	/**
592 592
 	 * grabs any attachments for the current item
593 593
 	 */
594
-	public function find_attachments($id=false) {
595
-		if(false !== $id){
596
-			if(empty($this->found_attachments)){
594
+	public function find_attachments($id = false) {
595
+		if (false !== $id) {
596
+			if (empty($this->found_attachments)) {
597 597
 
598 598
 				$attachments_args = array(
599 599
 					'post_parent' => $id,
@@ -605,9 +605,9 @@  discard block
 block discarded – undo
605 605
 				);
606 606
 
607 607
 				$attachments = new WP_Query($attachments_args);
608
-				if($attachments->have_posts()){
609
-					foreach($attachments->posts as $attachment){
610
-						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title);
608
+				if ($attachments->have_posts()) {
609
+					foreach ($attachments->posts as $attachment) {
610
+						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title);
611 611
 						$this->gallery_meta[] = $attachment->ID;
612 612
 					}
613 613
 				}
@@ -621,18 +621,18 @@  discard block
 block discarded – undo
621 621
 	/**
622 622
 	 * Saves the room data
623 623
 	 */
624
-	public function save_custom_field($value=false,$meta_key,$id,$decrease=false,$unique=true) {
625
-		if(false !== $value){
626
-			if(false !== $decrease){
624
+	public function save_custom_field($value = false, $meta_key, $id, $decrease = false, $unique = true) {
625
+		if (false !== $value) {
626
+			if (false !== $decrease) {
627 627
 				$value = intval($value);
628 628
 				$value--;
629 629
 			}
630
-			$prev = get_post_meta($id,$meta_key,true);
630
+			$prev = get_post_meta($id, $meta_key, true);
631 631
 
632
-			if(false !== $id && '0' !== $id && false !== $prev && true === $unique){
633
-				update_post_meta($id,$meta_key,$value,$prev);
634
-			}else{
635
-				add_post_meta($id,$meta_key,$value,$unique);
632
+			if (false !== $id && '0' !== $id && false !== $prev && true === $unique) {
633
+				update_post_meta($id, $meta_key, $value, $prev);
634
+			}else {
635
+				add_post_meta($id, $meta_key, $value, $unique);
636 636
 			}
637 637
 		}
638 638
 	}
@@ -641,12 +641,12 @@  discard block
 block discarded – undo
641 641
 	 * Grabs the custom fields,  and resaves an array of unique items.
642 642
 	 */
643 643
 	public function cleanup_posts() {
644
-		if(!empty($this->cleanup_posts)){
645
-			foreach($this->cleanup_posts as $id => $key) {
644
+		if (!empty($this->cleanup_posts)) {
645
+			foreach ($this->cleanup_posts as $id => $key) {
646 646
 				$prev_items = get_post_meta($id, $key, false);
647 647
 				$new_items = array_unique($prev_items);
648 648
 				delete_post_meta($id, $key);
649
-				foreach($new_items as $new_item) {
649
+				foreach ($new_items as $new_item) {
650 650
 					add_post_meta($id, $key, $new_item, false);
651 651
 				}
652 652
 			}
@@ -658,51 +658,51 @@  discard block
 block discarded – undo
658 658
 	/**
659 659
 	 * set_taxonomy with some terms
660 660
 	 */
661
-	public function set_taxonomy($taxonomy,$terms,$id) {
662
-		$result=array();
663
-		if(!empty($data))
661
+	public function set_taxonomy($taxonomy, $terms, $id) {
662
+		$result = array();
663
+		if (!empty($data))
664 664
 		{
665
-			foreach($data as $k)
665
+			foreach ($data as $k)
666 666
 			{
667
-				if($id)
667
+				if ($id)
668 668
 				{
669
-					if(!$term = term_exists(trim($k), $tax))
669
+					if (!$term = term_exists(trim($k), $tax))
670 670
 					{
671 671
 						$term = wp_insert_term(trim($k), $tax);
672
-						if ( is_wp_error($term) )
672
+						if (is_wp_error($term))
673 673
 						{
674 674
 							echo $term->get_error_message();
675 675
 						}
676 676
 						else
677 677
 						{
678
-							wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
678
+							wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
679 679
 						}
680 680
 					}
681 681
 					else
682 682
 					{
683
-						wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
683
+						wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
684 684
 					}
685 685
 				}
686 686
 				else
687 687
 				{
688
-					$result[]=trim($k);
688
+					$result[] = trim($k);
689 689
 				}
690 690
 			}
691 691
 		}
692 692
 		return $result;
693 693
 	}
694 694
 
695
-	public function set_term($id=false,$name=false,$taxonomy=false,$parent=false){
696
-		if(!$term = term_exists($name, $taxonomy))
695
+	public function set_term($id = false, $name = false, $taxonomy = false, $parent = false) {
696
+		if (!$term = term_exists($name, $taxonomy))
697 697
 		{
698
-			if(false !== $parent){ $parent = array('parent'=>$parent); }
699
-			$term = wp_insert_term(trim($name), $taxonomy,$parent);
700
-			if ( is_wp_error($term) ){echo $term->get_error_message();}
701
-			else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
698
+			if (false !== $parent) { $parent = array('parent'=>$parent); }
699
+			$term = wp_insert_term(trim($name), $taxonomy, $parent);
700
+			if (is_wp_error($term)) {echo $term->get_error_message(); }
701
+			else { wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); }
702 702
 		}
703 703
 		else
704 704
 		{
705
-			wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
705
+			wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
706 706
 		}
707 707
 		return $term['term_id'];
708 708
 	}
@@ -710,18 +710,18 @@  discard block
 block discarded – undo
710 710
 	/**
711 711
 	 * set_taxonomy with some terms
712 712
 	 */
713
-	public function taxonomy_checkboxes($taxonomy=false,$selected=array()) {
713
+	public function taxonomy_checkboxes($taxonomy = false, $selected = array()) {
714 714
 		$return = '';
715
-		if(false !== $taxonomy){
715
+		if (false !== $taxonomy) {
716 716
 			$return .= '<ul>';
717
-			$terms = get_terms(array('taxonomy'=>$taxonomy,'hide_empty'=>false));
717
+			$terms = get_terms(array('taxonomy'=>$taxonomy, 'hide_empty'=>false));
718 718
 
719
-			if(!is_wp_error($terms)){
720
-				foreach($terms as $term){
721
-					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected,$term->term_id,false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
719
+			if (!is_wp_error($terms)) {
720
+				foreach ($terms as $term) {
721
+					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected, $term->term_id, false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
722 722
 				}
723
-			}else{
724
-				$return .= '<li><input type="checkbox" value="" /> '.__('None','wetu-importer').'</li>';
723
+			}else {
724
+				$return .= '<li><input type="checkbox" value="" /> '.__('None', 'wetu-importer').'</li>';
725 725
 			}
726 726
 			$return .= '</ul>';
727 727
 		}
@@ -732,53 +732,53 @@  discard block
 block discarded – undo
732 732
 	/**
733 733
 	 * Saves the longitude and lattitude, as well as sets the map marker.
734 734
 	 */
735
-	public function set_map_data($data,$id,$zoom = '10') {
735
+	public function set_map_data($data, $id, $zoom = '10') {
736 736
 		$longitude = $latitude = $address = false;
737 737
 
738
-		if(isset($data[0]['position'])){
738
+		if (isset($data[0]['position'])) {
739 739
 
740
-			if(isset($data[0]['position']['driving_latitude'])){
740
+			if (isset($data[0]['position']['driving_latitude'])) {
741 741
 				$latitude = $data[0]['position']['driving_latitude'];
742
-			}elseif(isset($data[0]['position']['latitude'])){
742
+			}elseif (isset($data[0]['position']['latitude'])) {
743 743
 				$latitude = $data[0]['position']['latitude'];
744 744
 			}
745 745
 
746
-			if(isset($data[0]['position']['driving_longitude'])){
746
+			if (isset($data[0]['position']['driving_longitude'])) {
747 747
 				$longitude = $data[0]['position']['driving_longitude'];
748
-			}elseif(isset($data[0]['position']['longitude'])){
748
+			}elseif (isset($data[0]['position']['longitude'])) {
749 749
 				$longitude = $data[0]['position']['longitude'];
750 750
 			}
751 751
 
752 752
 		}
753
-		if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){
754
-			if(isset($data[0]['content']['contact_information']['address'])){
753
+		if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) {
754
+			if (isset($data[0]['content']['contact_information']['address'])) {
755 755
 				$address = strip_tags($data[0]['content']['contact_information']['address']);
756 756
 
757
-				$address = explode("\n",$address);
758
-				foreach($address as $bitkey => $bit){
757
+				$address = explode("\n", $address);
758
+				foreach ($address as $bitkey => $bit) {
759 759
 					$bit = ltrim(rtrim($bit));
760
-					if(false === $bit || '' === $bit || null === $bit or empty($bit)){
760
+					if (false === $bit || '' === $bit || null === $bit or empty($bit)) {
761 761
 						unset($address[$bitkey]);
762 762
 					}
763 763
 				}
764
-				$address = implode(', ',$address);
764
+				$address = implode(', ', $address);
765 765
 				$address = str_replace(', , ', ', ', $address);
766 766
 			}
767 767
 		}
768 768
 
769
-		if(false !== $longitude){
769
+		if (false !== $longitude) {
770 770
 			$location_data = array(
771
-				'address'	=>	(string)$address,
772
-				'lat'		=>	(string)$latitude,
773
-				'long'		=>	(string)$longitude,
774
-				'zoom'		=>	(string)$zoom,
771
+				'address'	=>	(string) $address,
772
+				'lat'		=>	(string) $latitude,
773
+				'long'		=>	(string) $longitude,
774
+				'zoom'		=>	(string) $zoom,
775 775
 				'elevation'	=>	'',
776 776
 			);
777
-			if(false !== $id && '0' !== $id){
778
-				$prev = get_post_meta($id,'location',true);
779
-				update_post_meta($id,'location',$location_data,$prev);
780
-			}else{
781
-				add_post_meta($id,'location',$location_data,true);
777
+			if (false !== $id && '0' !== $id) {
778
+				$prev = get_post_meta($id, 'location', true);
779
+				update_post_meta($id, 'location', $location_data, $prev);
780
+			}else {
781
+				add_post_meta($id, 'location', $location_data, true);
782 782
 			}
783 783
 		}
784 784
 	}
@@ -788,16 +788,16 @@  discard block
 block discarded – undo
788 788
 	/**
789 789
 	 * Creates the main gallery data
790 790
 	 */
791
-	public function set_featured_image($data,$id) {
792
-		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
793
-			$this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id);
791
+	public function set_featured_image($data, $id) {
792
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
793
+			$this->featured_image = $this->attach_image($data[0]['content']['images'][0], $id);
794 794
 
795
-			if(false !== $this->featured_image){
796
-				delete_post_meta($id,'_thumbnail_id');
797
-				add_post_meta($id,'_thumbnail_id',$this->featured_image,true);
795
+			if (false !== $this->featured_image) {
796
+				delete_post_meta($id, '_thumbnail_id');
797
+				add_post_meta($id, '_thumbnail_id', $this->featured_image, true);
798 798
 
799
-				if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){
800
-					add_post_meta($id,'gallery',$this->featured_image,false);
799
+				if (!empty($this->gallery_meta) && !in_array($this->featured_image, $this->gallery_meta)) {
800
+					add_post_meta($id, 'gallery', $this->featured_image, false);
801 801
 					$this->gallery_meta[] = $this->featured_image;
802 802
 				}
803 803
 			}
@@ -807,17 +807,17 @@  discard block
 block discarded – undo
807 807
 	/**
808 808
 	 * Sets a banner image
809 809
 	 */
810
-	public function set_banner_image($data,$id) {
811
-		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
812
-			$this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c'));
810
+	public function set_banner_image($data, $id) {
811
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
812
+			$this->banner_image = $this->attach_image($data[0]['content']['images'][1], $id, array('width'=>'1920', 'height'=>'800', 'cropping'=>'c'));
813 813
 
814
-			if(false !== $this->banner_image){
815
-				delete_post_meta($id,'image_group');
814
+			if (false !== $this->banner_image) {
815
+				delete_post_meta($id, 'image_group');
816 816
 				$new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image));
817
-				add_post_meta($id,'image_group',$new_banner,true);
817
+				add_post_meta($id, 'image_group', $new_banner, true);
818 818
 
819
-				if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){
820
-					add_post_meta($id,'gallery',$this->banner_image,false);
819
+				if (!empty($this->gallery_meta) && !in_array($this->banner_image, $this->gallery_meta)) {
820
+					add_post_meta($id, 'gallery', $this->banner_image, false);
821 821
 					$this->gallery_meta[] = $this->banner_image;
822 822
 				}
823 823
 			}
@@ -827,24 +827,24 @@  discard block
 block discarded – undo
827 827
 	/**
828 828
 	 * Creates the main gallery data
829 829
 	 */
830
-	public function create_main_gallery($data,$id) {
830
+	public function create_main_gallery($data, $id) {
831 831
 
832
-		if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){
832
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
833 833
 			$counter = 0;
834
-			foreach($data[0]['content']['images'] as $image_data){
835
-				if($counter === 0 && false !== $this->featured_image){$counter++;continue;}
836
-				if($counter === 1 && false !== $this->banner_image){$counter++;continue;}
834
+			foreach ($data[0]['content']['images'] as $image_data) {
835
+				if ($counter === 0 && false !== $this->featured_image) {$counter++; continue; }
836
+				if ($counter === 1 && false !== $this->banner_image) {$counter++; continue; }
837 837
 
838
-				$this->gallery_meta[] = $this->attach_image($image_data,$id);
838
+				$this->gallery_meta[] = $this->attach_image($image_data, $id);
839 839
 				$counter++;
840 840
 			}
841 841
 
842
-			if(!empty($this->gallery_meta)){
843
-				delete_post_meta($id,'gallery');
842
+			if (!empty($this->gallery_meta)) {
843
+				delete_post_meta($id, 'gallery');
844 844
 				$this->gallery_meta = array_unique($this->gallery_meta);
845
-				foreach($this->gallery_meta as $gallery_id){
846
-					if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){
847
-						add_post_meta($id,'gallery',$gallery_id,false);
845
+				foreach ($this->gallery_meta as $gallery_id) {
846
+					if (false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)) {
847
+						add_post_meta($id, 'gallery', $gallery_id, false);
848 848
 					}
849 849
 				}
850 850
 			}
@@ -854,27 +854,27 @@  discard block
 block discarded – undo
854 854
 	/**
855 855
 	 * search_form
856 856
 	 */
857
-	public function get_scaling_url($args=array()) {
857
+	public function get_scaling_url($args = array()) {
858 858
 
859 859
 		$defaults = array(
860 860
 			'width' => '640',
861 861
 			'height' => '480',
862 862
 			'cropping' => 'c'
863 863
 		);
864
-		if(false !== $this->options){
865
-			if(isset($this->options['width']) && '' !== $this->options['width']){
864
+		if (false !== $this->options) {
865
+			if (isset($this->options['width']) && '' !== $this->options['width']) {
866 866
 				$defaults['width'] = $this->options['width'];
867 867
 			}
868 868
 
869
-			if(isset($this->options['height']) && '' !== $this->options['height']){
869
+			if (isset($this->options['height']) && '' !== $this->options['height']) {
870 870
 				$defaults['height'] = $this->options['height'];
871 871
 			}
872 872
 
873
-			if(isset($this->options['cropping']) && '' !== $this->options['cropping']){
873
+			if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
874 874
 				$defaults['cropping'] = $this->options['cropping'];
875 875
 			}
876 876
 		}
877
-		$args = wp_parse_args($args,$defaults);
877
+		$args = wp_parse_args($args, $defaults);
878 878
 
879 879
 		$cropping = $args['cropping'];
880 880
 		$width = $args['width'];
@@ -887,40 +887,40 @@  discard block
 block discarded – undo
887 887
 	/**
888 888
 	 * Attaches 1 image
889 889
 	 */
890
-	public function attach_image($v=false,$parent_id,$image_sizes=false){
891
-		if(false !== $v){
892
-			$temp_fragment = explode('/',$v['url_fragment']);
893
-			$url_filename = $temp_fragment[count($temp_fragment)-1];
894
-			$url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename);
895
-
896
-			if(in_array($url_filename,$this->found_attachments)){
897
-				return array_search($url_filename,$this->found_attachments);
890
+	public function attach_image($v = false, $parent_id, $image_sizes = false) {
891
+		if (false !== $v) {
892
+			$temp_fragment = explode('/', $v['url_fragment']);
893
+			$url_filename = $temp_fragment[count($temp_fragment) - 1];
894
+			$url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename);
895
+
896
+			if (in_array($url_filename, $this->found_attachments)) {
897
+				return array_search($url_filename, $this->found_attachments);
898 898
 			}
899 899
 
900
-			$postdata=array();
901
-			if(empty($v['label']))
900
+			$postdata = array();
901
+			if (empty($v['label']))
902 902
 			{
903
-				$v['label']='';
903
+				$v['label'] = '';
904 904
 			}
905
-			if(!empty($v['description']))
905
+			if (!empty($v['description']))
906 906
 			{
907
-				$desc=wp_strip_all_tags($v['description']);
908
-				$posdata=array('post_excerpt'=>$desc);
907
+				$desc = wp_strip_all_tags($v['description']);
908
+				$posdata = array('post_excerpt'=>$desc);
909 909
 			}
910
-			if(!empty($v['section']))
910
+			if (!empty($v['section']))
911 911
 			{
912
-				$desc=wp_strip_all_tags($v['section']);
913
-				$posdata=array('post_excerpt'=>$desc);
912
+				$desc = wp_strip_all_tags($v['section']);
913
+				$posdata = array('post_excerpt'=>$desc);
914 914
 			}
915 915
 
916
-			$attachID=NULL;
916
+			$attachID = NULL;
917 917
 			//Resizor - add option to setting if required
918
-			$fragment = str_replace(' ','%20',$v['url_fragment']);
918
+			$fragment = str_replace(' ', '%20', $v['url_fragment']);
919 919
 			$url = $this->get_scaling_url($image_sizes).$fragment;
920
-			$attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata);
920
+			$attachID = $this->attach_external_image2($url, $parent_id, '', $v['label'], $postdata);
921 921
 
922 922
 			//echo($attachID.' add image');
923
-			if($attachID!=NULL)
923
+			if ($attachID != NULL)
924 924
 			{
925 925
 				return $attachID;
926 926
 			}
@@ -928,13 +928,13 @@  discard block
 block discarded – undo
928 928
 		return 	false;
929 929
 	}
930 930
 
931
-	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
931
+	public function attach_external_image2($url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array()) {
932 932
 
933
-		if ( !$url || !$post_id ) { return new WP_Error('missing', "Need a valid URL and post ID..."); }
933
+		if (!$url || !$post_id) { return new WP_Error('missing', "Need a valid URL and post ID..."); }
934 934
 
935
-		require_once(ABSPATH . 'wp-admin/includes/file.php');
936
-		require_once(ABSPATH . 'wp-admin/includes/media.php');
937
-		require_once(ABSPATH . 'wp-admin/includes/image.php');
935
+		require_once(ABSPATH.'wp-admin/includes/file.php');
936
+		require_once(ABSPATH.'wp-admin/includes/media.php');
937
+		require_once(ABSPATH.'wp-admin/includes/image.php');
938 938
 		// Download file to temp location, returns full server path to temp file
939 939
 		//$tmp = download_url( $url );
940 940
 
@@ -943,53 +943,53 @@  discard block
 block discarded – undo
943 943
 
944 944
 		$image = file_get_contents($url);
945 945
 		file_put_contents($tmp, $image);
946
-		chmod($tmp,'777');
946
+		chmod($tmp, '777');
947 947
 
948
-		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
948
+		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
949 949
 		$url_filename = basename($matches[0]);
950
-		$url_filename=str_replace('%20','_',$url_filename);
950
+		$url_filename = str_replace('%20', '_', $url_filename);
951 951
 		// extract filename from url for title
952
-		$url_type = wp_check_filetype($url_filename);                                           // determine file type (ext and mime/type)
952
+		$url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type)
953 953
 
954 954
 		// override filename if given, reconstruct server path
955
-		if ( !empty( $filename ) && " " != $filename )
955
+		if (!empty($filename) && " " != $filename)
956 956
 		{
957 957
 			$filename = sanitize_file_name($filename);
958
-			$tmppath = pathinfo( $tmp );
958
+			$tmppath = pathinfo($tmp);
959 959
 
960 960
 			$extension = '';
961
-			if(isset($tmppath['extension'])){
961
+			if (isset($tmppath['extension'])) {
962 962
 				$extension = $tmppath['extension'];
963 963
 			}
964 964
 
965
-			$new = $tmppath['dirname'] . "/". $filename . "." . $extension;
966
-			rename($tmp, $new);                                                                 // renames temp file on server
967
-			$tmp = $new;                                                                        // push new filename (in path) to be used in file array later
965
+			$new = $tmppath['dirname']."/".$filename.".".$extension;
966
+			rename($tmp, $new); // renames temp file on server
967
+			$tmp = $new; // push new filename (in path) to be used in file array later
968 968
 		}
969 969
 
970 970
 		// assemble file data (should be built like $_FILES since wp_handle_sideload() will be using)
971
-		$file_array['tmp_name'] = $tmp;                                                         // full server path to temp file
971
+		$file_array['tmp_name'] = $tmp; // full server path to temp file
972 972
 
973
-		if ( !empty( $filename) && " " != $filename )
973
+		if (!empty($filename) && " " != $filename)
974 974
 		{
975
-			$file_array['name'] = $filename . "." . $url_type['ext'];                           // user given filename for title, add original URL extension
975
+			$file_array['name'] = $filename.".".$url_type['ext']; // user given filename for title, add original URL extension
976 976
 		}
977 977
 		else
978 978
 		{
979
-			$file_array['name'] = $url_filename;                                                // just use original URL filename
979
+			$file_array['name'] = $url_filename; // just use original URL filename
980 980
 		}
981 981
 
982 982
 		// set additional wp_posts columns
983
-		if ( empty( $post_data['post_title'] ) )
983
+		if (empty($post_data['post_title']))
984 984
 		{
985 985
 
986
-			$url_filename=str_replace('%20',' ',$url_filename);
986
+			$url_filename = str_replace('%20', ' ', $url_filename);
987 987
 
988
-			$post_data['post_title'] = basename($url_filename, "." . $url_type['ext']);         // just use the original filename (no extension)
988
+			$post_data['post_title'] = basename($url_filename, ".".$url_type['ext']); // just use the original filename (no extension)
989 989
 		}
990 990
 
991 991
 		// make sure gets tied to parent
992
-		if ( empty( $post_data['post_parent'] ) )
992
+		if (empty($post_data['post_parent']))
993 993
 		{
994 994
 			$post_data['post_parent'] = $post_id;
995 995
 		}
@@ -997,12 +997,12 @@  discard block
 block discarded – undo
997 997
 		// required libraries for media_handle_sideload
998 998
 
999 999
 		// do the validation and storage stuff
1000
-		$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
1000
+		$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
1001 1001
 
1002 1002
 		// If error storing permanently, unlink
1003
-		if ( is_wp_error($att_id) )
1003
+		if (is_wp_error($att_id))
1004 1004
 		{
1005
-			unlink($file_array['tmp_name']);   // clean up
1005
+			unlink($file_array['tmp_name']); // clean up
1006 1006
 			return false; // output wp_error
1007 1007
 			//return $att_id; // output wp_error
1008 1008
 		}
@@ -1030,24 +1030,24 @@  discard block
 block discarded – undo
1030 1030
 	/**
1031 1031
 	 * Formats the row for the completed list.
1032 1032
 	 */
1033
-	public function format_completed_row($response){
1033
+	public function format_completed_row($response) {
1034 1034
 		echo '<li class="post-'.$response.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($response).'">'.get_the_title($response).'</a></li>';
1035 1035
 	}
1036 1036
 
1037 1037
 	/**
1038 1038
 	 * Does a multine search
1039 1039
 	 */
1040
-	public function multineedle_stripos($haystack, $needles, $offset=0) {
1040
+	public function multineedle_stripos($haystack, $needles, $offset = 0) {
1041 1041
 		$found = false;
1042 1042
 		$needle_count = count($needles);
1043
-		foreach($needles as $needle) {
1044
-			if(false !== stripos($haystack, $needle, $offset)){
1043
+		foreach ($needles as $needle) {
1044
+			if (false !== stripos($haystack, $needle, $offset)) {
1045 1045
 				$found[] = true;
1046 1046
 			}
1047 1047
 		}
1048
-		if(false !== $found && $needle_count === count($found)){
1048
+		if (false !== $found && $needle_count === count($found)) {
1049 1049
 			return true;
1050
-		}else{
1050
+		}else {
1051 1051
 			return false;
1052 1052
 		}
1053 1053
 	}
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
 	/**
1056 1056
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
1057 1057
 	 */
1058
-	public function find_current_accommodation($post_type='accommodation') {
1058
+	public function find_current_accommodation($post_type = 'accommodation') {
1059 1059
 		global $wpdb;
1060 1060
 		$return = array();
1061 1061
 
@@ -1071,8 +1071,8 @@  discard block
 block discarded – undo
1071 1071
 
1072 1072
 					LIMIT 0,500
1073 1073
 		");
1074
-		if(null !== $current_accommodation && !empty($current_accommodation)){
1075
-			foreach($current_accommodation as $accom){
1074
+		if (null !== $current_accommodation && !empty($current_accommodation)) {
1075
+			foreach ($current_accommodation as $accom) {
1076 1076
 				$return[$accom->meta_value] = $accom;
1077 1077
 			}
1078 1078
 		}
Please login to merge, or discard this patch.
Braces   +16 added lines, -22 removed lines patch added patch discarded remove patch
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 			if(isset($_GET['tab']) || isset($_POST['type'])) {
217 217
 				if(isset($_GET['tab'])) {
218 218
 					$this->tab_slug = $_GET['tab'];
219
-				}else{
219
+				} else{
220 220
 					$this->tab_slug = $_POST['type'];
221 221
 				}
222 222
 
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 					<?php } ?>
394 394
                 </ul>
395 395
 				<?php
396
-			}else{
396
+			} else{
397 397
 			   $this->current_importer->display_page();
398 398
             }; ?>
399 399
         </div>
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 					foreach($team_members->posts as $member){ ?>
515 515
                         <li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
516 516
 					<?php }
517
-				}else{ ?>
517
+				} else{ ?>
518 518
                     <li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li>
519 519
 				<?php }
520 520
 				?>
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 			if (in_array($needle, $haystack)) {
580 580
 				if(true === $wrap || 'true' === $wrap) {
581 581
 					$html = $type . '="' . $type . '"';
582
-				}else{
582
+				} else{
583 583
 					$html = $type;
584 584
 				}
585 585
 			}
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 
632 632
 			if(false !== $id && '0' !== $id && false !== $prev && true === $unique){
633 633
 				update_post_meta($id,$meta_key,$value,$prev);
634
-			}else{
634
+			} else{
635 635
 				add_post_meta($id,$meta_key,$value,$unique);
636 636
 			}
637 637
 		}
@@ -672,18 +672,15 @@  discard block
 block discarded – undo
672 672
 						if ( is_wp_error($term) )
673 673
 						{
674 674
 							echo $term->get_error_message();
675
-						}
676
-						else
675
+						} else
677 676
 						{
678 677
 							wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
679 678
 						}
680
-					}
681
-					else
679
+					} else
682 680
 					{
683 681
 						wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
684 682
 					}
685
-				}
686
-				else
683
+				} else
687 684
 				{
688 685
 					$result[]=trim($k);
689 686
 				}
@@ -697,10 +694,8 @@  discard block
 block discarded – undo
697 694
 		{
698 695
 			if(false !== $parent){ $parent = array('parent'=>$parent); }
699 696
 			$term = wp_insert_term(trim($name), $taxonomy,$parent);
700
-			if ( is_wp_error($term) ){echo $term->get_error_message();}
701
-			else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
702
-		}
703
-		else
697
+			if ( is_wp_error($term) ){echo $term->get_error_message();} else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); }
698
+		} else
704 699
 		{
705 700
 			wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true);
706 701
 		}
@@ -720,7 +715,7 @@  discard block
 block discarded – undo
720 715
 				foreach($terms as $term){
721 716
 					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected,$term->term_id,false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
722 717
 				}
723
-			}else{
718
+			} else{
724 719
 				$return .= '<li><input type="checkbox" value="" /> '.__('None','wetu-importer').'</li>';
725 720
 			}
726 721
 			$return .= '</ul>';
@@ -739,13 +734,13 @@  discard block
 block discarded – undo
739 734
 
740 735
 			if(isset($data[0]['position']['driving_latitude'])){
741 736
 				$latitude = $data[0]['position']['driving_latitude'];
742
-			}elseif(isset($data[0]['position']['latitude'])){
737
+			} elseif(isset($data[0]['position']['latitude'])){
743 738
 				$latitude = $data[0]['position']['latitude'];
744 739
 			}
745 740
 
746 741
 			if(isset($data[0]['position']['driving_longitude'])){
747 742
 				$longitude = $data[0]['position']['driving_longitude'];
748
-			}elseif(isset($data[0]['position']['longitude'])){
743
+			} elseif(isset($data[0]['position']['longitude'])){
749 744
 				$longitude = $data[0]['position']['longitude'];
750 745
 			}
751 746
 
@@ -777,7 +772,7 @@  discard block
 block discarded – undo
777 772
 			if(false !== $id && '0' !== $id){
778 773
 				$prev = get_post_meta($id,'location',true);
779 774
 				update_post_meta($id,'location',$location_data,$prev);
780
-			}else{
775
+			} else{
781 776
 				add_post_meta($id,'location',$location_data,true);
782 777
 			}
783 778
 		}
@@ -973,8 +968,7 @@  discard block
 block discarded – undo
973 968
 		if ( !empty( $filename) && " " != $filename )
974 969
 		{
975 970
 			$file_array['name'] = $filename . "." . $url_type['ext'];                           // user given filename for title, add original URL extension
976
-		}
977
-		else
971
+		} else
978 972
 		{
979 973
 			$file_array['name'] = $url_filename;                                                // just use original URL filename
980 974
 		}
@@ -1047,7 +1041,7 @@  discard block
 block discarded – undo
1047 1041
 		}
1048 1042
 		if(false !== $found && $needle_count === count($found)){
1049 1043
 			return true;
1050
-		}else{
1044
+		} else{
1051 1045
 			return false;
1052 1046
 		}
1053 1047
 	}
Please login to merge, or discard this patch.
classes/class-tours.php 4 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -568,6 +568,7 @@  discard block
 block discarded – undo
568 568
 
569 569
 	/**
570 570
 	 * A loop which runs through each leg on the tour.
571
+	 * @param boolean $importable_content
571 572
 	 */
572 573
 	public function process_itineraries($data,$id,$importable_content) {
573 574
 		$day_counter = 1;
@@ -822,6 +823,7 @@  discard block
 block discarded – undo
822 823
 	 *
823 824
 	 * @param $day array
824 825
 	 * @param $id string
826
+	 * @param integer $leg_counter
825 827
 	 * @return boolean / string
826 828
 	 */
827 829
 	public function set_destination($day,$id,$leg_counter) {
Please login to merge, or discard this patch.
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function set_variables()
99 99
 	{
100
-	    parent::set_variables();
100
+		parent::set_variables();
101 101
 
102 102
 		if ( false !== $this->api_username && false !== $this->api_password ) {
103 103
 			$this->url    = 'https://wetu.com/API/Itinerary/';
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 * Display the importer administration screen
123 123
 	 */
124 124
 	public function display_page() {
125
-        ?>
125
+		?>
126 126
         <div class="wrap">
127 127
 			<?php $this->navigation('tour'); ?>
128 128
 
@@ -254,20 +254,20 @@  discard block
 block discarded – undo
254 254
 			$result = $this->update_options();
255 255
 
256 256
 			if(true === $result){
257
-			    echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
258
-                echo ' - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>';
259
-            }else{
260
-			    echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
261
-            }
257
+				echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
258
+				echo ' - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>';
259
+			}else{
260
+				echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
261
+			}
262 262
 		}else{
263 263
 			echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>';
264
-        }
264
+		}
265 265
 		echo '</h3>';
266 266
 
267 267
 		$form_options = get_option('lsx_ti_tours_api_options');
268 268
 		if(false === $form_options){
269 269
 			$form_options = array(0);
270
-        }
270
+		}
271 271
 		?>
272 272
         <form method="get" class="tour-refresh-form" action="<?php echo admin_url('admin.php'); ?>">
273 273
 
@@ -295,15 +295,15 @@  discard block
 block discarded – undo
295 295
 	 */
296 296
 	public function update_options() {
297 297
 
298
-	    $own = '';
299
-	    $options = array();
298
+		$own = '';
299
+		$options = array();
300 300
 
301
-	    delete_option('lsx_ti_tours_api_options');
301
+		delete_option('lsx_ti_tours_api_options');
302 302
 
303
-	    if(isset($_GET['own'])){
303
+		if(isset($_GET['own'])){
304 304
 			$this->url_qs .= '&own=true';
305 305
 			$options[] = 'own';
306
-        }
306
+		}
307 307
 
308 308
 		if(isset($_GET['type'])){
309 309
 			$this->url_qs .= '&type='.implode('',$_GET['type']);
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
 		$tours = json_decode($data, true);
320 320
 
321 321
 		if(isset($tours['error'])){
322
-		    return $tours['error'];
323
-        }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
322
+			return $tours['error'];
323
+		}elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
324 324
 			set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2);
325 325
 			return true;
326 326
 		}
@@ -523,71 +523,71 @@  discard block
 block discarded – undo
523 523
 				$content = false;
524 524
 			}
525 525
 
526
-            $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
526
+			$jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
527 527
 
528
-            if($jdata)
529
-            {
528
+			if($jdata)
529
+			{
530 530
 				$jdata=json_decode($jdata,true);
531
-                if(!empty($jdata))
532
-                {
533
-                	$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
534
-                	$this->format_completed_row($return);
535
-                	$this->cleanup_posts();
536
-                	$this->attach_destination_images($content);
537
-                }
538
-            }
531
+				if(!empty($jdata))
532
+				{
533
+					$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
534
+					$this->format_completed_row($return);
535
+					$this->cleanup_posts();
536
+					$this->attach_destination_images($content);
537
+				}
538
+			}
539 539
 		}
540 540
 	}
541 541
 
542 542
 	/**
543 543
 	 * Connect to wetu
544
-     *
545
-     * @param $data array
546
-     * @param $wetu_id string
544
+	 *
545
+	 * @param $data array
546
+	 * @param $wetu_id string
547 547
 	 */
548 548
 	public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) {
549
-        $post_name = $data_post_content = $data_post_excerpt = '';
550
-        $post = array(
551
-          'post_type'		=> 'tour',
552
-        );
549
+		$post_name = $data_post_content = $data_post_excerpt = '';
550
+		$post = array(
551
+		  'post_type'		=> 'tour',
552
+		);
553 553
 
554
-        //Set the post_content
554
+		//Set the post_content
555 555
 		$content_used_general_description = false;
556
-        if(false !== $importable_content && in_array('description',$importable_content)){
557
-            $data_post_content = '';
558
-
559
-            if(isset($data['description'])){
560
-                $data_post_content = $data['description'];
561
-            }elseif(isset($data['summary'])){
562
-                $data_post_content = $data['summary'];
563
-            }
564
-            $post['post_content'] = $data_post_content;
565
-        }
566
-
567
-        //Create or update the post
568
-        if(false !== $id && '0' !== $id){
569
-            $post['ID'] = $id;
570
-	        $post['post_status'] = 'publish';
571
-            $id = wp_update_post($post);
572
-            $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
573
-            update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
574
-        }else{
575
-
576
-            //Set the name
577
-            if(isset($data['name'])){
578
-                $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
579
-            }
580
-            $post['post_name'] = $post_name;
581
-            $post['post_title'] = $data['name'];
582
-            $post['post_status'] = 'publish';
583
-            $id = wp_insert_post($post);
584
-
585
-            //Save the WETU ID and the Last date it was modified.
586
-            if(false !== $id){
587
-                add_post_meta($id,'lsx_wetu_id',$wetu_id);
588
-                add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
589
-            }
590
-        }
556
+		if(false !== $importable_content && in_array('description',$importable_content)){
557
+			$data_post_content = '';
558
+
559
+			if(isset($data['description'])){
560
+				$data_post_content = $data['description'];
561
+			}elseif(isset($data['summary'])){
562
+				$data_post_content = $data['summary'];
563
+			}
564
+			$post['post_content'] = $data_post_content;
565
+		}
566
+
567
+		//Create or update the post
568
+		if(false !== $id && '0' !== $id){
569
+			$post['ID'] = $id;
570
+			$post['post_status'] = 'publish';
571
+			$id = wp_update_post($post);
572
+			$prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
573
+			update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
574
+		}else{
575
+
576
+			//Set the name
577
+			if(isset($data['name'])){
578
+				$post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
579
+			}
580
+			$post['post_name'] = $post_name;
581
+			$post['post_title'] = $data['name'];
582
+			$post['post_status'] = 'publish';
583
+			$id = wp_insert_post($post);
584
+
585
+			//Save the WETU ID and the Last date it was modified.
586
+			if(false !== $id){
587
+				add_post_meta($id,'lsx_wetu_id',$wetu_id);
588
+				add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
589
+			}
590
+		}
591 591
 
592 592
 
593 593
 		//Set the price
@@ -600,15 +600,15 @@  discard block
 block discarded – undo
600 600
 			$this->set_duration($data,$id);
601 601
 		}
602 602
 
603
-        if(false !== $importable_content && in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
604
-            $this->process_itineraries($data,$id,$importable_content);
605
-        }
603
+		if(false !== $importable_content && in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
604
+			$this->process_itineraries($data,$id,$importable_content);
605
+		}
606 606
 
607 607
 		if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){
608 608
 			$this->set_map_data($data,$id);
609 609
 		}
610 610
 
611
-        return $id;
611
+		return $id;
612 612
 	}
613 613
 
614 614
 	/**
@@ -770,17 +770,17 @@  discard block
 block discarded – undo
770 770
 	 * Set the Itinerary Day
771 771
 	 */
772 772
 	public function set_itinerary_day($day,$id) {
773
-        $this->save_custom_field($day,'itinerary',$id,false,false);
773
+		$this->save_custom_field($day,'itinerary',$id,false,false);
774 774
 	}
775 775
 
776 776
 	/**
777 777
 	 * Set the price
778 778
 	 */
779 779
 	public function set_price($data,$id) {
780
-	    //Price
780
+		//Price
781 781
 		if(isset($data['price']) && ''!== $data['price']){
782
-            $price = preg_replace("/[^0-9,.]/", "", $data['price']);
783
-            $this->save_custom_field($price,'price',$id);
782
+			$price = preg_replace("/[^0-9,.]/", "", $data['price']);
783
+			$this->save_custom_field($price,'price',$id);
784 784
 		}
785 785
 
786 786
 		//Price includes
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 			$this->save_custom_field($data['price_includes'],'included',$id);
789 789
 		}
790 790
 
791
-        //Price Excludes
791
+		//Price Excludes
792 792
 		if(isset($data['price_excludes']) && ''!== $data['price_excludes']){
793 793
 			$this->save_custom_field($data['price_excludes'],'not_included',$id);
794 794
 		}
@@ -811,35 +811,35 @@  discard block
 block discarded – undo
811 811
 	 */
812 812
 	public function set_accommodation($day,$id) {
813 813
 
814
-	    $ac_id = false;
814
+		$ac_id = false;
815 815
 		$this->current_accommodation = $this->find_current_accommodation();
816 816
 		
817 817
 		if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){
818 818
 
819 819
 			if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){
820
-                $ac_id = $this->current_accommodation[$day['content_entity_id']];
820
+				$ac_id = $this->current_accommodation[$day['content_entity_id']];
821 821
 			}else{
822 822
 				$ac_id = wp_insert_post(array(
823
-                    'post_type' => 'accommodation',
824
-                    'post_status' => 'draft',
825
-                    'post_title' => $day['content_entity_id']
826
-                ));
823
+					'post_type' => 'accommodation',
824
+					'post_status' => 'draft',
825
+					'post_title' => $day['content_entity_id']
826
+				));
827 827
 				$this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id);
828 828
 			}
829 829
 
830 830
 			if('' !== $ac_id && false !== $ac_id){
831
-			    $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
831
+				$this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
832 832
 				$this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false);
833
-            }
833
+			}
834 834
 		}
835 835
 		return $ac_id;
836 836
 	}
837 837
 
838 838
 	/**
839 839
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
840
-     *
841
-     * @param $post_type string
842
-     * @return boolean / array
840
+	 *
841
+	 * @param $post_type string
842
+	 * @return boolean / array
843 843
 	 */
844 844
 	public function find_current_accommodation($post_type='accommodation') {
845 845
 		global $wpdb;
@@ -847,16 +847,16 @@  discard block
 block discarded – undo
847 847
 
848 848
 		$return = false;
849 849
 		if(!empty($accommodation)){
850
-		    foreach($accommodation as $key => $acc){
850
+			foreach($accommodation as $key => $acc){
851 851
 				$return[$acc->meta_value] = $acc->post_id;
852
-            }
853
-        }
852
+			}
853
+		}
854 854
 		return $return;
855 855
 	}
856 856
 
857 857
 	/**
858 858
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
859
-     * @return boolean / array
859
+	 * @return boolean / array
860 860
 	 */
861 861
 	public function find_current_destinations() {
862 862
 		return $this->find_current_accommodation('destination');
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 				$country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true);
885 885
 				if(false !== $country_wetu_id){
886 886
 					$country_id = $this->set_country($country_wetu_id, $id);
887
-                }
887
+				}
888 888
 
889 889
 			}else {
890 890
 
@@ -895,27 +895,27 @@  discard block
 block discarded – undo
895 895
 
896 896
 					if (!empty($destination_data) && !isset($destination_data['error'])) {
897 897
 
898
-					    $destination_title = $day['destination_content_entity_id'];
898
+						$destination_title = $day['destination_content_entity_id'];
899 899
 
900
-					    if(isset($destination_data[0]['name'])){
900
+						if(isset($destination_data[0]['name'])){
901 901
 							$destination_title = $destination_data[0]['name'];
902
-                        }
902
+						}
903 903
 
904
-					    if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
905
-                            && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
904
+						if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
905
+							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
906 906
 
907 907
 							$country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id);
908
-                        }
908
+						}
909 909
 
910
-                        $dest_post = array(
910
+						$dest_post = array(
911 911
 							'post_type' => 'destination',
912 912
 							'post_status' => 'draft',
913 913
 							'post_title' => $destination_title
914 914
 						);
915 915
 
916
-					    if(false !== $country_id){
916
+						if(false !== $country_id){
917 917
 							$dest_post['post_parent'] = $country_id;
918
-                        }
918
+						}
919 919
 						$dest_id = wp_insert_post($dest_post);
920 920
 
921 921
 						//Make sure we register the
@@ -933,16 +933,16 @@  discard block
 block discarded – undo
933 933
 
934 934
 				// Save the first destination so we can grab the tour featured image and banner
935 935
 				if(0 === $leg_counter){
936
-				    $this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']);
937
-                }
936
+					$this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']);
937
+				}
938 938
 
939 939
 				//Add this relation info so we can make sure certain items are set as countries.
940 940
 				if(0 !== $country_id && false !== $country_id){
941
-                    $this->relation_meta[$dest_id] = $country_id;
941
+					$this->relation_meta[$dest_id] = $country_id;
942 942
 					$this->relation_meta[$country_id] = 0;
943
-                }else{
943
+				}else{
944 944
 					$this->relation_meta[$dest_id] = 0;
945
-                }
945
+				}
946 946
 			}
947 947
 		}
948 948
 		return $dest_id;
@@ -952,53 +952,53 @@  discard block
 block discarded – undo
952 952
 	 * Connects the destinations post type
953 953
 	 *
954 954
 	 * @param $dest_id string
955
-     * @param $country_id array
955
+	 * @param $country_id array
956 956
 	 * @param $id string
957
-     *
958
-     * @return string
957
+	 *
958
+	 * @return string
959 959
 	 */
960 960
 	public function set_country($country_wetu_id, $id) {
961
-	    $country_id = false;
961
+		$country_id = false;
962 962
 		$this->current_destinations = $this->find_current_destinations();
963 963
 
964
-        if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
965
-            $country_id = $this->current_destinations[$country_wetu_id];
966
-        } else {
964
+		if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
965
+			$country_id = $this->current_destinations[$country_wetu_id];
966
+		} else {
967 967
 
968
-            $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
968
+			$country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
969 969
 
970
-            if ($country_json) {
971
-                $country_data = json_decode($country_json, true);
970
+			if ($country_json) {
971
+				$country_data = json_decode($country_json, true);
972 972
 
973
-                if (!empty($country_data) && !isset($country_data['error'])) {
973
+				if (!empty($country_data) && !isset($country_data['error'])) {
974 974
 
975 975
 					//Format the title of the destination if its available,  otherwise default to the WETU ID.
976
-                    $country_title = $country_wetu_id;
977
-                    if (isset($country_data[0]['name'])) {
976
+					$country_title = $country_wetu_id;
977
+					if (isset($country_data[0]['name'])) {
978 978
 						$country_title = $country_data[0]['name'];
979
-                    }
979
+					}
980 980
 
981 981
 					$country_id = wp_insert_post(array(
982
-                        'post_type' => 'destination',
983
-                        'post_status' => 'draft',
984
-                        'post_title' => $country_title
985
-                    ));
982
+						'post_type' => 'destination',
983
+						'post_status' => 'draft',
984
+						'post_title' => $country_title
985
+					));
986 986
 					//add the country to the current destination stack
987 987
 					$this->current_destinations[$country_wetu_id] = $country_id;
988 988
 
989 989
 					//Save the wetu field
990
-                    $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
991
-                }
992
-            }
993
-        }
994
-
995
-        if ('' !== $country_id && false !== $country_id) {
996
-            $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
997
-            $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
990
+					$this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
991
+				}
992
+			}
993
+		}
994
+
995
+		if ('' !== $country_id && false !== $country_id) {
996
+			$this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
997
+			$this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
998 998
 			$this->cleanup_posts[$country_id] = 'tour_to_destination';
999 999
 
1000
-            return $country_id;
1001
-        }
1000
+			return $country_id;
1001
+		}
1002 1002
 	}
1003 1003
 
1004 1004
 	/**
@@ -1011,9 +1011,9 @@  discard block
 block discarded – undo
1011 1011
 	 * @return string
1012 1012
 	 */
1013 1013
 	public function attach_destination_images($importable_content=array()) {
1014
-	    if(false !== $this->destination_images){
1014
+		if(false !== $this->destination_images){
1015 1015
 
1016
-	        foreach($this->destination_images as $tour => $destination){
1016
+			foreach($this->destination_images as $tour => $destination){
1017 1017
 
1018 1018
 				$url = 'https://wetu.com/API/Pins/' . $this->api_key;
1019 1019
 				$url_qs = '';
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 						}
1035 1035
 					}
1036 1036
 				}
1037
-            }
1038
-        }
1037
+			}
1038
+		}
1039 1039
 	}
1040 1040
 }
1041 1041
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
 			if(true === $result){
257 257
 			    echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
258 258
                 echo ' - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>';
259
-            }else{
259
+            } else{
260 260
 			    echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
261 261
             }
262
-		}else{
262
+		} else{
263 263
 			echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>';
264 264
         }
265 265
 		echo '</h3>';
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 
321 321
 		if(isset($tours['error'])){
322 322
 		    return $tours['error'];
323
-        }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
323
+        } elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
324 324
 			set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2);
325 325
 			return true;
326 326
 		}
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 
370 370
 				if(isset($_POST['keyword'] )) {
371 371
 					$keyphrases = $_POST['keyword'];
372
-				}else{
372
+				} else{
373 373
 					$keyphrases = array(0);
374 374
 				}
375 375
 
@@ -421,16 +421,16 @@  discard block
 block discarded – undo
421 421
 
422 422
 								if(0 !== $row['post_id']){
423 423
 									continue;
424
-								}else{
424
+								} else{
425 425
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
426 426
 								}
427 427
 
428 428
 
429
-							}else{
429
+							} else{
430 430
 
431 431
 								if(0 === $row['post_id']){
432 432
 									continue;
433
-								}else{
433
+								} else{
434 434
 									$current_status = get_post_status($row['post_id']);
435 435
 									if($current_status !== $post_status){
436 436
 										continue;
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 
442 442
 							}
443 443
 
444
-						}else{
444
+						} else{
445 445
 							//Search through each keyword.
446 446
 							foreach($keyphrases as $keyphrase){
447 447
 
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 			$wetu_id = $_POST['wetu_id'];
512 512
 			if(isset($_POST['post_id'])){
513 513
 				$post_id = $_POST['post_id'];	
514
-			}else{
514
+			} else{
515 515
 				$post_id = 0;
516 516
 			}
517 517
 
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
520 520
 				$content = $_POST['content'];
521 521
 				add_option('wetu_importer_tour_settings',$content);
522
-			}else{
522
+			} else{
523 523
 				$content = false;
524 524
 			}
525 525
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 
559 559
             if(isset($data['description'])){
560 560
                 $data_post_content = $data['description'];
561
-            }elseif(isset($data['summary'])){
561
+            } elseif(isset($data['summary'])){
562 562
                 $data_post_content = $data['summary'];
563 563
             }
564 564
             $post['post_content'] = $data_post_content;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
             $id = wp_update_post($post);
572 572
             $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
573 573
             update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
574
-        }else{
574
+        } else{
575 575
 
576 576
             //Set the name
577 577
             if(isset($data['name'])){
@@ -662,42 +662,42 @@  discard block
 block discarded – undo
662 662
 						//Description
663 663
 						if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){
664 664
 							$current_day['description'] = $day['notes'];
665
-						}else{
665
+						} else{
666 666
 							$current_day['description'] = '';
667 667
 						}
668 668
 
669 669
 						//Itinerary Gallery
670 670
 						if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){
671 671
 							$current_day['featured_image'] = '';
672
-						}else{
672
+						} else{
673 673
 							$current_day['featured_image'] = '';
674 674
 						}
675 675
 
676 676
 						//Accommodation
677 677
 						if(false !== $current_accommodation){
678 678
 							$current_day['accommodation_to_tour'] = array($current_accommodation);
679
-						}else{
679
+						} else{
680 680
 							$current_day['accommodation_to_tour'] = array();
681 681
 						}
682 682
 
683 683
 						//Destination
684 684
 						if(false !== $current_destination){
685 685
 							$current_day['destination_to_tour'] = array($current_destination);
686
-						}else{
686
+						} else{
687 687
 							$current_day['destination_to_tour'] = array();
688 688
 						}
689 689
 
690 690
 						//Included
691 691
 						if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){
692 692
 							$current_day['included'] = $day['included'];
693
-						}else{
693
+						} else{
694 694
 							$current_day['included'] = '';
695 695
 						}
696 696
 
697 697
 						//Excluded
698 698
 						if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){
699 699
 							$current_day['excluded'] = $day['excluded'];
700
-						}else{
700
+						} else{
701 701
 							$current_day['excluded'] = '';
702 702
 						}
703 703
 
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 						$day_counter++;
706 706
 					}
707 707
 
708
-				}else{
708
+				} else{
709 709
 					$day_counter = $day_counter + (int)$leg['nights'];
710 710
 				}
711 711
 
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
 
819 819
 			if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){
820 820
                 $ac_id = $this->current_accommodation[$day['content_entity_id']];
821
-			}else{
821
+			} else{
822 822
 				$ac_id = wp_insert_post(array(
823 823
                     'post_type' => 'accommodation',
824 824
                     'post_status' => 'draft',
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
 					$country_id = $this->set_country($country_wetu_id, $id);
887 887
                 }
888 888
 
889
-			}else {
889
+			} else {
890 890
 
891 891
 				$destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']);
892 892
 
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 				if(0 !== $country_id && false !== $country_id){
941 941
                     $this->relation_meta[$dest_id] = $country_id;
942 942
 					$this->relation_meta[$country_id] = 0;
943
-                }else{
943
+                } else{
944 944
 					$this->relation_meta[$dest_id] = 0;
945 945
                 }
946 946
 			}
Please login to merge, or discard this patch.
Spacing   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -99,21 +99,21 @@  discard block
 block discarded – undo
99 99
 	{
100 100
 	    parent::set_variables();
101 101
 
102
-		if ( false !== $this->api_username && false !== $this->api_password ) {
102
+		if (false !== $this->api_username && false !== $this->api_password) {
103 103
 			$this->url    = 'https://wetu.com/API/Itinerary/';
104
-			$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
105
-		} elseif ( false !== $this->api_key ) {
106
-			$this->url    = 'https://wetu.com/API/Itinerary/' . $this->api_key;
104
+			$this->url_qs = 'username='.$this->api_username.'&password='.$this->api_password;
105
+		} elseif (false !== $this->api_key) {
106
+			$this->url    = 'https://wetu.com/API/Itinerary/'.$this->api_key;
107 107
 			$this->url_qs = '';
108 108
 		}
109 109
 
110
-		$temp_options = get_option('_lsx-to_settings',false);
111
-		if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){
110
+		$temp_options = get_option('_lsx-to_settings', false);
111
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
112 112
 			$this->options = $temp_options[$this->plugin_slug];
113 113
 		}
114 114
 
115
-		$tour_options = get_option('wetu_importer_tour_settings',false);
116
-		if(false !== $tour_options){
115
+		$tour_options = get_option('wetu_importer_tour_settings', false);
116
+		if (false !== $tour_options) {
117 117
 			$this->tour_options = $tour_options;
118 118
 		}
119 119
 	}
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 			<form method="get" action="" id="posts-filter">
134 134
 				<input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" />
135 135
 				
136
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
137
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
136
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
137
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
138 138
 				</p>				
139 139
 
140 140
 				<table class="wp-list-table widefat fixed posts">
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 					<tbody id="the-list">
144 144
 						<tr class="post-0 type-tour status-none" id="post-0">
145 145
 							<th class="check-column" scope="row">
146
-								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label>
146
+								<label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label>
147 147
 							</th>
148 148
 							<td class="post-title page-title column-title">
149 149
 								<strong>
150
-									<?php _e('Enter a title to search for','wetu-importer'); ?>
150
+									<?php _e('Enter a title to search for', 'wetu-importer'); ?>
151 151
 								</strong>
152 152
 							</td>
153 153
 							<td class="date column-date">							
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 
162 162
 				</table>
163 163
 
164
-				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" />
165
-					<input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" />
164
+				<p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" />
165
+					<input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" />
166 166
 				</p>
167 167
 			</form>
168 168
 
@@ -174,16 +174,16 @@  discard block
 block discarded – undo
174 174
 						<div class="settings-all" style="width:30%;display:block;float:left;">
175 175
 							<h3><?php _e('What content to Sync from WETU'); ?></h3>
176 176
 							<ul>
177
-                                <li><input class="content select-all" <?php $this->checked($this->tour_options,'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php _e('Select All','wetu-importer'); ?></li>
178
-								<li><input class="content" <?php $this->checked($this->tour_options,'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li>
179
-								<li><input class="content" <?php $this->checked($this->tour_options,'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li>
177
+                                <li><input class="content select-all" <?php $this->checked($this->tour_options, 'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php _e('Select All', 'wetu-importer'); ?></li>
178
+								<li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li>
179
+								<li><input class="content" <?php $this->checked($this->tour_options, 'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li>
180 180
 
181
-                                <li><input class="content" <?php $this->checked($this->tour_options,'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price','wetu-importer'); ?></li>
182
-                                <li><input class="content" <?php $this->checked($this->tour_options,'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration','wetu-importer'); ?></li>
181
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price', 'wetu-importer'); ?></li>
182
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration', 'wetu-importer'); ?></li>
183 183
 
184
-								<li><input class="content" <?php $this->checked($this->tour_options,'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li>
184
+								<li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li>
185 185
 
186
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days','wetu-importer'); ?></li>
186
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days', 'wetu-importer'); ?></li>
187 187
 
188 188
 								<?php /*if(class_exists('LSX_TO_Maps')){ ?>
189 189
                                     <li><input class="content" <?php $this->checked($this->tour_options,'map'); ?> type="checkbox" name="content[]" value="map" /> <?php _e('Map Coordinates (generates a KML file)','wetu-importer'); ?></li>
@@ -193,20 +193,20 @@  discard block
 block discarded – undo
193 193
                         <div class="settings-all" style="width:30%;display:block;float:left;">
194 194
                             <h3><?php _e('Itinerary Info'); ?></h3>
195 195
                             <ul>
196
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description','wetu-importer'); ?></li>
197
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included','wetu-importer'); ?></li>
198
-                                <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded','wetu-importer'); ?></li>
196
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description', 'wetu-importer'); ?></li>
197
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included', 'wetu-importer'); ?></li>
198
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded', 'wetu-importer'); ?></li>
199 199
                             </ul>
200 200
 
201 201
                             <h4><?php _e('Additional Content'); ?></h4>
202 202
                             <ul>
203
-                                <li><input class="content" <?php $this->checked($this->tour_options,'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation','wetu-importer'); ?></li>
204
-                                <li><input class="content" <?php $this->checked($this->tour_options,'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations','wetu-importer'); ?></li>
205
-                                <li><input class="content" <?php $this->checked($this->tour_options,'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php _e('Featured Image','wetu-importer'); ?></li>
206
-                                <li><input class="content" <?php $this->checked($this->tour_options,'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php _e('Banner Image','wetu-importer'); ?></li>
203
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation', 'wetu-importer'); ?></li>
204
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations', 'wetu-importer'); ?></li>
205
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php _e('Featured Image', 'wetu-importer'); ?></li>
206
+                                <li><input class="content" <?php $this->checked($this->tour_options, 'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php _e('Banner Image', 'wetu-importer'); ?></li>
207 207
                             </ul>
208 208
                         </div>
209
-                        <?php if(class_exists('LSX_TO_Team')){ ?>
209
+                        <?php if (class_exists('LSX_TO_Team')) { ?>
210 210
                             <div style="width:30%;display:block;float:left;">
211 211
                                 <h3><?php _e('Assign a Team Member'); ?></h3>
212 212
                                 <?php $this->team_member_checkboxes($this->tour_options); ?>
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 
219 219
 
220 220
 					<h3><?php _e('Your List'); ?></h3>
221
-                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
221
+                    <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
222 222
 					<table class="wp-list-table widefat fixed posts">
223 223
 						<?php $this->table_header(); ?>
224 224
 
@@ -230,12 +230,12 @@  discard block
 block discarded – undo
230 230
 
231 231
 					</table>
232 232
 
233
-					<p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p>
233
+					<p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p>
234 234
 				</form>
235 235
 			</div>
236 236
 
237 237
 			<div style="display:none;" class="completed-list-wrapper">
238
-				<h3><?php _e('Completed','wetu-importer'); ?> - <small><?php _e('Import your','wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next','wetu-importer'); ?></small></h3>
238
+				<h3><?php _e('Completed', 'wetu-importer'); ?> - <small><?php _e('Import your', 'wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next', 'wetu-importer'); ?></small></h3>
239 239
 				<ul>
240 240
 				</ul>
241 241
 			</div>
@@ -249,23 +249,23 @@  discard block
 block discarded – undo
249 249
 	public function update_options_form() {
250 250
 		$tours = get_transient('lsx_ti_tours');
251 251
 
252
-		echo '<div class="wetu-status tour-wetu-status"><h3>'.__('Wetu Status','wetu-importer').' - ';
253
-		if('' === $tours || false === $tours || isset($_GET['refresh_tours'])){
252
+		echo '<div class="wetu-status tour-wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').' - ';
253
+		if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) {
254 254
 			$result = $this->update_options();
255 255
 
256
-			if(true === $result){
257
-			    echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>';
258
-                echo ' - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>';
259
-            }else{
256
+			if (true === $result) {
257
+			    echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>';
258
+                echo ' - <small><a href="#">'.esc_attr('Refresh', 'wetu-importer').'</a></small>';
259
+            }else {
260 260
 			    echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
261 261
             }
262
-		}else{
263
-			echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh','wetu-importer').'</a></small>';
262
+		}else {
263
+			echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh', 'wetu-importer').'</a></small>';
264 264
         }
265 265
 		echo '</h3>';
266 266
 
267 267
 		$form_options = get_option('lsx_ti_tours_api_options');
268
-		if(false === $form_options){
268
+		if (false === $form_options) {
269 269
 			$form_options = array(0);
270 270
         }
271 271
 		?>
@@ -276,16 +276,16 @@  discard block
 block discarded – undo
276 276
             <input type="hidden" name="refresh_tours" value="true" />
277 277
 
278 278
             <p class="tour-search-options">
279
-                <label for="own"><input class="content" <?php if(in_array('own',$form_options)){ echo 'checked'; } ?> type="checkbox" name="own" value="true" /> <?php esc_html_e('Own Tours','wetu-importer'); ?> </label>
279
+                <label for="own"><input class="content" <?php if (in_array('own', $form_options)) { echo 'checked'; } ?> type="checkbox" name="own" value="true" /> <?php esc_html_e('Own Tours', 'wetu-importer'); ?> </label>
280 280
             </p>
281 281
 
282 282
             <p class="tour-search-options">
283
-                <label for="type"><input class="content" <?php if(in_array('allitineraries',$form_options)){ echo 'checked'; } ?> type="radio" name="type[]" value="allitineraries" /> <?php _e('All','wetu-importer'); ?></label>
284
-                <label for="type"><input class="content" <?php if(in_array('sample',$form_options)){ echo 'checked'; } ?> type="radio" name="type[]" value="sample" /> <?php _e('Sample','wetu-importer'); ?></label>
285
-                <label for="type"><input class="content" <?php if(in_array('personal',$form_options)){ echo 'checked'; } ?> type="radio" name="type[]" value="personal" /> <?php _e('Personal','wetu-importer'); ?></label>
283
+                <label for="type"><input class="content" <?php if (in_array('allitineraries', $form_options)) { echo 'checked'; } ?> type="radio" name="type[]" value="allitineraries" /> <?php _e('All', 'wetu-importer'); ?></label>
284
+                <label for="type"><input class="content" <?php if (in_array('sample', $form_options)) { echo 'checked'; } ?> type="radio" name="type[]" value="sample" /> <?php _e('Sample', 'wetu-importer'); ?></label>
285
+                <label for="type"><input class="content" <?php if (in_array('personal', $form_options)) { echo 'checked'; } ?> type="radio" name="type[]" value="personal" /> <?php _e('Personal', 'wetu-importer'); ?></label>
286 286
             </p>
287 287
 
288
-            <p><input class="button button-primary submit" type="submit" value="<?php echo esc_attr('Refresh Tours','wetu-importer'); ?>"></p>
288
+            <p><input class="button button-primary submit" type="submit" value="<?php echo esc_attr('Refresh Tours', 'wetu-importer'); ?>"></p>
289 289
         </form>
290 290
 <br />
291 291
 		<?php
@@ -302,28 +302,28 @@  discard block
 block discarded – undo
302 302
 
303 303
 	    delete_option('lsx_ti_tours_api_options');
304 304
 
305
-	    if(isset($_GET['own'])){
305
+	    if (isset($_GET['own'])) {
306 306
 			$this->url_qs .= '&own=true';
307 307
 			$options[] = 'own';
308 308
         }
309 309
 
310
-		if(isset($_GET['type'])){
311
-			$this->url_qs .= '&type='.implode('',$_GET['type']);
312
-			$options[] = implode('',$_GET['type']);
310
+		if (isset($_GET['type'])) {
311
+			$this->url_qs .= '&type='.implode('', $_GET['type']);
312
+			$options[] = implode('', $_GET['type']);
313 313
 		}
314 314
 
315 315
 		$this->url_qs .= '&results=2000';
316 316
 
317
-		add_option('lsx_ti_tours_api_options',$options);
317
+		add_option('lsx_ti_tours_api_options', $options);
318 318
 
319
-		$data = file_get_contents( $this->url . '/V7/List?' . $this->url_qs );
319
+		$data = file_get_contents($this->url.'/V7/List?'.$this->url_qs);
320 320
 
321 321
 		$tours = json_decode($data, true);
322 322
 
323
-		if(isset($tours['error'])){
323
+		if (isset($tours['error'])) {
324 324
 		    return $tours['error'];
325 325
         }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
326
-			set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2);
326
+			set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2);
327 327
 			return true;
328 328
 		}
329 329
 	}
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
 
348 348
 					LIMIT 0,500
349 349
 		");
350
-		if(null !== $current_tours && !empty($current_tours)){
351
-			foreach($current_tours as $tour){
350
+		if (null !== $current_tours && !empty($current_tours)) {
351
+			foreach ($current_tours as $tour) {
352 352
 				$return[$tour->meta_value] = $tour;
353 353
 			}
354 354
 		}
@@ -361,38 +361,38 @@  discard block
 block discarded – undo
361 361
 	public function process_ajax_search() {
362 362
 		$return = false;
363 363
 
364
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug){
364
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) {
365 365
 
366 366
 
367 367
 			$tours = get_transient('lsx_ti_tours');
368
-			if ( false !== $tours) {
368
+			if (false !== $tours) {
369 369
 
370 370
 				$searched_items = false;
371 371
 
372
-				if(isset($_POST['keyword'] )) {
372
+				if (isset($_POST['keyword'])) {
373 373
 					$keyphrases = $_POST['keyword'];
374
-				}else{
374
+				}else {
375 375
 					$keyphrases = array(0);
376 376
 				}
377 377
 
378
-				if(!is_array($keyphrases)){
378
+				if (!is_array($keyphrases)) {
379 379
 					$keyphrases = array($keyphrases);
380 380
 				}
381
-				foreach($keyphrases as &$keyword){
381
+				foreach ($keyphrases as &$keyword) {
382 382
 					$keyword = ltrim(rtrim($keyword));
383 383
 				}
384 384
 
385 385
 				$post_status = false;
386
-				if(in_array('publish',$keyphrases)){
386
+				if (in_array('publish', $keyphrases)) {
387 387
 					$post_status = 'publish';
388 388
 				}
389
-				if(in_array('pending',$keyphrases)){
389
+				if (in_array('pending', $keyphrases)) {
390 390
 					$post_status = 'pending';
391 391
 				}
392
-				if(in_array('draft',$keyphrases)){
392
+				if (in_array('draft', $keyphrases)) {
393 393
 					$post_status = 'draft';
394 394
 				}
395
-				if(in_array('import',$keyphrases)){
395
+				if (in_array('import', $keyphrases)) {
396 396
 					$post_status = 'import';
397 397
 				}
398 398
 
@@ -400,9 +400,9 @@  discard block
 block discarded – undo
400 400
 				if (!empty($tours)) {
401 401
 					$current_tours = $this->find_current_tours();
402 402
 
403
-					foreach($tours as $row_key => $row){
403
+					foreach ($tours as $row_key => $row) {
404 404
 
405
-						if(isset($row['is_disabled']) && true === $row['is_disabled']){
405
+						if (isset($row['is_disabled']) && true === $row['is_disabled']) {
406 406
 							continue;
407 407
 						}
408 408
 
@@ -412,29 +412,29 @@  discard block
 block discarded – undo
412 412
 
413 413
 						//If this is a current tour, add its ID to the row.
414 414
 						$row['post_id'] = 0;
415
-						if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){
415
+						if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) {
416 416
 							$row['post_id'] = $current_tours[$row['identifier']]->post_id;
417 417
 						}
418 418
 
419 419
 						//If we are searching for
420
-						if(false !== $post_status){
420
+						if (false !== $post_status) {
421 421
 
422
-							if('import' === $post_status){
422
+							if ('import' === $post_status) {
423 423
 
424
-								if(0 !== $row['post_id']){
424
+								if (0 !== $row['post_id']) {
425 425
 									continue;
426
-								}else{
426
+								}else {
427 427
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
428 428
 								}
429 429
 
430 430
 
431
-							}else{
431
+							}else {
432 432
 
433
-								if(0 === $row['post_id']){
433
+								if (0 === $row['post_id']) {
434 434
 									continue;
435
-								}else{
435
+								}else {
436 436
 									$current_status = get_post_status($row['post_id']);
437
-									if($current_status !== $post_status){
437
+									if ($current_status !== $post_status) {
438 438
 										continue;
439 439
 									}
440 440
 
@@ -443,17 +443,17 @@  discard block
 block discarded – undo
443 443
 
444 444
 							}
445 445
 
446
-						}else{
446
+						}else {
447 447
 							//Search through each keyword.
448
-							foreach($keyphrases as $keyphrase){
448
+							foreach ($keyphrases as $keyphrase) {
449 449
 
450 450
 								//Make sure the keyphrase is turned into an array
451
-								$keywords = explode(" ",$keyphrase);
452
-								if(!is_array($keywords)){
451
+								$keywords = explode(" ", $keyphrase);
452
+								if (!is_array($keywords)) {
453 453
 									$keywords = array($keywords);
454 454
 								}
455 455
 
456
-								if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){
456
+								if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) {
457 457
 									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
458 458
 								}
459 459
 							}
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 					}
462 462
 				}
463 463
 
464
-				if(false !== $searched_items){
464
+				if (false !== $searched_items) {
465 465
 					ksort($searched_items);
466 466
 					$return = implode($searched_items);
467 467
 				}
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
 	/**
475 475
 	 * Formats the row for output on the screen.
476 476
 	 */	
477
-	public function format_row($row = false){
478
-		if(false !== $row){
477
+	public function format_row($row = false) {
478
+		if (false !== $row) {
479 479
 
480 480
 			$status = 'import';
481
-			if(0 !== $row['post_id']){
481
+			if (0 !== $row['post_id']) {
482 482
 				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
483 483
 			}
484 484
 
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 					<strong>'.$row['name'].'</strong> - '.$status.'
493 493
 				</td>
494 494
 				<td class="date column-date">
495
-					<abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified
495
+					<abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
496 496
 				</td>
497 497
 				<td class="ssid column-ssid">
498 498
 					'.$row['identifier'].'
@@ -508,31 +508,31 @@  discard block
 block discarded – undo
508 508
 	public function process_ajax_import($force = false) {
509 509
 		$return = false;
510 510
 
511
-		if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])){
511
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) {
512 512
 			
513 513
 			$wetu_id = $_POST['wetu_id'];
514
-			if(isset($_POST['post_id'])){
514
+			if (isset($_POST['post_id'])) {
515 515
 				$post_id = $_POST['post_id'];	
516
-			}else{
516
+			}else {
517 517
 				$post_id = 0;
518 518
 			}
519 519
 
520 520
 			delete_option('wetu_importer_tour_settings');
521
-			if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){
521
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
522 522
 				$content = $_POST['content'];
523
-				add_option('wetu_importer_tour_settings',$content);
524
-			}else{
523
+				add_option('wetu_importer_tour_settings', $content);
524
+			}else {
525 525
 				$content = false;
526 526
 			}
527 527
 
528
-            $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
528
+            $jdata = file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id);
529 529
 
530
-            if($jdata)
530
+            if ($jdata)
531 531
             {
532
-				$jdata=json_decode($jdata,true);
533
-                if(!empty($jdata))
532
+				$jdata = json_decode($jdata, true);
533
+                if (!empty($jdata))
534 534
                 {
535
-                	$return = $this->import_row($jdata,$wetu_id,$post_id,$content);
535
+                	$return = $this->import_row($jdata, $wetu_id, $post_id, $content);
536 536
                 	$this->format_completed_row($return);
537 537
                 	$this->cleanup_posts();
538 538
                 	$this->attach_destination_images($content);
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
      * @param $data array
548 548
      * @param $wetu_id string
549 549
 	 */
550
-	public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) {
550
+	public function import_row($data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false) {
551 551
         $post_name = $data_post_content = $data_post_excerpt = '';
552 552
         $post = array(
553 553
           'post_type'		=> 'tour',
@@ -555,29 +555,29 @@  discard block
 block discarded – undo
555 555
 
556 556
         //Set the post_content
557 557
 		$content_used_general_description = false;
558
-        if(false !== $importable_content && in_array('description',$importable_content)){
558
+        if (false !== $importable_content && in_array('description', $importable_content)) {
559 559
             $data_post_content = '';
560 560
 
561
-            if(isset($data['description'])){
561
+            if (isset($data['description'])) {
562 562
                 $data_post_content = $data['description'];
563
-            }elseif(isset($data['summary'])){
563
+            }elseif (isset($data['summary'])) {
564 564
                 $data_post_content = $data['summary'];
565 565
             }
566 566
             $post['post_content'] = $data_post_content;
567 567
         }
568 568
 
569 569
         //Create or update the post
570
-        if(false !== $id && '0' !== $id){
570
+        if (false !== $id && '0' !== $id) {
571 571
             $post['ID'] = $id;
572 572
 	        $post['post_status'] = 'publish';
573 573
             $id = wp_update_post($post);
574
-            $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true);
575
-            update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date);
576
-        }else{
574
+            $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
575
+            update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']), $prev_date);
576
+        }else {
577 577
 
578 578
             //Set the name
579
-            if(isset($data['name'])){
580
-                $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0);
579
+            if (isset($data['name'])) {
580
+                $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0);
581 581
             }
582 582
             $post['post_name'] = $post_name;
583 583
             $post['post_title'] = $data['name'];
@@ -585,29 +585,29 @@  discard block
 block discarded – undo
585 585
             $id = wp_insert_post($post);
586 586
 
587 587
             //Save the WETU ID and the Last date it was modified.
588
-            if(false !== $id){
589
-                add_post_meta($id,'lsx_wetu_id',$wetu_id);
590
-                add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']));
588
+            if (false !== $id) {
589
+                add_post_meta($id, 'lsx_wetu_id', $wetu_id);
590
+                add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']));
591 591
             }
592 592
         }
593 593
 
594 594
 
595 595
 		//Set the price
596
-		if(false !== $importable_content && in_array('price',$importable_content)){
597
-			$this->set_price($data,$id);
596
+		if (false !== $importable_content && in_array('price', $importable_content)) {
597
+			$this->set_price($data, $id);
598 598
 		}
599 599
 
600 600
 		//Set the Duration
601
-		if(false !== $importable_content && in_array('duration',$importable_content)){
602
-			$this->set_duration($data,$id);
601
+		if (false !== $importable_content && in_array('duration', $importable_content)) {
602
+			$this->set_duration($data, $id);
603 603
 		}
604 604
 
605
-        if(false !== $importable_content && in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){
606
-            $this->process_itineraries($data,$id,$importable_content);
605
+        if (false !== $importable_content && in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) {
606
+            $this->process_itineraries($data, $id, $importable_content);
607 607
         }
608 608
 
609
-		if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){
610
-			$this->set_map_data($data,$id);
609
+		if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) {
610
+			$this->set_map_data($data, $id);
611 611
 		}
612 612
 
613 613
         return $id;
@@ -616,151 +616,151 @@  discard block
 block discarded – undo
616 616
 	/**
617 617
 	 * A loop which runs through each leg on the tour.
618 618
 	 */
619
-	public function process_itineraries($data,$id,$importable_content) {
619
+	public function process_itineraries($data, $id, $importable_content) {
620 620
 		$day_counter = 1;
621 621
 		$leg_counter = 0;
622 622
 
623
-		delete_post_meta($id,'itinerary');
623
+		delete_post_meta($id, 'itinerary');
624 624
 
625
-		if(false !== $importable_content && in_array('accommodation',$importable_content)){
626
-			delete_post_meta($id,'accommodation_to_tour');
625
+		if (false !== $importable_content && in_array('accommodation', $importable_content)) {
626
+			delete_post_meta($id, 'accommodation_to_tour');
627 627
 		}
628
-		if(false !== $importable_content && in_array('destination',$importable_content)){
629
-			delete_post_meta($id,'destination_to_tour');
630
-			delete_post_meta($id,'departs_from');
631
-			delete_post_meta($id,'ends_in');
628
+		if (false !== $importable_content && in_array('destination', $importable_content)) {
629
+			delete_post_meta($id, 'destination_to_tour');
630
+			delete_post_meta($id, 'departs_from');
631
+			delete_post_meta($id, 'ends_in');
632 632
 		}
633 633
 
634 634
 		$departs_from = false;
635 635
 		$ends_in = false;
636 636
 
637
-		foreach($data['legs'] as $leg){
637
+		foreach ($data['legs'] as $leg) {
638 638
 
639
-			if(isset($leg['days']) && !empty($leg['days'])){
639
+			if (isset($leg['days']) && !empty($leg['days'])) {
640 640
 
641 641
 				//Itinerary Accommodation
642 642
 				$current_accommodation = false;
643
-				if(false !== $importable_content && in_array('accommodation',$importable_content)){
644
-					$current_accommodation = $this->set_accommodation($leg,$id);
643
+				if (false !== $importable_content && in_array('accommodation', $importable_content)) {
644
+					$current_accommodation = $this->set_accommodation($leg, $id);
645 645
 				}
646 646
 
647 647
 				//Itinerary Destination
648 648
 				$current_destination = false;
649
-				if(false !== $importable_content && in_array('destination',$importable_content)){
650
-					$current_destination = $this->set_destination($leg,$id,$leg_counter);
649
+				if (false !== $importable_content && in_array('destination', $importable_content)) {
650
+					$current_destination = $this->set_destination($leg, $id, $leg_counter);
651 651
 				}
652 652
 
653 653
 				//If the Nights are the same mount of days in the array,  then it isnt "By Destination"
654
-				if($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']){
654
+				if ($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']) {
655 655
 
656
-					foreach($leg['days'] as $day){
656
+					foreach ($leg['days'] as $day) {
657 657
 
658 658
 						$current_day = array();
659 659
 
660
-						$current_day['title'] =  esc_attr('Day ','wetu-importer').$day_counter;
660
+						$current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter;
661 661
 
662 662
 						//print_r('<pre>');print_r($day['notes']);print_r('</pre>');
663 663
 
664 664
 						//Description
665
-						if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){
665
+						if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) {
666 666
 							$current_day['description'] = $day['notes'];
667
-						}else{
667
+						}else {
668 668
 							$current_day['description'] = '';
669 669
 						}
670 670
 
671 671
 						//Itinerary Gallery
672
-						if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){
672
+						if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) {
673 673
 							$current_day['featured_image'] = '';
674
-						}else{
674
+						}else {
675 675
 							$current_day['featured_image'] = '';
676 676
 						}
677 677
 
678 678
 						//Accommodation
679
-						if(false !== $current_accommodation){
679
+						if (false !== $current_accommodation) {
680 680
 							$current_day['accommodation_to_tour'] = array($current_accommodation);
681
-						}else{
681
+						}else {
682 682
 							$current_day['accommodation_to_tour'] = array();
683 683
 						}
684 684
 
685 685
 						//Destination
686
-						if(false !== $current_destination){
686
+						if (false !== $current_destination) {
687 687
 							$current_day['destination_to_tour'] = array($current_destination);
688
-						}else{
688
+						}else {
689 689
 							$current_day['destination_to_tour'] = array();
690 690
 						}
691 691
 
692 692
 						//Included
693
-						if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){
693
+						if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) {
694 694
 							$current_day['included'] = $day['included'];
695
-						}else{
695
+						}else {
696 696
 							$current_day['included'] = '';
697 697
 						}
698 698
 
699 699
 						//Excluded
700
-						if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){
700
+						if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) {
701 701
 							$current_day['excluded'] = $day['excluded'];
702
-						}else{
702
+						}else {
703 703
 							$current_day['excluded'] = '';
704 704
 						}
705 705
 
706
-						$this->set_itinerary_day($current_day,$id);
706
+						$this->set_itinerary_day($current_day, $id);
707 707
 						$day_counter++;
708 708
 					}
709 709
 
710
-				}else{
711
-					$day_counter = $day_counter + (int)$leg['nights'];
710
+				}else {
711
+					$day_counter = $day_counter + (int) $leg['nights'];
712 712
 				}
713 713
 
714 714
 			}
715 715
 
716 716
 			//If we are in the first leg,  and the destination was attached then save it as the departure field.
717
-			if( 0 === $leg_counter && false !== $current_destination){
717
+			if (0 === $leg_counter && false !== $current_destination) {
718 718
 				$departs_from = $current_destination;
719 719
 			}
720 720
 
721 721
 			//If its the last leg then save it as the ends in.
722
-			if( $leg_counter === (count($data['legs'])-2) && false !== $current_destination){
722
+			if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) {
723 723
 				$ends_in = $current_destination;
724 724
 			}
725 725
 			$leg_counter++;
726 726
 		}
727 727
 
728
-		if(false !== $departs_from){
729
-			add_post_meta($id,'departs_from',$departs_from,true);
728
+		if (false !== $departs_from) {
729
+			add_post_meta($id, 'departs_from', $departs_from, true);
730 730
 		}
731
-		if(false !== $ends_in){
732
-			add_post_meta($id,'ends_in',$ends_in,true);
731
+		if (false !== $ends_in) {
732
+			add_post_meta($id, 'ends_in', $ends_in, true);
733 733
 		}
734 734
 	}
735 735
 
736 736
 	/**
737 737
 	 * Run through your routes and save the points as a KML file.
738 738
 	 */
739
-	public function set_map_data($data,$id,$zoom=9) {
739
+	public function set_map_data($data, $id, $zoom = 9) {
740 740
 
741
-		if(!empty($data['routes'])){
741
+		if (!empty($data['routes'])) {
742 742
 
743
-			delete_post_meta($id,'wetu_map_points');
743
+			delete_post_meta($id, 'wetu_map_points');
744 744
 
745 745
 			$points = array();
746 746
 
747
-			foreach($data['routes'] as $route){
747
+			foreach ($data['routes'] as $route) {
748 748
 
749 749
 
750
-				if(isset($route['points']) && '' !== $route['points']){
750
+				if (isset($route['points']) && '' !== $route['points']) {
751 751
 
752
-					$temp_points = explode(';',$route['points']);
752
+					$temp_points = explode(';', $route['points']);
753 753
 					$point_counter = count($temp_points);
754 754
 
755 755
 					for ($x = 0; $x <= $point_counter; $x++) {
756
-						$y = $x+1;
756
+						$y = $x + 1;
757 757
 						$points[] = $temp_points[$x].','.$temp_points[$y];
758 758
 						$x++;
759 759
 					}
760 760
 				}
761 761
 			}
762
-			if(!empty($points)){
763
-				$this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true);
762
+			if (!empty($points)) {
763
+				$this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true);
764 764
 			}
765 765
 		}
766 766
 
@@ -771,28 +771,28 @@  discard block
 block discarded – undo
771 771
 	/**
772 772
 	 * Set the Itinerary Day
773 773
 	 */
774
-	public function set_itinerary_day($day,$id) {
775
-        $this->save_custom_field($day,'itinerary',$id,false,false);
774
+	public function set_itinerary_day($day, $id) {
775
+        $this->save_custom_field($day, 'itinerary', $id, false, false);
776 776
 	}
777 777
 
778 778
 	/**
779 779
 	 * Set the price
780 780
 	 */
781
-	public function set_price($data,$id) {
781
+	public function set_price($data, $id) {
782 782
 	    //Price
783
-		if(isset($data['price']) && ''!== $data['price']){
783
+		if (isset($data['price']) && '' !== $data['price']) {
784 784
             $price = preg_replace("/[^0-9,.]/", "", $data['price']);
785
-            $this->save_custom_field($price,'price',$id);
785
+            $this->save_custom_field($price, 'price', $id);
786 786
 		}
787 787
 
788 788
 		//Price includes
789
-		if(isset($data['price_includes']) && ''!== $data['price_includes']){
790
-			$this->save_custom_field($data['price_includes'],'included',$id);
789
+		if (isset($data['price_includes']) && '' !== $data['price_includes']) {
790
+			$this->save_custom_field($data['price_includes'], 'included', $id);
791 791
 		}
792 792
 
793 793
         //Price Excludes
794
-		if(isset($data['price_excludes']) && ''!== $data['price_excludes']){
795
-			$this->save_custom_field($data['price_excludes'],'not_included',$id);
794
+		if (isset($data['price_excludes']) && '' !== $data['price_excludes']) {
795
+			$this->save_custom_field($data['price_excludes'], 'not_included', $id);
796 796
 		}
797 797
 
798 798
 	}
@@ -800,38 +800,38 @@  discard block
 block discarded – undo
800 800
 	/**
801 801
 	 * Set the duration
802 802
 	 */
803
-	public function set_duration($data,$id) {
804
-		if(isset($data['days']) && !empty($data['days'])){
803
+	public function set_duration($data, $id) {
804
+		if (isset($data['days']) && !empty($data['days'])) {
805 805
 			$price = $data['days'];
806 806
 			$price = preg_replace("/[^0-9,.]/", "", $price);
807
-			$this->save_custom_field($price,'duration',$id);
807
+			$this->save_custom_field($price, 'duration', $id);
808 808
 		}
809 809
 	}
810 810
 
811 811
 	/**
812 812
 	 * Connects the Accommodation if its available
813 813
 	 */
814
-	public function set_accommodation($day,$id) {
814
+	public function set_accommodation($day, $id) {
815 815
 
816 816
 	    $ac_id = false;
817 817
 		$this->current_accommodation = $this->find_current_accommodation();
818 818
 		
819
-		if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){
819
+		if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) {
820 820
 
821
-			if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){
821
+			if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) {
822 822
                 $ac_id = $this->current_accommodation[$day['content_entity_id']];
823
-			}else{
823
+			}else {
824 824
 				$ac_id = wp_insert_post(array(
825 825
                     'post_type' => 'accommodation',
826 826
                     'post_status' => 'draft',
827 827
                     'post_title' => $day['content_entity_id']
828 828
                 ));
829
-				$this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id);
829
+				$this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id);
830 830
 			}
831 831
 
832
-			if('' !== $ac_id && false !== $ac_id){
833
-			    $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false);
834
-				$this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false);
832
+			if ('' !== $ac_id && false !== $ac_id) {
833
+			    $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false);
834
+				$this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false);
835 835
             }
836 836
 		}
837 837
 		return $ac_id;
@@ -843,13 +843,13 @@  discard block
 block discarded – undo
843 843
      * @param $post_type string
844 844
      * @return boolean / array
845 845
 	 */
846
-	public function find_current_accommodation($post_type='accommodation') {
846
+	public function find_current_accommodation($post_type = 'accommodation') {
847 847
 		global $wpdb;
848 848
 		$accommodation = parent::find_current_accommodation($post_type);
849 849
 
850 850
 		$return = false;
851
-		if(!empty($accommodation)){
852
-		    foreach($accommodation as $key => $acc){
851
+		if (!empty($accommodation)) {
852
+		    foreach ($accommodation as $key => $acc) {
853 853
 				$return[$acc->meta_value] = $acc->post_id;
854 854
             }
855 855
         }
@@ -871,26 +871,26 @@  discard block
 block discarded – undo
871 871
 	 * @param $id string
872 872
 	 * @return boolean / string
873 873
 	 */
874
-	public function set_destination($day,$id,$leg_counter) {
874
+	public function set_destination($day, $id, $leg_counter) {
875 875
 		$dest_id = false;
876 876
 		$country_id = false;
877 877
 		$this->current_destinations = $this->find_current_destinations();
878 878
 
879
-		if(isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])){
879
+		if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) {
880 880
 
881
-			if(false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'],$this->current_destinations)){
881
+			if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) {
882 882
 				$dest_id = $this->current_destinations[$day['destination_content_entity_id']];
883 883
 
884 884
 				//Check if there is a country asigned.
885 885
 				$potential_id = wp_get_post_parent_id($dest_id);
886
-				$country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true);
887
-				if(false !== $country_wetu_id){
886
+				$country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true);
887
+				if (false !== $country_wetu_id) {
888 888
 					$country_id = $this->set_country($country_wetu_id, $id);
889 889
                 }
890 890
 
891 891
 			}else {
892 892
 
893
-				$destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']);
893
+				$destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$day['destination_content_entity_id']);
894 894
 
895 895
 				if ($destination_json) {
896 896
 					$destination_data = json_decode($destination_json, true);
@@ -899,12 +899,12 @@  discard block
 block discarded – undo
899 899
 
900 900
 					    $destination_title = $day['destination_content_entity_id'];
901 901
 
902
-					    if(isset($destination_data[0]['name'])){
902
+					    if (isset($destination_data[0]['name'])) {
903 903
 							$destination_title = $destination_data[0]['name'];
904 904
                         }
905 905
 
906
-					    if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
907
-                            && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){
906
+					    if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
907
+                            && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) {
908 908
 
909 909
 							$country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id);
910 910
                         }
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 							'post_title' => $destination_title
916 916
 						);
917 917
 
918
-					    if(false !== $country_id){
918
+					    if (false !== $country_id) {
919 919
 							$dest_post['post_parent'] = $country_id;
920 920
                         }
921 921
 						$dest_id = wp_insert_post($dest_post);
@@ -934,15 +934,15 @@  discard block
 block discarded – undo
934 934
 				$this->cleanup_posts[$dest_id] = 'tour_to_destination';
935 935
 
936 936
 				// Save the first destination so we can grab the tour featured image and banner
937
-				if(0 === $leg_counter){
938
-				    $this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']);
937
+				if (0 === $leg_counter) {
938
+				    $this->destination_images[$id] = array($dest_id, $day['destination_content_entity_id']);
939 939
                 }
940 940
 
941 941
 				//Add this relation info so we can make sure certain items are set as countries.
942
-				if(0 !== $country_id && false !== $country_id){
942
+				if (0 !== $country_id && false !== $country_id) {
943 943
                     $this->relation_meta[$dest_id] = $country_id;
944 944
 					$this->relation_meta[$country_id] = 0;
945
-                }else{
945
+                }else {
946 946
 					$this->relation_meta[$dest_id] = 0;
947 947
                 }
948 948
 			}
@@ -965,9 +965,9 @@  discard block
 block discarded – undo
965 965
 
966 966
         if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
967 967
             $country_id = $this->current_destinations[$country_wetu_id];
968
-        } else {
968
+        }else {
969 969
 
970
-            $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id);
970
+            $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$country_wetu_id);
971 971
 
972 972
             if ($country_json) {
973 973
                 $country_data = json_decode($country_json, true);
@@ -1012,15 +1012,15 @@  discard block
 block discarded – undo
1012 1012
 	 *
1013 1013
 	 * @return string
1014 1014
 	 */
1015
-	public function attach_destination_images($importable_content=array()) {
1016
-	    if(false !== $this->destination_images){
1015
+	public function attach_destination_images($importable_content = array()) {
1016
+	    if (false !== $this->destination_images) {
1017 1017
 
1018
-	        foreach($this->destination_images as $tour => $destination){
1018
+	        foreach ($this->destination_images as $tour => $destination) {
1019 1019
 
1020
-				$url = 'https://wetu.com/API/Pins/' . $this->api_key;
1020
+				$url = 'https://wetu.com/API/Pins/'.$this->api_key;
1021 1021
 				$url_qs = '';
1022 1022
 
1023
-				$jdata = file_get_contents($url . '/Get?' . $url_qs . '&ids=' . $destination[1]);
1023
+				$jdata = file_get_contents($url.'/Get?'.$url_qs.'&ids='.$destination[1]);
1024 1024
 				if ($jdata) {
1025 1025
 					$adata = json_decode($jdata, true);
1026 1026
 
Please login to merge, or discard this patch.
wetu-importer.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@
 block discarded – undo
11 11
  * Domain Path: /languages/
12 12
  */
13 13
 
14
-define('WETU_IMPORTER_PATH',  plugin_dir_path( __FILE__ ) );
15
-define('WETU_IMPORTER_CORE',  __FILE__ );
16
-define('WETU_IMPORTER_URL',  plugin_dir_url( __FILE__ ) );
17
-define('WETU_IMPORTER_VER',  '1.0.0' );
14
+define('WETU_IMPORTER_PATH', plugin_dir_path(__FILE__));
15
+define('WETU_IMPORTER_CORE', __FILE__);
16
+define('WETU_IMPORTER_URL', plugin_dir_url(__FILE__));
17
+define('WETU_IMPORTER_VER', '1.0.0');
18 18
 
19
-register_activation_hook( WETU_IMPORTER_CORE, array( 'WETU_Importer', 'register_activation_hook' ) );
19
+register_activation_hook(WETU_IMPORTER_CORE, array('WETU_Importer', 'register_activation_hook'));
20 20
 
21 21
 require_once(WETU_IMPORTER_PATH.'classes/class-importer.php');
22 22
 //require_once(WETU_IMPORTER_PATH.'classes/class-connect-accommodation.php');
Please login to merge, or discard this patch.