Passed
Push — master ( dc4fe7...6bd0e7 )
by Warwick
02:35 queued 13s
created
classes/class-lsx-wetu-importer-accommodation.php 1 patch
Spacing   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -76,19 +76,19 @@  discard block
 block discarded – undo
76 76
 		//	$this->url    = 'https://wetu.com/API/Pins/';
77 77
 		//	$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
78 78
 		//} elseif ( false !== $this->api_key ) {
79
-			$this->url    = 'https://wetu.com/API/Pins/' . $this->api_key;
79
+			$this->url    = 'https://wetu.com/API/Pins/'.$this->api_key;
80 80
 			$this->url_qs = 'all=include';
81 81
 		//}
82 82
 
83
-		$temp_options = get_option( '_lsx-to_settings', false );
83
+		$temp_options = get_option('_lsx-to_settings', false);
84 84
 
85
-		if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) {
86
-			$this->options = $temp_options[ $this->plugin_slug ];
85
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
86
+			$this->options = $temp_options[$this->plugin_slug];
87 87
 		}
88 88
 
89
-		$accommodation_options = get_option( 'lsx_wetu_importer_accommodation_settings',false );
89
+		$accommodation_options = get_option('lsx_wetu_importer_accommodation_settings', false);
90 90
 
91
-		if ( false !== $accommodation_options ) {
91
+		if (false !== $accommodation_options) {
92 92
 			$this->accommodation_options = $accommodation_options;
93 93
 		}
94 94
 	}
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 			</div>
108 108
 
109 109
 			<form method="get" action="" id="posts-filter">
110
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
110
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" />
111 111
 
112 112
 				<table class="wp-list-table widefat fixed posts">
113 113
 					<?php $this->table_header(); ?>
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
 					<tbody id="the-list">
116 116
 						<tr class="post-0 type-tour status-none" id="post-0">
117 117
 							<th class="check-column" scope="row">
118
-								<label for="cb-select-0" class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter', 'lsx-wetu-importer' ); ?></label>
118
+								<label for="cb-select-0" class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'lsx-wetu-importer'); ?></label>
119 119
 							</th>
120 120
 							<td class="post-title page-title column-title">
121 121
 								<strong>
122
-									<?php esc_html_e( 'Enter a title to search for', 'lsx-wetu-importer' ); ?>
122
+									<?php esc_html_e('Enter a title to search for', 'lsx-wetu-importer'); ?>
123 123
 								</strong>
124 124
 							</td>
125 125
 							<td class="date column-date">
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 
134 134
 				</table>
135 135
 
136
-				<p><input class="button button-primary add" type="button" value="<?php esc_attr_e( 'Add to List', 'lsx-wetu-importer' ); ?>" />
137
-					<input class="button button-primary clear" type="button" value="<?php esc_attr_e( 'Clear', 'lsx-wetu-importer' ); ?>" />
136
+				<p><input class="button button-primary add" type="button" value="<?php esc_attr_e('Add to List', 'lsx-wetu-importer'); ?>" />
137
+					<input class="button button-primary clear" type="button" value="<?php esc_attr_e('Clear', 'lsx-wetu-importer'); ?>" />
138 138
 				</p>
139 139
 			</form>
140 140
 
@@ -144,60 +144,60 @@  discard block
 block discarded – undo
144 144
 
145 145
 					<div class="row">
146 146
 						<div class="settings-all" style="width:30%;display:block;float:left;">
147
-							<h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3>
147
+							<h3><?php esc_html_e('What content to Sync from WETU'); ?></h3>
148 148
 							<ul>
