Completed
Push — master ( 9cb74e...c65df1 )
by Warwick
03:35
created
classes/class-lsx-wetu-importer-destination.php 1 patch
Spacing   +256 added lines, -256 removed lines patch added patch discarded remove patch
@@ -70,17 +70,17 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	public function set_variables() {
72 72
 		parent::set_variables();
73
-		$this->url    = 'https://wetu.com/API/Pins/' . $this->api_key;
73
+		$this->url    = 'https://wetu.com/API/Pins/'.$this->api_key;
74 74
 		$this->url_qs = 'all=include';
75
-		$temp_options = get_option( '_lsx-to_settings', false );
75
+		$temp_options = get_option('_lsx-to_settings', false);
76 76
 
77
-		if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) {
78
-			$this->options = $temp_options[ $this->plugin_slug ];
77
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
78
+			$this->options = $temp_options[$this->plugin_slug];
79 79
 		}
80 80
 
81
-		$destination_options = get_option( 'lsx_wetu_importer_destination_settings', false );
81
+		$destination_options = get_option('lsx_wetu_importer_destination_settings', false);
82 82
 
83
-		if ( false !== $destination_options ) {
83
+		if (false !== $destination_options) {
84 84
 			$this->destination_options = $destination_options;
85 85
 		}
86 86
 	}
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 			</div>
97 97
 
98 98
 			<form method="get" action="" id="posts-filter">
99
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>"/>
99
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>"/>
100 100
 
101 101
 				<table class="wp-list-table widefat fixed posts">
102 102
 					<?php $this->table_header(); ?>
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 					<tr class="post-0 type-tour status-none" id="post-0">
106 106
 						<th class="check-column" scope="row">
107 107
 							<label for="cb-select-0"
108
-								   class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter', 'lsx-wetu-importer' ); ?></label>
108
+								   class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'lsx-wetu-importer'); ?></label>
109 109
 						</th>
110 110
 						<td class="post-title page-title column-title">
111 111
 							<strong>
112
-								<?php esc_html_e( 'Enter a title to search for', 'lsx-wetu-importer' ); ?>
112
+								<?php esc_html_e('Enter a title to search for', 'lsx-wetu-importer'); ?>
113 113
 							</strong>
114 114
 						</td>
115 115
 						<td class="date column-date">
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 				</table>
125 125
 
126 126
 				<p><input class="button button-primary add" type="button"
127
-						  value="<?php esc_html_e( 'Add to List', 'lsx-wetu-importer' ); ?>"/>
127
+						  value="<?php esc_html_e('Add to List', 'lsx-wetu-importer'); ?>"/>
128 128
 					<input class="button button-primary clear" type="button"
129
-						   value="<?php esc_html_e( 'Clear', 'lsx-wetu-importer' ); ?>"/>
129
+						   value="<?php esc_html_e('Clear', 'lsx-wetu-importer'); ?>"/>
130 130
 				</p>
131 131
 			</form>
132 132
 
@@ -136,119 +136,119 @@  discard block
 block discarded – undo
136 136
 
137 137
 					<div class="row">
138 138
 						<div class="settings-all" style="width:30%;display:block;float:left;">
139
-							<h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3>
139
+							<h3><?php esc_html_e('What content to Sync from WETU'); ?></h3>
140 140
 							<ul>
141 141
 								<li>
142
-									<input class="content select-all" <?php $this->checked( $this->destination_options, 'all' ); ?>
142
+									<input class="content select-all" <?php $this->checked($this->destination_options, 'all'); ?>
143 143
 										   type="checkbox" name="content[]"
