Passed
Push — master ( 2aa6e3...e34bbe )
by Warwick
04:33
created
classes/class-wetu-importer-destination.php 1 patch
Spacing   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -75,19 +75,19 @@  discard block
 block discarded – undo
75 75
 		//	$this->url    = 'https://wetu.com/API/Pins/';
76 76
 		//	$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
77 77
 		//} elseif ( false !== $this->api_key ) {
78
-		$this->url = 'https://wetu.com/API/Pins/' . $this->api_key;
78
+		$this->url = 'https://wetu.com/API/Pins/'.$this->api_key;
79 79
 		$this->url_qs = 'all=include';
80 80
 		//}
81 81
 
82
-		$temp_options = get_option( '_lsx-to_settings', false );
82
+		$temp_options = get_option('_lsx-to_settings', false);
83 83
 
84
-		if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) {
85
-			$this->options = $temp_options[ $this->plugin_slug ];
84
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
85
+			$this->options = $temp_options[$this->plugin_slug];
86 86
 		}
87 87
 
88
-		$destination_options = get_option( 'wetu_importer_destination_settings', false );
88
+		$destination_options = get_option('wetu_importer_destination_settings', false);
89 89
 
90
-		if ( false !== $destination_options ) {
90
+		if (false !== $destination_options) {
91 91
 			$this->destination_options = $destination_options;
92 92
 		}
93 93
 	}
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
 	public function display_page() {
99 99
 		?>
100 100
 		<div class="wrap">
101
-			<?php $this->navigation( 'destination' ); ?>
101
+			<?php $this->navigation('destination'); ?>
102 102
 
103 103
 			<?php $this->search_form(); ?>
104 104
 
105 105
 			<form method="get" action="" id="posts-filter">
106
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>"/>
106
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>"/>
107 107
 
108 108
 				<p><input class="button button-primary add" type="button"
109
-						  value="<?php esc_html_e( 'Add to List', 'wetu-importer' ); ?>"/>
109
+						  value="<?php esc_html_e('Add to List', 'wetu-importer'); ?>"/>
110 110
 					<input class="button button-primary clear" type="button"
111
-						   value="<?php esc_html_e( 'Clear', 'wetu-importer' ); ?>"/>
111
+						   value="<?php esc_html_e('Clear', 'wetu-importer'); ?>"/>
112 112
 				</p>
113 113
 
114 114
 				<table class="wp-list-table widefat fixed posts">
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
 					<tr class="post-0 type-tour status-none" id="post-0">
119 119
 						<th class="check-column" scope="row">
120 120
 							<label for="cb-select-0"
121
-								   class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter', 'wetu-importer' ); ?></label>
121
+								   class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'wetu-importer'); ?></label>
122 122
 						</th>
123 123
 						<td class="post-title page-title column-title">
124 124
 							<strong>
125
-								<?php esc_html_e( 'Enter a title to search for', 'wetu-importer' ); ?>
125
+								<?php esc_html_e('Enter a title to search for', 'wetu-importer'); ?>
126 126
 							</strong>
127 127
 						</td>
128 128
 						<td class="date column-date">
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
 				</table>
138 138
 
139 139
 				<p><input class="button button-primary add" type="button"
140
-						  value="<?php esc_html_e( 'Add to List', 'wetu-importer' ); ?>"/>
140
+						  value="<?php esc_html_e('Add to List', 'wetu-importer'); ?>"/>
141 141
 					<input class="button button-primary clear" type="button"
142
-						   value="<?php esc_html_e( 'Clear', 'wetu-importer' ); ?>"/>
142
+						   value="<?php esc_html_e('Clear', 'wetu-importer'); ?>"/>
143 143
 				</p>
144 144
 			</form>
145 145
 
@@ -149,109 +149,109 @@  discard block
 block discarded – undo
149 149
 
150 150
 					<div class="row">
151 151
 						<div class="settings-all" style="width:30%;display:block;float:left;">
152
-							<h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3>
152
+							<h3><?php esc_html_e('What content to Sync from WETU'); ?></h3>
153 153
 							<ul>
154 154
 								<li>
155
-									<input class="content select-all" <?php $this->checked( $this->destination_options, 'all' ); ?>
155
+									<input class="content select-all" <?php $this->checked($this->destination_options, 'all'); ?>
156 156
 										   type="checkbox" name="content[]"
