Passed
Push — master ( 74af01...9724c5 )
by Warwick
01:57
created
classes/class-lsx-wetu-importer-tours.php 1 patch
Spacing   +401 added lines, -401 removed lines patch added patch discarded remove patch
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function set_variables() {
99 99
 		parent::set_variables();
100
-		if ( false !== $this->api_key ) {
101
-			$this->url    = 'https://wetu.com/API/Itinerary/' . $this->api_key;
100
+		if (false !== $this->api_key) {
101
+			$this->url    = 'https://wetu.com/API/Itinerary/'.$this->api_key;
102 102
 			$this->url_qs = '';
103 103
 		}
104
-		$tour_options = get_option( 'lsx_wetu_importer_tour_settings',false );
105
-		if ( false !== $tour_options ) {
104
+		$tour_options = get_option('lsx_wetu_importer_tour_settings', false);
105
+		if (false !== $tour_options) {
106 106
 			$this->tour_options = $tour_options;
107 107
 		}
108 108
 	}
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 			</div>
127 127
 
128 128
 			<form method="get" action="" id="posts-filter">
129
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
129
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" />
130 130
 
131 131
 				<table class="wp-list-table widefat fixed posts">
132 132
 					<?php $this->table_header(); ?>
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 						<tr class="post-0 type-tour status-none" id="post-0">
136 136
 							<td class="date column-date column-ref" colspan="5">
137 137
 								<strong>
138
-									<?php esc_html_e( 'Search for tours using the search form above','lsx-wetu-importer' ); ?>
138
+									<?php esc_html_e('Search for tours using the search form above', 'lsx-wetu-importer'); ?>
139 139
 								</strong>
140 140
 							</td>
141 141
 						</tr>
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 
146 146
 				</table>
147 147
 
148
-				<p><input class="button button-primary add" type="button" value="<?php esc_html_e( 'Add to List','lsx-wetu-importer' ); ?>" />
149
-					<input class="button button-primary clear" type="button" value="<?php esc_html_e( 'Clear','lsx-wetu-importer' ); ?>" />
148
+				<p><input class="button button-primary add" type="button" value="<?php esc_html_e('Add to List', 'lsx-wetu-importer'); ?>" />
149
+					<input class="button button-primary clear" type="button" value="<?php esc_html_e('Clear', 'lsx-wetu-importer'); ?>" />
150 150
 				</p>
151 151
 			</form>
152 152
 
@@ -156,52 +156,52 @@  discard block
 block discarded – undo
156 156
 
157 157
 					<div class="row">
158 158
 						<div class="settings-all" style="width:30%;display:block;float:left;">
159
-							<h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3>
159
+							<h3><?php esc_html_e('What content to Sync from WETU'); ?></h3>
160 160
 							<ul>
161
-								<li><input class="content select-all" <?php $this->checked( $this->tour_options, 'all' ); ?> type="checkbox"name="content[]"  value="all" /> <?php esc_html_e( 'Select All','lsx-wetu-importer' ); ?></li>
161
+								<li><input class="content select-all" <?php $this->checked($this->tour_options, 'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php esc_html_e('Select All', 'lsx-wetu-importer'); ?></li>
162 162
 
163
-								<?php if ( isset( $this->options ) && ! isset( $this->options['disable_tour_descriptions'] ) ) { ?>
164
-									<li><input class="content" <?php $this->checked( $this->tour_options, 'description' ); ?> type="checkbox" name="content[]" value="description" /> <?php esc_html_e( 'Description','lsx-wetu-importer' ); ?></li>
163
+								<?php if (isset($this->options) && !isset($this->options['disable_tour_descriptions'])) { ?>
164
+									<li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li>
165 165
 								<?php } ?>
166 166
 
167
-								<li><input class="content" <?php $this->checked( $this->tour_options, 'price' ); ?> type="checkbox" name="content[]" value="price" /> <?php esc_html_e( 'Price','lsx-wetu-importer' ); ?></li>
168
-								<li><input class="content" <?php $this->checked( $this->tour_options, 'duration' ); ?> type="checkbox" name="content[]" value="duration" /> <?php esc_html_e( 'Duration','lsx-wetu-importer' ); ?></li>
169
-								<li><input class="content" <?php $this->checked( $this->tour_options, 'group_size' ); ?> type="checkbox" name="content[]" value="group_size" /> <?php esc_html_e( 'Group Size','lsx-wetu-importer' ); ?></li>
170
-								<li><input class="content" <?php $this->checked( $this->tour_options, 'category' ); ?> type="checkbox" name="content[]" value="category" /> <?php esc_html_e( 'Category','lsx-wetu-importer' ); ?></li>
171
-								<?php if ( isset( $this->options ) && ! isset( $this->options['disable_tour_tags'] ) ) { ?>
172
-									<li><input class="content" <?php $this->checked( $this->tour_options, 'tags' ); ?> type="checkbox" name="content[]" value="tags" /> <?php esc_html_e( 'Tags','lsx-wetu-importer' ); ?></li>
167
+								<li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php esc_html_e('Price', 'lsx-wetu-importer'); ?></li>
168
+								<li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php esc_html_e('Duration', 'lsx-wetu-importer'); ?></li>
169
+								<li><input class="content" <?php $this->checked($this->tour_options, 'group_size'); ?> type="checkbox" name="content[]" value="group_size" /> <?php esc_html_e('Group Size', 'lsx-wetu-importer'); ?></li>
170
+								<li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php esc_html_e('Category', 'lsx-wetu-importer'); ?></li>
171
+								<?php if (isset($this->options) && !isset($this->options['disable_tour_tags'])) { ?>
172
+									<li><input class="content" <?php $this->checked($this->tour_options, 'tags'); ?> type="checkbox" name="content[]" value="tags" /> <?php esc_html_e('Tags', 'lsx-wetu-importer'); ?></li>
173 173
 								<?php } ?>
174
-								<li><input class="content" <?php $this->checked( $this->tour_options, 'itineraries' ); ?> type="checkbox" name="content[]" value="itineraries" /> <?php esc_html_e( 'Itinerary Days','lsx-wetu-importer' ); ?></li>
174
+								<li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php esc_html_e('Itinerary Days', 'lsx-wetu-importer'); ?></li>
175 175
 							</ul>
176 176
 						</div>
177 177
 						<div class="settings-all" style="width:30%;display:block;float:left;">
178
-							<h3><?php esc_html_e( 'Itinerary Info' ); ?></h3>
178
+							<h3><?php esc_html_e('Itinerary Info'); ?></h3>
179 179
 							<ul>
180
-								<li><input class="content" <?php $this->checked( $this->tour_options, 'itinerary_description' ); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php esc_html_e( 'Description','lsx-wetu-importer' ); ?></li>
181
-								<li><input class="content" <?php $this->checked( $this->tour_options, 'itinerary_included' ); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php esc_html_e( 'Included','lsx-wetu-importer' ); ?></li>
182
-								<li><input class="content" <?php $this->checked( $this->tour_options, 'itinerary_excluded' ); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php esc_html_e( 'Excluded','lsx-wetu-importer' ); ?></li>
180
+								<li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li>
181
+								<li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php esc_html_e('Included', 'lsx-wetu-importer'); ?></li>
182
+								<li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php esc_html_e('Excluded', 'lsx-wetu-importer'); ?></li>
183 183
 							</ul>
184 184
 
185
-							<h4><?php esc_html_e( 'Additional Content' ); ?></h4>
185
+							<h4><?php esc_html_e('Additional Content'); ?></h4>
186 186
 							<ul>
187
-								<li><input class="content" <?php $this->checked( $this->tour_options, 'accommodation' ); ?> type="checkbox" name="content[]" value="accommodation" /> <?php esc_html_e( 'Sync Accommodation','lsx-wetu-importer' ); ?></li>
188
-								<li><input class="content" <?php $this->checked( $this->tour_options, 'destination' ); ?> type="checkbox" name="content[]" value="destination" /> <?php esc_html_e( 'Sync Destinations','lsx-wetu-importer' ); ?></li>
189
-								<li><input class="content" <?php $this->checked( $this->tour_options, 'featured_image' ); ?> type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e( 'Featured Image','lsx-wetu-importer' ); ?></li>
190
-								<li><input class="content" <?php $this->checked( $this->tour_options, 'banner_image' ); ?> type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e( 'Banner Image','lsx-wetu-importer' ); ?></li>
187
+								<li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php esc_html_e('Sync Accommodation', 'lsx-wetu-importer'); ?></li>
188
+								<li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php esc_html_e('Sync Destinations', 'lsx-wetu-importer'); ?></li>
189
+								<li><input class="content" <?php $this->checked($this->tour_options, 'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e('Featured Image', 'lsx-wetu-importer'); ?></li>
190
+								<li><input class="content" <?php $this->checked($this->tour_options, 'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e('Banner Image', 'lsx-wetu-importer'); ?></li>
191 191
 							</ul>
192 192
 						</div>
193
-						<?php if ( class_exists( 'LSX_TO_Team' ) ) { ?>
193
+						<?php if (class_exists('LSX_TO_Team')) { ?>
194 194
 							<div style="width:30%;display:block;float:left;">
195
-								<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3>
196
-								<?php $this->team_member_checkboxes( $this->tour_options ); ?>
195
+								<h3><?php esc_html_e('Assign a Team Member'); ?></h3>
196
+								<?php $this->team_member_checkboxes($this->tour_options); ?>
197 197
 							</div>
198 198
 						<?php } ?>
199 199
 
200 200
 						<br clear="both" />
201 201
 					</div>
202 202
 
203
-					<h3><?php esc_html_e( 'Your List' ); ?></h3>
204
-					<p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>" /></p>
203
+					<h3><?php esc_html_e('Your List'); ?></h3>
204
+					<p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>" /></p>
205 205
 					<table class="wp-list-table widefat fixed posts">
206 206
 						<?php $this->table_header(); ?>
207 207
 
@@ -213,12 +213,12 @@  discard block
 block discarded – undo
213 213
 
214 214
 					</table>
215 215
 
216
-					<p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>" /></p>
216
+					<p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>" /></p>
217 217
 				</form>
218 218
 			</div>
219 219
 
220 220
 			<div style="display:none;" class="completed-list-wrapper">
221
-				<h3><?php esc_html_e( 'Completed', 'lsx-wetu-importer' ); ?> - <small><?php esc_html_e( 'Import your', 'lsx-wetu-importer' ); ?> <a href="<?php echo esc_attr( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->plugin_slug ); ?>&tab=accommodation"><?php esc_html_e( 'accommodation' ); ?></a> <?php esc_html_e( 'next','lsx-wetu-importer' ); ?></small></h3>
221
+				<h3><?php esc_html_e('Completed', 'lsx-wetu-importer'); ?> - <small><?php esc_html_e('Import your', 'lsx-wetu-importer'); ?> <a href="<?php echo esc_attr(admin_url('admin.php')); ?>?page=<?php echo esc_attr($this->plugin_slug); ?>&tab=accommodation"><?php esc_html_e('accommodation'); ?></a> <?php esc_html_e('next', 'lsx-wetu-importer'); ?></small></h3>
222 222
 				<ul>
223 223
 				</ul>
224 224
 			</div>
@@ -232,23 +232,23 @@  discard block
 block discarded – undo
232 232
 	 * @return void
233 233
 	 */
234 234
 	public function update_options_form() {
235
-		$form_options = get_option( 'lsx_ti_tours_api_options' );
236
-		if ( false === $form_options ) {
237
-			$form_options = array( 'sample' );
235
+		$form_options = get_option('lsx_ti_tours_api_options');
236
+		if (false === $form_options) {
237
+			$form_options = array('sample');
238 238
 		}
239 239
 		?>
240 240
 		<form method="get" class="tour-refresh-form">
241
-			<input type="hidden" name="page" value="<?php echo esc_attr( $this->plugin_slug ); ?>" />
241
+			<input type="hidden" name="page" value="<?php echo esc_attr($this->plugin_slug); ?>" />
242 242
 			<input type="hidden" name="tab" value="tour" />
243 243
 			<input type="hidden" name="refresh_tours" value="true" />
244 244
 			<input class="content" type="hidden" name="own" value="true" />
245 245
 
246 246
 			<select name="type">
247
-				<option <?php if ( in_array( 'allitineraries', $form_options ) ) { echo esc_attr( 'selected="selected"' ); } ?> value="allitineraries"><?php esc_html_e( 'All Itineraries','lsx-wetu-importer' ); ?></option>
248
-				<option <?php if ( in_array( 'sample', $form_options ) ) { echo esc_attr( 'selected="selected"' ); } ?>value="sample"><?php esc_html_e( 'Sample','lsx-wetu-importer' ); ?></option>
249
-				<option <?php if ( in_array( 'personal', $form_options ) ) { echo esc_attr( 'selected="selected"' ); } ?>value="personal"><?php esc_html_e( 'Personal','lsx-wetu-importer' ); ?></option>
247
+				<option <?php if (in_array('allitineraries', $form_options)) { echo esc_attr('selected="selected"'); } ?> value="allitineraries"><?php esc_html_e('All Itineraries', 'lsx-wetu-importer'); ?></option>
248
+				<option <?php if (in_array('sample', $form_options)) { echo esc_attr('selected="selected"'); } ?>value="sample"><?php esc_html_e('Sample', 'lsx-wetu-importer'); ?></option>
249
+				<option <?php if (in_array('personal', $form_options)) { echo esc_attr('selected="selected"'); } ?>value="personal"><?php esc_html_e('Personal', 'lsx-wetu-importer'); ?></option>
250 250
 			</select>
251
-			<input class="button submit" type="submit" value="<?php esc_attr_e( 'Refresh', 'lsx-wetu-importer' ); ?>" />
251
+			<input class="button submit" type="submit" value="<?php esc_attr_e('Refresh', 'lsx-wetu-importer'); ?>" />
252 252
 		</form>
253 253
 		<?php
254 254
 	}
@@ -273,9 +273,9 @@  discard block
 block discarded – undo
273 273
 			LIMIT 0,500
274 274
 		");
275 275
 
276
-		if ( null !== $current_tours && ! empty( $current_tours ) ) {
277
-			foreach ( $current_tours as $tour ) {
278
-				$return[ $tour->meta_value ] = $tour;
276
+		if (null !== $current_tours && !empty($current_tours)) {
277
+			foreach ($current_tours as $tour) {
278
+				$return[$tour->meta_value] = $tour;
279 279
 			}
280 280
 		}
281 281
 
@@ -287,45 +287,45 @@  discard block
 block discarded – undo
287 287
 	 */
288 288
 	public function process_ajax_search() {
289 289
 		$return = false;
290
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
290
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
291 291
 
292
-		if ( isset( $_POST['action'] ) && 'lsx_tour_importer' === $_POST['action'] && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug ) {
293
-			$tours = get_transient( 'lsx_ti_tours' );
292
+		if (isset($_POST['action']) && 'lsx_tour_importer' === $_POST['action'] && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) {
293
+			$tours = get_transient('lsx_ti_tours');
294 294
 
295
-			if ( false !== $tours ) {
295
+			if (false !== $tours) {
296 296
 				$searched_items = false;
297
-				if ( isset( $_POST['keyword'] ) ) {
298
-					$keyphrases = array_map( 'sanitize_text_field', wp_unslash( $_POST['keyword'] ) );
299
-				} else {
300
-					$keyphrases = array( 0 );
297
+				if (isset($_POST['keyword'])) {
298
+					$keyphrases = array_map('sanitize_text_field', wp_unslash($_POST['keyword']));
299
+				}else {
300
+					$keyphrases = array(0);
301 301
 				}
302 302
 
303
-				if ( ! is_array( $keyphrases ) ) {
304
-					$keyphrases = array( $keyphrases );
303
+				if (!is_array($keyphrases)) {
304
+					$keyphrases = array($keyphrases);
305 305
 				}
306
-				foreach ( $keyphrases as &$keyword ) {
307
-					$keyword = ltrim( rtrim( $keyword ) );
306
+				foreach ($keyphrases as &$keyword) {
307
+					$keyword = ltrim(rtrim($keyword));
308 308
 				}
309 309
 
310 310
 				$post_status = false;
311
-				if ( in_array( 'publish',$keyphrases ) ) {
311
+				if (in_array('publish', $keyphrases)) {
312 312
 					$post_status = 'publish';
313 313
 				}
314
-				if ( in_array( 'pending',$keyphrases ) ) {
314
+				if (in_array('pending', $keyphrases)) {
315 315
 					$post_status = 'pending';
316 316
 				}
317
-				if ( in_array( 'draft',$keyphrases ) ) {
317
+				if (in_array('draft', $keyphrases)) {
318 318
 					$post_status = 'draft';
319 319
 				}
320
-				if ( in_array( 'import',$keyphrases ) ) {
320
+				if (in_array('import', $keyphrases)) {
321 321
 					$post_status = 'import';
322 322
 				}
323 323
 
324
-				if ( ! empty( $tours ) ) {
324
+				if (!empty($tours)) {
325 325
 					$current_tours = $this->find_current_tours();
326 326
 
327
-					foreach ( $tours as $row_key => $row ) {
328
-						if ( isset( $row['is_disabled'] ) && true === $row['is_disabled'] ) {
327
+					foreach ($tours as $row_key => $row) {
328
+						if (isset($row['is_disabled']) && true === $row['is_disabled']) {
329 329
 							continue;
330 330
 						}
331 331
 
@@ -333,61 +333,61 @@  discard block
 block discarded – undo
333 333
 						$row['post_id'] = 0;
334 334
 						$row['post_title'] = $row['name'];
335 335
 
336
-						if ( false !== $current_tours && array_key_exists( $row['identifier'], $current_tours ) ) {
337
-							$row['post_id'] = $current_tours[ $row['identifier'] ]->post_id;
338
-							$row['post_title'] = $current_tours[ $row['identifier'] ]->post_title;
336
+						if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) {
337
+							$row['post_id'] = $current_tours[$row['identifier']]->post_id;
338
+							$row['post_title'] = $current_tours[$row['identifier']]->post_title;
339 339
 						}
340 340
 
341 341
 						// If we are searching for.
342
-						if ( false !== $post_status ) {
343
-							if ( 'import' === $post_status ) {
342
+						if (false !== $post_status) {
343
+							if ('import' === $post_status) {
344 344
 
345
-								if ( 0 !== $row['post_id'] ) {
345
+								if (0 !== $row['post_id']) {
346 346
 									continue;
347
-								} else {
348
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
347
+								}else {
348
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
349 349
 								}
350
-							} else {
351
-								if ( 0 === $row['post_id'] ) {
350
+							}else {
351
+								if (0 === $row['post_id']) {
352 352
 									continue;
353
-								} else {
354
-									$current_status = get_post_status( $row['post_id'] );
353
+								}else {
354
+									$current_status = get_post_status($row['post_id']);
355 355
 
356
-									if ( $current_status !== $post_status ) {
356
+									if ($current_status !== $post_status) {
357 357
 										continue;
358 358
 									}
359 359
 								}
360 360
 
361
-								$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
361
+								$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
362 362
 							}
363
-						} else {
363
+						}else {
364 364
 							// Search through each keyword.
365
-							foreach ( $keyphrases as $keyphrase ) {
365
+							foreach ($keyphrases as $keyphrase) {
366 366
 
367 367
 								// Make sure the keyphrase is turned into an array.
368
-								$keywords = explode( ' ',$keyphrase );
369
-								if ( ! is_array( $keywords ) ) {
370
-									$keywords = array( $keywords );
368
+								$keywords = explode(' ', $keyphrase);
369
+								if (!is_array($keywords)) {
370
+									$keywords = array($keywords);
371 371
 								}
372 372
 
373
-								if ( $this->multineedle_stripos( ltrim( rtrim( $row['name'] ) ), $keywords ) !== false ) {
374
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
375
-								} else if ( $this->multineedle_stripos( ltrim( rtrim( $row['reference_number'] ) ), $keywords ) !== false ) {
376
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
377
-								} else if ( $this->multineedle_stripos( ltrim( rtrim( $row['identifier_key'] ) ), $keywords ) !== false ) {
378
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
373
+								if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) {
374
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
375
+								}else if ($this->multineedle_stripos(ltrim(rtrim($row['reference_number'])), $keywords) !== false) {
376
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
377
+								}else if ($this->multineedle_stripos(ltrim(rtrim($row['identifier_key'])), $keywords) !== false) {
378
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
379 379
 								}
380 380
 							}
381 381
 						}
382 382
 					}
383 383
 				}
384 384
 
385
-				if ( false !== $searched_items ) {
386
-					ksort( $searched_items );
387
-					$return = implode( $searched_items );
385
+				if (false !== $searched_items) {
386
+					ksort($searched_items);
387
+					$return = implode($searched_items);
388 388
 				}
389 389
 			}
390
-			print_r( $return );
390
+			print_r($return);
391 391
 			die();
392 392
 		}
393 393
 	}
@@ -395,31 +395,31 @@  discard block
 block discarded – undo
395 395
 	/**
396 396
 	 * Formats the row for output on the screen.
397 397
 	 */
398
-	public function format_row( $row = false ) {
399
-		if ( false !== $row ) {
398
+	public function format_row($row = false) {
399
+		if (false !== $row) {
400 400
 			$status = 'import';
401 401
 
402
-			if ( 0 !== $row['post_id'] ) {
403
-				$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>';
402
+			if (0 !== $row['post_id']) {
403
+				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
404 404
 			}
405 405
 
406 406
 			$row_html = '
407
-			<tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '">
407
+			<tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'">
408 408
 				<th class="check-column" scope="row">
409
-					<label for="cb-select-' . $row['identifier'] . '" class="screen-reader-text">' . $row['post_title'] . '</label>
410
-					<input type="checkbox" data-identifier="' . $row['identifier'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['identifier'] . '">
409
+					<label for="cb-select-' . $row['identifier'].'" class="screen-reader-text">'.$row['post_title'].'</label>
410
+					<input type="checkbox" data-identifier="' . $row['identifier'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['identifier'].'">
411 411
 				</th>
412 412
 				<td class="post-title page-title column-title">
413
-					' . $row['post_title'] . ' - ' . $status . '
413
+					' . $row['post_title'].' - '.$status.'
414 414
 				</td>
415 415
 				<td class="date column-date">
416
-					' . $row['reference_number'] . '
416
+					' . $row['reference_number'].'
417 417
 				</td>				
418 418
 				<td class="date column-date">
419
-					<abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified
419
+					<abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
420 420
 				</td>
421 421
 				<td class="ssid column-ssid">
422
-					' . $row['identifier'] . '
422
+					' . $row['identifier'].'
423 423
 				</td>
424 424
 			</tr>';
425 425
 			return $row_html;
@@ -429,44 +429,44 @@  discard block
 block discarded – undo
429 429
 	/**
430 430
 	 * Connect to wetu
431 431
 	 */
432
-	public function process_ajax_import( $force = false ) {
432
+	public function process_ajax_import($force = false) {
433 433
 		$return = false;
434
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
435
-		if ( isset( $_POST['action'] ) && 'lsx_import_items' === $_POST['action'] && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug && isset( $_POST['wetu_id'] ) ) {
434
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
435
+		if (isset($_POST['action']) && 'lsx_import_items' === $_POST['action'] && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) {
436 436
 
437
-			$wetu_id = sanitize_text_field( $_POST['wetu_id'] );
438
-			if ( isset( $_POST['post_id'] ) ) {
439
-				$post_id = sanitize_text_field( $_POST['post_id'] );
440
-			} else {
437
+			$wetu_id = sanitize_text_field($_POST['wetu_id']);
438
+			if (isset($_POST['post_id'])) {
439
+				$post_id = sanitize_text_field($_POST['post_id']);
440
+			}else {
441 441
 				$post_id = 0;
442 442
 			}
443 443
 
444
-			delete_option( 'lsx_wetu_importer_tour_settings' );
444
+			delete_option('lsx_wetu_importer_tour_settings');
445 445
 
446
-			if ( isset( $_POST['team_members'] ) ) {
447
-				$team_members = array_map( 'sanitize_text_field', wp_unslash( $_POST['team_members'] ) );
448
-			} else {
446
+			if (isset($_POST['team_members'])) {
447
+				$team_members = array_map('sanitize_text_field', wp_unslash($_POST['team_members']));
448
+			}else {
449 449
 				$team_members = false;
450 450
 			}
451 451
 
452
-			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
453
-				$content = array_map( 'sanitize_text_field', wp_unslash( $_POST['content'] ) );
454
-				add_option( 'lsx_wetu_importer_tour_settings',$content );
455
-			} else {
452
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
453
+				$content = array_map('sanitize_text_field', wp_unslash($_POST['content']));
454
+				add_option('lsx_wetu_importer_tour_settings', $content);
455
+			}else {
456 456
 				$content = false;
457 457
 			}
458
-			$jdata = wp_remote_get( 'https://wetu.com/API/Itinerary/V8/Get?id=' . $wetu_id );
458
+			$jdata = wp_remote_get('https://wetu.com/API/Itinerary/V8/Get?id='.$wetu_id);
459 459
 
460
-			if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
461
-				$jdata = json_decode( $jdata['body'], true );
462
-				$return = $this->import_row( $jdata, $wetu_id, $post_id, $team_members, $content );
463
-				$this->format_completed_row( $return );
460
+			if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
461
+				$jdata = json_decode($jdata['body'], true);
462
+				$return = $this->import_row($jdata, $wetu_id, $post_id, $team_members, $content);
463
+				$this->format_completed_row($return);
464 464
 				$this->save_queue();
465 465
 				$this->cleanup_posts();
466
-				$this->attach_destination_images( $content );
467
-				$this->clean_attached_destinations( $return );
468
-			} else {
469
-				$this->format_error( esc_html__( 'There was a problem importing your tour, please contact support.', 'lsx-wetu-importer' ) );
466
+				$this->attach_destination_images($content);
467
+				$this->clean_attached_destinations($return);
468
+			}else {
469
+				$this->format_error(esc_html__('There was a problem importing your tour, please contact support.', 'lsx-wetu-importer'));
470 470
 			}
471 471
 		}
472 472
 	}
@@ -477,13 +477,13 @@  discard block
 block discarded – undo
477 477
 	 * @param $id string
478 478
 	 * @return void
479 479
 	 */
480
-	public function clean_attached_destinations( $id ) {
481
-		$current_connections = get_post_meta( $id, 'destination_to_tour', false );
482
-		delete_post_meta( $id,'destination_to_tour' );
483
-		$current_connections = array_unique( $current_connections );
480
+	public function clean_attached_destinations($id) {
481
+		$current_connections = get_post_meta($id, 'destination_to_tour', false);
482
+		delete_post_meta($id, 'destination_to_tour');
483
+		$current_connections = array_unique($current_connections);
484 484
 
485
-		foreach ( $current_connections as $connection ) {
486
-			add_post_meta( $id, 'destination_to_tour',$connection, false );
485
+		foreach ($current_connections as $connection) {
486
+			add_post_meta($id, 'destination_to_tour', $connection, false);
487 487
 		}
488 488
 	}
489 489
 
@@ -493,12 +493,12 @@  discard block
 block discarded – undo
493 493
 	 * @param $data array
494 494
 	 * @param $wetu_id string
495 495
 	 */
496
-	public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $old1 = false, $old2 = false ) {
496
+	public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $old1 = false, $old2 = false) {
497 497
 		$post_name = '';
498 498
 		$data_post_content = '';
499 499
 		$data_post_excerpt = '';
500 500
 
501
-		$current_post = get_post( $id );
501
+		$current_post = get_post($id);
502 502
 
503 503
 		$post = array(
504 504
 			'post_type' => 'tour',
@@ -506,72 +506,72 @@  discard block
 block discarded – undo
506 506
 
507 507
 		$content_used_general_description = false;
508 508
 
509
-		if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) {
509
+		if (!empty($importable_content) && in_array('description', $importable_content)) {
510 510
 			$data_post_content = $current_post->post_content;
511
-			if ( isset( $data['summary'] ) && ! empty( $data['summary'] ) ) {
511
+			if (isset($data['summary']) && !empty($data['summary'])) {
512 512
 				$data_post_content = $data['summary'];
513 513
 			}
514 514
 			$post['post_content'] = $data_post_content;
515 515
 		}
516 516
 
517 517
 		// Create or update the post.
518
-		if ( false !== $id && '0' !== $id ) {
518
+		if (false !== $id && '0' !== $id) {
519 519
 			$post['ID'] = $id;
520 520
 			$post['post_status'] = 'publish';
521
-			if ( isset( $this->options ) && 'on' !== $this->options['disable_accommodation_title'] ) {
521
+			if (isset($this->options) && 'on' !== $this->options['disable_accommodation_title']) {
522 522
 				$post['post_title'] = $data['name'];
523 523
 			}
524
-			$id = wp_update_post( $post );
525
-		} else {
524
+			$id = wp_update_post($post);
525
+		}else {
526 526
 			// Set the name.
527
-			if ( isset( $data['name'] ) ) {
528
-				$post_name = wp_unique_post_slug( sanitize_title( $data['name'] ), $id, 'draft', 'tour', 0 );
527
+			if (isset($data['name'])) {
528
+				$post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0);
529 529
 			}
530 530
 
531
-			if ( ! isset( $post['post_content'] ) ) {
531
+			if (!isset($post['post_content'])) {
532 532
 				$post['post_content'] = ' ';
533 533
 			}
534 534
 
535 535
 			$post['post_name']   = $post_name;
536 536
 			$post['post_title']  = $data['name'];
537 537
 			$post['post_status'] = 'publish';
538
-			$id = wp_insert_post( $post );
538
+			$id = wp_insert_post($post);
539 539
 		}
540 540
 
541 541
 		// Set reference number.
542
-		$this->set_reference_number( $data, $id );
542
+		$this->set_reference_number($data, $id);
543 543
 
544 544
 		// Set the team member if it is there.
545
-		if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) {
546
-			$this->set_team_member( $id, $team_members );
545
+		if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
546
+			$this->set_team_member($id, $team_members);
547 547
 		}
548 548
 
549 549
 		// Set the price.
550
-		if ( false !== $importable_content && in_array( 'price', $importable_content ) ) {
551
-			$this->set_price( $data, $id );
550
+		if (false !== $importable_content && in_array('price', $importable_content)) {
551
+			$this->set_price($data, $id);
552 552
 		}
553 553
 
554 554
 		// Set the Duration.
555
-		if ( false !== $importable_content && in_array( 'duration', $importable_content ) ) {
556
-			$this->set_duration( $data, $id );
555
+		if (false !== $importable_content && in_array('duration', $importable_content)) {
556
+			$this->set_duration($data, $id);
557 557
 		}
558 558
 
559 559
 		// Set the Group Size.
560
-		if ( false !== $importable_content && in_array( 'group_size', $importable_content ) ) {
561
-			$this->set_group_size( $data, $id );
560
+		if (false !== $importable_content && in_array('group_size', $importable_content)) {
561
+			$this->set_group_size($data, $id);
562 562
 		}
563 563
 
564 564
 		// Set the Group Size.
565
-		if ( false !== $importable_content && in_array( 'tags', $importable_content ) ) {
566
-			$this->set_travel_styles( $id, $data );
565
+		if (false !== $importable_content && in_array('tags', $importable_content)) {
566
+			$this->set_travel_styles($id, $data);
567 567
 		}
568 568
 
569
-		if ( false !== $importable_content && in_array( 'itineraries', $importable_content ) && isset( $data['legs'] ) && ! empty( $data['legs'] ) ) {
570
-			$this->process_itineraries( $data, $id, $importable_content );
569
+		if (false !== $importable_content && in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) {
570
+			$this->process_itineraries($data, $id, $importable_content);
571 571
 		}
572 572
 
573
-		if ( in_array( 'map', $importable_content ) && isset( $data['routes'] ) && ! empty( $data['routes'] ) ) {
574
-			$this->set_map_data( $data, $id );
573
+		if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) {
574
+			$this->set_map_data($data, $id);
575 575
 		}
576 576
 
577 577
 		return $id;
@@ -580,195 +580,195 @@  discard block
 block discarded – undo
580 580
 	/**
581 581
 	 * A loop which runs through each leg on the tour.
582 582
 	 */
583
-	public function process_itineraries( $data, $id, $importable_content ) {
583
+	public function process_itineraries($data, $id, $importable_content) {
584 584
 		$day_counter = 1;
585 585
 		$leg_counter = 0;
586 586
 
587
-		delete_post_meta( $id, 'itinerary' );
587
+		delete_post_meta($id, 'itinerary');
588 588
 
589
-		if ( false !== $importable_content && in_array( 'accommodation', $importable_content ) ) {
590
-			delete_post_meta( $id, 'accommodation_to_tour' );
589
+		if (false !== $importable_content && in_array('accommodation', $importable_content)) {
590
+			delete_post_meta($id, 'accommodation_to_tour');
591 591
 		}
592
-		if ( false !== $importable_content && in_array( 'destination', $importable_content ) ) {
593
-			delete_post_meta( $id, 'departs_from' );
594
-			delete_post_meta( $id, 'ends_in' );
592
+		if (false !== $importable_content && in_array('destination', $importable_content)) {
593
+			delete_post_meta($id, 'departs_from');
594
+			delete_post_meta($id, 'ends_in');
595 595
 		}
596 596
 
597 597
 		$departs_from = false;
598 598
 		$ends_in = false;
599 599
 
600
-		foreach ( $data['legs'] as $leg ) {
600
+		foreach ($data['legs'] as $leg) {
601 601
 			// Itinerary Accommodation.
602 602
 			$current_accommodation = false;
603
-			if ( false !== $importable_content && in_array( 'accommodation', $importable_content ) ) {
604
-				$current_accommodation = $this->set_accommodation( $leg, $id );
603
+			if (false !== $importable_content && in_array('accommodation', $importable_content)) {
604
+				$current_accommodation = $this->set_accommodation($leg, $id);
605 605
 			}
606 606
 
607 607
 			// Itinerary Destination.
608 608
 			$current_destination = false;
609
-			if ( false !== $importable_content && in_array( 'destination', $importable_content ) ) {
610
-				$current_destination = $this->set_destination( $leg, $id, $leg_counter );
609
+			if (false !== $importable_content && in_array('destination', $importable_content)) {
610
+				$current_destination = $this->set_destination($leg, $id, $leg_counter);
611 611
 			}
612 612
 
613 613
 			// If the Nights are the same mount of days in the array,  then it isnt "By Destination".
614
-			if ( ( ( 1 <= (int) $leg['nights'] && isset( $leg['periods'] ) ) ) || 0 === $leg['itinerary_leg_id'] ) {
615
-				foreach ( $leg['periods'] as $day ) {
614
+			if (((1 <= (int) $leg['nights'] && isset($leg['periods']))) || 0 === $leg['itinerary_leg_id']) {
615
+				foreach ($leg['periods'] as $day) {
616 616
 					$current_day = array();
617
-					$current_day['title'] = esc_attr( 'Day ', 'lsx-wetu-importer' ) . $day_counter;
617
+					$current_day['title'] = esc_attr('Day ', 'lsx-wetu-importer').$day_counter;
618 618
 
619 619
 					//print_r('<pre>');print_r($day['notes']);print_r('</pre>');
620 620
 
621 621
 					// Description.
622
-					if ( false !== $importable_content && in_array( 'itinerary_description', $importable_content ) && isset( $day['notes'] ) ) {
622
+					if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) {
623 623
 						$current_day['description'] = $day['notes'];
624
-					} else {
624
+					}else {
625 625
 						$current_day['description'] = '';
626 626
 					}
627 627
 
628 628
 					// Itinerary Gallery.
629
-					if ( false !== $importable_content && in_array( 'itinerary_gallery', $importable_content ) && isset( $day['images'] ) ) {
629
+					if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) {
630 630
 						$current_day['featured_image'] = '';
631
-					} else {
631
+					}else {
632 632
 						$current_day['featured_image'] = '';
633 633
 					}
634 634
 
635 635
 					// Accommodation.
636
-					if ( false !== $current_accommodation ) {
637
-						$current_day['accommodation_to_tour'] = array( $current_accommodation );
638
-					} else {
636
+					if (false !== $current_accommodation) {
637
+						$current_day['accommodation_to_tour'] = array($current_accommodation);
638
+					}else {
639 639
 						$current_day['accommodation_to_tour'] = array();
640 640
 					}
641 641
 
642 642
 					// Destination.
643
-					if ( false !== $current_destination ) {
644
-						$current_day['destination_to_tour'] = array( $current_destination );
645
-					} else {
643
+					if (false !== $current_destination) {
644
+						$current_day['destination_to_tour'] = array($current_destination);
645
+					}else {
646 646
 						$current_day['destination_to_tour'] = array();
647 647
 					}
648 648
 
649 649
 					// Included.
650
-					if ( false !== $importable_content && in_array( 'itinerary_included', $importable_content ) && isset( $day['included'] ) && '' !== $day['included'] ) {
650
+					if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) {
651 651
 						$current_day['included'] = $day['included'];
652
-					} else {
652
+					}else {
653 653
 						$current_day['included'] = '';
654 654
 					}
655 655
 
656 656
 					// Excluded.
657
-					if ( false !== $importable_content && in_array( 'itinerary_excluded', $importable_content ) && isset( $day['excluded'] ) && '' !== $day['excluded'] ) {
657
+					if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) {
658 658
 						$current_day['excluded'] = $day['excluded'];
659
-					} else {
659
+					}else {
660 660
 						$current_day['excluded'] = '';
661 661
 					}
662 662
 
663
-					$this->set_itinerary_day( $current_day,$id );
663
+					$this->set_itinerary_day($current_day, $id);
664 664
 					$day_counter++;
665 665
 				}
666
-			} else {
666
+			}else {
667 667
 				// This is for the by destination.
668 668
 
669 669
 				$current_day = array();
670 670
 				$next_day_count = $day_counter + (int) $leg['nights'];
671 671
 				$day_count_label = $next_day_count - 1;
672 672
 
673
-				$current_day['title'] = esc_attr( 'Day ', 'lsx-wetu-importer' ) . $day_counter;
673
+				$current_day['title'] = esc_attr('Day ', 'lsx-wetu-importer').$day_counter;
674 674
 
675
-				if ( 0 !== (int) $leg['nights'] ) {
676
-					$current_day['title'] .= ' - ' . $day_count_label;
675
+				if (0 !== (int) $leg['nights']) {
676
+					$current_day['title'] .= ' - '.$day_count_label;
677 677
 				}
678 678
 
679 679
 				// Description.
680
-				if ( false !== $importable_content && in_array( 'itinerary_description', $importable_content ) && isset( $leg['notes'] ) ) {
680
+				if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($leg['notes'])) {
681 681
 					$current_day['description'] = $leg['notes'];
682
-				} else {
682
+				}else {
683 683
 					$current_day['description'] = '';
684 684
 				}
685 685
 
686 686
 				// Itinerary Gallery.
687
-				if ( false !== $importable_content && in_array( 'itinerary_gallery', $importable_content ) && isset( $leg['images'] ) ) {
687
+				if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($leg['images'])) {
688 688
 					$current_day['featured_image'] = '';
689
-				} else {
689
+				}else {
690 690
 					$current_day['featured_image'] = '';
691 691
 				}
692 692
 
693 693
 				// Accommodation.
694
-				if ( false !== $current_accommodation ) {
695
-					$current_day['accommodation_to_tour'] = array( $current_accommodation );
696
-				} else {
694
+				if (false !== $current_accommodation) {
695
+					$current_day['accommodation_to_tour'] = array($current_accommodation);
696
+				}else {
697 697
 					$current_day['accommodation_to_tour'] = array();
698 698
 				}
699 699
 
700 700
 				// Destination.
701
-				if ( false !== $current_destination ) {
702
-					$current_day['destination_to_tour'] = array( $current_destination );
703
-				} else {
701
+				if (false !== $current_destination) {
702
+					$current_day['destination_to_tour'] = array($current_destination);
703
+				}else {
704 704
 					$current_day['destination_to_tour'] = array();
705 705
 				}
706 706
 
707 707
 				// Included.
708
-				if ( false !== $importable_content && in_array( 'itinerary_included', $importable_content ) && isset( $leg['included'] ) && '' !== $leg['included'] ) {
708
+				if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($leg['included']) && '' !== $leg['included']) {
709 709
 					$current_day['included'] = $leg['included'];
710
-				} else {
710
+				}else {
711 711
 					$current_day['included'] = '';
712 712
 				}
713 713
 
714 714
 				// Excluded.
715
-				if ( false !== $importable_content && in_array( 'itinerary_excluded', $importable_content ) && isset( $leg['excluded'] ) && '' !== $leg['excluded'] ) {
715
+				if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($leg['excluded']) && '' !== $leg['excluded']) {
716 716
 					$current_day['excluded'] = $leg['excluded'];
717
-				} else {
717
+				}else {
718 718
 					$current_day['excluded'] = '';
719 719
 				}
720 720
 
721
-				$this->set_itinerary_day( $current_day,$id );
721
+				$this->set_itinerary_day($current_day, $id);
722 722
 				$day_counter = $next_day_count;
723 723
 			}
724 724
 
725 725
 			// If we are in the first leg,  and the destination was attached then save it as the departure field.
726
-			if ( 0 === $leg_counter && false !== $current_destination ) {
726
+			if (0 === $leg_counter && false !== $current_destination) {
727 727
 				$departs_from = $current_destination;
728 728
 			}
729 729
 
730 730
 			// If its the last leg then save it as the ends in.
731
-			if ( ( count( $data['legs'] ) - 2 ) === $leg_counter && false !== $current_destination ) {
731
+			if ((count($data['legs']) - 2) === $leg_counter && false !== $current_destination) {
732 732
 				$ends_in = $current_destination;
733 733
 			}
734 734
 
735 735
 			$leg_counter++;
736 736
 		}
737 737
 
738
-		if ( false !== $departs_from ) {
739
-			add_post_meta( $id, 'departs_from', $departs_from, true );
738
+		if (false !== $departs_from) {
739
+			add_post_meta($id, 'departs_from', $departs_from, true);
740 740
 		}
741
-		if ( false !== $ends_in ) {
742
-			add_post_meta( $id, 'ends_in', $ends_in, true );
741
+		if (false !== $ends_in) {
742
+			add_post_meta($id, 'ends_in', $ends_in, true);
743 743
 		}
744 744
 	}
745 745
 
746 746
 	/**
747 747
 	 * Run through your routes and save the points as a KML file.
748 748
 	 */
749
-	public function set_map_data( $data, $id, $zoom = 9 ) {
750
-		if ( ! empty( $data['routes'] ) ) {
751
-			delete_post_meta( $id,'wetu_map_points' );
749
+	public function set_map_data($data, $id, $zoom = 9) {
750
+		if (!empty($data['routes'])) {
751
+			delete_post_meta($id, 'wetu_map_points');
752 752
 
753 753
 			$points = array();
754 754
 
755
-			foreach ( $data['routes'] as $route ) {
755
+			foreach ($data['routes'] as $route) {
756 756
 
757
-				if ( isset( $route['points'] ) && '' !== $route['points'] ) {
757
+				if (isset($route['points']) && '' !== $route['points']) {
758 758
 
759
-					$temp_points = explode( ';',$route['points'] );
760
-					$point_counter = count( $temp_points );
759
+					$temp_points = explode(';', $route['points']);
760
+					$point_counter = count($temp_points);
761 761
 
762
-					for ( $x = 0; $x <= $point_counter; $x++ ) {
762
+					for ($x = 0; $x <= $point_counter; $x++) {
763 763
 						$y = $x + 1;
764
-						$points[] = $temp_points[ $x ] . ',' . $temp_points[ $y ];
764
+						$points[] = $temp_points[$x].','.$temp_points[$y];
765 765
 						$x++;
766 766
 					}
767 767
 				}
768 768
 			}
769 769
 
770
-			if ( ! empty( $points ) ) {
771
-				$this->save_custom_field( implode( ' ',$points ),'wetu_map_points',$id,false,true );
770
+			if (!empty($points)) {
771
+				$this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true);
772 772
 			}
773 773
 		}
774 774
 
@@ -779,64 +779,64 @@  discard block
 block discarded – undo
779 779
 	/**
780 780
 	 * Set the Itinerary Day.
781 781
 	 */
782
-	public function set_itinerary_day( $day, $id ) {
783
-		$this->save_custom_field( $day, 'itinerary', $id, false, false );
782
+	public function set_itinerary_day($day, $id) {
783
+		$this->save_custom_field($day, 'itinerary', $id, false, false);
784 784
 	}
785 785
 
786 786
 	/**
787 787
 	 * Set the ref number
788 788
 	 */
789
-	public function set_reference_number( $data, $id ) {
790
-		if ( isset( $data['reference_number'] ) && '' !== $data['reference_number'] ) {
791
-			$this->save_custom_field( $data['reference_number'], 'lsx_wetu_ref', $id );
789
+	public function set_reference_number($data, $id) {
790
+		if (isset($data['reference_number']) && '' !== $data['reference_number']) {
791
+			$this->save_custom_field($data['reference_number'], 'lsx_wetu_ref', $id);
792 792
 		}
793 793
 	}
794 794
 
795 795
 	/**
796 796
 	 * Set the price.
797 797
 	 */
798
-	public function set_price( $data, $id ) {
798
+	public function set_price($data, $id) {
799 799
 		// Price.
800
-		if ( isset( $data['price'] ) && '' !== $data['price'] ) {
800
+		if (isset($data['price']) && '' !== $data['price']) {
801 801
 			$price = $data['price'];
802
-			if ( false === apply_filters( 'lsx_wetu_importer_disable_tour_price_filter', false ) ) {
803
-				$price = preg_replace( '/[^0-9,.]/', '', $price );
802
+			if (false === apply_filters('lsx_wetu_importer_disable_tour_price_filter', false)) {
803
+				$price = preg_replace('/[^0-9,.]/', '', $price);
804 804
 			}
805
-			$meta_key = apply_filters( 'lsx_wetu_importer_price_meta_key', 'price' );
806
-			$this->save_custom_field( $price, $meta_key, $id );
805
+			$meta_key = apply_filters('lsx_wetu_importer_price_meta_key', 'price');
806
+			$this->save_custom_field($price, $meta_key, $id);
807 807
 		}
808 808
 
809 809
 		// Price includes.
810
-		if ( isset( $data['price_includes'] ) && '' !== $data['price_includes'] ) {
811
-			$meta_key = apply_filters( 'lsx_wetu_importer_included_meta_key', 'included' );
812
-			$this->save_custom_field( $data['price_includes'], $meta_key, $id );
810
+		if (isset($data['price_includes']) && '' !== $data['price_includes']) {
811
+			$meta_key = apply_filters('lsx_wetu_importer_included_meta_key', 'included');
812
+			$this->save_custom_field($data['price_includes'], $meta_key, $id);
813 813
 		}
814 814
 
815 815
 		// Price Excludes.
816
-		if ( isset( $data['price_excludes'] ) && '' !== $data['price_excludes'] ) {
817
-			$meta_key = apply_filters( 'lsx_wetu_importer_not_included_meta_key', 'not_included' );
818
-			$this->save_custom_field( $data['price_excludes'], $meta_key, $id );
816
+		if (isset($data['price_excludes']) && '' !== $data['price_excludes']) {
817
+			$meta_key = apply_filters('lsx_wetu_importer_not_included_meta_key', 'not_included');
818
+			$this->save_custom_field($data['price_excludes'], $meta_key, $id);
819 819
 		}
820 820
 	}
821 821
 
822 822
 	/**
823 823
 	 * Set the duration.
824 824
 	 */
825
-	public function set_duration( $data, $id ) {
826
-		if ( isset( $data['days'] ) && ! empty( $data['days'] ) ) {
825
+	public function set_duration($data, $id) {
826
+		if (isset($data['days']) && !empty($data['days'])) {
827 827
 			$price = $data['days'];
828
-			$price = preg_replace( '/[^0-9,.]/', '', $price );
829
-			$this->save_custom_field( $price, 'duration', $id );
828
+			$price = preg_replace('/[^0-9,.]/', '', $price);
829
+			$this->save_custom_field($price, 'duration', $id);
830 830
 		}
831 831
 	}
832 832
 
833 833
 	/**
834 834
 	 * Set the group size
835 835
 	 */
836
-	public function set_group_size( $data, $id ) {
837
-		if ( isset( $data['group_size'] ) && ! empty( $data['group_size'] ) ) {
836
+	public function set_group_size($data, $id) {
837
+		if (isset($data['group_size']) && !empty($data['group_size'])) {
838 838
 			$group_size = $data['group_size'];
839
-			$this->save_custom_field( $group_size,'group_size',$id );
839
+			$this->save_custom_field($group_size, 'group_size', $id);
840 840
 		}
841 841
 	}
842 842
 
@@ -847,10 +847,10 @@  discard block
 block discarded – undo
847 847
 	 * @param array $travel_styles
848 848
 	 * @return void
849 849
 	 */
850
-	public function set_travel_styles( $id, $data ) {
851
-		if ( isset( $data['tags'] ) ) {
852
-			foreach ( $data['tags'] as $tag ) {
853
-				$this->set_term( $id, $tag, 'travel-style' );
850
+	public function set_travel_styles($id, $data) {
851
+		if (isset($data['tags'])) {
852
+			foreach ($data['tags'] as $tag) {
853
+				$this->set_term($id, $tag, 'travel-style');
854 854
 			}
855 855
 		}
856 856
 	}
@@ -858,27 +858,27 @@  discard block
 block discarded – undo
858 858
 	/**
859 859
 	 * Connects the Accommodation if its available
860 860
 	 */
861
-	public function set_accommodation( $day, $id ) {
861
+	public function set_accommodation($day, $id) {
862 862
 		$ac_id = false;
863 863
 		$this->current_accommodation = $this->find_current_accommodation();
864 864
 
865
-		if ( isset( $day['content_entity_id'] ) && ! empty( $day['content_entity_id'] ) ) {
866
-			if ( false !== $this->current_accommodation && ! empty( $this->current_accommodation ) && array_key_exists( $day['content_entity_id'],$this->current_accommodation ) ) {
867
-				$ac_id = $this->current_accommodation[ $day['content_entity_id'] ];
868
-			} else {
865
+		if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) {
866
+			if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) {
867
+				$ac_id = $this->current_accommodation[$day['content_entity_id']];
868
+			}else {
869 869
 				$ac_id = wp_insert_post(array(
870 870
 					'post_type' => 'accommodation',
871 871
 					'post_status' => 'draft',
872 872
 					'post_title' => $day['content_entity_id'],
873 873
 				));
874 874
 
875
-				$this->save_custom_field( $day['content_entity_id'],'lsx_wetu_id',$ac_id );
875
+				$this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id);
876 876
 			}
877 877
 
878
-			if ( '' !== $ac_id && false !== $ac_id ) {
879
-				$this->save_custom_field( $ac_id,'accommodation_to_tour',$id,false,false );
880
-				$this->save_custom_field( $id,'tour_to_accommodation',$ac_id,false,false );
881
-				$this->queue_item( $ac_id );
878
+			if ('' !== $ac_id && false !== $ac_id) {
879
+				$this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false);
880
+				$this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false);
881
+				$this->queue_item($ac_id);
882 882
 			}
883 883
 		}
884 884
 		return $ac_id;
@@ -890,14 +890,14 @@  discard block
 block discarded – undo
890 890
 	 * @param $post_type string
891 891
 	 * @return boolean / array
892 892
 	 */
893
-	public function find_current_accommodation( $post_type = 'accommodation' ) {
893
+	public function find_current_accommodation($post_type = 'accommodation') {
894 894
 		global $wpdb;
895
-		$accommodation = parent::find_current_accommodation( $post_type );
895
+		$accommodation = parent::find_current_accommodation($post_type);
896 896
 		$return = false;
897 897
 
898
-		if ( ! empty( $accommodation ) ) {
899
-			foreach ( $accommodation as $key => $acc ) {
900
-				$return[ $acc->meta_value ] = $acc->post_id;
898
+		if (!empty($accommodation)) {
899
+			foreach ($accommodation as $key => $acc) {
900
+				$return[$acc->meta_value] = $acc->post_id;
901 901
 			}
902 902
 		}
903 903
 
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 	 * @return boolean / array
910 910
 	 */
911 911
 	public function find_current_destinations() {
912
-		return $this->find_current_accommodation( 'destination' );
912
+		return $this->find_current_accommodation('destination');
913 913
 	}
914 914
 
915 915
 	/**
@@ -919,44 +919,44 @@  discard block
 block discarded – undo
919 919
 	 * @param $id string
920 920
 	 * @return boolean / string
921 921
 	 */
922
-	public function set_destination( $day, $id, $leg_counter ) {
922
+	public function set_destination($day, $id, $leg_counter) {
923 923
 		$dest_id    = false;
924 924
 		$country_id = false;
925 925
 
926 926
 		$this->current_destinations = $this->find_current_destinations();
927 927
 
928
-		if ( isset( $day['destination_content_entity_id'] ) && ! empty( $day['destination_content_entity_id'] ) ) {
929
-			if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $day['destination_content_entity_id'], $this->current_destinations ) ) {
930
-				$dest_id = $this->current_destinations[ $day['destination_content_entity_id'] ];
928
+		if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) {
929
+			if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) {
930
+				$dest_id = $this->current_destinations[$day['destination_content_entity_id']];
931 931
 
932 932
 				//TODO Check for attachments here.
933
-				$this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] );
933
+				$this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']);
934 934
 
935 935
 				//Check if there is a country asigned.
936
-				$potential_id = wp_get_post_parent_id( $dest_id );
937
-				$country_wetu_id = get_post_meta( $potential_id, 'lsx_wetu_id', true );
936
+				$potential_id = wp_get_post_parent_id($dest_id);
937
+				$country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true);
938 938
 
939
-				if ( false !== $country_wetu_id ) {
940
-					$country_id = $this->set_country( $country_wetu_id, $id );
939
+				if (false !== $country_wetu_id) {
940
+					$country_id = $this->set_country($country_wetu_id, $id);
941 941
 				}
942
-			} else {
943
-				$destination_json = wp_remote_get( 'https://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $day['destination_content_entity_id'] );
942
+			}else {
943
+				$destination_json = wp_remote_get('https://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$day['destination_content_entity_id']);
944 944
 
945
-				if ( ! empty( $destination_json ) && isset( $destination_json['response'] ) && isset( $destination_json['response']['code'] ) && 200 === $destination_json['response']['code'] ) {
945
+				if (!empty($destination_json) && isset($destination_json['response']) && isset($destination_json['response']['code']) && 200 === $destination_json['response']['code']) {
946 946
 
947
-					$destination_data = json_decode( $destination_json['body'], true );
947
+					$destination_data = json_decode($destination_json['body'], true);
948 948
 
949
-					if ( ! empty( $destination_data ) && ! isset( $destination_data['error'] ) ) {
949
+					if (!empty($destination_data) && !isset($destination_data['error'])) {
950 950
 						$destination_title = $day['destination_content_entity_id'];
951 951
 
952
-						if ( isset( $destination_data[0]['name'] ) ) {
952
+						if (isset($destination_data[0]['name'])) {
953 953
 							$destination_title = $destination_data[0]['name'];
954 954
 						}
955 955
 
956
-						if ( isset( $destination_data[0]['map_object_id'] ) && isset( $destination_data[0]['position']['country_content_entity_id'] )
957
-							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id'] ) {
956
+						if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
957
+							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) {
958 958
 
959
-							$country_id = $this->set_country( $destination_data[0]['position']['country_content_entity_id'], $id );
959
+							$country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id);
960 960
 							// Save the destination so we can grab the tour featured image and banner from them.
961 961
 						}
962 962
 
@@ -966,40 +966,40 @@  discard block
 block discarded – undo
966 966
 							'post_title' => $destination_title,
967 967
 						);
968 968
 
969
-						if ( false !== $country_id ) {
969
+						if (false !== $country_id) {
970 970
 							$dest_post['post_parent'] = $country_id;
971 971
 						}
972
-						$dest_id = wp_insert_post( $dest_post );
972
+						$dest_id = wp_insert_post($dest_post);
973 973
 
974 974
 						// Make sure we register the.
975
-						$this->current_destinations[ $day['destination_content_entity_id'] ] = $dest_id;
975
+						$this->current_destinations[$day['destination_content_entity_id']] = $dest_id;
976 976
 
977 977
 						// If there are images attached then use the destination.
978
-						if ( isset( $destination_data[0]['content']['images'] ) && ! empty( $destination_data[0]['content']['images'] ) ) {
979
-							$this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] );
978
+						if (isset($destination_data[0]['content']['images']) && !empty($destination_data[0]['content']['images'])) {
979
+							$this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']);
980 980
 						}
981 981
 
982
-						$this->save_custom_field( $day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id );
982
+						$this->save_custom_field($day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id);
983 983
 					}
984 984
 				}
985 985
 			}
986 986
 
987
-			if ( '' !== $dest_id && false !== $dest_id ) {
988
-				$this->save_custom_field( $dest_id, 'destination_to_tour', $id, false, false );
989
-				$this->save_custom_field( $id, 'tour_to_destination', $dest_id, false, false );
987
+			if ('' !== $dest_id && false !== $dest_id) {
988
+				$this->save_custom_field($dest_id, 'destination_to_tour', $id, false, false);
989
+				$this->save_custom_field($id, 'tour_to_destination', $dest_id, false, false);
990 990
 
991 991
 				//Save the item to display in the queue
992
-				$this->queue_item( $dest_id );
992
+				$this->queue_item($dest_id);
993 993
 
994 994
 				//Save the item to clean up the amount of connections.
995
-				$this->cleanup_posts[ $dest_id ] = 'tour_to_destination';
995
+				$this->cleanup_posts[$dest_id] = 'tour_to_destination';
996 996
 
997 997
 				//Add this relation info so we can make sure certain items are set as countries.
998
-				if ( 0 !== $country_id && false !== $country_id ) {
999
-					$this->relation_meta[ $dest_id ] = $country_id;
1000
-					$this->relation_meta[ $country_id ] = 0;
1001
-				} else {
1002
-					$this->relation_meta[ $dest_id ] = 0;
998
+				if (0 !== $country_id && false !== $country_id) {
999
+					$this->relation_meta[$dest_id] = $country_id;
1000
+					$this->relation_meta[$country_id] = 0;
1001
+				}else {
1002
+					$this->relation_meta[$dest_id] = 0;
1003 1003
 				}
1004 1004
 			}
1005 1005
 		}
@@ -1015,23 +1015,23 @@  discard block
 block discarded – undo
1015 1015
 	 *
1016 1016
 	 * @return string
1017 1017
 	 */
1018
-	public function set_country( $country_wetu_id, $id ) {
1018
+	public function set_country($country_wetu_id, $id) {
1019 1019
 		$country_id = false;
1020 1020
 		$this->current_destinations = $this->find_current_destinations();
1021 1021
 
1022
-		if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $country_wetu_id, $this->current_destinations ) ) {
1023
-			$country_id = $this->current_destinations[ $country_wetu_id ];
1024
-			$this->destination_images[ $id ][] = array( $country_id, $country_wetu_id );
1025
-		} else {
1026
-			$country_json = wp_remote_get( 'https://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $country_wetu_id );
1022
+		if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
1023
+			$country_id = $this->current_destinations[$country_wetu_id];
1024
+			$this->destination_images[$id][] = array($country_id, $country_wetu_id);
1025
+		}else {
1026
+			$country_json = wp_remote_get('https://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$country_wetu_id);
1027 1027
 
1028
-			if ( ! empty( $country_json ) && isset( $country_json['response'] ) && isset( $country_json['response']['code'] ) && 200 === $country_json['response']['code'] ) {
1029
-				$country_data = json_decode( $country_json['body'], true );
1028
+			if (!empty($country_json) && isset($country_json['response']) && isset($country_json['response']['code']) && 200 === $country_json['response']['code']) {
1029
+				$country_data = json_decode($country_json['body'], true);
1030 1030
 
1031 1031
 				// Format the title of the destination if its available,  otherwise default to the WETU ID.
1032 1032
 				$country_title = $country_wetu_id;
1033 1033
 
1034
-				if ( isset( $country_data[0]['name'] ) ) {
1034
+				if (isset($country_data[0]['name'])) {
1035 1035
 					$country_title = $country_data[0]['name'];
1036 1036
 				}
1037 1037
 
@@ -1042,23 +1042,23 @@  discard block
 block discarded – undo
1042 1042
 				));
1043 1043
 
1044 1044
 				//add the country to the current destination stack
1045
-				$this->current_destinations[ $country_wetu_id ] = $country_id;
1045
+				$this->current_destinations[$country_wetu_id] = $country_id;
1046 1046
 
1047 1047
 				// Check if there are images and save fore use later.
1048
-				if ( isset( $country_data[0]['content']['images'] ) && ! empty( $country_data[0]['content']['images'] ) ) {
1049
-					$this->destination_images[ $id ][] = array( $country_id,$country_wetu_id );
1048
+				if (isset($country_data[0]['content']['images']) && !empty($country_data[0]['content']['images'])) {
1049
+					$this->destination_images[$id][] = array($country_id, $country_wetu_id);
1050 1050
 				}
1051 1051
 
1052 1052
 				//Save the wetu field
1053
-				$this->save_custom_field( $country_wetu_id, 'lsx_wetu_id', $country_id );
1053
+				$this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
1054 1054
 			}
1055 1055
 		}
1056 1056
 
1057
-		if ( '' !== $country_id && false !== $country_id ) {
1058
-			$this->save_custom_field( $country_id, 'destination_to_tour', $id, false, false );
1059
-			$this->save_custom_field( $id, 'tour_to_destination', $country_id, false, false );
1060
-			$this->queue_item( $country_id );
1061
-			$this->cleanup_posts[ $country_id ] = 'tour_to_destination';
1057
+		if ('' !== $country_id && false !== $country_id) {
1058
+			$this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
1059
+			$this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
1060
+			$this->queue_item($country_id);
1061
+			$this->cleanup_posts[$country_id] = 'tour_to_destination';
1062 1062
 
1063 1063
 			return $country_id;
1064 1064
 		}
@@ -1073,44 +1073,44 @@  discard block
 block discarded – undo
1073 1073
 	 *
1074 1074
 	 * @return string
1075 1075
 	 */
1076
-	public function attach_destination_images( $importable_content = array() ) {
1077
-		if ( false !== $this->destination_images ) {
1078
-			$this->shuffle_assoc( $this->destination_images );
1076
+	public function attach_destination_images($importable_content = array()) {
1077
+		if (false !== $this->destination_images) {
1078
+			$this->shuffle_assoc($this->destination_images);
1079 1079
 
1080
-			foreach ( $this->destination_images as $tour => $destinations ) {
1080
+			foreach ($this->destination_images as $tour => $destinations) {
1081 1081
 				//$this->shuffle_assoc( $destinations );
1082 1082
 
1083 1083
 				$image_set = false;
1084 1084
 				$forced = false;
1085 1085
 
1086
-				foreach ( $destinations as $destination ) {
1087
-					if ( false === $image_set && false === $forced ) {
1088
-						$url = 'https://wetu.com/API/Pins/' . $this->api_key;
1086
+				foreach ($destinations as $destination) {
1087
+					if (false === $image_set && false === $forced) {
1088
+						$url = 'https://wetu.com/API/Pins/'.$this->api_key;
1089 1089
 						$url_qs = '';
1090 1090
 
1091
-						$jdata = wp_remote_get( $url . '/Get?' . $url_qs . '&ids=' . $destination[1] );
1091
+						$jdata = wp_remote_get($url.'/Get?'.$url_qs.'&ids='.$destination[1]);
1092 1092
 
1093
-						if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
1094
-							$adata = json_decode( $jdata['body'], true );
1093
+						if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
1094
+							$adata = json_decode($jdata['body'], true);
1095 1095
 
1096
-							if ( ! empty( $adata ) && ! empty( $adata[0]['content']['images'] ) ) {
1097
-								$this->find_attachments( $destination[0] );
1096
+							if (!empty($adata) && !empty($adata[0]['content']['images'])) {
1097
+								$this->find_attachments($destination[0]);
1098 1098
 
1099 1099
 								//Set the featured image
1100
-								if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
1101
-									$image_set = $this->set_featured_image( $adata, $tour );
1102
-									if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
1103
-										$image_set = $this->set_banner_image( $adata, $tour );
1100
+								if (false !== $importable_content && in_array('featured_image', $importable_content)) {
1101
+									$image_set = $this->set_featured_image($adata, $tour);
1102
+									if (false !== $importable_content && in_array('banner_image', $importable_content)) {
1103
+										$image_set = $this->set_banner_image($adata, $tour);
1104 1104
 										$forced = true;
1105 1105
 									}
1106 1106
 									continue;
1107 1107
 								}
1108
-								if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
1109
-									$image_set = $this->set_banner_image( $adata, $tour );
1108
+								if (false !== $importable_content && in_array('banner_image', $importable_content)) {
1109
+									$image_set = $this->set_banner_image($adata, $tour);
1110 1110
 								}
1111 1111
 							}
1112 1112
 						}
1113
-					} else {
1113
+					}else {
1114 1114
 						continue;
1115 1115
 					}
1116 1116
 				}
@@ -1121,28 +1121,28 @@  discard block
 block discarded – undo
1121 1121
 	/**
1122 1122
 	 * Creates the main gallery data
1123 1123
 	 */
1124
-	public function set_featured_image( $data, $id ) {
1124
+	public function set_featured_image($data, $id) {
1125 1125
 		$image_set = false;
1126 1126
 		$counter = 0;
1127 1127
 
1128
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
1129
-			foreach ( $data[0]['content']['images'] as $v ) {
1128
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
1129
+			foreach ($data[0]['content']['images'] as $v) {
1130 1130
 				/*print_r('<pre>');
1131 1131
 				print_r( $v );
1132 1132
 				print_r('</pre>');*/
1133 1133
 
1134
-				if ( true === $image_set ) {
1134
+				if (true === $image_set) {
1135 1135
 					$counter++;
1136 1136
 					continue;
1137 1137
 				}
1138 1138
 
1139
-				if ( ! $this->check_if_image_is_used( $v ) ) {
1140
-					$temp_featured_image = $this->attach_image( $v , $id );
1139
+				if (!$this->check_if_image_is_used($v)) {
1140
+					$temp_featured_image = $this->attach_image($v, $id);
1141 1141
 
1142
-					if ( false !== $temp_featured_image ) {
1142
+					if (false !== $temp_featured_image) {
1143 1143
 						$this->featured_image = $temp_featured_image;
1144
-						delete_post_meta( $id, '_thumbnail_id' );
1145
-						add_post_meta( $id, '_thumbnail_id', $this->featured_image, true );
1144
+						delete_post_meta($id, '_thumbnail_id');
1145
+						add_post_meta($id, '_thumbnail_id', $this->featured_image, true);
1146 1146
 						$image_set = true;
1147 1147
 					}
1148 1148
 				}
@@ -1156,40 +1156,40 @@  discard block
 block discarded – undo
1156 1156
 	/**
1157 1157
 	 * Sets a banner image
1158 1158
 	 */
1159
-	public function set_banner_image( $data, $id, $content = array( 'none' ) ) {
1159
+	public function set_banner_image($data, $id, $content = array('none')) {
1160 1160
 		$image_set = false;
1161 1161
 		$counter = 0;
1162 1162
 
1163
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
1163
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
1164 1164
 
1165
-			foreach ( $data[0]['content']['images'] as $v ) {
1165
+			foreach ($data[0]['content']['images'] as $v) {
1166 1166
 				/*print_r('<pre>');
1167 1167
 				print_r( $v );
1168 1168
 				print_r('</pre>');*/
1169 1169
 
1170
-				if ( true === $image_set || 0 === $counter ) {
1170
+				if (true === $image_set || 0 === $counter) {
1171 1171
 					$counter++;
1172 1172
 					continue;
1173 1173
 				}
1174 1174
 
1175
-				if ( ! $this->check_if_image_is_used( $v ) ) {
1176
-					$temp_banner = $this->attach_image( $v, $id, array(
1175
+				if (!$this->check_if_image_is_used($v)) {
1176
+					$temp_banner = $this->attach_image($v, $id, array(
1177 1177
 						'width' => '1920',
1178 1178
 						'height' => '600',
1179 1179
 						'cropping' => 'c',
1180
-					) );
1180
+					));
1181 1181
 
1182
-					if ( false !== $temp_banner ) {
1182
+					if (false !== $temp_banner) {
1183 1183
 						$this->banner_image = $temp_banner;
1184 1184
 
1185
-						delete_post_meta( $id,'image_group' );
1185
+						delete_post_meta($id, 'image_group');
1186 1186
 
1187 1187
 						$new_banner = array(
1188 1188
 							'banner_image' => array(
1189 1189
 								'cmb-field-0' => $this->banner_image,
1190 1190
 							),
1191 1191
 						);
1192
-						add_post_meta( $id,'image_group',$new_banner,true );
1192
+						add_post_meta($id, 'image_group', $new_banner, true);
1193 1193
 						$image_set = true;
1194 1194
 					}
1195 1195
 				}
@@ -1203,36 +1203,36 @@  discard block
 block discarded – undo
1203 1203
 	/**
1204 1204
 	 * Grabs all of the current used featured images on the site.
1205 1205
 	 */
1206
-	public function check_if_image_is_used( $v ) {
1206
+	public function check_if_image_is_used($v) {
1207 1207
 		global $wpdb;
1208 1208
 
1209
-		$temp_fragment = explode( '/', $v['url_fragment'] );
1210
-		$url_filename = $temp_fragment[ count( $temp_fragment ) - 1 ];
1211
-		$url_filename = str_replace( array( '.jpg', '.png', '.jpeg' ), '', $url_filename );
1212
-		$url_filename = trim( $url_filename );
1213
-		$url_filename = str_replace( ' ', '_', $url_filename );
1209
+		$temp_fragment = explode('/', $v['url_fragment']);
1210
+		$url_filename = $temp_fragment[count($temp_fragment) - 1];
1211
+		$url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename);
1212
+		$url_filename = trim($url_filename);
1213
+		$url_filename = str_replace(' ', '_', $url_filename);
1214 1214
 
1215
-		if ( in_array( $url_filename, $this->found_attachments ) ) {
1215
+		if (in_array($url_filename, $this->found_attachments)) {
1216 1216
 			// check to see if there is a featured image set with this ID.
1217
-			$found_id = array_search( $url_filename, $this->found_attachments );
1217
+			$found_id = array_search($url_filename, $this->found_attachments);
1218 1218
 
1219
-			$results = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value = '%s' AND meta_key = '_thumbnail_id'", array( $found_id ) ) );
1220
-			if ( ! empty( $results ) ) {
1219
+			$results = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value = '%s' AND meta_key = '_thumbnail_id'", array($found_id)));
1220
+			if (!empty($results)) {
1221 1221
 				return true;
1222
-			} else {
1222
+			}else {
1223 1223
 				return false;
1224 1224
 			}
1225
-		} else {
1226
-			$results = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = '%s'", array( $url_filename ) ) );
1225
+		}else {
1226
+			$results = $wpdb->get_results($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_name = '%s'", array($url_filename)));
1227 1227
 
1228
-			if ( ! empty( $results ) ) {
1229
-				$results = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value = '%s' AND meta_key = '_thumbnail_id'", array( $results[0]->ID ) ) );
1230
-				if ( ! empty( $results ) ) {
1228
+			if (!empty($results)) {
1229
+				$results = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value = '%s' AND meta_key = '_thumbnail_id'", array($results[0]->ID)));
1230
+				if (!empty($results)) {
1231 1231
 					return true;
1232
-				} else {
1232
+				}else {
1233 1233
 					return false;
1234 1234
 				}
1235
-			} else {
1235
+			}else {
1236 1236
 				return false;
1237 1237
 			}
1238 1238
 		}
@@ -1243,10 +1243,10 @@  discard block
 block discarded – undo
1243 1243
 	 *
1244 1244
 	 * @param   $id     int
1245 1245
 	 */
1246
-	public function queue_item( $id ) {
1247
-		if ( is_array( $this->import_queue ) && ! in_array( $id, $this->import_queue ) ) {
1246
+	public function queue_item($id) {
1247
+		if (is_array($this->import_queue) && !in_array($id, $this->import_queue)) {
1248 1248
 			$this->import_queue[] = $id;
1249
-		} else {
1249
+		}else {
1250 1250
 			$this->import_queue[] = $id;
1251 1251
 		}
1252 1252
 	}
@@ -1255,18 +1255,18 @@  discard block
 block discarded – undo
1255 1255
 	 * Saves the queue to the option.
1256 1256
 	 */
1257 1257
 	public function save_queue() {
1258
-		if ( ! empty( $this->import_queue ) ) {
1259
-			if ( ! empty( $this->queued_imports ) ) {
1260
-				$saved_imports = array_merge( $this->queued_imports, $this->import_queue );
1261
-			} else {
1258
+		if (!empty($this->import_queue)) {
1259
+			if (!empty($this->queued_imports)) {
1260
+				$saved_imports = array_merge($this->queued_imports, $this->import_queue);
1261
+			}else {
1262 1262
 				$saved_imports = $this->import_queue;
1263 1263
 			}
1264 1264
 
1265
-			delete_option( 'lsx_wetu_importer_que' );
1265
+			delete_option('lsx_wetu_importer_que');
1266 1266
 
1267
-			if ( ! empty( $saved_imports ) ) {
1268
-				$saved_imports = array_unique( $saved_imports );
1269
-				update_option( 'lsx_wetu_importer_que', $saved_imports );
1267
+			if (!empty($saved_imports)) {
1268
+				$saved_imports = array_unique($saved_imports);
1269
+				update_option('lsx_wetu_importer_que', $saved_imports);
1270 1270
 			}
1271 1271
 		}
1272 1272
 	}
@@ -1279,13 +1279,13 @@  discard block
 block discarded – undo
1279 1279
 		<thead>
1280 1280
 		<tr>
1281 1281
 			<th style="" class="manage-column column-cb check-column no-sort" id="cb" scope="col">
1282
-				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'lsx-wetu-importer' ); ?></label>
1282
+				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'lsx-wetu-importer'); ?></label>
1283 1283
 				<input type="checkbox" id="cb-select-all-1">
1284 1284
 			</th>
1285
-			<th style="" class="manage-column column-title " id="title" scope="col"><?php esc_attr_e( 'Title', 'lsx-wetu-importer' ); ?></th>
1286
-			<th style="" class="manage-column column-date" id="ref" scope="col"><?php esc_attr_e( 'Ref', 'lsx-wetu-importer' ); ?></th>
1287
-			<th style="" class="manage-column column-date" id="date" scope="col"><?php esc_attr_e( 'Date', 'lsx-wetu-importer' ); ?></th>
1288
-			<th style="" class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'lsx-wetu-importer' ); ?></th>
1285
+			<th style="" class="manage-column column-title " id="title" scope="col"><?php esc_attr_e('Title', 'lsx-wetu-importer'); ?></th>
1286
+			<th style="" class="manage-column column-date" id="ref" scope="col"><?php esc_attr_e('Ref', 'lsx-wetu-importer'); ?></th>
1287
+			<th style="" class="manage-column column-date" id="date" scope="col"><?php esc_attr_e('Date', 'lsx-wetu-importer'); ?></th>
1288
+			<th style="" class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e('WETU ID', 'lsx-wetu-importer'); ?></th>
1289 1289
 		</tr>
1290 1290
 		</thead>
1291 1291
 		<?php
@@ -1299,13 +1299,13 @@  discard block
 block discarded – undo
1299 1299
 		<tfoot>
1300 1300
 		<tr>
1301 1301
 			<th style="" class="manage-column column-cb check-column" id="cb" scope="col">
1302
-				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'lsx-wetu-importer' ); ?></label>
1302
+				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'lsx-wetu-importer'); ?></label>
1303 1303
 				<input type="checkbox" id="cb-select-all-1">
1304 1304
 			</th>
1305
-			<th style="" class="manage-column column-title" scope="col"><?php esc_attr_e( 'Title', 'lsx-wetu-importer' ); ?></th>
1306
-			<th style="" class="manage-column column-date" id="ref" scope="col"><?php esc_attr_e( 'Ref', 'lsx-wetu-importer' ); ?></th>			
1307
-			<th style="" class="manage-column column-date" scope="col"><?php esc_attr_e( 'Date', 'lsx-wetu-importer' ); ?></th>
1308
-			<th style="" class="manage-column column-ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'lsx-wetu-importer' ); ?></th>
1305
+			<th style="" class="manage-column column-title" scope="col"><?php esc_attr_e('Title', 'lsx-wetu-importer'); ?></th>
1306
+			<th style="" class="manage-column column-date" id="ref" scope="col"><?php esc_attr_e('Ref', 'lsx-wetu-importer'); ?></th>			
1307
+			<th style="" class="manage-column column-date" scope="col"><?php esc_attr_e('Date', 'lsx-wetu-importer'); ?></th>
1308
+			<th style="" class="manage-column column-ssid" scope="col"><?php esc_attr_e('WETU ID', 'lsx-wetu-importer'); ?></th>
1309 1309
 		</tr>
1310 1310
 		</tfoot>
1311 1311
 		<?php
Please login to merge, or discard this patch.