144
-										   value="all"/> <?php esc_html_e( 'Select All', 'lsx-wetu-importer' ); ?></li>
145
-								<?php if ( isset( $this->options ) && isset( $this->options['disable_destination_descriptions'] ) && 'on' !== $this->options['disable_destination_descriptions'] ) { ?>
144
+										   value="all"/> <?php esc_html_e('Select All', 'lsx-wetu-importer'); ?></li>
145
+								<?php if (isset($this->options) && isset($this->options['disable_destination_descriptions']) && 'on' !== $this->options['disable_destination_descriptions']) { ?>
146 146
 								<li>
147
-									<input class="content" <?php $this->checked( $this->destination_options, 'description' ); ?>
147
+									<input class="content" <?php $this->checked($this->destination_options, 'description'); ?>
148 148
 										   type="checkbox" name="content[]"
149
-										   value="description"/> <?php esc_html_e( 'Description', 'lsx-wetu-importer' ); ?></li>
149
+										   value="description"/> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li>
150 150
 								<?php } ?>
151 151
 
152 152
 								<li>
153
-									<input class="content" <?php $this->checked( $this->destination_options, 'gallery' ); ?>
153
+									<input class="content" <?php $this->checked($this->destination_options, 'gallery'); ?>
154 154
 										   type="checkbox" name="content[]"
155
-										   value="gallery"/> <?php esc_html_e( 'Main Gallery', 'lsx-wetu-importer' ); ?></li>
155
+										   value="gallery"/> <?php esc_html_e('Main Gallery', 'lsx-wetu-importer'); ?></li>
156 156
 
157 157
 									<li>
158
-										<input class="content" <?php $this->checked( $this->destination_options, 'location' ); ?>
158
+										<input class="content" <?php $this->checked($this->destination_options, 'location'); ?>
159 159
 											   type="checkbox" name="content[]"
160
-											   value="location"/> <?php esc_html_e( 'Location', 'lsx-wetu-importer' ); ?>
160
+											   value="location"/> <?php esc_html_e('Location', 'lsx-wetu-importer'); ?>
161 161
 									</li>
162 162
 
163 163
 
164
-								<?php if ( class_exists( 'LSX_TO_Videos' ) ) { ?>
164
+								<?php if (class_exists('LSX_TO_Videos')) { ?>
165 165
 									<li>
166
-										<input class="content" <?php $this->checked( $this->destination_options, 'videos' ); ?>
166
+										<input class="content" <?php $this->checked($this->destination_options, 'videos'); ?>
167 167
 											   type="checkbox" name="content[]"
168
-											   value="videos"/> <?php esc_html_e( 'Videos', 'lsx-wetu-importer' ); ?></li>
168
+											   value="videos"/> <?php esc_html_e('Videos', 'lsx-wetu-importer'); ?></li>
169 169
 								<?php } ?>
170 170
 
171 171
 							</ul>
172
-							<h4><?php esc_html_e( 'Additional Content' ); ?></h4>
172
+							<h4><?php esc_html_e('Additional Content'); ?></h4>
173 173
 							<ul>
174 174
 								<li>
175
-									<input class="content" <?php $this->checked( $this->destination_options, 'country' ); ?>
175
+									<input class="content" <?php $this->checked($this->destination_options, 'country'); ?>
176 176
 										   type="checkbox" name="content[]"
177
-										   value="country"/> <?php esc_html_e( 'Set Country', 'lsx-wetu-importer' ); ?></li>
177
+										   value="country"/> <?php esc_html_e('Set Country', 'lsx-wetu-importer'); ?></li>
178 178
 								<li>
179
-									<input class="content" <?php $this->checked( $this->destination_options, 'continent' ); ?>
179
+									<input class="content" <?php $this->checked($this->destination_options, 'continent'); ?>
180 180
 										   type="checkbox" name="content[]"
181
-										   value="continent"/> <?php esc_html_e( 'Set Continent', 'lsx-wetu-importer' ); ?></li>
181
+										   value="continent"/> <?php esc_html_e('Set Continent', 'lsx-wetu-importer'); ?></li>
182 182
 
183 183
 								<li>
184
-									<input class="content" <?php $this->checked( $this->destination_options, 'featured_image' ); ?>
184
+									<input class="content" <?php $this->checked($this->destination_options, 'featured_image'); ?>
185 185
 										   type="checkbox" name="content[]"
186
-										   value="featured_image"/> <?php esc_html_e( 'Set Featured Image', 'lsx-wetu-importer' ); ?>
186
+										   value="featured_image"/> <?php esc_html_e('Set Featured Image', 'lsx-wetu-importer'); ?>
187 187
 								</li>
188
-								<?php if ( class_exists( 'LSX_Banners' ) ) { ?>
188
+								<?php if (class_exists('LSX_Banners')) { ?>
189 189
 									<li>
190
-										<input class="content" <?php $this->checked( $this->destination_options, 'banner_image' ); ?>
190
+										<input class="content" <?php $this->checked($this->destination_options, 'banner_image'); ?>
191 191
 											   type="checkbox" name="content[]"
192
-											   value="banner_image"/> <?php esc_html_e( 'Set Banner Image', 'lsx-wetu-importer' ); ?>
192
+											   value="banner_image"/> <?php esc_html_e('Set Banner Image', 'lsx-wetu-importer'); ?>
193 193
 									</li>
194 194
 									<li>
195
-										<input class="content" <?php $this->checked( $this->destination_options, 'unique_banner_image' ); ?>
195
+										<input class="content" <?php $this->checked($this->destination_options, 'unique_banner_image'); ?>
196 196
 											   type="checkbox" name="content[]"
197
-											   value="unique_banner_image"/> <?php esc_html_e( 'Use the WETU banner field', 'lsx-wetu-importer' ); ?>
197
+											   value="unique_banner_image"/> <?php esc_html_e('Use the WETU banner field', 'lsx-wetu-importer'); ?>
198 198
 									</li>
199 199
 								<?php } ?>
200 200
 
201 201
 								<li>
202
-									<input class="content" <?php $this->checked( $this->destination_options, 'strip_tags' ); ?>
202
+									<input class="content" <?php $this->checked($this->destination_options, 'strip_tags'); ?>
203 203
 										   type="checkbox" name="content[]"
204
-										   value="strip_tags"/> <?php esc_html_e( 'Strip HTML from the description', 'lsx-wetu-importer' ); ?></li>
204
+										   value="strip_tags"/> <?php esc_html_e('Strip HTML from the description', 'lsx-wetu-importer'); ?></li>
205 205
 							</ul>
206 206
 						</div>
207 207
 						<div class="settings-all" style="width:30%;display:block;float:left;">
208
-							<h3><?php esc_html_e( 'Travel Information' ); ?></h3>
208
+							<h3><?php esc_html_e('Travel Information'); ?></h3>
209 209
 							<ul>
210 210
 								<li>
211
-									<input class="content" <?php $this->checked( $this->destination_options, 'electricity' ); ?>
211
+									<input class="content" <?php $this->checked($this->destination_options, 'electricity'); ?>
212 212
 										   type="checkbox" name="content[]"
213
-										   value="electricity"/> <?php esc_html_e( 'Electricity', 'lsx-wetu-importer' ); ?></li>
213
+										   value="electricity"/> <?php esc_html_e('Electricity', 'lsx-wetu-importer'); ?></li>
214 214
 								<li>
215
-									<input class="content" <?php $this->checked( $this->destination_options, 'banking' ); ?>
215
+									<input class="content" <?php $this->checked($this->destination_options, 'banking'); ?>
216 216
 										   type="checkbox" name="content[]"
217
-										   value="banking"/> <?php esc_html_e( 'Banking', 'lsx-wetu-importer' ); ?></li>
217
+										   value="banking"/> <?php esc_html_e('Banking', 'lsx-wetu-importer'); ?></li>
218 218
 								<li>
219
-									<input class="content" <?php $this->checked( $this->destination_options, 'cuisine' ); ?>
219
+									<input class="content" <?php $this->checked($this->destination_options, 'cuisine'); ?>
220 220
 										   type="checkbox" name="content[]"
221
-										   value="cuisine"/> <?php esc_html_e( 'Cuisine', 'lsx-wetu-importer' ); ?></li>
221
+										   value="cuisine"/> <?php esc_html_e('Cuisine', 'lsx-wetu-importer'); ?></li>
222 222
 								<li>
223
-									<input class="content" <?php $this->checked( $this->destination_options, 'climate' ); ?>
223
+									<input class="content" <?php $this->checked($this->destination_options, 'climate'); ?>
224 224
 										   type="checkbox" name="content[]"
225
-										   value="climate"/> <?php esc_html_e( 'Climate', 'lsx-wetu-importer' ); ?></li>
225
+										   value="climate"/> <?php esc_html_e('Climate', 'lsx-wetu-importer'); ?></li>
226 226
 								<li>
227
-									<input class="content" <?php $this->checked( $this->destination_options, 'transport' ); ?>
227
+									<input class="content" <?php $this->checked($this->destination_options, 'transport'); ?>
228 228
 										   type="checkbox" name="content[]"
229
-										   value="transport"/> <?php esc_html_e( 'Transport', 'lsx-wetu-importer' ); ?></li>
230
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'dress' ); ?>
229
+										   value="transport"/> <?php esc_html_e('Transport', 'lsx-wetu-importer'); ?></li>
230
+								<li><input class="content" <?php $this->checked($this->destination_options, 'dress'); ?>
231 231
 										   type="checkbox" name="content[]"
232
-										   value="dress"/> <?php esc_html_e( 'Dress', 'lsx-wetu-importer' ); ?></li>
233
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'health' ); ?>
232
+										   value="dress"/> <?php esc_html_e('Dress', 'lsx-wetu-importer'); ?></li>
233
+								<li><input class="content" <?php $this->checked($this->destination_options, 'health'); ?>
234 234
 										   type="checkbox" name="content[]"
235
-										   value="health"/> <?php esc_html_e( 'Health', 'lsx-wetu-importer' ); ?></li>
236
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'safety' ); ?>
235
+										   value="health"/> <?php esc_html_e('Health', 'lsx-wetu-importer'); ?></li>
236
+								<li><input class="content" <?php $this->checked($this->destination_options, 'safety'); ?>
237 237
 										   type="checkbox" name="content[]"