149
-								<?php if ( isset( $this->options['disable_accommodation_descriptions'] ) && 'on' !== $this->options['disable_accommodation_descriptions'] ) { ?>
150
-									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="description" /> <?php esc_html_e( 'Description', 'lsx-wetu-importer' ); ?></li>
149
+								<?php if (isset($this->options['disable_accommodation_descriptions']) && 'on' !== $this->options['disable_accommodation_descriptions']) { ?>
150
+									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="description" /> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li>
151 151
 								<?php } ?>
152
-								<?php if ( isset( $this->options['disable_accommodation_excerpts'] ) && 'on' !== $this->options['disable_accommodation_excerpts'] ) { ?>
153
-									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="excerpt" /> <?php esc_html_e( 'Excerpt', 'lsx-wetu-importer' ); ?></li>
152
+								<?php if (isset($this->options['disable_accommodation_excerpts']) && 'on' !== $this->options['disable_accommodation_excerpts']) { ?>
153
+									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="excerpt" /> <?php esc_html_e('Excerpt', 'lsx-wetu-importer'); ?></li>
154 154
 								<?php } ?>
155 155
 
156
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="gallery" /> <?php esc_html_e( 'Main Gallery', 'lsx-wetu-importer' ); ?></li>
157
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="category" /> <?php esc_html_e( 'Category', 'lsx-wetu-importer' ); ?></li>
158
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="location" /> <?php esc_html_e( 'Location', 'lsx-wetu-importer' ); ?></li>
156
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="gallery" /> <?php esc_html_e('Main Gallery', 'lsx-wetu-importer'); ?></li>
157
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="category" /> <?php esc_html_e('Category', 'lsx-wetu-importer'); ?></li>
158
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="location" /> <?php esc_html_e('Location', 'lsx-wetu-importer'); ?></li>
159 159
 
160
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e( 'Connect Destinations', 'lsx-wetu-importer' ); ?></li>
161
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="rating" /> <?php esc_html_e( 'Rating', 'lsx-wetu-importer' ); ?></li>
162
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="rooms" /> <?php esc_html_e( 'Rooms', 'lsx-wetu-importer' ); ?></li>
160
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e('Connect Destinations', 'lsx-wetu-importer'); ?></li>
161
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="rating" /> <?php esc_html_e('Rating', 'lsx-wetu-importer'); ?></li>
162
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="rooms" /> <?php esc_html_e('Rooms', 'lsx-wetu-importer'); ?></li>
163 163
 
164
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="checkin" /> <?php esc_html_e( 'Check In / Check Out', 'lsx-wetu-importer' ); ?></li>
165
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="facilities" /> <?php esc_html_e( 'Facilities', 'lsx-wetu-importer' ); ?></li>
166
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="friendly" /> <?php esc_html_e( 'Friendly', 'lsx-wetu-importer' ); ?></li>
164
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="checkin" /> <?php esc_html_e('Check In / Check Out', 'lsx-wetu-importer'); ?></li>
165
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="facilities" /> <?php esc_html_e('Facilities', 'lsx-wetu-importer'); ?></li>
166
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="friendly" /> <?php esc_html_e('Friendly', 'lsx-wetu-importer'); ?></li>
167 167
 
168 168
 
169
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="special_interests" /> <?php esc_html_e( 'Special Interests', 'lsx-wetu-importer' ); ?></li>
170
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="spoken_languages" /> <?php esc_html_e( 'Spoken Languages', 'lsx-wetu-importer' ); ?></li>
169
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="special_interests" /> <?php esc_html_e('Special Interests', 'lsx-wetu-importer'); ?></li>
170
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="spoken_languages" /> <?php esc_html_e('Spoken Languages', 'lsx-wetu-importer'); ?></li>
171 171
 
172
-								<?php if ( class_exists( 'LSX_TO_Videos' ) ) { ?>
173
-									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="videos" /> <?php esc_html_e( 'Videos', 'lsx-wetu-importer' ); ?></li>
172
+								<?php if (class_exists('LSX_TO_Videos')) { ?>
173
+									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="videos" /> <?php esc_html_e('Videos', 'lsx-wetu-importer'); ?></li>
174 174
 								<?php } ?>
175 175
 							</ul>
176
-							<h4><?php esc_html_e( 'Additional Content' ); ?></h4>
176
+							<h4><?php esc_html_e('Additional Content'); ?></h4>
177 177
 							<ul>
178
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e( 'Set Featured Image', 'lsx-wetu-importer' ); ?></li>
179
-								<?php if ( class_exists( 'LSX_Banners' ) && ! isset( $this->accommodation_settings['disable_single'] ) ) { ?>
180
-									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e( 'Set Banner Image', 'lsx-wetu-importer' ); ?></li>
178
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e('Set Featured Image', 'lsx-wetu-importer'); ?></li>
179
+								<?php if (class_exists('LSX_Banners') && !isset($this->accommodation_settings['disable_single'])) { ?>
180
+									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e('Set Banner Image', 'lsx-wetu-importer'); ?></li>
181 181
 								<?php } ?>
182 182
 							</ul>
183 183
 						</div>
184 184
 						<div style="width:30%;display:block;float:left;">
185
-							<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3>
186
-							<?php $this->team_member_checkboxes( $this->accommodation_options ); ?>
185
+							<h3><?php esc_html_e('Assign a Team Member'); ?></h3>
186
+							<?php $this->team_member_checkboxes($this->accommodation_options); ?>
187 187
 						</div>
188 188
 
189 189
 						<div style="width:30%;display:block;float:left;">
190
-							<h3><?php esc_html_e( 'Assign a Safari Brand' ); ?></h3>
190
+							<h3><?php esc_html_e('Assign a Safari Brand'); ?></h3>
191 191
 							<?php
192
-								echo wp_kses_post( $this->taxonomy_checkboxes( 'accommodation-brand', $this->accommodation_options ) );
192
+								echo wp_kses_post($this->taxonomy_checkboxes('accommodation-brand', $this->accommodation_options));
193 193
 							?>
194 194
 						</div>
195 195
 
196 196
 						<br clear="both" />
197 197
 					</div>
198 198
 
199
-					<h3><?php esc_html_e( 'Your List' ); ?></h3>
200
-					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'lsx-wetu-importer' ); ?>" /></p>
199
+					<h3><?php esc_html_e('Your List'); ?></h3>
200
+					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e('Sync', 'lsx-wetu-importer'); ?>" /></p>
201 201
 					<table class="wp-list-table widefat fixed posts">
202 202
 						<?php $this->table_header(); ?>
203 203
 
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
 
210 210
 					</table>
211 211
 
212
-					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'lsx-wetu-importer' ); ?>" /></p>
212
+					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e('Sync', 'lsx-wetu-importer'); ?>" /></p>
213 213
 				</form>
214 214
 			</div>
215 215
 
216 216
 			<div style="display:none;" class="completed-list-wrapper">
217
-				<h3><?php esc_html_e( 'Completed' ); ?> - <small><?php esc_html_e( 'Import your', 'lsx-wetu-importer' ); ?> <a href="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->plugin_slug ); ?>&tab=destination"><?php esc_html_e( 'destinations' ); ?></a> <?php esc_html_e( 'next', 'lsx-wetu-importer' ); ?></small></h3>
217
+				<h3><?php esc_html_e('Completed'); ?> - <small><?php esc_html_e('Import your', 'lsx-wetu-importer'); ?> <a href="<?php echo esc_url(admin_url('admin.php')); ?>?page=<?php echo esc_attr($this->plugin_slug); ?>&tab=destination"><?php esc_html_e('destinations'); ?></a> <?php esc_html_e('next', 'lsx-wetu-importer'); ?></small></h3>
218 218
 				<ul>
219 219
 				</ul>
220 220
 			</div>
@@ -227,115 +227,115 @@  discard block
 block discarded – undo
227 227
 	 */
228 228
 	public function process_ajax_search() {
229 229
 		$return = false;
230
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
231
-		if ( isset( $_POST['action'] ) && 'lsx_tour_importer' === $_POST['action'] && isset( $_POST['type'] ) && 'accommodation' === $_POST['type'] ) {
230
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
231
+		if (isset($_POST['action']) && 'lsx_tour_importer' === $_POST['action'] && isset($_POST['type']) && 'accommodation' === $_POST['type']) {
232 232
 
233 233
 			$searched_items = false;
234
-			if ( isset( $_POST['keyword'] ) ) {
235
-				$keyphrases = array_map( 'sanitize_text_field', wp_unslash( $_POST['keyword'] ) );
236
-			} else {
237
-				$keyphrases = array( 0 );
234
+			if (isset($_POST['keyword'])) {
235
+				$keyphrases = array_map('sanitize_text_field', wp_unslash($_POST['keyword']));
236
+			}else {
237
+				$keyphrases = array(0);
238 238
 			}
239 239
 
240
-			if ( ! is_array( $keyphrases ) ) {
241
-				$keyphrases = array( $keyphrases );
240
+			if (!is_array($keyphrases)) {
241
+				$keyphrases = array($keyphrases);
242 242
 			}
243
-			foreach ( $keyphrases as &$keyword ) {
244
-				$keyword = ltrim( rtrim( $keyword ) );
243
+			foreach ($keyphrases as &$keyword) {
244
+				$keyword = ltrim(rtrim($keyword));
245 245
 			}
246 246
 
247 247
 			$post_status = false;
248 248
 
249
-			if ( in_array( 'publish', $keyphrases ) ) {
249
+			if (in_array('publish', $keyphrases)) {
250 250
 				$post_status = 'publish';
251 251
 			}
252
-			if ( in_array( 'pending', $keyphrases ) ) {
252
+			if (in_array('pending', $keyphrases)) {
253 253
 				$post_status = 'pending';
254 254
 			}
255
-			if ( in_array( 'draft', $keyphrases ) ) {
255
+			if (in_array('draft', $keyphrases)) {
256 256
 				$post_status = 'draft';
257 257
 			}
258
-			if ( in_array( 'import', $keyphrases ) ) {
258
+			if (in_array('import', $keyphrases)) {
259 259
 				$post_status = 'import';
260 260
 			}
261 261
 
262 262
 			// If there is a post status use it.
263
-			if ( false !== $post_status ) {
263
+			if (false !== $post_status) {
264 264
 
265 265
 				$accommodation = array();
266 266
 				$current_accommodation = $this->find_current_accommodation();
267
-				if ( ! empty( $current_accommodation ) ) {
268
-					foreach ( $current_accommodation as $cs_key => $ccs_id ) {
269
-						$accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id );
267
+				if (!empty($current_accommodation)) {
268
+					foreach ($current_accommodation as $cs_key => $ccs_id) {
269
+						$accommodation[] = $this->prepare_row_attributes($cs_key, $ccs_id->post_id);
270 270
 					}
271 271
 				}
272 272
 
273 273
 				// Run through each accommodation and use it.
274
-				if ( ! empty( $accommodation ) ) {
275
-					foreach ( $accommodation as $row_key => $row ) {
274
+				if (!empty($accommodation)) {
275
+					foreach ($accommodation as $row_key => $row) {
276 276
 						$row['post_title'] = $row['name'];
277
-						if ( 'import' === $post_status ) {
278
-							if ( is_array( $this->queued_imports ) && in_array( $row['post_id'], $this->queued_imports ) ) {
279
-								$current_status = get_post_status( $row['post_id'] );
280
-								if ( 'draft' === $current_status ) {
281
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
277
+						if ('import' === $post_status) {
278
+							if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) {
279
+								$current_status = get_post_status($row['post_id']);
280
+								if ('draft' === $current_status) {
281
+									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
282 282
 								}
283
-							} else {
283
+							}else {
284 284
 								continue;
285 285
 							}
286
-						} else {
287
-							if ( 0 === $row['post_id'] ) {
286
+						}else {
287
+							if (0 === $row['post_id']) {
288 288
 								continue;
289
-							} else {
290
-								$current_status = get_post_status( $row['post_id'] );
291
-								if ( $current_status !== $post_status ) {
289
+							}else {
290
+								$current_status = get_post_status($row['post_id']);
291
+								if ($current_status !== $post_status) {
292 292
 									continue;
293 293
 								}
294 294
 							}
295
-							$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row, $row_key );
295
+							$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row, $row_key);
296 296
 						}
297 297
 					}
298 298
 				}
299
-			} else {
300
-				$key_string_search = implode( '+', $keyphrases );
301
-				$search_data       = wp_remote_get( $this->url . '/Search/' . $key_string_search );
302
-				if ( ! empty( $search_data ) && isset( $search_data['response'] ) && isset( $search_data['response']['code'] ) && 200 === $search_data['response']['code'] ) {
299
+			}else {
300
+				$key_string_search = implode('+', $keyphrases);
301
+				$search_data       = wp_remote_get($this->url.'/Search/'.$key_string_search);
302
+				if (!empty($search_data) && isset($search_data['response']) && isset($search_data['response']['code']) && 200 === $search_data['response']['code']) {
303 303
 
304
-					$search_data = json_decode( $search_data['body'], true );
305
-					foreach ( $search_data as $sdata_key => $sdata ) {
304
+					$search_data = json_decode($search_data['body'], true);
305
+					foreach ($search_data as $sdata_key => $sdata) {
306 306
 
307
-						if ( 'Destination' === trim( $sdata['type'] ) || 'Activity' === trim( $sdata['type'] ) || 'Restaurant' === trim( $sdata['type'] ) || 'None' === trim( $sdata['type'] ) || 'Site / Attraction' === trim( $sdata['type'] ) || '' === trim( $sdata['type'] ) ) {
307
+						if ('Destination' === trim($sdata['type']) || 'Activity' === trim($sdata['type']) || 'Restaurant' === trim($sdata['type']) || 'None' === trim($sdata['type']) || 'Site / Attraction' === trim($sdata['type']) || '' === trim($sdata['type'])) {
308 308
 							continue;
309 309
 						}
310 310
 
311
-						$temp_id = $this->get_post_id_by_key_value( $sdata['id'] );
312
-						if ( false === $temp_id ) {
311
+						$temp_id = $this->get_post_id_by_key_value($sdata['id']);
312
+						if (false === $temp_id) {
313 313
 							$sdata['post_id'] = 0;
314 314
 							$sdata['post_title'] = $sdata['name'];
315
-						} else {
315
+						}else {
316 316
 							$sdata['post_id'] = $temp_id;
317
-							$sdata['post_title'] = get_the_title( $temp_id );
317
+							$sdata['post_title'] = get_the_title($temp_id);
318 318
 						}
319
-						$searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata, $sdata_key );
319
+						$searched_items[sanitize_title($sdata['name']).'-'.$sdata['id']] = $this->format_row($sdata, $sdata_key);
320 320
 					}
321 321
 				}
322 322
 			}
323 323
 
324
-			if ( false !== $searched_items ) {
325
-				$return = implode( $searched_items );
324
+			if (false !== $searched_items) {
325
+				$return = implode($searched_items);
326 326
 			}
327
-			print_r( $return );
327
+			print_r($return);
328 328
 		}
329 329
 
330 330
 		die();
331 331
 	}
332 332
 
333
-	public function prepare_row_attributes( $cs_key, $ccs_id ) {
333
+	public function prepare_row_attributes($cs_key, $ccs_id) {
334 334
 		$row_item = array(
335 335
 			'id' => $cs_key,
336 336
 			'type' => 'Accommodation',
337
-			'name' => get_the_title( $ccs_id ),
338
-			'last_modified' => date( 'Y-m-d', strtotime( 'now' ) ),
337
+			'name' => get_the_title($ccs_id),
338
+			'last_modified' => date('Y-m-d', strtotime('now')),
339 339
 			'post_id' => $ccs_id,
340 340
 		);
341 341
 		return $row_item;
@@ -347,31 +347,31 @@  discard block
 block discarded – undo
347 347
 	 * @param boolean $row the current row to format.
348 348
 	 * @return void
349 349
 	 */
350
-	public function format_row( $row = false, $row_key = '' ) {
351
-		if ( false !== $row ) {
350
+	public function format_row($row = false, $row_key = '') {
351
+		if (false !== $row) {
352 352
 
353 353
 			$status = 'import';
354
-			if ( 0 !== $row['post_id'] ) {
355
-				$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>';
354
+			if (0 !== $row['post_id']) {
355
+				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
356 356
 			}
357 357
 
358 358
 			$row_html = '
359
-			<tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '">
359
+			<tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'">
360 360
 				<th class="check-column" scope="row">
361
-					<label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label>
362
-					<input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '">
361
+					<label for="cb-select-' . $row['id'].'" class="screen-reader-text">'.$row['name'].'</label>
362
+					<input type="checkbox" data-identifier="' . $row['id'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['id'].'">
363 363
 				</th>
364 364
 				<td class="column-order">
365
-					' . ( $row_key + 1 ) . '
365
+					' . ($row_key + 1).'
366 366
 				</td>
367 367
 				<td class="post-title page-title column-title">
368
-					<strong>' . $row['post_title'] . '</strong> - ' . $status . '
368
+					<strong>' . $row['post_title'].'</strong> - '.$status.'
369 369
 				</td>
370 370
 				<td class="date column-date">
371
-					<abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified
371
+					<abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
372 372
 				</td>
373 373
 				<td class="ssid column-ssid">
374
-					' . $row['id'] . '
374
+					' . $row['id'].'
375 375
 				</td>
376 376
 			</tr>';
377 377
 			return $row_html;
@@ -381,14 +381,14 @@  discard block
 block discarded – undo
381 381
 	/**
382 382
 	 * Saves the queue to the option.
383 383
 	 */
384
-	public function remove_from_queue( $id ) {
385
-		if ( ! empty( $this->queued_imports ) ) {
386
-			$key = array_search( $id, $this->queued_imports );
387
-			if ( false !== $key ) {
388
-				unset( $this->queued_imports[ $key ] );
384
+	public function remove_from_queue($id) {
385
+		if (!empty($this->queued_imports)) {
386
+			$key = array_search($id, $this->queued_imports);
387
+			if (false !== $key) {
388
+				unset($this->queued_imports[$key]);
389 389
 
390
-				delete_option( 'lsx_wetu_importer_que' );
391
-				update_option( 'lsx_wetu_importer_que', $this->queued_imports );
390
+				delete_option('lsx_wetu_importer_que');
391
+				update_option('lsx_wetu_importer_que', $this->queued_imports);
392 392
 			}
393 393
 		}
394 394
 	}
@@ -398,47 +398,47 @@  discard block
 block discarded – undo
398 398
 	 */
399 399
 	public function process_ajax_import() {
400 400
 		$return = false;
401
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
401
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
402 402
 
403
-		if ( isset( $_POST['action'] ) && 'lsx_import_items' === $_POST['action'] && isset( $_POST['type'] ) && 'accommodation' === $_POST['type'] && isset( $_POST['wetu_id'] ) ) {
403
+		if (isset($_POST['action']) && 'lsx_import_items' === $_POST['action'] && isset($_POST['type']) && 'accommodation' === $_POST['type'] && isset($_POST['wetu_id'])) {
404 404
 
405
-			$wetu_id = sanitize_text_field( $_POST['wetu_id'] );
406
-			if ( isset( $_POST['post_id'] ) ) {
407
-				$post_id = sanitize_text_field( $_POST['post_id'] );
408
-			} else {
405
+			$wetu_id = sanitize_text_field($_POST['wetu_id']);
406
+			if (isset($_POST['post_id'])) {
407
+				$post_id = sanitize_text_field($_POST['post_id']);
408
+			}else {
409 409
 				$post_id = 0;
410 410
 			}
411 411
 
412
-			if ( isset( $_POST['team_members'] ) ) {
413
-				$team_members = array_map( 'sanitize_text_field', wp_unslash( $_POST['team_members'] ) );
414
-			} else {
412
+			if (isset($_POST['team_members'])) {
413
+				$team_members = array_map('sanitize_text_field', wp_unslash($_POST['team_members']));
414
+			}else {
415 415
 				$team_members = false;
416 416
 			}
417 417
 
418
-			if ( isset( $_POST['safari_brands'] ) ) {
419
-				$safari_brands = array_map( 'sanitize_text_field', wp_unslash( $_POST['safari_brands'] ) );
420
-			} else {
418
+			if (isset($_POST['safari_brands'])) {
419
+				$safari_brands = array_map('sanitize_text_field', wp_unslash($_POST['safari_brands']));
420
+			}else {
421 421
 				$safari_brands = false;
422 422
 			}
423
-			delete_option( 'lsx_wetu_importer_accommodation_settings' );
423
+			delete_option('lsx_wetu_importer_accommodation_settings');
424 424
 
425
-			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
426
-				$content = array_map( 'sanitize_text_field', wp_unslash( $_POST['content'] ) );
427
-				add_option( 'lsx_wetu_importer_accommodation_settings',$content );
428
-			} else {
425
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
426
+				$content = array_map('sanitize_text_field', wp_unslash($_POST['content']));
427
+				add_option('lsx_wetu_importer_accommodation_settings', $content);
428
+			}else {
429 429
 				$content = false;
430 430
 			}
431 431
 
432
-			$jdata = wp_remote_get( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
432
+			$jdata = wp_remote_get($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
433 433
 
434
-			if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
435
-				$adata = json_decode( $jdata['body'], true );
436
-				$return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands );
437
-				$this->format_completed_row( $return );
438
-				$this->remove_from_queue( $return );
434
+			if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
435
+				$adata = json_decode($jdata['body'], true);
436
+				$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
437
+				$this->format_completed_row($return);
438
+				$this->remove_from_queue($return);
439 439
 				$this->cleanup_posts();
440
-			} else {
441
-				$this->format_error( esc_html__( 'There was a problem importing your accommodation, please try refreshing the page.', 'lsx-wetu-importer' ) );
440
+			}else {
441
+				$this->format_error(esc_html__('There was a problem importing your accommodation, please try refreshing the page.', 'lsx-wetu-importer'));
442 442
 			}
443 443
 		}
444 444
 	}
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 	/**
447 447
 	 * Connect to wetu
448 448
 	 */
449
-	public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false ) {
449
+	public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false) {
450 450
 		$post_name = '';
451 451
 		$data_post_content = '';
452 452
 		$data_post_excerpt = '';
@@ -457,142 +457,142 @@  discard block
 block discarded – undo
457 457
 		$content_used_general_description = false;
458 458
 
459 459
 		// Set the post_content.
460
-		if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) {
461
-			if ( isset( $data[0]['content']['extended_description'] ) ) {
460
+		if (!empty($importable_content) && in_array('description', $importable_content)) {
461
+			if (isset($data[0]['content']['extended_description'])) {
462 462
 				$data_post_content = $data[0]['content']['extended_description'];
463
-			} elseif ( isset( $data[0]['content']['general_description'] ) ) {
463
+			} elseif (isset($data[0]['content']['general_description'])) {
464 464
 				$data_post_content = $data[0]['content']['general_description'];
465 465
 				$content_used_general_description = true;
466
-			} elseif ( isset( $data[0]['content']['teaser_description'] ) ) {
466
+			} elseif (isset($data[0]['content']['teaser_description'])) {
467 467
 				$data_post_content = $data[0]['content']['teaser_description'];
468 468
 			}
469 469
 
470
-			if ( isset( $this->options['disable_accommodation_filtering'] ) && 'on' === $this->options['disable_accommodation_filtering'] ) {
470
+			if (isset($this->options['disable_accommodation_filtering']) && 'on' === $this->options['disable_accommodation_filtering']) {
471 471
 				$post['post_content'] = $data_post_content;
472
-			} else {
473
-				$post['post_content'] = wp_strip_all_tags( $data_post_content );
472
+			}else {
473
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
474 474
 			}
475 475
 		}
476 476
 
477 477
 		// set the post_excerpt.
478
-		if ( ! empty( $importable_content ) && in_array( 'excerpt', $importable_content ) ) {
479
-			if ( isset( $data[0]['content']['teaser_description'] ) ) {
478
+		if (!empty($importable_content) && in_array('excerpt', $importable_content)) {
479
+			if (isset($data[0]['content']['teaser_description'])) {
480 480
 				$data_post_excerpt = $data[0]['content']['teaser_description'];
481
-			} elseif ( isset( $data[0]['content']['general_description'] ) && false === $content_used_general_description ) {
481
+			} elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) {
482 482
 				$data_post_excerpt = $data[0]['content']['general_description'];
483 483
 			}
484 484
 
485 485
 			$post['post_excerpt'] = $data_post_excerpt;
486 486
 		}
487 487
 
488
-		if ( false !== $id && '0' !== $id ) {
488
+		if (false !== $id && '0' !== $id) {
489 489
 			$post['ID'] = $id;
490 490
 
491
-			if ( isset( $this->options ) && 'on' !== $this->options['disable_accommodation_title'] && isset( $data[0]['name'] ) ) {
491
+			if (isset($this->options) && 'on' !== $this->options['disable_accommodation_title'] && isset($data[0]['name'])) {
492 492
 				$post['post_title'] = $data[0]['name'];
493
-				$post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'accommodation', 0 );
493
+				$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0);
494 494
 			}
495 495
 
496 496
 			$post['post_status'] = 'publish';
497 497
 
498
-			$id = wp_update_post( $post );
499
-			$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
500
-			update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date );
501
-		} else {
498
+			$id = wp_update_post($post);
499
+			$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
500
+			update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
501
+		}else {
502 502
 			// Set the name.
503
-			if ( isset( $data[0]['name'] ) ) {
504
-				$post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'accommodation', 0 );
503
+			if (isset($data[0]['name'])) {
504
+				$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0);
505 505
 			}
506 506
 
507 507
 			$post['post_name']   = $post_name;
508 508
 			$post['post_title']  = $data[0]['name'];
509 509
 			$post['post_status'] = 'publish';
510
-			$id                  = wp_insert_post( $post );
510
+			$id                  = wp_insert_post($post);
511 511
 
512 512
 			// Save the WETU ID and the Last date it was modified.
513
-			if ( false !== $id ) {
514
-				add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
515
-				add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) );
513
+			if (false !== $id) {
514
+				add_post_meta($id, 'lsx_wetu_id', $wetu_id);
515
+				add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']));
516 516
 			}
517 517
 		}
518 518
 
519 519
 		// Setup some default for use in the import.
520
-		if ( false !== $importable_content && ( in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content ) ) ) {
521
-			$this->find_attachments( $id );
520
+		if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) {
521
+			$this->find_attachments($id);
522 522
 		}
523 523
 
524 524
 		// Set the team member if it is there.
525
-		if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) {
526
-			$this->set_team_member( $id, $team_members );
525
+		if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
526
+			$this->set_team_member($id, $team_members);
527 527
 		}
528 528
 
529 529
 		// Set the safari brand.
530
-		if ( false !== $safari_brands && '' !== $safari_brands ) {
531
-			$this->set_safari_brands( $id, $safari_brands );
530
+		if (false !== $safari_brands && '' !== $safari_brands) {
531
+			$this->set_safari_brands($id, $safari_brands);
532 532
 		}
533 533
 
534
-		$this->set_map_data( $data, $id, 9 );
534
+		$this->set_map_data($data, $id, 9);
535 535
 
536
-		if ( post_type_exists( 'destination' ) && false !== $importable_content && in_array( 'destination', $importable_content ) ) {
537
-			$this->connect_destinations( $data, $id );
536
+		if (post_type_exists('destination') && false !== $importable_content && in_array('destination', $importable_content)) {
537
+			$this->connect_destinations($data, $id);
538 538
 		}
539 539
 
540
-		if ( false !== $importable_content && in_array( 'category', $importable_content ) ) {
541
-			$this->set_taxonomy_style( $data, $id );
540
+		if (false !== $importable_content && in_array('category', $importable_content)) {
541
+			$this->set_taxonomy_style($data, $id);
542 542
 		}
543 543
 
544 544
 		// Set the Room Data.
545
-		if ( false !== $importable_content && in_array( 'rooms', $importable_content ) ) {
546
-			$this->set_room_data( $data, $id );
545
+		if (false !== $importable_content && in_array('rooms', $importable_content)) {
546
+			$this->set_room_data($data, $id);
547 547
 		}
548 548
 
549 549
 		// Set the rating.
550
-		if ( false !== $importable_content && in_array( 'rating', $importable_content ) ) {
551
-			$this->set_rating( $data, $id );
550
+		if (false !== $importable_content && in_array('rating', $importable_content)) {
551
+			$this->set_rating($data, $id);
552 552
 		}
553 553
 
554 554
 		// Set the checkin checkout data.
555
-		if ( false !== $importable_content && in_array( 'checkin', $importable_content ) ) {
556
-			$this->set_checkin_checkout( $data, $id );
555
+		if (false !== $importable_content && in_array('checkin', $importable_content)) {
556
+			$this->set_checkin_checkout($data, $id);
557 557
 		}
558 558
 
559 559
 		// Set the Spoken Languages.
560
-		if ( false !== $importable_content && in_array( 'spoken_languages', $importable_content ) ) {
561
-			$this->set_spoken_languages( $data, $id );
560
+		if (false !== $importable_content && in_array('spoken_languages', $importable_content)) {
561
+			$this->set_spoken_languages($data, $id);
562 562
 		}
563 563
 
564 564
 		// Set the friendly options.
565
-		if ( false !== $importable_content && in_array( 'friendly', $importable_content ) ) {
566
-			$this->set_friendly( $data, $id );
565
+		if (false !== $importable_content && in_array('friendly', $importable_content)) {
566
+			$this->set_friendly($data, $id);
567 567
 		}
568 568
 
569 569
 		// Set the special_interests.
570
-		if ( false !== $importable_content && in_array( 'special_interests', $importable_content ) ) {
571
-			$this->set_special_interests( $data, $id );
570
+		if (false !== $importable_content && in_array('special_interests', $importable_content)) {
571
+			$this->set_special_interests($data, $id);
572 572
 		}
573 573
 
574 574
 		// Import the videos.
575
-		if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) {
576
-			$this->set_video_data( $data, $id );
575
+		if (false !== $importable_content && in_array('videos', $importable_content)) {
576
+			$this->set_video_data($data, $id);
577 577
 		}
578 578
 
579 579
 		// Import the facilities.
580
-		if ( false !== $importable_content && in_array( 'facilities', $importable_content ) ) {
581
-			$this->set_facilities( $data, $id );
580
+		if (false !== $importable_content && in_array('facilities', $importable_content)) {
581
+			$this->set_facilities($data, $id);
582 582
 		}
583 583
 
584 584
 		// Set the featured image.
585
-		if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
586
-			$this->set_featured_image( $data, $id );
585
+		if (false !== $importable_content && in_array('featured_image', $importable_content)) {
586
+			$this->set_featured_image($data, $id);
587 587
 		}
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
 
593 593
 		// Import the main gallery.
594
-		if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) {
595
-			$this->create_main_gallery( $data, $id );
594
+		if (false !== $importable_content && in_array('gallery', $importable_content)) {
595
+			$this->create_main_gallery($data, $id);
596 596
 		}
597 597
 
598 598
 		return $id;
@@ -601,55 +601,55 @@  discard block
 block discarded – undo
601 601
 	/**
602 602
 	 * Set the team memberon each item.
603 603
 	 */
604
-	public function set_team_member( $id, $team_members ) {
605
-		delete_post_meta( $id, 'team_to_' . $this->tab_slug );
604
+	public function set_team_member($id, $team_members) {
605
+		delete_post_meta($id, 'team_to_'.$this->tab_slug);
606 606
 
607
-		foreach ( $team_members as $team ) {
608
-			add_post_meta( $id, 'team_to_' . $this->tab_slug, $team );
607
+		foreach ($team_members as $team) {
608
+			add_post_meta($id, 'team_to_'.$this->tab_slug, $team);
609 609
 		}
610 610
 	}
611 611
 
612 612
 	/**
613 613
 	 * Set the safari brand
614 614
 	 */
615
-	public function set_safari_brands( $id, $safari_brands ) {
616
-		foreach ( $safari_brands as $safari_brand ) {
617
-			wp_set_object_terms( $id, intval( $safari_brand ), 'accommodation-brand', true );
615
+	public function set_safari_brands($id, $safari_brands) {
616
+		foreach ($safari_brands as $safari_brand) {
617
+			wp_set_object_terms($id, intval($safari_brand), 'accommodation-brand', true);
618 618
 		}
619 619
 	}
620 620
 
621 621
 	/**
622 622
 	 * Connects the destinations post type
623 623
 	 */
624
-	public function connect_destinations( $data, $id ) {
625
-		if ( isset( $data[0]['position'] ) ) {
624
+	public function connect_destinations($data, $id) {
625
+		if (isset($data[0]['position'])) {
626 626
 			$destinations = false;
627 627
 
628
-			if ( isset( $data[0]['position']['country'] ) ) {
628
+			if (isset($data[0]['position']['country'])) {
629 629
 				$destinations['country'] = $data[0]['position']['country'];
630 630
 			}
631 631
 
632
-			if ( isset( $data[0]['position']['destination'] ) ) {
632
+			if (isset($data[0]['position']['destination'])) {
633 633
 				$destinations['destination'] = $data[0]['position']['destination'];
634 634
 			}
635 635
 
636
-			if ( false !== $destinations ) {
637
-				$prev_values = get_post_meta( $id, 'destination_to_accommodation', false );
636
+			if (false !== $destinations) {
637
+				$prev_values = get_post_meta($id, 'destination_to_accommodation', false);
638 638
 
639
-				if ( false === $prev_values || ! is_array( $prev_values ) ) {
639
+				if (false === $prev_values || !is_array($prev_values)) {
640 640
 					$prev_values = array();
641 641
 				}
642 642
 
643
-				delete_post_meta( $id, 'destination_to_accommodation', $prev_values );
644
-				$destinations = array_unique( $destinations );
643
+				delete_post_meta($id, 'destination_to_accommodation', $prev_values);
644
+				$destinations = array_unique($destinations);
645 645
 
646
-				foreach ( $destinations as $key => $value ) {
647
-					$destination = get_page_by_title( ltrim( rtrim( $value ) ), 'OBJECT', 'destination' );
648
-					if ( null !== $destination ) {
649
-						if ( ! in_array( $destination->ID, $prev_values ) ) {
650
-							add_post_meta( $id, 'destination_to_accommodation', $destination->ID, false );
651
-							add_post_meta( $destination->ID, 'accommodation_to_destination', $id, false );
652
-							$this->cleanup_posts[ $destination->ID ] = 'accommodation_to_destination';
646
+				foreach ($destinations as $key => $value) {
647
+					$destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
648
+					if (null !== $destination) {
649
+						if (!in_array($destination->ID, $prev_values)) {
650
+							add_post_meta($id, 'destination_to_accommodation', $destination->ID, false);
651
+							add_post_meta($destination->ID, 'accommodation_to_destination', $id, false);
652
+							$this->cleanup_posts[$destination->ID] = 'accommodation_to_destination';
653 653
 						}
654 654
 					}
655 655
 				}
@@ -660,72 +660,72 @@  discard block
 block discarded – undo
660 660
 	/**
661 661
 	 * Set the Travel Style
662 662
 	 */
663
-	public function set_taxonomy_style( $data, $id ) {
663
+	public function set_taxonomy_style($data, $id) {
664 664
 		$terms = false;
665 665
 
666
-		if ( isset( $data[0]['category'] ) ) {
667
-			$term = term_exists( trim( $data[0]['category'] ), 'accommodation-type' );
668
-			if ( ! $term ) {
669
-				$term = wp_insert_term( trim( $data[0]['category'] ), 'accommodation-type' );
666
+		if (isset($data[0]['category'])) {
667
+			$term = term_exists(trim($data[0]['category']), 'accommodation-type');
668
+			if (!$term) {
669
+				$term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
670 670
 
671
-				if ( is_wp_error( $term ) ) {
672
-					echo wp_kses_post( $term->get_error_message() );
671
+				if (is_wp_error($term)) {
672
+					echo wp_kses_post($term->get_error_message());
673 673
 				}
674
-			} else {
675
-				wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type', true );
674
+			}else {
675
+				wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true);
676 676
 			}
677
-		} else {
678
-			wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type', true );
677
+		}else {
678
+			wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true);
679 679
 		}
680 680
 	}
681 681
 
682 682
 	/**
683 683
 	 * Saves the room data
684 684
 	 */
685
-	public function set_room_data( $data, $id ) {
686
-		if ( ! empty( $data[0]['rooms'] ) && is_array( $data[0]['rooms'] ) ) {
685
+	public function set_room_data($data, $id) {
686
+		if (!empty($data[0]['rooms']) && is_array($data[0]['rooms'])) {
687 687
 			$rooms = false;
688 688
 
689
-			foreach ( $data[0]['rooms'] as $room ) {
689
+			foreach ($data[0]['rooms'] as $room) {
690 690
 				$temp_room = array();
691 691
 
692
-				if ( isset( $room['name'] ) ) {
692
+				if (isset($room['name'])) {
693 693
 					$temp_room['title'] = $room['name'];
694 694
 				}
695 695
 
696
-				if ( isset( $room['description'] ) ) {
697
-					$temp_room['description'] = strip_tags( $room['description'] );
696
+				if (isset($room['description'])) {
697
+					$temp_room['description'] = strip_tags($room['description']);
698 698
 				}
699 699
 
700 700
 				$temp_room['price'] = 0;
701 701
 				$temp_room['type']  = 'room';
702 702
 
703
-				if ( ! empty( $room['images'] ) && is_array( $room['images'] ) ) {
703
+				if (!empty($room['images']) && is_array($room['images'])) {
704 704
 					$temp_room['gallery'] = array();
705
-					$temp_room['gallery'][] = $this->attach_image( $room['images'][0], $id );
705
+					$temp_room['gallery'][] = $this->attach_image($room['images'][0], $id);
706 706
 				}
707 707
 				$rooms[] = $temp_room;
708 708
 			}
709 709
 
710
-			if ( false !== $id && '0' !== $id ) {
711
-				delete_post_meta( $id, 'units' );
710
+			if (false !== $id && '0' !== $id) {
711
+				delete_post_meta($id, 'units');
712 712
 			}
713 713
 
714
-			foreach ( $rooms as $room ) {
715
-				add_post_meta( $id, 'units', $room, false );
714
+			foreach ($rooms as $room) {
715
+				add_post_meta($id, 'units', $room, false);
716 716
 			}
717 717
 
718
-			if ( isset( $data[0]['features'] ) && isset( $data[0]['features']['rooms'] ) ) {
718
+			if (isset($data[0]['features']) && isset($data[0]['features']['rooms'])) {
719 719
 				$room_count = $data[0]['features']['rooms'];
720
-			} else {
721
-				$room_count = count( $data[0]['rooms'] );
720
+			}else {
721
+				$room_count = count($data[0]['rooms']);
722 722
 			}
723 723
 
724
-			if ( false !== $id && '0' !== $id ) {
725
-				$prev_rooms = get_post_meta( $id, 'number_of_rooms', true );
726
-				update_post_meta( $id, 'number_of_rooms', $room_count, $prev_rooms );
727
-			} else {
728
-				add_post_meta( $id, 'number_of_rooms', $room_count, true );
724
+			if (false !== $id && '0' !== $id) {
725
+				$prev_rooms = get_post_meta($id, 'number_of_rooms', true);
726
+				update_post_meta($id, 'number_of_rooms', $room_count, $prev_rooms);
727
+			}else {
728
+				add_post_meta($id, 'number_of_rooms', $room_count, true);
729 729
 			}
730 730
 		}
731 731
 	}
@@ -733,33 +733,33 @@  discard block
 block discarded – undo
733 733
 	/**
734 734
 	 * Set the ratings
735 735
 	 */
736
-	public function set_rating( $data, $id ) {
737
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['star_authority'] ) ) {
736
+	public function set_rating($data, $id) {
737
+		if (!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])) {
738 738
 			$rating_type = $data[0]['features']['star_authority'];
739
-		} else {
739
+		}else {
740 740
 			$rating_type = 'Unspecified2';
741 741
 		}
742 742
 
743
-		$this->save_custom_field( $rating_type, 'rating_type', $id );
743
+		$this->save_custom_field($rating_type, 'rating_type', $id);
744 744
 
745
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['stars'] ) ) {
746
-			$this->save_custom_field( $data[0]['features']['stars'], 'rating', $id, true );
745
+		if (!empty($data[0]['features']) && isset($data[0]['features']['stars'])) {
746
+			$this->save_custom_field($data[0]['features']['stars'], 'rating', $id, true);
747 747
 		}
748 748
 	}
749 749
 
750 750
 	/**
751 751
 	 * Set the spoken_languages
752 752
 	 */
753
-	public function set_spoken_languages( $data, $id ) {
754
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['spoken_languages'] ) && ! empty( $data[0]['features']['spoken_languages'] ) ) {
753
+	public function set_spoken_languages($data, $id) {
754
+		if (!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])) {
755 755
 			$languages = false;
756 756
 
757
-			foreach ( $data[0]['features']['spoken_languages'] as $spoken_language ) {
758
-				$languages[] = sanitize_title( $spoken_language );
757
+			foreach ($data[0]['features']['spoken_languages'] as $spoken_language) {
758
+				$languages[] = sanitize_title($spoken_language);
759 759
 			}
760 760
 
761
-			if ( false !== $languages ) {
762
-				$this->save_custom_field( $languages, 'spoken_languages', $id );
761
+			if (false !== $languages) {
762
+				$this->save_custom_field($languages, 'spoken_languages', $id);
763 763
 			}
764 764
 		}
765 765
 	}
@@ -767,16 +767,16 @@  discard block
 block discarded – undo
767 767
 	/**
768 768
 	 * Set the friendly
769 769
 	 */
770
-	public function set_friendly( $data, $id ) {
771
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['suggested_visitor_types'] ) && ! empty( $data[0]['features']['suggested_visitor_types'] ) ) {
770
+	public function set_friendly($data, $id) {
771
+		if (!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])) {
772 772
 			$friendly_options = false;
773 773
 
774
-			foreach ( $data[0]['features']['suggested_visitor_types'] as $visitor_type ) {
775
-				$friendly_options[] = sanitize_title( $visitor_type );
774
+			foreach ($data[0]['features']['suggested_visitor_types'] as $visitor_type) {
775
+				$friendly_options[] = sanitize_title($visitor_type);
776 776
 			}
777 777
 
778
-			if ( false !== $friendly_options ) {
779
-				$this->save_custom_field( $friendly_options, 'suggested_visitor_types', $id );
778
+			if (false !== $friendly_options) {
779
+				$this->save_custom_field($friendly_options, 'suggested_visitor_types', $id);
780 780
 			}
781 781
 		}
782 782
 	}
@@ -784,16 +784,16 @@  discard block
 block discarded – undo
784 784
 	/**
785 785
 	 * Set the special interests
786 786
 	 */
787
-	public function set_special_interests( $data, $id ) {
788
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['special_interests'] ) && ! empty( $data[0]['features']['special_interests'] ) ) {
787
+	public function set_special_interests($data, $id) {
788
+		if (!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])) {
789 789
 			$interests = false;
790 790
 
791
-			foreach ( $data[0]['features']['special_interests'] as $special_interest ) {
792
-				$interests[] = sanitize_title( $special_interest );
791
+			foreach ($data[0]['features']['special_interests'] as $special_interest) {
792
+				$interests[] = sanitize_title($special_interest);
793 793
 			}
794 794
 
795
-			if ( false !== $interests ) {
796
-				$this->save_custom_field( $interests, 'special_interests', $id );
795
+			if (false !== $interests) {
796
+				$this->save_custom_field($interests, 'special_interests', $id);
797 797
 			}
798 798
 		}
799 799
 	}
@@ -801,24 +801,24 @@  discard block
 block discarded – undo
801 801
 	/**
802 802
 	 * Set the Check in and Check out Date
803 803
 	 */
804
-	public function set_checkin_checkout( $data, $id ) {
805
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_in_time'] ) ) {
806
-			$time = str_replace( 'h', ':', $data[0]['features']['check_in_time'] );
807
-			$time = date( 'h:ia', strtotime( $time ) );
808
-			$this->save_custom_field( $time, 'checkin_time', $id );
804
+	public function set_checkin_checkout($data, $id) {
805
+		if (!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])) {
806
+			$time = str_replace('h', ':', $data[0]['features']['check_in_time']);
807
+			$time = date('h:ia', strtotime($time));
808
+			$this->save_custom_field($time, 'checkin_time', $id);
809 809
 		}
810 810
 
811
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_out_time'] ) ) {
812
-			$time = str_replace( 'h', ':', $data[0]['features']['check_out_time'] );
813
-			$time = date( 'h:ia', strtotime( $time ) );
814
-			$this->save_custom_field( $time, 'checkout_time', $id );
811
+		if (!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])) {
812
+			$time = str_replace('h', ':', $data[0]['features']['check_out_time']);
813
+			$time = date('h:ia', strtotime($time));
814
+			$this->save_custom_field($time, 'checkout_time', $id);
815 815
 		}
816 816
 	}
817 817
 
818 818
 	/**
819 819
 	 * Set the Facilities
820 820
 	 */
821
-	public function set_facilities( $data, $id ) {
821
+	public function set_facilities($data, $id) {
822 822
 		$parent_facilities = array(
823 823
 			'available_services' => 'Available Services',
824 824
 			'property_facilities' => 'Property Facilities',
@@ -826,15 +826,15 @@  discard block
 block discarded – undo
826 826
 			'activities_on_site' => 'Activities on Site',
827 827
 		);
828 828
 
829
-		foreach ( $parent_facilities as $key => $label ) {
829
+		foreach ($parent_facilities as $key => $label) {
830 830
 			$terms = false;
831 831
 
832
-			if ( isset( $data[0]['features'] ) && isset( $data[0]['features'][ $key ] ) ) {
833
-				$parent_id = $this->set_term( $id, $label, 'facility' );
832
+			if (isset($data[0]['features']) && isset($data[0]['features'][$key])) {
833
+				$parent_id = $this->set_term($id, $label, 'facility');
834 834
 			}
835 835
 
836
-			foreach ( $data[0]['features'][ $key ] as $child_facility ) {
837
-				$this->set_term( $id, $child_facility, 'facility', $parent_id );
836
+			foreach ($data[0]['features'][$key] as $child_facility) {
837
+				$this->set_term($id, $child_facility, 'facility', $parent_id);
838 838
 			}
839 839
 		}
840 840
 	}
Please login to merge, or discard this patch.