Passed
Push — master ( ea5bcf...bf7f32 )
by Warwick
04:30
created
classes/class-lsx-wetu-importer-accommodation.php 1 patch
Spacing   +279 added lines, -279 removed lines patch added patch discarded remove patch
@@ -76,19 +76,19 @@  discard block
 block discarded – undo
76 76
 		// $this->url    = 'https://wetu.com/API/Pins/';
77 77
 		// $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
78 78
 		// } elseif ( false !== $this->api_key ) {
79
-			$this->url    = 'https://wetu.com/API/Pins/' . $this->api_key;
79
+			$this->url    = 'https://wetu.com/API/Pins/'.$this->api_key;
80 80
 			$this->url_qs = 'all=include';
81 81
 		// }
82 82
 
83
-		$temp_options = get_option( '_lsx-to_settings', false );
83
+		$temp_options = get_option('_lsx-to_settings', false);
84 84
 
85
-		if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) {
86
-			$this->options = $temp_options[ $this->plugin_slug ];
85
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
86
+			$this->options = $temp_options[$this->plugin_slug];
87 87
 		}
88 88
 
89
-		$accommodation_options = get_option( 'lsx_wetu_importer_accommodation_settings', false );
89
+		$accommodation_options = get_option('lsx_wetu_importer_accommodation_settings', false);
90 90
 
91
-		if ( false !== $accommodation_options ) {
91
+		if (false !== $accommodation_options) {
92 92
 			$this->accommodation_options = $accommodation_options;
93 93
 		}
94 94
 	}
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 			</div>
108 108
 
109 109
 			<form method="get" action="" id="posts-filter">
110
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
110
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" />
111 111
 
112 112
 				<table class="wp-list-table widefat fixed posts">
113 113
 					<?php $this->table_header(); ?>
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
 					<tbody id="the-list">
116 116
 						<tr class="post-0 type-tour status-none" id="post-0">
117 117
 							<th class="check-column" scope="row">
118
-								<label for="cb-select-0" class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter', 'lsx-wetu-importer' ); ?></label>
118
+								<label for="cb-select-0" class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'lsx-wetu-importer'); ?></label>
119 119
 							</th>
120 120
 							<td class="post-title page-title column-title">
121 121
 								<strong>
122
-									<?php esc_html_e( 'Enter a title to search for', 'lsx-wetu-importer' ); ?>
122
+									<?php esc_html_e('Enter a title to search for', 'lsx-wetu-importer'); ?>
123 123
 								</strong>
124 124
 							</td>
125 125
 							<td class="date column-date">
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 
134 134
 				</table>
135 135
 
136
-				<p><input class="button button-primary add" type="button" value="<?php esc_attr_e( 'Add to List', 'lsx-wetu-importer' ); ?>" />
137
-					<input class="button button-primary clear" type="button" value="<?php esc_attr_e( 'Clear', 'lsx-wetu-importer' ); ?>" />
136
+				<p><input class="button button-primary add" type="button" value="<?php esc_attr_e('Add to List', 'lsx-wetu-importer'); ?>" />
137
+					<input class="button button-primary clear" type="button" value="<?php esc_attr_e('Clear', 'lsx-wetu-importer'); ?>" />
138 138
 				</p>
139 139
 			</form>
140 140
 
@@ -144,58 +144,58 @@  discard block
 block discarded – undo
144 144
 
145 145
 					<div class="row">
146 146
 						<div class="settings-all" style="width:30%;display:block;float:left;">
147
-							<h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3>
147
+							<h3><?php esc_html_e('What content to Sync from WETU'); ?></h3>
148 148
 							<ul>
149
-								<?php if ( isset( $this->options['disable_accommodation_descriptions'] ) && 'on' !== $this->options['disable_accommodation_descriptions'] ) { ?>
150
-									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="description" /> <?php esc_html_e( 'Description', 'lsx-wetu-importer' ); ?></li>
149
+								<?php if (isset($this->options['disable_accommodation_descriptions']) && 'on' !== $this->options['disable_accommodation_descriptions']) { ?>
150
+									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="description" /> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li>
151 151
 								<?php } ?>
152
-								<?php if ( isset( $this->options['disable_accommodation_excerpts'] ) && 'on' !== $this->options['disable_accommodation_excerpts'] ) { ?>
153
-									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="excerpt" /> <?php esc_html_e( 'Excerpt', 'lsx-wetu-importer' ); ?></li>
152
+								<?php if (isset($this->options['disable_accommodation_excerpts']) && 'on' !== $this->options['disable_accommodation_excerpts']) { ?>
153
+									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="excerpt" /> <?php esc_html_e('Excerpt', 'lsx-wetu-importer'); ?></li>
154 154
 								<?php } ?>
155 155
 
156
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="gallery" /> <?php esc_html_e( 'Main Gallery', 'lsx-wetu-importer' ); ?></li>
157
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="category" /> <?php esc_html_e( 'Category', 'lsx-wetu-importer' ); ?></li>
158
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="location" /> <?php esc_html_e( 'Location', 'lsx-wetu-importer' ); ?></li>
156
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="gallery" /> <?php esc_html_e('Main Gallery', 'lsx-wetu-importer'); ?></li>
157
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="category" /> <?php esc_html_e('Category', 'lsx-wetu-importer'); ?></li>
158
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="location" /> <?php esc_html_e('Location', 'lsx-wetu-importer'); ?></li>
159 159
 
160
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e( 'Connect Destinations', 'lsx-wetu-importer' ); ?></li>
161
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="rating" /> <?php esc_html_e( 'Rating', 'lsx-wetu-importer' ); ?></li>
162
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="rooms" /> <?php esc_html_e( 'Rooms', 'lsx-wetu-importer' ); ?></li>
160
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e('Connect Destinations', 'lsx-wetu-importer'); ?></li>
161
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="rating" /> <?php esc_html_e('Rating', 'lsx-wetu-importer'); ?></li>
162
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="rooms" /> <?php esc_html_e('Rooms', 'lsx-wetu-importer'); ?></li>
163 163
 
164
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="checkin" /> <?php esc_html_e( 'Check In / Check Out', 'lsx-wetu-importer' ); ?></li>
165
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="facilities" /> <?php esc_html_e( 'Facilities', 'lsx-wetu-importer' ); ?></li>
166
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="friendly" /> <?php esc_html_e( 'Friendly', 'lsx-wetu-importer' ); ?></li>
164
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="checkin" /> <?php esc_html_e('Check In / Check Out', 'lsx-wetu-importer'); ?></li>
165
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="facilities" /> <?php esc_html_e('Facilities', 'lsx-wetu-importer'); ?></li>
166
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="friendly" /> <?php esc_html_e('Friendly', 'lsx-wetu-importer'); ?></li>
167 167
 
168 168
 
169
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="special_interests" /> <?php esc_html_e( 'Special Interests', 'lsx-wetu-importer' ); ?></li>
170
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="spoken_languages" /> <?php esc_html_e( 'Spoken Languages', 'lsx-wetu-importer' ); ?></li>
169
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="special_interests" /> <?php esc_html_e('Special Interests', 'lsx-wetu-importer'); ?></li>
170
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="spoken_languages" /> <?php esc_html_e('Spoken Languages', 'lsx-wetu-importer'); ?></li>
171 171
 
172
-								<?php if ( class_exists( 'LSX_TO_Videos' ) ) { ?>
173
-									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="videos" /> <?php esc_html_e( 'Videos', 'lsx-wetu-importer' ); ?></li>
172
+								<?php if (class_exists('LSX_TO_Videos')) { ?>
173
+									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="videos" /> <?php esc_html_e('Videos', 'lsx-wetu-importer'); ?></li>
174 174
 								<?php } ?>
175 175
 							</ul>
176
-							<h4><?php esc_html_e( 'Additional Content' ); ?></h4>
176
+							<h4><?php esc_html_e('Additional Content'); ?></h4>
177 177
 							<ul>
178
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e( 'Set Featured Image', 'lsx-wetu-importer' ); ?></li>
179
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e( 'Set Banner Image', 'lsx-wetu-importer' ); ?></li>
178
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e('Set Featured Image', 'lsx-wetu-importer'); ?></li>
179
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e('Set Banner Image', 'lsx-wetu-importer'); ?></li>
180 180
 							</ul>
181 181
 						</div>
182 182
 						<div style="width:30%;display:block;float:left;">
183
-							<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3>
184
-							<?php $this->team_member_checkboxes( $this->accommodation_options ); ?>
183
+							<h3><?php esc_html_e('Assign a Team Member'); ?></h3>
184
+							<?php $this->team_member_checkboxes($this->accommodation_options); ?>
185 185
 						</div>
186 186
 
187 187
 						<div style="width:30%;display:block;float:left;">
188
-							<h3><?php esc_html_e( 'Assign a Safari Brand' ); ?></h3>
188
+							<h3><?php esc_html_e('Assign a Safari Brand'); ?></h3>
189 189
 							<?php
190
-								echo wp_kses_post( $this->taxonomy_checkboxes( 'accommodation-brand', $this->accommodation_options ) );
190
+								echo wp_kses_post($this->taxonomy_checkboxes('accommodation-brand', $this->accommodation_options));
191 191
 							?>
192 192
 						</div>
193 193
 
194 194
 						<br clear="both" />
195 195
 					</div>
196 196
 
197
-					<h3><?php esc_html_e( 'Your List' ); ?></h3>
198
-					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'lsx-wetu-importer' ); ?>" /></p>
197
+					<h3><?php esc_html_e('Your List'); ?></h3>
198
+					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e('Sync', 'lsx-wetu-importer'); ?>" /></p>
199 199
 					<table class="wp-list-table widefat fixed posts">
200 200
 						<?php $this->table_header(); ?>
201 201
 
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
 
208 208
 					</table>
209 209
 
210
-					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'lsx-wetu-importer' ); ?>" /></p>
210
+					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e('Sync', 'lsx-wetu-importer'); ?>" /></p>
211 211
 				</form>
212 212
 			</div>
213 213
 
214 214
 			<div style="display:none;" class="completed-list-wrapper">
215
-				<h3><?php esc_html_e( 'Completed' ); ?> - <small><?php esc_html_e( 'Import your', 'lsx-wetu-importer' ); ?> <a href="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->plugin_slug ); ?>&tab=destination"><?php esc_html_e( 'destinations' ); ?></a> <?php esc_html_e( 'next', 'lsx-wetu-importer' ); ?></small></h3>
215
+				<h3><?php esc_html_e('Completed'); ?> - <small><?php esc_html_e('Import your', 'lsx-wetu-importer'); ?> <a href="<?php echo esc_url(admin_url('admin.php')); ?>?page=<?php echo esc_attr($this->plugin_slug); ?>&tab=destination"><?php esc_html_e('destinations'); ?></a> <?php esc_html_e('next', 'lsx-wetu-importer'); ?></small></h3>
216 216
 				<ul>
217 217
 				</ul>
218 218
 			</div>
@@ -225,115 +225,115 @@  discard block
 block discarded – undo
225 225
 	 */
226 226
 	public function process_ajax_search() {
227 227
 		$return = false;
228
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
229
-		if ( isset( $_POST['action'] ) && 'lsx_tour_importer' === $_POST['action'] && isset( $_POST['type'] ) && 'accommodation' === $_POST['type'] ) {
228
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
229
+		if (isset($_POST['action']) && 'lsx_tour_importer' === $_POST['action'] && isset($_POST['type']) && 'accommodation' === $_POST['type']) {
230 230
 
231 231
 			$searched_items = false;
232
-			if ( isset( $_POST['keyword'] ) ) {
233
-				$keyphrases = array_map( 'sanitize_text_field', wp_unslash( $_POST['keyword'] ) );
234
-			} else {
235
-				$keyphrases = array( 0 );
232
+			if (isset($_POST['keyword'])) {
233
+				$keyphrases = array_map('sanitize_text_field', wp_unslash($_POST['keyword']));
234
+			}else {
235
+				$keyphrases = array(0);
236 236
 			}
237 237
 
238
-			if ( ! is_array( $keyphrases ) ) {
239
-				$keyphrases = array( $keyphrases );
238
+			if (!is_array($keyphrases)) {
239
+				$keyphrases = array($keyphrases);
240 240
 			}
241
-			foreach ( $keyphrases as &$keyword ) {
242
-				$keyword = ltrim( rtrim( $keyword ) );
241
+			foreach ($keyphrases as &$keyword) {
242
+				$keyword = ltrim(rtrim($keyword));
243 243
 			}
244 244
 
245 245
 			$post_status = false;
246 246
 
247
-			if ( in_array( 'publish', $keyphrases ) ) {
247
+			if (in_array('publish', $keyphrases)) {
248 248
 				$post_status = 'publish';
249 249
 			}
250
-			if ( in_array( 'pending', $keyphrases ) ) {
250
+			if (in_array('pending', $keyphrases)) {
251 251
 				$post_status = 'pending';
252 252
 			}
253
-			if ( in_array( 'draft', $keyphrases ) ) {
253
+			if (in_array('draft', $keyphrases)) {
254 254
 				$post_status = 'draft';
255 255
 			}
256
-			if ( in_array( 'import', $keyphrases ) ) {
256
+			if (in_array('import', $keyphrases)) {
257 257
 				$post_status = 'import';
258 258
 			}
259 259
 
260 260
 			// If there is a post status use it.
261
-			if ( false !== $post_status ) {
261
+			if (false !== $post_status) {
262 262
 
263 263
 				$accommodation         = array();
264 264
 				$current_accommodation = $this->find_current_accommodation();
265
-				if ( ! empty( $current_accommodation ) ) {
266
-					foreach ( $current_accommodation as $cs_key => $ccs_id ) {
267
-						$accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id );
265
+				if (!empty($current_accommodation)) {
266
+					foreach ($current_accommodation as $cs_key => $ccs_id) {
267
+						$accommodation[] = $this->prepare_row_attributes($cs_key, $ccs_id->post_id);
268 268
 					}
269 269
 				}
270 270
 
271 271
 				// Run through each accommodation and use it.
272
-				if ( ! empty( $accommodation ) ) {
273
-					foreach ( $accommodation as $row_key => $row ) {
272
+				if (!empty($accommodation)) {
273
+					foreach ($accommodation as $row_key => $row) {
274 274
 						$row['post_title'] = $row['name'];
275
-						if ( 'import' === $post_status ) {
276
-							if ( is_array( $this->queued_imports ) && in_array( $row['post_id'], $this->queued_imports ) ) {
277
-								$current_status = get_post_status( $row['post_id'] );
278
-								if ( 'draft' === $current_status ) {
279
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
275
+						if ('import' === $post_status) {
276
+							if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) {
277
+								$current_status = get_post_status($row['post_id']);
278
+								if ('draft' === $current_status) {
279
+									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
280 280
 								}
281
-							} else {
281
+							}else {
282 282
 								continue;
283 283
 							}
284
-						} else {
285
-							if ( 0 === $row['post_id'] ) {
284
+						}else {
285
+							if (0 === $row['post_id']) {
286 286
 								continue;
287
-							} else {
288
-								$current_status = get_post_status( $row['post_id'] );
289
-								if ( $current_status !== $post_status ) {
287
+							}else {
288
+								$current_status = get_post_status($row['post_id']);
289
+								if ($current_status !== $post_status) {
290 290
 									continue;
291 291
 								}
292 292
 							}
293
-							$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row, $row_key );
293
+							$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row, $row_key);
294 294
 						}
295 295
 					}
296 296
 				}
297
-			} else {
298
-				$key_string_search = implode( '+', $keyphrases );
299
-				$search_data       = wp_remote_get( $this->url . '/Search/' . $key_string_search );
300
-				if ( ! empty( $search_data ) && isset( $search_data['response'] ) && isset( $search_data['response']['code'] ) && 200 === $search_data['response']['code'] ) {
297
+			}else {
298
+				$key_string_search = implode('+', $keyphrases);
299
+				$search_data       = wp_remote_get($this->url.'/Search/'.$key_string_search);
300
+				if (!empty($search_data) && isset($search_data['response']) && isset($search_data['response']['code']) && 200 === $search_data['response']['code']) {
301 301
 
302
-					$search_data = json_decode( $search_data['body'], true );
303
-					foreach ( $search_data as $sdata_key => $sdata ) {
302
+					$search_data = json_decode($search_data['body'], true);
303
+					foreach ($search_data as $sdata_key => $sdata) {
304 304
 
305
-						if ( 'Destination' === trim( $sdata['type'] ) || 'Activity' === trim( $sdata['type'] ) || 'Restaurant' === trim( $sdata['type'] ) || 'None' === trim( $sdata['type'] ) || 'Site / Attraction' === trim( $sdata['type'] ) || '' === trim( $sdata['type'] ) ) {
305
+						if ('Destination' === trim($sdata['type']) || 'Activity' === trim($sdata['type']) || 'Restaurant' === trim($sdata['type']) || 'None' === trim($sdata['type']) || 'Site / Attraction' === trim($sdata['type']) || '' === trim($sdata['type'])) {
306 306
 							continue;
307 307
 						}
308 308
 
309
-						$temp_id = $this->get_post_id_by_key_value( $sdata['id'] );
310
-						if ( false === $temp_id ) {
309
+						$temp_id = $this->get_post_id_by_key_value($sdata['id']);
310
+						if (false === $temp_id) {
311 311
 							$sdata['post_id']    = 0;
312 312
 							$sdata['post_title'] = $sdata['name'];
313
-						} else {
313
+						}else {
314 314
 							$sdata['post_id']    = $temp_id;
315
-							$sdata['post_title'] = get_the_title( $temp_id );
315
+							$sdata['post_title'] = get_the_title($temp_id);
316 316
 						}
317
-						$searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata, $sdata_key );
317
+						$searched_items[sanitize_title($sdata['name']).'-'.$sdata['id']] = $this->format_row($sdata, $sdata_key);
318 318
 					}
319 319
 				}
320 320
 			}
321 321
 
322
-			if ( false !== $searched_items ) {
323
-				$return = implode( $searched_items );
322
+			if (false !== $searched_items) {
323
+				$return = implode($searched_items);
324 324
 			}
325
-			print_r( $return );
325
+			print_r($return);
326 326
 		}
327 327
 
328 328
 		die();
329 329
 	}
330 330
 
331
-	public function prepare_row_attributes( $cs_key, $ccs_id ) {
331
+	public function prepare_row_attributes($cs_key, $ccs_id) {
332 332
 		$row_item = array(
333 333
 			'id'            => $cs_key,
334 334
 			'type'          => 'Accommodation',
335
-			'name'          => get_the_title( $ccs_id ),
336
-			'last_modified' => date( 'Y-m-d', strtotime( 'now' ) ),
335
+			'name'          => get_the_title($ccs_id),
336
+			'last_modified' => date('Y-m-d', strtotime('now')),
337 337
 			'post_id'       => $ccs_id,
338 338
 		);
339 339
 		return $row_item;
@@ -345,31 +345,31 @@  discard block
 block discarded – undo
345 345
 	 * @param boolean $row the current row to format.
346 346
 	 * @return void
347 347
 	 */
348
-	public function format_row( $row = false, $row_key = '' ) {
349
-		if ( false !== $row ) {
348
+	public function format_row($row = false, $row_key = '') {
349
+		if (false !== $row) {
350 350
 
351 351
 			$status = 'import';
352
-			if ( 0 !== $row['post_id'] ) {
353
-				$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>';
352
+			if (0 !== $row['post_id']) {
353
+				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
354 354
 			}
355 355
 
356 356
 			$row_html = '
357
-			<tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '">
357
+			<tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'">
358 358
 				<th class="check-column" scope="row">
359
-					<label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label>
360
-					<input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '">
359
+					<label for="cb-select-' . $row['id'].'" class="screen-reader-text">'.$row['name'].'</label>
360
+					<input type="checkbox" data-identifier="' . $row['id'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['id'].'">
361 361
 				</th>
362 362
 				<td class="column-order">
363
-					' . ( $row_key + 1 ) . '
363
+					' . ($row_key + 1).'
364 364
 				</td>
365 365
 				<td class="post-title page-title column-title">
366
-					<strong>' . $row['post_title'] . '</strong> - ' . $status . '
366
+					<strong>' . $row['post_title'].'</strong> - '.$status.'
367 367
 				</td>
368 368
 				<td class="date column-date">
369
-					<abbr title="' . date( 'Y/m/d', strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d', strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified
369
+					<abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
370 370
 				</td>
371 371
 				<td class="ssid column-ssid">
372
-					' . $row['id'] . '
372
+					' . $row['id'].'
373 373
 				</td>
374 374
 			</tr>';
375 375
 			return $row_html;
@@ -379,14 +379,14 @@  discard block
 block discarded – undo
379 379
 	/**
380 380
 	 * Saves the queue to the option.
381 381
 	 */
382
-	public function remove_from_queue( $id ) {
383
-		if ( ! empty( $this->queued_imports ) ) {
384
-			$key = array_search( $id, $this->queued_imports );
385
-			if ( false !== $key ) {
386
-				unset( $this->queued_imports[ $key ] );
382
+	public function remove_from_queue($id) {
383
+		if (!empty($this->queued_imports)) {
384
+			$key = array_search($id, $this->queued_imports);
385
+			if (false !== $key) {
386
+				unset($this->queued_imports[$key]);
387 387
 
388
-				delete_option( 'lsx_wetu_importer_que' );
389
-				update_option( 'lsx_wetu_importer_que', $this->queued_imports );
388
+				delete_option('lsx_wetu_importer_que');
389
+				update_option('lsx_wetu_importer_que', $this->queued_imports);
390 390
 			}
391 391
 		}
392 392
 	}
@@ -396,47 +396,47 @@  discard block
 block discarded – undo
396 396
 	 */
397 397
 	public function process_ajax_import() {
398 398
 		$return = false;
399
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
399
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
400 400
 
401
-		if ( isset( $_POST['action'] ) && 'lsx_import_items' === $_POST['action'] && isset( $_POST['type'] ) && 'accommodation' === $_POST['type'] && isset( $_POST['wetu_id'] ) ) {
401
+		if (isset($_POST['action']) && 'lsx_import_items' === $_POST['action'] && isset($_POST['type']) && 'accommodation' === $_POST['type'] && isset($_POST['wetu_id'])) {
402 402
 
403
-			$wetu_id = sanitize_text_field( $_POST['wetu_id'] );
404
-			if ( isset( $_POST['post_id'] ) ) {
405
-				$post_id = sanitize_text_field( $_POST['post_id'] );
406
-			} else {
403
+			$wetu_id = sanitize_text_field($_POST['wetu_id']);
404
+			if (isset($_POST['post_id'])) {
405
+				$post_id = sanitize_text_field($_POST['post_id']);
406
+			}else {
407 407
 				$post_id = 0;
408 408
 			}
409 409
 
410
-			if ( isset( $_POST['team_members'] ) ) {
411
-				$team_members = array_map( 'sanitize_text_field', wp_unslash( $_POST['team_members'] ) );
412
-			} else {
410
+			if (isset($_POST['team_members'])) {
411
+				$team_members = array_map('sanitize_text_field', wp_unslash($_POST['team_members']));
412
+			}else {
413 413
 				$team_members = false;
414 414
 			}
415 415
 
416
-			if ( isset( $_POST['safari_brands'] ) ) {
417
-				$safari_brands = array_map( 'sanitize_text_field', wp_unslash( $_POST['safari_brands'] ) );
418
-			} else {
416
+			if (isset($_POST['safari_brands'])) {
417
+				$safari_brands = array_map('sanitize_text_field', wp_unslash($_POST['safari_brands']));
418
+			}else {
419 419
 				$safari_brands = false;
420 420
 			}
421
-			delete_option( 'lsx_wetu_importer_accommodation_settings' );
421
+			delete_option('lsx_wetu_importer_accommodation_settings');
422 422
 
423
-			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
424
-				$content = array_map( 'sanitize_text_field', wp_unslash( $_POST['content'] ) );
425
-				add_option( 'lsx_wetu_importer_accommodation_settings', $content );
426
-			} else {
423
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
424
+				$content = array_map('sanitize_text_field', wp_unslash($_POST['content']));
425
+				add_option('lsx_wetu_importer_accommodation_settings', $content);
426
+			}else {
427 427
 				$content = false;
428 428
 			}
429 429
 
430
-			$jdata = wp_remote_get( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
430
+			$jdata = wp_remote_get($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
431 431
 
432
-			if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
433
-				$adata  = json_decode( $jdata['body'], true );
434
-				$return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands );
435
-				$this->format_completed_row( $return );
436
-				$this->remove_from_queue( $return );
432
+			if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
433
+				$adata  = json_decode($jdata['body'], true);
434
+				$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
435
+				$this->format_completed_row($return);
436
+				$this->remove_from_queue($return);
437 437
 				$this->cleanup_posts();
438
-			} else {
439
-				$this->format_error( esc_html__( 'There was a problem importing your accommodation, please try refreshing the page.', 'lsx-wetu-importer' ) );
438
+			}else {
439
+				$this->format_error(esc_html__('There was a problem importing your accommodation, please try refreshing the page.', 'lsx-wetu-importer'));
440 440
 			}
441 441
 		}
442 442
 	}
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 	/**
445 445
 	 * Connect to wetu
446 446
 	 */
447
-	public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false ) {
447
+	public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false) {
448 448
 		$post_name         = '';
449 449
 		$data_post_content = '';
450 450
 		$data_post_excerpt = '';
@@ -455,142 +455,142 @@  discard block
 block discarded – undo
455 455
 		$content_used_general_description = false;
456 456
 
457 457
 		// Set the post_content.
458
-		if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) {
459
-			if ( isset( $data[0]['content']['extended_description'] ) ) {
458
+		if (!empty($importable_content) && in_array('description', $importable_content)) {
459
+			if (isset($data[0]['content']['extended_description'])) {
460 460
 				$data_post_content = $data[0]['content']['extended_description'];
461
-			} elseif ( isset( $data[0]['content']['general_description'] ) ) {
461
+			} elseif (isset($data[0]['content']['general_description'])) {
462 462
 				$data_post_content                = $data[0]['content']['general_description'];
463 463
 				$content_used_general_description = true;
464
-			} elseif ( isset( $data[0]['content']['teaser_description'] ) ) {
464
+			} elseif (isset($data[0]['content']['teaser_description'])) {
465 465
 				$data_post_content = $data[0]['content']['teaser_description'];
466 466
 			}
467 467
 
468
-			if ( isset( $this->options['disable_accommodation_filtering'] ) && 'on' === $this->options['disable_accommodation_filtering'] ) {
468
+			if (isset($this->options['disable_accommodation_filtering']) && 'on' === $this->options['disable_accommodation_filtering']) {
469 469
 				$post['post_content'] = $data_post_content;
470
-			} else {
471
-				$post['post_content'] = wp_strip_all_tags( $data_post_content );
470
+			}else {
471
+				$post['post_content'] = wp_strip_all_tags($data_post_content);
472 472
 			}
473 473
 		}
474 474
 
475 475
 		// set the post_excerpt.
476
-		if ( ! empty( $importable_content ) && in_array( 'excerpt', $importable_content ) ) {
477
-			if ( isset( $data[0]['content']['teaser_description'] ) ) {
476
+		if (!empty($importable_content) && in_array('excerpt', $importable_content)) {
477
+			if (isset($data[0]['content']['teaser_description'])) {
478 478
 				$data_post_excerpt = $data[0]['content']['teaser_description'];
479
-			} elseif ( isset( $data[0]['content']['general_description'] ) && false === $content_used_general_description ) {
479
+			} elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) {
480 480
 				$data_post_excerpt = $data[0]['content']['general_description'];
481 481
 			}
482 482
 
483 483
 			$post['post_excerpt'] = $data_post_excerpt;
484 484
 		}
485 485
 
486
-		if ( false !== $id && '0' !== $id ) {
486
+		if (false !== $id && '0' !== $id) {
487 487
 			$post['ID'] = $id;
488 488
 
489
-			if ( isset( $this->options ) && 'on' !== $this->options['disable_accommodation_title'] && isset( $data[0]['name'] ) ) {
489
+			if (isset($this->options) && 'on' !== $this->options['disable_accommodation_title'] && isset($data[0]['name'])) {
490 490
 				$post['post_title'] = $data[0]['name'];
491
-				$post['post_name']  = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'accommodation', 0 );
491
+				$post['post_name']  = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0);
492 492
 			}
493 493
 
494 494
 			$post['post_status'] = 'publish';
495 495
 
496
-			$id        = wp_update_post( $post );
497
-			$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
498
-			update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date );
499
-		} else {
496
+			$id        = wp_update_post($post);
497
+			$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
498
+			update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
499
+		}else {
500 500
 			// Set the name.
501
-			if ( isset( $data[0]['name'] ) ) {
502
-				$post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'accommodation', 0 );
501
+			if (isset($data[0]['name'])) {
502
+				$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0);
503 503
 			}
504 504
 
505 505
 			$post['post_name']   = $post_name;
506 506
 			$post['post_title']  = $data[0]['name'];
507 507
 			$post['post_status'] = 'publish';
508
-			$id                  = wp_insert_post( $post );
508
+			$id                  = wp_insert_post($post);
509 509
 
510 510
 			// Save the WETU ID and the Last date it was modified.
511
-			if ( false !== $id ) {
512
-				add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
513
-				add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) );
511
+			if (false !== $id) {
512
+				add_post_meta($id, 'lsx_wetu_id', $wetu_id);
513
+				add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']));
514 514
 			}
515 515
 		}
516 516
 
517 517
 		// Setup some default for use in the import.
518
-		if ( false !== $importable_content && ( in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content ) ) ) {
519
-			$this->find_attachments( $id );
518
+		if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) {
519
+			$this->find_attachments($id);
520 520
 		}
521 521
 
522 522
 		// Set the team member if it is there.
523
-		if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) {
524
-			$this->set_team_member( $id, $team_members );
523
+		if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
524
+			$this->set_team_member($id, $team_members);
525 525
 		}
526 526
 
527 527
 		// Set the safari brand.
528
-		if ( false !== $safari_brands && '' !== $safari_brands ) {
529
-			$this->set_safari_brands( $id, $safari_brands );
528
+		if (false !== $safari_brands && '' !== $safari_brands) {
529
+			$this->set_safari_brands($id, $safari_brands);
530 530
 		}
531 531
 
532
-		$this->set_map_data( $data, $id, 9 );
532
+		$this->set_map_data($data, $id, 9);
533 533
 
534
-		if ( post_type_exists( 'destination' ) && false !== $importable_content && in_array( 'destination', $importable_content ) ) {
535
-			$this->connect_destinations( $data, $id );
534
+		if (post_type_exists('destination') && false !== $importable_content && in_array('destination', $importable_content)) {
535
+			$this->connect_destinations($data, $id);
536 536
 		}
537 537
 
538
-		if ( false !== $importable_content && in_array( 'category', $importable_content ) ) {
539
-			$this->set_taxonomy_style( $data, $id );
538
+		if (false !== $importable_content && in_array('category', $importable_content)) {
539
+			$this->set_taxonomy_style($data, $id);
540 540
 		}
541 541
 
542 542
 		// Set the Room Data.
543
-		if ( false !== $importable_content && in_array( 'rooms', $importable_content ) ) {
544
-			$this->set_room_data( $data, $id );
543
+		if (false !== $importable_content && in_array('rooms', $importable_content)) {
544
+			$this->set_room_data($data, $id);
545 545
 		}
546 546
 
547 547
 		// Set the rating.
548
-		if ( false !== $importable_content && in_array( 'rating', $importable_content ) ) {
549
-			$this->set_rating( $data, $id );
548
+		if (false !== $importable_content && in_array('rating', $importable_content)) {
549
+			$this->set_rating($data, $id);
550 550
 		}
551 551
 
552 552
 		// Set the checkin checkout data.
553
-		if ( false !== $importable_content && in_array( 'checkin', $importable_content ) ) {
554
-			$this->set_checkin_checkout( $data, $id );
553
+		if (false !== $importable_content && in_array('checkin', $importable_content)) {
554
+			$this->set_checkin_checkout($data, $id);
555 555
 		}
556 556
 
557 557
 		// Set the Spoken Languages.
558
-		if ( false !== $importable_content && in_array( 'spoken_languages', $importable_content ) ) {
559
-			$this->set_spoken_languages( $data, $id );
558
+		if (false !== $importable_content && in_array('spoken_languages', $importable_content)) {
559
+			$this->set_spoken_languages($data, $id);
560 560
 		}
561 561
 
562 562
 		// Set the friendly options.
563
-		if ( false !== $importable_content && in_array( 'friendly', $importable_content ) ) {
564
-			$this->set_friendly( $data, $id );
563
+		if (false !== $importable_content && in_array('friendly', $importable_content)) {
564
+			$this->set_friendly($data, $id);
565 565
 		}
566 566
 
567 567
 		// Set the special_interests.
568
-		if ( false !== $importable_content && in_array( 'special_interests', $importable_content ) ) {
569
-			$this->set_special_interests( $data, $id );
568
+		if (false !== $importable_content && in_array('special_interests', $importable_content)) {
569
+			$this->set_special_interests($data, $id);
570 570
 		}
571 571
 
572 572
 		// Import the videos.
573
-		if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) {
574
-			$this->set_video_data( $data, $id );
573
+		if (false !== $importable_content && in_array('videos', $importable_content)) {
574
+			$this->set_video_data($data, $id);
575 575
 		}
576 576
 
577 577
 		// Import the facilities.
578
-		if ( false !== $importable_content && in_array( 'facilities', $importable_content ) ) {
579
-			$this->set_facilities( $data, $id );
578
+		if (false !== $importable_content && in_array('facilities', $importable_content)) {
579
+			$this->set_facilities($data, $id);
580 580
 		}
581 581
 
582 582
 		// Set the featured image.
583
-		if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
584
-			$this->set_featured_image( $data, $id );
583
+		if (false !== $importable_content && in_array('featured_image', $importable_content)) {
584
+			$this->set_featured_image($data, $id);
585 585
 		}
586 586
 
587
-		if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
588
-			$this->set_banner_image( $data, $id );
587
+		if (false !== $importable_content && in_array('banner_image', $importable_content)) {
588
+			$this->set_banner_image($data, $id);
589 589
 		}
590 590
 
591 591
 		// Import the main gallery.
592
-		if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) {
593
-			$this->create_main_gallery( $data, $id );
592
+		if (false !== $importable_content && in_array('gallery', $importable_content)) {
593
+			$this->create_main_gallery($data, $id);
594 594
 		}
595 595
 
596 596
 		return $id;
@@ -599,44 +599,44 @@  discard block
 block discarded – undo
599 599
 	/**
600 600
 	 * Set the safari brand
601 601
 	 */
602
-	public function set_safari_brands( $id, $safari_brands ) {
603
-		foreach ( $safari_brands as $safari_brand ) {
604
-			wp_set_object_terms( $id, intval( $safari_brand ), 'accommodation-brand', true );
602
+	public function set_safari_brands($id, $safari_brands) {
603
+		foreach ($safari_brands as $safari_brand) {
604
+			wp_set_object_terms($id, intval($safari_brand), 'accommodation-brand', true);
605 605
 		}
606 606
 	}
607 607
 
608 608
 	/**
609 609
 	 * Connects the destinations post type
610 610
 	 */
611
-	public function connect_destinations( $data, $id ) {
612
-		if ( isset( $data[0]['position'] ) ) {
611
+	public function connect_destinations($data, $id) {
612
+		if (isset($data[0]['position'])) {
613 613
 			$destinations = false;
614 614
 
615
-			if ( isset( $data[0]['position']['country'] ) ) {
615
+			if (isset($data[0]['position']['country'])) {
616 616
 				$destinations['country'] = $data[0]['position']['country'];
617 617
 			}
618 618
 
619
-			if ( isset( $data[0]['position']['destination'] ) ) {
619
+			if (isset($data[0]['position']['destination'])) {
620 620
 				$destinations['destination'] = $data[0]['position']['destination'];
621 621
 			}
622 622
 
623
-			if ( false !== $destinations ) {
624
-				$prev_values = get_post_meta( $id, 'destination_to_accommodation', false );
623
+			if (false !== $destinations) {
624
+				$prev_values = get_post_meta($id, 'destination_to_accommodation', false);
625 625
 
626
-				if ( false === $prev_values || ! is_array( $prev_values ) ) {
626
+				if (false === $prev_values || !is_array($prev_values)) {
627 627
 					$prev_values = array();
628 628
 				}
629 629
 
630
-				delete_post_meta( $id, 'destination_to_accommodation', $prev_values );
631
-				$destinations = array_unique( $destinations );
630
+				delete_post_meta($id, 'destination_to_accommodation', $prev_values);
631
+				$destinations = array_unique($destinations);
632 632
 
633
-				foreach ( $destinations as $key => $value ) {
634
-					$destination = get_page_by_title( ltrim( rtrim( $value ) ), 'OBJECT', 'destination' );
635
-					if ( null !== $destination ) {
636
-						if ( ! in_array( $destination->ID, $prev_values ) ) {
637
-							add_post_meta( $id, 'destination_to_accommodation', $destination->ID, false );
638
-							add_post_meta( $destination->ID, 'accommodation_to_destination', $id, false );
639
-							$this->cleanup_posts[ $destination->ID ] = 'accommodation_to_destination';
633
+				foreach ($destinations as $key => $value) {
634
+					$destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
635
+					if (null !== $destination) {
636
+						if (!in_array($destination->ID, $prev_values)) {
637
+							add_post_meta($id, 'destination_to_accommodation', $destination->ID, false);
638
+							add_post_meta($destination->ID, 'accommodation_to_destination', $id, false);
639
+							$this->cleanup_posts[$destination->ID] = 'accommodation_to_destination';
640 640
 						}
641 641
 					}
642 642
 				}
@@ -647,72 +647,72 @@  discard block
 block discarded – undo
647 647
 	/**
648 648
 	 * Set the Travel Style
649 649
 	 */
650
-	public function set_taxonomy_style( $data, $id ) {
650
+	public function set_taxonomy_style($data, $id) {
651 651
 		$terms = false;
652 652
 
653
-		if ( isset( $data[0]['category'] ) ) {
654
-			$term = term_exists( trim( $data[0]['category'] ), 'accommodation-type' );
655
-			if ( ! $term ) {
656
-				$term = wp_insert_term( trim( $data[0]['category'] ), 'accommodation-type' );
653
+		if (isset($data[0]['category'])) {
654
+			$term = term_exists(trim($data[0]['category']), 'accommodation-type');
655
+			if (!$term) {
656
+				$term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
657 657
 
658
-				if ( is_wp_error( $term ) ) {
659
-					echo wp_kses_post( $term->get_error_message() );
658
+				if (is_wp_error($term)) {
659
+					echo wp_kses_post($term->get_error_message());
660 660
 				}
661
-			} else {
662
-				wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type', true );
661
+			}else {
662
+				wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true);
663 663
 			}
664
-		} else {
665
-			wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type', true );
664
+		}else {
665
+			wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true);
666 666
 		}
667 667
 	}
668 668
 
669 669
 	/**
670 670
 	 * Saves the room data
671 671
 	 */
672
-	public function set_room_data( $data, $id ) {
673
-		if ( ! empty( $data[0]['rooms'] ) && is_array( $data[0]['rooms'] ) ) {
672
+	public function set_room_data($data, $id) {
673
+		if (!empty($data[0]['rooms']) && is_array($data[0]['rooms'])) {
674 674
 			$rooms = false;
675 675
 
676
-			foreach ( $data[0]['rooms'] as $room ) {
676
+			foreach ($data[0]['rooms'] as $room) {
677 677
 				$temp_room = array();
678 678
 
679
-				if ( isset( $room['name'] ) ) {
679
+				if (isset($room['name'])) {
680 680
 					$temp_room['title'] = $room['name'];
681 681
 				}
682 682
 
683
-				if ( isset( $room['description'] ) ) {
684
-					$temp_room['description'] = strip_tags( $room['description'] );
683
+				if (isset($room['description'])) {
684
+					$temp_room['description'] = strip_tags($room['description']);
685 685
 				}
686 686
 
687 687
 				$temp_room['price'] = 0;
688 688
 				$temp_room['type']  = 'room';
689 689
 
690
-				if ( ! empty( $room['images'] ) && is_array( $room['images'] ) ) {
690
+				if (!empty($room['images']) && is_array($room['images'])) {
691 691
 					$temp_room['gallery']   = array();
692
-					$temp_room['gallery'][] = $this->attach_image( $room['images'][0], $id );
692
+					$temp_room['gallery'][] = $this->attach_image($room['images'][0], $id);
693 693
 				}
694 694
 				$rooms[] = $temp_room;
695 695
 			}
696 696
 
697
-			if ( false !== $id && '0' !== $id ) {
698
-				delete_post_meta( $id, 'units' );
697
+			if (false !== $id && '0' !== $id) {
698
+				delete_post_meta($id, 'units');
699 699
 			}
700 700
 
701
-			foreach ( $rooms as $room ) {
702
-				add_post_meta( $id, 'units', $room, false );
701
+			foreach ($rooms as $room) {
702
+				add_post_meta($id, 'units', $room, false);
703 703
 			}
704 704
 
705
-			if ( isset( $data[0]['features'] ) && isset( $data[0]['features']['rooms'] ) ) {
705
+			if (isset($data[0]['features']) && isset($data[0]['features']['rooms'])) {
706 706
 				$room_count = $data[0]['features']['rooms'];
707
-			} else {
708
-				$room_count = count( $data[0]['rooms'] );
707
+			}else {
708
+				$room_count = count($data[0]['rooms']);
709 709
 			}
710 710
 
711
-			if ( false !== $id && '0' !== $id ) {
712
-				$prev_rooms = get_post_meta( $id, 'number_of_rooms', true );
713
-				update_post_meta( $id, 'number_of_rooms', $room_count, $prev_rooms );
714
-			} else {
715
-				add_post_meta( $id, 'number_of_rooms', $room_count, true );
711
+			if (false !== $id && '0' !== $id) {
712
+				$prev_rooms = get_post_meta($id, 'number_of_rooms', true);
713
+				update_post_meta($id, 'number_of_rooms', $room_count, $prev_rooms);
714
+			}else {
715
+				add_post_meta($id, 'number_of_rooms', $room_count, true);
716 716
 			}
717 717
 		}
718 718
 	}
@@ -720,33 +720,33 @@  discard block
 block discarded – undo
720 720
 	/**
721 721
 	 * Set the ratings
722 722
 	 */
723
-	public function set_rating( $data, $id ) {
724
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['star_authority'] ) ) {
723
+	public function set_rating($data, $id) {
724
+		if (!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])) {
725 725
 			$rating_type = $data[0]['features']['star_authority'];
726
-		} else {
726
+		}else {
727 727
 			$rating_type = 'Unspecified2';
728 728
 		}
729 729
 
730
-		$this->save_custom_field( $rating_type, 'rating_type', $id );
730
+		$this->save_custom_field($rating_type, 'rating_type', $id);
731 731
 
732
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['stars'] ) ) {
733
-			$this->save_custom_field( $data[0]['features']['stars'], 'rating', $id, true );
732
+		if (!empty($data[0]['features']) && isset($data[0]['features']['stars'])) {
733
+			$this->save_custom_field($data[0]['features']['stars'], 'rating', $id, true);
734 734
 		}
735 735
 	}
736 736
 
737 737
 	/**
738 738
 	 * Set the spoken_languages
739 739
 	 */
740
-	public function set_spoken_languages( $data, $id ) {
741
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['spoken_languages'] ) && ! empty( $data[0]['features']['spoken_languages'] ) ) {
740
+	public function set_spoken_languages($data, $id) {
741
+		if (!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])) {
742 742
 			$languages = false;
743 743
 
744
-			foreach ( $data[0]['features']['spoken_languages'] as $spoken_language ) {
745
-				$languages[] = sanitize_title( $spoken_language );
744
+			foreach ($data[0]['features']['spoken_languages'] as $spoken_language) {
745
+				$languages[] = sanitize_title($spoken_language);
746 746
 			}
747 747
 
748
-			if ( false !== $languages ) {
749
-				$this->save_custom_field( $languages, 'spoken_languages', $id );
748
+			if (false !== $languages) {
749
+				$this->save_custom_field($languages, 'spoken_languages', $id);
750 750
 			}
751 751
 		}
752 752
 	}
@@ -754,16 +754,16 @@  discard block
 block discarded – undo
754 754
 	/**
755 755
 	 * Set the friendly
756 756
 	 */
757
-	public function set_friendly( $data, $id ) {
758
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['suggested_visitor_types'] ) && ! empty( $data[0]['features']['suggested_visitor_types'] ) ) {
757
+	public function set_friendly($data, $id) {
758
+		if (!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])) {
759 759
 			$friendly_options = false;
760 760
 
761
-			foreach ( $data[0]['features']['suggested_visitor_types'] as $visitor_type ) {
762
-				$friendly_options[] = sanitize_title( $visitor_type );
761
+			foreach ($data[0]['features']['suggested_visitor_types'] as $visitor_type) {
762
+				$friendly_options[] = sanitize_title($visitor_type);
763 763
 			}
764 764
 
765
-			if ( false !== $friendly_options ) {
766
-				$this->save_custom_field( $friendly_options, 'suggested_visitor_types', $id );
765
+			if (false !== $friendly_options) {
766
+				$this->save_custom_field($friendly_options, 'suggested_visitor_types', $id);
767 767
 			}
768 768
 		}
769 769
 	}
@@ -771,16 +771,16 @@  discard block
 block discarded – undo
771 771
 	/**
772 772
 	 * Set the special interests
773 773
 	 */
774
-	public function set_special_interests( $data, $id ) {
775
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['special_interests'] ) && ! empty( $data[0]['features']['special_interests'] ) ) {
774
+	public function set_special_interests($data, $id) {
775
+		if (!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])) {
776 776
 			$interests = false;
777 777
 
778
-			foreach ( $data[0]['features']['special_interests'] as $special_interest ) {
779
-				$interests[] = sanitize_title( $special_interest );
778
+			foreach ($data[0]['features']['special_interests'] as $special_interest) {
779
+				$interests[] = sanitize_title($special_interest);
780 780
 			}
781 781
 
782
-			if ( false !== $interests ) {
783
-				$this->save_custom_field( $interests, 'special_interests', $id );
782
+			if (false !== $interests) {
783
+				$this->save_custom_field($interests, 'special_interests', $id);
784 784
 			}
785 785
 		}
786 786
 	}
@@ -788,24 +788,24 @@  discard block
 block discarded – undo
788 788
 	/**
789 789
 	 * Set the Check in and Check out Date
790 790
 	 */
791
-	public function set_checkin_checkout( $data, $id ) {
792
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_in_time'] ) ) {
793
-			$time = str_replace( 'h', ':', $data[0]['features']['check_in_time'] );
794
-			$time = date( 'h:ia', strtotime( $time ) );
795
-			$this->save_custom_field( $time, 'checkin_time', $id );
791
+	public function set_checkin_checkout($data, $id) {
792
+		if (!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])) {
793
+			$time = str_replace('h', ':', $data[0]['features']['check_in_time']);
794
+			$time = date('h:ia', strtotime($time));
795
+			$this->save_custom_field($time, 'checkin_time', $id);
796 796
 		}
797 797
 
798
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_out_time'] ) ) {
799
-			$time = str_replace( 'h', ':', $data[0]['features']['check_out_time'] );
800
-			$time = date( 'h:ia', strtotime( $time ) );
801
-			$this->save_custom_field( $time, 'checkout_time', $id );
798
+		if (!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])) {
799
+			$time = str_replace('h', ':', $data[0]['features']['check_out_time']);
800
+			$time = date('h:ia', strtotime($time));
801
+			$this->save_custom_field($time, 'checkout_time', $id);
802 802
 		}
803 803
 	}
804 804
 
805 805
 	/**
806 806
 	 * Set the Facilities
807 807
 	 */
808
-	public function set_facilities( $data, $id ) {
808
+	public function set_facilities($data, $id) {
809 809
 		$parent_facilities = array(
810 810
 			'available_services'  => 'Available Services',
811 811
 			'property_facilities' => 'Property Facilities',
@@ -813,15 +813,15 @@  discard block
 block discarded – undo
813 813
 			'activities_on_site'  => 'Activities on Site',
814 814
 		);
815 815
 
816
-		foreach ( $parent_facilities as $key => $label ) {
816
+		foreach ($parent_facilities as $key => $label) {
817 817
 			$terms = false;
818 818
 
819
-			if ( isset( $data[0]['features'] ) && isset( $data[0]['features'][ $key ] ) ) {
820
-				$parent_id = $this->set_term( $id, $label, 'facility' );
819
+			if (isset($data[0]['features']) && isset($data[0]['features'][$key])) {
820
+				$parent_id = $this->set_term($id, $label, 'facility');
821 821
 			}
822 822
 
823
-			foreach ( $data[0]['features'][ $key ] as $child_facility ) {
824
-				$this->set_term( $id, $child_facility, 'facility', $parent_id );
823
+			foreach ($data[0]['features'][$key] as $child_facility) {
824
+				$this->set_term($id, $child_facility, 'facility', $parent_id);
825 825
 			}
826 826
 		}
827 827
 	}
Please login to merge, or discard this patch.
classes/class-lsx-wetu-importer-connect-accommodation.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -35,17 +35,17 @@  discard block
 block discarded – undo
35 35
 	 * @access private
36 36
 	 */
37 37
 	public function __construct() {
38
-		$temp_options = get_option( '_lsx-to_settings', false );
38
+		$temp_options = get_option('_lsx-to_settings', false);
39 39
 
40
-		if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) {
41
-			$this->options = $temp_options[ $this->plugin_slug ];
40
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
41
+			$this->options = $temp_options[$this->plugin_slug];
42 42
 		}
43 43
 
44
-		$this->url = 'http://wetu.com/API/Pins/' . $this->options['api_key'] . '/List';
44
+		$this->url = 'http://wetu.com/API/Pins/'.$this->options['api_key'].'/List';
45 45
 
46
-		add_action( 'lsx_tour_importer_admin_tab_' . $this->tab_slug, array( $this, 'display_page' ) );
47
-		add_action( 'wp_ajax_lsx_import_connect_accommodation', array( $this, 'process_connection' ) );
48
-		add_action( 'wp_ajax_nopriv_lsx_import_connect_accommodation', array( $this, 'process_connection' ) );
46
+		add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page'));
47
+		add_action('wp_ajax_lsx_import_connect_accommodation', array($this, 'process_connection'));
48
+		add_action('wp_ajax_nopriv_lsx_import_connect_accommodation', array($this, 'process_connection'));
49 49
 	}
50 50
 
51 51
 	/**
@@ -55,46 +55,46 @@  discard block
 block discarded – undo
55 55
 		global $post;
56 56
 		?>
57 57
 		<div class="wrap">
58
-			<h3><span class="dashicons dashicons-admin-multisite"></span> <?php esc_html_e( 'Connect your Accommodation', 'lsx-wetu-importer' ); ?></h3>
58
+			<h3><span class="dashicons dashicons-admin-multisite"></span> <?php esc_html_e('Connect your Accommodation', 'lsx-wetu-importer'); ?></h3>
59 59
 
60 60
 			<form method="get" action="" id="connect-accommodation-filter">
61
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
61
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" />
62 62
 
63
-				<p><?php esc_html_e( 'Below is a list of your accommodation that does not contain a WETU ID, but its Title matches a name in the WETU DB. Connecting it will all you to pull through information from WETU.', 'lsx-wetu-importer' ); ?></p>
63
+				<p><?php esc_html_e('Below is a list of your accommodation that does not contain a WETU ID, but its Title matches a name in the WETU DB. Connecting it will all you to pull through information from WETU.', 'lsx-wetu-importer'); ?></p>
64 64
 
65 65
 				<div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
66
-					<img style="width:32px;" src="<?php echo esc_url( LSX_WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" />
66
+					<img style="width:32px;" src="<?php echo esc_url(LSX_WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" />
67 67
 				</div>
68 68
 
69 69
 				<?php
70 70
 					$loose_accommodation = $this->find_current_accommodation();
71 71
 				?>
72
-				<p><input class="button button-primary connect" type="button" value="<?php esc_html_e( 'Connect', 'lsx-wetu-importer' ); ?>" /></p>
72
+				<p><input class="button button-primary connect" type="button" value="<?php esc_html_e('Connect', 'lsx-wetu-importer'); ?>" /></p>
73 73
 				<table class="wp-list-table widefat fixed posts">
74 74
 					<?php $this->table_header(); ?>
75 75
 
76 76
 					<tbody>
77 77
 						<?php
78
-						if ( false !== $loose_accommodation ) {
78
+						if (false !== $loose_accommodation) {
79 79
 
80
-							$loose_args                = array(
80
+							$loose_args = array(
81 81
 								'post_type'   => 'accommodation',
82
-								'post_status' => array( 'publish', 'pending' ),
82
+								'post_status' => array('publish', 'pending'),
83 83
 								'nopagin'     => true,
84 84
 								'post__in'    => $loose_accommodation,
85 85
 							);
86
-							$loose_accommodation_query = new WP_Query( $loose_args );
87
-							$accommodation             = get_transient( 'lsx_ti_accommodation' );
86
+							$loose_accommodation_query = new WP_Query($loose_args);
87
+							$accommodation             = get_transient('lsx_ti_accommodation');
88 88
 							$identifier                = '';
89 89
 
90
-							if ( $loose_accommodation_query->have_posts() && false !== $accommodation ) {
91
-								while ( $loose_accommodation_query->have_posts() ) {
90
+							if ($loose_accommodation_query->have_posts() && false !== $accommodation) {
91
+								while ($loose_accommodation_query->have_posts()) {
92 92
 									$loose_accommodation_query->the_post();
93 93
 
94
-									foreach ( $accommodation as $row_key => $row ) {
95
-										if ( stripos( ltrim( rtrim( $row->name ) ), $post->post_title ) !== false ) {
94
+									foreach ($accommodation as $row_key => $row) {
95
+										if (stripos(ltrim(rtrim($row->name)), $post->post_title) !== false) {
96 96
 											$identifier = $row->id;
97
-										} else {
97
+										}else {
98 98
 											continue;
99 99
 										}
100 100
 									}
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
 									<tr class="post-<?php the_ID(); ?> type-accommodation status-none" id="post-<?php the_ID(); ?>">
103 103
 										<th class="check-column" scope="row">
104 104
 											<label for="cb-select-<?php the_ID(); ?>" class="screen-reader-text"><?php the_title(); ?></label>
105
-											<input type="checkbox" data-identifier="<?php echo esc_attr( $identifier ); ?>" value="<?php the_ID(); ?>" name="post[]" id="cb-select-<?php the_ID(); ?>">
105
+											<input type="checkbox" data-identifier="<?php echo esc_attr($identifier); ?>" value="<?php the_ID(); ?>" name="post[]" id="cb-select-<?php the_ID(); ?>">
106 106
 										</th>
107 107
 										<td class="post-title page-title column-title">
108
-											<strong><?php the_title(); ?></strong> - <a href="<?php echo esc_url( admin_url( '/post.php?post=' . $post->ID . '&action=edit' ) ); ?>" target="_blank"><?php echo esc_html( $post->post_status ); ?></a>
108
+											<strong><?php the_title(); ?></strong> - <a href="<?php echo esc_url(admin_url('/post.php?post='.$post->ID.'&action=edit')); ?>" target="_blank"><?php echo esc_html($post->post_status); ?></a>
109 109
 										</td>
110 110
 										<td class="excerpt column-excerpt">
111 111
 											<?php
112
-												echo wp_kses_post( strip_tags( get_the_excerpt() ) );
112
+												echo wp_kses_post(strip_tags(get_the_excerpt()));
113 113
 											?>
114 114
 										</td>
115 115
 									</tr>
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 
125 125
 				</table>
126 126
 
127
-				<p><input class="button button-primary connect" type="button" value="<?php esc_html_e( 'Connect', 'lsx-wetu-importer' ); ?>" /></p>
127
+				<p><input class="button button-primary connect" type="button" value="<?php esc_html_e('Connect', 'lsx-wetu-importer'); ?>" /></p>
128 128
 
129 129
 			</form>
130 130
 
131 131
 			<div style="display:none;" class="completed-list-wrapper">
132
-				<h3><?php esc_html_e( 'Completed' ); ?></h3>
132
+				<h3><?php esc_html_e('Completed'); ?></h3>
133 133
 				<ul>
134 134
 				</ul>
135 135
 			</div>
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
 			ARRAY_A
207 207
 		);
208 208
 
209
-		if ( null !== $all_accommodation && ! empty( $all_accommodation ) ) {
209
+		if (null !== $all_accommodation && !empty($all_accommodation)) {
210 210
 			// remove the extra accommodation
211
-			if ( null !== $current_accommodation && ! empty( $current_accommodation ) ) {
212
-				$all_accommodation = array_diff( $this->format_array( $all_accommodation, 'ID' ), $this->format_array( $current_accommodation, 'post_id' ) );
213
-			} elseif ( null !== $current_accommodation && empty( $current_accommodation ) ) {
214
-				$all_accommodation = $this->format_array( $current_accommodation, 'post_id' );
211
+			if (null !== $current_accommodation && !empty($current_accommodation)) {
212
+				$all_accommodation = array_diff($this->format_array($all_accommodation, 'ID'), $this->format_array($current_accommodation, 'post_id'));
213
+			} elseif (null !== $current_accommodation && empty($current_accommodation)) {
214
+				$all_accommodation = $this->format_array($current_accommodation, 'post_id');
215 215
 			}
216 216
 
217 217
 			$return = $all_accommodation;
@@ -223,11 +223,11 @@  discard block
 block discarded – undo
223 223
 	/**
224 224
 	 * format the array
225 225
 	 */
226
-	public function format_array( $array, $key ) {
226
+	public function format_array($array, $key) {
227 227
 		$new_array = array();
228 228
 
229
-		foreach ( $array as $value ) {
230
-			$new_array[] = $value[ $key ];
229
+		foreach ($array as $value) {
230
+			$new_array[] = $value[$key];
231 231
 		}
232 232
 
233 233
 		return $new_array;
@@ -238,18 +238,18 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	public function process_connection() {
240 240
 		$return = false;
241
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
242
-		if ( isset( $_POST['action'] ) && 'lsx_import_connect_accommodation' === $_POST['action'] && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug && isset( $_POST['post_id'] ) && isset( $_POST['wetu_id'] ) ) {
241
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
242
+		if (isset($_POST['action']) && 'lsx_import_connect_accommodation' === $_POST['action'] && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['post_id']) && isset($_POST['wetu_id'])) {
243 243
 			$post_id     = false;
244 244
 			$matching_id = false;
245
-			$post_id     = sanitize_text_field( $_POST['post_id'] );
246
-			$matching_id = sanitize_text_field( $_POST['wetu_id'] );
245
+			$post_id     = sanitize_text_field($_POST['post_id']);
246
+			$matching_id = sanitize_text_field($_POST['wetu_id']);
247 247
 
248
-			add_post_meta( $post_id, 'lsx_wetu_id', $matching_id );
249
-			$return = '<li class="post-' . $post_id . '"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="' . get_permalink( $post_id ) . '">' . get_the_title( $post_id ) . '</a></li>';
248
+			add_post_meta($post_id, 'lsx_wetu_id', $matching_id);
249
+			$return = '<li class="post-'.$post_id.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($post_id).'">'.get_the_title($post_id).'</a></li>';
250 250
 		}
251 251
 
252
-		print_r( $return );
252
+		print_r($return);
253 253
 		die();
254 254
 	}
255 255
 
Please login to merge, or discard this patch.
classes/class-lsx-wetu-importer-post-columns.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 	 * @access private
30 30
 	 */
31 31
 	public function __construct() {
32
-		add_filter( 'manage_tour_posts_columns', array( $this, 'register_tour_columns' ) );
33
-		add_action( 'manage_tour_posts_custom_column', array( $this, 'output_tour_ref_column' ), 10, 2 );
32
+		add_filter('manage_tour_posts_columns', array($this, 'register_tour_columns'));
33
+		add_action('manage_tour_posts_custom_column', array($this, 'output_tour_ref_column'), 10, 2);
34 34
 
35 35
 		// Sortables Columns, sorting needs to be fixed
36 36
 		// add_filter( 'manage_edit-tour_sortable_columns', array( $this, 'register_sortable_columns' ) );
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	public static function get_instance() {
46 46
 		// If the single instance hasn't been set, set it now.
47
-		if ( ! isset( self::$instance ) ) {
47
+		if (!isset(self::$instance)) {
48 48
 			self::$instance = new self();
49 49
 		}
50 50
 		return self::$instance;
@@ -63,16 +63,16 @@  discard block
 block discarded – undo
63 63
 	 * @param array $columns
64 64
 	 * @return array
65 65
 	 */
66
-	public function register_tour_columns( $columns ) {
66
+	public function register_tour_columns($columns) {
67 67
 		$new_columns = array(
68 68
 			'cb'       => $columns['cb'],
69 69
 			'title'    => $columns['title'],
70
-			'wetu_ref' => __( 'Ref', 'lsx-wetu-importer' ),
70
+			'wetu_ref' => __('Ref', 'lsx-wetu-importer'),
71 71
 		);
72
-		unset( $columns['cb'] );
73
-		unset( $columns['title'] );
74
-		foreach ( $columns as $column_key => $column_label ) {
75
-			$new_columns[ $column_key ] = $column_label;
72
+		unset($columns['cb']);
73
+		unset($columns['title']);
74
+		foreach ($columns as $column_key => $column_label) {
75
+			$new_columns[$column_key] = $column_label;
76 76
 		}
77 77
 		$columns = $new_columns;
78 78
 		return $columns;
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	 * @param string $post_id
86 86
 	 * @return void
87 87
 	 */
88
-	public function output_tour_ref_column( $column, $post_id ) {
89
-		if ( 'wetu_ref' === $column ) {
90
-			echo esc_attr( get_post_meta( $post_id, 'lsx_wetu_ref', true ) );
88
+	public function output_tour_ref_column($column, $post_id) {
89
+		if ('wetu_ref' === $column) {
90
+			echo esc_attr(get_post_meta($post_id, 'lsx_wetu_ref', true));
91 91
 		}
92 92
 	}
93 93
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @param array $columns
98 98
 	 * @return array
99 99
 	 */
100
-	public function register_sortable_columns( $columns = array() ) {
100
+	public function register_sortable_columns($columns = array()) {
101 101
 		$columns['wetu_ref'] = 'price_per_month';
102 102
 		return $columns;
103 103
 	}
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
 	 * @param object $query WP_Query()
109 109
 	 * @return void
110 110
 	 */
111
-	public function columns_posts_orderby( $query ) {
112
-		if ( ! is_admin() || ! $query->is_main_query() ) {
111
+	public function columns_posts_orderby($query) {
112
+		if (!is_admin() || !$query->is_main_query()) {
113 113
 			return;
114 114
 		}
115
-		if ( 'wetu_ref' === $query->get( 'orderby' ) ) {
116
-			$query->set( 'orderby', 'meta_value' );
117
-			$query->set( 'meta_key', 'lsx_wetu_reference' );
115
+		if ('wetu_ref' === $query->get('orderby')) {
116
+			$query->set('orderby', 'meta_value');
117
+			$query->set('meta_key', 'lsx_wetu_reference');
118 118
 		}
119 119
 		/*
120 120
 		if ( $query->is_search() && 'tour' === $query->get( 'post_type' ) ) {
Please login to merge, or discard this patch.
classes/class-lsx-wetu-importer.php 1 patch
Spacing   +367 added lines, -367 removed lines patch added patch discarded remove patch
@@ -197,40 +197,40 @@  discard block
 block discarded – undo
197 197
 	 * @access private
198 198
 	 */
199 199
 	public function __construct() {
200
-		add_action( 'admin_init', array( $this, 'compatible_version_check' ) );
201
-		require_once LSX_WETU_IMPORTER_PATH . 'includes/helpers.php';
200
+		add_action('admin_init', array($this, 'compatible_version_check'));
201
+		require_once LSX_WETU_IMPORTER_PATH.'includes/helpers.php';
202 202
 
203 203
 		// Don't run anything else in the plugin, if we're on an incompatible PHP version.
204
-		if ( ! self::compatible_version() ) {
204
+		if (!self::compatible_version()) {
205 205
 			return;
206 206
 		}
207 207
 
208 208
 		$this->set_variables();
209 209
 
210
-		add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
211
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 11 );
212
-		add_action( 'admin_menu', array( $this, 'register_importer_page' ), 20 );
210
+		add_action('init', array($this, 'load_plugin_textdomain'));
211
+		add_action('admin_enqueue_scripts', array($this, 'admin_scripts'), 11);
212
+		add_action('admin_menu', array($this, 'register_importer_page'), 20);
213 213
 
214
-		require_once LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer-welcome.php';
215
-		require_once LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer-accommodation.php';
216
-		require_once LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer-destination.php';
217
-		require_once LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer-tours.php';
218
-		require_once LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer-settings.php';
219
-		require_once LSX_WETU_IMPORTER_PATH . 'classes/class-cron.php';
214
+		require_once LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer-welcome.php';
215
+		require_once LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer-accommodation.php';
216
+		require_once LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer-destination.php';
217
+		require_once LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer-tours.php';
218
+		require_once LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer-settings.php';
219
+		require_once LSX_WETU_IMPORTER_PATH.'classes/class-cron.php';
220 220
 
221
-		if ( isset( $this->options ) && isset( $this->options['enable_tour_ref_column'] ) && '' !== $this->options['enable_tour_ref_column'] ) {
222
-			require_once LSX_WETU_IMPORTER_PATH . 'classes/class-lsx-wetu-importer-post-columns.php';
221
+		if (isset($this->options) && isset($this->options['enable_tour_ref_column']) && '' !== $this->options['enable_tour_ref_column']) {
222
+			require_once LSX_WETU_IMPORTER_PATH.'classes/class-lsx-wetu-importer-post-columns.php';
223 223
 			$this->post_columns = LSX_WETU_Importer_Post_Columns::get_instance();
224 224
 		}
225 225
 
226
-		add_action( 'init', array( $this, 'load_class' ) );
226
+		add_action('init', array($this, 'load_class'));
227 227
 
228
-		if ( 'default' !== $this->tab_slug ) {
229
-			add_action( 'wp_ajax_lsx_tour_importer', array( $this, 'process_ajax_search' ) );
230
-			add_action( 'wp_ajax_nopriv_lsx_tour_importer', array( $this, 'process_ajax_search' ) );
228
+		if ('default' !== $this->tab_slug) {
229
+			add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search'));
230
+			add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search'));
231 231
 
232
-			add_action( 'wp_ajax_lsx_import_items', array( $this, 'process_ajax_import' ) );
233
-			add_action( 'wp_ajax_nopriv_lsx_import_items', array( $this, 'process_ajax_import' ) );
232
+			add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import'));
233
+			add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import'));
234 234
 		}
235 235
 	}
236 236
 
@@ -240,21 +240,21 @@  discard block
 block discarded – undo
240 240
 	 * @since 1.0.0
241 241
 	 */
242 242
 	public function load_plugin_textdomain() {
243
-		load_plugin_textdomain( 'lsx-wetu-importer', false, basename( LSX_WETU_IMPORTER_PATH ) . '/languages' );
243
+		load_plugin_textdomain('lsx-wetu-importer', false, basename(LSX_WETU_IMPORTER_PATH).'/languages');
244 244
 	}
245 245
 
246 246
 	/**
247 247
 	 * Sets the variables used throughout the plugin.
248 248
 	 */
249 249
 	public function set_variables() {
250
-		$this->post_types = array( 'accommodation', 'destination', 'tour' );
250
+		$this->post_types = array('accommodation', 'destination', 'tour');
251 251
 		$options          = lsx_wetu_get_options();
252 252
 
253 253
 		// Set the options.
254 254
 		$this->options = $options;
255 255
 
256
-		$temp_options = get_option( '_lsx-to_settings', false );
257
-		if ( false !== $temp_options ) {
256
+		$temp_options = get_option('_lsx-to_settings', false);
257
+		if (false !== $temp_options) {
258 258
 			$this->accommodation_settings = $temp_options['accommodation'];
259 259
 			$this->tour_settings          = $temp_options['tour'];
260 260
 			$this->destination_settings   = $temp_options['destination'];
@@ -262,51 +262,51 @@  discard block
 block discarded – undo
262 262
 
263 263
 		$this->api_key = false;
264 264
 
265
-		if ( ! defined( 'WETU_API_KEY' ) ) {
266
-			if ( isset( $options['api_key'] ) && '' !== $options['api_key'] ) {
265
+		if (!defined('WETU_API_KEY')) {
266
+			if (isset($options['api_key']) && '' !== $options['api_key']) {
267 267
 				$this->api_key = $options['api_key'];
268 268
 			}
269
-		} else {
269
+		}else {
270 270
 			$this->api_key = WETU_API_KEY;
271 271
 		}
272 272
 
273 273
 		// Set the tab slug.
274 274
 		// @codingStandardsIgnoreLine
275
-		if ( isset( $_GET['tab'] ) || ( defined( 'DOING_AJAX' ) && isset( $_POST['type'] ) ) ) {
276
-			if ( isset( $_GET['tab'] ) ) {
277
-				$this->tab_slug = sanitize_text_field( $_GET['tab'] );
278
-			} else {
275
+		if (isset($_GET['tab']) || (defined('DOING_AJAX') && isset($_POST['type']))) {
276
+			if (isset($_GET['tab'])) {
277
+				$this->tab_slug = sanitize_text_field($_GET['tab']);
278
+			}else {
279 279
 				// @codingStandardsIgnoreLine
280
-				$this->tab_slug = sanitize_text_field( $_POST['type'] );
280
+				$this->tab_slug = sanitize_text_field($_POST['type']);
281 281
 			}
282 282
 		}
283 283
 
284 284
 		// If any tours were queued.
285
-		$this->queued_imports = get_option( 'lsx_wetu_importer_que', array() );
285
+		$this->queued_imports = get_option('lsx_wetu_importer_que', array());
286 286
 
287 287
 		// Set the scaling options.
288
-		if ( isset( $this->options ) && isset( $this->options['image_scaling'] ) ) {
288
+		if (isset($this->options) && isset($this->options['image_scaling'])) {
289 289
 			$this->scale_images = true;
290 290
 
291 291
 			$width = '1024';
292
-			if ( isset( $this->options['width'] ) && '' !== $this->options['width'] ) {
292
+			if (isset($this->options['width']) && '' !== $this->options['width']) {
293 293
 				$width = $this->options['width'];
294 294
 			}
295 295
 
296 296
 			$height = '768';
297
-			if ( isset( $this->options['height'] ) && '' !== $this->options['height'] ) {
297
+			if (isset($this->options['height']) && '' !== $this->options['height']) {
298 298
 				$height = $this->options['height'];
299 299
 			}
300 300
 
301 301
 			$cropping = 'w';
302
-			if ( isset( $this->options['cropping'] ) && '' !== $this->options['cropping'] ) {
302
+			if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
303 303
 				$cropping = $this->options['cropping'];
304 304
 			}
305 305
 
306
-			$this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
306
+			$this->image_scaling_url = 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/';
307 307
 		}
308 308
 
309
-		if ( isset( $this->options ) && isset( $this->options['image_limit'] ) && '' !== $this->options['image_limit'] ) {
309
+		if (isset($this->options) && isset($this->options['image_limit']) && '' !== $this->options['image_limit']) {
310 310
 			$this->image_limit = $this->options['image_limit'];
311 311
 		}
312 312
 	}
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	 * @since 1.0.0
329 329
 	 */
330 330
 	public static function compatible_version() {
331
-		if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
331
+		if (version_compare(PHP_VERSION, '5.6', '<')) {
332 332
 			return false;
333 333
 		}
334 334
 
@@ -342,13 +342,13 @@  discard block
 block discarded – undo
342 342
 	 * @since 1.0.0
343 343
 	 */
344 344
 	public function compatible_version_check() {
345
-		if ( ! self::compatible_version() ) {
346
-			if ( is_plugin_active( plugin_basename( LSX_WETU_IMPORTER_CORE ) ) ) {
347
-				deactivate_plugins( plugin_basename( LSX_WETU_IMPORTER_CORE ) );
348
-				add_action( 'admin_notices', array( $this, 'compatible_version_notice' ) );
345
+		if (!self::compatible_version()) {
346
+			if (is_plugin_active(plugin_basename(LSX_WETU_IMPORTER_CORE))) {
347
+				deactivate_plugins(plugin_basename(LSX_WETU_IMPORTER_CORE));
348
+				add_action('admin_notices', array($this, 'compatible_version_notice'));
349 349
 
350
-				if ( isset( $_GET['activate'] ) ) {
351
-					unset( $_GET['activate'] );
350
+				if (isset($_GET['activate'])) {
351
+					unset($_GET['activate']);
352 352
 				}
353 353
 			}
354 354
 		}
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
 	 */
362 362
 	public function compatible_version_notice() {
363 363
 		$class   = 'notice notice-error';
364
-		$message = esc_html__( 'LSX Importer for Wetu Plugin requires PHP 5.6 or higher.', 'lsx-wetu-importer' );
365
-		printf( '<div class="%1$s"><p>%2$s</p></div>', esc_html( $class ), esc_html( $message ) );
364
+		$message = esc_html__('LSX Importer for Wetu Plugin requires PHP 5.6 or higher.', 'lsx-wetu-importer');
365
+		printf('<div class="%1$s"><p>%2$s</p></div>', esc_html($class), esc_html($message));
366 366
 	}
367 367
 
368 368
 	/**
@@ -372,9 +372,9 @@  discard block
 block discarded – undo
372 372
 	 * @since 1.0.0
373 373
 	 */
374 374
 	public static function compatible_version_check_on_activation() {
375
-		if ( ! self::compatible_version() ) {
376
-			deactivate_plugins( plugin_basename( LSX_WETU_IMPORTER_CORE ) );
377
-			wp_die( esc_html__( 'LSX Importer for Wetu Plugin requires PHP 5.6 or higher.', 'lsx-wetu-importer' ) );
375
+		if (!self::compatible_version()) {
376
+			deactivate_plugins(plugin_basename(LSX_WETU_IMPORTER_CORE));
377
+			wp_die(esc_html__('LSX Importer for Wetu Plugin requires PHP 5.6 or higher.', 'lsx-wetu-importer'));
378 378
 		}
379 379
 	}
380 380
 
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 	 * Load the importer class you want to use
385 385
 	 */
386 386
 	public function load_class() {
387
-		switch ( $this->tab_slug ) {
387
+		switch ($this->tab_slug) {
388 388
 			case 'accommodation':
389 389
 				$this->current_importer = new LSX_WETU_Importer_Accommodation();
390 390
 				break;
@@ -411,36 +411,36 @@  discard block
 block discarded – undo
411 411
 	 * Registers the admin page which will house the importer form.
412 412
 	 */
413 413
 	public function register_importer_page() {
414
-		add_submenu_page( 'tour-operator', esc_html__( 'Importer', 'tour-operator' ), esc_html__( 'Importer', 'tour-operator' ), 'manage_options', 'lsx-wetu-importer', array( $this, 'display_page' ) );
414
+		add_submenu_page('tour-operator', esc_html__('Importer', 'tour-operator'), esc_html__('Importer', 'tour-operator'), 'manage_options', 'lsx-wetu-importer', array($this, 'display_page'));
415 415
 	}
416 416
 
417 417
 	/**
418 418
 	 * Enqueue the JS needed to contact wetu and return your result.
419 419
 	 */
420 420
 	public function admin_scripts() {
421
-		if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) {
421
+		if (defined('WP_DEBUG') && true === WP_DEBUG) {
422 422
 			$min = '';
423
-		} else {
423
+		}else {
424 424
 			$min = '.min';
425 425
 		}
426 426
 
427 427
 		$min = '';
428 428
 
429
-		if ( is_admin() && isset( $_GET['page'] ) && $this->plugin_slug === $_GET['page'] ) {
429
+		if (is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']) {
430 430
 
431 431
 			// wp_enqueue_style( 'datatables', LSX_WETU_IMPORTER_URL . 'assets/css/datatables' . $min . '.css', LSX_WETU_IMPORTER_VER, true );
432
-			wp_enqueue_style( 'lsx-wetu-importer-style', LSX_WETU_IMPORTER_URL . 'assets/css/lsx-wetu-importer.css', LSX_WETU_IMPORTER_VER, true );
432
+			wp_enqueue_style('lsx-wetu-importer-style', LSX_WETU_IMPORTER_URL.'assets/css/lsx-wetu-importer.css', LSX_WETU_IMPORTER_VER, true);
433 433
 
434
-			if ( isset( $_GET['tab'] ) ) {
435
-				wp_enqueue_script( 'datatables', LSX_WETU_IMPORTER_URL . 'assets/js/datatables' . $min . '.js', array( 'jquery' ), LSX_WETU_IMPORTER_VER, true );
436
-				wp_enqueue_script( 'lsx-wetu-importers-script', LSX_WETU_IMPORTER_URL . 'assets/js/lsx-wetu-importer' . $min . '.js', array( 'jquery', 'datatables' ), LSX_WETU_IMPORTER_VER, true );
434
+			if (isset($_GET['tab'])) {
435
+				wp_enqueue_script('datatables', LSX_WETU_IMPORTER_URL.'assets/js/datatables'.$min.'.js', array('jquery'), LSX_WETU_IMPORTER_VER, true);
436
+				wp_enqueue_script('lsx-wetu-importers-script', LSX_WETU_IMPORTER_URL.'assets/js/lsx-wetu-importer'.$min.'.js', array('jquery', 'datatables'), LSX_WETU_IMPORTER_VER, true);
437 437
 
438 438
 				wp_localize_script(
439 439
 					'lsx-wetu-importers-script',
440 440
 					'lsx_tour_importer_params',
441 441
 					array(
442
-						'ajax_url'   => admin_url( 'admin-ajax.php' ),
443
-						'ajax_nonce' => wp_create_nonce( 'lsx_wetu_ajax_action' ),
442
+						'ajax_url'   => admin_url('admin-ajax.php'),
443
+						'ajax_nonce' => wp_create_nonce('lsx_wetu_ajax_action'),
444 444
 					)
445 445
 				);
446 446
 			}
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
 		?>
455 455
 		<div class="wrap">
456 456
 			<?php
457
-			$this->navigation( $this->tab_slug );
458
-			if ( 'default' !== $this->tab_slug && 'settings' !== $this->tab_slug ) {
457
+			$this->navigation($this->tab_slug);
458
+			if ('default' !== $this->tab_slug && 'settings' !== $this->tab_slug) {
459 459
 				$this->wetu_status();
460 460
 				$this->post_status_navigation();
461 461
 			}
@@ -473,18 +473,18 @@  discard block
 block discarded – undo
473 473
 	public function post_status_navigation() {
474 474
 		?>
475 475
 		<ul class="subsubsub">
476
-			<li class="searchform"><a class="current" href="#search"><?php esc_attr_e( 'Search', 'lsx-wetu-importer' ); ?></a> | </li>
477
-			<li class="publish"><a href="#publish"><?php esc_attr_e( 'Published', 'lsx-wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( lsx_wetu_get_post_count( $this->tab_slug, 'publish ' ) ); ?>)</span></a> | </li>
478
-			<li class="pending"><a href="#pending"><?php esc_attr_e( 'Pending', 'lsx-wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( lsx_wetu_get_post_count( $this->tab_slug, 'pending ' ) ); ?>)</span></a>| </li>
479
-			<li class="draft"><a href="#draft"><?php esc_attr_e( 'Draft', 'lsx-wetu-importer' ); ?></a> <span class="count"> (<?php echo esc_attr( lsx_wetu_get_post_count( $this->tab_slug, 'draft ' ) ); ?>)</span></li>
480
-
481
-			<?php if ( 'tour' === $this->tab_slug ) { ?>
482
-				<li class="import"> | <a class="import search-toggle"  href="#import"><?php esc_attr_e( 'WETU', 'lsx-wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( lsx_wetu_get_tour_count() ); ?>)</span></a></li>
483
-			<?php } elseif ( ! empty( $this->queued_imports ) ) { ?>
484
-				<li class="import"> | <a class="import search-toggle"  href="#import"><?php esc_attr_e( 'WETU Queue', 'lsx-wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( lsx_wetu_get_queue_count( $this->tab_slug ) ); ?>)</span></a></li>
476
+			<li class="searchform"><a class="current" href="#search"><?php esc_attr_e('Search', 'lsx-wetu-importer'); ?></a> | </li>
477
+			<li class="publish"><a href="#publish"><?php esc_attr_e('Published', 'lsx-wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(lsx_wetu_get_post_count($this->tab_slug, 'publish ')); ?>)</span></a> | </li>
478
+			<li class="pending"><a href="#pending"><?php esc_attr_e('Pending', 'lsx-wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(lsx_wetu_get_post_count($this->tab_slug, 'pending ')); ?>)</span></a>| </li>
479
+			<li class="draft"><a href="#draft"><?php esc_attr_e('Draft', 'lsx-wetu-importer'); ?></a> <span class="count"> (<?php echo esc_attr(lsx_wetu_get_post_count($this->tab_slug, 'draft ')); ?>)</span></li>
480
+
481
+			<?php if ('tour' === $this->tab_slug) { ?>
482
+				<li class="import"> | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU', 'lsx-wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(lsx_wetu_get_tour_count()); ?>)</span></a></li>
483
+			<?php } elseif (!empty($this->queued_imports)) { ?>
484
+				<li class="import"> | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU Queue', 'lsx-wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(lsx_wetu_get_queue_count($this->tab_slug)); ?>)</span></a></li>
485 485
 			<?php } ?>
486 486
 		</ul>
487
-		<a class="documentation" target="_blank"href="https://tour-operator.lsdev.biz/documentation/extension/wetu-importer/"><?php esc_attr_e( 'Documentation', 'lsx-wetu-importer' ); ?></a>
487
+		<a class="documentation" target="_blank"href="https://tour-operator.lsdev.biz/documentation/extension/wetu-importer/"><?php esc_attr_e('Documentation', 'lsx-wetu-importer'); ?></a>
488 488
 		<?php
489 489
 	}
490 490
 
@@ -493,29 +493,29 @@  discard block
 block discarded – undo
493 493
 	 */
494 494
 	public function search_form() {
495 495
 		?>
496
-		<form class="ajax-form" id="<?php echo esc_attr( $this->plugin_slug ); ?>-search-form" method="get" action="tools.php" data-type="<?php echo esc_attr( $this->tab_slug ); ?>">
497
-			<input type="hidden" name="page" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
496
+		<form class="ajax-form" id="<?php echo esc_attr($this->plugin_slug); ?>-search-form" method="get" action="tools.php" data-type="<?php echo esc_attr($this->tab_slug); ?>">
497
+			<input type="hidden" name="page" value="<?php echo esc_attr($this->tab_slug); ?>" />
498 498
 
499
-			<?php do_action( 'lsx_wetu_importer_search_form', $this ); ?>
499
+			<?php do_action('lsx_wetu_importer_search_form', $this); ?>
500 500
 
501 501
 			<div class="normal-search">
502
-				<input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php esc_html_e( 'Search', 'lsx-wetu-importer' ); ?>" />
502
+				<input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php esc_html_e('Search', 'lsx-wetu-importer'); ?>" />
503 503
 			</div>
504 504
 
505 505
 			<div class="advanced-search hidden" style="display:none;">
506 506
 				<textarea rows="10" cols="40" name="bulk-keywords"></textarea>
507
-				<input class="button button-primary submit" type="submit" value="<?php esc_attr_e( 'Search', 'lsx-wetu-importer' ); ?>" />
507
+				<input class="button button-primary submit" type="submit" value="<?php esc_attr_e('Search', 'lsx-wetu-importer'); ?>" />
508 508
 			</div>
509 509
 
510 510
 			<div class="ajax-loader" style="display:none;width:100%;text-align:center;">
511
-				<img style="width:64px;" src="<?php echo esc_url( LSX_WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" />
511
+				<img style="width:64px;" src="<?php echo esc_url(LSX_WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" />
512 512
 			</div>
513 513
 
514 514
 			<div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
515
-				<img style="width:32px;" src="<?php echo esc_url( LSX_WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" />
515
+				<img style="width:32px;" src="<?php echo esc_url(LSX_WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" />
516 516
 			</div>
517 517
 
518
-			<a class="button advanced-search-toggle" href="#"><?php esc_html_e( 'Bulk Search', 'lsx-wetu-importer' ); ?></a>
518
+			<a class="button advanced-search-toggle" href="#"><?php esc_html_e('Bulk Search', 'lsx-wetu-importer'); ?></a>
519 519
 		</form>
520 520
 		<?php
521 521
 	}
@@ -528,13 +528,13 @@  discard block
 block discarded – undo
528 528
 		<thead>
529 529
 		<tr>
530 530
 			<th style="" class="manage-column column-cb check-column no-sort" id="cb" scope="col">
531
-				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'lsx-wetu-importer' ); ?></label>
531
+				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'lsx-wetu-importer'); ?></label>
532 532
 				<input type="checkbox" id="cb-select-all-1">
533 533
 			</th>
534
-			<th style="" class="manage-column column-order " id="order"><?php esc_attr_e( 'Order', 'lsx-wetu-importer' ); ?></th>
535
-			<th style="" class="manage-column column-title " id="title" style="width:50%;" scope="col"><?php esc_attr_e( 'Title', 'lsx-wetu-importer' ); ?></th>
536
-			<th style="" class="manage-column column-date" id="date" scope="col"><?php esc_attr_e( 'Date', 'lsx-wetu-importer' ); ?></th>
537
-			<th style="" class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'lsx-wetu-importer' ); ?></th>
534
+			<th style="" class="manage-column column-order " id="order"><?php esc_attr_e('Order', 'lsx-wetu-importer'); ?></th>
535
+			<th style="" class="manage-column column-title " id="title" style="width:50%;" scope="col"><?php esc_attr_e('Title', 'lsx-wetu-importer'); ?></th>
536
+			<th style="" class="manage-column column-date" id="date" scope="col"><?php esc_attr_e('Date', 'lsx-wetu-importer'); ?></th>
537
+			<th style="" class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e('WETU ID', 'lsx-wetu-importer'); ?></th>
538 538
 		</tr>
539 539
 		</thead>
540 540
 		<?php
@@ -548,13 +548,13 @@  discard block
 block discarded – undo
548 548
 		<tfoot>
549 549
 		<tr>
550 550
 			<th style="" class="manage-column column-cb check-column" id="cb" scope="col">
551
-				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'lsx-wetu-importer' ); ?></label>
551
+				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'lsx-wetu-importer'); ?></label>
552 552
 				<input type="checkbox" id="cb-select-all-1">
553 553
 			</th>
554
-			<th style="" class="manage-column column-order "><?php esc_attr_e( 'Order', 'lsx-wetu-importer' ); ?></th>
555
-			<th style="" class="manage-column column-title" scope="col"><?php esc_attr_e( 'Title', 'lsx-wetu-importer' ); ?></th>
556
-			<th style="" class="manage-column column-date" scope="col"><?php esc_attr_e( 'Date', 'lsx-wetu-importer' ); ?></th>
557
-			<th style="" class="manage-column column-ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'lsx-wetu-importer' ); ?></th>
554
+			<th style="" class="manage-column column-order "><?php esc_attr_e('Order', 'lsx-wetu-importer'); ?></th>
555
+			<th style="" class="manage-column column-title" scope="col"><?php esc_attr_e('Title', 'lsx-wetu-importer'); ?></th>
556
+			<th style="" class="manage-column column-date" scope="col"><?php esc_attr_e('Date', 'lsx-wetu-importer'); ?></th>
557
+			<th style="" class="manage-column column-ssid" scope="col"><?php esc_attr_e('WETU ID', 'lsx-wetu-importer'); ?></th>
558 558
 		</tr>
559 559
 		</tfoot>
560 560
 		<?php
@@ -565,42 +565,42 @@  discard block
 block discarded – undo
565 565
 	 *
566 566
 	 * @param $tab string
567 567
 	 */
568
-	public function navigation( $tab = '' ) {
568
+	public function navigation($tab = '') {
569 569
 		$post_types = array(
570
-			'tour'          => esc_attr( 'Tours', 'lsx-wetu-importer' ),
571
-			'accommodation' => esc_attr( 'Accommodation', 'lsx-wetu-importer' ),
572
-			'destination'   => esc_attr( 'Destinations', 'lsx-wetu-importer' ),
570
+			'tour'          => esc_attr('Tours', 'lsx-wetu-importer'),
571
+			'accommodation' => esc_attr('Accommodation', 'lsx-wetu-importer'),
572
+			'destination'   => esc_attr('Destinations', 'lsx-wetu-importer'),
573 573
 		);
574 574
 
575
-		echo wp_kses_post( '<div class="wp-filter">' );
576
-		echo wp_kses_post( '<ul class="filter-links">' );
577
-		echo wp_kses_post( '<li><a class="' . $this->itemd( $tab, 'default', 'current', false ) . '" href="' . admin_url( 'admin.php' ) . '?page=' . $this->plugin_slug . '">' . esc_attr__( 'Home', 'lsx-wetu-importer' ) . '</a></li>' );
575
+		echo wp_kses_post('<div class="wp-filter">');
576
+		echo wp_kses_post('<ul class="filter-links">');
577
+		echo wp_kses_post('<li><a class="'.$this->itemd($tab, 'default', 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'">'.esc_attr__('Home', 'lsx-wetu-importer').'</a></li>');
578 578
 
579
-		foreach ( $post_types as $post_type => $label ) {
580
-			echo wp_kses_post( ' | <li><a class="' . $this->itemd( $tab, $post_type, 'current', false ) . '" href="' . admin_url( 'admin.php' ) . '?page=' . $this->plugin_slug . '&tab=' . $post_type . '">' . $label . '</a></li>' );
579
+		foreach ($post_types as $post_type => $label) {
580
+			echo wp_kses_post(' | <li><a class="'.$this->itemd($tab, $post_type, 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a></li>');
581 581
 		}
582 582
 
583
-		echo wp_kses_post( ' | <li><a class="' . $this->itemd( $tab, 'settings', 'current', false ) . '" href="' . admin_url( 'admin.php' ) . '?page=' . $this->plugin_slug . '&tab=settings">' . esc_attr__( 'Settings', 'lsx-wetu-importer' ) . '</a></li>' );
584
-		echo wp_kses_post( '</ul> </div>' );
583
+		echo wp_kses_post(' | <li><a class="'.$this->itemd($tab, 'settings', 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=settings">'.esc_attr__('Settings', 'lsx-wetu-importer').'</a></li>');
584
+		echo wp_kses_post('</ul> </div>');
585 585
 	}
586 586
 
587 587
 	/**
588 588
 	 * Wetu Status Bar.
589 589
 	 */
590 590
 	public function wetu_status() {
591
-		$tours = get_transient( 'lsx_ti_tours' );
592
-		echo '<div class="wetu-status tour-wetu-status"><h3>' . esc_html__( 'Wetu Status', 'lsx-wetu-importer' ) . ' - ';
591
+		$tours = get_transient('lsx_ti_tours');
592
+		echo '<div class="wetu-status tour-wetu-status"><h3>'.esc_html__('Wetu Status', 'lsx-wetu-importer').' - ';
593 593
 
594
-		if ( '' === $tours || false === $tours || isset( $_GET['refresh_tours'] ) ) {
594
+		if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) {
595 595
 			$result = $this->update_options();
596
-			if ( true === $result ) {
597
-				echo '<span style="color:green;">' . esc_attr( 'Connected', 'lsx-wetu-importer' ) . '</span>';
598
-				echo ' - <small><a href="#">' . esc_attr( 'Refresh', 'lsx-wetu-importer' ) . '</a></small>';
599
-			} else {
600
-				echo '<span style="color:red;">' . wp_kses_post( $result ) . '</span>';
596
+			if (true === $result) {
597
+				echo '<span style="color:green;">'.esc_attr('Connected', 'lsx-wetu-importer').'</span>';
598
+				echo ' - <small><a href="#">'.esc_attr('Refresh', 'lsx-wetu-importer').'</a></small>';
599
+			}else {
600
+				echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
601 601
 			}
602
-		} else {
603
-			echo '<span style="color:green;">' . esc_attr( 'Connected', 'lsx-wetu-importer' ) . '</span> - <small><a href="#">' . esc_attr( 'Refresh', 'lsx-wetu-importer' ) . '</a></small>';
602
+		}else {
603
+			echo '<span style="color:green;">'.esc_attr('Connected', 'lsx-wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh', 'lsx-wetu-importer').'</a></small>';
604 604
 		}
605 605
 		echo '</h3>';
606 606
 		echo '</div>';
@@ -609,8 +609,8 @@  discard block
 block discarded – undo
609 609
 	/**
610 610
 	 * Set_taxonomy with some terms
611 611
 	 */
612
-	public function team_member_checkboxes( $selected = array() ) {
613
-		if ( post_type_exists( 'team' ) ) {
612
+	public function team_member_checkboxes($selected = array()) {
613
+		if (post_type_exists('team')) {
614 614
 			?>
615 615
 			<ul>
616 616
 				<?php
@@ -621,17 +621,17 @@  discard block
 block discarded – undo
621 621
 						'fields'      => 'ids',
622 622
 					);
623 623
 
624
-					$team_members = new WP_Query( $team_args );
624
+					$team_members = new WP_Query($team_args);
625 625
 
626
-					if ( $team_members->have_posts() ) {
627
-						foreach ( $team_members->posts as $member ) {
626
+					if ($team_members->have_posts()) {
627
+						foreach ($team_members->posts as $member) {
628 628
 							?>
629
-							<li><input class="team" <?php $this->checked( $selected, $member ); ?> type="checkbox" value="<?php echo esc_attr( $member ); ?>" /> <?php echo wp_kses_post( get_the_title( $member ) ); ?></li>
629
+							<li><input class="team" <?php $this->checked($selected, $member); ?> type="checkbox" value="<?php echo esc_attr($member); ?>" /> <?php echo wp_kses_post(get_the_title($member)); ?></li>
630 630
 							<?php
631 631
 						}
632
-					} else {
632
+					}else {
633 633
 						?>
634
-						<li><input class="team" type="checkbox" value="0" /> <?php esc_html_e( 'None', 'lsx-wetu-importer' ); ?></li>
634
+						<li><input class="team" type="checkbox" value="0" /> <?php esc_html_e('None', 'lsx-wetu-importer'); ?></li>
635 635
 						<?php
636 636
 					}
637 637
 					?>
@@ -650,13 +650,13 @@  discard block
 block discarded – undo
650 650
 	 * @param $needle string
651 651
 	 * @param $echo bool
652 652
 	 */
653
-	public function checked( $haystack = false, $needle = '', $echo = true ) {
654
-		$return = $this->itemd( $haystack, $needle, 'checked', false );
653
+	public function checked($haystack = false, $needle = '', $echo = true) {
654
+		$return = $this->itemd($haystack, $needle, 'checked', false);
655 655
 
656
-		if ( '' !== $return ) {
657
-			if ( true === $echo ) {
658
-				echo wp_kses_post( $return );
659
-			} else {
656
+		if ('' !== $return) {
657
+			if (true === $echo) {
658
+				echo wp_kses_post($return);
659
+			}else {
660 660
 				return $return;
661 661
 			}
662 662
 		}
@@ -669,13 +669,13 @@  discard block
 block discarded – undo
669 669
 	 * @param $needle string
670 670
 	 * @param $echo bool
671 671
 	 */
672
-	public function selected( $haystack = false, $needle = '', $echo = true ) {
673
-		$return = $this->itemd( $haystack, $needle, 'selected' );
672
+	public function selected($haystack = false, $needle = '', $echo = true) {
673
+		$return = $this->itemd($haystack, $needle, 'selected');
674 674
 
675
-		if ( '' !== $return ) {
676
-			if ( true === $echo ) {
677
-				echo wp_kses_post( $return );
678
-			} else {
675
+		if ('' !== $return) {
676
+			if (true === $echo) {
677
+				echo wp_kses_post($return);
678
+			}else {
679 679
 				return $return;
680 680
 			}
681 681
 		}
@@ -690,17 +690,17 @@  discard block
 block discarded – undo
690 690
 	 * @param $wrap bool
691 691
 	 * @return $html string
692 692
 	 */
693
-	public function itemd( $haystack = false, $needle = '', $type = '', $wrap = true ) {
693
+	public function itemd($haystack = false, $needle = '', $type = '', $wrap = true) {
694 694
 		$html = '';
695 695
 
696
-		if ( '' !== $type ) {
697
-			if ( ! is_array( $haystack ) ) {
698
-				$haystack = array( $haystack );
696
+		if ('' !== $type) {
697
+			if (!is_array($haystack)) {
698
+				$haystack = array($haystack);
699 699
 			}
700
-			if ( in_array( $needle, $haystack ) ) {
701
-				if ( true === $wrap || 'true' === $wrap ) {
702
-					$html = $type . '="' . $type . '"';
703
-				} else {
700
+			if (in_array($needle, $haystack)) {
701
+				if (true === $wrap || 'true' === $wrap) {
702
+					$html = $type.'="'.$type.'"';
703
+				}else {
704 704
 					$html = $type;
705 705
 				}
706 706
 			}
@@ -712,9 +712,9 @@  discard block
 block discarded – undo
712 712
 	/**
713 713
 	 * Grabs any attachments for the current item
714 714
 	 */
715
-	public function find_attachments( $id = false ) {
716
-		if ( false !== $id ) {
717
-			if ( empty( $this->found_attachments ) ) {
715
+	public function find_attachments($id = false) {
716
+		if (false !== $id) {
717
+			if (empty($this->found_attachments)) {
718 718
 				$attachments_args = array(
719 719
 					'post_parent'    => $id,
720 720
 					'post_status'    => 'inherit',
@@ -724,11 +724,11 @@  discard block
 block discarded – undo
724 724
 					'posts_per_page' => '-1',
725 725
 				);
726 726
 
727
-				$attachments = new WP_Query( $attachments_args );
727
+				$attachments = new WP_Query($attachments_args);
728 728
 
729
-				if ( $attachments->have_posts() ) {
730
-					foreach ( $attachments->posts as $attachment ) {
731
-						$this->found_attachments[ $attachment->ID ] = str_replace( array( '.jpg', '.png', '.jpeg' ), '', $attachment->post_title );
729
+				if ($attachments->have_posts()) {
730
+					foreach ($attachments->posts as $attachment) {
731
+						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title);
732 732
 					}
733 733
 				}
734 734
 			}
@@ -740,19 +740,19 @@  discard block
 block discarded – undo
740 740
 	/**
741 741
 	 * Saves the room data
742 742
 	 */
743
-	public function save_custom_field( $value = false, $meta_key, $id, $decrease = false, $unique = true ) {
744
-		if ( false !== $value ) {
745
-			if ( false !== $decrease ) {
746
-				$value = intval( $value );
743
+	public function save_custom_field($value = false, $meta_key, $id, $decrease = false, $unique = true) {
744
+		if (false !== $value) {
745
+			if (false !== $decrease) {
746
+				$value = intval($value);
747 747
 				$value--;
748 748
 			}
749 749
 
750
-			$prev = get_post_meta( $id, $meta_key, true );
750
+			$prev = get_post_meta($id, $meta_key, true);
751 751
 
752
-			if ( false !== $id && '0' !== $id && false !== $prev && true === $unique ) {
753
-				update_post_meta( $id, $meta_key, $value, $prev );
754
-			} else {
755
-				add_post_meta( $id, $meta_key, $value, $unique );
752
+			if (false !== $id && '0' !== $id && false !== $prev && true === $unique) {
753
+				update_post_meta($id, $meta_key, $value, $prev);
754
+			}else {
755
+				add_post_meta($id, $meta_key, $value, $unique);
756 756
 			}
757 757
 		}
758 758
 	}
@@ -761,15 +761,15 @@  discard block
 block discarded – undo
761 761
 	 * Grabs the custom fields,  and resaves an array of unique items.
762 762
 	 */
763 763
 	public function cleanup_posts() {
764
-		if ( ! empty( $this->cleanup_posts ) ) {
764
+		if (!empty($this->cleanup_posts)) {
765 765
 
766
-			foreach ( $this->cleanup_posts as $id => $key ) {
767
-				$prev_items = get_post_meta( $id, $key, false );
768
-				$new_items  = array_unique( $prev_items );
769
-				delete_post_meta( $id, $key );
766
+			foreach ($this->cleanup_posts as $id => $key) {
767
+				$prev_items = get_post_meta($id, $key, false);
768
+				$new_items  = array_unique($prev_items);
769
+				delete_post_meta($id, $key);
770 770
 
771
-				foreach ( $new_items as $new_item ) {
772
-					add_post_meta( $id, $key, $new_item, false );
771
+				foreach ($new_items as $new_item) {
772
+					add_post_meta($id, $key, $new_item, false);
773 773
 				}
774 774
 			}
775 775
 		}
@@ -780,26 +780,26 @@  discard block
 block discarded – undo
780 780
 	/**
781 781
 	 * Set_taxonomy with some terms
782 782
 	 */
783
-	public function set_taxonomy( $taxonomy, $terms, $id ) {
783
+	public function set_taxonomy($taxonomy, $terms, $id) {
784 784
 		$result = array();
785 785
 
786
-		if ( ! empty( $data ) ) {
787
-			foreach ( $data as $k ) {
788
-				if ( $id ) {
789
-					$term = term_exists( trim( $k ), $tax );
790
-					if ( ! $term ) {
791
-						$term = wp_insert_term( trim( $k ), $tax );
792
-
793
-						if ( is_wp_error( $term ) ) {
794
-							echo wp_kses_post( $term->get_error_message() );
795
-						} else {
796
-							wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy, true );
786
+		if (!empty($data)) {
787
+			foreach ($data as $k) {
788
+				if ($id) {
789
+					$term = term_exists(trim($k), $tax);
790
+					if (!$term) {
791
+						$term = wp_insert_term(trim($k), $tax);
792
+
793
+						if (is_wp_error($term)) {
794
+							echo wp_kses_post($term->get_error_message());
795
+						}else {
796
+							wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
797 797
 						}
798
-					} else {
799
-						wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy, true );
798
+					}else {
799
+						wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
800 800
 					}
801
-				} else {
802
-					$result[] = trim( $k );
801
+				}else {
802
+					$result[] = trim($k);
803 803
 				}
804 804
 			}
805 805
 		}
@@ -815,23 +815,23 @@  discard block
 block discarded – undo
815 815
 	 * @param boolean $parent
816 816
 	 * @return void
817 817
 	 */
818
-	public function set_term( $id = false, $name = false, $taxonomy = false, $parent = false ) {
819
-		$term = term_exists( $name, $taxonomy );
820
-		if ( ! $term ) {
821
-			if ( false !== $parent ) {
818
+	public function set_term($id = false, $name = false, $taxonomy = false, $parent = false) {
819
+		$term = term_exists($name, $taxonomy);
820
+		if (!$term) {
821
+			if (false !== $parent) {
822 822
 				$parent = array(
823 823
 					'parent' => $parent,
824 824
 				);
825 825
 			}
826
-			$term = wp_insert_term( trim( $name ), $taxonomy, $parent );
826
+			$term = wp_insert_term(trim($name), $taxonomy, $parent);
827 827
 
828
-			if ( is_wp_error( $term ) ) {
829
-				echo wp_kses_post( $term->get_error_message() );
830
-			} else {
831
-				wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy, true );
828
+			if (is_wp_error($term)) {
829
+				echo wp_kses_post($term->get_error_message());
830
+			}else {
831
+				wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
832 832
 			}
833
-		} else {
834
-			wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy, true );
833
+		}else {
834
+			wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
835 835
 		}
836 836
 
837 837
 		return $term['term_id'];
@@ -840,10 +840,10 @@  discard block
 block discarded – undo
840 840
 	/**
841 841
 	 * set_taxonomy with some terms
842 842
 	 */
843
-	public function taxonomy_checkboxes( $taxonomy = false, $selected = array() ) {
843
+	public function taxonomy_checkboxes($taxonomy = false, $selected = array()) {
844 844
 		$return = '';
845 845
 
846
-		if ( false !== $taxonomy ) {
846
+		if (false !== $taxonomy) {
847 847
 			$return .= '<ul>';
848 848
 			$terms   = get_terms(
849 849
 				array(
@@ -852,12 +852,12 @@  discard block
 block discarded – undo
852 852
 				)
853 853
 			);
854 854
 
855
-			if ( ! is_wp_error( $terms ) ) {
856
-				foreach ( $terms as $term ) {
857
-					$return .= '<li><input class="' . $taxonomy . '" ' . $this->checked( $selected, $term->term_id, false ) . ' type="checkbox" value="' . $term->term_id . '" /> ' . $term->name . '</li>';
855
+			if (!is_wp_error($terms)) {
856
+				foreach ($terms as $term) {
857
+					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected, $term->term_id, false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
858 858
 				}
859
-			} else {
860
-				$return .= '<li><input type="checkbox" value="" /> ' . __( 'None', 'lsx-wetu-importer' ) . '</li>';
859
+			}else {
860
+				$return .= '<li><input type="checkbox" value="" /> '.__('None', 'lsx-wetu-importer').'</li>';
861 861
 			}
862 862
 
863 863
 			$return .= '</ul>';
@@ -871,44 +871,44 @@  discard block
 block discarded – undo
871 871
 	/**
872 872
 	 * Saves the longitude and lattitude, as well as sets the map marker.
873 873
 	 */
874
-	public function set_map_data( $data, $id, $zoom = '10' ) {
874
+	public function set_map_data($data, $id, $zoom = '10') {
875 875
 		$longitude = false;
876 876
 		$latitude  = false;
877 877
 		$address   = false;
878 878
 
879
-		if ( isset( $data[0]['position'] ) ) {
880
-			if ( isset( $data[0]['position']['driving_latitude'] ) ) {
879
+		if (isset($data[0]['position'])) {
880
+			if (isset($data[0]['position']['driving_latitude'])) {
881 881
 				$latitude = $data[0]['position']['driving_latitude'];
882
-			} elseif ( isset( $data[0]['position']['latitude'] ) ) {
882
+			} elseif (isset($data[0]['position']['latitude'])) {
883 883
 				$latitude = $data[0]['position']['latitude'];
884 884
 			}
885 885
 
886
-			if ( isset( $data[0]['position']['driving_longitude'] ) ) {
886
+			if (isset($data[0]['position']['driving_longitude'])) {
887 887
 				$longitude = $data[0]['position']['driving_longitude'];
888
-			} elseif ( isset( $data[0]['position']['longitude'] ) ) {
888
+			} elseif (isset($data[0]['position']['longitude'])) {
889 889
 				$longitude = $data[0]['position']['longitude'];
890 890
 			}
891 891
 		}
892 892
 
893
-		if ( isset( $data[0]['content'] ) && isset( $data[0]['content']['contact_information'] ) ) {
894
-			if ( isset( $data[0]['content']['contact_information']['address'] ) ) {
895
-				$address = strip_tags( $data[0]['content']['contact_information']['address'] );
896
-				$address = explode( "\n", $address );
893
+		if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) {
894
+			if (isset($data[0]['content']['contact_information']['address'])) {
895
+				$address = strip_tags($data[0]['content']['contact_information']['address']);
896
+				$address = explode("\n", $address);
897 897
 
898
-				foreach ( $address as $bitkey => $bit ) {
899
-					$bit = ltrim( rtrim( $bit ) );
898
+				foreach ($address as $bitkey => $bit) {
899
+					$bit = ltrim(rtrim($bit));
900 900
 
901
-					if ( false === $bit || '' === $bit || null === $bit || empty( $bit ) ) {
902
-						unset( $address[ $bitkey ] );
901
+					if (false === $bit || '' === $bit || null === $bit || empty($bit)) {
902
+						unset($address[$bitkey]);
903 903
 					}
904 904
 				}
905 905
 
906
-				$address = implode( ', ', $address );
907
-				$address = str_replace( ', , ', ', ', $address );
906
+				$address = implode(', ', $address);
907
+				$address = str_replace(', , ', ', ', $address);
908 908
 			}
909 909
 		}
910 910
 
911
-		if ( false !== $longitude ) {
911
+		if (false !== $longitude) {
912 912
 			$location_data = array(
913 913
 				'address'   => (string) $address,
914 914
 				'lat'       => (string) $latitude,
@@ -917,11 +917,11 @@  discard block
 block discarded – undo
917 917
 				'elevation' => '',
918 918
 			);
919 919
 
920
-			if ( false !== $id && '0' !== $id ) {
921
-				$prev = get_post_meta( $id, 'location', true );
922
-				update_post_meta( $id, 'location', $location_data, $prev );
923
-			} else {
924
-				add_post_meta( $id, 'location', $location_data, true );
920
+			if (false !== $id && '0' !== $id) {
921
+				$prev = get_post_meta($id, 'location', true);
922
+				update_post_meta($id, 'location', $location_data, $prev);
923
+			}else {
924
+				add_post_meta($id, 'location', $location_data, true);
925 925
 			}
926 926
 		}
927 927
 	}
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 	/**
932 932
 	 * Creates the main gallery data
933 933
 	 */
934
-	public function set_featured_image( $data, $id ) {
935
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
934
+	public function set_featured_image($data, $id) {
935
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
936 936
 			$this->featured_image = $this->attach_image(
937 937
 				$data[0]['content']['images'][0],
938 938
 				$id,
@@ -943,9 +943,9 @@  discard block
 block discarded – undo
943 943
 				)
944 944
 			);
945 945
 
946
-			if ( false !== $this->featured_image ) {
947
-				delete_post_meta( $id, '_thumbnail_id' );
948
-				add_post_meta( $id, '_thumbnail_id', $this->featured_image, true );
946
+			if (false !== $this->featured_image) {
947
+				delete_post_meta($id, '_thumbnail_id');
948
+				add_post_meta($id, '_thumbnail_id', $this->featured_image, true);
949 949
 			}
950 950
 		}
951 951
 	}
@@ -953,9 +953,9 @@  discard block
 block discarded – undo
953 953
 	/**
954 954
 	 * Sets a banner image
955 955
 	 */
956
-	public function set_banner_image( $data, $id, $content = array( 'none' ) ) {
957
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
958
-			if ( in_array( 'unique_banner_image', $content ) && isset( $data[0]['destination_image'] ) && is_array( $data[0]['destination_image'] ) ) {
956
+	public function set_banner_image($data, $id, $content = array('none')) {
957
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
958
+			if (in_array('unique_banner_image', $content) && isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) {
959 959
 				$temp_banner = $this->attach_image(
960 960
 					$data[0]['destination_image'],
961 961
 					$id,
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
 						'cropping' => 'c',
966 966
 					)
967 967
 				);
968
-			} else {
968
+			}else {
969 969
 				$temp_banner = $this->attach_image(
970 970
 					$data[0]['content']['images'][1],
971 971
 					$id,
@@ -977,10 +977,10 @@  discard block
 block discarded – undo
977 977
 				);
978 978
 			}
979 979
 
980
-			if ( false !== $temp_banner ) {
980
+			if (false !== $temp_banner) {
981 981
 				$this->banner_image = $temp_banner;
982 982
 
983
-				delete_post_meta( $id, 'image_group' );
983
+				delete_post_meta($id, 'image_group');
984 984
 
985 985
 				$new_banner = array(
986 986
 					'banner_image' => array(
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 					),
989 989
 				);
990 990
 
991
-				add_post_meta( $id, 'image_group', $new_banner, true );
991
+				add_post_meta($id, 'image_group', $new_banner, true);
992 992
 			}
993 993
 		}
994 994
 	}
@@ -996,13 +996,13 @@  discard block
 block discarded – undo
996 996
 	/**
997 997
 	 * Checks if the current image is being used as a thumbnail somewhere else.
998 998
 	 */
999
-	public function is_image_being_used( $image_id = '', $post_id = '' ) {
999
+	public function is_image_being_used($image_id = '', $post_id = '') {
1000 1000
 		global $wpdb;
1001 1001
 		$being_used = false;
1002
-		if ( '' !== $image_id ) {
1002
+		if ('' !== $image_id) {
1003 1003
 			$sql     = "SELECT * FROM `{$wpdb->postmeta}` WHERE `post_id` != {$post_id} AND `meta_key` LIKE '_thumbnail_id' AND `meta_value` LIKE '{$image_id}'";
1004
-			$results = $wpdb->query( $sql );
1005
-			if ( false !== $results && ! empty( $results ) ) {
1004
+			$results = $wpdb->query($sql);
1005
+			if (false !== $results && !empty($results)) {
1006 1006
 				$being_used = true;
1007 1007
 			}
1008 1008
 		}
@@ -1012,17 +1012,17 @@  discard block
 block discarded – undo
1012 1012
 	/**
1013 1013
 	 * Creates the main gallery data
1014 1014
 	 */
1015
-	public function create_main_gallery( $data, $id ) {
1016
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
1017
-			if ( isset( $this->options['image_replacing'] ) && 'on' === $this->options['image_replacing'] ) {
1018
-				$current_gallery = get_post_meta( $id, 'gallery', false );
1015
+	public function create_main_gallery($data, $id) {
1016
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
1017
+			if (isset($this->options['image_replacing']) && 'on' === $this->options['image_replacing']) {
1018
+				$current_gallery = get_post_meta($id, 'gallery', false);
1019 1019
 
1020
-				if ( false !== $current_gallery && ! empty( $current_gallery ) ) {
1021
-					foreach ( $current_gallery as $g ) {
1022
-						delete_post_meta( $id, 'gallery', $g );
1020
+				if (false !== $current_gallery && !empty($current_gallery)) {
1021
+					foreach ($current_gallery as $g) {
1022
+						delete_post_meta($id, 'gallery', $g);
1023 1023
 
1024
-						if ( 'attachment' === get_post_type( $g ) && false === $this->is_image_being_used( $g, $id ) ) {
1025
-							wp_delete_attachment( $g, true );
1024
+						if ('attachment' === get_post_type($g) && false === $this->is_image_being_used($g, $id)) {
1025
+							wp_delete_attachment($g, true);
1026 1026
 						}
1027 1027
 					}
1028 1028
 				}
@@ -1030,32 +1030,32 @@  discard block
 block discarded – undo
1030 1030
 
1031 1031
 			$counter = 0;
1032 1032
 
1033
-			foreach ( $data[0]['content']['images'] as $image_data ) {
1034
-				if ( ( 0 === $counter && false !== $this->featured_image ) || ( 1 === $counter && false !== $this->banner_image ) ) {
1033
+			foreach ($data[0]['content']['images'] as $image_data) {
1034
+				if ((0 === $counter && false !== $this->featured_image) || (1 === $counter && false !== $this->banner_image)) {
1035 1035
 					$counter++;
1036 1036
 
1037
-					if ( false !== $this->image_limit && false !== $this->image_limit ) {
1037
+					if (false !== $this->image_limit && false !== $this->image_limit) {
1038 1038
 						$this->image_limit++;
1039 1039
 					}
1040 1040
 
1041 1041
 					continue;
1042 1042
 				}
1043 1043
 
1044
-				if ( false !== $this->image_limit && $counter >= $this->image_limit ) {
1044
+				if (false !== $this->image_limit && $counter >= $this->image_limit) {
1045 1045
 					continue;
1046 1046
 				}
1047 1047
 
1048
-				$this->gallery_meta[] = $this->attach_image( $image_data, $id );
1048
+				$this->gallery_meta[] = $this->attach_image($image_data, $id);
1049 1049
 				$counter++;
1050 1050
 			}
1051 1051
 
1052
-			if ( ! empty( $this->gallery_meta ) ) {
1053
-				delete_post_meta( $id, 'gallery' );
1054
-				$this->gallery_meta = array_unique( $this->gallery_meta );
1052
+			if (!empty($this->gallery_meta)) {
1053
+				delete_post_meta($id, 'gallery');
1054
+				$this->gallery_meta = array_unique($this->gallery_meta);
1055 1055
 
1056
-				foreach ( $this->gallery_meta as $gallery_id ) {
1057
-					if ( false !== $gallery_id && '' !== $gallery_id && ! is_array( $gallery_id ) ) {
1058
-						add_post_meta( $id, 'gallery', $gallery_id, false );
1056
+				foreach ($this->gallery_meta as $gallery_id) {
1057
+					if (false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)) {
1058
+						add_post_meta($id, 'gallery', $gallery_id, false);
1059 1059
 					}
1060 1060
 				}
1061 1061
 			}
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 	/**
1066 1066
 	 * search_form
1067 1067
 	 */
1068
-	public function get_scaling_url( $args = array() ) {
1068
+	public function get_scaling_url($args = array()) {
1069 1069
 		$defaults = array(
1070 1070
 			'width'    => '1024',
1071 1071
 			'height'   => '768',
@@ -1073,59 +1073,59 @@  discard block
 block discarded – undo
1073 1073
 			'cropping' => 'h',
1074 1074
 		);
1075 1075
 
1076
-		if ( false !== $this->options ) {
1077
-			if ( isset( $this->options['width'] ) && '' !== $this->options['width'] ) {
1076
+		if (false !== $this->options) {
1077
+			if (isset($this->options['width']) && '' !== $this->options['width']) {
1078 1078
 				$defaults['width'] = $this->options['width'];
1079 1079
 			}
1080 1080
 
1081
-			if ( isset( $this->options['height'] ) && '' !== $this->options['height'] ) {
1081
+			if (isset($this->options['height']) && '' !== $this->options['height']) {
1082 1082
 				$defaults['height'] = $this->options['height'];
1083 1083
 			}
1084 1084
 
1085
-			if ( isset( $this->options['cropping'] ) && '' !== $this->options['cropping'] ) {
1085
+			if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
1086 1086
 				$defaults['cropping'] = $this->options['cropping'];
1087 1087
 			}
1088 1088
 		}
1089 1089
 
1090
-		$args     = wp_parse_args( $args, $defaults );
1090
+		$args     = wp_parse_args($args, $defaults);
1091 1091
 		$cropping = $args['cropping'];
1092 1092
 		$width    = $args['width'];
1093 1093
 		$height   = $args['height'];
1094 1094
 
1095
-		return 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
1095
+		return 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/';
1096 1096
 	}
1097 1097
 
1098 1098
 	/**
1099 1099
 	 * Attaches 1 image
1100 1100
 	 */
1101
-	public function attach_image( $v = false, $parent_id, $image_sizes = false, $banner = false ) {
1102
-		if ( false !== $v ) {
1103
-			$temp_fragment = explode( '/', $v['url_fragment'] );
1104
-			$url_filename  = $temp_fragment[ count( $temp_fragment ) - 1 ];
1105
-			$url_filename  = str_replace( array( '.jpg', '.png', '.jpeg' ), '', $url_filename );
1106
-			$url_filename  = trim( $url_filename );
1101
+	public function attach_image($v = false, $parent_id, $image_sizes = false, $banner = false) {
1102
+		if (false !== $v) {
1103
+			$temp_fragment = explode('/', $v['url_fragment']);
1104
+			$url_filename  = $temp_fragment[count($temp_fragment) - 1];
1105
+			$url_filename  = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename);
1106
+			$url_filename  = trim($url_filename);
1107 1107
 			$title         = $url_filename;
1108
-			$url_filename  = str_replace( ' ', '_', $url_filename );
1108
+			$url_filename  = str_replace(' ', '_', $url_filename);
1109 1109
 
1110
-			if ( ! isset( $this->options['image_replacing'] ) && in_array( $url_filename, $this->found_attachments ) ) {
1111
-				return array_search( $url_filename, $this->found_attachments );
1110
+			if (!isset($this->options['image_replacing']) && in_array($url_filename, $this->found_attachments)) {
1111
+				return array_search($url_filename, $this->found_attachments);
1112 1112
 			}
1113 1113
 
1114 1114
 			$postdata = array();
1115 1115
 
1116
-			if ( empty( $v['label'] ) ) {
1116
+			if (empty($v['label'])) {
1117 1117
 				$v['label'] = '';
1118 1118
 			}
1119 1119
 
1120
-			if ( ! empty( $v['description'] ) ) {
1121
-				$desc    = wp_strip_all_tags( $v['description'] );
1120
+			if (!empty($v['description'])) {
1121
+				$desc    = wp_strip_all_tags($v['description']);
1122 1122
 				$posdata = array(
1123 1123
 					'post_excerpt' => $desc,
1124 1124
 				);
1125 1125
 			}
1126 1126
 
1127
-			if ( ! empty( $v['section'] ) ) {
1128
-				$desc    = wp_strip_all_tags( $v['section'] );
1127
+			if (!empty($v['section'])) {
1128
+				$desc    = wp_strip_all_tags($v['section']);
1129 1129
 				$posdata = array(
1130 1130
 					'post_excerpt' => $desc,
1131 1131
 				);
@@ -1133,83 +1133,83 @@  discard block
 block discarded – undo
1133 1133
 
1134 1134
 			$attach_id = null;
1135 1135
 			// Resizor - add option to setting if required.
1136
-			$fragment  = str_replace( ' ', '%20', $v['url_fragment'] );
1137
-			$url       = $this->get_scaling_url( $image_sizes ) . $fragment;
1138
-			$attach_id = $this->attach_external_image2( $url, $parent_id, '', $v['label'], $postdata );
1139
-			if ( ! empty( $attach_id ) ) {
1140
-				$this->found_attachments[ $attach_id ] = $url_filename;
1141
-				add_post_meta( $attach_id, 'lsx_wetu_id', $v['url_fragment'], true );
1136
+			$fragment  = str_replace(' ', '%20', $v['url_fragment']);
1137
+			$url       = $this->get_scaling_url($image_sizes).$fragment;
1138
+			$attach_id = $this->attach_external_image2($url, $parent_id, '', $v['label'], $postdata);
1139
+			if (!empty($attach_id)) {
1140
+				$this->found_attachments[$attach_id] = $url_filename;
1141
+				add_post_meta($attach_id, 'lsx_wetu_id', $v['url_fragment'], true);
1142 1142
 				return $attach_id;
1143 1143
 			}
1144 1144
 		}
1145 1145
 		return false;
1146 1146
 	}
1147 1147
 
1148
-	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
1149
-		if ( ! $url || ! $post_id ) {
1150
-			return new WP_Error( 'missing', 'Need a valid URL and post ID...' ); }
1148
+	public function attach_external_image2($url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array()) {
1149
+		if (!$url || !$post_id) {
1150
+			return new WP_Error('missing', 'Need a valid URL and post ID...'); }
1151 1151
 		$att_id = false;
1152 1152
 
1153
-		require_once ABSPATH . 'wp-admin/includes/file.php';
1154
-		require_once ABSPATH . 'wp-admin/includes/media.php';
1155
-		require_once ABSPATH . 'wp-admin/includes/image.php';
1153
+		require_once ABSPATH.'wp-admin/includes/file.php';
1154
+		require_once ABSPATH.'wp-admin/includes/media.php';
1155
+		require_once ABSPATH.'wp-admin/includes/image.php';
1156 1156
 		// Download file to temp location, returns full server path to temp file.
1157 1157
 
1158
-		$tmp   = tempnam( '/tmp', 'FOO' );
1159
-		$image = wp_remote_get( $url );
1160
-		if ( ! is_wp_error( $image ) && ! empty( $image ) && isset( $image['response'] ) && isset( $image['response']['code'] ) && 200 === $image['response']['code'] ) {
1161
-			file_put_contents( $tmp, $image['body'] );
1162
-			chmod( $tmp, '777' );
1158
+		$tmp   = tempnam('/tmp', 'FOO');
1159
+		$image = wp_remote_get($url);
1160
+		if (!is_wp_error($image) && !empty($image) && isset($image['response']) && isset($image['response']['code']) && 200 === $image['response']['code']) {
1161
+			file_put_contents($tmp, $image['body']);
1162
+			chmod($tmp, '777');
1163 1163
 
1164
-			preg_match( '/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches );    // fix file filename for query strings
1165
-			$url_filename = basename( $matches[0] );
1166
-			$url_filename = str_replace( '%20', '_', $url_filename );
1164
+			preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches); // fix file filename for query strings
1165
+			$url_filename = basename($matches[0]);
1166
+			$url_filename = str_replace('%20', '_', $url_filename);
1167 1167
 			// extract filename from url for title
1168
-			$url_type = wp_check_filetype( $url_filename );                                           // determine file type (ext and mime/type)
1168
+			$url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type)
1169 1169
 
1170 1170
 			// override filename if given, reconstruct server path.
1171
-			if ( ! empty( $filename ) && ' ' != $filename ) {
1172
-				$filename = sanitize_file_name( $filename );
1173
-				$tmppath  = pathinfo( $tmp );
1171
+			if (!empty($filename) && ' ' != $filename) {
1172
+				$filename = sanitize_file_name($filename);
1173
+				$tmppath  = pathinfo($tmp);
1174 1174
 
1175 1175
 				$extension = '';
1176
-				if ( isset( $tmppath['extension'] ) ) {
1176
+				if (isset($tmppath['extension'])) {
1177 1177
 					$extension = $tmppath['extension'];
1178 1178
 				}
1179 1179
 
1180
-				$new = $tmppath['dirname'] . '/' . $filename . '.' . $extension;
1181
-				rename( $tmp, $new );                                                                 // renames temp file on server
1182
-				$tmp = $new;                                                                        // push new filename (in path) to be used in file array later
1180
+				$new = $tmppath['dirname'].'/'.$filename.'.'.$extension;
1181
+				rename($tmp, $new); // renames temp file on server
1182
+				$tmp = $new; // push new filename (in path) to be used in file array later
1183 1183
 			}
1184 1184
 
1185 1185
 			// assemble file data (should be built like $_FILES since wp_handle_sideload() will be using).
1186
-			$file_array['tmp_name'] = $tmp;                                                         // full server path to temp file
1186
+			$file_array['tmp_name'] = $tmp; // full server path to temp file
1187 1187
 
1188
-			if ( ! empty( $filename ) && ' ' != $filename ) {
1189
-				$file_array['name'] = $filename . '.' . $url_type['ext'];                           // user given filename for title, add original URL extension
1190
-			} else {
1191
-				$file_array['name'] = $url_filename;                                                // just use original URL filename
1188
+			if (!empty($filename) && ' ' != $filename) {
1189
+				$file_array['name'] = $filename.'.'.$url_type['ext']; // user given filename for title, add original URL extension
1190
+			}else {
1191
+				$file_array['name'] = $url_filename; // just use original URL filename
1192 1192
 			}
1193 1193
 
1194 1194
 			// set additional wp_posts columns.
1195
-			if ( empty( $post_data['post_title'] ) ) {
1195
+			if (empty($post_data['post_title'])) {
1196 1196
 
1197
-				$url_filename = str_replace( '%20', ' ', $url_filename );
1197
+				$url_filename = str_replace('%20', ' ', $url_filename);
1198 1198
 
1199
-				$post_data['post_title'] = basename( $url_filename, '.' . $url_type['ext'] );         // just use the original filename (no extension)
1199
+				$post_data['post_title'] = basename($url_filename, '.'.$url_type['ext']); // just use the original filename (no extension)
1200 1200
 			}
1201 1201
 
1202 1202
 			// make sure gets tied to parent.
1203
-			if ( empty( $post_data['post_parent'] ) ) {
1203
+			if (empty($post_data['post_parent'])) {
1204 1204
 				$post_data['post_parent'] = $post_id;
1205 1205
 			}
1206 1206
 
1207 1207
 			// do the validation and storage stuff.
1208
-			$att_id = media_handle_sideload( $file_array, $post_id, null, $post_data );             // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status
1208
+			$att_id = media_handle_sideload($file_array, $post_id, null, $post_data); // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status
1209 1209
 
1210 1210
 			// If error storing permanently, unlink.
1211
-			if ( is_wp_error( $att_id ) ) {
1212
-				unlink( $file_array['tmp_name'] );
1211
+			if (is_wp_error($att_id)) {
1212
+				unlink($file_array['tmp_name']);
1213 1213
 				return false;
1214 1214
 			}
1215 1215
 		}
@@ -1236,33 +1236,33 @@  discard block
 block discarded – undo
1236 1236
 	/**
1237 1237
 	 * Formats the row for the completed list.
1238 1238
 	 */
1239
-	public function format_completed_row( $response ) {
1240
-		echo wp_kses_post( '<li class="post-' . $response . '"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="' . get_permalink( $response ) . '">' . get_the_title( $response ) . '</a></li>' );
1239
+	public function format_completed_row($response) {
1240
+		echo wp_kses_post('<li class="post-'.$response.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($response).'">'.get_the_title($response).'</a></li>');
1241 1241
 	}
1242 1242
 
1243 1243
 	/**
1244 1244
 	 * Formats the error.
1245 1245
 	 */
1246
-	public function format_error( $response ) {
1247
-		echo wp_kses_post( '<li class="post-error"><span class="dashicons dashicons-no"></span>' . $response . '</li>' );
1246
+	public function format_error($response) {
1247
+		echo wp_kses_post('<li class="post-error"><span class="dashicons dashicons-no"></span>'.$response.'</li>');
1248 1248
 	}
1249 1249
 
1250 1250
 	/**
1251 1251
 	 * Does a multine search
1252 1252
 	 */
1253
-	public function multineedle_stripos( $haystack, $needles, $offset = 0 ) {
1253
+	public function multineedle_stripos($haystack, $needles, $offset = 0) {
1254 1254
 		$found        = false;
1255
-		$needle_count = count( $needles );
1255
+		$needle_count = count($needles);
1256 1256
 
1257
-		foreach ( $needles as $needle ) {
1258
-			if ( false !== stripos( $haystack, $needle, $offset ) ) {
1257
+		foreach ($needles as $needle) {
1258
+			if (false !== stripos($haystack, $needle, $offset)) {
1259 1259
 				$found[] = true;
1260 1260
 			}
1261 1261
 		}
1262 1262
 
1263
-		if ( false !== $found && count( $found ) === $needle_count ) {
1263
+		if (false !== $found && count($found) === $needle_count) {
1264 1264
 			return true;
1265
-		} else {
1265
+		}else {
1266 1266
 			return false;
1267 1267
 		}
1268 1268
 	}
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 	/**
1271 1271
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
1272 1272
 	 */
1273
-	public function find_current_accommodation( $post_type = 'accommodation' ) {
1273
+	public function find_current_accommodation($post_type = 'accommodation') {
1274 1274
 		global $wpdb;
1275 1275
 		$return = array();
1276 1276
 
@@ -1289,9 +1289,9 @@  discard block
 block discarded – undo
1289 1289
 		");
1290 1290
 		// @codingStandardsIgnoreEnd
1291 1291
 
1292
-		if ( null !== $current_accommodation && ! empty( $current_accommodation ) ) {
1293
-			foreach ( $current_accommodation as $accom ) {
1294
-				$return[ $accom->meta_value ] = $accom;
1292
+		if (null !== $current_accommodation && !empty($current_accommodation)) {
1293
+			foreach ($current_accommodation as $accom) {
1294
+				$return[$accom->meta_value] = $accom;
1295 1295
 			}
1296 1296
 		}
1297 1297
 
@@ -1301,20 +1301,20 @@  discard block
 block discarded – undo
1301 1301
 	/**
1302 1302
 	 * Set the Video date
1303 1303
 	 */
1304
-	public function set_video_data( $data, $id ) {
1305
-		if ( ! empty( $data[0]['content']['youtube_videos'] ) && is_array( $data[0]['content']['youtube_videos'] ) ) {
1304
+	public function set_video_data($data, $id) {
1305
+		if (!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])) {
1306 1306
 			$videos = false;
1307 1307
 
1308
-			foreach ( $data[0]['content']['youtube_videos'] as $video ) {
1308
+			foreach ($data[0]['content']['youtube_videos'] as $video) {
1309 1309
 				$temp_video = array();
1310 1310
 
1311
-				if ( isset( $video['label'] ) ) {
1311
+				if (isset($video['label'])) {
1312 1312
 					$temp_video['title'] = $video['label'];
1313 1313
 				}
1314
-				if ( isset( $video['description'] ) ) {
1315
-					$temp_video['description'] = strip_tags( $video['description'] );
1314
+				if (isset($video['description'])) {
1315
+					$temp_video['description'] = strip_tags($video['description']);
1316 1316
 				}
1317
-				if ( isset( $video['url'] ) ) {
1317
+				if (isset($video['url'])) {
1318 1318
 					$temp_video['url'] = $video['url'];
1319 1319
 				}
1320 1320
 
@@ -1322,24 +1322,24 @@  discard block
 block discarded – undo
1322 1322
 				$videos[]                = $temp_video;
1323 1323
 			}
1324 1324
 
1325
-			if ( false !== $id && '0' !== $id ) {
1326
-				delete_post_meta( $id, 'videos' );
1325
+			if (false !== $id && '0' !== $id) {
1326
+				delete_post_meta($id, 'videos');
1327 1327
 			}
1328 1328
 
1329
-			foreach ( $videos as $video ) {
1330
-				add_post_meta( $id, 'videos', $video, false );
1329
+			foreach ($videos as $video) {
1330
+				add_post_meta($id, 'videos', $video, false);
1331 1331
 			}
1332 1332
 		}
1333 1333
 	}
1334 1334
 
1335
-	public function shuffle_assoc( &$array ) {
1335
+	public function shuffle_assoc(&$array) {
1336 1336
 		$new  = array();
1337
-		$keys = array_keys( $array );
1337
+		$keys = array_keys($array);
1338 1338
 
1339
-		shuffle( $keys );
1339
+		shuffle($keys);
1340 1340
 
1341
-		foreach ( $keys as $key ) {
1342
-			$new[ $key ] = $array[ $key ];
1341
+		foreach ($keys as $key) {
1342
+			$new[$key] = $array[$key];
1343 1343
 		}
1344 1344
 
1345 1345
 		$array = $new;
@@ -1353,31 +1353,31 @@  discard block
 block discarded – undo
1353 1353
 	public function update_options() {
1354 1354
 		$own     = '';
1355 1355
 		$options = array();
1356
-		delete_option( 'lsx_ti_tours_api_options' );
1356
+		delete_option('lsx_ti_tours_api_options');
1357 1357
 
1358
-		if ( isset( $_GET['own'] ) ) {
1358
+		if (isset($_GET['own'])) {
1359 1359
 			$this->current_importer->url_qs .= '&own=true';
1360 1360
 			$options[]                       = 'own';
1361 1361
 		}
1362 1362
 
1363
-		if ( isset( $_GET['type'] ) && 'allitineraries' !== $_GET['type'] ) {
1364
-			$this->current_importer->url_qs .= '&type=' . $_GET['type'];
1363
+		if (isset($_GET['type']) && 'allitineraries' !== $_GET['type']) {
1364
+			$this->current_importer->url_qs .= '&type='.$_GET['type'];
1365 1365
 			$options[]                       = $_GET['type'];
1366
-		} else {
1366
+		}else {
1367 1367
 			$options[]                       = 'sample';
1368 1368
 			$this->current_importer->url_qs .= '&type=sample';
1369 1369
 		}
1370 1370
 
1371
-		$url  = str_replace( 'Pins', 'Itinerary', $this->current_importer->url . '/V8/List?' . $this->current_importer->url_qs );
1371
+		$url  = str_replace('Pins', 'Itinerary', $this->current_importer->url.'/V8/List?'.$this->current_importer->url_qs);
1372 1372
 		$url .= '&results=2000';
1373
-		add_option( 'lsx_ti_tours_api_options', $options );
1374
-		$data  = wp_remote_get( $url );
1375
-		$tours = json_decode( wp_remote_retrieve_body( $data ), true );
1373
+		add_option('lsx_ti_tours_api_options', $options);
1374
+		$data  = wp_remote_get($url);
1375
+		$tours = json_decode(wp_remote_retrieve_body($data), true);
1376 1376
 
1377
-		if ( isset( $tours['error'] ) ) {
1377
+		if (isset($tours['error'])) {
1378 1378
 			return $tours['error'];
1379
-		} elseif ( isset( $tours['itineraries'] ) && ! empty( $tours['itineraries'] ) ) {
1380
-			set_transient( 'lsx_ti_tours', $tours['itineraries'], 60 * 60 * 4 );
1379
+		} elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
1380
+			set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 4);
1381 1381
 			return true;
1382 1382
 		}
1383 1383
 	}
@@ -1388,12 +1388,12 @@  discard block
 block discarded – undo
1388 1388
 	 * @param boolean $wetu_id
1389 1389
 	 * @return string
1390 1390
 	 */
1391
-	public function get_post_id_by_key_value( $wetu_id = false ) {
1391
+	public function get_post_id_by_key_value($wetu_id = false) {
1392 1392
 		global $wpdb;
1393 1393
 		$id = false;
1394
-		if ( false !== $wetu_id && '' !== $wetu_id ) {
1395
-			$result = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM `$wpdb->postmeta` WHERE `meta_key` = 'lsx_wetu_id' AND `meta_value` = '%s'", array( $wetu_id ) ) );
1396
-			if ( false !== $result && ! empty( $result ) ) {
1394
+		if (false !== $wetu_id && '' !== $wetu_id) {
1395
+			$result = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM `$wpdb->postmeta` WHERE `meta_key` = 'lsx_wetu_id' AND `meta_value` = '%s'", array($wetu_id)));
1396
+			if (false !== $result && !empty($result)) {
1397 1397
 				$id = $result;
1398 1398
 			}
1399 1399
 		}
@@ -1402,11 +1402,11 @@  discard block
 block discarded – undo
1402 1402
 	/**
1403 1403
 	 * Set the team memberon each item.
1404 1404
 	 */
1405
-	public function set_team_member( $id, $team_members ) {
1406
-		delete_post_meta( $id, 'team_to_' . $this->tab_slug );
1405
+	public function set_team_member($id, $team_members) {
1406
+		delete_post_meta($id, 'team_to_'.$this->tab_slug);
1407 1407
 
1408
-		foreach ( $team_members as $team ) {
1409
-			add_post_meta( $id, 'team_to_' . $this->tab_slug, $team );
1408
+		foreach ($team_members as $team) {
1409
+			add_post_meta($id, 'team_to_'.$this->tab_slug, $team);
1410 1410
 		}
1411 1411
 	}
1412 1412
 }
Please login to merge, or discard this patch.
classes/class-lsx-wetu-importer-tours.php 1 patch
Spacing   +439 added lines, -439 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,53 +156,53 @@  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
-								<?php if ( isset( $this->options ) && isset( $this->options['disable_tour_descriptions'] ) && 'on' !== $this->options['disable_tour_descriptions'] ) { ?>
162
-									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="description" /> <?php esc_html_e( 'Description', 'lsx-wetu-importer' ); ?></li>
161
+								<?php if (isset($this->options) && isset($this->options['disable_tour_descriptions']) && 'on' !== $this->options['disable_tour_descriptions']) { ?>
162
+									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="description" /> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li>
163 163
 								<?php } ?>
164 164
 
165
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="price" /> <?php esc_html_e( 'Price', 'lsx-wetu-importer' ); ?></li>
166
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="duration" /> <?php esc_html_e( 'Duration', 'lsx-wetu-importer' ); ?></li>
167
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="group_size" /> <?php esc_html_e( 'Group Size', 'lsx-wetu-importer' ); ?></li>
168
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="category" /> <?php esc_html_e( 'Category', 'lsx-wetu-importer' ); ?></li>
169
-								<?php if ( isset( $this->options ) && isset( $this->options['disable_tour_tags'] ) && 'on' !== $this->options['disable_tour_tags'] ) { ?>
170
-									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="tags" /> <?php esc_html_e( 'Tags', 'lsx-wetu-importer' ); ?></li>
165
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="price" /> <?php esc_html_e('Price', 'lsx-wetu-importer'); ?></li>
166
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="duration" /> <?php esc_html_e('Duration', 'lsx-wetu-importer'); ?></li>
167
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="group_size" /> <?php esc_html_e('Group Size', 'lsx-wetu-importer'); ?></li>
168
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="category" /> <?php esc_html_e('Category', 'lsx-wetu-importer'); ?></li>
169
+								<?php if (isset($this->options) && isset($this->options['disable_tour_tags']) && 'on' !== $this->options['disable_tour_tags']) { ?>
170
+									<li><input class="content" checked="checked" type="checkbox" name="content[]" value="tags" /> <?php esc_html_e('Tags', 'lsx-wetu-importer'); ?></li>
171 171
 								<?php } ?>
172
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="itineraries" /> <?php esc_html_e( 'Itinerary Days', 'lsx-wetu-importer' ); ?></li>
173
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="start_end_point" /> <?php esc_html_e( 'Departs from / Ends in', 'lsx-wetu-importer' ); ?></li>
172
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="itineraries" /> <?php esc_html_e('Itinerary Days', 'lsx-wetu-importer'); ?></li>
173
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="start_end_point" /> <?php esc_html_e('Departs from / Ends in', 'lsx-wetu-importer'); ?></li>
174 174
 							</ul>
175 175
 						</div>
176 176
 						<div class="settings-all" style="width:30%;display:block;float:left;">
177
-							<h3><?php esc_html_e( 'Itinerary Info' ); ?></h3>
177
+							<h3><?php esc_html_e('Itinerary Info'); ?></h3>
178 178
 							<ul>
179
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="itinerary_description" /> <?php esc_html_e( 'Description', 'lsx-wetu-importer' ); ?></li>
180
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="itinerary_included" /> <?php esc_html_e( 'Included', 'lsx-wetu-importer' ); ?></li>
181
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="itinerary_excluded" /> <?php esc_html_e( 'Excluded', 'lsx-wetu-importer' ); ?></li>
182
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="room_basis" /> <?php esc_html_e( 'Room Basis', 'lsx-wetu-importer' ); ?></li>
183
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="drinks_basis" /> <?php esc_html_e( 'Drink Bases', 'lsx-wetu-importer' ); ?></li>
179
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="itinerary_description" /> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li>
180
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="itinerary_included" /> <?php esc_html_e('Included', 'lsx-wetu-importer'); ?></li>
181
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="itinerary_excluded" /> <?php esc_html_e('Excluded', 'lsx-wetu-importer'); ?></li>
182
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="room_basis" /> <?php esc_html_e('Room Basis', 'lsx-wetu-importer'); ?></li>
183
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="drinks_basis" /> <?php esc_html_e('Drink Bases', 'lsx-wetu-importer'); ?></li>
184 184
 							</ul>
185 185
 
186
-							<h4><?php esc_html_e( 'Additional Content' ); ?></h4>
186
+							<h4><?php esc_html_e('Additional Content'); ?></h4>
187 187
 							<ul>
188
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="accommodation" /> <?php esc_html_e( 'Sync Accommodation', 'lsx-wetu-importer' ); ?></li>
189
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e( 'Sync Destinations', 'lsx-wetu-importer' ); ?></li>
190
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e( 'Featured Image', 'lsx-wetu-importer' ); ?></li>
191
-								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e( 'Banner Image', 'lsx-wetu-importer' ); ?></li>
188
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="accommodation" /> <?php esc_html_e('Sync Accommodation', 'lsx-wetu-importer'); ?></li>
189
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e('Sync Destinations', 'lsx-wetu-importer'); ?></li>
190
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e('Featured Image', 'lsx-wetu-importer'); ?></li>
191
+								<li><input class="content" checked="checked" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e('Banner Image', 'lsx-wetu-importer'); ?></li>
192 192
 							</ul>
193 193
 						</div>
194
-						<?php if ( class_exists( 'LSX_TO_Team' ) ) { ?>
194
+						<?php if (class_exists('LSX_TO_Team')) { ?>
195 195
 							<div style="width:30%;display:block;float:left;">
196
-								<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3>
197
-								<?php $this->team_member_checkboxes( $this->tour_options ); ?>
196
+								<h3><?php esc_html_e('Assign a Team Member'); ?></h3>
197
+								<?php $this->team_member_checkboxes($this->tour_options); ?>
198 198
 							</div>
199 199
 						<?php } ?>
200 200
 
201 201
 						<br clear="both" />
202 202
 					</div>
203 203
 
204
-					<h3><?php esc_html_e( 'Your List' ); ?></h3>
205
-					<p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>" /></p>
204
+					<h3><?php esc_html_e('Your List'); ?></h3>
205
+					<p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>" /></p>
206 206
 					<table class="wp-list-table widefat fixed posts">
207 207
 						<?php $this->table_header(); ?>
208 208
 
@@ -214,12 +214,12 @@  discard block
 block discarded – undo
214 214
 
215 215
 					</table>
216 216
 
217
-					<p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>" /></p>
217
+					<p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>" /></p>
218 218
 				</form>
219 219
 			</div>
220 220
 
221 221
 			<div style="display:none;" class="completed-list-wrapper">
222
-				<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
+				<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>
223 223
 				<ul>
224 224
 				</ul>
225 225
 			</div>
@@ -233,13 +233,13 @@  discard block
 block discarded – undo
233 233
 	 * @return void
234 234
 	 */
235 235
 	public function update_options_form() {
236
-		$form_options = get_option( 'lsx_ti_tours_api_options' );
237
-		if ( false === $form_options ) {
238
-			$form_options = array( 'sample' );
236
+		$form_options = get_option('lsx_ti_tours_api_options');
237
+		if (false === $form_options) {
238
+			$form_options = array('sample');
239 239
 		}
240 240
 		?>
241 241
 		<form method="get" class="tour-refresh-form">
242
-			<input type="hidden" name="page" value="<?php echo esc_attr( $this->plugin_slug ); ?>" />
242
+			<input type="hidden" name="page" value="<?php echo esc_attr($this->plugin_slug); ?>" />
243 243
 			<input type="hidden" name="tab" value="tour" />
244 244
 			<input type="hidden" name="refresh_tours" value="true" />
245 245
 			<input class="content" type="hidden" name="own" value="true" />
@@ -247,18 +247,18 @@  discard block
 block discarded – undo
247 247
 			<select name="type">
248 248
 				<option 
249 249
 				<?php
250
-				if ( in_array( 'personal', $form_options ) ) {
251
-					echo esc_attr( 'selected="selected"' ); }
250
+				if (in_array('personal', $form_options)) {
251
+					echo esc_attr('selected="selected"'); }
252 252
 				?>
253
-value="personal"><?php esc_html_e( 'Personal', 'lsx-wetu-importer' ); ?></option>
253
+value="personal"><?php esc_html_e('Personal', 'lsx-wetu-importer'); ?></option>
254 254
 				<option 
255 255
 				<?php
256
-				if ( in_array( 'sample', $form_options ) ) {
257
-					echo esc_attr( 'selected="selected"' ); }
256
+				if (in_array('sample', $form_options)) {
257
+					echo esc_attr('selected="selected"'); }
258 258
 				?>
259
-value="sample"><?php esc_html_e( 'Sample', 'lsx-wetu-importer' ); ?></option>
259
+value="sample"><?php esc_html_e('Sample', 'lsx-wetu-importer'); ?></option>
260 260
 			</select>
261
-			<input class="button submit" type="submit" value="<?php esc_attr_e( 'Refresh', 'lsx-wetu-importer' ); ?>" />
261
+			<input class="button submit" type="submit" value="<?php esc_attr_e('Refresh', 'lsx-wetu-importer'); ?>" />
262 262
 		</form>
263 263
 		<?php
264 264
 	}
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
 		"
286 286
 		);
287 287
 
288
-		if ( null !== $current_tours && ! empty( $current_tours ) ) {
289
-			foreach ( $current_tours as $tour ) {
290
-				$return[ $tour->meta_value ] = $tour;
288
+		if (null !== $current_tours && !empty($current_tours)) {
289
+			foreach ($current_tours as $tour) {
290
+				$return[$tour->meta_value] = $tour;
291 291
 			}
292 292
 		}
293 293
 
@@ -299,45 +299,45 @@  discard block
 block discarded – undo
299 299
 	 */
300 300
 	public function process_ajax_search() {
301 301
 		$return = false;
302
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
302
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
303 303
 
304
-		if ( isset( $_POST['action'] ) && 'lsx_tour_importer' === $_POST['action'] && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug ) {
305
-			$tours = get_transient( 'lsx_ti_tours' );
304
+		if (isset($_POST['action']) && 'lsx_tour_importer' === $_POST['action'] && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) {
305
+			$tours = get_transient('lsx_ti_tours');
306 306
 
307
-			if ( false !== $tours ) {
307
+			if (false !== $tours) {
308 308
 				$searched_items = false;
309
-				if ( isset( $_POST['keyword'] ) ) {
310
-					$keyphrases = array_map( 'sanitize_text_field', wp_unslash( $_POST['keyword'] ) );
311
-				} else {
312
-					$keyphrases = array( 0 );
309
+				if (isset($_POST['keyword'])) {
310
+					$keyphrases = array_map('sanitize_text_field', wp_unslash($_POST['keyword']));
311
+				}else {
312
+					$keyphrases = array(0);
313 313
 				}
314 314
 
315
-				if ( ! is_array( $keyphrases ) ) {
316
-					$keyphrases = array( $keyphrases );
315
+				if (!is_array($keyphrases)) {
316
+					$keyphrases = array($keyphrases);
317 317
 				}
318
-				foreach ( $keyphrases as &$keyword ) {
319
-					$keyword = ltrim( rtrim( $keyword ) );
318
+				foreach ($keyphrases as &$keyword) {
319
+					$keyword = ltrim(rtrim($keyword));
320 320
 				}
321 321
 
322 322
 				$post_status = false;
323
-				if ( in_array( 'publish', $keyphrases ) ) {
323
+				if (in_array('publish', $keyphrases)) {
324 324
 					$post_status = 'publish';
325 325
 				}
326
-				if ( in_array( 'pending', $keyphrases ) ) {
326
+				if (in_array('pending', $keyphrases)) {
327 327
 					$post_status = 'pending';
328 328
 				}
329
-				if ( in_array( 'draft', $keyphrases ) ) {
329
+				if (in_array('draft', $keyphrases)) {
330 330
 					$post_status = 'draft';
331 331
 				}
332
-				if ( in_array( 'import', $keyphrases ) ) {
332
+				if (in_array('import', $keyphrases)) {
333 333
 					$post_status = 'import';
334 334
 				}
335 335
 
336
-				if ( ! empty( $tours ) ) {
336
+				if (!empty($tours)) {
337 337
 					$current_tours = $this->find_current_tours();
338 338
 
339
-					foreach ( $tours as $row_key => $row ) {
340
-						if ( isset( $row['is_disabled'] ) && true === $row['is_disabled'] ) {
339
+					foreach ($tours as $row_key => $row) {
340
+						if (isset($row['is_disabled']) && true === $row['is_disabled']) {
341 341
 							continue;
342 342
 						}
343 343
 
@@ -345,60 +345,60 @@  discard block
 block discarded – undo
345 345
 						$row['post_id']    = 0;
346 346
 						$row['post_title'] = $row['name'];
347 347
 
348
-						if ( false !== $current_tours && array_key_exists( $row['identifier'], $current_tours ) ) {
349
-							$row['post_id']    = $current_tours[ $row['identifier'] ]->post_id;
350
-							$row['post_title'] = $current_tours[ $row['identifier'] ]->post_title;
348
+						if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) {
349
+							$row['post_id']    = $current_tours[$row['identifier']]->post_id;
350
+							$row['post_title'] = $current_tours[$row['identifier']]->post_title;
351 351
 						}
352 352
 
353 353
 						// If we are searching for.
354
-						if ( false !== $post_status ) {
355
-							if ( 'import' === $post_status ) {
354
+						if (false !== $post_status) {
355
+							if ('import' === $post_status) {
356 356
 
357
-								if ( 0 !== $row['post_id'] ) {
357
+								if (0 !== $row['post_id']) {
358 358
 									continue;
359
-								} else {
360
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row, $row_key );
359
+								}else {
360
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row, $row_key);
361 361
 								}
362
-							} else {
363
-								if ( 0 === $row['post_id'] ) {
362
+							}else {
363
+								if (0 === $row['post_id']) {
364 364
 									continue;
365
-								} else {
366
-									$current_status = get_post_status( $row['post_id'] );
365
+								}else {
366
+									$current_status = get_post_status($row['post_id']);
367 367
 
368
-									if ( $current_status !== $post_status ) {
368
+									if ($current_status !== $post_status) {
369 369
 										continue;
370 370
 									}
371 371
 								}
372 372
 
373
-								$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row, $row_key );
373
+								$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row, $row_key);
374 374
 							}
375
-						} else {
375
+						}else {
376 376
 							// Search through each keyword.
377
-							foreach ( $keyphrases as $keyphrase ) {
377
+							foreach ($keyphrases as $keyphrase) {
378 378
 
379 379
 								// Make sure the keyphrase is turned into an array.
380
-								$keywords = explode( ' ', $keyphrase );
381
-								if ( ! is_array( $keywords ) ) {
382
-									$keywords = array( $keywords );
380
+								$keywords = explode(' ', $keyphrase);
381
+								if (!is_array($keywords)) {
382
+									$keywords = array($keywords);
383 383
 								}
384 384
 
385
-								if ( $this->multineedle_stripos( ltrim( rtrim( $row['name'] ) ), $keywords ) !== false ) {
386
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row, $row_key );
387
-								} elseif ( $this->multineedle_stripos( ltrim( rtrim( $row['reference_number'] ) ), $keywords ) !== false ) {
388
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row, $row_key );
389
-								} elseif ( $this->multineedle_stripos( ltrim( rtrim( $row['identifier_key'] ) ), $keywords ) !== false ) {
390
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row, $row_key );
385
+								if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) {
386
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row, $row_key);
387
+								} elseif ($this->multineedle_stripos(ltrim(rtrim($row['reference_number'])), $keywords) !== false) {
388
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row, $row_key);
389
+								} elseif ($this->multineedle_stripos(ltrim(rtrim($row['identifier_key'])), $keywords) !== false) {
390
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row, $row_key);
391 391
 								}
392 392
 							}
393 393
 						}
394 394
 					}
395 395
 				}
396 396
 
397
-				if ( false !== $searched_items ) {
398
-					$return = implode( $searched_items );
397
+				if (false !== $searched_items) {
398
+					$return = implode($searched_items);
399 399
 				}
400 400
 			}
401
-			print_r( $return );
401
+			print_r($return);
402 402
 			die();
403 403
 		}
404 404
 	}
@@ -406,34 +406,34 @@  discard block
 block discarded – undo
406 406
 	/**
407 407
 	 * Formats the row for output on the screen.
408 408
 	 */
409
-	public function format_row( $row = false, $row_key = '' ) {
410
-		if ( false !== $row ) {
409
+	public function format_row($row = false, $row_key = '') {
410
+		if (false !== $row) {
411 411
 			$status = 'import';
412 412
 
413
-			if ( 0 !== $row['post_id'] ) {
414
-				$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>';
413
+			if (0 !== $row['post_id']) {
414
+				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
415 415
 			}
416 416
 
417 417
 			$row_html = '
418
-			<tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '">
418
+			<tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'">
419 419
 				<td class="check-column">
420
-					<label for="cb-select-' . $row['identifier'] . '" class="screen-reader-text">' . $row['post_title'] . '</label>
421
-					<input type="checkbox" data-identifier="' . $row['identifier'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['identifier'] . '">
420
+					<label for="cb-select-' . $row['identifier'].'" class="screen-reader-text">'.$row['post_title'].'</label>
421
+					<input type="checkbox" data-identifier="' . $row['identifier'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['identifier'].'">
422 422
 				</td>
423 423
 				<td class="column-order">
424
-					' . ( $row_key + 1 ) . '
424
+					' . ($row_key + 1).'
425 425
 				</td>
426 426
 				<td class="post-title page-title column-title">
427
-					' . $row['post_title'] . ' - ' . $status . '
427
+					' . $row['post_title'].' - '.$status.'
428 428
 				</td>
429 429
 				<td class="date column-date">
430
-					' . $row['reference_number'] . '
430
+					' . $row['reference_number'].'
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['identifier'] . '
436
+					' . $row['identifier'].'
437 437
 				</td>
438 438
 			</tr>';
439 439
 			return $row_html;
@@ -443,44 +443,44 @@  discard block
 block discarded – undo
443 443
 	/**
444 444
 	 * Connect to wetu
445 445
 	 */
446
-	public function process_ajax_import( $force = false ) {
446
+	public function process_ajax_import($force = false) {
447 447
 		$return = false;
448
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
449
-		if ( isset( $_POST['action'] ) && 'lsx_import_items' === $_POST['action'] && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug && isset( $_POST['wetu_id'] ) ) {
448
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
449
+		if (isset($_POST['action']) && 'lsx_import_items' === $_POST['action'] && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) {
450 450
 
451
-			$wetu_id = sanitize_text_field( $_POST['wetu_id'] );
452
-			if ( isset( $_POST['post_id'] ) ) {
453
-				$post_id = sanitize_text_field( $_POST['post_id'] );
454
-			} else {
451
+			$wetu_id = sanitize_text_field($_POST['wetu_id']);
452
+			if (isset($_POST['post_id'])) {
453
+				$post_id = sanitize_text_field($_POST['post_id']);
454
+			}else {
455 455
 				$post_id = 0;
456 456
 			}
457 457
 
458
-			delete_option( 'lsx_wetu_importer_tour_settings' );
458
+			delete_option('lsx_wetu_importer_tour_settings');
459 459
 
460
-			if ( isset( $_POST['team_members'] ) ) {
461
-				$team_members = array_map( 'sanitize_text_field', wp_unslash( $_POST['team_members'] ) );
462
-			} else {
460
+			if (isset($_POST['team_members'])) {
461
+				$team_members = array_map('sanitize_text_field', wp_unslash($_POST['team_members']));
462
+			}else {
463 463
 				$team_members = false;
464 464
 			}
465 465
 
466
-			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
467
-				$content = array_map( 'sanitize_text_field', wp_unslash( $_POST['content'] ) );
468
-				add_option( 'lsx_wetu_importer_tour_settings', $content );
469
-			} else {
466
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
467
+				$content = array_map('sanitize_text_field', wp_unslash($_POST['content']));
468
+				add_option('lsx_wetu_importer_tour_settings', $content);
469
+			}else {
470 470
 				$content = false;
471 471
 			}
472
-			$jdata = wp_remote_get( 'https://wetu.com/API/Itinerary/V8/Get?id=' . $wetu_id );
472
+			$jdata = wp_remote_get('https://wetu.com/API/Itinerary/V8/Get?id='.$wetu_id);
473 473
 
474
-			if ( ! is_wp_error( $jdata ) && ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
475
-				$jdata  = json_decode( $jdata['body'], true );
476
-				$return = $this->import_row( $jdata, $wetu_id, $post_id, $team_members, $content );
477
-				$this->format_completed_row( $return );
474
+			if (!is_wp_error($jdata) && !empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
475
+				$jdata  = json_decode($jdata['body'], true);
476
+				$return = $this->import_row($jdata, $wetu_id, $post_id, $team_members, $content);
477
+				$this->format_completed_row($return);
478 478
 				$this->save_queue();
479 479
 				$this->cleanup_posts();
480
-				$this->attach_destination_images( $content );
481
-				$this->clean_attached_destinations( $return );
482
-			} else {
483
-				$this->format_error( esc_html__( 'There was a problem importing your tour, please try again.', 'lsx-wetu-importer' ) );
480
+				$this->attach_destination_images($content);
481
+				$this->clean_attached_destinations($return);
482
+			}else {
483
+				$this->format_error(esc_html__('There was a problem importing your tour, please try again.', 'lsx-wetu-importer'));
484 484
 			}
485 485
 		}
486 486
 	}
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
 	 * @param $id string
492 492
 	 * @return void
493 493
 	 */
494
-	public function clean_attached_destinations( $id ) {
495
-		$current_connections = get_post_meta( $id, 'destination_to_tour', false );
496
-		delete_post_meta( $id, 'destination_to_tour' );
497
-		$current_connections = array_unique( $current_connections );
494
+	public function clean_attached_destinations($id) {
495
+		$current_connections = get_post_meta($id, 'destination_to_tour', false);
496
+		delete_post_meta($id, 'destination_to_tour');
497
+		$current_connections = array_unique($current_connections);
498 498
 
499
-		foreach ( $current_connections as $connection ) {
500
-			add_post_meta( $id, 'destination_to_tour', $connection, false );
499
+		foreach ($current_connections as $connection) {
500
+			add_post_meta($id, 'destination_to_tour', $connection, false);
501 501
 		}
502 502
 	}
503 503
 
@@ -507,12 +507,12 @@  discard block
 block discarded – undo
507 507
 	 * @param $data array
508 508
 	 * @param $wetu_id string
509 509
 	 */
510
-	public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $old1 = false, $old2 = false ) {
510
+	public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $old1 = false, $old2 = false) {
511 511
 		$post_name         = '';
512 512
 		$data_post_content = '';
513 513
 		$data_post_excerpt = '';
514 514
 
515
-		$current_post = get_post( $id );
515
+		$current_post = get_post($id);
516 516
 
517 517
 		$post = array(
518 518
 			'post_type' => 'tour',
@@ -520,83 +520,83 @@  discard block
 block discarded – undo
520 520
 
521 521
 		$content_used_general_description = false;
522 522
 
523
-		if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) {
523
+		if (!empty($importable_content) && in_array('description', $importable_content)) {
524 524
 			$data_post_content = $current_post->post_content;
525
-			if ( isset( $data['summary'] ) && ! empty( $data['summary'] ) ) {
525
+			if (isset($data['summary']) && !empty($data['summary'])) {
526 526
 				$data_post_content = $data['summary'];
527 527
 			}
528 528
 			$post['post_content'] = $data_post_content;
529 529
 		}
530 530
 
531 531
 		// Create or update the post.
532
-		if ( false !== $id && '0' !== $id ) {
532
+		if (false !== $id && '0' !== $id) {
533 533
 			$post['ID']          = $id;
534 534
 			$post['post_status'] = 'publish';
535
-			if ( isset( $this->options ) && 'on' !== $this->options['disable_accommodation_title'] ) {
535
+			if (isset($this->options) && 'on' !== $this->options['disable_accommodation_title']) {
536 536
 				$post['post_title'] = $data['name'];
537 537
 			}
538
-			$id = wp_update_post( $post );
539
-		} else {
538
+			$id = wp_update_post($post);
539
+		}else {
540 540
 			// Set the name.
541
-			if ( isset( $data['name'] ) ) {
542
-				$post_name = wp_unique_post_slug( sanitize_title( $data['name'] ), $id, 'draft', 'tour', 0 );
541
+			if (isset($data['name'])) {
542
+				$post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0);
543 543
 			}
544 544
 
545
-			if ( ! isset( $post['post_content'] ) ) {
545
+			if (!isset($post['post_content'])) {
546 546
 				$post['post_content'] = ' ';
547 547
 			}
548 548
 
549 549
 			$post['post_name']   = $post_name;
550 550
 			$post['post_title']  = $data['name'];
551 551
 			$post['post_status'] = 'publish';
552
-			$id                  = wp_insert_post( $post );
552
+			$id                  = wp_insert_post($post);
553 553
 
554 554
 			// Save the WETU ID and the Last date it was modified.
555
-			if ( false !== $id ) {
556
-				add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
557
-				add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data['last_modified'] ) );
555
+			if (false !== $id) {
556
+				add_post_meta($id, 'lsx_wetu_id', $wetu_id);
557
+				add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']));
558 558
 			}
559 559
 		}
560 560
 
561 561
 		// Set reference number.
562
-		$this->set_reference_number( $data, $id );
562
+		$this->set_reference_number($data, $id);
563 563
 
564 564
 		// Set the team member if it is there.
565
-		if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) {
566
-			$this->set_team_member( $id, $team_members );
565
+		if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
566
+			$this->set_team_member($id, $team_members);
567 567
 		}
568 568
 
569 569
 		// Set the price.
570
-		if ( false !== $importable_content && in_array( 'price', $importable_content ) ) {
571
-			$this->set_price( $data, $id );
570
+		if (false !== $importable_content && in_array('price', $importable_content)) {
571
+			$this->set_price($data, $id);
572 572
 		}
573 573
 
574 574
 		// Set the Duration.
575
-		if ( false !== $importable_content && in_array( 'duration', $importable_content ) ) {
576
-			$this->set_duration( $data, $id );
575
+		if (false !== $importable_content && in_array('duration', $importable_content)) {
576
+			$this->set_duration($data, $id);
577 577
 		}
578 578
 
579 579
 		// Set the Group Size.
580
-		if ( false !== $importable_content && in_array( 'group_size', $importable_content ) ) {
581
-			$this->set_group_size( $data, $id );
580
+		if (false !== $importable_content && in_array('group_size', $importable_content)) {
581
+			$this->set_group_size($data, $id);
582 582
 		}
583 583
 
584 584
 		// Set the Group Size.
585
-		if ( false !== $importable_content && in_array( 'tags', $importable_content ) ) {
586
-			$this->set_travel_styles( $id, $data );
585
+		if (false !== $importable_content && in_array('tags', $importable_content)) {
586
+			$this->set_travel_styles($id, $data);
587 587
 		}
588 588
 
589 589
 		// Set the Start and End Point Destinations.
590
-		if ( false !== $importable_content && in_array( 'start_end_point', $importable_content ) ) {
591
-			$this->set_start_end_point( $data, $id );
590
+		if (false !== $importable_content && in_array('start_end_point', $importable_content)) {
591
+			$this->set_start_end_point($data, $id);
592 592
 		}
593 593
 
594
-		if ( false !== $importable_content && in_array( 'itineraries', $importable_content ) && isset( $data['legs'] ) && ! empty( $data['legs'] ) ) {
595
-			$this->process_itineraries( $data, $id, $importable_content );
594
+		if (false !== $importable_content && in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) {
595
+			$this->process_itineraries($data, $id, $importable_content);
596 596
 		}
597 597
 
598
-		if ( in_array( 'map', $importable_content ) && isset( $data['routes'] ) && ! empty( $data['routes'] ) ) {
599
-			$this->set_map_data( $data, $id );
598
+		if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) {
599
+			$this->set_map_data($data, $id);
600 600
 		}
601 601
 
602 602
 		return $id;
@@ -605,181 +605,181 @@  discard block
 block discarded – undo
605 605
 	/**
606 606
 	 * A loop which runs through each leg on the tour.
607 607
 	 */
608
-	public function process_itineraries( $data, $id, $importable_content ) {
608
+	public function process_itineraries($data, $id, $importable_content) {
609 609
 		$day_counter = 1;
610 610
 		$leg_counter = 0;
611 611
 
612
-		delete_post_meta( $id, 'itinerary' );
612
+		delete_post_meta($id, 'itinerary');
613 613
 
614
-		if ( false !== $importable_content && in_array( 'accommodation', $importable_content ) ) {
615
-			delete_post_meta( $id, 'accommodation_to_tour' );
614
+		if (false !== $importable_content && in_array('accommodation', $importable_content)) {
615
+			delete_post_meta($id, 'accommodation_to_tour');
616 616
 		}
617 617
 
618
-		foreach ( $data['legs'] as $leg ) {
618
+		foreach ($data['legs'] as $leg) {
619 619
 
620 620
 			// Itinerary Accommodation.
621 621
 			$current_accommodation = false;
622 622
 			$current_destination   = false;
623
-			if ( 'Mobile' !== $leg['type'] ) {
624
-				if ( false !== $importable_content && in_array( 'accommodation', $importable_content ) ) {
625
-					$current_accommodation = $this->set_accommodation( $leg, $id );
623
+			if ('Mobile' !== $leg['type']) {
624
+				if (false !== $importable_content && in_array('accommodation', $importable_content)) {
625
+					$current_accommodation = $this->set_accommodation($leg, $id);
626 626
 				}
627
-				if ( false !== $importable_content && in_array( 'destination', $importable_content ) ) {
628
-					$current_destination = $this->set_destination( $leg, $id, $leg_counter );
627
+				if (false !== $importable_content && in_array('destination', $importable_content)) {
628
+					$current_destination = $this->set_destination($leg, $id, $leg_counter);
629 629
 				}
630 630
 			}
631 631
 
632 632
 			// If the Nights are the same mount of days in the array,  then it isnt "By Destination".
633
-			if ( ( 1 <= (int) $leg['nights'] && isset( $leg['periods'] ) ) || 0 === $leg['itinerary_leg_id'] ) {
633
+			if ((1 <= (int) $leg['nights'] && isset($leg['periods'])) || 0 === $leg['itinerary_leg_id']) {
634 634
 
635
-				foreach ( $leg['periods'] as $day_key => $day ) {
635
+				foreach ($leg['periods'] as $day_key => $day) {
636 636
 					$current_day = array();
637 637
 
638 638
 					// If this is a moble tented solution.
639 639
 					$next_day_count = $day_counter + (int) $day['days'];
640 640
 
641
-					if ( ( isset( $leg['stops'] ) && 'Mobile' !== $leg['type'] ) || ( 1 < (int) $day['days'] ) ) {
642
-						$day_count_label = ' - ' . ( $next_day_count - 1 );
643
-					} else {
641
+					if ((isset($leg['stops']) && 'Mobile' !== $leg['type']) || (1 < (int) $day['days'])) {
642
+						$day_count_label = ' - '.($next_day_count - 1);
643
+					}else {
644 644
 						$day_count_label = '';
645 645
 					}
646
-					$current_day['title'] = esc_attr( 'Day ', 'lsx-wetu-importer' ) . $day_counter . $day_count_label;
646
+					$current_day['title'] = esc_attr('Day ', 'lsx-wetu-importer').$day_counter.$day_count_label;
647 647
 
648 648
 					// Description.
649
-					if ( false !== $importable_content && in_array( 'itinerary_description', $importable_content ) && isset( $day['notes'] ) ) {
649
+					if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) {
650 650
 						$current_day['description'] = $day['notes'];
651
-					} else {
651
+					}else {
652 652
 						$current_day['description'] = '';
653 653
 					}
654 654
 
655 655
 					// Itinerary Gallery.
656
-					if ( false !== $importable_content && in_array( 'itinerary_gallery', $importable_content ) && isset( $day['images'] ) ) {
656
+					if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) {
657 657
 						$current_day['featured_image'] = '';
658
-					} else {
658
+					}else {
659 659
 						$current_day['featured_image'] = '';
660 660
 					}
661 661
 
662 662
 					// If its a mobile safari, we need to get the destination and accommodation data from the stops.
663
-					if ( 'Mobile' === $leg['type'] ) {
664
-						$current_destination   = $this->get_mobile_destination( $day, $leg, $id );
665
-						$current_accommodation = $this->get_mobile_accommodation( $day, $leg, $id );
663
+					if ('Mobile' === $leg['type']) {
664
+						$current_destination   = $this->get_mobile_destination($day, $leg, $id);
665
+						$current_accommodation = $this->get_mobile_accommodation($day, $leg, $id);
666 666
 					}
667 667
 
668 668
 					// Accommodation.
669
-					if ( false !== $current_accommodation ) {
670
-						$current_day['accommodation_to_tour'] = array( $current_accommodation );
671
-					} else {
669
+					if (false !== $current_accommodation) {
670
+						$current_day['accommodation_to_tour'] = array($current_accommodation);
671
+					}else {
672 672
 						$current_day['accommodation_to_tour'] = array();
673 673
 					}
674 674
 
675 675
 					// Destination.
676
-					if ( false !== $current_destination ) {
677
-						$current_day['destination_to_tour'] = array( $current_destination );
678
-					} else {
676
+					if (false !== $current_destination) {
677
+						$current_day['destination_to_tour'] = array($current_destination);
678
+					}else {
679 679
 						$current_day['destination_to_tour'] = array();
680 680
 					}
681 681
 
682 682
 					// Included.
683
-					if ( false !== $importable_content && in_array( 'itinerary_included', $importable_content ) && isset( $day['included'] ) && '' !== $day['included'] ) {
683
+					if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) {
684 684
 						$current_day['included'] = $day['included'];
685
-					} else {
685
+					}else {
686 686
 						$current_day['included'] = '';
687 687
 					}
688 688
 
689 689
 					// Excluded.
690
-					if ( false !== $importable_content && in_array( 'itinerary_excluded', $importable_content ) && isset( $day['excluded'] ) && '' !== $day['excluded'] ) {
690
+					if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) {
691 691
 						$current_day['excluded'] = $day['excluded'];
692
-					} else {
692
+					}else {
693 693
 						$current_day['excluded'] = '';
694 694
 					}
695 695
 
696 696
 					// Excluded.
697
-					if ( false !== $importable_content && in_array( 'room_basis', $importable_content ) && isset( $day['room_basis'] ) && '' !== $day['room_basis'] ) {
697
+					if (false !== $importable_content && in_array('room_basis', $importable_content) && isset($day['room_basis']) && '' !== $day['room_basis']) {
698 698
 						$current_day['room_basis'] = $day['room_basis'];
699
-					} else {
699
+					}else {
700 700
 						$current_day['room_basis'] = '';
701 701
 					}
702 702
 
703 703
 					// Excluded.
704
-					if ( false !== $importable_content && in_array( 'drinks_basis', $importable_content ) && isset( $day['drinks_basis'] ) && '' !== $day['drinks_basis'] ) {
704
+					if (false !== $importable_content && in_array('drinks_basis', $importable_content) && isset($day['drinks_basis']) && '' !== $day['drinks_basis']) {
705 705
 						$current_day['drinks_basis'] = $day['drinks_basis'];
706
-					} else {
706
+					}else {
707 707
 						$current_day['drinks_basis'] = '';
708 708
 					}
709 709
 
710
-					$this->set_itinerary_day( $current_day, $id );
710
+					$this->set_itinerary_day($current_day, $id);
711 711
 					$day_counter = $next_day_count;
712 712
 				}
713
-			} else {
713
+			}else {
714 714
 				// This is for the by destination.
715 715
 
716 716
 				$current_day     = array();
717 717
 				$next_day_count  = $day_counter + (int) $leg['nights'];
718 718
 				$day_count_label = $next_day_count - 1;
719 719
 
720
-				$current_day['title'] = esc_attr( 'Day ', 'lsx-wetu-importer' ) . $day_counter;
720
+				$current_day['title'] = esc_attr('Day ', 'lsx-wetu-importer').$day_counter;
721 721
 
722
-				if ( 0 !== (int) $leg['nights'] ) {
723
-					$current_day['title'] .= ' - ' . $day_count_label;
722
+				if (0 !== (int) $leg['nights']) {
723
+					$current_day['title'] .= ' - '.$day_count_label;
724 724
 				}
725 725
 
726 726
 				// Description.
727
-				if ( false !== $importable_content && in_array( 'itinerary_description', $importable_content ) && isset( $leg['notes'] ) ) {
727
+				if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($leg['notes'])) {
728 728
 					$current_day['description'] = $leg['notes'];
729
-				} else {
729
+				}else {
730 730
 					$current_day['description'] = '';
731 731
 				}
732 732
 
733 733
 				// Itinerary Gallery.
734
-				if ( false !== $importable_content && in_array( 'itinerary_gallery', $importable_content ) && isset( $leg['images'] ) ) {
734
+				if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($leg['images'])) {
735 735
 					$current_day['featured_image'] = '';
736
-				} else {
736
+				}else {
737 737
 					$current_day['featured_image'] = '';
738 738
 				}
739 739
 
740 740
 				// Accommodation.
741
-				if ( false !== $current_accommodation ) {
742
-					$current_day['accommodation_to_tour'] = array( $current_accommodation );
743
-				} else {
741
+				if (false !== $current_accommodation) {
742
+					$current_day['accommodation_to_tour'] = array($current_accommodation);
743
+				}else {
744 744
 					$current_day['accommodation_to_tour'] = array();
745 745
 				}
746 746
 
747 747
 				// Destination.
748
-				if ( false !== $current_destination ) {
749
-					$current_day['destination_to_tour'] = array( $current_destination );
750
-				} else {
748
+				if (false !== $current_destination) {
749
+					$current_day['destination_to_tour'] = array($current_destination);
750
+				}else {
751 751
 					$current_day['destination_to_tour'] = array();
752 752
 				}
753 753
 
754 754
 				// Included.
755
-				if ( false !== $importable_content && in_array( 'itinerary_included', $importable_content ) && isset( $leg['included'] ) && '' !== $leg['included'] ) {
755
+				if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($leg['included']) && '' !== $leg['included']) {
756 756
 					$current_day['included'] = $leg['included'];
757
-				} else {
757
+				}else {
758 758
 					$current_day['included'] = '';
759 759
 				}
760 760
 
761 761
 				// Excluded.
762
-				if ( false !== $importable_content && in_array( 'itinerary_excluded', $importable_content ) && isset( $leg['excluded'] ) && '' !== $leg['excluded'] ) {
762
+				if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($leg['excluded']) && '' !== $leg['excluded']) {
763 763
 					$current_day['excluded'] = $leg['excluded'];
764
-				} else {
764
+				}else {
765 765
 					$current_day['excluded'] = '';
766 766
 				}
767 767
 
768 768
 				// Excluded.
769
-				if ( false !== $importable_content && in_array( 'room_basis', $importable_content ) && isset( $leg['room_basis'] ) && '' !== $leg['room_basis'] ) {
769
+				if (false !== $importable_content && in_array('room_basis', $importable_content) && isset($leg['room_basis']) && '' !== $leg['room_basis']) {
770 770
 					$current_day['room_basis'] = $leg['room_basis'];
771
-				} else {
771
+				}else {
772 772
 					$current_day['room_basis'] = '';
773 773
 				}
774 774
 
775 775
 				// Excluded.
776
-				if ( false !== $importable_content && in_array( 'drinks_basis', $importable_content ) && isset( $leg['drinks_basis'] ) && '' !== $leg['drinks_basis'] ) {
776
+				if (false !== $importable_content && in_array('drinks_basis', $importable_content) && isset($leg['drinks_basis']) && '' !== $leg['drinks_basis']) {
777 777
 					$current_day['drinks_basis'] = $leg['drinks_basis'];
778
-				} else {
778
+				}else {
779 779
 					$current_day['drinks_basis'] = '';
780 780
 				}
781 781
 
782
-				$this->set_itinerary_day( $current_day, $id );
782
+				$this->set_itinerary_day($current_day, $id);
783 783
 				$day_counter = $next_day_count;
784 784
 			}
785 785
 			$leg_counter++;
@@ -793,47 +793,47 @@  discard block
 block discarded – undo
793 793
 	 * @param string $id
794 794
 	 * @return void
795 795
 	 */
796
-	public function set_start_end_point( $data, $id ) {
797
-		delete_post_meta( $id, 'departs_from' );
798
-		delete_post_meta( $id, 'ends_in' );
796
+	public function set_start_end_point($data, $id) {
797
+		delete_post_meta($id, 'departs_from');
798
+		delete_post_meta($id, 'ends_in');
799 799
 		$departs_from = false;
800 800
 		$ends_in      = false;
801 801
 
802 802
 		$args = array(
803 803
 			'points'      => $data['legs'],
804 804
 			'start_index' => 0,
805
-			'end_index'   => count( $data['legs'] ) - 2,
805
+			'end_index'   => count($data['legs']) - 2,
806 806
 		);
807
-		$args = apply_filters( 'lsx_wetu_start_end_args', $args, $data );
807
+		$args = apply_filters('lsx_wetu_start_end_args', $args, $data);
808 808
 
809
-		if ( ! empty( $args['points'] ) && is_array( $args['points'] ) ) {
809
+		if (!empty($args['points']) && is_array($args['points'])) {
810 810
 			$leg_counter = 0;
811 811
 
812
-			foreach ( $args['points'] as $point ) {
812
+			foreach ($args['points'] as $point) {
813 813
 				// If we are in the first leg,  and the destination was attached then save it as the departure field.
814
-				if ( $leg_counter === $args['start_index'] ) {
815
-					$departs_from_destination = $this->set_country( $point['destination_content_entity_id'], $id );
816
-					if ( false !== $departs_from_destination ) {
814
+				if ($leg_counter === $args['start_index']) {
815
+					$departs_from_destination = $this->set_country($point['destination_content_entity_id'], $id);
816
+					if (false !== $departs_from_destination) {
817 817
 						$departs_from = $departs_from_destination;
818 818
 					}
819 819
 				}
820 820
 				// If its the last leg then save it as the ends in.
821
-				if ( $leg_counter === $args['end_index'] ) {
821
+				if ($leg_counter === $args['end_index']) {
822 822
 					$ends_in = $point['destination_content_entity_id'];
823 823
 				}
824 824
 				$leg_counter++;
825 825
 			}
826 826
 
827
-			$departs_from = apply_filters( 'lsx_wetu_departs_from_id', $departs_from, $data, $this );
828
-			if ( false !== $departs_from ) {
829
-				add_post_meta( $id, 'departs_from', $departs_from, true );
827
+			$departs_from = apply_filters('lsx_wetu_departs_from_id', $departs_from, $data, $this);
828
+			if (false !== $departs_from) {
829
+				add_post_meta($id, 'departs_from', $departs_from, true);
830 830
 			}
831 831
 
832
-			if ( false !== $ends_in ) {
833
-				$ends_in             = apply_filters( 'lsx_wetu_ends_in_id', $ends_in, $data, $this );
834
-				$ends_in_destination = $this->set_country( $ends_in, $id );
835
-				if ( false !== $ends_in_destination ) {
836
-					add_post_meta( $id, 'ends_in', $ends_in_destination, true );
832
+			if (false !== $ends_in) {
833
+				$ends_in             = apply_filters('lsx_wetu_ends_in_id', $ends_in, $data, $this);
834
+				$ends_in_destination = $this->set_country($ends_in, $id);
835
+				if (false !== $ends_in_destination) {
836
+					add_post_meta($id, 'ends_in', $ends_in_destination, true);
837 837
 				}
838 838
 			}
839 839
 		}
@@ -846,15 +846,15 @@  discard block
 block discarded – undo
846 846
 	 * @param $leg
847 847
 	 * @return void
848 848
 	 */
849
-	public function get_mobile_destination( $day, $leg, $id ) {
849
+	public function get_mobile_destination($day, $leg, $id) {
850 850
 		$current_destination = false;
851 851
 		$current_day         = (int) $day['period_start_day'];
852
-		if ( isset( $leg['stops'] ) ) {
853
-			foreach ( $leg['stops'] as $stop ) {
852
+		if (isset($leg['stops'])) {
853
+			foreach ($leg['stops'] as $stop) {
854 854
 				$arrival_day   = (int) $stop['arrival_day'];
855 855
 				$departure_day = (int) $stop['departure_day'];
856
-				if ( $arrival_day <= $current_day && $current_day < $departure_day ) {
857
-					$current_destination = $this->set_destination( $stop, $id, 0 );
856
+				if ($arrival_day <= $current_day && $current_day < $departure_day) {
857
+					$current_destination = $this->set_destination($stop, $id, 0);
858 858
 				}
859 859
 			}
860 860
 		}
@@ -868,15 +868,15 @@  discard block
 block discarded – undo
868 868
 	 * @param $leg
869 869
 	 * @return void
870 870
 	 */
871
-	public function get_mobile_accommodation( $day, $leg, $id ) {
871
+	public function get_mobile_accommodation($day, $leg, $id) {
872 872
 		$current_accommodation = false;
873 873
 		$current_day           = (int) $day['period_start_day'];
874
-		if ( isset( $leg['stops'] ) ) {
875
-			foreach ( $leg['stops'] as $stop ) {
874
+		if (isset($leg['stops'])) {
875
+			foreach ($leg['stops'] as $stop) {
876 876
 				$arrival_day   = (int) $stop['arrival_day'];
877 877
 				$departure_day = (int) $stop['departure_day'];
878
-				if ( $arrival_day <= $current_day && $current_day < $departure_day ) {
879
-					$current_accommodation = $this->set_accommodation( $stop, $id, 0 );
878
+				if ($arrival_day <= $current_day && $current_day < $departure_day) {
879
+					$current_accommodation = $this->set_accommodation($stop, $id, 0);
880 880
 				}
881 881
 			}
882 882
 		}
@@ -886,29 +886,29 @@  discard block
 block discarded – undo
886 886
 	/**
887 887
 	 * Run through your routes and save the points as a KML file.
888 888
 	 */
889
-	public function set_map_data( $data, $id, $zoom = 9 ) {
890
-		if ( ! empty( $data['routes'] ) ) {
891
-			delete_post_meta( $id, 'wetu_map_points' );
889
+	public function set_map_data($data, $id, $zoom = 9) {
890
+		if (!empty($data['routes'])) {
891
+			delete_post_meta($id, 'wetu_map_points');
892 892
 
893 893
 			$points = array();
894 894
 
895
-			foreach ( $data['routes'] as $route ) {
895
+			foreach ($data['routes'] as $route) {
896 896
 
897
-				if ( isset( $route['points'] ) && '' !== $route['points'] ) {
897
+				if (isset($route['points']) && '' !== $route['points']) {
898 898
 
899
-					$temp_points   = explode( ';', $route['points'] );
900
-					$point_counter = count( $temp_points );
899
+					$temp_points   = explode(';', $route['points']);
900
+					$point_counter = count($temp_points);
901 901
 
902
-					for ( $x = 0; $x <= $point_counter; $x++ ) {
902
+					for ($x = 0; $x <= $point_counter; $x++) {
903 903
 						$y        = $x + 1;
904
-						$points[] = $temp_points[ $x ] . ',' . $temp_points[ $y ];
904
+						$points[] = $temp_points[$x].','.$temp_points[$y];
905 905
 						$x++;
906 906
 					}
907 907
 				}
908 908
 			}
909 909
 
910
-			if ( ! empty( $points ) ) {
911
-				$this->save_custom_field( implode( ' ', $points ), 'wetu_map_points', $id, false, true );
910
+			if (!empty($points)) {
911
+				$this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true);
912 912
 			}
913 913
 		}
914 914
 
@@ -919,64 +919,64 @@  discard block
 block discarded – undo
919 919
 	/**
920 920
 	 * Set the Itinerary Day.
921 921
 	 */
922
-	public function set_itinerary_day( $day, $id ) {
923
-		$this->save_custom_field( $day, 'itinerary', $id, false, false );
922
+	public function set_itinerary_day($day, $id) {
923
+		$this->save_custom_field($day, 'itinerary', $id, false, false);
924 924
 	}
925 925
 
926 926
 	/**
927 927
 	 * Set the ref number
928 928
 	 */
929
-	public function set_reference_number( $data, $id ) {
930
-		if ( isset( $data['reference_number'] ) && '' !== $data['reference_number'] ) {
931
-			$this->save_custom_field( $data['reference_number'], 'lsx_wetu_ref', $id );
929
+	public function set_reference_number($data, $id) {
930
+		if (isset($data['reference_number']) && '' !== $data['reference_number']) {
931
+			$this->save_custom_field($data['reference_number'], 'lsx_wetu_ref', $id);
932 932
 		}
933 933
 	}
934 934
 
935 935
 	/**
936 936
 	 * Set the price.
937 937
 	 */
938
-	public function set_price( $data, $id ) {
938
+	public function set_price($data, $id) {
939 939
 		// Price.
940
-		if ( isset( $data['price'] ) && '' !== $data['price'] ) {
940
+		if (isset($data['price']) && '' !== $data['price']) {
941 941
 			$price = $data['price'];
942
-			if ( false === apply_filters( 'lsx_wetu_importer_disable_tour_price_filter', false ) ) {
943
-				$price = preg_replace( '/[^0-9,.]/', '', $price );
942
+			if (false === apply_filters('lsx_wetu_importer_disable_tour_price_filter', false)) {
943
+				$price = preg_replace('/[^0-9,.]/', '', $price);
944 944
 			}
945
-			$meta_key = apply_filters( 'lsx_wetu_importer_price_meta_key', 'price' );
946
-			$this->save_custom_field( $price, $meta_key, $id );
945
+			$meta_key = apply_filters('lsx_wetu_importer_price_meta_key', 'price');
946
+			$this->save_custom_field($price, $meta_key, $id);
947 947
 		}
948 948
 
949 949
 		// Price includes.
950
-		if ( isset( $data['price_includes'] ) && '' !== $data['price_includes'] ) {
951
-			$meta_key = apply_filters( 'lsx_wetu_importer_included_meta_key', 'included' );
952
-			$this->save_custom_field( $data['price_includes'], $meta_key, $id );
950
+		if (isset($data['price_includes']) && '' !== $data['price_includes']) {
951
+			$meta_key = apply_filters('lsx_wetu_importer_included_meta_key', 'included');
952
+			$this->save_custom_field($data['price_includes'], $meta_key, $id);
953 953
 		}
954 954
 
955 955
 		// Price Excludes.
956
-		if ( isset( $data['price_excludes'] ) && '' !== $data['price_excludes'] ) {
957
-			$meta_key = apply_filters( 'lsx_wetu_importer_not_included_meta_key', 'not_included' );
958
-			$this->save_custom_field( $data['price_excludes'], $meta_key, $id );
956
+		if (isset($data['price_excludes']) && '' !== $data['price_excludes']) {
957
+			$meta_key = apply_filters('lsx_wetu_importer_not_included_meta_key', 'not_included');
958
+			$this->save_custom_field($data['price_excludes'], $meta_key, $id);
959 959
 		}
960 960
 	}
961 961
 
962 962
 	/**
963 963
 	 * Set the duration.
964 964
 	 */
965
-	public function set_duration( $data, $id ) {
966
-		if ( isset( $data['days'] ) && ! empty( $data['days'] ) ) {
965
+	public function set_duration($data, $id) {
966
+		if (isset($data['days']) && !empty($data['days'])) {
967 967
 			$price = $data['days'];
968
-			$price = preg_replace( '/[^0-9,.]/', '', $price );
969
-			$this->save_custom_field( $price, 'duration', $id );
968
+			$price = preg_replace('/[^0-9,.]/', '', $price);
969
+			$this->save_custom_field($price, 'duration', $id);
970 970
 		}
971 971
 	}
972 972
 
973 973
 	/**
974 974
 	 * Set the group size
975 975
 	 */
976
-	public function set_group_size( $data, $id ) {
977
-		if ( isset( $data['group_size'] ) && ! empty( $data['group_size'] ) ) {
976
+	public function set_group_size($data, $id) {
977
+		if (isset($data['group_size']) && !empty($data['group_size'])) {
978 978
 			$group_size = $data['group_size'];
979
-			$this->save_custom_field( $group_size, 'group_size', $id );
979
+			$this->save_custom_field($group_size, 'group_size', $id);
980 980
 		}
981 981
 	}
982 982
 
@@ -987,11 +987,11 @@  discard block
 block discarded – undo
987 987
 	 * @param array  $travel_styles
988 988
 	 * @return void
989 989
 	 */
990
-	public function set_travel_styles( $id, $data ) {
991
-		$tags = apply_filters( 'lsx_wetu_importer_tour_travel_styles', $data['tags'] );
992
-		if ( isset( $data['tags'] ) && ! empty( $tags ) ) {
993
-			foreach ( $tags as $tag ) {
994
-				$this->set_term( $id, $tag, 'travel-style' );
990
+	public function set_travel_styles($id, $data) {
991
+		$tags = apply_filters('lsx_wetu_importer_tour_travel_styles', $data['tags']);
992
+		if (isset($data['tags']) && !empty($tags)) {
993
+			foreach ($tags as $tag) {
994
+				$this->set_term($id, $tag, 'travel-style');
995 995
 			}
996 996
 		}
997 997
 	}
@@ -999,14 +999,14 @@  discard block
 block discarded – undo
999 999
 	/**
1000 1000
 	 * Connects the Accommodation if its available
1001 1001
 	 */
1002
-	public function set_accommodation( $day, $id ) {
1002
+	public function set_accommodation($day, $id) {
1003 1003
 		$ac_id                       = false;
1004 1004
 		$this->current_accommodation = $this->find_current_accommodation();
1005 1005
 
1006
-		if ( isset( $day['content_entity_id'] ) && ! empty( $day['content_entity_id'] ) ) {
1007
-			if ( false !== $this->current_accommodation && ! empty( $this->current_accommodation ) && array_key_exists( $day['content_entity_id'], $this->current_accommodation ) ) {
1008
-				$ac_id = $this->current_accommodation[ $day['content_entity_id'] ];
1009
-			} else {
1006
+		if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) {
1007
+			if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) {
1008
+				$ac_id = $this->current_accommodation[$day['content_entity_id']];
1009
+			}else {
1010 1010
 				$ac_id = wp_insert_post(
1011 1011
 					array(
1012 1012
 						'post_type'   => 'accommodation',
@@ -1015,13 +1015,13 @@  discard block
 block discarded – undo
1015 1015
 					)
1016 1016
 				);
1017 1017
 
1018
-				$this->save_custom_field( $day['content_entity_id'], 'lsx_wetu_id', $ac_id );
1018
+				$this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id);
1019 1019
 			}
1020 1020
 
1021
-			if ( '' !== $ac_id && false !== $ac_id ) {
1022
-				$this->save_custom_field( $ac_id, 'accommodation_to_tour', $id, false, false );
1023
-				$this->save_custom_field( $id, 'tour_to_accommodation', $ac_id, false, false );
1024
-				$this->queue_item( $ac_id );
1021
+			if ('' !== $ac_id && false !== $ac_id) {
1022
+				$this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false);
1023
+				$this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false);
1024
+				$this->queue_item($ac_id);
1025 1025
 			}
1026 1026
 		}
1027 1027
 		return $ac_id;
@@ -1033,14 +1033,14 @@  discard block
 block discarded – undo
1033 1033
 	 * @param $post_type string
1034 1034
 	 * @return boolean / array
1035 1035
 	 */
1036
-	public function find_current_accommodation( $post_type = 'accommodation' ) {
1036
+	public function find_current_accommodation($post_type = 'accommodation') {
1037 1037
 		global $wpdb;
1038
-		$accommodation = parent::find_current_accommodation( $post_type );
1038
+		$accommodation = parent::find_current_accommodation($post_type);
1039 1039
 		$return        = false;
1040 1040
 
1041
-		if ( ! empty( $accommodation ) ) {
1042
-			foreach ( $accommodation as $key => $acc ) {
1043
-				$return[ $acc->meta_value ] = $acc->post_id;
1041
+		if (!empty($accommodation)) {
1042
+			foreach ($accommodation as $key => $acc) {
1043
+				$return[$acc->meta_value] = $acc->post_id;
1044 1044
 			}
1045 1045
 		}
1046 1046
 
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 	 * @return boolean / array
1054 1054
 	 */
1055 1055
 	public function find_current_destinations() {
1056
-		return $this->find_current_accommodation( 'destination' );
1056
+		return $this->find_current_accommodation('destination');
1057 1057
 	}
1058 1058
 
1059 1059
 	/**
@@ -1063,45 +1063,45 @@  discard block
 block discarded – undo
1063 1063
 	 * @param $id string
1064 1064
 	 * @return boolean / string
1065 1065
 	 */
1066
-	public function set_destination( $day, $id, $leg_counter ) {
1066
+	public function set_destination($day, $id, $leg_counter) {
1067 1067
 		$dest_id    = false;
1068 1068
 		$country_id = false;
1069 1069
 
1070 1070
 		$this->current_destinations = $this->find_current_destinations();
1071 1071
 
1072
-		if ( isset( $day['destination_content_entity_id'] ) && ! empty( $day['destination_content_entity_id'] ) ) {
1073
-			if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $day['destination_content_entity_id'], $this->current_destinations ) ) {
1074
-				$dest_id = $this->current_destinations[ $day['destination_content_entity_id'] ];
1072
+		if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) {
1073
+			if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) {
1074
+				$dest_id = $this->current_destinations[$day['destination_content_entity_id']];
1075 1075
 
1076 1076
 				// TODO Check for attachments here.
1077
-				$this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] );
1077
+				$this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']);
1078 1078
 
1079 1079
 				// Check if there is a country asigned.
1080
-				$potential_id    = wp_get_post_parent_id( $dest_id );
1081
-				$country_wetu_id = get_post_meta( $potential_id, 'lsx_wetu_id', true );
1080
+				$potential_id    = wp_get_post_parent_id($dest_id);
1081
+				$country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true);
1082 1082
 
1083
-				if ( false !== $country_wetu_id ) {
1084
-					$country_id = $this->set_country( $country_wetu_id, $id );
1083
+				if (false !== $country_wetu_id) {
1084
+					$country_id = $this->set_country($country_wetu_id, $id);
1085 1085
 					// $this->destination_images[ $id ][] = array( $id, $country_wetu_id );
1086 1086
 				}
1087
-			} else {
1088
-				$destination_json = wp_remote_get( 'https://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $day['destination_content_entity_id'] );
1087
+			}else {
1088
+				$destination_json = wp_remote_get('https://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$day['destination_content_entity_id']);
1089 1089
 
1090
-				if ( ! is_wp_error( $destination_json ) && ! empty( $destination_json ) && isset( $destination_json['response'] ) && isset( $destination_json['response']['code'] ) && 200 === $destination_json['response']['code'] ) {
1090
+				if (!is_wp_error($destination_json) && !empty($destination_json) && isset($destination_json['response']) && isset($destination_json['response']['code']) && 200 === $destination_json['response']['code']) {
1091 1091
 
1092
-					$destination_data = json_decode( $destination_json['body'], true );
1092
+					$destination_data = json_decode($destination_json['body'], true);
1093 1093
 
1094
-					if ( ! empty( $destination_data ) && ! isset( $destination_data['error'] ) ) {
1094
+					if (!empty($destination_data) && !isset($destination_data['error'])) {
1095 1095
 						$destination_title = $day['destination_content_entity_id'];
1096 1096
 
1097
-						if ( isset( $destination_data[0]['name'] ) ) {
1097
+						if (isset($destination_data[0]['name'])) {
1098 1098
 							$destination_title = $destination_data[0]['name'];
1099 1099
 						}
1100 1100
 
1101
-						if ( isset( $destination_data[0]['map_object_id'] ) && isset( $destination_data[0]['position']['country_content_entity_id'] )
1102
-							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id'] ) {
1101
+						if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
1102
+							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) {
1103 1103
 
1104
-							$country_id = $this->set_country( $destination_data[0]['position']['country_content_entity_id'], $id );
1104
+							$country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id);
1105 1105
 							// Save the destination so we can grab the tour featured image and banner from them.
1106 1106
 						}
1107 1107
 
@@ -1111,40 +1111,40 @@  discard block
 block discarded – undo
1111 1111
 							'post_title'  => $destination_title,
1112 1112
 						);
1113 1113
 
1114
-						if ( false !== $country_id ) {
1114
+						if (false !== $country_id) {
1115 1115
 							$dest_post['post_parent'] = $country_id;
1116 1116
 						}
1117
-						$dest_id = wp_insert_post( $dest_post );
1117
+						$dest_id = wp_insert_post($dest_post);
1118 1118
 
1119 1119
 						// Make sure we register the.
1120
-						$this->current_destinations[ $day['destination_content_entity_id'] ] = $dest_id;
1120
+						$this->current_destinations[$day['destination_content_entity_id']] = $dest_id;
1121 1121
 
1122 1122
 						// If there are images attached then use the destination.
1123
-						if ( isset( $destination_data[0]['content']['images'] ) && ! empty( $destination_data[0]['content']['images'] ) ) {
1124
-							$this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] );
1123
+						if (isset($destination_data[0]['content']['images']) && !empty($destination_data[0]['content']['images'])) {
1124
+							$this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']);
1125 1125
 						}
1126 1126
 
1127
-						$this->save_custom_field( $day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id );
1127
+						$this->save_custom_field($day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id);
1128 1128
 					}
1129 1129
 				}
1130 1130
 			}
1131 1131
 
1132
-			if ( '' !== $dest_id && false !== $dest_id ) {
1133
-				$this->save_custom_field( $dest_id, 'destination_to_tour', $id, false, false );
1134
-				$this->save_custom_field( $id, 'tour_to_destination', $dest_id, false, false );
1132
+			if ('' !== $dest_id && false !== $dest_id) {
1133
+				$this->save_custom_field($dest_id, 'destination_to_tour', $id, false, false);
1134
+				$this->save_custom_field($id, 'tour_to_destination', $dest_id, false, false);
1135 1135
 
1136 1136
 				// Save the item to display in the queue
1137
-				$this->queue_item( $dest_id );
1137
+				$this->queue_item($dest_id);
1138 1138
 
1139 1139
 				// Save the item to clean up the amount of connections.
1140
-				$this->cleanup_posts[ $dest_id ] = 'tour_to_destination';
1140
+				$this->cleanup_posts[$dest_id] = 'tour_to_destination';
1141 1141
 
1142 1142
 				// Add this relation info so we can make sure certain items are set as countries.
1143
-				if ( 0 !== $country_id && false !== $country_id ) {
1144
-					$this->relation_meta[ $dest_id ]    = $country_id;
1145
-					$this->relation_meta[ $country_id ] = 0;
1146
-				} else {
1147
-					$this->relation_meta[ $dest_id ] = 0;
1143
+				if (0 !== $country_id && false !== $country_id) {
1144
+					$this->relation_meta[$dest_id]    = $country_id;
1145
+					$this->relation_meta[$country_id] = 0;
1146
+				}else {
1147
+					$this->relation_meta[$dest_id] = 0;
1148 1148
 				}
1149 1149
 			}
1150 1150
 		}
@@ -1160,23 +1160,23 @@  discard block
 block discarded – undo
1160 1160
 	 *
1161 1161
 	 * @return string
1162 1162
 	 */
1163
-	public function set_country( $country_wetu_id, $id ) {
1163
+	public function set_country($country_wetu_id, $id) {
1164 1164
 		$country_id                 = false;
1165 1165
 		$this->current_destinations = $this->find_current_destinations();
1166 1166
 
1167
-		if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $country_wetu_id, $this->current_destinations ) ) {
1168
-			$country_id                        = $this->current_destinations[ $country_wetu_id ];
1169
-			$this->destination_images[ $id ][] = array( $country_id, $country_wetu_id );
1170
-		} else {
1171
-			$country_json = wp_remote_get( 'https://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $country_wetu_id );
1167
+		if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
1168
+			$country_id                        = $this->current_destinations[$country_wetu_id];
1169
+			$this->destination_images[$id][] = array($country_id, $country_wetu_id);
1170
+		}else {
1171
+			$country_json = wp_remote_get('https://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$country_wetu_id);
1172 1172
 
1173
-			if ( ! is_wp_error( $country_json ) && ! empty( $country_json ) && isset( $country_json['response'] ) && isset( $country_json['response']['code'] ) && 200 === $country_json['response']['code'] ) {
1174
-				$country_data = json_decode( $country_json['body'], true );
1173
+			if (!is_wp_error($country_json) && !empty($country_json) && isset($country_json['response']) && isset($country_json['response']['code']) && 200 === $country_json['response']['code']) {
1174
+				$country_data = json_decode($country_json['body'], true);
1175 1175
 
1176 1176
 				// Format the title of the destination if its available,  otherwise default to the WETU ID.
1177 1177
 				$country_title = $country_wetu_id;
1178 1178
 
1179
-				if ( isset( $country_data[0]['name'] ) ) {
1179
+				if (isset($country_data[0]['name'])) {
1180 1180
 					$country_title = $country_data[0]['name'];
1181 1181
 				}
1182 1182
 
@@ -1189,23 +1189,23 @@  discard block
 block discarded – undo
1189 1189
 				);
1190 1190
 
1191 1191
 				// add the country to the current destination stack
1192
-				$this->current_destinations[ $country_wetu_id ] = $country_id;
1192
+				$this->current_destinations[$country_wetu_id] = $country_id;
1193 1193
 
1194 1194
 				// Check if there are images and save fore use later.
1195
-				if ( isset( $country_data[0]['content']['images'] ) && ! empty( $country_data[0]['content']['images'] ) ) {
1196
-					$this->destination_images[ $id ][] = array( $country_id, $country_wetu_id );
1195
+				if (isset($country_data[0]['content']['images']) && !empty($country_data[0]['content']['images'])) {
1196
+					$this->destination_images[$id][] = array($country_id, $country_wetu_id);
1197 1197
 				}
1198 1198
 
1199 1199
 				// Save the wetu field
1200
-				$this->save_custom_field( $country_wetu_id, 'lsx_wetu_id', $country_id );
1200
+				$this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
1201 1201
 			}
1202 1202
 		}
1203 1203
 
1204
-		if ( '' !== $country_id && false !== $country_id ) {
1205
-			$this->save_custom_field( $country_id, 'destination_to_tour', $id, false, false );
1206
-			$this->save_custom_field( $id, 'tour_to_destination', $country_id, false, false );
1207
-			$this->queue_item( $country_id );
1208
-			$this->cleanup_posts[ $country_id ] = 'tour_to_destination';
1204
+		if ('' !== $country_id && false !== $country_id) {
1205
+			$this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
1206
+			$this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
1207
+			$this->queue_item($country_id);
1208
+			$this->cleanup_posts[$country_id] = 'tour_to_destination';
1209 1209
 
1210 1210
 			return $country_id;
1211 1211
 		}
@@ -1220,42 +1220,42 @@  discard block
 block discarded – undo
1220 1220
 	 *
1221 1221
 	 * @return string
1222 1222
 	 */
1223
-	public function attach_destination_images( $importable_content = array() ) {
1224
-		if ( false !== $this->destination_images ) {
1225
-			$this->shuffle_assoc( $this->destination_images );
1226
-			foreach ( $this->destination_images as $tour => $destinations ) {
1227
-				shuffle( $destinations );
1223
+	public function attach_destination_images($importable_content = array()) {
1224
+		if (false !== $this->destination_images) {
1225
+			$this->shuffle_assoc($this->destination_images);
1226
+			foreach ($this->destination_images as $tour => $destinations) {
1227
+				shuffle($destinations);
1228 1228
 				$image_set = false;
1229 1229
 				$forced    = false;
1230 1230
 
1231
-				foreach ( $destinations as $destination ) {
1232
-					if ( false === $image_set && false === $forced ) {
1233
-						$url = 'https://wetu.com/API/Pins/' . $this->api_key;
1231
+				foreach ($destinations as $destination) {
1232
+					if (false === $image_set && false === $forced) {
1233
+						$url = 'https://wetu.com/API/Pins/'.$this->api_key;
1234 1234
 
1235 1235
 						$url_qs = '';
1236
-						$jdata  = wp_remote_get( $url . '/Get?' . $url_qs . '&ids=' . $destination[1] );
1236
+						$jdata  = wp_remote_get($url.'/Get?'.$url_qs.'&ids='.$destination[1]);
1237 1237
 
1238
-						if ( ! is_wp_error( $jdata ) && ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
1239
-							$adata = json_decode( $jdata['body'], true );
1238
+						if (!is_wp_error($jdata) && !empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
1239
+							$adata = json_decode($jdata['body'], true);
1240 1240
 
1241
-							if ( ! empty( $adata ) && ! empty( $adata[0]['content']['images'] ) ) {
1242
-								$this->find_attachments( $destination[0] );
1241
+							if (!empty($adata) && !empty($adata[0]['content']['images'])) {
1242
+								$this->find_attachments($destination[0]);
1243 1243
 
1244 1244
 								// Set the featured image.
1245
-								if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
1246
-									$image_set = $this->set_featured_image( $adata, $tour );
1247
-									if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
1248
-										$image_set = $this->set_banner_image( $adata, $tour );
1245
+								if (false !== $importable_content && in_array('featured_image', $importable_content)) {
1246
+									$image_set = $this->set_featured_image($adata, $tour);
1247
+									if (false !== $importable_content && in_array('banner_image', $importable_content)) {
1248
+										$image_set = $this->set_banner_image($adata, $tour);
1249 1249
 										$forced    = true;
1250 1250
 									}
1251 1251
 									continue;
1252 1252
 								}
1253
-								if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
1254
-									$image_set = $this->set_banner_image( $adata, $tour );
1253
+								if (false !== $importable_content && in_array('banner_image', $importable_content)) {
1254
+									$image_set = $this->set_banner_image($adata, $tour);
1255 1255
 								}
1256 1256
 							}
1257 1257
 						}
1258
-					} else {
1258
+					}else {
1259 1259
 						continue;
1260 1260
 					}
1261 1261
 				}
@@ -1266,31 +1266,31 @@  discard block
 block discarded – undo
1266 1266
 	/**
1267 1267
 	 * Creates the main gallery data
1268 1268
 	 */
1269
-	public function set_featured_image( $data, $id ) {
1269
+	public function set_featured_image($data, $id) {
1270 1270
 		$image_set = false;
1271 1271
 		$counter   = 0;
1272 1272
 
1273
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
1273
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
1274 1274
 			$images_array = $data[0]['content']['images'];
1275 1275
 
1276
-			if ( 'on' === $this->options['enable_tour_featured_random'] ) {
1277
-				shuffle( $images_array );
1276
+			if ('on' === $this->options['enable_tour_featured_random']) {
1277
+				shuffle($images_array);
1278 1278
 			}
1279 1279
 
1280
-			foreach ( $images_array as $v ) {
1280
+			foreach ($images_array as $v) {
1281 1281
 
1282
-				if ( true === $image_set ) {
1282
+				if (true === $image_set) {
1283 1283
 					$counter++;
1284 1284
 					continue;
1285 1285
 				}
1286 1286
 
1287
-				if ( ! $this->check_if_image_is_used( $v ) ) {
1288
-					$temp_featured_image = $this->attach_image( $v, $id );
1287
+				if (!$this->check_if_image_is_used($v)) {
1288
+					$temp_featured_image = $this->attach_image($v, $id);
1289 1289
 
1290
-					if ( false !== $temp_featured_image ) {
1290
+					if (false !== $temp_featured_image) {
1291 1291
 						$this->featured_image = $temp_featured_image;
1292
-						delete_post_meta( $id, '_thumbnail_id' );
1293
-						add_post_meta( $id, '_thumbnail_id', $this->featured_image, true );
1292
+						delete_post_meta($id, '_thumbnail_id');
1293
+						add_post_meta($id, '_thumbnail_id', $this->featured_image, true);
1294 1294
 						$image_set = true;
1295 1295
 					}
1296 1296
 				}
@@ -1304,24 +1304,24 @@  discard block
 block discarded – undo
1304 1304
 	/**
1305 1305
 	 * Sets a banner image
1306 1306
 	 */
1307
-	public function set_banner_image( $data, $id, $content = array( 'none' ) ) {
1307
+	public function set_banner_image($data, $id, $content = array('none')) {
1308 1308
 		$image_set = false;
1309 1309
 		$counter   = 0;
1310 1310
 
1311
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
1311
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
1312 1312
 
1313
-			foreach ( $data[0]['content']['images'] as $v ) {
1313
+			foreach ($data[0]['content']['images'] as $v) {
1314 1314
 				/*
1315 1315
 				print_r('<pre>');
1316 1316
 				print_r( $v );
1317 1317
 				print_r('</pre>');*/
1318 1318
 
1319
-				if ( true === $image_set || 0 === $counter ) {
1319
+				if (true === $image_set || 0 === $counter) {
1320 1320
 					$counter++;
1321 1321
 					continue;
1322 1322
 				}
1323 1323
 
1324
-				if ( ! $this->check_if_image_is_used( $v ) ) {
1324
+				if (!$this->check_if_image_is_used($v)) {
1325 1325
 					$temp_banner = $this->attach_image(
1326 1326
 						$v,
1327 1327
 						$id,
@@ -1332,17 +1332,17 @@  discard block
 block discarded – undo
1332 1332
 						)
1333 1333
 					);
1334 1334
 
1335
-					if ( false !== $temp_banner ) {
1335
+					if (false !== $temp_banner) {
1336 1336
 						$this->banner_image = $temp_banner;
1337 1337
 
1338
-						delete_post_meta( $id, 'image_group' );
1338
+						delete_post_meta($id, 'image_group');
1339 1339
 
1340 1340
 						$new_banner = array(
1341 1341
 							'banner_image' => array(
1342 1342
 								'cmb-field-0' => $this->banner_image,
1343 1343
 							),
1344 1344
 						);
1345
-						add_post_meta( $id, 'image_group', $new_banner, true );
1345
+						add_post_meta($id, 'image_group', $new_banner, true);
1346 1346
 						$image_set = true;
1347 1347
 					}
1348 1348
 				}
@@ -1356,29 +1356,29 @@  discard block
 block discarded – undo
1356 1356
 	/**
1357 1357
 	 * Grabs all of the current used featured images on the site.
1358 1358
 	 */
1359
-	public function check_if_image_is_used( $v ) {
1359
+	public function check_if_image_is_used($v) {
1360 1360
 		global $wpdb;
1361 1361
 		$return = false;
1362 1362
 
1363
-		$results        = $wpdb->get_results(
1363
+		$results = $wpdb->get_results(
1364 1364
 			$wpdb->prepare(
1365 1365
 				"SELECT post_id
1366 1366
 				 FROM {$wpdb->postmeta}
1367 1367
 				 WHERE meta_value = '%s'
1368 1368
 				 AND meta_key = 'lsx_wetu_id'
1369 1369
 				",
1370
-				array( $value )
1370
+				array($value)
1371 1371
 			)
1372 1372
 		);
1373 1373
 		$attached_tours = array();
1374
-		if ( ! empty( $results ) ) {
1375
-			foreach ( $results as $result ) {
1376
-				if ( 'tour' === get_post_type( $result['post_id'] ) ) {
1374
+		if (!empty($results)) {
1375
+			foreach ($results as $result) {
1376
+				if ('tour' === get_post_type($result['post_id'])) {
1377 1377
 					$attached_tours[] = $result['post_id'];
1378 1378
 				}
1379 1379
 			}
1380 1380
 		}
1381
-		if ( ! empty( $attached_tours ) ) {
1381
+		if (!empty($attached_tours)) {
1382 1382
 			$return = true;
1383 1383
 		}
1384 1384
 		return $return;
@@ -1389,10 +1389,10 @@  discard block
 block discarded – undo
1389 1389
 	 *
1390 1390
 	 * @param   $id     int
1391 1391
 	 */
1392
-	public function queue_item( $id ) {
1393
-		if ( is_array( $this->import_queue ) && ! in_array( $id, $this->import_queue ) ) {
1392
+	public function queue_item($id) {
1393
+		if (is_array($this->import_queue) && !in_array($id, $this->import_queue)) {
1394 1394
 			$this->import_queue[] = $id;
1395
-		} else {
1395
+		}else {
1396 1396
 			$this->import_queue[] = $id;
1397 1397
 		}
1398 1398
 	}
@@ -1401,18 +1401,18 @@  discard block
 block discarded – undo
1401 1401
 	 * Saves the queue to the option.
1402 1402
 	 */
1403 1403
 	public function save_queue() {
1404
-		if ( ! empty( $this->import_queue ) ) {
1405
-			if ( ! empty( $this->queued_imports ) ) {
1406
-				$saved_imports = array_merge( $this->queued_imports, $this->import_queue );
1407
-			} else {
1404
+		if (!empty($this->import_queue)) {
1405
+			if (!empty($this->queued_imports)) {
1406
+				$saved_imports = array_merge($this->queued_imports, $this->import_queue);
1407
+			}else {
1408 1408
 				$saved_imports = $this->import_queue;
1409 1409
 			}
1410 1410
 
1411
-			delete_option( 'lsx_wetu_importer_que' );
1411
+			delete_option('lsx_wetu_importer_que');
1412 1412
 
1413
-			if ( ! empty( $saved_imports ) ) {
1414
-				$saved_imports = array_unique( $saved_imports );
1415
-				update_option( 'lsx_wetu_importer_que', $saved_imports );
1413
+			if (!empty($saved_imports)) {
1414
+				$saved_imports = array_unique($saved_imports);
1415
+				update_option('lsx_wetu_importer_que', $saved_imports);
1416 1416
 			}
1417 1417
 		}
1418 1418
 	}
@@ -1425,14 +1425,14 @@  discard block
 block discarded – undo
1425 1425
 		<thead>
1426 1426
 		<tr>
1427 1427
 			<th class="manage-column column-cb check-column" id="cb" scope="col">
1428
-				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'lsx-wetu-importer' ); ?></label>
1428
+				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'lsx-wetu-importer'); ?></label>
1429 1429
 				<input type="checkbox" id="cb-select-all-1">
1430 1430
 			</th>
1431
-			<th class="manage-column column-order " id="order" scope="col"><?php esc_attr_e( 'Order', 'lsx-wetu-importer' ); ?></th>
1432
-			<th class="manage-column column-title " id="title" scope="col"><?php esc_attr_e( 'Title', 'lsx-wetu-importer' ); ?></th>
1433
-			<th class="manage-column column-date" id="ref" scope="col"><?php esc_attr_e( 'Ref', 'lsx-wetu-importer' ); ?></th>
1434
-			<th class="manage-column column-date" id="date" scope="col"><?php esc_attr_e( 'Date', 'lsx-wetu-importer' ); ?></th>
1435
-			<th class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'lsx-wetu-importer' ); ?></th>
1431
+			<th class="manage-column column-order " id="order" scope="col"><?php esc_attr_e('Order', 'lsx-wetu-importer'); ?></th>
1432
+			<th class="manage-column column-title " id="title" scope="col"><?php esc_attr_e('Title', 'lsx-wetu-importer'); ?></th>
1433
+			<th class="manage-column column-date" id="ref" scope="col"><?php esc_attr_e('Ref', 'lsx-wetu-importer'); ?></th>
1434
+			<th class="manage-column column-date" id="date" scope="col"><?php esc_attr_e('Date', 'lsx-wetu-importer'); ?></th>
1435
+			<th class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e('WETU ID', 'lsx-wetu-importer'); ?></th>
1436 1436
 		</tr>
1437 1437
 		</thead>
1438 1438
 		<?php
@@ -1446,14 +1446,14 @@  discard block
 block discarded – undo
1446 1446
 		<tfoot>
1447 1447
 		<tr>
1448 1448
 			<th class="manage-column column-cb check-column" id="cb" scope="col">
1449
-				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'lsx-wetu-importer' ); ?></label>
1449
+				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'lsx-wetu-importer'); ?></label>
1450 1450
 				<input type="checkbox" id="cb-select-all-1">
1451 1451
 			</th>
1452
-			<th class="manage-column column-order " id="order" scope="col"><?php esc_attr_e( 'Order', 'lsx-wetu-importer' ); ?></th>
1453
-			<th class="manage-column column-title" scope="col"><?php esc_attr_e( 'Title', 'lsx-wetu-importer' ); ?></th>
1454
-			<th class="manage-column column-date" id="ref" scope="col"><?php esc_attr_e( 'Ref', 'lsx-wetu-importer' ); ?></th>
1455
-			<th class="manage-column column-date" scope="col"><?php esc_attr_e( 'Date', 'lsx-wetu-importer' ); ?></th>
1456
-			<th class="manage-column column-ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'lsx-wetu-importer' ); ?></th>
1452
+			<th class="manage-column column-order " id="order" scope="col"><?php esc_attr_e('Order', 'lsx-wetu-importer'); ?></th>
1453
+			<th class="manage-column column-title" scope="col"><?php esc_attr_e('Title', 'lsx-wetu-importer'); ?></th>
1454
+			<th class="manage-column column-date" id="ref" scope="col"><?php esc_attr_e('Ref', 'lsx-wetu-importer'); ?></th>
1455
+			<th class="manage-column column-date" scope="col"><?php esc_attr_e('Date', 'lsx-wetu-importer'); ?></th>
1456
+			<th class="manage-column column-ssid" scope="col"><?php esc_attr_e('WETU ID', 'lsx-wetu-importer'); ?></th>
1457 1457
 		</tr>
1458 1458
 		</tfoot>
1459 1459
 		<?php
Please login to merge, or discard this patch.
classes/class-cron.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 	 * @access private
34 34
 	 */
35 35
 	public function __construct() {
36
-		add_filter( 'cron_schedules', array( $this, 'register_schedule' ), 10, 1 );
37
-		add_action( 'lsx_wetu_importer_settings_before', array( $this, 'watch_for_trigger' ), 200 );
38
-		add_action( 'lsx_wetu_accommodation_images_cron', array( $this, 'process' ), 10, 1 );
39
-		add_action( 'lsx_wetu_accommodation_images_sync', array( $this, 'cron_callback' ), 10, 1 );
40
-		add_filter( 'cmb_meta_boxes', array( $this, 'metaboxes' ) );
36
+		add_filter('cron_schedules', array($this, 'register_schedule'), 10, 1);
37
+		add_action('lsx_wetu_importer_settings_before', array($this, 'watch_for_trigger'), 200);
38
+		add_action('lsx_wetu_accommodation_images_cron', array($this, 'process'), 10, 1);
39
+		add_action('lsx_wetu_accommodation_images_sync', array($this, 'cron_callback'), 10, 1);
40
+		add_filter('cmb_meta_boxes', array($this, 'metaboxes'));
41 41
 	}
42 42
 
43 43
 	/**
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	public static function get_instance() {
51 51
 		// If the single instance hasn't been set, set it now.
52
-		if ( null === self::$instance ) {
52
+		if (null === self::$instance) {
53 53
 			self::$instance = new self();
54 54
 		}
55 55
 		return self::$instance;
@@ -61,26 +61,26 @@  discard block
 block discarded – undo
61 61
 	 * @param  array $meta_boxes
62 62
 	 * @return array
63 63
 	 */
64
-	public function metaboxes( array $meta_boxes ) {
64
+	public function metaboxes(array $meta_boxes) {
65 65
 		// Allowed post types.
66
-		$allowed_post_types = array( 'accommodation' );
66
+		$allowed_post_types = array('accommodation');
67 67
 
68 68
 		$fields = array();
69 69
 
70 70
 		$fields[] = array(
71 71
 			'id'   => 'wetu_skip_banner',
72
-			'name' => esc_html__( 'Skip Banner Image', 'lsx-banners' ),
72
+			'name' => esc_html__('Skip Banner Image', 'lsx-banners'),
73 73
 			'type' => 'checkbox',
74 74
 		);
75 75
 
76 76
 		$fields[] = array(
77 77
 			'id'   => 'wetu_skip_featured',
78
-			'name' => esc_html__( 'Skip Featured Image', 'lsx-banners' ),
78
+			'name' => esc_html__('Skip Featured Image', 'lsx-banners'),
79 79
 			'type' => 'checkbox',
80 80
 		);
81 81
 
82 82
 		$meta_boxes[] = array(
83
-			'title'    => esc_html__( 'WETU Settings', 'lsx-banners' ),
83
+			'title'    => esc_html__('WETU Settings', 'lsx-banners'),
84 84
 			'pages'    => $allowed_post_types,
85 85
 			'fields'   => $fields,
86 86
 			'context'  => 'side',
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 	 * @param  array $schedules
97 97
 	 * @return array
98 98
 	 */
99
-	public function register_schedule( $schedules ) {
99
+	public function register_schedule($schedules) {
100 100
 		$schedules['wetu-5-minutes'] = array(
101 101
 			'interval' => 5 * MINUTE_IN_SECONDS,
102
-			'display'  => __( 'Every 5 minutes', 'lsx-wetu-importer' ),
102
+			'display'  => __('Every 5 minutes', 'lsx-wetu-importer'),
103 103
 		);
104 104
 		return $schedules;
105 105
 	}
@@ -111,26 +111,26 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function watch_for_trigger() {
113 113
 
114
-		if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) {
114
+		if (isset($_GET['page']) && 'lsx-wetu-importer' === $_GET['page'] && isset($_GET['tab']) && 'settings' === $_GET['tab']) {
115 115
 			$options = lsx_wetu_get_options();
116 116
 
117 117
 			// Check what state the option is in.
118 118
 			$accommodation_cron = 'deactivate';
119
-			if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
119
+			if (isset($options['accommodation_images_cron']) && '' !== $options['accommodation_images_cron']) {
120 120
 				$accommodation_cron = 'activate';
121 121
 			}
122 122
 
123 123
 			// Check what state the cron is in.
124 124
 			$scheduled = false;
125
-			if ( wp_next_scheduled( 'lsx_wetu_accommodation_images_cron' ) ) {
125
+			if (wp_next_scheduled('lsx_wetu_accommodation_images_cron')) {
126 126
 				$scheduled = true;
127 127
 			}
128 128
 
129 129
 			// If activate and its not running.
130
-			if ( false === $scheduled && 'activate' === $accommodation_cron ) {
130
+			if (false === $scheduled && 'activate' === $accommodation_cron) {
131 131
 				$schedule = 'weekly';
132
-				$this->schedule( 'lsx_wetu_accommodation_images_cron', $schedule );
133
-			} elseif ( true === $scheduled && 'deactivate' === $accommodation_cron ) {
132
+				$this->schedule('lsx_wetu_accommodation_images_cron', $schedule);
133
+			} elseif (true === $scheduled && 'deactivate' === $accommodation_cron) {
134 134
 				$this->deactivate();
135 135
 			}
136 136
 		}
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 * @return void
143 143
 	 */
144
-	public function deactivate( $task = 'lsx_wetu_accommodation_images_cron' ) {
145
-		wp_clear_scheduled_hook( $task, array( $task ) );
144
+	public function deactivate($task = 'lsx_wetu_accommodation_images_cron') {
145
+		wp_clear_scheduled_hook($task, array($task));
146 146
 	}
147 147
 
148 148
 	/**
@@ -153,16 +153,16 @@  discard block
 block discarded – undo
153 153
 	 * @param string $time
154 154
 	 * @return void
155 155
 	 */
156
-	public function schedule( $task = 'lsx_wetu_accommodation_images_cron', $schedule = 'weekly', $time = 'Sunday 10pm' ) {
157
-		$args = array( $task );
158
-		if ( '' === $time ) {
156
+	public function schedule($task = 'lsx_wetu_accommodation_images_cron', $schedule = 'weekly', $time = 'Sunday 10pm') {
157
+		$args = array($task);
158
+		if ('' === $time) {
159 159
 			$time = time();
160 160
 		}
161 161
 
162
-		if ( isset( $_GET['accommodation_images_cron_featured'] ) && '' !== $_GET['accommodation_images_cron_featured'] ) {
162
+		if (isset($_GET['accommodation_images_cron_featured']) && '' !== $_GET['accommodation_images_cron_featured']) {
163 163
 			$args[] = 'featured_image';
164 164
 		}
165
-		wp_schedule_event( $time, $schedule, $task, $args );
165
+		wp_schedule_event($time, $schedule, $task, $args);
166 166
 	}
167 167
 
168 168
 	/**
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @return void
172 172
 	 */
173
-	public function process( $task = '' ) {
174
-		switch ( $task ) {
173
+	public function process($task = '') {
174
+		switch ($task) {
175 175
 			case 'lsx_wetu_accommodation_images_cron':
176 176
 					$this->register_accommodation_images_sync();
177 177
 				break;
@@ -187,10 +187,10 @@  discard block
 block discarded – undo
187 187
 	 * @return void
188 188
 	 */
189 189
 	public function register_accommodation_images_sync() {
190
-		$time = strtotime( '+5 min' );
191
-		if ( ! wp_next_scheduled( 'lsx_wetu_accommodation_images_sync' ) ) {
192
-			$this->load_items_to_sync( 'accommodation_images' );
193
-			$this->schedule( 'lsx_wetu_accommodation_images_sync', 'wetu-5-minutes', $time );
190
+		$time = strtotime('+5 min');
191
+		if (!wp_next_scheduled('lsx_wetu_accommodation_images_sync')) {
192
+			$this->load_items_to_sync('accommodation_images');
193
+			$this->schedule('lsx_wetu_accommodation_images_sync', 'wetu-5-minutes', $time);
194 194
 		}
195 195
 	}
196 196
 
@@ -199,58 +199,58 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return void
201 201
 	 */
202
-	public function cron_callback( $task = '', $featured_image = '' ) {
203
-		$has_accommodation = get_option( $task );
204
-		if ( false !== $has_accommodation && ! empty( $has_accommodation ) ) {
205
-			$next_time = array_slice( $has_accommodation, 3 );
206
-			$this_time = array_slice( $has_accommodation, 0, 2 );
202
+	public function cron_callback($task = '', $featured_image = '') {
203
+		$has_accommodation = get_option($task);
204
+		if (false !== $has_accommodation && !empty($has_accommodation)) {
205
+			$next_time = array_slice($has_accommodation, 3);
206
+			$this_time = array_slice($has_accommodation, 0, 2);
207 207
 
208 208
 			$api_key = $this->get_api_key();
209
-			$url     = 'https://wetu.com/API/Pins/' . $api_key . '/Get?all=include&ids=';
209
+			$url     = 'https://wetu.com/API/Pins/'.$api_key.'/Get?all=include&ids=';
210 210
 
211 211
 			// Run through the current items.
212
-			foreach ( $this_time as $accommodation ) {
213
-				$wetu_id   = get_post_meta( $accommodation, 'lsx_wetu_id', true );
214
-				$last_date = get_post_meta( $accommodation, 'lsx_wetu_modified_date', true );
212
+			foreach ($this_time as $accommodation) {
213
+				$wetu_id   = get_post_meta($accommodation, 'lsx_wetu_id', true);
214
+				$last_date = get_post_meta($accommodation, 'lsx_wetu_modified_date', true);
215 215
 
216 216
 				// Grabbing the image sync.
217
-				$featured_image = get_post_meta( $accommodation, 'wetu_skip_featured', true );
218
-				$banner_image   = get_post_meta( $accommodation, 'wetu_skip_banner', true );
217
+				$featured_image = get_post_meta($accommodation, 'wetu_skip_featured', true);
218
+				$banner_image   = get_post_meta($accommodation, 'wetu_skip_banner', true);
219 219
 
220
-				$accommodation_info = wp_remote_get( $url . $wetu_id );
221
-				if ( ! empty( $accommodation_info ) && isset( $accommodation_info['response'] ) && isset( $accommodation_info['response']['code'] ) && 200 === $accommodation_info['response']['code'] ) {
222
-					$adata = json_decode( $accommodation_info['body'], true );
220
+				$accommodation_info = wp_remote_get($url.$wetu_id);
221
+				if (!empty($accommodation_info) && isset($accommodation_info['response']) && isset($accommodation_info['response']['code']) && 200 === $accommodation_info['response']['code']) {
222
+					$adata = json_decode($accommodation_info['body'], true);
223 223
 
224
-					if ( isset( $adata[0] ) && isset( $adata[0]['last_modified'] ) && '' !== $adata[0]['last_modified'] ) {
225
-						$modified_time = strtotime( $adata[0]['last_modified'] );
226
-						if ( $modified_time > $last_date ) {
224
+					if (isset($adata[0]) && isset($adata[0]['last_modified']) && '' !== $adata[0]['last_modified']) {
225
+						$modified_time = strtotime($adata[0]['last_modified']);
226
+						if ($modified_time > $last_date) {
227 227
 							$accommodation_importer = new \LSX_WETU_Importer_Accommodation();
228 228
 
229
-							if ( false === $banner_image || '' === $banner_image ) {
230
-								$accommodation_importer->set_banner_image( $adata, $accommodation );
229
+							if (false === $banner_image || '' === $banner_image) {
230
+								$accommodation_importer->set_banner_image($adata, $accommodation);
231 231
 							}
232 232
 
233
-							if ( false === $featured_image || '' === $featured_image ) {
234
-								$accommodation_importer->set_featured_image( $adata, $accommodation );
233
+							if (false === $featured_image || '' === $featured_image) {
234
+								$accommodation_importer->set_featured_image($adata, $accommodation);
235 235
 							}
236 236
 
237
-							$accommodation_importer->create_main_gallery( $adata, $accommodation );
238
-							update_post_meta( $accommodation, 'lsx_wetu_modified_date', $modified_time, $last_date );
237
+							$accommodation_importer->create_main_gallery($adata, $accommodation);
238
+							update_post_meta($accommodation, 'lsx_wetu_modified_date', $modified_time, $last_date);
239 239
 						}
240 240
 					}
241 241
 				}
242 242
 			}
243 243
 
244 244
 			// Save the values for next time.
245
-			if ( ! empty( $next_time ) ) {
246
-				update_option( $task, $next_time );
247
-			} else {
248
-				delete_option( $task );
249
-				$this->deactivate( $task );
245
+			if (!empty($next_time)) {
246
+				update_option($task, $next_time);
247
+			}else {
248
+				delete_option($task);
249
+				$this->deactivate($task);
250 250
 			}
251
-		} else {
252
-			$this->deactivate( $task );
253
-			update_option( 'lsx_wetu_nexttime', $task );
251
+		}else {
252
+			$this->deactivate($task);
253
+			update_option('lsx_wetu_nexttime', $task);
254 254
 		}
255 255
 	}
256 256
 
@@ -260,14 +260,14 @@  discard block
 block discarded – undo
260 260
 	 * @param  string $task
261 261
 	 * @return void
262 262
 	 */
263
-	public function load_items_to_sync( $task = 'accommodation_images' ) {
263
+	public function load_items_to_sync($task = 'accommodation_images') {
264 264
 		$args = array(
265 265
 			'post_status'    => 'publish',
266 266
 			'posts_per_page' => -1,
267 267
 			'nopagin'        => true,
268 268
 			'fields'         => 'ids',
269 269
 		);
270
-		switch ( $task ) {
270
+		switch ($task) {
271 271
 			case 'accommodation_images':
272 272
 					$args['post_type'] = 'accommodation';
273 273
 				break;
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 			default:
276 276
 				break;
277 277
 		}
278
-		$items = new \WP_Query( $args );
279
-		if ( $items->have_posts() ) {
280
-			update_option( 'lsx_wetu_' . $task . '_sync', $items->posts );
278
+		$items = new \WP_Query($args);
279
+		if ($items->have_posts()) {
280
+			update_option('lsx_wetu_'.$task.'_sync', $items->posts);
281 281
 		}
282 282
 	}
283 283
 
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
 		$api_key = false;
291 291
 		$options = lsx_wetu_get_options();
292 292
 
293
-		if ( ! defined( 'WETU_API_KEY' ) ) {
294
-			if ( isset( $options['api_key'] ) && '' !== $options['api_key'] ) {
293
+		if (!defined('WETU_API_KEY')) {
294
+			if (isset($options['api_key']) && '' !== $options['api_key']) {
295 295
 				$api_key = $options['api_key'];
296 296
 			}
297
-		} else {
297
+		}else {
298 298
 			$api_key = WETU_API_KEY;
299 299
 		}
300 300
 		return $api_key;
Please login to merge, or discard this patch.
classes/class-lsx-wetu-importer-banner-integration.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 	 * @access private
27 27
 	 */
28 28
 	public function __construct() {
29
-		add_action( 'wp_ajax_lsx_import_sync_banners', array( $this, 'sync_new_banner' ) );
30
-		add_action( 'wp_ajax_nopriv_lsx_import_sync_banners', array( $this, 'sync_new_banner' ) );
29
+		add_action('wp_ajax_lsx_import_sync_banners', array($this, 'sync_new_banner'));
30
+		add_action('wp_ajax_nopriv_lsx_import_sync_banners', array($this, 'sync_new_banner'));
31 31
 	}
32 32
 
33 33
 	/**
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 36
 	public function display_page() {
37 37
 		?>
38 38
 		<div class="wrap">
39
-			<h2><?php esc_html_e( 'Download new banners straight from WETU', 'lsx-wetu-importer' ); ?></h2>
39
+			<h2><?php esc_html_e('Download new banners straight from WETU', 'lsx-wetu-importer'); ?></h2>
40 40
 
41 41
 			<form method="get" action="" id="banners-filter">
42
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
42
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" />
43 43
 
44 44
 			   <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
45
-					<img style="width:32px;" src="<?php echo esc_url( LSX_WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" />
45
+					<img style="width:32px;" src="<?php echo esc_url(LSX_WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" />
46 46
 				</div>
47 47
 
48 48
 				<table class="wp-list-table widefat fixed posts">
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 					<?php
61 61
 						$accommodation_args = array(
62 62
 							'post_type'      => 'accommodation',
63
-							'post_status'    => array( 'publish', 'pending', 'draft', 'future', 'private' ),
63
+							'post_status'    => array('publish', 'pending', 'draft', 'future', 'private'),
64 64
 							'nopagin'        => 'true',
65 65
 							'posts_per_page' => '1000',
66 66
 							'meta_query'     => array(
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 								),
81 81
 							),
82 82
 						);
83
-						$accommodation      = new WP_Query( $accommodation_args );
83
+						$accommodation = new WP_Query($accommodation_args);
84 84
 						?>
85 85
 
86 86
 					<tbody id="the-list">
87 87
 						<?php
88
-						if ( $accommodation->have_posts() ) {
89
-							while ( $accommodation->have_posts() ) {
88
+						if ($accommodation->have_posts()) {
89
+							while ($accommodation->have_posts()) {
90 90
 								$accommodation->the_post();
91 91
 								?>
92 92
 									<tr class="post-<?php the_ID(); ?> type-tour status-none" id="post-<?php the_ID(); ?>">
@@ -95,26 +95,26 @@  discard block
 block discarded – undo
95 95
 									$min_width               = '1920';
96 96
 									$min_height              = '500';
97 97
 
98
-									$img_group = get_post_meta( get_the_ID(), 'image_group', true );
98
+									$img_group = get_post_meta(get_the_ID(), 'image_group', true);
99 99
 
100 100
 									$thumbnails_html = false;
101 101
 
102
-									if ( false !== $img_group ) {
103
-										foreach ( $img_group['banner_image'] as $banner_image ) {
104
-											$large       = wp_get_attachment_image_src( $banner_image, 'full' );
102
+									if (false !== $img_group) {
103
+										foreach ($img_group['banner_image'] as $banner_image) {
104
+											$large       = wp_get_attachment_image_src($banner_image, 'full');
105 105
 											$real_width  = $large[1];
106 106
 											$real_height = $large[2];
107 107
 
108 108
 											$status = 'optimized';
109
-											if ( $real_width < intval( $real_width ) ) {
109
+											if ($real_width < intval($real_width)) {
110 110
 												$status = 'width not enough.';
111 111
 											}
112 112
 
113
-											$thumbnail         = wp_get_attachment_image_src( $banner_image, 'thumbnail' );
113
+											$thumbnail         = wp_get_attachment_image_src($banner_image, 'thumbnail');
114 114
 											$thumbnails_html[] = '
115 115
 													<div style="display:block;float:left;">
116
-														<img src="' . $thumbnail[0] . '" />
117
-														<p style="text-align:center;">' . $real_width . 'px by ' . $real_height . 'px</p>
116
+														<img src="' . $thumbnail[0].'" />
117
+														<p style="text-align:center;">' . $real_width.'px by '.$real_height.'px</p>
118 118
 													</div>';
119 119
 										}
120 120
 									}
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
 										<td class="post-title page-title column-title">
128 128
 									<?php
129
-									echo '<a href="' . esc_url( admin_url( '/post.php?post=' . get_the_ID() . '&action=edit' ) ) . '" target="_blank">';
129
+									echo '<a href="'.esc_url(admin_url('/post.php?post='.get_the_ID().'&action=edit')).'" target="_blank">';
130 130
 									the_title();
131 131
 									echo '</a>';
132 132
 									?>
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 
135 135
 										<td colspan="2" class="thumbnails column-thumbnails">
136 136
 									<?php
137
-									if ( false !== $thumbnails_html ) {
138
-										echo wp_kses_post( implode( '', $thumbnails_html ) );
139
-									} else {
137
+									if (false !== $thumbnails_html) {
138
+										echo wp_kses_post(implode('', $thumbnails_html));
139
+									}else {
140 140
 										echo '<p>There was an error retrieving your images.</p>';
141 141
 									}
142 142
 									?>
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 
162 162
 				</table>
163 163
 
164
-				<p><input class="button button-primary download" type="button" value="<?php esc_html_e( 'Download new Banners', 'lsx-wetu-importer' ); ?>" />
164
+				<p><input class="button button-primary download" type="button" value="<?php esc_html_e('Download new Banners', 'lsx-wetu-importer'); ?>" />
165 165
 				</p>
166 166
 			</form>
167 167
 		</div>
@@ -172,32 +172,32 @@  discard block
 block discarded – undo
172 172
 	 * Creates the main gallery data
173 173
 	 */
174 174
 	public function sync_new_banner() {
175
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
176
-		if ( isset( $_POST['action'] ) && 'lsx_import_sync_banners' === $_POST['action'] && isset( $_POST['post_id'] ) ) {
175
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
176
+		if (isset($_POST['action']) && 'lsx_import_sync_banners' === $_POST['action'] && isset($_POST['post_id'])) {
177 177
 
178
-			$post_id       = sanitize_text_field( $_POST['post_id'] );
179
-			$banners       = get_post_meta( $post_id, 'image_group', true );
180
-			$this->wetu_id = get_post_meta( $post_id, 'lsx_wetu_id', true );
178
+			$post_id       = sanitize_text_field($_POST['post_id']);
179
+			$banners       = get_post_meta($post_id, 'image_group', true);
180
+			$this->wetu_id = get_post_meta($post_id, 'lsx_wetu_id', true);
181 181
 
182 182
 			$new_banner_array = false;
183 183
 			$array_index      = 0;
184 184
 
185
-			foreach ( $banners['banner_image'] as $banner_image ) {
186
-				$image_id = $this->attach_external_image2( $this->format_wetu_url( $banner_image ), array(), $post_id );
187
-				if ( null !== $image_id && '' !== $image_id ) {
188
-					$new_banner_array['banner_image'][ 'cmb-field-' . $array_index ] = $image_id;
185
+			foreach ($banners['banner_image'] as $banner_image) {
186
+				$image_id = $this->attach_external_image2($this->format_wetu_url($banner_image), array(), $post_id);
187
+				if (null !== $image_id && '' !== $image_id) {
188
+					$new_banner_array['banner_image']['cmb-field-'.$array_index] = $image_id;
189 189
 					$array_index++;
190 190
 				}
191 191
 			}
192 192
 
193
-			if ( false !== $new_banner_array ) {
194
-				delete_post_meta( $post_id, 'image_group' );
195
-				add_post_meta( $post_id, 'image_group', $new_banner_array, true );
193
+			if (false !== $new_banner_array) {
194
+				delete_post_meta($post_id, 'image_group');
195
+				add_post_meta($post_id, 'image_group', $new_banner_array, true);
196 196
 				echo true;
197
-			} else {
197
+			}else {
198 198
 				echo false;
199 199
 			}
200
-		} else {
200
+		}else {
201 201
 			echo false;
202 202
 		}
203 203
 
@@ -207,81 +207,81 @@  discard block
 block discarded – undo
207 207
 	/**
208 208
 	 * formats the url
209 209
 	 */
210
-	public function format_wetu_url( $post_id ) {
211
-		return 'https://wetu.com/ImageHandler/c1920x800/' . $this->wetu_id . '/' . $this->format_filename( $post_id );
210
+	public function format_wetu_url($post_id) {
211
+		return 'https://wetu.com/ImageHandler/c1920x800/'.$this->wetu_id.'/'.$this->format_filename($post_id);
212 212
 	}
213 213
 
214 214
 	/**
215 215
 	 * formats the filename
216 216
 	 */
217
-	public function format_filename( $post_id ) {
218
-		$base = str_replace( '_', ' ', get_the_title( $post_id ) );
219
-		$base = rawurlencode( $base );
220
-		$type = get_post_mime_type( $post_id );
217
+	public function format_filename($post_id) {
218
+		$base = str_replace('_', ' ', get_the_title($post_id));
219
+		$base = rawurlencode($base);
220
+		$type = get_post_mime_type($post_id);
221 221
 
222
-		switch ( $type ) {
222
+		switch ($type) {
223 223
 			case 'image/jpeg':
224
-				return $base . '.jpg';
224
+				return $base.'.jpg';
225 225
 			break;
226 226
 			case 'image/png':
227
-				return $base . '.png';
227
+				return $base.'.png';
228 228
 			break;
229 229
 			case 'image/gif':
230
-				return $base . '.gif';
230
+				return $base.'.gif';
231 231
 			break;
232 232
 			default:
233 233
 				return false;
234 234
 		}
235 235
 	}
236 236
 
237
-	public function attach_external_image2( $url = null, $post_data = array(), $post_id = '' ) {
238
-		if ( ! $url ) {
239
-			return new WP_Error( 'missing', 'Need a valid URL' ); }
237
+	public function attach_external_image2($url = null, $post_data = array(), $post_id = '') {
238
+		if (!$url) {
239
+			return new WP_Error('missing', 'Need a valid URL'); }
240 240
 		$att_id = false;
241 241
 
242
-		require_once ABSPATH . 'wp-admin/includes/file.php';
243
-		require_once ABSPATH . 'wp-admin/includes/media.php';
244
-		require_once ABSPATH . 'wp-admin/includes/image.php';
242
+		require_once ABSPATH.'wp-admin/includes/file.php';
243
+		require_once ABSPATH.'wp-admin/includes/media.php';
244
+		require_once ABSPATH.'wp-admin/includes/image.php';
245 245
 
246
-		$tmp   = tempnam( '/tmp', 'FOO' );
247
-		$image = wp_remote_get( $url );
246
+		$tmp   = tempnam('/tmp', 'FOO');
247
+		$image = wp_remote_get($url);
248 248
 
249
-		if ( ! empty( $image ) && isset( $image['response'] ) && isset( $image['response']['code'] ) && 200 === $image['response']['code'] ) {
250
-			file_put_contents( $tmp, $image['body'] );
251
-			chmod( $tmp, '777' );
249
+		if (!empty($image) && isset($image['response']) && isset($image['response']['code']) && 200 === $image['response']['code']) {
250
+			file_put_contents($tmp, $image['body']);
251
+			chmod($tmp, '777');
252 252
 
253
-			preg_match( '/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches );
254
-			$url_filename = basename( $matches[0] );
255
-			$url_filename = str_replace( '%20', '_', $url_filename );
253
+			preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches);
254
+			$url_filename = basename($matches[0]);
255
+			$url_filename = str_replace('%20', '_', $url_filename);
256 256
 			// extract filename from url for title.
257
-			$url_type = wp_check_filetype( $url_filename );
257
+			$url_type = wp_check_filetype($url_filename);
258 258
 
259 259
 			// assemble file data (should be built like $_FILES since wp_handle_sideload() will be using).
260 260
 			$file_array['tmp_name'] = $tmp;
261 261
 
262
-			if ( ! empty( $filename ) && ' ' != $filename ) {
263
-				$file_array['name'] = $filename . '.' . $url_type['ext'];
264
-			} else {
262
+			if (!empty($filename) && ' ' != $filename) {
263
+				$file_array['name'] = $filename.'.'.$url_type['ext'];
264
+			}else {
265 265
 				$file_array['name'] = $url_filename;
266 266
 			}
267 267
 
268 268
 			// set additional wp_posts columns.
269
-			if ( empty( $post_data['post_title'] ) ) {
270
-				$url_filename            = str_replace( '%20', ' ', $url_filename );
271
-				$post_data['post_title'] = basename( $url_filename, '.' . $url_type['ext'] );
269
+			if (empty($post_data['post_title'])) {
270
+				$url_filename            = str_replace('%20', ' ', $url_filename);
271
+				$post_data['post_title'] = basename($url_filename, '.'.$url_type['ext']);
272 272
 			}
273 273
 
274 274
 			// make sure gets tied to parent.
275
-			if ( empty( $post_data['post_parent'] ) ) {
275
+			if (empty($post_data['post_parent'])) {
276 276
 				$post_data['post_parent'] = $post_id;
277 277
 			}
278 278
 
279 279
 			// do the validation and storage stuff.
280
-			$att_id = media_handle_sideload( $file_array, $post_id, null, $post_data );
280
+			$att_id = media_handle_sideload($file_array, $post_id, null, $post_data);
281 281
 
282 282
 			// If error storing permanently, unlink.
283
-			if ( is_wp_error( $att_id ) ) {
284
-				unlink( $file_array['tmp_name'] );
283
+			if (is_wp_error($att_id)) {
284
+				unlink($file_array['tmp_name']);
285 285
 				return false;
286 286
 			}
287 287
 		}
Please login to merge, or discard this patch.
classes/class-lsx-wetu-importer-destination.php 1 patch
Spacing   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -70,17 +70,17 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	public function set_variables() {
72 72
 		parent::set_variables();
73
-		$this->url    = 'https://wetu.com/API/Pins/' . $this->api_key;
73
+		$this->url    = 'https://wetu.com/API/Pins/'.$this->api_key;
74 74
 		$this->url_qs = 'all=include';
75
-		$temp_options = get_option( '_lsx-to_settings', false );
75
+		$temp_options = get_option('_lsx-to_settings', false);
76 76
 
77
-		if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) {
78
-			$this->options = $temp_options[ $this->plugin_slug ];
77
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
78
+			$this->options = $temp_options[$this->plugin_slug];
79 79
 		}
80 80
 
81
-		$destination_options = get_option( 'lsx_wetu_importer_destination_settings', false );
81
+		$destination_options = get_option('lsx_wetu_importer_destination_settings', false);
82 82
 
83
-		if ( false !== $destination_options ) {
83
+		if (false !== $destination_options) {
84 84
 			$this->destination_options = $destination_options;
85 85
 		}
86 86
 	}
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 			</div>
99 99
 
100 100
 			<form method="get" action="" id="posts-filter">
101
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>"/>
101
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>"/>
102 102
 
103 103
 				<table class="wp-list-table widefat fixed posts">
104 104
 					<?php $this->table_header(); ?>
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 					<tr class="post-0 type-tour status-none" id="post-0">
108 108
 						<th class="check-column" scope="row">
109 109
 							<label for="cb-select-0"
110
-								   class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter', 'lsx-wetu-importer' ); ?></label>
110
+								   class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'lsx-wetu-importer'); ?></label>
111 111
 						</th>
112 112
 						<td class="post-title page-title column-title">
113 113
 							<strong>
114
-								<?php esc_html_e( 'Enter a title to search for', 'lsx-wetu-importer' ); ?>
114
+								<?php esc_html_e('Enter a title to search for', 'lsx-wetu-importer'); ?>
115 115
 							</strong>
116 116
 						</td>
117 117
 						<td class="date column-date">
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 				</table>
127 127
 
128 128
 				<p><input class="button button-primary add" type="button"
129
-						  value="<?php esc_html_e( 'Add to List', 'lsx-wetu-importer' ); ?>"/>
129
+						  value="<?php esc_html_e('Add to List', 'lsx-wetu-importer'); ?>"/>
130 130
 					<input class="button button-primary clear" type="button"
131
-						   value="<?php esc_html_e( 'Clear', 'lsx-wetu-importer' ); ?>"/>
131
+						   value="<?php esc_html_e('Clear', 'lsx-wetu-importer'); ?>"/>
132 132
 				</p>
133 133
 			</form>
134 134
 
@@ -138,56 +138,56 @@  discard block
 block discarded – undo
138 138
 
139 139
 					<div class="row">
140 140
 						<div class="settings-all" style="width:30%;display:block;float:left;">
141
-							<h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3>
141
+							<h3><?php esc_html_e('What content to Sync from WETU'); ?></h3>
142 142
 							<ul>
143
-								<?php if ( isset( $this->options ) && isset( $this->options['disable_destination_descriptions'] ) && 'on' !== $this->options['disable_destination_descriptions'] ) { ?>
143
+								<?php if (isset($this->options) && isset($this->options['disable_destination_descriptions']) && 'on' !== $this->options['disable_destination_descriptions']) { ?>
144 144
 								<li>
145 145
 									<input class="content" checked="checked"
146 146
 										   type="checkbox" name="content[]"
147
-										   value="description"/> <?php esc_html_e( 'Description', 'lsx-wetu-importer' ); ?></li>
147
+										   value="description"/> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li>
148 148
 								<?php } ?>
149 149
 
150 150
 								<li>
151 151
 									<input class="content" checked="checked"
152 152
 										   type="checkbox" name="content[]"
153
-										   value="gallery"/> <?php esc_html_e( 'Main Gallery', 'lsx-wetu-importer' ); ?></li>
153
+										   value="gallery"/> <?php esc_html_e('Main Gallery', 'lsx-wetu-importer'); ?></li>
154 154
 
155 155
 									<li>
156 156
 										<input class="content" checked="checked"
157 157
 											   type="checkbox" name="content[]"
158
-											   value="location"/> <?php esc_html_e( 'Location', 'lsx-wetu-importer' ); ?>
158
+											   value="location"/> <?php esc_html_e('Location', 'lsx-wetu-importer'); ?>
159 159
 									</li>
160 160
 
161 161
 
162
-								<?php if ( class_exists( 'LSX_TO_Videos' ) ) { ?>
162
+								<?php if (class_exists('LSX_TO_Videos')) { ?>
163 163
 									<li>
164 164
 										<input class="content" checked="checked"
165 165
 											   type="checkbox" name="content[]"
166
-											   value="videos"/> <?php esc_html_e( 'Videos', 'lsx-wetu-importer' ); ?></li>
166
+											   value="videos"/> <?php esc_html_e('Videos', 'lsx-wetu-importer'); ?></li>
167 167
 								<?php } ?>
168 168
 
169 169
 							</ul>
170
-							<h4><?php esc_html_e( 'Additional Content' ); ?></h4>
170
+							<h4><?php esc_html_e('Additional Content'); ?></h4>
171 171
 							<ul>
172 172
 								<li>
173 173
 									<input class="content" checked="checked"
174 174
 										   type="checkbox" name="content[]"
175
-										   value="country"/> <?php esc_html_e( 'Set Country', 'lsx-wetu-importer' ); ?></li>
175
+										   value="country"/> <?php esc_html_e('Set Country', 'lsx-wetu-importer'); ?></li>
176 176
 								<li>
177 177
 									<input class="content" checked="checked"
178 178
 										   type="checkbox" name="content[]"
179
-										   value="continent"/> <?php esc_html_e( 'Set Continent', 'lsx-wetu-importer' ); ?></li>
179
+										   value="continent"/> <?php esc_html_e('Set Continent', 'lsx-wetu-importer'); ?></li>
180 180
 
181 181
 								<li>
182 182
 									<input class="content" checked="checked"
183 183
 										   type="checkbox" name="content[]"
184
-										   value="featured_image"/> <?php esc_html_e( 'Set Featured Image', 'lsx-wetu-importer' ); ?>
184
+										   value="featured_image"/> <?php esc_html_e('Set Featured Image', 'lsx-wetu-importer'); ?>
185 185
 								</li>
186 186
 
187 187
 								<li>
188 188
 									<input class="content" checked="checked"
189 189
 											type="checkbox" name="content[]"
190
-											value="banner_image"/> <?php esc_html_e( 'Set Banner Image', 'lsx-wetu-importer' ); ?>
190
+											value="banner_image"/> <?php esc_html_e('Set Banner Image', 'lsx-wetu-importer'); ?>
191 191
 								</li>
192 192
 								<?php
193 193
 								/*
@@ -201,54 +201,54 @@  discard block
 block discarded – undo
201 201
 								<li>
202 202
 									<input class="content" checked="checked"
203 203
 										   type="checkbox" name="content[]"
204
-										   value="strip_tags"/> <?php esc_html_e( 'Strip HTML from the description', 'lsx-wetu-importer' ); ?></li>
204
+										   value="strip_tags"/> <?php esc_html_e('Strip HTML from the description', 'lsx-wetu-importer'); ?></li>
205 205
 							</ul>
206 206
 						</div>
207 207
 						<div class="settings-all" style="width:30%;display:block;float:left;">
208
-							<h3><?php esc_html_e( 'Travel Information' ); ?></h3>
208
+							<h3><?php esc_html_e('Travel Information'); ?></h3>
209 209
 							<ul>
210 210
 								<li>
211 211
 									<input class="content" checked="checked"
212 212
 										   type="checkbox" name="content[]"
213
-										   value="electricity"/> <?php esc_html_e( 'Electricity', 'lsx-wetu-importer' ); ?></li>
213
+										   value="electricity"/> <?php esc_html_e('Electricity', 'lsx-wetu-importer'); ?></li>
214 214
 								<li>
215 215
 									<input class="content" checked="checked"
216 216
 										   type="checkbox" name="content[]"
217
-										   value="banking"/> <?php esc_html_e( 'Banking', 'lsx-wetu-importer' ); ?></li>
217
+										   value="banking"/> <?php esc_html_e('Banking', 'lsx-wetu-importer'); ?></li>
218 218
 								<li>
219 219
 									<input class="content" checked="checked"
220 220
 										   type="checkbox" name="content[]"
221
-										   value="cuisine"/> <?php esc_html_e( 'Cuisine', 'lsx-wetu-importer' ); ?></li>
221
+										   value="cuisine"/> <?php esc_html_e('Cuisine', 'lsx-wetu-importer'); ?></li>
222 222
 								<li>
223 223
 									<input class="content" checked="checked"
224 224
 										   type="checkbox" name="content[]"
225
-										   value="climate"/> <?php esc_html_e( 'Climate', 'lsx-wetu-importer' ); ?></li>
225
+										   value="climate"/> <?php esc_html_e('Climate', 'lsx-wetu-importer'); ?></li>
226 226
 								<li>
227 227
 									<input class="content" checked="checked"
228 228
 										   type="checkbox" name="content[]"
229
-										   value="transport"/> <?php esc_html_e( 'Transport', 'lsx-wetu-importer' ); ?></li>
229
+										   value="transport"/> <?php esc_html_e('Transport', 'lsx-wetu-importer'); ?></li>
230 230
 								<li><input class="content" checked="checked"
231 231
 										   type="checkbox" name="content[]"
232
-										   value="dress"/> <?php esc_html_e( 'Dress', 'lsx-wetu-importer' ); ?></li>
232
+										   value="dress"/> <?php esc_html_e('Dress', 'lsx-wetu-importer'); ?></li>
233 233
 								<li><input class="content" checked="checked"
234 234
 										   type="checkbox" name="content[]"
235
-										   value="health"/> <?php esc_html_e( 'Health', 'lsx-wetu-importer' ); ?></li>
235
+										   value="health"/> <?php esc_html_e('Health', 'lsx-wetu-importer'); ?></li>
236 236
 								<li><input class="content" checked="checked"
237 237
 										   type="checkbox" name="content[]"
238
-										   value="safety"/> <?php esc_html_e( 'Safety', 'lsx-wetu-importer' ); ?></li>
238
+										   value="safety"/> <?php esc_html_e('Safety', 'lsx-wetu-importer'); ?></li>
239 239
 								<li><input class="content" checked="checked"
240 240
 										   type="checkbox" name="content[]"
241
-										   value="visa"/> <?php esc_html_e( 'Visa', 'lsx-wetu-importer' ); ?></li>
241
+										   value="visa"/> <?php esc_html_e('Visa', 'lsx-wetu-importer'); ?></li>
242 242
 								<li><input class="content" checked="checked"
243 243
 										   type="checkbox" name="content[]"
244
-										   value="additional_info"/> <?php esc_html_e( 'General', 'lsx-wetu-importer' ); ?></li>
244
+										   value="additional_info"/> <?php esc_html_e('General', 'lsx-wetu-importer'); ?></li>
245 245
 							</ul>
246 246
 						</div>
247 247
 
248
-						<?php if ( class_exists( 'LSX_TO_Team' ) ) { ?>
248
+						<?php if (class_exists('LSX_TO_Team')) { ?>
249 249
 							<div style="width:30%;display:block;float:left;">
250
-								<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3>
251
-								<?php $this->team_member_checkboxes( $this->destination_options ); ?>
250
+								<h3><?php esc_html_e('Assign a Team Member'); ?></h3>
251
+								<?php $this->team_member_checkboxes($this->destination_options); ?>
252 252
 							</div>
253 253
 						<?php } ?>
254 254
 
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 					</div>
257 257
 
258 258
 
259
-					<h3><?php esc_html_e( 'Your List' ); ?></h3>
259
+					<h3><?php esc_html_e('Your List'); ?></h3>
260 260
 					<p><input class="button button-primary" type="submit"
261
-							  value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>"/></p>
261
+							  value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>"/></p>
262 262
 					<table class="wp-list-table widefat fixed posts">
263 263
 						<?php $this->table_header(); ?>
264 264
 
@@ -271,12 +271,12 @@  discard block
 block discarded – undo
271 271
 					</table>
272 272
 
273 273
 					<p><input class="button button-primary" type="submit"
274
-							  value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>"/></p>
274
+							  value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>"/></p>
275 275
 				</form>
276 276
 			</div>
277 277
 
278 278
 			<div style="display:none;" class="completed-list-wrapper">
279
-				<h3><?php esc_html_e( 'Completed' ); ?></h3>
279
+				<h3><?php esc_html_e('Completed'); ?></h3>
280 280
 				<ul>
281 281
 				</ul>
282 282
 			</div>
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	/**
288 288
 	 * Grab all the current destination posts via the lsx_wetu_id field.
289 289
 	 */
290
-	public function find_current_destination( $post_type = 'destination' ) {
290
+	public function find_current_destination($post_type = 'destination') {
291 291
 		global $wpdb;
292 292
 		$return = array();
293 293
 
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
 		");
307 307
 		// @codingStandardsIgnoreEnd
308 308
 
309
-		if ( null !== $current_destination && ! empty( $current_destination ) ) {
310
-			foreach ( $current_destination as $accom ) {
311
-				$return[ $accom->meta_value ] = $accom;
309
+		if (null !== $current_destination && !empty($current_destination)) {
310
+			foreach ($current_destination as $accom) {
311
+				$return[$accom->meta_value] = $accom;
312 312
 			}
313 313
 		}
314 314
 
@@ -320,118 +320,118 @@  discard block
 block discarded – undo
320 320
 	 */
321 321
 	public function process_ajax_search() {
322 322
 		$return = false;
323
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
324
-		if ( isset( $_POST['action'] ) && 'lsx_tour_importer' === $_POST['action'] && isset( $_POST['type'] ) && 'destination' === $_POST['type'] ) {
323
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
324
+		if (isset($_POST['action']) && 'lsx_tour_importer' === $_POST['action'] && isset($_POST['type']) && 'destination' === $_POST['type']) {
325 325
 
326 326
 			$searched_items = false;
327
-			if ( isset( $_POST['keyword'] ) ) {
328
-				$keyphrases = array_map( 'sanitize_text_field', wp_unslash( $_POST['keyword'] ) );
329
-			} else {
330
-				$keyphrases = array( 0 );
327
+			if (isset($_POST['keyword'])) {
328
+				$keyphrases = array_map('sanitize_text_field', wp_unslash($_POST['keyword']));
329
+			}else {
330
+				$keyphrases = array(0);
331 331
 			}
332 332
 
333
-			if ( ! is_array( $keyphrases ) ) {
334
-				$keyphrases = array( $keyphrases );
333
+			if (!is_array($keyphrases)) {
334
+				$keyphrases = array($keyphrases);
335 335
 			}
336
-			foreach ( $keyphrases as &$keyword ) {
337
-				$keyword = ltrim( rtrim( $keyword ) );
336
+			foreach ($keyphrases as &$keyword) {
337
+				$keyword = ltrim(rtrim($keyword));
338 338
 			}
339 339
 
340 340
 			$post_status = false;
341 341
 
342
-			if ( in_array( 'publish', $keyphrases ) ) {
342
+			if (in_array('publish', $keyphrases)) {
343 343
 				$post_status = 'publish';
344 344
 			}
345
-			if ( in_array( 'pending', $keyphrases ) ) {
345
+			if (in_array('pending', $keyphrases)) {
346 346
 				$post_status = 'pending';
347 347
 			}
348
-			if ( in_array( 'draft', $keyphrases ) ) {
348
+			if (in_array('draft', $keyphrases)) {
349 349
 				$post_status = 'draft';
350 350
 			}
351
-			if ( in_array( 'import', $keyphrases ) ) {
351
+			if (in_array('import', $keyphrases)) {
352 352
 				$post_status = 'import';
353 353
 			}
354 354
 
355 355
 			// If there is a post status use it.
356
-			if ( false !== $post_status ) {
356
+			if (false !== $post_status) {
357 357
 
358 358
 				$accommodation         = array();
359
-				$current_accommodation = $this->find_current_accommodation( 'destination' );
360
-				if ( ! empty( $current_accommodation ) ) {
361
-					foreach ( $current_accommodation as $cs_key => $ccs_id ) {
362
-						$accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id );
359
+				$current_accommodation = $this->find_current_accommodation('destination');
360
+				if (!empty($current_accommodation)) {
361
+					foreach ($current_accommodation as $cs_key => $ccs_id) {
362
+						$accommodation[] = $this->prepare_row_attributes($cs_key, $ccs_id->post_id);
363 363
 					}
364 364
 				}
365 365
 
366 366
 				// Run through each accommodation and use it.
367
-				if ( ! empty( $accommodation ) ) {
368
-					foreach ( $accommodation as $row_key => $row ) {
367
+				if (!empty($accommodation)) {
368
+					foreach ($accommodation as $row_key => $row) {
369 369
 						$row['post_title'] = $row['name'];
370
-						if ( 'import' === $post_status ) {
371
-							if ( is_array( $this->queued_imports ) && in_array( $row['post_id'], $this->queued_imports ) ) {
372
-								$current_status = get_post_status( $row['post_id'] );
373
-								if ( 'draft' === $current_status ) {
374
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row, $row_key );
370
+						if ('import' === $post_status) {
371
+							if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) {
372
+								$current_status = get_post_status($row['post_id']);
373
+								if ('draft' === $current_status) {
374
+									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row, $row_key);
375 375
 								}
376
-							} else {
376
+							}else {
377 377
 								continue;
378 378
 							}
379
-						} else {
380
-							if ( 0 === $row['post_id'] ) {
379
+						}else {
380
+							if (0 === $row['post_id']) {
381 381
 								continue;
382
-							} else {
383
-								$current_status = get_post_status( $row['post_id'] );
382
+							}else {
383
+								$current_status = get_post_status($row['post_id']);
384 384
 
385
-								if ( $current_status !== $post_status ) {
385
+								if ($current_status !== $post_status) {
386 386
 									continue;
387 387
 								}
388 388
 							}
389
-							$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row, $row_key );
389
+							$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row, $row_key);
390 390
 						}
391 391
 					}
392 392
 				}
393
-			} else {
393
+			}else {
394 394
 
395
-				$key_string_search = implode( '+', $keyphrases );
396
-				$search_data       = wp_remote_get( $this->url . '/Search/' . $key_string_search . '/?all=include' );
395
+				$key_string_search = implode('+', $keyphrases);
396
+				$search_data       = wp_remote_get($this->url.'/Search/'.$key_string_search.'/?all=include');
397 397
 
398
-				if ( ! is_wp_error( $search_data ) || ! empty( $search_data ) && isset( $search_data['response'] ) && isset( $search_data['response']['code'] ) && 200 === $search_data['response']['code'] ) {
399
-					$search_data = json_decode( $search_data['body'], true );
400
-					foreach ( $search_data as $sdata_key => $sdata ) {
398
+				if (!is_wp_error($search_data) || !empty($search_data) && isset($search_data['response']) && isset($search_data['response']['code']) && 200 === $search_data['response']['code']) {
399
+					$search_data = json_decode($search_data['body'], true);
400
+					foreach ($search_data as $sdata_key => $sdata) {
401 401
 
402
-						if ( isset( $sdata['type'] ) && 'Destination' !== trim( $sdata['type'] ) && 'Area' !== trim( $sdata['type'] ) ) {
402
+						if (isset($sdata['type']) && 'Destination' !== trim($sdata['type']) && 'Area' !== trim($sdata['type'])) {
403 403
 							continue;
404 404
 						}
405 405
 
406
-						$temp_id = $this->get_post_id_by_key_value( $sdata['id'] );
407
-						if ( false === $temp_id ) {
406
+						$temp_id = $this->get_post_id_by_key_value($sdata['id']);
407
+						if (false === $temp_id) {
408 408
 							$sdata['post_id']    = 0;
409 409
 							$sdata['post_title'] = $sdata['name'];
410
-						} else {
410
+						}else {
411 411
 							$sdata['post_id']    = $temp_id;
412
-							$sdata['post_title'] = get_the_title( $temp_id );
412
+							$sdata['post_title'] = get_the_title($temp_id);
413 413
 						}
414
-						$searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata, $sdata_key );
414
+						$searched_items[sanitize_title($sdata['name']).'-'.$sdata['id']] = $this->format_row($sdata, $sdata_key);
415 415
 					}
416 416
 				}
417 417
 			}
418 418
 
419
-			if ( false !== $searched_items ) {
420
-				$return = implode( $searched_items );
419
+			if (false !== $searched_items) {
420
+				$return = implode($searched_items);
421 421
 			}
422
-			print_r( $return );
423
-		} else {
424
-			echo esc_attr( 'None found' );
422
+			print_r($return);
423
+		}else {
424
+			echo esc_attr('None found');
425 425
 		}
426 426
 		die();
427 427
 	}
428 428
 
429
-	public function prepare_row_attributes( $cs_key, $ccs_id ) {
429
+	public function prepare_row_attributes($cs_key, $ccs_id) {
430 430
 		$row_item = array(
431 431
 			'id'            => $cs_key,
432 432
 			'type'          => 'Destination',
433
-			'name'          => get_the_title( $ccs_id ),
434
-			'last_modified' => date( 'Y-m-d', strtotime( 'now' ) ),
433
+			'name'          => get_the_title($ccs_id),
434
+			'last_modified' => date('Y-m-d', strtotime('now')),
435 435
 			'post_id'       => $ccs_id,
436 436
 		);
437 437
 		return $row_item;
@@ -440,31 +440,31 @@  discard block
 block discarded – undo
440 440
 	/**
441 441
 	 * Formats the row for output on the screen.
442 442
 	 */
443
-	public function format_row( $row = false, $row_key = '' ) {
444
-		if ( false !== $row ) {
443
+	public function format_row($row = false, $row_key = '') {
444
+		if (false !== $row) {
445 445
 
446 446
 			$status = 'import';
447
-			if ( 0 !== $row['post_id'] ) {
448
-				$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>';
447
+			if (0 !== $row['post_id']) {
448
+				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
449 449
 			}
450 450
 
451 451
 			$row_html = '
452
-			<tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '">
452
+			<tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'">
453 453
 				<th class="check-column" scope="row">
454
-					<label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label>
455
-					<input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '">
454
+					<label for="cb-select-' . $row['id'].'" class="screen-reader-text">'.$row['name'].'</label>
455
+					<input type="checkbox" data-identifier="' . $row['id'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['id'].'">
456 456
 				</th>
457 457
 				<td class="column-order">
458
-					' . ( $row_key + 1 ) . '
458
+					' . ($row_key + 1).'
459 459
 				</td>
460 460
 				<td class="post-title page-title column-title">
461
-					<strong>' . $row['post_title'] . '</strong> - ' . $status . '
461
+					<strong>' . $row['post_title'].'</strong> - '.$status.'
462 462
 				</td>
463 463
 				<td class="date column-date">
464
-					<abbr title="' . date( 'Y/m/d', strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d', strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified
464
+					<abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
465 465
 				</td>
466 466
 				<td class="ssid column-ssid">
467
-					' . $row['id'] . '
467
+					' . $row['id'].'
468 468
 				</td>
469 469
 			</tr>';
470 470
 			return $row_html;
@@ -477,44 +477,44 @@  discard block
 block discarded – undo
477 477
 	public function process_ajax_import() {
478 478
 		$return = false;
479 479
 
480
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
481
-		if ( isset( $_POST['action'] ) && 'lsx_import_items' === $_POST['action'] && isset( $_POST['type'] ) && 'destination' === $_POST['type'] && isset( $_POST['wetu_id'] ) ) {
480
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
481
+		if (isset($_POST['action']) && 'lsx_import_items' === $_POST['action'] && isset($_POST['type']) && 'destination' === $_POST['type'] && isset($_POST['wetu_id'])) {
482 482
 
483
-			$wetu_id = sanitize_text_field( $_POST['wetu_id'] );
483
+			$wetu_id = sanitize_text_field($_POST['wetu_id']);
484 484
 
485
-			if ( isset( $_POST['post_id'] ) ) {
486
-				$post_id            = sanitize_text_field( $_POST['post_id'] );
487
-				$this->current_post = get_post( $post_id );
488
-			} else {
485
+			if (isset($_POST['post_id'])) {
486
+				$post_id            = sanitize_text_field($_POST['post_id']);
487
+				$this->current_post = get_post($post_id);
488
+			}else {
489 489
 				$post_id = 0;
490 490
 			}
491 491
 
492
-			if ( isset( $_POST['team_members'] ) ) {
493
-				$team_members = array_map( 'sanitize_text_field', wp_unslash( $_POST['team_members'] ) );
494
-			} else {
492
+			if (isset($_POST['team_members'])) {
493
+				$team_members = array_map('sanitize_text_field', wp_unslash($_POST['team_members']));
494
+			}else {
495 495
 				$team_members = false;
496 496
 			}
497 497
 
498 498
 			$safari_brands = false;
499 499
 
500
-			delete_option( 'lsx_wetu_importer_destination_settings' );
500
+			delete_option('lsx_wetu_importer_destination_settings');
501 501
 
502
-			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
503
-				$content = array_map( 'sanitize_text_field', wp_unslash( $_POST['content'] ) );
504
-				add_option( 'lsx_wetu_importer_destination_settings', $content );
505
-			} else {
502
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
503
+				$content = array_map('sanitize_text_field', wp_unslash($_POST['content']));
504
+				add_option('lsx_wetu_importer_destination_settings', $content);
505
+			}else {
506 506
 				$content = false;
507 507
 			}
508 508
 
509
-			$jdata = wp_remote_get( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
509
+			$jdata = wp_remote_get($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
510 510
 
511
-			if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
512
-				$adata  = json_decode( $jdata['body'], true );
513
-				$return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands );
514
-				$this->remove_from_queue( $return );
515
-				$this->format_completed_row( $return );
516
-			} else {
517
-				$this->format_error( esc_html__( 'There was a problem importing your destination, please try refreshing the page.', 'lsx-wetu-importer' ) );
511
+			if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
512
+				$adata  = json_decode($jdata['body'], true);
513
+				$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
514
+				$this->remove_from_queue($return);
515
+				$this->format_completed_row($return);
516
+			}else {
517
+				$this->format_error(esc_html__('There was a problem importing your destination, please try refreshing the page.', 'lsx-wetu-importer'));
518 518
 			}
519 519
 		}
520 520
 		die();
@@ -523,14 +523,14 @@  discard block
 block discarded – undo
523 523
 	/**
524 524
 	 * Saves the queue to the option.
525 525
 	 */
526
-	public function remove_from_queue( $id ) {
527
-		if ( ! empty( $this->queued_imports ) ) {
528
-			$key = array_search( $id, $this->queued_imports );
529
-			if ( false !== $key ) {
530
-				unset( $this->queued_imports[ $key ] );
526
+	public function remove_from_queue($id) {
527
+		if (!empty($this->queued_imports)) {
528
+			$key = array_search($id, $this->queued_imports);
529
+			if (false !== $key) {
530
+				unset($this->queued_imports[$key]);
531 531
 
532
-				delete_option( 'lsx_wetu_importer_que' );
533
-				update_option( 'lsx_wetu_importer_que', $this->queued_imports );
532
+				delete_option('lsx_wetu_importer_que');
533
+				update_option('lsx_wetu_importer_que', $this->queued_imports);
534 534
 			}
535 535
 		}
536 536
 	}
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
 	/**
539 539
 	 * Connect to wetu
540 540
 	 */
541
-	public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false ) {
542
-		if ( 'Destination' === trim( $data[0]['type'] ) || 'Area' === trim( $data[0]['type'] ) ) {
541
+	public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false) {
542
+		if ('Destination' === trim($data[0]['type']) || 'Area' === trim($data[0]['type'])) {
543 543
 			$post_name         = '';
544 544
 			$data_post_content = '';
545 545
 			$data_post_excerpt = '';
@@ -548,129 +548,129 @@  discard block
 block discarded – undo
548 548
 				'post_type' => 'destination',
549 549
 			);
550 550
 
551
-			if ( ! empty( $importable_content ) && in_array( 'country', $importable_content ) ) {
552
-				$parent = $this->check_for_parent( $data );
553
-				if ( false !== $parent ) {
551
+			if (!empty($importable_content) && in_array('country', $importable_content)) {
552
+				$parent = $this->check_for_parent($data);
553
+				if (false !== $parent) {
554 554
 					$post['post_parent'] = $parent;
555 555
 				}
556 556
 			}
557 557
 
558 558
 			// Set the post_content.
559
-			if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) {
560
-				if ( isset( $data[0]['content']['general_description'] ) ) {
559
+			if (!empty($importable_content) && in_array('description', $importable_content)) {
560
+				if (isset($data[0]['content']['general_description'])) {
561 561
 
562
-					if ( in_array( 'strip_tags', $importable_content ) ) {
563
-						$post['post_content'] = wp_strip_all_tags( $data[0]['content']['general_description'] );
564
-					} else {
562
+					if (in_array('strip_tags', $importable_content)) {
563
+						$post['post_content'] = wp_strip_all_tags($data[0]['content']['general_description']);
564
+					}else {
565 565
 						$post['post_content'] = $data[0]['content']['general_description'];
566 566
 					}
567 567
 				}
568 568
 			}
569 569
 
570
-			if ( false !== $id && '0' !== $id ) {
570
+			if (false !== $id && '0' !== $id) {
571 571
 				$post['ID'] = $id;
572
-				if ( isset( $this->options ) && 'on' !== $this->options['disable_destination_title'] && isset( $data[0]['name'] ) ) {
572
+				if (isset($this->options) && 'on' !== $this->options['disable_destination_title'] && isset($data[0]['name'])) {
573 573
 					$post['post_title'] = $data[0]['name'];
574
-					$post['post_name']  = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 );
574
+					$post['post_name']  = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
575 575
 				}
576 576
 				$post['post_status'] = 'publish';
577 577
 
578
-				$id        = wp_update_post( $post );
579
-				$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
580
-				update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date );
581
-			} else {
578
+				$id        = wp_update_post($post);
579
+				$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
580
+				update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
581
+			}else {
582 582
 				// Set the name.
583
-				if ( isset( $data[0]['name'] ) ) {
584
-					$post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 );
583
+				if (isset($data[0]['name'])) {
584
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
585 585
 				}
586 586
 
587 587
 				$post['post_name']   = $post_name;
588 588
 				$post['post_title']  = $data[0]['name'];
589 589
 				$post['post_status'] = 'publish';
590
-				$id                  = wp_insert_post( $post );
590
+				$id                  = wp_insert_post($post);
591 591
 
592 592
 				// Save the WETU ID and the Last date it was modified.
593
-				if ( false !== $id ) {
594
-					add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
595
-					add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) );
593
+				if (false !== $id) {
594
+					add_post_meta($id, 'lsx_wetu_id', $wetu_id);
595
+					add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']));
596 596
 				}
597 597
 			}
598 598
 
599
-			$this->find_attachments( $id );
599
+			$this->find_attachments($id);
600 600
 
601 601
 			// Set the team member if it is there.
602
-			if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) {
603
-				$this->set_team_member( $id, $team_members );
602
+			if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
603
+				$this->set_team_member($id, $team_members);
604 604
 			}
605 605
 
606
-			$this->set_map_data( $data, $id, 9 );
606
+			$this->set_map_data($data, $id, 9);
607 607
 
608 608
 			// Set the Room Data.
609
-			if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) {
610
-				$this->set_video_data( $data, $id );
609
+			if (false !== $importable_content && in_array('videos', $importable_content)) {
610
+				$this->set_video_data($data, $id);
611 611
 			}
612 612
 
613 613
 			// Set the Electricity.
614
-			if ( false !== $importable_content && in_array( 'electricity', $importable_content ) ) {
615
-				$this->set_travel_info( $data, $id, 'electricity', $importable_content );
614
+			if (false !== $importable_content && in_array('electricity', $importable_content)) {
615
+				$this->set_travel_info($data, $id, 'electricity', $importable_content);
616 616
 			}
617 617
 			// Set the cuisine.
618
-			if ( false !== $importable_content && in_array( 'cuisine', $importable_content ) ) {
619
-				$this->set_travel_info( $data, $id, 'cuisine', $importable_content );
618
+			if (false !== $importable_content && in_array('cuisine', $importable_content)) {
619
+				$this->set_travel_info($data, $id, 'cuisine', $importable_content);
620 620
 			}
621 621
 			// Set the banking.
622
-			if ( false !== $importable_content && in_array( 'banking', $importable_content ) ) {
623
-				$this->set_travel_info( $data, $id, 'banking', $importable_content );
622
+			if (false !== $importable_content && in_array('banking', $importable_content)) {
623
+				$this->set_travel_info($data, $id, 'banking', $importable_content);
624 624
 			}
625 625
 			// Set the transport.
626
-			if ( false !== $importable_content && in_array( 'transport', $importable_content ) ) {
627
-				$this->set_travel_info( $data, $id, 'transport', $importable_content );
626
+			if (false !== $importable_content && in_array('transport', $importable_content)) {
627
+				$this->set_travel_info($data, $id, 'transport', $importable_content);
628 628
 			}
629 629
 			// Set the dress.
630
-			if ( false !== $importable_content && in_array( 'dress', $importable_content ) ) {
631
-				$this->set_travel_info( $data, $id, 'dress', $importable_content );
630
+			if (false !== $importable_content && in_array('dress', $importable_content)) {
631
+				$this->set_travel_info($data, $id, 'dress', $importable_content);
632 632
 			}
633 633
 			// Set the climate.
634
-			if ( false !== $importable_content && in_array( 'climate', $importable_content ) ) {
635
-				$this->set_travel_info( $data, $id, 'climate', $importable_content );
634
+			if (false !== $importable_content && in_array('climate', $importable_content)) {
635
+				$this->set_travel_info($data, $id, 'climate', $importable_content);
636 636
 			}
637 637
 			// Set the Health.
638
-			if ( false !== $importable_content && in_array( 'health', $importable_content ) ) {
639
-				$this->set_travel_info( $data, $id, 'health', $importable_content );
638
+			if (false !== $importable_content && in_array('health', $importable_content)) {
639
+				$this->set_travel_info($data, $id, 'health', $importable_content);
640 640
 			}
641 641
 			// Set the Safety.
642
-			if ( false !== $importable_content && in_array( 'safety', $importable_content ) ) {
643
-				$this->set_travel_info( $data, $id, 'safety', $importable_content );
642
+			if (false !== $importable_content && in_array('safety', $importable_content)) {
643
+				$this->set_travel_info($data, $id, 'safety', $importable_content);
644 644
 			}
645 645
 			// Set the Visa.
646
-			if ( false !== $importable_content && in_array( 'visa', $importable_content ) ) {
647
-				$this->set_travel_info( $data, $id, 'visa', $importable_content );
646
+			if (false !== $importable_content && in_array('visa', $importable_content)) {
647
+				$this->set_travel_info($data, $id, 'visa', $importable_content);
648 648
 			}
649 649
 			// Set the General.
650
-			if ( false !== $importable_content && in_array( 'additional_info', $importable_content ) ) {
651
-				$this->set_travel_info( $data, $id, 'additional_info', $importable_content );
650
+			if (false !== $importable_content && in_array('additional_info', $importable_content)) {
651
+				$this->set_travel_info($data, $id, 'additional_info', $importable_content);
652 652
 			}
653 653
 
654 654
 			// Setup some default for use in the import.
655
-			if ( false !== $importable_content && ( in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content ) ) ) {
656
-				$this->find_attachments( $id );
655
+			if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) {
656
+				$this->find_attachments($id);
657 657
 
658 658
 				// Set the featured image.
659
-				if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
660
-					$this->set_featured_image( $data, $id );
659
+				if (false !== $importable_content && in_array('featured_image', $importable_content)) {
660
+					$this->set_featured_image($data, $id);
661 661
 				}
662
-				if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
663
-					$this->set_banner_image( $data, $id, $importable_content );
662
+				if (false !== $importable_content && in_array('banner_image', $importable_content)) {
663
+					$this->set_banner_image($data, $id, $importable_content);
664 664
 				}
665 665
 				// Import the main gallery.
666
-				if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) {
667
-					$this->create_main_gallery( $data, $id );
666
+				if (false !== $importable_content && in_array('gallery', $importable_content)) {
667
+					$this->create_main_gallery($data, $id);
668 668
 				}
669 669
 			}
670 670
 
671 671
 			// Set the continent.
672
-			if ( false !== $importable_content && in_array( 'continent', $importable_content ) ) {
673
-				$this->set_continent( $data, $id );
672
+			if (false !== $importable_content && in_array('continent', $importable_content)) {
673
+				$this->set_continent($data, $id);
674 674
 			}
675 675
 		}
676 676
 
@@ -680,43 +680,43 @@  discard block
 block discarded – undo
680 680
 	/**
681 681
 	 * Saves the room data
682 682
 	 */
683
-	public function set_travel_info( $data, $id, $meta_key, $importable = array( 'none' ) ) {
684
-		if ( ! empty( $data[0]['travel_information'] ) && isset( $data[0]['travel_information'][ $meta_key ] ) ) {
685
-			$content = $data[0]['travel_information'][ $meta_key ];
683
+	public function set_travel_info($data, $id, $meta_key, $importable = array('none')) {
684
+		if (!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])) {
685
+			$content = $data[0]['travel_information'][$meta_key];
686 686
 
687
-			if ( in_array( 'strip_tags', $importable ) ) {
688
-				$content = strip_tags( $content );
687
+			if (in_array('strip_tags', $importable)) {
688
+				$content = strip_tags($content);
689 689
 			}
690 690
 
691
-			$this->save_custom_field( $content, $meta_key, $id );
691
+			$this->save_custom_field($content, $meta_key, $id);
692 692
 		}
693 693
 	}
694 694
 
695 695
 	/**
696 696
 	 * Set the Travel Style
697 697
 	 */
698
-	public function set_continent( $data, $id ) {
698
+	public function set_continent($data, $id) {
699 699
 
700
-		if ( isset( $data[0]['position']['country'] ) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id'] ) {
700
+		if (isset($data[0]['position']['country']) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id']) {
701 701
 			// Get the continent code.
702
-			$country_code    = to_country_data( $data[0]['position']['country'], false );
703
-			$continent_code  = to_continent_code( $country_code );
704
-			$continent_label = to_continent_label( $continent_code );
702
+			$country_code    = to_country_data($data[0]['position']['country'], false);
703
+			$continent_code  = to_continent_code($country_code);
704
+			$continent_label = to_continent_label($continent_code);
705 705
 
706
-			if ( ! empty( tour_operator()->options['display']['enable_search_region_filter'] ) ) {
707
-				$continent_label = to_continent_region_label( $country_code );
706
+			if (!empty(tour_operator()->options['display']['enable_search_region_filter'])) {
707
+				$continent_label = to_continent_region_label($country_code);
708 708
 			}
709 709
 
710
-			if ( '' !== $continent_label ) {
711
-				$term = term_exists( trim( $continent_label ), 'continent' );
712
-				if ( ! $term ) {
713
-					$term = wp_insert_term( trim( $continent_label ), 'continent' );
710
+			if ('' !== $continent_label) {
711
+				$term = term_exists(trim($continent_label), 'continent');
712
+				if (!$term) {
713
+					$term = wp_insert_term(trim($continent_label), 'continent');
714 714
 
715
-					if ( is_wp_error( $term ) ) {
716
-						echo wp_kses_post( $term->get_error_message() );
715
+					if (is_wp_error($term)) {
716
+						echo wp_kses_post($term->get_error_message());
717 717
 					}
718
-				} else {
719
-					wp_set_object_terms( $id, sanitize_title( $continent_label ), 'continent', true );
718
+				}else {
719
+					wp_set_object_terms($id, sanitize_title($continent_label), 'continent', true);
720 720
 				}
721 721
 			}
722 722
 		}
@@ -725,12 +725,12 @@  discard block
 block discarded – undo
725 725
 	/**
726 726
 	 * Save the list of Accommodation into an option
727 727
 	 */
728
-	public function check_for_parent( $data = array() ) {
728
+	public function check_for_parent($data = array()) {
729 729
 		global $wpdb;
730 730
 
731
-		if ( $data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id'] ) {
732
-			$result = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'lsx_wetu_id' AND meta_value = '%s'", array( $data[0]['position']['country_content_entity_id'] ) ) );
733
-			if ( ! empty( $result ) && '' !== $result && false !== $result ) {
731
+		if ($data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id']) {
732
+			$result = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'lsx_wetu_id' AND meta_value = '%s'", array($data[0]['position']['country_content_entity_id'])));
733
+			if (!empty($result) && '' !== $result && false !== $result) {
734 734
 				return $result;
735 735
 			}
736 736
 		}
Please login to merge, or discard this patch.
classes/class-lsx-wetu-importer-settings.php 1 patch
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 			'accommodation_images_cron'          => '',
67 67
 			'accommodation_images_cron_featured' => '',
68 68
 		);
69
-		$this->fields   = array_keys( $this->defaults );
70
-		add_action( 'admin_init', array( $this, 'save_options' ) );
69
+		$this->fields = array_keys($this->defaults);
70
+		add_action('admin_init', array($this, 'save_options'));
71 71
 	}
72 72
 
73 73
 	/**
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 */
78 78
 	public static function get_instance() {
79 79
 		// If the single instance hasn't been set, set it now.
80
-		if ( ! isset( self::$instance ) ) {
80
+		if (!isset(self::$instance)) {
81 81
 			self::$instance = new self();
82 82
 		}
83 83
 		return self::$instance;
@@ -88,27 +88,27 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function display_page() {
90 90
 		$options = lsx_wetu_get_options();
91
-		foreach ( $options as $key => $value ) {
92
-			$value = trim( $value );
91
+		foreach ($options as $key => $value) {
92
+			$value = trim($value);
93 93
 		}
94
-		$options = wp_parse_args( $options, $this->defaults );
94
+		$options = wp_parse_args($options, $this->defaults);
95 95
 		?>
96 96
 		<div class="wrap">
97 97
 			<form method="post" class="">
98
-				<?php wp_nonce_field( 'lsx_wetu_importer_save', 'lsx_wetu_importer_save_options' ); ?>
99
-				<?php do_action( 'lsx_wetu_importer_settings_before' ); ?>
100
-				<h1><?php esc_html_e( 'General', 'lsx-wetu-importer' ); ?></h1>
98
+				<?php wp_nonce_field('lsx_wetu_importer_save', 'lsx_wetu_importer_save_options'); ?>
99
+				<?php do_action('lsx_wetu_importer_settings_before'); ?>
100
+				<h1><?php esc_html_e('General', 'lsx-wetu-importer'); ?></h1>
101 101
 				<table class="form-table">
102 102
 					<tbody>
103 103
 						<tr class="form-field">
104 104
 							<th scope="row">
105
-								<label for="wetu_api_key"><span title="The API key can be found on your My Account page of your WETU account." id="doc-tooltip" class="dashicons dashicons-editor-help tooltip"></span> <?php esc_html_e( 'API Key', 'lsx-wetu-importer' ); ?></label>
105
+								<label for="wetu_api_key"><span title="The API key can be found on your My Account page of your WETU account." id="doc-tooltip" class="dashicons dashicons-editor-help tooltip"></span> <?php esc_html_e('API Key', 'lsx-wetu-importer'); ?></label>
106 106
 							</th>
107 107
 							<td>
108 108
 								<input data-toggle="tooltip" data-placement="top" title="The API key can be found on your My Account page of your WETU account." type="text" value="
109 109
 								<?php
110
-								if ( isset( $options['api_key'] ) ) {
111
-									echo esc_attr( $options['api_key'] );
110
+								if (isset($options['api_key'])) {
111
+									echo esc_attr($options['api_key']);
112 112
 								}
113 113
 								?>
114 114
 								" name="api_key" />
@@ -117,227 +117,227 @@  discard block
 block discarded – undo
117 117
 					</tbody>
118 118
 				</table>
119 119
 
120
-				<h1><?php esc_html_e( 'Tours', 'lsx-wetu-importer' ); ?></h1>
120
+				<h1><?php esc_html_e('Tours', 'lsx-wetu-importer'); ?></h1>
121 121
 				<table class="form-table">
122 122
 					<tbody>
123 123
 						<tr class="form-field -wrap">
124 124
 							<th scope="row">
125
-								<label for="disable_tour_title"><?php esc_html_e( 'Enable Custom Titles', 'lsx-wetu-importer' ); ?></label>
125
+								<label for="disable_tour_title"><?php esc_html_e('Enable Custom Titles', 'lsx-wetu-importer'); ?></label>
126 126
 							</th>
127 127
 							<td>
128 128
 								<input type="checkbox"
129 129
 								<?php
130
-								if ( isset( $options['disable_tour_title'] ) && '' !== $options['disable_tour_title'] ) {
131
-									echo esc_attr( 'checked="checked"' );
130
+								if (isset($options['disable_tour_title']) && '' !== $options['disable_tour_title']) {
131
+									echo esc_attr('checked="checked"');
132 132
 								}
133 133
 								?>
134 134
 								name="disable_tour_title" />
135 135
 
136
-								<small><?php esc_html_e( 'If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer' ); ?></small>
136
+								<small><?php esc_html_e('If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer'); ?></small>
137 137
 							</td>
138 138
 						</tr>
139 139
 						<tr class="form-field -wrap">
140 140
 							<th scope="row">
141
-								<label for="disable_tour_descriptions"><?php esc_html_e( 'Disable Descriptions', 'lsx-wetu-importer' ); ?></label>
141
+								<label for="disable_tour_descriptions"><?php esc_html_e('Disable Descriptions', 'lsx-wetu-importer'); ?></label>
142 142
 							</th>
143 143
 							<td>
144 144
 								<input type="checkbox"
145 145
 								<?php
146
-								if ( isset( $options['disable_tour_descriptions'] ) && '' !== $options['disable_tour_descriptions'] ) {
147
-									echo esc_attr( 'checked="checked"' );
146
+								if (isset($options['disable_tour_descriptions']) && '' !== $options['disable_tour_descriptions']) {
147
+									echo esc_attr('checked="checked"');
148 148
 								}
149 149
 								?>
150 150
 								name="disable_tour_descriptions" />
151 151
 
152
-								<small><?php esc_html_e( 'If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer' ); ?></small>
152
+								<small><?php esc_html_e('If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer'); ?></small>
153 153
 							</td>
154 154
 						</tr>
155 155
 						<tr class="form-field -wrap">
156 156
 							<th scope="row">
157
-								<label for="disable_tour_tags"><?php esc_html_e( 'Disable Tags / Travel Styles', 'lsx-wetu-importer' ); ?></label>
157
+								<label for="disable_tour_tags"><?php esc_html_e('Disable Tags / Travel Styles', 'lsx-wetu-importer'); ?></label>
158 158
 							</th>
159 159
 							<td>
160 160
 								<input type="checkbox"
161 161
 								<?php
162
-								if ( isset( $options['disable_tour_tags'] ) && '' !== $options['disable_tour_tags'] ) {
163
-									echo esc_attr( 'checked="checked"' );
162
+								if (isset($options['disable_tour_tags']) && '' !== $options['disable_tour_tags']) {
163
+									echo esc_attr('checked="checked"');
164 164
 								}
165 165
 								?>
166 166
 								name="disable_tour_tags" />
167 167
 
168
-								<small><?php esc_html_e( 'Disable this is you dont want the option available on the import screen.', 'lsx-wetu-importer' ); ?></small>
168
+								<small><?php esc_html_e('Disable this is you dont want the option available on the import screen.', 'lsx-wetu-importer'); ?></small>
169 169
 							</td>
170 170
 						</tr>
171 171
 
172 172
 						<tr class="form-field -wrap">
173 173
 							<th scope="row">
174
-								<label for="enable_tour_ref_column"><?php esc_html_e( 'Enable Reference Column', 'lsx-wetu-importer' ); ?></label>
174
+								<label for="enable_tour_ref_column"><?php esc_html_e('Enable Reference Column', 'lsx-wetu-importer'); ?></label>
175 175
 							</th>
176 176
 							<td>
177 177
 								<input type="checkbox"
178 178
 								<?php
179
-								if ( isset( $options['enable_tour_ref_column'] ) && '' !== $options['enable_tour_ref_column'] ) {
180
-									echo esc_attr( 'checked="checked"' );
179
+								if (isset($options['enable_tour_ref_column']) && '' !== $options['enable_tour_ref_column']) {
180
+									echo esc_attr('checked="checked"');
181 181
 								}
182 182
 								?>
183 183
 								name="enable_tour_ref_column" />
184
-								<small><?php esc_html_e( 'Enables the use of the WETU Reference Column for better tours management.', 'lsx-wetu-importer' ); ?></small>
184
+								<small><?php esc_html_e('Enables the use of the WETU Reference Column for better tours management.', 'lsx-wetu-importer'); ?></small>
185 185
 							</td>
186 186
 						</tr>
187 187
 
188 188
 						<tr class="form-field -wrap">
189 189
 							<th scope="row">
190
-								<label for="enable_tour_featured_random"><?php esc_html_e( 'Randomize Featured Image', 'lsx-wetu-importer' ); ?></label>
190
+								<label for="enable_tour_featured_random"><?php esc_html_e('Randomize Featured Image', 'lsx-wetu-importer'); ?></label>
191 191
 							</th>
192 192
 							<td>
193 193
 								<input type="checkbox"
194 194
 								<?php
195
-								if ( isset( $options['enable_tour_featured_random'] ) && '' !== $options['enable_tour_featured_random'] ) {
196
-									echo esc_attr( 'checked="checked"' );
195
+								if (isset($options['enable_tour_featured_random']) && '' !== $options['enable_tour_featured_random']) {
196
+									echo esc_attr('checked="checked"');
197 197
 								}
198 198
 								?>
199 199
 								name="enable_tour_featured_random" />
200
-								<small><?php esc_html_e( 'This will randomize the featured image from the destination gallery.', 'lsx-wetu-importer' ); ?></small>
200
+								<small><?php esc_html_e('This will randomize the featured image from the destination gallery.', 'lsx-wetu-importer'); ?></small>
201 201
 							</td>
202 202
 						</tr>
203 203
 					</tbody>
204 204
 				</table>
205 205
 
206
-				<h1><?php esc_html_e( 'Accommodation', 'lsx-wetu-importer' ); ?></h1>
206
+				<h1><?php esc_html_e('Accommodation', 'lsx-wetu-importer'); ?></h1>
207 207
 
208 208
 				<table class="form-table">
209 209
 					<tbody>
210 210
 						<tr class="form-field -wrap">
211 211
 							<th scope="row">
212
-								<label for="disable_accommodation_title"><?php esc_html_e( 'Enable Custom Titles', 'lsx-wetu-importer' ); ?></label>
212
+								<label for="disable_accommodation_title"><?php esc_html_e('Enable Custom Titles', 'lsx-wetu-importer'); ?></label>
213 213
 							</th>
214 214
 							<td>
215 215
 								<input type="checkbox"
216 216
 								<?php
217
-								if ( isset( $options['disable_accommodation_title'] ) && '' !== $options['disable_accommodation_title'] ) {
218
-									echo esc_attr( 'checked="checked"' );
217
+								if (isset($options['disable_accommodation_title']) && '' !== $options['disable_accommodation_title']) {
218
+									echo esc_attr('checked="checked"');
219 219
 								}
220 220
 								?>
221 221
 								name="disable_accommodation_title" />
222 222
 
223
-								<small><?php esc_html_e( 'If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer' ); ?></small>
223
+								<small><?php esc_html_e('If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer'); ?></small>
224 224
 							</td>
225 225
 						</tr>
226 226
 						<tr class="form-field -wrap">
227 227
 							<th scope="row">
228
-								<label for="disable_accommodation_descriptions"><?php esc_html_e( 'Disable Descriptions', 'lsx-wetu-importer' ); ?></label>
228
+								<label for="disable_accommodation_descriptions"><?php esc_html_e('Disable Descriptions', 'lsx-wetu-importer'); ?></label>
229 229
 							</th>
230 230
 							<td>
231 231
 								<input type="checkbox"
232 232
 								<?php
233
-								if ( isset( $options['disable_accommodation_descriptions'] ) && '' !== $options['disable_accommodation_descriptions'] ) {
234
-									echo esc_attr( 'checked="checked"' );
233
+								if (isset($options['disable_accommodation_descriptions']) && '' !== $options['disable_accommodation_descriptions']) {
234
+									echo esc_attr('checked="checked"');
235 235
 								}
236 236
 								?>
237 237
 								name="disable_accommodation_descriptions" />
238
-								<small><?php esc_html_e( 'If you are going to edit the accommodation descriptions imported then enable this setting.', 'lsx-wetu-importer' ); ?></small>
238
+								<small><?php esc_html_e('If you are going to edit the accommodation descriptions imported then enable this setting.', 'lsx-wetu-importer'); ?></small>
239 239
 							</td>
240 240
 						</tr>
241 241
 						<tr class="form-field -wrap">
242 242
 							<th scope="row">
243
-								<label for="disable_accommodation_filtering"><?php esc_html_e( 'Disable Description Filtering', 'lsx-wetu-importer' ); ?></label>
243
+								<label for="disable_accommodation_filtering"><?php esc_html_e('Disable Description Filtering', 'lsx-wetu-importer'); ?></label>
244 244
 							</th>
245 245
 							<td>
246 246
 								<input type="checkbox"
247 247
 								<?php
248
-								if ( isset( $options['disable_accommodation_filtering'] ) && '' !== $options['disable_accommodation_filtering'] ) {
249
-									echo esc_attr( 'checked="checked"' );
248
+								if (isset($options['disable_accommodation_filtering']) && '' !== $options['disable_accommodation_filtering']) {
249
+									echo esc_attr('checked="checked"');
250 250
 								}
251 251
 								?>
252 252
 								name="disable_accommodation_filtering" />
253
-								<small><?php esc_html_e( 'This will stop the HTML from being stripped out of the description.', 'lsx-wetu-importer' ); ?></small>
253
+								<small><?php esc_html_e('This will stop the HTML from being stripped out of the description.', 'lsx-wetu-importer'); ?></small>
254 254
 							</td>
255 255
 						</tr>
256 256
 
257 257
 						<tr class="form-field -wrap">
258 258
 							<th scope="row">
259
-								<label for="disable_accommodation_excerpts"><?php esc_html_e( 'Disable Excerpts', 'lsx-wetu-importer' ); ?></label>
259
+								<label for="disable_accommodation_excerpts"><?php esc_html_e('Disable Excerpts', 'lsx-wetu-importer'); ?></label>
260 260
 							</th>
261 261
 							<td>
262 262
 								<input type="checkbox"
263 263
 								<?php
264
-								if ( isset( $options['disable_accommodation_excerpts'] ) && '' !== $options['disable_accommodation_excerpts'] ) {
265
-									echo esc_attr( 'checked="checked"' );
264
+								if (isset($options['disable_accommodation_excerpts']) && '' !== $options['disable_accommodation_excerpts']) {
265
+									echo esc_attr('checked="checked"');
266 266
 								}
267 267
 								?>
268 268
 								name="disable_accommodation_excerpts" />
269
-								<small><?php esc_html_e( 'If you are going to edit the accommodation excerpts then enable this setting.', 'lsx-wetu-importer' ); ?></small>
269
+								<small><?php esc_html_e('If you are going to edit the accommodation excerpts then enable this setting.', 'lsx-wetu-importer'); ?></small>
270 270
 							</td>
271 271
 						</tr>
272 272
 					</tbody>
273 273
 				</table>
274 274
 
275
-				<h1><?php esc_html_e( 'Destinations', 'lsx-wetu-importer' ); ?></h1>
275
+				<h1><?php esc_html_e('Destinations', 'lsx-wetu-importer'); ?></h1>
276 276
 
277 277
 				<table class="form-table">
278 278
 					<tbody>
279 279
 						<tr class="form-field -wrap">
280 280
 							<th scope="row">
281
-								<label for="disable_destination_title"><?php esc_html_e( 'Enable Custom Titles', 'lsx-wetu-importer' ); ?></label>
281
+								<label for="disable_destination_title"><?php esc_html_e('Enable Custom Titles', 'lsx-wetu-importer'); ?></label>
282 282
 							</th>
283 283
 							<td>
284 284
 								<input type="checkbox"
285 285
 								<?php
286
-								if ( isset( $options['disable_destination_title'] ) && '' !== $options['disable_destination_title'] ) {
287
-									echo esc_attr( 'checked="checked"' );
286
+								if (isset($options['disable_destination_title']) && '' !== $options['disable_destination_title']) {
287
+									echo esc_attr('checked="checked"');
288 288
 								}
289 289
 								?>
290 290
 								name="disable_destination_title" />
291 291
 
292
-								<small><?php esc_html_e( 'If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer' ); ?></small>
292
+								<small><?php esc_html_e('If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer'); ?></small>
293 293
 							</td>
294 294
 						</tr>
295 295
 						<tr class="form-field -wrap">
296 296
 							<th scope="row">
297
-								<label for="disable_destination_descriptions"><?php esc_html_e( 'Disable Descriptions', 'lsx-wetu-importer' ); ?></label>
297
+								<label for="disable_destination_descriptions"><?php esc_html_e('Disable Descriptions', 'lsx-wetu-importer'); ?></label>
298 298
 							</th>
299 299
 							<td>
300 300
 								<input type="checkbox"
301 301
 								<?php
302
-								if ( isset( $options['disable_destination_descriptions'] ) && '' !== $options['disable_destination_descriptions'] ) {
303
-									echo esc_attr( 'checked="checked"' );
302
+								if (isset($options['disable_destination_descriptions']) && '' !== $options['disable_destination_descriptions']) {
303
+									echo esc_attr('checked="checked"');
304 304
 								}
305 305
 								?>
306 306
 								name="disable_destination_descriptions" />
307
-								<small><?php esc_html_e( 'If you are going to edit the destination descriptions on this site then enable this setting.', 'lsx-wetu-importer' ); ?></small>
307
+								<small><?php esc_html_e('If you are going to edit the destination descriptions on this site then enable this setting.', 'lsx-wetu-importer'); ?></small>
308 308
 							</td>
309 309
 						</tr>
310 310
 					</tbody>
311 311
 				</table>
312 312
 
313
-				<h1><?php esc_html_e( 'Images', 'lsx-wetu-importer' ); ?></h1>
313
+				<h1><?php esc_html_e('Images', 'lsx-wetu-importer'); ?></h1>
314 314
 
315 315
 				<table class="form-table">
316 316
 					<tbody>
317 317
 						<tr class="form-field -wrap">
318 318
 							<th scope="row">
319
-								<label for="image_replacing"><?php esc_html_e( 'Replace Images', 'lsx-wetu-importer' ); ?></label>
319
+								<label for="image_replacing"><?php esc_html_e('Replace Images', 'lsx-wetu-importer'); ?></label>
320 320
 							</th>
321 321
 							<td>
322 322
 								<input type="checkbox"
323 323
 								<?php
324
-								if ( isset( $options['image_replacing'] ) && '' !== $options['image_replacing'] ) {
325
-									echo esc_attr( 'checked="checked"' );
324
+								if (isset($options['image_replacing']) && '' !== $options['image_replacing']) {
325
+									echo esc_attr('checked="checked"');
326 326
 								}
327 327
 								?>
328 328
 								name="image_replacing" />
329
-								<p><?php esc_html_e( 'Do you want your images to be replaced on each import.', 'lsx-wetu-importer' ); ?></p>
329
+								<p><?php esc_html_e('Do you want your images to be replaced on each import.', 'lsx-wetu-importer'); ?></p>
330 330
 							</td>
331 331
 						</tr>
332 332
 						<tr class="form-field -wrap">
333 333
 							<th scope="row">
334
-								<label for="image_limit"> <?php esc_html_e( 'Limit the amount of images imported to the gallery', 'lsx-wetu-importer' ); ?></label>
334
+								<label for="image_limit"> <?php esc_html_e('Limit the amount of images imported to the gallery', 'lsx-wetu-importer'); ?></label>
335 335
 							</th>
336 336
 							<td>
337 337
 								<input placeholder="" type="text" value="
338 338
 								<?php
339
-								if ( isset( $options['image_limit'] ) && '' !== $options['image_limit'] ) {
340
-									echo esc_attr( $options['image_limit'] );
339
+								if (isset($options['image_limit']) && '' !== $options['image_limit']) {
340
+									echo esc_attr($options['image_limit']);
341 341
 								}
342 342
 								?>
343 343
 								"
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
 
348 348
 						<tr class="form-field -wrap">
349 349
 							<th scope="row">
350
-								<label for="image_scaling"><?php esc_html_e( 'Enable Image Scaling', 'lsx-wetu-importer' ); ?></label>
350
+								<label for="image_scaling"><?php esc_html_e('Enable Image Scaling', 'lsx-wetu-importer'); ?></label>
351 351
 							</th>
352 352
 							<td>
353 353
 								<input type="checkbox"
354 354
 								<?php
355
-								if ( isset( $options['image_scaling'] ) && '' !== $options['image_scaling'] ) {
356
-									echo esc_attr( 'checked="checked"' );
355
+								if (isset($options['image_scaling']) && '' !== $options['image_scaling']) {
356
+									echo esc_attr('checked="checked"');
357 357
 								}
358 358
 								?>
359 359
 								name="image_scaling" />
@@ -361,13 +361,13 @@  discard block
 block discarded – undo
361 361
 						</tr>
362 362
 						<tr class="form-field -wrap">
363 363
 							<th scope="row">
364
-								<label for="width"> <?php esc_html_e( 'Width (px)', 'lsx-wetu-importer' ); ?></label>
364
+								<label for="width"> <?php esc_html_e('Width (px)', 'lsx-wetu-importer'); ?></label>
365 365
 							</th>
366 366
 							<td>
367 367
 								<input placeholder="800" type="text" value="
368 368
 								<?php
369
-								if ( isset( $options['width'] ) && '' !== $options['width'] ) {
370
-									echo esc_attr( $options['width'] );
369
+								if (isset($options['width']) && '' !== $options['width']) {
370
+									echo esc_attr($options['width']);
371 371
 								}
372 372
 								?>
373 373
 								"
@@ -376,13 +376,13 @@  discard block
 block discarded – undo
376 376
 						</tr>
377 377
 						<tr class="form-field -wrap">
378 378
 							<th scope="row">
379
-								<label for="height"> <?php esc_html_e( 'Height (px)', 'lsx-wetu-importer' ); ?></label>
379
+								<label for="height"> <?php esc_html_e('Height (px)', 'lsx-wetu-importer'); ?></label>
380 380
 							</th>
381 381
 							<td>
382 382
 								<input placeholder="600" type="text" value="
383 383
 								<?php
384
-								if ( isset( $options['height'] ) && '' !== $options['height'] ) {
385
-									echo esc_attr( $options['height'] );
384
+								if (isset($options['height']) && '' !== $options['height']) {
385
+									echo esc_attr($options['height']);
386 386
 								}
387 387
 								?>
388 388
 								"
@@ -392,93 +392,93 @@  discard block
 block discarded – undo
392 392
 
393 393
 						<tr class="form-field -wrap image-settings">
394 394
 							<th scope="row">
395
-								<label for="scaling"> <?php esc_html_e( 'Scaling', 'lsx-wetu-importer' ); ?></label>
395
+								<label for="scaling"> <?php esc_html_e('Scaling', 'lsx-wetu-importer'); ?></label>
396 396
 							</th>
397 397
 							<td>
398 398
 								<input type="radio"
399 399
 								<?php
400
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'raw' === $options['scaling'] ) {
401
-									echo esc_attr( 'checked="checked"' );
400
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'raw' === $options['scaling']) {
401
+									echo esc_attr('checked="checked"');
402 402
 								}
403 403
 								?>
404
-								name="scaling" value="raw" /> <?php esc_html_e( 'Get the Full size image, no cropping takes place.', 'lsx-wetu-importer' ); ?><br />
404
+								name="scaling" value="raw" /> <?php esc_html_e('Get the Full size image, no cropping takes place.', 'lsx-wetu-importer'); ?><br />
405 405
 								<input type="radio"
406 406
 								<?php
407
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'c' === $options['scaling'] ) {
408
-									echo esc_attr( 'checked="checked"' );
407
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'c' === $options['scaling']) {
408
+									echo esc_attr('checked="checked"');
409 409
 								}
410 410
 								?>
411
-								name="scaling"  value="c" /> <?php esc_html_e( 'Crop image to fit fully into the frame, Crop is taken from middle, preserving as much of the image as possible.', 'lsx-wetu-importer' ); ?><br />
411
+								name="scaling"  value="c" /> <?php esc_html_e('Crop image to fit fully into the frame, Crop is taken from middle, preserving as much of the image as possible.', 'lsx-wetu-importer'); ?><br />
412 412
 								<input type="radio"
413 413
 								<?php
414
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'h' === $options['scaling'] ) {
415
-									echo esc_attr( 'checked="checked"' );
414
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'h' === $options['scaling']) {
415
+									echo esc_attr('checked="checked"');
416 416
 								}
417 417
 								?>
418
-								name="scaling"  value="h" /> <?php esc_html_e( 'Crop image to fit fully into the frame, but resize to height first, then crop on width if needed', 'lsx-wetu-importer' ); ?><br />
418
+								name="scaling"  value="h" /> <?php esc_html_e('Crop image to fit fully into the frame, but resize to height first, then crop on width if needed', 'lsx-wetu-importer'); ?><br />
419 419
 								<input type="radio"
420 420
 								<?php
421
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'w' === $options['scaling'] ) {
422
-									echo esc_attr( 'checked="checked"' );
421
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'w' === $options['scaling']) {
422
+									echo esc_attr('checked="checked"');
423 423
 								}
424 424
 								?>
425
-								name="scaling"  value="w" /> <?php esc_html_e( 'Crop image to fit fully into the frame, but resize to width first, then crop on height if needed', 'lsx-wetu-importer' ); ?><br />
425
+								name="scaling"  value="w" /> <?php esc_html_e('Crop image to fit fully into the frame, but resize to width first, then crop on height if needed', 'lsx-wetu-importer'); ?><br />
426 426
 								<input type="radio"
427 427
 								<?php
428
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'nf' === $options['scaling'] ) {
429
-									echo esc_attr( 'checked="checked"' );
428
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'nf' === $options['scaling']) {
429
+									echo esc_attr('checked="checked"');
430 430
 								}
431 431
 								?>
432
-								name="scaling"  value="nf" /> <?php esc_html_e( 'Resize the image to fit within the frame. but pad the image with white to ensure the resolution matches the frame', 'lsx-wetu-importer' ); ?><br />
432
+								name="scaling"  value="nf" /> <?php esc_html_e('Resize the image to fit within the frame. but pad the image with white to ensure the resolution matches the frame', 'lsx-wetu-importer'); ?><br />
433 433
 								<input type="radio"
434 434
 								<?php
435
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'n' === $options['scaling'] ) {
436
-									echo esc_attr( 'checked="checked"' );
435
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'n' === $options['scaling']) {
436
+									echo esc_attr('checked="checked"');
437 437
 								}
438 438
 								?>
439
-								name="scaling"  value="n" /> <?php esc_html_e( 'Resize the image to fit within the frame. but do not upscale the image.', 'lsx-wetu-importer' ); ?><br />
439
+								name="scaling"  value="n" /> <?php esc_html_e('Resize the image to fit within the frame. but do not upscale the image.', 'lsx-wetu-importer'); ?><br />
440 440
 								<input type="radio"
441 441
 								<?php
442
-								if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'W' === $options['scaling'] ) {
443
-									echo esc_attr( 'checked="checked"' );
442
+								if (isset($options['scaling']) && '' !== $options['scaling'] && 'W' === $options['scaling']) {
443
+									echo esc_attr('checked="checked"');
444 444
 								}
445 445
 								?>
446
-								name="scaling"  value="W" /> <?php esc_html_e( 'Resize the image to fit within the frame. Image will not exceed specified dimensions', 'lsx-wetu-importer' ); ?>
446
+								name="scaling"  value="W" /> <?php esc_html_e('Resize the image to fit within the frame. Image will not exceed specified dimensions', 'lsx-wetu-importer'); ?>
447 447
 							</td>
448 448
 						</tr>
449 449
 					</tbody>
450 450
 				</table>
451 451
 
452
-				<h1><?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?></h1>
452
+				<h1><?php esc_html_e('Sync', 'lsx-wetu-importer'); ?></h1>
453 453
 
454 454
 				<table class="form-table">
455 455
 					<tbody>
456 456
 						<tr class="form-field -wrap">
457 457
 							<th scope="row">
458
-								<label for="cron_schedule"><?php esc_html_e( 'Schedule', 'lsx-wetu-importer' ); ?></label>
458
+								<label for="cron_schedule"><?php esc_html_e('Schedule', 'lsx-wetu-importer'); ?></label>
459 459
 							</th>
460 460
 							<td>
461 461
 								<select name="cron_schedule" id="cron_schedule"	class="widefat layout">
462 462
 									<?php
463
-									if ( isset( $options['cron_schedule'] ) && '' !== $options['cron_schedule'] ) {
463
+									if (isset($options['cron_schedule']) && '' !== $options['cron_schedule']) {
464 464
 										$schedule = $options['cron_schedule'];
465
-									} else {
465
+									}else {
466 466
 										$schedule = 'daily';
467 467
 									}
468 468
 									$timeslots = array(
469
-										'daily'      => __( 'Daily', 'lsx-wetu-importer' ),
470
-										'weekly-mon' => __( 'Weekly (Monday)', 'lsx-wetu-importer' ),
471
-										'weekly-tue' => __( 'Weekly (Tuesday)', 'lsx-wetu-importer' ),
472
-										'weekly-wed' => __( 'Weekly (Wednesday)', 'lsx-wetu-importer' ),
473
-										'weekly-thu' => __( 'Weekly (Thursday)', 'lsx-wetu-importer' ),
474
-										'weekly-fri' => __( 'Weekly (Friday)', 'lsx-wetu-importer' ),
475
-										'weekly-sat' => __( 'Weekly (Saturday)', 'lsx-wetu-importer' ),
476
-										'weekly-sun' => __( 'Weekly (Sunday)', 'lsx-wetu-importer' ),
469
+										'daily'      => __('Daily', 'lsx-wetu-importer'),
470
+										'weekly-mon' => __('Weekly (Monday)', 'lsx-wetu-importer'),
471
+										'weekly-tue' => __('Weekly (Tuesday)', 'lsx-wetu-importer'),
472
+										'weekly-wed' => __('Weekly (Wednesday)', 'lsx-wetu-importer'),
473
+										'weekly-thu' => __('Weekly (Thursday)', 'lsx-wetu-importer'),
474
+										'weekly-fri' => __('Weekly (Friday)', 'lsx-wetu-importer'),
475
+										'weekly-sat' => __('Weekly (Saturday)', 'lsx-wetu-importer'),
476
+										'weekly-sun' => __('Weekly (Sunday)', 'lsx-wetu-importer'),
477 477
 									);
478
-									foreach ( $timeslots as $key => $name ) {
479
-										$selected = ( $schedule == $key ) ? ' selected="selected"' : '';
478
+									foreach ($timeslots as $key => $name) {
479
+										$selected = ($schedule == $key) ? ' selected="selected"' : '';
480 480
 										?>
481
-										<option value="<?php echo wp_kses_post( $key ); ?>" id="<?php echo wp_kses_post( $key ); ?>" <?php echo wp_kses_post( $selected ); ?>><?php echo wp_kses_post( $name ); ?></option>
481
+										<option value="<?php echo wp_kses_post($key); ?>" id="<?php echo wp_kses_post($key); ?>" <?php echo wp_kses_post($selected); ?>><?php echo wp_kses_post($name); ?></option>
482 482
 										<?php
483 483
 									}
484 484
 									?>
@@ -487,38 +487,38 @@  discard block
 block discarded – undo
487 487
 						</tr>
488 488
 						<tr class="form-field -wrap">
489 489
 							<th scope="row">
490
-								<label for="accommodation_images_cron"><?php esc_html_e( 'Accommodation Images', 'lsx-wetu-importer' ); ?></label>
490
+								<label for="accommodation_images_cron"><?php esc_html_e('Accommodation Images', 'lsx-wetu-importer'); ?></label>
491 491
 							</th>
492 492
 							<td>
493 493
 								<input type="checkbox"
494 494
 								<?php
495
-								if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) {
496
-									echo esc_attr( 'checked="checked"' );
495
+								if (isset($options['accommodation_images_cron']) && '' !== $options['accommodation_images_cron']) {
496
+									echo esc_attr('checked="checked"');
497 497
 								}
498 498
 								?>
499 499
 								name="accommodation_images_cron" />
500
-								<p><?php esc_html_e( 'Update the accommodation images accodring to the schedule above.', 'lsx-wetu-importer' ); ?></p>
500
+								<p><?php esc_html_e('Update the accommodation images accodring to the schedule above.', 'lsx-wetu-importer'); ?></p>
501 501
 							</td>
502 502
 						</tr>
503 503
 						<tr class="form-field -wrap">
504 504
 							<th scope="row">
505
-								<label for="accommodation_images_cron_featured"><?php esc_html_e( 'Featured Images', 'lsx-wetu-importer' ); ?></label>
505
+								<label for="accommodation_images_cron_featured"><?php esc_html_e('Featured Images', 'lsx-wetu-importer'); ?></label>
506 506
 							</th>
507 507
 							<td>
508 508
 								<input type="checkbox"
509 509
 								<?php
510
-								if ( isset( $options['accommodation_images_cron_featured'] ) && '' !== $options['accommodation_images_cron_featured'] ) {
511
-									echo esc_attr( 'checked="checked"' );
510
+								if (isset($options['accommodation_images_cron_featured']) && '' !== $options['accommodation_images_cron_featured']) {
511
+									echo esc_attr('checked="checked"');
512 512
 								}
513 513
 								?>
514 514
 								name="accommodation_images_cron_featured" />
515
-								<p><?php esc_html_e( 'Set the featured image when the gallery is created.', 'lsx-wetu-importer' ); ?></p>
515
+								<p><?php esc_html_e('Set the featured image when the gallery is created.', 'lsx-wetu-importer'); ?></p>
516 516
 							</td>
517 517
 						</tr>
518 518
 					</tbody>
519 519
 				</table>
520 520
 
521
-				<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_html_e( 'Save Changes', 'lsx-wetu-importer' ); ?>"></p>
521
+				<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_html_e('Save Changes', 'lsx-wetu-importer'); ?>"></p>
522 522
 			</form>
523 523
 		</div>
524 524
 		<?php
@@ -530,17 +530,17 @@  discard block
 block discarded – undo
530 530
 	 * @return void
531 531
 	 */
532 532
 	public function save_options() {
533
-		if ( ! isset( $_POST['lsx_wetu_importer_save_options'] ) || ! wp_verify_nonce( $_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save' ) ) {
533
+		if (!isset($_POST['lsx_wetu_importer_save_options']) || !wp_verify_nonce($_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save')) {
534 534
 			return;
535 535
 		}
536 536
 		$data_to_save = array();
537
-		foreach ( $this->defaults as $key => $field ) {
538
-			if ( isset( $_POST[ $key ] ) ) {
539
-				$data_to_save[ $key ] = sanitize_text_field( $_POST[ $key ] );
540
-			} else {
541
-				$data_to_save[ $key ] = '';
537
+		foreach ($this->defaults as $key => $field) {
538
+			if (isset($_POST[$key])) {
539
+				$data_to_save[$key] = sanitize_text_field($_POST[$key]);
540
+			}else {
541
+				$data_to_save[$key] = '';
542 542
 			}
543 543
 		}
544
-		update_option( 'lsx_wetu_importer_settings', $data_to_save );
544
+		update_option('lsx_wetu_importer_settings', $data_to_save);
545 545
 	}
546 546
 }
Please login to merge, or discard this patch.