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