157
-										   value="all"/> <?php esc_html_e( 'Select All', 'wetu-importer' ); ?></li>
158
-								<?php if ( isset( $this->options ) && 'on' !== $this->options['disable_destination_descriptions'] ) { ?>
157
+										   value="all"/> <?php esc_html_e('Select All', 'wetu-importer'); ?></li>
158
+								<?php if (isset($this->options) && 'on' !== $this->options['disable_destination_descriptions']) { ?>
159 159
 								<li>
160
-									<input class="content" <?php $this->checked( $this->destination_options, 'description' ); ?>
160
+									<input class="content" <?php $this->checked($this->destination_options, 'description'); ?>
161 161
 										   type="checkbox" name="content[]"
162
-										   value="description"/> <?php esc_html_e( 'Description', 'wetu-importer' ); ?></li>
162
+										   value="description"/> <?php esc_html_e('Description', 'wetu-importer'); ?></li>
163 163
 								<?php } ?>
164 164
 
165 165
 								<li>
166
-									<input class="content" <?php $this->checked( $this->destination_options, 'gallery' ); ?>
166
+									<input class="content" <?php $this->checked($this->destination_options, 'gallery'); ?>
167 167
 										   type="checkbox" name="content[]"
168
-										   value="gallery"/> <?php esc_html_e( 'Main Gallery', 'wetu-importer' ); ?></li>
169
-								<?php if ( class_exists( 'LSX_TO_Maps' ) ) { ?>
168
+										   value="gallery"/> <?php esc_html_e('Main Gallery', 'wetu-importer'); ?></li>
169
+								<?php if (class_exists('LSX_TO_Maps')) { ?>
170 170
 									<li>
171
-										<input class="content" <?php $this->checked( $this->destination_options, 'location' ); ?>
171
+										<input class="content" <?php $this->checked($this->destination_options, 'location'); ?>
172 172
 											   type="checkbox" name="content[]"
173
-											   value="location"/> <?php esc_html_e( 'Location', 'wetu-importer' ); ?></li>
173
+											   value="location"/> <?php esc_html_e('Location', 'wetu-importer'); ?></li>
174 174
 								<?php } ?>
175 175
 
176
-								<?php if ( class_exists( 'LSX_TO_Videos' ) ) { ?>
176
+								<?php if (class_exists('LSX_TO_Videos')) { ?>
177 177
 									<li>
178
-										<input class="content" <?php $this->checked( $this->destination_options, 'videos' ); ?>
178
+										<input class="content" <?php $this->checked($this->destination_options, 'videos'); ?>
179 179
 											   type="checkbox" name="content[]"
180
-											   value="videos"/> <?php esc_html_e( 'Videos', 'wetu-importer' ); ?></li>
180
+											   value="videos"/> <?php esc_html_e('Videos', 'wetu-importer'); ?></li>
181 181
 								<?php } ?>
182 182
 
183 183
 							</ul>
184
-							<h4><?php esc_html_e( 'Additional Content' ); ?></h4>
184
+							<h4><?php esc_html_e('Additional Content'); ?></h4>
185 185
 							<ul>
186 186
 								<li>
187
-									<input class="content" <?php $this->checked( $this->destination_options, 'continent' ); ?>
187
+									<input class="content" <?php $this->checked($this->destination_options, 'continent'); ?>
188 188
 										   type="checkbox" name="content[]"
189
-										   value="continent"/> <?php esc_html_e( 'Set Continent', 'wetu-importer' ); ?></li>
189
+										   value="continent"/> <?php esc_html_e('Set Continent', 'wetu-importer'); ?></li>
190 190
 
191 191
 								<li>
192
-									<input class="content" <?php $this->checked( $this->destination_options, 'featured_image' ); ?>
192
+									<input class="content" <?php $this->checked($this->destination_options, 'featured_image'); ?>
193 193
 										   type="checkbox" name="content[]"
194
-										   value="featured_image"/> <?php esc_html_e( 'Set Featured Image', 'wetu-importer' ); ?>
194
+										   value="featured_image"/> <?php esc_html_e('Set Featured Image', 'wetu-importer'); ?>
195 195
 								</li>
196
-								<?php if ( class_exists( 'LSX_Banners' ) ) { ?>
196
+								<?php if (class_exists('LSX_Banners')) { ?>
197 197
 									<li>
198
-										<input class="content" <?php $this->checked( $this->destination_options, 'banner_image' ); ?>
198
+										<input class="content" <?php $this->checked($this->destination_options, 'banner_image'); ?>
199 199
 											   type="checkbox" name="content[]"
200
-											   value="banner_image"/> <?php esc_html_e( 'Set Banner Image', 'wetu-importer' ); ?>
200
+											   value="banner_image"/> <?php esc_html_e('Set Banner Image', 'wetu-importer'); ?>
201 201
 									</li>
202 202
 								<?php } ?>
203 203
 
204 204
 								<li>
205
-									<input class="content" <?php $this->checked( $this->destination_options, 'strip_tags' ); ?>
205
+									<input class="content" <?php $this->checked($this->destination_options, 'strip_tags'); ?>
206 206
 										   type="checkbox" name="content[]"
207
-										   value="strip_tags"/> <?php esc_html_e( 'Strip HTML from the description', 'wetu-importer' ); ?></li>
207
+										   value="strip_tags"/> <?php esc_html_e('Strip HTML from the description', 'wetu-importer'); ?></li>
208 208
 							</ul>
209 209
 						</div>
210 210
 						<div class="settings-all" style="width:30%;display:block;float:left;">
211
-							<h3><?php esc_html_e( 'Travel Information' ); ?></h3>
211
+							<h3><?php esc_html_e('Travel Information'); ?></h3>
212 212
 							<ul>
213 213
 								<li>
214
-									<input class="content" <?php $this->checked( $this->destination_options, 'electricity' ); ?>
214
+									<input class="content" <?php $this->checked($this->destination_options, 'electricity'); ?>
215 215
 										   type="checkbox" name="content[]"
216
-										   value="electricity"/> <?php esc_html_e( 'Electricity', 'wetu-importer' ); ?></li>
216
+										   value="electricity"/> <?php esc_html_e('Electricity', 'wetu-importer'); ?></li>
217 217
 								<li>
218
-									<input class="content" <?php $this->checked( $this->destination_options, 'banking' ); ?>
218
+									<input class="content" <?php $this->checked($this->destination_options, 'banking'); ?>
219 219
 										   type="checkbox" name="content[]"
220
-										   value="banking"/> <?php esc_html_e( 'Banking', 'wetu-importer' ); ?></li>
220
+										   value="banking"/> <?php esc_html_e('Banking', 'wetu-importer'); ?></li>
221 221
 								<li>
222
-									<input class="content" <?php $this->checked( $this->destination_options, 'cuisine' ); ?>
222
+									<input class="content" <?php $this->checked($this->destination_options, 'cuisine'); ?>
223 223
 										   type="checkbox" name="content[]"
224
-										   value="cuisine"/> <?php esc_html_e( 'Cuisine', 'wetu-importer' ); ?></li>
224
+										   value="cuisine"/> <?php esc_html_e('Cuisine', 'wetu-importer'); ?></li>
225 225
 								<li>
226
-									<input class="content" <?php $this->checked( $this->destination_options, 'climate' ); ?>
226
+									<input class="content" <?php $this->checked($this->destination_options, 'climate'); ?>
227 227
 										   type="checkbox" name="content[]"
228
-										   value="climate"/> <?php esc_html_e( 'Climate', 'wetu-importer' ); ?></li>
228
+										   value="climate"/> <?php esc_html_e('Climate', 'wetu-importer'); ?></li>
229 229
 								<li>
230
-									<input class="content" <?php $this->checked( $this->destination_options, 'transport' ); ?>
230
+									<input class="content" <?php $this->checked($this->destination_options, 'transport'); ?>
231 231
 										   type="checkbox" name="content[]"
232
-										   value="transport"/> <?php esc_html_e( 'Transport', 'wetu-importer' ); ?></li>
233
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'dress' ); ?>
232
+										   value="transport"/> <?php esc_html_e('Transport', 'wetu-importer'); ?></li>
233
+								<li><input class="content" <?php $this->checked($this->destination_options, 'dress'); ?>
234 234
 										   type="checkbox" name="content[]"
235
-										   value="dress"/> <?php esc_html_e( 'Dress', 'wetu-importer' ); ?></li>
236
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'health' ); ?>
235
+										   value="dress"/> <?php esc_html_e('Dress', 'wetu-importer'); ?></li>
236
+								<li><input class="content" <?php $this->checked($this->destination_options, 'health'); ?>
237 237
 										   type="checkbox" name="content[]"
238
-										   value="health"/> <?php esc_html_e( 'Health', 'wetu-importer' ); ?></li>
239
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'safety' ); ?>
238
+										   value="health"/> <?php esc_html_e('Health', 'wetu-importer'); ?></li>
239
+								<li><input class="content" <?php $this->checked($this->destination_options, 'safety'); ?>
240 240
 										   type="checkbox" name="content[]"
241
-										   value="safety"/> <?php esc_html_e( 'Safety', 'wetu-importer' ); ?></li>
242
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'visa' ); ?>
241
+										   value="safety"/> <?php esc_html_e('Safety', 'wetu-importer'); ?></li>
242
+								<li><input class="content" <?php $this->checked($this->destination_options, 'visa'); ?>
243 243
 										   type="checkbox" name="content[]"