238
-										   value="safety"/> <?php esc_html_e( 'Safety', 'lsx-wetu-importer' ); ?></li>
239
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'visa' ); ?>
238
+										   value="safety"/> <?php esc_html_e('Safety', 'lsx-wetu-importer'); ?></li>
239
+								<li><input class="content" <?php $this->checked($this->destination_options, 'visa'); ?>
240 240
 										   type="checkbox" name="content[]"
241
-										   value="visa"/> <?php esc_html_e( 'Visa', 'lsx-wetu-importer' ); ?></li>
242
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'additional_info' ); ?>
241
+										   value="visa"/> <?php esc_html_e('Visa', 'lsx-wetu-importer'); ?></li>
242
+								<li><input class="content" <?php $this->checked($this->destination_options, 'additional_info'); ?>
243 243
 										   type="checkbox" name="content[]"
244
-										   value="additional_info"/> <?php esc_html_e( 'General', 'lsx-wetu-importer' ); ?></li>
244
+										   value="additional_info"/> <?php esc_html_e('General', 'lsx-wetu-importer'); ?></li>
245 245
 							</ul>
246 246
 						</div>
247 247
 
248
-						<?php if ( class_exists( 'LSX_TO_Team' ) ) { ?>
248
+						<?php if (class_exists('LSX_TO_Team')) { ?>
249 249
 							<div style="width:30%;display:block;float:left;">
250
-								<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3>
251
-								<?php $this->team_member_checkboxes( $this->destination_options ); ?>
250
+								<h3><?php esc_html_e('Assign a Team Member'); ?></h3>
251
+								<?php $this->team_member_checkboxes($this->destination_options); ?>
252 252
 							</div>
253 253
 						<?php } ?>
254 254
 
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 					</div>
257 257
 
258 258
 
259
-					<h3><?php esc_html_e( 'Your List' ); ?></h3>
259
+					<h3><?php esc_html_e('Your List'); ?></h3>
260 260
 					<p><input class="button button-primary" type="submit"
261
-							  value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>"/></p>
261
+							  value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>"/></p>
262 262
 					<table class="wp-list-table widefat fixed posts">
263 263
 						<?php $this->table_header(); ?>
264 264
 
@@ -271,12 +271,12 @@  discard block
 block discarded – undo
271 271
 					</table>
272 272
 
273 273
 					<p><input class="button button-primary" type="submit"
274
-							  value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>"/></p>
274
+							  value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>"/></p>
275 275
 				</form>
276 276
 			</div>
277 277
 
278 278
 			<div style="display:none;" class="completed-list-wrapper">
279
-				<h3><?php esc_html_e( 'Completed' ); ?></h3>
279
+				<h3><?php esc_html_e('Completed'); ?></h3>
280 280
 				<ul>
281 281
 				</ul>
282 282
 			</div>
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	/**
288 288
 	 * Grab all the current destination posts via the lsx_wetu_id field.
289 289
 	 */
290
-	public function find_current_destination( $post_type = 'destination' ) {
290
+	public function find_current_destination($post_type = 'destination') {
291 291
 		global $wpdb;
292 292
 		$return = array();
293 293
 
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
 		");
307 307
 		// @codingStandardsIgnoreEnd
308 308
 
309
-		if ( null !== $current_destination && ! empty( $current_destination ) ) {
310
-			foreach ( $current_destination as $accom ) {
311
-				$return[ $accom->meta_value ] = $accom;
309
+		if (null !== $current_destination && !empty($current_destination)) {
310
+			foreach ($current_destination as $accom) {
311
+				$return[$accom->meta_value] = $accom;
312 312
 			}
313 313
 		}
314 314
 
@@ -320,117 +320,117 @@  discard block
 block discarded – undo
320 320
 	 */
321 321
 	public function process_ajax_search() {
322 322
 		$return = false;
323
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
324
-		if ( isset( $_POST['action'] ) && 'lsx_tour_importer' === $_POST['action'] && isset( $_POST['type'] ) && 'destination' === $_POST['type'] ) {
323
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
324
+		if (isset($_POST['action']) && 'lsx_tour_importer' === $_POST['action'] && isset($_POST['type']) && 'destination' === $_POST['type']) {
325 325
 
326 326
 			$searched_items = false;
327
-			if ( isset( $_POST['keyword'] ) ) {
328
-				$keyphrases = array_map( 'sanitize_text_field', wp_unslash( $_POST['keyword'] ) );
329
-			} else {
330
-				$keyphrases = array( 0 );
327
+			if (isset($_POST['keyword'])) {
328
+				$keyphrases = array_map('sanitize_text_field', wp_unslash($_POST['keyword']));
329
+			}else {
330
+				$keyphrases = array(0);
331 331
 			}
332 332
 
333
-			if ( ! is_array( $keyphrases ) ) {
334
-				$keyphrases = array( $keyphrases );
333
+			if (!is_array($keyphrases)) {
334
+				$keyphrases = array($keyphrases);
335 335
 			}
336
-			foreach ( $keyphrases as &$keyword ) {
337
-				$keyword = ltrim( rtrim( $keyword ) );
336
+			foreach ($keyphrases as &$keyword) {
337
+				$keyword = ltrim(rtrim($keyword));
338 338
 			}
339 339
 
340 340
 			$post_status = false;
341 341
 
342
-			if ( in_array( 'publish', $keyphrases ) ) {
342
+			if (in_array('publish', $keyphrases)) {
343 343
 				$post_status = 'publish';
344 344
 			}
345
-			if ( in_array( 'pending', $keyphrases ) ) {
345
+			if (in_array('pending', $keyphrases)) {
346 346
 				$post_status = 'pending';
347 347
 			}
348
-			if ( in_array( 'draft', $keyphrases ) ) {
348
+			if (in_array('draft', $keyphrases)) {
349 349
 				$post_status = 'draft';
350 350
 			}
351
-			if ( in_array( 'import', $keyphrases ) ) {
351
+			if (in_array('import', $keyphrases)) {
352 352
 				$post_status = 'import';
353 353
 			}
354 354
 
355 355
 			// If there is a post status use it.
356
-			if ( false !== $post_status ) {
356
+			if (false !== $post_status) {
357 357
 
358 358
 				$accommodation = array();
359
-				$current_accommodation = $this->find_current_accommodation( 'destination' );
360
-				if ( ! empty( $current_accommodation ) ) {
361
-					foreach ( $current_accommodation as $cs_key => $ccs_id ) {
362
-						$accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id );
359
+				$current_accommodation = $this->find_current_accommodation('destination');
360
+				if (!empty($current_accommodation)) {
361
+					foreach ($current_accommodation as $cs_key => $ccs_id) {
362
+						$accommodation[] = $this->prepare_row_attributes($cs_key, $ccs_id->post_id);
363 363
 					}
364 364
 				}
365 365
 
366 366
 				// Run through each accommodation and use it.
367
-				if ( ! empty( $accommodation ) ) {
368
-					foreach ( $accommodation as $row_key => $row ) {
369
-						if ( 'import' === $post_status ) {
370
-
371
-							if ( is_array( $this->queued_imports ) && in_array( $row['post_id'], $this->queued_imports ) ) {
372
-								$current_status = get_post_status( $row['post_id'] );
373
-								if ( 'draft' === $current_status ) {
374
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
367
+				if (!empty($accommodation)) {
368
+					foreach ($accommodation as $row_key => $row) {
369
+						if ('import' === $post_status) {
370
+
371
+							if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) {
372
+								$current_status = get_post_status($row['post_id']);
373
+								if ('draft' === $current_status) {
374
+									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
375 375
 								}
376
-							} else {
376
+							}else {
377 377
 								continue;
378 378
 							}
379
-						} else {
380
-							if ( 0 === $row['post_id'] ) {
379
+						}else {
380
+							if (0 === $row['post_id']) {
381 381
 								continue;
382
-							} else {
383
-								$current_status = get_post_status( $row['post_id'] );
382
+							}else {
383
+								$current_status = get_post_status($row['post_id']);
384 384
 
385
-								if ( $current_status !== $post_status ) {
385
+								if ($current_status !== $post_status) {
386 386
 									continue;
387 387
 								}
388 388
 							}
389
-							$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
389
+							$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
390 390
 						}
391 391
 					}
392 392
 				}
393
-			} else {
393
+			}else {
394 394
 
395
-				$key_string_search = implode( '+', $keyphrases );
396
-				$search_data       = wp_remote_get( $this->url . '/Search/' . $key_string_search . '/?all=include' );
395
+				$key_string_search = implode('+', $keyphrases);
396
+				$search_data       = wp_remote_get($this->url.'/Search/'.$key_string_search.'/?all=include');
397 397
 
398
-				if ( ! is_wp_error( $search_data ) || ! empty( $search_data ) && isset( $search_data['response'] ) && isset( $search_data['response']['code'] ) && 200 === $search_data['response']['code'] ) {
399
-					$search_data = json_decode( $search_data['body'], true );
400
-					foreach ( $search_data as $sdata ) {
398
+				if (!is_wp_error($search_data) || !empty($search_data) && isset($search_data['response']) && isset($search_data['response']['code']) && 200 === $search_data['response']['code']) {
399
+					$search_data = json_decode($search_data['body'], true);
400
+					foreach ($search_data as $sdata) {
401 401
 
402
-						if ( 'Destination' !== trim( $sdata['type'] ) ) {
402
+						if ('Destination' !== trim($sdata['type'])) {
403 403
 							continue;
404 404
 						}
405 405
 
406
-						$temp_id = $this->get_post_id_by_key_value( $sdata['id'] );
407
-						if ( false === $temp_id ) {
406
+						$temp_id = $this->get_post_id_by_key_value($sdata['id']);
407
+						if (false === $temp_id) {
408 408
 							$sdata['post_id'] = 0;
409
-						} else {
409
+						}else {
410 410
 							$sdata['post_id'] = $temp_id;
411 411
 						}
412
-						$searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata );
412
+						$searched_items[sanitize_title($sdata['name']).'-'.$sdata['id']] = $this->format_row($sdata);
413 413
 					}
414 414
 				}
415 415
 			}
416 416
 
417
-			if ( false !== $searched_items ) {
418
-				ksort( $searched_items );
419
-				$return = implode( $searched_items );
417
+			if (false !== $searched_items) {
418
+				ksort($searched_items);
419
+				$return = implode($searched_items);
420 420
 			}
421
-			print_r( $return );
422
-		} else {
423
-			echo esc_attr( 'None found' );
421
+			print_r($return);
422
+		}else {
423
+			echo esc_attr('None found');
424 424
 		}
425 425
 		die();
426 426
 	}
427 427
 
428
-	public function prepare_row_attributes( $cs_key, $ccs_id ) {
428
+	public function prepare_row_attributes($cs_key, $ccs_id) {
429 429
 		$row_item = array(
430 430
 			'id' => $cs_key,
431 431
 			'type' => 'Destination',
432
-			'name' => get_the_title( $ccs_id ),
433
-			'last_modified' => date( 'Y-m-d', strtotime( 'now' ) ),
432
+			'name' => get_the_title($ccs_id),
433
+			'last_modified' => date('Y-m-d', strtotime('now')),
434 434
 			'post_id' => $ccs_id,
435 435
 		);
436 436
 		return $row_item;
@@ -439,28 +439,28 @@  discard block
 block discarded – undo
439 439
 	/**
440 440
 	 * Formats the row for output on the screen.
441 441
 	 */
442
-	public function format_row( $row = false ) {
443
-		if ( false !== $row ) {
442
+	public function format_row($row = false) {
443
+		if (false !== $row) {
444 444
 
445 445
 			$status = 'import';
446
-			if ( 0 !== $row['post_id'] ) {
447
-				$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>';
446
+			if (0 !== $row['post_id']) {
447
+				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
448 448
 			}
449 449
 
450 450
 			$row_html = '
451
-			<tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '">
451
+			<tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'">
452 452
 				<th class="check-column" scope="row">
453
-					<label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label>
454
-					<input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '">
453
+					<label for="cb-select-' . $row['id'].'" class="screen-reader-text">'.$row['name'].'</label>
454
+					<input type="checkbox" data-identifier="' . $row['id'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['id'].'">
455 455
 				</th>
456 456
 				<td class="post-title page-title column-title">
457
-					<strong>' . $row['name'] . '</strong> - ' . $status . '
457
+					<strong>' . $row['name'].'</strong> - '.$status.'
458 458
 				</td>
459 459
 				<td class="date column-date">
460
-					<abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified
460
+					<abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
461 461
 				</td>
462 462
 				<td class="ssid column-ssid">
463
-					' . $row['id'] . '
463
+					' . $row['id'].'
464 464
 				</td>
465 465
 			</tr>';
466 466
 			return $row_html;
@@ -473,45 +473,45 @@  discard block
 block discarded – undo
473 473
 	public function process_ajax_import() {
474 474
 		$return = false;
475 475
 
476
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
477
-		if ( isset( $_POST['action'] ) && 'lsx_import_items' === $_POST['action'] && isset( $_POST['type'] ) && 'destination' === $_POST['type'] && isset( $_POST['wetu_id'] ) ) {
476
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
477
+		if (isset($_POST['action']) && 'lsx_import_items' === $_POST['action'] && isset($_POST['type']) && 'destination' === $_POST['type'] && isset($_POST['wetu_id'])) {
478 478
 
479
-			$wetu_id = sanitize_text_field( $_POST['wetu_id'] );
479
+			$wetu_id = sanitize_text_field($_POST['wetu_id']);
480 480
 
481
-			if ( isset( $_POST['post_id'] ) ) {
482
-				$post_id = sanitize_text_field( $_POST['post_id'] );
483
-				$this->current_post = get_post( $post_id );
484
-			} else {
481
+			if (isset($_POST['post_id'])) {
482
+				$post_id = sanitize_text_field($_POST['post_id']);
483
+				$this->current_post = get_post($post_id);
484
+			}else {
485 485
 				$post_id = 0;
486 486
 			}
487 487
 
488
-			if ( isset( $_POST['team_members'] ) ) {
489
-				$team_members = sanitize_text_field( $_POST['team_members'] );
490
-			} else {
488
+			if (isset($_POST['team_members'])) {
489
+				$team_members = sanitize_text_field($_POST['team_members']);
490
+			}else {
491 491
 				$team_members = false;
492 492
 			}
493 493
 
494 494
 			$safari_brands = false;
495 495
 
496
-			delete_option( 'lsx_wetu_importer_destination_settings' );
496
+			delete_option('lsx_wetu_importer_destination_settings');
497 497
 
498
-			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
499
-				$content = array_map( 'sanitize_text_field', wp_unslash( $_POST['content'] ) );
500
-				add_option( 'lsx_wetu_importer_destination_settings', $content );
501
-			} else {
498
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
499
+				$content = array_map('sanitize_text_field', wp_unslash($_POST['content']));
500
+				add_option('lsx_wetu_importer_destination_settings', $content);
501
+			}else {
502 502
 				$content = false;
503 503
 			}
504 504
 
505
-			print_r( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
506
-			$jdata = wp_remote_get( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
505
+			print_r($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'] ) ) {
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'])) {
540 540
 			$post_name = '';
541 541
 			$data_post_content = '';
542 542
 			$data_post_excerpt = '';
@@ -545,130 +545,130 @@  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 569
 
570
-				if ( isset( $data[0]['name'] ) ) {
570
+				if (isset($data[0]['name'])) {
571 571
 					$post['post_title'] = $data[0]['name'];
572 572
 					$post['post_status'] = 'publish';
573
-					$post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 );
573
+					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
574 574
 				}
575 575
 
576
-				$id = wp_update_post( $post );
577
-				$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
578
-				update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date );
579
-			} else {
576
+				$id = wp_update_post($post);
577
+				$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
578
+				update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
579
+			}else {
580 580
 				// Set the name.
581
-				if ( isset( $data[0]['name'] ) ) {
582
-					$post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 );
581
+				if (isset($data[0]['name'])) {
582
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
583 583
 				}
584 584
 
585 585
 				$post['post_name'] = $post_name;
586 586
 				$post['post_title'] = $data[0]['name'];
587 587
 				$post['post_status'] = 'publish';
588
-				$id = wp_insert_post( $post );
588
+				$id = wp_insert_post($post);
589 589
 
590 590
 				// Save the WETU ID and the Last date it was modified.
591
-				if ( false !== $id ) {
592
-					add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
593
-					add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) );
591
+				if (false !== $id) {
592
+					add_post_meta($id, 'lsx_wetu_id', $wetu_id);
593
+					add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']));
594 594
 				}
595 595
 			}
596 596
 
597
-			$this->find_attachments( $id );
597
+			$this->find_attachments($id);
598 598
 
599 599
 			// Set the team member if it is there.
600
-			if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) {
601
-				$this->set_team_member( $id, $team_members );
600
+			if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
601
+				$this->set_team_member($id, $team_members);
602 602
 			}
603 603
 
604
-			$this->set_map_data( $data, $id, 9 );
604
+			$this->set_map_data($data, $id, 9);
605 605
 
606 606
 			// Set the Room Data.
607
-			if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) {
608
-				$this->set_video_data( $data, $id );
607
+			if (false !== $importable_content && in_array('videos', $importable_content)) {
608
+				$this->set_video_data($data, $id);
609 609
 			}
610 610
 
611 611
 			// Set the Electricity.
612
-			if ( false !== $importable_content && in_array( 'electricity', $importable_content ) ) {
613
-				$this->set_travel_info( $data, $id, 'electricity', $importable_content );
612
+			if (false !== $importable_content && in_array('electricity', $importable_content)) {
613
+				$this->set_travel_info($data, $id, 'electricity', $importable_content);
614 614
 			}
615 615
 			// Set the cuisine.
616
-			if ( false !== $importable_content && in_array( 'cuisine', $importable_content ) ) {
617
-				$this->set_travel_info( $data, $id, 'cuisine', $importable_content );
616
+			if (false !== $importable_content && in_array('cuisine', $importable_content)) {
617
+				$this->set_travel_info($data, $id, 'cuisine', $importable_content);
618 618
 			}
619 619
 			// Set the banking.
620
-			if ( false !== $importable_content && in_array( 'banking', $importable_content ) ) {
621
-				$this->set_travel_info( $data, $id, 'banking', $importable_content );
620
+			if (false !== $importable_content && in_array('banking', $importable_content)) {
621
+				$this->set_travel_info($data, $id, 'banking', $importable_content);
622 622
 			}
623 623
 			// Set the transport.
624
-			if ( false !== $importable_content && in_array( 'transport', $importable_content ) ) {
625
-				$this->set_travel_info( $data, $id, 'transport', $importable_content );
624
+			if (false !== $importable_content && in_array('transport', $importable_content)) {
625
+				$this->set_travel_info($data, $id, 'transport', $importable_content);
626 626
 			}
627 627
 			// Set the dress.
628
-			if ( false !== $importable_content && in_array( 'dress', $importable_content ) ) {
629
-				$this->set_travel_info( $data, $id, 'dress', $importable_content );
628
+			if (false !== $importable_content && in_array('dress', $importable_content)) {
629
+				$this->set_travel_info($data, $id, 'dress', $importable_content);
630 630
 			}
631 631
 			// Set the climate.
632
-			if ( false !== $importable_content && in_array( 'climate', $importable_content ) ) {
633
-				$this->set_travel_info( $data, $id, 'climate', $importable_content );
632
+			if (false !== $importable_content && in_array('climate', $importable_content)) {
633
+				$this->set_travel_info($data, $id, 'climate', $importable_content);
634 634
 			}
635 635
 			// Set the Health.
636
-			if ( false !== $importable_content && in_array( 'health', $importable_content ) ) {
637
-				$this->set_travel_info( $data, $id, 'health', $importable_content );
636
+			if (false !== $importable_content && in_array('health', $importable_content)) {
637
+				$this->set_travel_info($data, $id, 'health', $importable_content);
638 638
 			}
639 639
 			// Set the Safety.
640
-			if ( false !== $importable_content && in_array( 'safety', $importable_content ) ) {
641
-				$this->set_travel_info( $data, $id, 'safety', $importable_content );
640
+			if (false !== $importable_content && in_array('safety', $importable_content)) {
641
+				$this->set_travel_info($data, $id, 'safety', $importable_content);
642 642
 			}
643 643
 			// Set the Visa.
644
-			if ( false !== $importable_content && in_array( 'visa', $importable_content ) ) {
645
-				$this->set_travel_info( $data, $id, 'visa', $importable_content );
644
+			if (false !== $importable_content && in_array('visa', $importable_content)) {
645
+				$this->set_travel_info($data, $id, 'visa', $importable_content);
646 646
 			}
647 647
 			// Set the General.
648
-			if ( false !== $importable_content && in_array( 'additional_info', $importable_content ) ) {
649
-				$this->set_travel_info( $data, $id, 'additional_info', $importable_content );
648
+			if (false !== $importable_content && in_array('additional_info', $importable_content)) {
649
+				$this->set_travel_info($data, $id, 'additional_info', $importable_content);
650 650
 			}
651 651
 
652 652
 			// Setup some default for use in the import.
653
-			if ( false !== $importable_content && (in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content )) ) {
654
-				$this->find_attachments( $id );
653
+			if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) {
654
+				$this->find_attachments($id);
655 655
 
656 656
 				// Set the featured image.
657
-				if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
658
-					$this->set_featured_image( $data, $id );
657
+				if (false !== $importable_content && in_array('featured_image', $importable_content)) {
658
+					$this->set_featured_image($data, $id);
659 659
 				}
660
-				if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
661
-					$this->set_banner_image( $data, $id, $importable_content );
660
+				if (false !== $importable_content && in_array('banner_image', $importable_content)) {
661
+					$this->set_banner_image($data, $id, $importable_content);
662 662
 				}
663 663
 				// Import the main gallery.
664
-				if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) {
665
-					$this->create_main_gallery( $data, $id );
664
+				if (false !== $importable_content && in_array('gallery', $importable_content)) {
665
+					$this->create_main_gallery($data, $id);
666 666
 				}
667 667
 			}
668 668
 
669 669
 			// Set the continent.
670
-			if ( false !== $importable_content && in_array( 'continent', $importable_content ) ) {
671
-				$this->set_continent( $data, $id );
670
+			if (false !== $importable_content && in_array('continent', $importable_content)) {
671
+				$this->set_continent($data, $id);
672 672
 			}
673 673
 		}
674 674
 
@@ -678,48 +678,48 @@  discard block
 block discarded – undo
678 678
 	/**
679 679
 	 * Set the team memberon each item.
680 680
 	 */
681
-	public function set_team_member( $id, $team_members ) {
682
-		delete_post_meta( $id, 'team_to_' . $this->tab_slug );
681
+	public function set_team_member($id, $team_members) {
682
+		delete_post_meta($id, 'team_to_'.$this->tab_slug);
683 683
 
684
-		foreach ( $team_members as $team ) {
685
-			add_post_meta( $id, 'team_to_' . $this->tab_slug, $team );
684
+		foreach ($team_members as $team) {
685
+			add_post_meta($id, 'team_to_'.$this->tab_slug, $team);
686 686
 		}
687 687
 	}
688 688
 
689 689
 	/**
690 690
 	 * Saves the room data
691 691
 	 */
692
-	public function set_travel_info( $data, $id, $meta_key, $importable = array( 'none' ) ) {
693
-		if ( ! empty( $data[0]['travel_information'] ) && isset( $data[0]['travel_information'][ $meta_key ] ) ) {
694
-			$content = $data[0]['travel_information'][ $meta_key ];
692
+	public function set_travel_info($data, $id, $meta_key, $importable = array('none')) {
693
+		if (!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])) {
694
+			$content = $data[0]['travel_information'][$meta_key];
695 695
 
696
-			if ( in_array( 'strip_tags', $importable ) ) {
697
-				$content = strip_tags( $content );
696
+			if (in_array('strip_tags', $importable)) {
697
+				$content = strip_tags($content);
698 698
 			}
699 699
 
700
-			$this->save_custom_field( $content, $meta_key, $id );
700
+			$this->save_custom_field($content, $meta_key, $id);
701 701
 		}
702 702
 	}
703 703
 
704 704
 	/**
705 705
 	 * Set the Travel Style
706 706
 	 */
707
-	public function set_continent( $data, $id ) {
707
+	public function set_continent($data, $id) {
708 708
 
709
-		if ( isset( $data[0]['position']['country'] ) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id'] ) {
709
+		if (isset($data[0]['position']['country']) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id']) {
710 710
 			//get the continent code.
711
-			$continent_code = to_continent_label( to_continent_code( to_country_data( $data[0]['position']['country'], false ) ) );
711
+			$continent_code = to_continent_label(to_continent_code(to_country_data($data[0]['position']['country'], false)));
712 712
 
713
-			if ( '' !== $continent_code ) {
714
-				$term = term_exists( trim( $continent_code ), 'continent' );
715
-				if ( ! $term ) {
716
-					$term = wp_insert_term( trim( $continent_code ), 'continent' );
713
+			if ('' !== $continent_code) {
714
+				$term = term_exists(trim($continent_code), 'continent');
715
+				if (!$term) {
716
+					$term = wp_insert_term(trim($continent_code), 'continent');
717 717
 
718
-					if ( is_wp_error( $term ) ) {
719
-						echo wp_kses_post( $term->get_error_message() );
718
+					if (is_wp_error($term)) {
719
+						echo wp_kses_post($term->get_error_message());
720 720
 					}
721
-				} else {
722
-					wp_set_object_terms( $id, sanitize_title( $continent_code ), 'continent', true );
721
+				}else {
722
+					wp_set_object_terms($id, sanitize_title($continent_code), 'continent', true);
723 723
 				}
724 724
 			}
725 725
 		}
@@ -729,10 +729,10 @@  discard block
 block discarded – undo
729 729
 	 * Save the list of Accommodation into an option
730 730
 	 */
731 731
 	public function update_options() {
732
-		$data = wp_remote_get( $this->url . '/List?' . $this->url_qs );
733
-		if ( ! empty( $data ) && isset( $data['response'] ) && isset( $data['response']['code'] ) && 200 === $data['response']['code'] ) {
734
-			$accommodation = json_decode( $data['body'], true );
735
-			set_transient( 'lsx_ti_accommodation', $accommodation, 60 * 60 * 2 );
732
+		$data = wp_remote_get($this->url.'/List?'.$this->url_qs);
733
+		if (!empty($data) && isset($data['response']) && isset($data['response']['code']) && 200 === $data['response']['code']) {
734
+			$accommodation = json_decode($data['body'], true);
735
+			set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2);
736 736
 			return true;
737 737
 		}
738 738
 	}
@@ -741,11 +741,11 @@  discard block
 block discarded – undo
741 741
 	 * search_form
742 742
 	 */
743 743
 	public function update_options_form() {
744
-		echo '<div style="display:none;" class="wetu-status"><h3>' . esc_html__( 'Wetu Status', 'lsx-wetu-importer' ) . '</h3>';
744
+		echo '<div style="display:none;" class="wetu-status"><h3>'.esc_html__('Wetu Status', 'lsx-wetu-importer').'</h3>';
745 745
 
746
-		$accommodation = get_transient( 'lsx_ti_accommodation' );
746
+		$accommodation = get_transient('lsx_ti_accommodation');
747 747
 
748
-		if ( '' === $accommodation || false === $accommodation || isset( $_GET['refresh_accommodation'] ) ) {
748
+		if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) {
749 749
 			$this->update_options();
750 750
 		}
751 751
 
@@ -755,12 +755,12 @@  discard block
 block discarded – undo
755 755
 	/**
756 756
 	 * Save the list of Accommodation into an option
757 757
 	 */
758
-	public function check_for_parent( $data = array() ) {
758
+	public function check_for_parent($data = array()) {
759 759
 		global $wpdb;
760 760
 
761
-		if ( $data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id'] ) {
762
-			$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'] ) ) );
763
-			if ( ! empty( $result ) && '' !== $result && false !== $result ) {
761
+		if ($data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id']) {
762
+			$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'])));
763
+			if (!empty($result) && '' !== $result && false !== $result) {
764 764
 				return $result;
765 765
 			}
766 766
 		}
Please login to merge, or discard this patch.