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