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