Passed
Push — master ( a92f6e...cb691f )
by Warwick
02:18
created
classes/class-wetu-importer-destination.php 1 patch
Spacing   +216 added lines, -216 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 = '';
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,86 +325,86 @@  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' ) {
328
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'destination') {
329 329
 
330 330
 			// @codingStandardsIgnoreLine
331
-			if ( isset( $_POST['keyword'] ) ) {
331
+			if (isset($_POST['keyword'])) {
332 332
 				$searched_items = false;
333 333
 
334 334
 				// @codingStandardsIgnoreLine
335
-				if ( isset( $_POST['keyword'] ) ) {
335
+				if (isset($_POST['keyword'])) {
336 336
 					// @codingStandardsIgnoreLine
337 337
 					$keyphrases = $_POST['keyword'];
338
-				} else {
339
-					$keyphrases = array( 0 );
338
+				}else {
339
+					$keyphrases = array(0);
340 340
 				}
341 341
 
342
-				if ( ! is_array( $keyphrases ) ) {
343
-					$keyphrases = array( $keyphrases );
342
+				if (!is_array($keyphrases)) {
343
+					$keyphrases = array($keyphrases);
344 344
 				}
345
-				foreach ( $keyphrases as &$keyword ) {
346
-					$keyword = ltrim( rtrim( $keyword ) );
345
+				foreach ($keyphrases as &$keyword) {
346
+					$keyword = ltrim(rtrim($keyword));
347 347
 				}
348 348
 
349 349
 				$post_status = false;
350
-				if ( in_array( 'publish', $keyphrases ) ) {
350
+				if (in_array('publish', $keyphrases)) {
351 351
 					$post_status = 'publish';
352 352
 				}
353
-				if ( in_array( 'pending', $keyphrases ) ) {
353
+				if (in_array('pending', $keyphrases)) {
354 354
 					$post_status = 'pending';
355 355
 				}
356
-				if ( in_array( 'draft', $keyphrases ) ) {
356
+				if (in_array('draft', $keyphrases)) {
357 357
 					$post_status = 'draft';
358 358
 				}
359
-				if ( in_array( 'import', $keyphrases ) ) {
359
+				if (in_array('import', $keyphrases)) {
360 360
 					$post_status = 'import';
361 361
 				}
362 362
 
363 363
 				$destination = $this->find_current_destination();
364 364
 
365
-				if ( ! empty( $destination ) ) {
365
+				if (!empty($destination)) {
366 366
 
367
-					foreach ( $destination as $row ) {
367
+					foreach ($destination as $row) {
368 368
 
369 369
 						//If we are searching for
370
-						if ( 'import' === $post_status ) {
371
-							if ( is_array( $this->queued_imports ) && in_array( $row->post_id,$this->queued_imports ) ) {
372
-								$searched_items[ sanitize_title( $row->name ) . '-' . $row->meta_value ] = $this->format_row( $row );
373
-							} else {
370
+						if ('import' === $post_status) {
371
+							if (is_array($this->queued_imports) && in_array($row->post_id, $this->queued_imports)) {
372
+								$searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
373
+							}else {
374 374
 								continue;
375 375
 							}
376
-						} else if ( false !== $post_status ) {
376
+						}else if (false !== $post_status) {
377 377
 
378
-							$current_status = get_post_status( $row->post_id );
379
-							if ( $current_status !== $post_status ) {
378
+							$current_status = get_post_status($row->post_id);
379
+							if ($current_status !== $post_status) {
380 380
 								continue;
381 381
 							}
382
-							$searched_items[ sanitize_title( $row->name ) . '-' . $row->meta_value ] = $this->format_row( $row );
382
+							$searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
383 383
 
384
-						} else {
384
+						}else {
385 385
 							//Search through each keyword.
386
-							foreach ( $keyphrases as $keyphrase ) {
386
+							foreach ($keyphrases as $keyphrase) {
387 387
 
388 388
 								//Make sure the keyphrase is turned into an array
389
-								$keywords = explode( ' ', $keyphrase );
390
-								if ( ! is_array( $keywords ) ) {
391
-									$keywords = array( $keywords );
389
+								$keywords = explode(' ', $keyphrase);
390
+								if (!is_array($keywords)) {
391
+									$keywords = array($keywords);
392 392
 								}
393 393
 
394
-								if ( $this->multineedle_stripos( ltrim( rtrim( $row->name ) ), $keywords ) !== false ) {
395
-									$searched_items[ sanitize_title( $row->name ) . '-' . $row->meta_value ] = $this->format_row( $row );
394
+								if ($this->multineedle_stripos(ltrim(rtrim($row->name)), $keywords) !== false) {
395
+									$searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row);
396 396
 								}
397 397
 							}
398 398
 						}
399 399
 					}
400 400
 				}
401 401
 
402
-				if ( false !== $searched_items ) {
403
-					ksort( $searched_items );
404
-					$return = implode( $searched_items );
402
+				if (false !== $searched_items) {
403
+					ksort($searched_items);
404
+					$return = implode($searched_items);
405 405
 				}
406 406
 			}
407
-			print_r( $return );
407
+			print_r($return);
408 408
 			die();
409 409
 		}
410 410
 	}
@@ -412,28 +412,28 @@  discard block
 block discarded – undo
412 412
 	/**
413 413
 	 * Formats the row for output on the screen.
414 414
 	 */
415
-	public function format_row( $row = false ) {
416
-		if ( false !== $row ) {
415
+	public function format_row($row = false) {
416
+		if (false !== $row) {
417 417
 
418 418
 			$status = 'import';
419
-			if ( 0 !== $row->post_id ) {
420
-				$status = '<a href="' . admin_url( '/post.php?post=' . $row->post_id . '&action=edit' ) . '" target="_blank">' . get_post_status( $row->post_id ) . '</a>';
419
+			if (0 !== $row->post_id) {
420
+				$status = '<a href="'.admin_url('/post.php?post='.$row->post_id.'&action=edit').'" target="_blank">'.get_post_status($row->post_id).'</a>';
421 421
 			}
422 422
 
423 423
 			$row_html = '
424
-			<tr class="post-' . $row->post_id . ' type-tour" id="post-' . $row->post_id . '">
424
+			<tr class="post-' . $row->post_id.' type-tour" id="post-'.$row->post_id.'">
425 425
 				<th class="check-column" scope="row">
426
-					<label for="cb-select-' . $row->meta_value . '" class="screen-reader-text">' . $row->name . '</label>
427
-					<input type="checkbox" data-identifier="' . $row->meta_value . '" value="' . $row->post_id . '" name="post[]" id="cb-select-' . $row->meta_value . '">
426
+					<label for="cb-select-' . $row->meta_value.'" class="screen-reader-text">'.$row->name.'</label>
427
+					<input type="checkbox" data-identifier="' . $row->meta_value.'" value="'.$row->post_id.'" name="post[]" id="cb-select-'.$row->meta_value.'">
428 428
 				</th>
429 429
 				<td class="post-title page-title column-title">
430
-					<strong>' . $row->name . '</strong> - ' . $status . '
430
+					<strong>' . $row->name.'</strong> - '.$status.'
431 431
 				</td>
432 432
 				<td class="date column-date">
433
-					<abbr title="' . date( 'Y/m/d', strtotime( $row->last_modified ) ) . '">' . date( 'Y/m/d', strtotime( $row->last_modified ) ) . '</abbr><br>Last Modified
433
+					<abbr title="' . date('Y/m/d', strtotime($row->last_modified)).'">'.date('Y/m/d', strtotime($row->last_modified)).'</abbr><br>Last Modified
434 434
 				</td>
435 435
 				<td class="ssid column-ssid">
436
-					' . $row->meta_value . '
436
+					' . $row->meta_value.'
437 437
 				</td>
438 438
 			</tr>';
439 439
 			return $row_html;
@@ -447,54 +447,54 @@  discard block
 block discarded – undo
447 447
 		$return = false;
448 448
 
449 449
 		// @codingStandardsIgnoreLine
450
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === 'destination' && isset( $_POST['wetu_id'] ) ) {
450
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'destination' && isset($_POST['wetu_id'])) {
451 451
 			// @codingStandardsIgnoreLine
452 452
 			$wetu_id = $_POST['wetu_id'];
453 453
 
454 454
 			// @codingStandardsIgnoreLine
455
-			if ( isset( $_POST['post_id'] ) ) {
455
+			if (isset($_POST['post_id'])) {
456 456
 				// @codingStandardsIgnoreLine
457 457
 				$post_id = $_POST['post_id'];
458
-				$this->current_post = get_post( $post_id );
459
-			} else {
458
+				$this->current_post = get_post($post_id);
459
+			}else {
460 460
 				$post_id = 0;
461 461
 			}
462 462
 
463 463
 			// @codingStandardsIgnoreLine
464
-			if ( isset( $_POST['team_members'] ) ) {
464
+			if (isset($_POST['team_members'])) {
465 465
 				// @codingStandardsIgnoreLine
466 466
 				$team_members = $_POST['team_members'];
467
-			} else {
467
+			}else {
468 468
 				$team_members = false;
469 469
 			}
470 470
 
471 471
 			$safari_brands = false;
472 472
 
473
-			delete_option( 'wetu_importer_destination_settings' );
473
+			delete_option('wetu_importer_destination_settings');
474 474
 
475 475
 			// @codingStandardsIgnoreLine
476
-			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
476
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
477 477
 				// @codingStandardsIgnoreLine
478 478
 				$content = $_POST['content'];
479
-				add_option( 'wetu_importer_destination_settings', $content );
480
-			} else {
479
+				add_option('wetu_importer_destination_settings', $content);
480
+			}else {
481 481
 				$content = false;
482 482
 			}
483 483
 
484
-			$jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
484
+			$jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
485 485
 
486
-			if ( $jdata ) {
487
-				$adata = json_decode( $jdata, true );
486
+			if ($jdata) {
487
+				$adata = json_decode($jdata, true);
488 488
 
489
-				if ( ! empty( $adata ) && ! isset( $adata['error'] ) ) {
490
-					$return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands );
491
-					$this->remove_from_queue( $return );
492
-					$this->format_completed_row( $return );
493
-				} else {
494
-					if ( isset( $adata['error'] ) ) {
495
-						$this->format_error( $adata['error'] );
496
-					} else {
497
-						$this->format_error( esc_html__( 'There was a problem importing your destination, please try refreshing the page.','wetu-importer' ) );
489
+				if (!empty($adata) && !isset($adata['error'])) {
490
+					$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
491
+					$this->remove_from_queue($return);
492
+					$this->format_completed_row($return);
493
+				}else {
494
+					if (isset($adata['error'])) {
495
+						$this->format_error($adata['error']);
496
+					}else {
497
+						$this->format_error(esc_html__('There was a problem importing your destination, please try refreshing the page.', 'wetu-importer'));
498 498
 					}
499 499
 				}
500 500
 			}
@@ -504,14 +504,14 @@  discard block
 block discarded – undo
504 504
 	/**
505 505
 	 * Saves the queue to the option.
506 506
 	 */
507
-	public function remove_from_queue( $id ) {
508
-		if ( ! empty( $this->queued_imports ) ) {
507
+	public function remove_from_queue($id) {
508
+		if (!empty($this->queued_imports)) {
509 509
 			// @codingStandardsIgnoreLine
510
-			if ( ( $key = array_search( $id, $this->queued_imports ) ) !== false ) {
511
-				unset( $this->queued_imports[ $key ] );
510
+			if (($key = array_search($id, $this->queued_imports)) !== false) {
511
+				unset($this->queued_imports[$key]);
512 512
 
513
-				delete_option( 'wetu_importer_que' );
514
-				update_option( 'wetu_importer_que',$this->queued_imports );
513
+				delete_option('wetu_importer_que');
514
+				update_option('wetu_importer_que', $this->queued_imports);
515 515
 			}
516 516
 		}
517 517
 	}
@@ -519,8 +519,8 @@  discard block
 block discarded – undo
519 519
 	/**
520 520
 	 * Connect to wetu
521 521
 	 */
522
-	public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false ) {
523
-		if ( 'Destination' === trim( $data[0]['type'] ) ) {
522
+	public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false) {
523
+		if ('Destination' === trim($data[0]['type'])) {
524 524
 			$post_name = '';
525 525
 			$data_post_content = '';
526 526
 			$data_post_excerpt = '';
@@ -530,124 +530,124 @@  discard block
 block discarded – undo
530 530
 			);
531 531
 
532 532
 			//Set the post_content
533
-			if ( false !== $importable_content && in_array( 'description', $importable_content ) ) {
534
-				if ( isset( $data[0]['content']['general_description'] ) ) {
533
+			if (false !== $importable_content && in_array('description', $importable_content)) {
534
+				if (isset($data[0]['content']['general_description'])) {
535 535
 
536
-					if ( false !== $importable_content && in_array( 'strip_tags', $importable_content ) ) {
537
-						$post['post_content'] = wp_strip_all_tags( $data[0]['content']['general_description'] );
538
-					} else {
536
+					if (false !== $importable_content && in_array('strip_tags', $importable_content)) {
537
+						$post['post_content'] = wp_strip_all_tags($data[0]['content']['general_description']);
538
+					}else {
539 539
 						$post['post_content'] = $data[0]['content']['general_description'];
540 540
 					}
541 541
 				}
542 542
 			}
543 543
 
544
-			if ( false !== $id && '0' !== $id ) {
544
+			if (false !== $id && '0' !== $id) {
545 545
 				$post['ID'] = $id;
546 546
 
547
-				if ( isset( $data[0]['name'] ) ) {
547
+				if (isset($data[0]['name'])) {
548 548
 					$post['post_title'] = $data[0]['name'];
549 549
 					$post['post_status'] = 'publish';
550
-					$post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 );
550
+					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
551 551
 				}
552 552
 
553
-				$id = wp_update_post( $post );
554
-				$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
555
-				update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date );
556
-			} else {
553
+				$id = wp_update_post($post);
554
+				$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
555
+				update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
556
+			}else {
557 557
 				//Set the name
558
-				if ( isset( $data[0]['name'] ) ) {
559
-					$post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 );
558
+				if (isset($data[0]['name'])) {
559
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
560 560
 				}
561 561
 
562 562
 				$post['post_name'] = $post_name;
563 563
 				$post['post_title'] = $data[0]['name'];
564 564
 				$post['post_status'] = 'publish';
565
-				$id = wp_insert_post( $post );
565
+				$id = wp_insert_post($post);
566 566
 
567 567
 				//Save the WETU ID and the Last date it was modified.
568
-				if ( false !== $id ) {
569
-					add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
570
-					add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) );
568
+				if (false !== $id) {
569
+					add_post_meta($id, 'lsx_wetu_id', $wetu_id);
570
+					add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']));
571 571
 				}
572 572
 			}
573 573
 
574
-			$this->find_attachments( $id );
574
+			$this->find_attachments($id);
575 575
 
576 576
 			//Set the team member if it is there
577
-			if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) {
578
-				$this->set_team_member( $id, $team_members );
577
+			if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
578
+				$this->set_team_member($id, $team_members);
579 579
 			}
580 580
 
581
-			if ( class_exists( 'LSX_TO_Maps' ) ) {
582
-				$this->set_map_data( $data, $id, 9 );
581
+			if (class_exists('LSX_TO_Maps')) {
582
+				$this->set_map_data($data, $id, 9);
583 583
 			}
584 584
 
585 585
 			//Set the Room Data
586
-			if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) {
587
-				$this->set_video_data( $data, $id );
586
+			if (false !== $importable_content && in_array('videos', $importable_content)) {
587
+				$this->set_video_data($data, $id);
588 588
 			}
589 589
 
590 590
 			//Set the Electricity
591
-			if ( false !== $importable_content && in_array( 'electricity', $importable_content ) ) {
592
-				$this->set_travel_info( $data, $id, 'electricity' );
591
+			if (false !== $importable_content && in_array('electricity', $importable_content)) {
592
+				$this->set_travel_info($data, $id, 'electricity');
593 593
 			}
594 594
 			//Set the cuisine
595
-			if ( false !== $importable_content && in_array( 'cuisine', $importable_content ) ) {
596
-				$this->set_travel_info( $data, $id, 'cuisine' );
595
+			if (false !== $importable_content && in_array('cuisine', $importable_content)) {
596
+				$this->set_travel_info($data, $id, 'cuisine');
597 597
 			}
598 598
 			//Set the banking
599
-			if ( false !== $importable_content && in_array( 'banking', $importable_content ) ) {
600
-				$this->set_travel_info( $data, $id, 'banking' );
599
+			if (false !== $importable_content && in_array('banking', $importable_content)) {
600
+				$this->set_travel_info($data, $id, 'banking');
601 601
 			}
602 602
 			//Set the transport
603
-			if ( false !== $importable_content && in_array( 'transport', $importable_content ) ) {
604
-				$this->set_travel_info( $data, $id, 'transport' );
603
+			if (false !== $importable_content && in_array('transport', $importable_content)) {
604
+				$this->set_travel_info($data, $id, 'transport');
605 605
 			}
606 606
 			//Set the dress
607
-			if ( false !== $importable_content && in_array( 'dress', $importable_content ) ) {
608
-				$this->set_travel_info( $data, $id, 'dress' );
607
+			if (false !== $importable_content && in_array('dress', $importable_content)) {
608
+				$this->set_travel_info($data, $id, 'dress');
609 609
 			}
610 610
 			//Set the climate
611
-			if ( false !== $importable_content && in_array( 'climate', $importable_content ) ) {
612
-				$this->set_travel_info( $data, $id, 'climate' );
611
+			if (false !== $importable_content && in_array('climate', $importable_content)) {
612
+				$this->set_travel_info($data, $id, 'climate');
613 613
 			}
614 614
 			//Set the Health
615
-			if ( false !== $importable_content && in_array( 'health', $importable_content ) ) {
616
-				$this->set_travel_info( $data, $id, 'health' );
615
+			if (false !== $importable_content && in_array('health', $importable_content)) {
616
+				$this->set_travel_info($data, $id, 'health');
617 617
 			}
618 618
 			//Set the Safety
619
-			if ( false !== $importable_content && in_array( 'safety', $importable_content ) ) {
620
-				$this->set_travel_info( $data, $id, 'safety' );
619
+			if (false !== $importable_content && in_array('safety', $importable_content)) {
620
+				$this->set_travel_info($data, $id, 'safety');
621 621
 			}
622 622
 			//Set the Visa
623
-			if ( false !== $importable_content && in_array( 'visa', $importable_content ) ) {
624
-				$this->set_travel_info( $data, $id, 'visa' );
623
+			if (false !== $importable_content && in_array('visa', $importable_content)) {
624
+				$this->set_travel_info($data, $id, 'visa');
625 625
 			}
626 626
 			//Set the General
627
-			if ( false !== $importable_content && in_array( 'additional_info', $importable_content ) ) {
628
-				$this->set_travel_info( $data, $id, 'additional_info' );
627
+			if (false !== $importable_content && in_array('additional_info', $importable_content)) {
628
+				$this->set_travel_info($data, $id, 'additional_info');
629 629
 			}
630 630
 
631 631
 			//Setup some default for use in the import
632
-			if ( false !== $importable_content && (in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content )) ) {
633
-				$this->find_attachments( $id );
632
+			if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) {
633
+				$this->find_attachments($id);
634 634
 
635 635
 				//Set the featured image
636
-				if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
637
-					$this->set_featured_image( $data, $id );
636
+				if (false !== $importable_content && in_array('featured_image', $importable_content)) {
637
+					$this->set_featured_image($data, $id);
638 638
 				}
639
-				if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
640
-					$this->set_banner_image( $data, $id );
639
+				if (false !== $importable_content && in_array('banner_image', $importable_content)) {
640
+					$this->set_banner_image($data, $id);
641 641
 				}
642 642
 				//Import the main gallery
643
-				if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) {
644
-					$this->create_main_gallery( $data, $id );
643
+				if (false !== $importable_content && in_array('gallery', $importable_content)) {
644
+					$this->create_main_gallery($data, $id);
645 645
 				}
646 646
 			}
647 647
 
648 648
 			//Set the continent
649
-			if ( false !== $importable_content && in_array( 'continent', $importable_content ) ) {
650
-				$this->set_continent( $data, $id );
649
+			if (false !== $importable_content && in_array('continent', $importable_content)) {
650
+				$this->set_continent($data, $id);
651 651
 			}
652 652
 		}
653 653
 
@@ -657,44 +657,44 @@  discard block
 block discarded – undo
657 657
 	/**
658 658
 	 * Set the team memberon each item.
659 659
 	 */
660
-	public function set_team_member( $id, $team_members ) {
661
-		delete_post_meta( $id, 'team_to_' . $this->tab_slug );
660
+	public function set_team_member($id, $team_members) {
661
+		delete_post_meta($id, 'team_to_'.$this->tab_slug);
662 662
 
663
-		foreach ( $team_members as $team ) {
664
-			add_post_meta( $id, 'team_to_' . $this->tab_slug, $team );
663
+		foreach ($team_members as $team) {
664
+			add_post_meta($id, 'team_to_'.$this->tab_slug, $team);
665 665
 		}
666 666
 	}
667 667
 
668 668
 	/**
669 669
 	 * Saves the room data
670 670
 	 */
671
-	public function set_travel_info( $data, $id, $meta_key ) {
672
-		if ( ! empty( $data[0]['travel_information'] ) && isset( $data[0]['travel_information'][ $meta_key ] ) ) {
673
-			$content = $data[0]['travel_information'][ $meta_key ];
674
-			$this->save_custom_field( $content, $meta_key, $id );
671
+	public function set_travel_info($data, $id, $meta_key) {
672
+		if (!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])) {
673
+			$content = $data[0]['travel_information'][$meta_key];
674
+			$this->save_custom_field($content, $meta_key, $id);
675 675
 		}
676 676
 	}
677 677
 
678 678
 	/**
679 679
 	 * Set the Travel Style
680 680
 	 */
681
-	public function set_continent( $data, $id ) {
681
+	public function set_continent($data, $id) {
682 682
 
683
-		if ( isset( $data[0]['position']['country'] ) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id'] ) {
683
+		if (isset($data[0]['position']['country']) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id']) {
684 684
 			//get the continent code.
685
-			$continent_code = to_continent_label( to_continent_code( to_country_data( $data[0]['position']['country'], false ) ) );
685
+			$continent_code = to_continent_label(to_continent_code(to_country_data($data[0]['position']['country'], false)));
686 686
 
687
-			if ( '' !== $continent_code ) {
687
+			if ('' !== $continent_code) {
688 688
 				// @codingStandardsIgnoreLine
689
-				if ( ! $term = term_exists( trim( $continent_code ), 'continent' ) ) {
690
-					$term = wp_insert_term( trim( $continent_code ), 'continent' );
689
+				if (!$term = term_exists(trim($continent_code), 'continent')) {
690
+					$term = wp_insert_term(trim($continent_code), 'continent');
691 691
 
692
-					if ( is_wp_error( $term ) ) {
692
+					if (is_wp_error($term)) {
693 693
 						// @codingStandardsIgnoreLine
694 694
 						echo $term->get_error_message();
695 695
 					}
696
-				} else {
697
-					wp_set_object_terms( $id, sanitize_title( $continent_code ), 'continent', true );
696
+				}else {
697
+					wp_set_object_terms($id, sanitize_title($continent_code), 'continent', true);
698 698
 				}
699 699
 			}
700 700
 
Please login to merge, or discard this patch.