244
-										   value="visa"/> <?php esc_html_e( 'Visa', 'wetu-importer' ); ?></li>
245
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'additional_info' ); ?>
244
+										   value="visa"/> <?php esc_html_e('Visa', 'wetu-importer'); ?></li>
245
+								<li><input class="content" <?php $this->checked($this->destination_options, 'additional_info'); ?>
246 246
 										   type="checkbox" name="content[]"
247
-										   value="additional_info"/> <?php esc_html_e( 'General', 'wetu-importer' ); ?></li>
247
+										   value="additional_info"/> <?php esc_html_e('General', 'wetu-importer'); ?></li>
248 248
 							</ul>
249 249
 						</div>
250 250
 
251
-						<?php if ( class_exists( 'LSX_TO_Team' ) ) { ?>
251
+						<?php if (class_exists('LSX_TO_Team')) { ?>
252 252
 							<div style="width:30%;display:block;float:left;">
253
-								<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3>
254
-								<?php $this->team_member_checkboxes( $this->destination_options ); ?>
253
+								<h3><?php esc_html_e('Assign a Team Member'); ?></h3>
254
+								<?php $this->team_member_checkboxes($this->destination_options); ?>
255 255
 							</div>
256 256
 						<?php } ?>
257 257
 
@@ -259,9 +259,9 @@  discard block
 block discarded – undo
259 259
 					</div>
260 260
 
261 261
 
262
-					<h3><?php esc_html_e( 'Your List' ); ?></h3>
262
+					<h3><?php esc_html_e('Your List'); ?></h3>
263 263
 					<p><input class="button button-primary" type="submit"
264
-							  value="<?php esc_html_e( 'Sync', 'wetu-importer' ); ?>"/></p>
264
+							  value="<?php esc_html_e('Sync', 'wetu-importer'); ?>"/></p>
265 265
 					<table class="wp-list-table widefat fixed posts">
266 266
 						<?php $this->table_header(); ?>
267 267
 
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 					</table>
275 275
 
276 276
 					<p><input class="button button-primary" type="submit"
277
-							  value="<?php esc_html_e( 'Sync', 'wetu-importer' ); ?>"/></p>
277
+							  value="<?php esc_html_e('Sync', 'wetu-importer'); ?>"/></p>
278 278
 				</form>
279 279
 			</div>
280 280
 
281 281
 			<div style="display:none;" class="completed-list-wrapper">
282
-				<h3><?php esc_html_e( 'Completed' ); ?></h3>
282
+				<h3><?php esc_html_e('Completed'); ?></h3>
283 283
 				<ul>
284 284
 				</ul>
285 285
 			</div>
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	/**
291 291
 	 * Grab all the current destination posts via the lsx_wetu_id field.
292 292
 	 */
293
-	public function find_current_destination( $post_type = 'destination' ) {
293
+	public function find_current_destination($post_type = 'destination') {
294 294
 		global $wpdb;
295 295
 		$return = array();
296 296
 
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
 		");
310 310
 		// @codingStandardsIgnoreEnd
311 311
 
312
-		if ( null !== $current_destination && ! empty( $current_destination ) ) {
313
-			foreach ( $current_destination as $accom ) {
314
-				$return[ $accom->meta_value ] = $accom;
312
+		if (null !== $current_destination && !empty($current_destination)) {
313
+			foreach ($current_destination as $accom) {
314
+				$return[$accom->meta_value] = $accom;
315 315
 			}
316 316
 		}
317 317
 
@@ -325,96 +325,96 @@  discard block
 block discarded – undo
325 325
 		$return = false;
326 326
 
327 327
 		// @codingStandardsIgnoreLine
328
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_tour_importer' && isset( $_POST['type'] ) && $_POST['type'] === 'destination' ) {
329
-			$accommodation = get_transient( 'lsx_ti_accommodation' );
328
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'destination') {
329
+			$accommodation = get_transient('lsx_ti_accommodation');
330 330
 
331
-			if ( false === $accommodation ) {
331
+			if (false === $accommodation) {
332 332
 				$this->update_options();
333 333
 			}
334 334
 
335
-			if ( false !== $accommodation ) {
335
+			if (false !== $accommodation) {
336 336
 				$searched_items = false;
337 337
 
338 338
 				// @codingStandardsIgnoreLine
339
-				if ( isset( $_POST['keyword'] ) ) {
339
+				if (isset($_POST['keyword'])) {
340 340
 					// @codingStandardsIgnoreLine
341 341
 					$keyphrases = $_POST['keyword'];
342
-				} else {
343
-					$keyphrases = array( 0 );
342
+				}else {
343
+					$keyphrases = array(0);
344 344
 				}
345 345
 
346
-				if ( ! is_array( $keyphrases ) ) {
347
-					$keyphrases = array( $keyphrases );
346
+				if (!is_array($keyphrases)) {
347
+					$keyphrases = array($keyphrases);
348 348
 				}
349
-				foreach ( $keyphrases as &$keyword ) {
350
-					$keyword = ltrim( rtrim( $keyword ) );
349
+				foreach ($keyphrases as &$keyword) {
350
+					$keyword = ltrim(rtrim($keyword));
351 351
 				}
352 352
 
353 353
 				$post_status = false;
354 354
 
355
-				if ( in_array( 'publish',$keyphrases ) ) {
355
+				if (in_array('publish', $keyphrases)) {
356 356
 					$post_status = 'publish';
357 357
 				}
358
-				if ( in_array( 'pending',$keyphrases ) ) {
358
+				if (in_array('pending', $keyphrases)) {
359 359
 					$post_status = 'pending';
360 360
 				}
361
-				if ( in_array( 'draft',$keyphrases ) ) {
361
+				if (in_array('draft', $keyphrases)) {
362 362
 					$post_status = 'draft';
363 363
 				}
364
-				if ( in_array( 'import',$keyphrases ) ) {
364
+				if (in_array('import', $keyphrases)) {
365 365
 					$post_status = 'import';
366 366
 				}
367 367
 
368
-				if ( ! empty( $accommodation ) ) {
369
-					$current_accommodation = $this->find_current_accommodation( 'destination' );
368
+				if (!empty($accommodation)) {
369
+					$current_accommodation = $this->find_current_accommodation('destination');
370 370
 
371
-					foreach ( $accommodation as $row_key => $row ) {
371
+					foreach ($accommodation as $row_key => $row) {
372 372
 
373
-						if ( 'Destination' === trim( $row['type'] ) ) {
373
+						if ('Destination' === trim($row['type'])) {
374 374
 
375
-							print_r( $row );
375
+							print_r($row);
376 376
 
377 377
 							//If this is a current tour, add its ID to the row.
378 378
 							$row['post_id'] = 0;
379 379
 
380
-							if ( false !== $current_accommodation && array_key_exists( $row['id'], $current_accommodation ) ) {
381
-								$row['post_id'] = $current_accommodation[ $row['id'] ]->post_id;
380
+							if (false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)) {
381
+								$row['post_id'] = $current_accommodation[$row['id']]->post_id;
382 382
 							}
383 383
 
384 384
 							//If we are searching for
385
-							if ( false !== $post_status ) {
386
-								if ( 'import' === $post_status ) {
385
+							if (false !== $post_status) {
386
+								if ('import' === $post_status) {
387 387
 
388
-									if ( is_array( $this->queued_imports ) && in_array( $row['post_id'], $this->queued_imports ) ) {
389
-										$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
390
-									} else {
388
+									if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) {
389
+										$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
390
+									}else {
391 391
 										continue;
392 392
 									}
393
-								} else {
394
-									if ( 0 === $row['post_id'] ) {
393
+								}else {
394
+									if (0 === $row['post_id']) {
395 395
 										continue;
396
-									} else {
397
-										$current_status = get_post_status( $row['post_id'] );
396
+									}else {
397
+										$current_status = get_post_status($row['post_id']);
398 398
 
399
-										if ( $current_status !== $post_status ) {
399
+										if ($current_status !== $post_status) {
400 400
 											continue;
401 401
 										}
402 402
 									}
403 403
 
404
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
404
+									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
405 405
 								}
406
-							} else {
406
+							}else {
407 407
 								//Search through each keyword.
408
-								foreach ( $keyphrases as $keyphrase ) {
408
+								foreach ($keyphrases as $keyphrase) {
409 409
 									//Make sure the keyphrase is turned into an array
410
-									$keywords = explode( ' ', $keyphrase );
410
+									$keywords = explode(' ', $keyphrase);
411 411
 
412
-									if ( ! is_array( $keywords ) ) {
413
-										$keywords = array( $keywords );
412
+									if (!is_array($keywords)) {
413
+										$keywords = array($keywords);
414 414
 									}
415 415
 
416
-									if ( $this->multineedle_stripos( ltrim( rtrim( $row['name'] ) ), $keywords ) !== false ) {
417
-										$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
416
+									if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) {
417
+										$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
418 418
 									}
419 419
 								}
420 420
 							}
@@ -422,13 +422,13 @@  discard block
 block discarded – undo
422 422
 					}
423 423
 				}
424 424
 
425
-				if ( false !== $searched_items ) {
426
-					ksort( $searched_items );
427
-					$return = implode( $searched_items );
425
+				if (false !== $searched_items) {
426
+					ksort($searched_items);
427
+					$return = implode($searched_items);
428 428
 				}
429 429
 			}
430 430
 
431
-			print_r( $return );
431
+			print_r($return);
432 432
 		}
433 433
 
434 434
 		die();
@@ -437,28 +437,28 @@  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 ) {
441
-		if ( false !== $row ) {
440
+	public function format_row($row = false) {
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="post-title page-title column-title">
455
-					<strong>' . $row['name'] . '</strong> - ' . $status . '
455
+					<strong>' . $row['name'].'</strong> - '.$status.'
456 456
 				</td>
457 457
 				<td class="date column-date">
458
-					<abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified
458
+					<abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
459 459
 				</td>
460 460
 				<td class="ssid column-ssid">
461
-					' . $row['id'] . '
461
+					' . $row['id'].'
462 462
 				</td>
463 463
 			</tr>';
464 464
 			return $row_html;
@@ -472,54 +472,54 @@  discard block
 block discarded – undo
472 472
 		$return = false;
473 473
 
474 474
 		// @codingStandardsIgnoreLine
475
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === 'destination' && isset( $_POST['wetu_id'] ) ) {
475
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'destination' && isset($_POST['wetu_id'])) {
476 476
 			// @codingStandardsIgnoreLine
477 477
 			$wetu_id = $_POST['wetu_id'];
478 478
 
479 479
 			// @codingStandardsIgnoreLine
480
-			if ( isset( $_POST['post_id'] ) ) {
480
+			if (isset($_POST['post_id'])) {
481 481
 				// @codingStandardsIgnoreLine
482 482
 				$post_id = $_POST['post_id'];
483
-				$this->current_post = get_post( $post_id );
484
-			} else {
483
+				$this->current_post = get_post($post_id);
484
+			}else {
485 485
 				$post_id = 0;
486 486
 			}
487 487
 
488 488
 			// @codingStandardsIgnoreLine
489
-			if ( isset( $_POST['team_members'] ) ) {
489
+			if (isset($_POST['team_members'])) {
490 490
 				// @codingStandardsIgnoreLine
491 491
 				$team_members = $_POST['team_members'];
492
-			} else {
492
+			}else {
493 493
 				$team_members = false;
494 494
 			}
495 495
 
496 496
 			$safari_brands = false;
497 497
 
498
-			delete_option( 'wetu_importer_destination_settings' );
498
+			delete_option('wetu_importer_destination_settings');
499 499
 
500 500
 			// @codingStandardsIgnoreLine
501
-			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
501
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
502 502
 				// @codingStandardsIgnoreLine
503 503
 				$content = $_POST['content'];
504
-				add_option( 'wetu_importer_destination_settings', $content );
505
-			} else {
504
+				add_option('wetu_importer_destination_settings', $content);
505
+			}else {
506 506
 				$content = false;
507 507
 			}
508 508
 
509
-			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
509
+			$jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
510 510
 
511
-			if ( $jdata ) {
512
-				$adata = json_decode( $jdata, true );
511
+			if ($jdata) {
512
+				$adata = json_decode($jdata, true);
513 513
 
514
-				if ( ! empty( $adata ) && ! isset( $adata['error'] ) ) {
515
-					$return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands );
516
-					$this->remove_from_queue( $return );
517
-					$this->format_completed_row( $return );
518
-				} else {
519
-					if ( isset( $adata['error'] ) ) {
520
-						$this->format_error( $adata['error'] );
521
-					} else {
522
-						$this->format_error( esc_html__( 'There was a problem importing your destination, please try refreshing the page.','wetu-importer' ) );
514
+				if (!empty($adata) && !isset($adata['error'])) {
515
+					$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
516
+					$this->remove_from_queue($return);
517
+					$this->format_completed_row($return);
518
+				}else {
519
+					if (isset($adata['error'])) {
520
+						$this->format_error($adata['error']);
521
+					}else {
522
+						$this->format_error(esc_html__('There was a problem importing your destination, please try refreshing the page.', 'wetu-importer'));
523 523
 					}
524 524
 				}
525 525
 			}
@@ -529,14 +529,14 @@  discard block
 block discarded – undo
529 529
 	/**
530 530
 	 * Saves the queue to the option.
531 531
 	 */
532
-	public function remove_from_queue( $id ) {
533
-		if ( ! empty( $this->queued_imports ) ) {
532
+	public function remove_from_queue($id) {
533
+		if (!empty($this->queued_imports)) {
534 534
 			// @codingStandardsIgnoreLine
535
-			if ( ( $key = array_search( $id, $this->queued_imports ) ) !== false ) {
536
-				unset( $this->queued_imports[ $key ] );
535
+			if (($key = array_search($id, $this->queued_imports)) !== false) {
536
+				unset($this->queued_imports[$key]);
537 537
 
538
-				delete_option( 'wetu_importer_que' );
539
-				update_option( 'wetu_importer_que',$this->queued_imports );
538
+				delete_option('wetu_importer_que');
539
+				update_option('wetu_importer_que', $this->queued_imports);
540 540
 			}
541 541
 		}
542 542
 	}
@@ -544,8 +544,8 @@  discard block
 block discarded – undo
544 544
 	/**
545 545
 	 * Connect to wetu
546 546
 	 */
547
-	public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false ) {
548
-		if ( 'Destination' === trim( $data[0]['type'] ) ) {
547
+	public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false) {
548
+		if ('Destination' === trim($data[0]['type'])) {
549 549
 			$post_name = '';
550 550
 			$data_post_content = '';
551 551
 			$data_post_excerpt = '';
@@ -555,124 +555,124 @@  discard block
 block discarded – undo
555 555
 			);
556 556
 
557 557
 			//Set the post_content
558
-			if ( false !== $importable_content && in_array( 'description', $importable_content ) ) {
559
-				if ( isset( $data[0]['content']['general_description'] ) ) {
558
+			if (false !== $importable_content && in_array('description', $importable_content)) {
559
+				if (isset($data[0]['content']['general_description'])) {
560 560
 
561
-					if ( false !== $importable_content && in_array( 'strip_tags', $importable_content ) ) {
562
-						$post['post_content'] = wp_strip_all_tags( $data[0]['content']['general_description'] );
563
-					} else {
561
+					if (false !== $importable_content && in_array('strip_tags', $importable_content)) {
562
+						$post['post_content'] = wp_strip_all_tags($data[0]['content']['general_description']);
563
+					}else {
564 564
 						$post['post_content'] = $data[0]['content']['general_description'];
565 565
 					}
566 566
 				}
567 567
 			}
568 568
 
569
-			if ( false !== $id && '0' !== $id ) {
569
+			if (false !== $id && '0' !== $id) {
570 570
 				$post['ID'] = $id;
571 571
 
572
-				if ( isset( $data[0]['name'] ) ) {
572
+				if (isset($data[0]['name'])) {
573 573
 					$post['post_title'] = $data[0]['name'];
574 574
 					$post['post_status'] = 'publish';
575
-					$post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 );
575
+					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
576 576
 				}
577 577
 
578
-				$id = wp_update_post( $post );
579
-				$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
580
-				update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date );
581
-			} else {
578
+				$id = wp_update_post($post);
579
+				$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
580
+				update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
581
+			}else {
582 582
 				//Set the name
583
-				if ( isset( $data[0]['name'] ) ) {
584
-					$post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 );
583
+				if (isset($data[0]['name'])) {
584
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
585 585
 				}
586 586
 
587 587
 				$post['post_name'] = $post_name;
588 588
 				$post['post_title'] = $data[0]['name'];
589 589
 				$post['post_status'] = 'publish';
590
-				$id = wp_insert_post( $post );
590
+				$id = wp_insert_post($post);
591 591
 
592 592
 				//Save the WETU ID and the Last date it was modified.
593
-				if ( false !== $id ) {
594
-					add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
595
-					add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) );
593
+				if (false !== $id) {
594
+					add_post_meta($id, 'lsx_wetu_id', $wetu_id);
595
+					add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']));
596 596
 				}
597 597
 			}
598 598
 
599
-			$this->find_attachments( $id );
599
+			$this->find_attachments($id);
600 600
 
601 601
 			//Set the team member if it is there
602
-			if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) {
603
-				$this->set_team_member( $id, $team_members );
602
+			if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
603
+				$this->set_team_member($id, $team_members);
604 604
 			}
605 605
 
606
-			if ( class_exists( 'LSX_TO_Maps' ) ) {
607
-				$this->set_map_data( $data, $id, 9 );
606
+			if (class_exists('LSX_TO_Maps')) {
607
+				$this->set_map_data($data, $id, 9);
608 608
 			}
609 609
 
610 610
 			//Set the Room Data
611
-			if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) {
612
-				$this->set_video_data( $data, $id );
611
+			if (false !== $importable_content && in_array('videos', $importable_content)) {
612
+				$this->set_video_data($data, $id);
613 613
 			}
614 614
 
615 615
 			//Set the Electricity
616
-			if ( false !== $importable_content && in_array( 'electricity', $importable_content ) ) {
617
-				$this->set_travel_info( $data, $id, 'electricity' );
616
+			if (false !== $importable_content && in_array('electricity', $importable_content)) {
617
+				$this->set_travel_info($data, $id, 'electricity');
618 618
 			}
619 619
 			//Set the cuisine
620
-			if ( false !== $importable_content && in_array( 'cuisine', $importable_content ) ) {
621
-				$this->set_travel_info( $data, $id, 'cuisine' );
620
+			if (false !== $importable_content && in_array('cuisine', $importable_content)) {
621
+				$this->set_travel_info($data, $id, 'cuisine');
622 622
 			}
623 623
 			//Set the banking
624
-			if ( false !== $importable_content && in_array( 'banking', $importable_content ) ) {
625
-				$this->set_travel_info( $data, $id, 'banking' );
624
+			if (false !== $importable_content && in_array('banking', $importable_content)) {
625
+				$this->set_travel_info($data, $id, 'banking');
626 626
 			}
627 627
 			//Set the transport
628
-			if ( false !== $importable_content && in_array( 'transport', $importable_content ) ) {
629
-				$this->set_travel_info( $data, $id, 'transport' );
628
+			if (false !== $importable_content && in_array('transport', $importable_content)) {
629
+				$this->set_travel_info($data, $id, 'transport');
630 630
 			}
631 631
 			//Set the dress
632
-			if ( false !== $importable_content && in_array( 'dress', $importable_content ) ) {
633
-				$this->set_travel_info( $data, $id, 'dress' );
632
+			if (false !== $importable_content && in_array('dress', $importable_content)) {
633
+				$this->set_travel_info($data, $id, 'dress');
634 634
 			}
635 635
 			//Set the climate
636
-			if ( false !== $importable_content && in_array( 'climate', $importable_content ) ) {
637
-				$this->set_travel_info( $data, $id, 'climate' );
636
+			if (false !== $importable_content && in_array('climate', $importable_content)) {
637
+				$this->set_travel_info($data, $id, 'climate');
638 638
 			}
639 639
 			//Set the Health
640
-			if ( false !== $importable_content && in_array( 'health', $importable_content ) ) {
641
-				$this->set_travel_info( $data, $id, 'health' );
640
+			if (false !== $importable_content && in_array('health', $importable_content)) {
641
+				$this->set_travel_info($data, $id, 'health');
642 642
 			}
643 643
 			//Set the Safety
644
-			if ( false !== $importable_content && in_array( 'safety', $importable_content ) ) {
645
-				$this->set_travel_info( $data, $id, 'safety' );
644
+			if (false !== $importable_content && in_array('safety', $importable_content)) {
645
+				$this->set_travel_info($data, $id, 'safety');
646 646
 			}
647 647
 			//Set the Visa
648
-			if ( false !== $importable_content && in_array( 'visa', $importable_content ) ) {
649
-				$this->set_travel_info( $data, $id, 'visa' );
648
+			if (false !== $importable_content && in_array('visa', $importable_content)) {
649
+				$this->set_travel_info($data, $id, 'visa');
650 650
 			}
651 651
 			//Set the General
652
-			if ( false !== $importable_content && in_array( 'additional_info', $importable_content ) ) {
653
-				$this->set_travel_info( $data, $id, 'additional_info' );
652
+			if (false !== $importable_content && in_array('additional_info', $importable_content)) {
653
+				$this->set_travel_info($data, $id, 'additional_info');
654 654
 			}
655 655
 
656 656
 			//Setup some default for use in the import
657
-			if ( false !== $importable_content && (in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content )) ) {
658
-				$this->find_attachments( $id );
657
+			if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) {
658
+				$this->find_attachments($id);
659 659
 
660 660
 				//Set the featured image
661
-				if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
662
-					$this->set_featured_image( $data, $id );
661
+				if (false !== $importable_content && in_array('featured_image', $importable_content)) {
662
+					$this->set_featured_image($data, $id);
663 663
 				}
664
-				if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
665
-					$this->set_banner_image( $data, $id );
664
+				if (false !== $importable_content && in_array('banner_image', $importable_content)) {
665
+					$this->set_banner_image($data, $id);
666 666
 				}
667 667
 				//Import the main gallery
668
-				if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) {
669
-					$this->create_main_gallery( $data, $id );
668
+				if (false !== $importable_content && in_array('gallery', $importable_content)) {
669
+					$this->create_main_gallery($data, $id);
670 670
 				}
671 671
 			}
672 672
 
673 673
 			//Set the continent
674
-			if ( false !== $importable_content && in_array( 'continent', $importable_content ) ) {
675
-				$this->set_continent( $data, $id );
674
+			if (false !== $importable_content && in_array('continent', $importable_content)) {
675
+				$this->set_continent($data, $id);
676 676
 			}
677 677
 		}
678 678
 
@@ -682,44 +682,44 @@  discard block
 block discarded – undo
682 682
 	/**
683 683
 	 * Set the team memberon each item.
684 684
 	 */
685
-	public function set_team_member( $id, $team_members ) {
686
-		delete_post_meta( $id, 'team_to_' . $this->tab_slug );
685
+	public function set_team_member($id, $team_members) {
686
+		delete_post_meta($id, 'team_to_'.$this->tab_slug);
687 687
 
688
-		foreach ( $team_members as $team ) {
689
-			add_post_meta( $id, 'team_to_' . $this->tab_slug, $team );
688
+		foreach ($team_members as $team) {
689
+			add_post_meta($id, 'team_to_'.$this->tab_slug, $team);
690 690
 		}
691 691
 	}
692 692
 
693 693
 	/**
694 694
 	 * Saves the room data
695 695
 	 */
696
-	public function set_travel_info( $data, $id, $meta_key ) {
697
-		if ( ! empty( $data[0]['travel_information'] ) && isset( $data[0]['travel_information'][ $meta_key ] ) ) {
698
-			$content = $data[0]['travel_information'][ $meta_key ];
699
-			$this->save_custom_field( $content, $meta_key, $id );
696
+	public function set_travel_info($data, $id, $meta_key) {
697
+		if (!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])) {
698
+			$content = $data[0]['travel_information'][$meta_key];
699
+			$this->save_custom_field($content, $meta_key, $id);
700 700
 		}
701 701
 	}
702 702
 
703 703
 	/**
704 704
 	 * Set the Travel Style
705 705
 	 */
706
-	public function set_continent( $data, $id ) {
706
+	public function set_continent($data, $id) {
707 707
 
708
-		if ( isset( $data[0]['position']['country'] ) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id'] ) {
708
+		if (isset($data[0]['position']['country']) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id']) {
709 709
 			//get the continent code.
710
-			$continent_code = to_continent_label( to_continent_code( to_country_data( $data[0]['position']['country'], false ) ) );
710
+			$continent_code = to_continent_label(to_continent_code(to_country_data($data[0]['position']['country'], false)));
711 711
 
712
-			if ( '' !== $continent_code ) {
712
+			if ('' !== $continent_code) {
713 713
 				// @codingStandardsIgnoreLine
714
-				if ( ! $term = term_exists( trim( $continent_code ), 'continent' ) ) {
715
-					$term = wp_insert_term( trim( $continent_code ), 'continent' );
714
+				if (!$term = term_exists(trim($continent_code), 'continent')) {
715
+					$term = wp_insert_term(trim($continent_code), 'continent');
716 716
 
717
-					if ( is_wp_error( $term ) ) {
717
+					if (is_wp_error($term)) {
718 718
 						// @codingStandardsIgnoreLine
719 719
 						echo $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
 
@@ -730,11 +730,11 @@  discard block
 block discarded – undo
730 730
 	 * search_form
731 731
 	 */
732 732
 	public function update_options_form() {
733
-		echo '<div style="display:none;" class="wetu-status"><h3>' . esc_html__( 'Wetu Status', 'wetu-importer' ) . '</h3>';
733
+		echo '<div style="display:none;" class="wetu-status"><h3>'.esc_html__('Wetu Status', 'wetu-importer').'</h3>';
734 734
 
735
-		$accommodation = get_transient( 'lsx_ti_accommodation' );
735
+		$accommodation = get_transient('lsx_ti_accommodation');
736 736
 
737
-		if ( '' === $accommodation || false === $accommodation || isset( $_GET['refresh_accommodation'] ) ) {
737
+		if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) {
738 738
 			$this->update_options();
739 739
 		}
740 740
 
@@ -745,14 +745,14 @@  discard block
 block discarded – undo
745 745
 	 * Save the list of Accommodation into an option
746 746
 	 */
747 747
 	public function update_options() {
748
-		$data = file_get_contents( $this->url . '/List?' . $this->url_qs );
748
+		$data = file_get_contents($this->url.'/List?'.$this->url_qs);
749 749
 
750
-		$accommodation = json_decode( $data, true );
750
+		$accommodation = json_decode($data, true);
751 751
 
752
-		if ( isset( $accommodation['error'] ) ) {
752
+		if (isset($accommodation['error'])) {
753 753
 			return $accommodation['error'];
754
-		} elseif ( isset( $accommodation ) && ! empty( $accommodation ) ) {
755
-			set_transient( 'lsx_ti_accommodation',$accommodation,60 * 60 * 2 );
754
+		} elseif (isset($accommodation) && !empty($accommodation)) {
755
+			set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2);
756 756
 			return true;
757 757
 		}
758 758
 	}
Please login to merge, or discard this patch.