Passed
Push — master ( 36c501...e65b13 )
by Warwick
02:26
created
classes/class-lsx-wetu-importer.php 1 patch
Spacing   +342 added lines, -342 removed lines patch added patch discarded remove patch
@@ -197,34 +197,34 @@  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-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-settings.php';
214
+		require_once LSX_WETU_IMPORTER_PATH.'classes/class-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-settings.php';
219 219
 
220
-		add_action( 'init', array( $this, 'load_class' ) );
220
+		add_action('init', array($this, 'load_class'));
221 221
 
222
-		if ( 'default' !== $this->tab_slug ) {
223
-			add_action( 'wp_ajax_lsx_tour_importer', array( $this, 'process_ajax_search' ) );
224
-			add_action( 'wp_ajax_nopriv_lsx_tour_importer', array( $this, 'process_ajax_search' ) );
222
+		if ('default' !== $this->tab_slug) {
223
+			add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search'));
224
+			add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search'));
225 225
 
226
-			add_action( 'wp_ajax_lsx_import_items', array( $this, 'process_ajax_import' ) );
227
-			add_action( 'wp_ajax_nopriv_lsx_import_items', array( $this, 'process_ajax_import' ) );
226
+			add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import'));
227
+			add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import'));
228 228
 		}
229 229
 	}
230 230
 
@@ -236,22 +236,22 @@  discard block
 block discarded – undo
236 236
 	 * @since 1.0.0
237 237
 	 */
238 238
 	public function load_plugin_textdomain() {
239
-		load_plugin_textdomain( 'lsx-wetu-importer', false, basename( LSX_WETU_IMPORTER_PATH ) . '/languages' );
239
+		load_plugin_textdomain('lsx-wetu-importer', false, basename(LSX_WETU_IMPORTER_PATH).'/languages');
240 240
 	}
241 241
 
242 242
 	/**
243 243
 	 * Sets the variables used throughout the plugin.
244 244
 	 */
245 245
 	public function set_variables() {
246
-		$this->post_types = array( 'accommodation', 'destination', 'tour' );
246
+		$this->post_types = array('accommodation', 'destination', 'tour');
247 247
 		$options = \lsx_wetu_importer\includes\helpers\get_options();
248 248
 
249 249
 		// Set the options.
250
-		if ( ! empty( $options ) ) {
250
+		if (!empty($options)) {
251 251
 			$this->options = $options;
252 252
 
253
-			$temp_options = get_option( '_lsx-to_settings', false );
254
-			if ( false !== $temp_options ) {
253
+			$temp_options = get_option('_lsx-to_settings', false);
254
+			if (false !== $temp_options) {
255 255
 				$this->accommodation_settings = $temp_options['accommodation'];
256 256
 				$this->tour_settings          = $temp_options['tour'];
257 257
 				$this->destination_settings   = $temp_options['destination'];
@@ -259,50 +259,50 @@  discard block
 block discarded – undo
259 259
 
260 260
 			$this->api_key = false;
261 261
 
262
-			if ( ! defined( 'WETU_API_KEY' ) ) {
263
-				if ( isset( $options['api_key'] ) && '' !== $options['api_key'] ) {
262
+			if (!defined('WETU_API_KEY')) {
263
+				if (isset($options['api_key']) && '' !== $options['api_key']) {
264 264
 					$this->api_key = $options['api_key'];
265 265
 				}
266
-			} else {
266
+			}else {
267 267
 				$this->api_key = WETU_API_KEY;
268 268
 			}
269 269
 
270 270
 			// Set the tab slug.
271 271
 			// @codingStandardsIgnoreLine
272
-			if ( isset( $_GET['tab'] ) || isset( $_POST['type'] ) ) {
273
-				if ( isset( $_GET['tab'] ) ) {
274
-					$this->tab_slug = wp_unslash( $_GET['tab'] );
275
-				} else {
276
-					$this->tab_slug = wp_unslash( $_POST['type'] );
272
+			if (isset($_GET['tab']) || isset($_POST['type'])) {
273
+				if (isset($_GET['tab'])) {
274
+					$this->tab_slug = wp_unslash($_GET['tab']);
275
+				}else {
276
+					$this->tab_slug = wp_unslash($_POST['type']);
277 277
 				}
278 278
 
279 279
 				// If any tours were queued.
280
-				$this->queued_imports = get_option( 'lsx_wetu_importer_que', array() );
280
+				$this->queued_imports = get_option('lsx_wetu_importer_que', array());
281 281
 			}
282 282
 
283 283
 			// Set the scaling options.
284
-			if ( isset( $this->options ) && isset( $this->options['image_scaling'] ) ) {
284
+			if (isset($this->options) && isset($this->options['image_scaling'])) {
285 285
 				$this->scale_images = true;
286 286
 
287 287
 				$width = '1024';
288
-				if ( isset( $this->options['width'] ) && '' !== $this->options['width'] ) {
288
+				if (isset($this->options['width']) && '' !== $this->options['width']) {
289 289
 					$width = $this->options['width'];
290 290
 				}
291 291
 
292 292
 				$height = '768';
293
-				if ( isset( $this->options['height'] ) && '' !== $this->options['height'] ) {
293
+				if (isset($this->options['height']) && '' !== $this->options['height']) {
294 294
 					$height = $this->options['height'];
295 295
 				}
296 296
 
297 297
 				$cropping = 'w';
298
-				if ( isset( $this->options['cropping'] ) && '' !== $this->options['cropping'] ) {
298
+				if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
299 299
 					$cropping = $this->options['cropping'];
300 300
 				}
301 301
 
302
-				$this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
302
+				$this->image_scaling_url = 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/';
303 303
 			}
304 304
 
305
-			if ( isset( $this->options ) && isset( $this->options['image_limit'] ) && '' !== $this->options['image_limit'] ) {
305
+			if (isset($this->options) && isset($this->options['image_limit']) && '' !== $this->options['image_limit']) {
306 306
 				$this->image_limit = $this->options['image_limit'];
307 307
 			}
308 308
 		}
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	 * @since 1.0.0
326 326
 	 */
327 327
 	public static function compatible_version() {
328
-		if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
328
+		if (version_compare(PHP_VERSION, '5.6', '<')) {
329 329
 			return false;
330 330
 		}
331 331
 
@@ -339,13 +339,13 @@  discard block
 block discarded – undo
339 339
 	 * @since 1.0.0
340 340
 	 */
341 341
 	public function compatible_version_check() {
342
-		if ( ! self::compatible_version() ) {
343
-			if ( is_plugin_active( plugin_basename( LSX_WETU_IMPORTER_CORE ) ) ) {
344
-				deactivate_plugins( plugin_basename( LSX_WETU_IMPORTER_CORE ) );
345
-				add_action( 'admin_notices', array( $this, 'compatible_version_notice' ) );
342
+		if (!self::compatible_version()) {
343
+			if (is_plugin_active(plugin_basename(LSX_WETU_IMPORTER_CORE))) {
344
+				deactivate_plugins(plugin_basename(LSX_WETU_IMPORTER_CORE));
345
+				add_action('admin_notices', array($this, 'compatible_version_notice'));
346 346
 
347
-				if ( isset( $_GET['activate'] ) ) {
348
-					unset( $_GET['activate'] );
347
+				if (isset($_GET['activate'])) {
348
+					unset($_GET['activate']);
349 349
 				}
350 350
 			}
351 351
 		}
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 	 */
359 359
 	public function compatible_version_notice() {
360 360
 		$class = 'notice notice-error';
361
-		$message = esc_html__( 'LSX Importer for Wetu Plugin requires PHP 5.6 or higher.', 'lsx-wetu-importer' );
362
-		printf( '<div class="%1$s"><p>%2$s</p></div>', esc_html( $class ), esc_html( $message ) );
361
+		$message = esc_html__('LSX Importer for Wetu Plugin requires PHP 5.6 or higher.', 'lsx-wetu-importer');
362
+		printf('<div class="%1$s"><p>%2$s</p></div>', esc_html($class), esc_html($message));
363 363
 	}
364 364
 
365 365
 	/**
@@ -369,9 +369,9 @@  discard block
 block discarded – undo
369 369
 	 * @since 1.0.0
370 370
 	 */
371 371
 	public static function compatible_version_check_on_activation() {
372
-		if ( ! self::compatible_version() ) {
373
-			deactivate_plugins( plugin_basename( LSX_WETU_IMPORTER_CORE ) );
374
-			wp_die( esc_html__( 'LSX Importer for Wetu Plugin requires PHP 5.6 or higher.', 'lsx-wetu-importer' ) );
372
+		if (!self::compatible_version()) {
373
+			deactivate_plugins(plugin_basename(LSX_WETU_IMPORTER_CORE));
374
+			wp_die(esc_html__('LSX Importer for Wetu Plugin requires PHP 5.6 or higher.', 'lsx-wetu-importer'));
375 375
 		}
376 376
 	}
377 377
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 	 * Load the importer class you want to use
382 382
 	 */
383 383
 	public function load_class() {
384
-		switch ( $this->tab_slug ) {
384
+		switch ($this->tab_slug) {
385 385
 			case 'accommodation':
386 386
 				$this->current_importer = new LSX_WETU_Importer_Accommodation();
387 387
 				break;
@@ -408,32 +408,32 @@  discard block
 block discarded – undo
408 408
 	 * Registers the admin page which will house the importer form.
409 409
 	 */
410 410
 	public function register_importer_page() {
411
-		add_submenu_page( 'tour-operator', esc_html__( 'Importer', 'tour-operator' ), esc_html__( 'Importer', 'tour-operator' ), 'manage_options', 'lsx-wetu-importer', array( $this, 'display_page' ) );
411
+		add_submenu_page('tour-operator', esc_html__('Importer', 'tour-operator'), esc_html__('Importer', 'tour-operator'), 'manage_options', 'lsx-wetu-importer', array($this, 'display_page'));
412 412
 	}
413 413
 
414 414
 	/**
415 415
 	 * Enqueue the JS needed to contact wetu and return your result.
416 416
 	 */
417 417
 	public function admin_scripts() {
418
-		if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) {
418
+		if (defined('WP_DEBUG') && true === WP_DEBUG) {
419 419
 			$min = '';
420
-		} else {
420
+		}else {
421 421
 			$min = '.min';
422 422
 		}
423 423
 
424 424
 		$min = '';
425 425
 
426
-		if ( is_admin() && isset( $_GET['page'] ) && $this->plugin_slug === $_GET['page'] ) {
426
+		if (is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']) {
427 427
 
428
-			wp_enqueue_style( 'lsx-wetu-importer-style', LSX_WETU_IMPORTER_URL . 'assets/css/lsx-wetu-importer.css', LSX_WETU_IMPORTER_VER, true );
429
-			wp_enqueue_script( 'lsx-wetu-importers-script', LSX_WETU_IMPORTER_URL . 'assets/js/lsx-wetu-importer' . $min . '.js', array( 'jquery' ), LSX_WETU_IMPORTER_VER, true );
428
+			wp_enqueue_style('lsx-wetu-importer-style', LSX_WETU_IMPORTER_URL.'assets/css/lsx-wetu-importer.css', LSX_WETU_IMPORTER_VER, true);
429
+			wp_enqueue_script('lsx-wetu-importers-script', LSX_WETU_IMPORTER_URL.'assets/js/lsx-wetu-importer'.$min.'.js', array('jquery'), LSX_WETU_IMPORTER_VER, true);
430 430
 
431 431
 			wp_localize_script(
432 432
 				'lsx-wetu-importers-script',
433 433
 				'lsx_tour_importer_params',
434 434
 				array(
435
-					'ajax_url' => admin_url( 'admin-ajax.php' ),
436
-					'ajax_nonce' => wp_create_nonce( 'lsx_wetu_ajax_action' ),
435
+					'ajax_url' => admin_url('admin-ajax.php'),
436
+					'ajax_nonce' => wp_create_nonce('lsx_wetu_ajax_action'),
437 437
 				)
438 438
 			);
439 439
 		}
@@ -446,8 +446,8 @@  discard block
 block discarded – undo
446 446
 		?>
447 447
 		<div class="wrap">
448 448
 			<?php
449
-			$this->navigation( $this->tab_slug );
450
-			if ( 'default' !== $this->tab_slug && 'settings' !== $this->tab_slug ) {
449
+			$this->navigation($this->tab_slug);
450
+			if ('default' !== $this->tab_slug && 'settings' !== $this->tab_slug) {
451 451
 				$this->wetu_status();
452 452
 				$this->post_status_navigation();
453 453
 			}
@@ -465,15 +465,15 @@  discard block
 block discarded – undo
465 465
 	public function post_status_navigation() {
466 466
 		?>
467 467
 		<ul class="subsubsub">
468
-			<li class="searchform"><a class="current" href="#search"><?php esc_attr_e( 'Search', 'lsx-wetu-importer' ); ?></a> | </li>
469
-			<li class="publish"><a href="#publish"><?php esc_attr_e( 'Published', 'lsx-wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( \lsx_wetu_importer\includes\helpers\get_post_count( $this->tab_slug, 'publish ' ) ); ?>)</span></a> | </li>
470
-			<li class="pending"><a href="#pending"><?php esc_attr_e( 'Pending', 'lsx-wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( \lsx_wetu_importer\includes\helpers\get_post_count( $this->tab_slug, 'pending ' ) ); ?>)</span></a>| </li> 
471
-			<li class="draft"><a href="#draft"><?php esc_attr_e( 'Draft', 'lsx-wetu-importer' ); ?></a> <span class="count"> (<?php echo esc_attr( \lsx_wetu_importer\includes\helpers\get_post_count( $this->tab_slug, 'draft ' ) ); ?>)</span></li>
472
-
473
-			<?php if ( 'tour' === $this->tab_slug ) { ?>
474
-				<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_importer\includes\helpers\get_wetu_tour_count() ); ?>)</span></a></li>
475
-			<?php } else if ( ! empty( $this->queued_imports ) ) { ?>
476
-				<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_importer\includes\helpers\get_wetu_queue_count( $this->tab_slug ) ); ?>)</span></a></li>
468
+			<li class="searchform"><a class="current" href="#search"><?php esc_attr_e('Search', 'lsx-wetu-importer'); ?></a> | </li>
469
+			<li class="publish"><a href="#publish"><?php esc_attr_e('Published', 'lsx-wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(\lsx_wetu_importer\includes\helpers\get_post_count($this->tab_slug, 'publish ')); ?>)</span></a> | </li>
470
+			<li class="pending"><a href="#pending"><?php esc_attr_e('Pending', 'lsx-wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(\lsx_wetu_importer\includes\helpers\get_post_count($this->tab_slug, 'pending ')); ?>)</span></a>| </li> 
471
+			<li class="draft"><a href="#draft"><?php esc_attr_e('Draft', 'lsx-wetu-importer'); ?></a> <span class="count"> (<?php echo esc_attr(\lsx_wetu_importer\includes\helpers\get_post_count($this->tab_slug, 'draft ')); ?>)</span></li>
472
+
473
+			<?php if ('tour' === $this->tab_slug) { ?>
474
+				<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_importer\includes\helpers\get_wetu_tour_count()); ?>)</span></a></li>
475
+			<?php }else if (!empty($this->queued_imports)) { ?>
476
+				<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_importer\includes\helpers\get_wetu_queue_count($this->tab_slug)); ?>)</span></a></li>
477 477
 			<?php } ?>
478 478
 		</ul>
479 479
 		<?php
@@ -484,29 +484,29 @@  discard block
 block discarded – undo
484 484
 	 */
485 485
 	public function search_form() {
486 486
 		?>
487
-		<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 ); ?>">
488
-			<input type="hidden" name="page" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
487
+		<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); ?>">
488
+			<input type="hidden" name="page" value="<?php echo esc_attr($this->tab_slug); ?>" />
489 489
 
490
-			<?php do_action( 'lsx_wetu_importer_search_form',$this ); ?>
490
+			<?php do_action('lsx_wetu_importer_search_form', $this); ?>
491 491
 
492 492
 			<div class="normal-search">
493
-				<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' ); ?>" />
493
+				<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'); ?>" />
494 494
 			</div>
495 495
 
496 496
 			<div class="advanced-search hidden" style="display:none;">
497 497
 				<textarea rows="10" cols="40" name="bulk-keywords"></textarea>
498
-				<input class="button button-primary submit" type="submit" value="<?php esc_attr_e( 'Search', 'lsx-wetu-importer' ); ?>" />
498
+				<input class="button button-primary submit" type="submit" value="<?php esc_attr_e('Search', 'lsx-wetu-importer'); ?>" />
499 499
 			</div>
500 500
 
501 501
 			<div class="ajax-loader" style="display:none;width:100%;text-align:center;">
502
-				<img style="width:64px;" src="<?php echo esc_url( LSX_WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" />
502
+				<img style="width:64px;" src="<?php echo esc_url(LSX_WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" />
503 503
 			</div>
504 504
 
505 505
 			<div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
506
-				<img style="width:32px;" src="<?php echo esc_url( LSX_WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" />
506
+				<img style="width:32px;" src="<?php echo esc_url(LSX_WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" />
507 507
 			</div>
508 508
 
509
-			<a class="button advanced-search-toggle" href="#"><?php esc_html_e( 'Bulk Search', 'lsx-wetu-importer' ); ?></a>
509
+			<a class="button advanced-search-toggle" href="#"><?php esc_html_e('Bulk Search', 'lsx-wetu-importer'); ?></a>
510 510
 		</form>
511 511
 		<?php
512 512
 	}
@@ -554,43 +554,43 @@  discard block
 block discarded – undo
554 554
 	 *
555 555
 	 * @param $tab string
556 556
 	 */
557
-	public function navigation( $tab = '' ) {
557
+	public function navigation($tab = '') {
558 558
 		$post_types = array(
559
-			'tour'          => esc_attr( 'Tours', 'lsx-wetu-importer' ),
560
-			'accommodation' => esc_attr( 'Accommodation', 'lsx-wetu-importer' ),
561
-			'destination'   => esc_attr( 'Destinations', 'lsx-wetu-importer' ),
559
+			'tour'          => esc_attr('Tours', 'lsx-wetu-importer'),
560
+			'accommodation' => esc_attr('Accommodation', 'lsx-wetu-importer'),
561
+			'destination'   => esc_attr('Destinations', 'lsx-wetu-importer'),
562 562
 		);
563 563
 
564
-		echo wp_kses_post( '<div class="wp-filter">' );
565
-		echo wp_kses_post( '<ul class="filter-links">' );
566
-		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>' );
564
+		echo wp_kses_post('<div class="wp-filter">');
565
+		echo wp_kses_post('<ul class="filter-links">');
566
+		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>');
567 567
 
568
-		foreach ( $post_types as $post_type => $label ) {
569
-			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>' );
568
+		foreach ($post_types as $post_type => $label) {
569
+			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>');
570 570
 		}
571 571
 
572
-		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>' );
573
-		echo wp_kses_post( '</ul> </div>' );
572
+		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>');
573
+		echo wp_kses_post('</ul> </div>');
574 574
 	}
575 575
 
576 576
 	/**
577 577
 	 * Wetu Status Bar.
578 578
 	 */
579 579
 	public function wetu_status() {
580
-		$tours = get_transient( 'lsx_ti_tours' );
581
-		echo '<div class="wetu-status tour-wetu-status"><h3>' . esc_html__( 'Wetu Status','lsx-wetu-importer' ) . ' - ';
580
+		$tours = get_transient('lsx_ti_tours');
581
+		echo '<div class="wetu-status tour-wetu-status"><h3>'.esc_html__('Wetu Status', 'lsx-wetu-importer').' - ';
582 582
 
583
-		if ( '' === $tours || false === $tours || isset( $_GET['refresh_tours'] ) ) {
583
+		if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) {
584 584
 			$result = $this->update_options();
585 585
 
586
-			if ( true === $result ) {
587
-				echo '<span style="color:green;">' . esc_attr( 'Connected','lsx-wetu-importer' ) . '</span>';
588
-				echo ' - <small><a href="#">' . esc_attr( 'Refresh','lsx-wetu-importer' ) . '</a></small>';
589
-			} else {
590
-				echo '<span style="color:red;">' . wp_kses_post( $result ) . '</span>';
586
+			if (true === $result) {
587
+				echo '<span style="color:green;">'.esc_attr('Connected', 'lsx-wetu-importer').'</span>';
588
+				echo ' - <small><a href="#">'.esc_attr('Refresh', 'lsx-wetu-importer').'</a></small>';
589
+			}else {
590
+				echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
591 591
 			}
592
-		} else {
593
-			echo '<span style="color:green;">' . esc_attr( 'Connected','lsx-wetu-importer' ) . '</span> - <small><a href="#">' . esc_attr( 'Refresh','lsx-wetu-importer' ) . '</a></small>';
592
+		}else {
593
+			echo '<span style="color:green;">'.esc_attr('Connected', 'lsx-wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh', 'lsx-wetu-importer').'</a></small>';
594 594
 		}
595 595
 		echo '</h3>';
596 596
 		echo '</div>';
@@ -599,8 +599,8 @@  discard block
 block discarded – undo
599 599
 	/**
600 600
 	 * Set_taxonomy with some terms
601 601
 	 */
602
-	public function team_member_checkboxes( $selected = array() ) {
603
-		if ( post_type_exists( 'team' ) ) { ?>
602
+	public function team_member_checkboxes($selected = array()) {
603
+		if (post_type_exists('team')) { ?>
604 604
 			<ul>
605 605
 				<?php
606 606
 					$team_args = array(
@@ -610,16 +610,16 @@  discard block
 block discarded – undo
610 610
 						'fields' => 'ids',
611 611
 					);
612 612
 
613
-					$team_members = new WP_Query( $team_args );
613
+					$team_members = new WP_Query($team_args);
614 614
 
615
-					if ( $team_members->have_posts() ) {
616
-						foreach ( $team_members->posts as $member ) {
615
+					if ($team_members->have_posts()) {
616
+						foreach ($team_members->posts as $member) {
617 617
 							?>
618
-							<li><input class="team" <?php $this->checked( $selected, $member ); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title( $member ); ?></li>
618
+							<li><input class="team" <?php $this->checked($selected, $member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
619 619
 							<?php
620 620
 						}
621
-					} else { ?>
622
-						<li><input class="team" type="checkbox" value="0" /> <?php esc_html_e( 'None', 'lsx-wetu-importer' ); ?></li>
621
+					}else { ?>
622
+						<li><input class="team" type="checkbox" value="0" /> <?php esc_html_e('None', 'lsx-wetu-importer'); ?></li>
623 623
 					<?php }
624 624
 				?>
625 625
 			</ul>
@@ -636,13 +636,13 @@  discard block
 block discarded – undo
636 636
 	 * @param $needle string
637 637
 	 * @param $echo bool
638 638
 	 */
639
-	public function checked( $haystack = false, $needle = '', $echo = true ) {
640
-		$return = $this->itemd( $haystack,$needle, 'checked' );
639
+	public function checked($haystack = false, $needle = '', $echo = true) {
640
+		$return = $this->itemd($haystack, $needle, 'checked');
641 641
 
642
-		if ( '' !== $return ) {
643
-			if ( true === $echo ) {
644
-				echo wp_kses_post( $return );
645
-			} else {
642
+		if ('' !== $return) {
643
+			if (true === $echo) {
644
+				echo wp_kses_post($return);
645
+			}else {
646 646
 				return $return;
647 647
 			}
648 648
 		}
@@ -655,13 +655,13 @@  discard block
 block discarded – undo
655 655
 	 * @param $needle string
656 656
 	 * @param $echo bool
657 657
 	 */
658
-	public function selected( $haystack = false, $needle = '', $echo = true ) {
659
-		$return = $this->itemd( $haystack, $needle, 'selected' );
658
+	public function selected($haystack = false, $needle = '', $echo = true) {
659
+		$return = $this->itemd($haystack, $needle, 'selected');
660 660
 
661
-		if ( '' !== $return ) {
662
-			if ( true === $echo ) {
663
-				echo wp_kses_post( $return );
664
-			} else {
661
+		if ('' !== $return) {
662
+			if (true === $echo) {
663
+				echo wp_kses_post($return);
664
+			}else {
665 665
 				return $return;
666 666
 			}
667 667
 		}
@@ -676,17 +676,17 @@  discard block
 block discarded – undo
676 676
 	 * @param $wrap bool
677 677
 	 * @return $html string
678 678
 	 */
679
-	public function itemd( $haystack = false, $needle = '', $type = '', $wrap = true ) {
679
+	public function itemd($haystack = false, $needle = '', $type = '', $wrap = true) {
680 680
 		$html = '';
681 681
 
682
-		if ( '' !== $type ) {
683
-			if ( ! is_array( $haystack ) ) {
684
-				$haystack = array( $haystack );
682
+		if ('' !== $type) {
683
+			if (!is_array($haystack)) {
684
+				$haystack = array($haystack);
685 685
 			}
686
-			if ( in_array( $needle, $haystack ) ) {
687
-				if ( true === $wrap || 'true' === $wrap ) {
688
-					$html = $type . '="' . $type . '"';
689
-				} else {
686
+			if (in_array($needle, $haystack)) {
687
+				if (true === $wrap || 'true' === $wrap) {
688
+					$html = $type.'="'.$type.'"';
689
+				}else {
690 690
 					$html = $type;
691 691
 				}
692 692
 			}
@@ -698,9 +698,9 @@  discard block
 block discarded – undo
698 698
 	/**
699 699
 	 * Grabs any attachments for the current item
700 700
 	 */
701
-	public function find_attachments( $id = false ) {
702
-		if ( false !== $id ) {
703
-			if ( empty( $this->found_attachments ) ) {
701
+	public function find_attachments($id = false) {
702
+		if (false !== $id) {
703
+			if (empty($this->found_attachments)) {
704 704
 				$attachments_args = array(
705 705
 					'post_parent' => $id,
706 706
 					'post_status' => 'inherit',
@@ -710,11 +710,11 @@  discard block
 block discarded – undo
710 710
 					'posts_per_page' => '-1',
711 711
 				);
712 712
 
713
-				$attachments = new WP_Query( $attachments_args );
713
+				$attachments = new WP_Query($attachments_args);
714 714
 
715
-				if ( $attachments->have_posts() ) {
716
-					foreach ( $attachments->posts as $attachment ) {
717
-						$this->found_attachments[ $attachment->ID ] = str_replace( array( '.jpg', '.png', '.jpeg' ), '', $attachment->post_title );
715
+				if ($attachments->have_posts()) {
716
+					foreach ($attachments->posts as $attachment) {
717
+						$this->found_attachments[$attachment->ID] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title);
718 718
 					}
719 719
 				}
720 720
 			}
@@ -726,19 +726,19 @@  discard block
 block discarded – undo
726 726
 	/**
727 727
 	 * Saves the room data
728 728
 	 */
729
-	public function save_custom_field( $value = false, $meta_key, $id, $decrease = false, $unique = true ) {
730
-		if ( false !== $value ) {
731
-			if ( false !== $decrease ) {
732
-				$value = intval( $value );
729
+	public function save_custom_field($value = false, $meta_key, $id, $decrease = false, $unique = true) {
730
+		if (false !== $value) {
731
+			if (false !== $decrease) {
732
+				$value = intval($value);
733 733
 				$value--;
734 734
 			}
735 735
 
736
-			$prev = get_post_meta( $id, $meta_key, true );
736
+			$prev = get_post_meta($id, $meta_key, true);
737 737
 
738
-			if ( false !== $id && '0' !== $id && false !== $prev && true === $unique ) {
739
-				update_post_meta( $id, $meta_key, $value, $prev );
740
-			} else {
741
-				add_post_meta( $id, $meta_key, $value, $unique );
738
+			if (false !== $id && '0' !== $id && false !== $prev && true === $unique) {
739
+				update_post_meta($id, $meta_key, $value, $prev);
740
+			}else {
741
+				add_post_meta($id, $meta_key, $value, $unique);
742 742
 			}
743 743
 		}
744 744
 	}
@@ -747,15 +747,15 @@  discard block
 block discarded – undo
747 747
 	 * Grabs the custom fields,  and resaves an array of unique items.
748 748
 	 */
749 749
 	public function cleanup_posts() {
750
-		if ( ! empty( $this->cleanup_posts ) ) {
750
+		if (!empty($this->cleanup_posts)) {
751 751
 
752
-			foreach ( $this->cleanup_posts as $id => $key ) {
753
-				$prev_items = get_post_meta( $id, $key, false );
754
-				$new_items = array_unique( $prev_items );
755
-				delete_post_meta( $id, $key );
752
+			foreach ($this->cleanup_posts as $id => $key) {
753
+				$prev_items = get_post_meta($id, $key, false);
754
+				$new_items = array_unique($prev_items);
755
+				delete_post_meta($id, $key);
756 756
 
757
-				foreach ( $new_items as $new_item ) {
758
-					add_post_meta( $id, $key, $new_item, false );
757
+				foreach ($new_items as $new_item) {
758
+					add_post_meta($id, $key, $new_item, false);
759 759
 				}
760 760
 			}
761 761
 		}
@@ -766,26 +766,26 @@  discard block
 block discarded – undo
766 766
 	/**
767 767
 	 * Set_taxonomy with some terms
768 768
 	 */
769
-	public function set_taxonomy( $taxonomy, $terms, $id ) {
769
+	public function set_taxonomy($taxonomy, $terms, $id) {
770 770
 		$result = array();
771 771
 
772
-		if ( ! empty( $data ) ) {
773
-			foreach ( $data as $k ) {
774
-				if ( $id ) {
775
-					$term = term_exists( trim( $k ), $tax );
776
-					if ( ! $term ) {
777
-						$term = wp_insert_term( trim( $k ), $tax );
778
-
779
-						if ( is_wp_error( $term ) ) {
780
-							echo wp_kses_post( $term->get_error_message() );
781
-						} else {
782
-							wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true );
772
+		if (!empty($data)) {
773
+			foreach ($data as $k) {
774
+				if ($id) {
775
+					$term = term_exists(trim($k), $tax);
776
+					if (!$term) {
777
+						$term = wp_insert_term(trim($k), $tax);
778
+
779
+						if (is_wp_error($term)) {
780
+							echo wp_kses_post($term->get_error_message());
781
+						}else {
782
+							wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
783 783
 						}
784
-					} else {
785
-						wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true );
784
+					}else {
785
+						wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
786 786
 					}
787
-				} else {
788
-					$result[] = trim( $k );
787
+				}else {
788
+					$result[] = trim($k);
789 789
 				}
790 790
 			}
791 791
 		}
@@ -801,23 +801,23 @@  discard block
 block discarded – undo
801 801
 	 * @param boolean $parent
802 802
 	 * @return void
803 803
 	 */
804
-	public function set_term( $id = false, $name = false, $taxonomy = false, $parent = false ) {
805
-		$term = term_exists( $name, $taxonomy );
806
-		if ( ! $term ) {
807
-			if ( false !== $parent ) {
804
+	public function set_term($id = false, $name = false, $taxonomy = false, $parent = false) {
805
+		$term = term_exists($name, $taxonomy);
806
+		if (!$term) {
807
+			if (false !== $parent) {
808 808
 				$parent = array(
809 809
 					'parent' => $parent,
810 810
 				);
811 811
 			}
812
-			$term = wp_insert_term( trim( $name ), $taxonomy,$parent );
812
+			$term = wp_insert_term(trim($name), $taxonomy, $parent);
813 813
 
814
-			if ( is_wp_error( $term ) ) {
815
-				echo wp_kses_post( $term->get_error_message() );
816
-			} else {
817
-				wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true );
814
+			if (is_wp_error($term)) {
815
+				echo wp_kses_post($term->get_error_message());
816
+			}else {
817
+				wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
818 818
 			}
819
-		} else {
820
-			wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true );
819
+		}else {
820
+			wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
821 821
 		}
822 822
 
823 823
 		return $term['term_id'];
@@ -826,22 +826,22 @@  discard block
 block discarded – undo
826 826
 	/**
827 827
 	 * set_taxonomy with some terms
828 828
 	 */
829
-	public function taxonomy_checkboxes( $taxonomy = false, $selected = array() ) {
829
+	public function taxonomy_checkboxes($taxonomy = false, $selected = array()) {
830 830
 		$return = '';
831 831
 
832
-		if ( false !== $taxonomy ) {
832
+		if (false !== $taxonomy) {
833 833
 			$return .= '<ul>';
834
-			$terms = get_terms( array(
834
+			$terms = get_terms(array(
835 835
 				'taxonomy' => $taxonomy,
836 836
 				'hide_empty' => false,
837
-			) );
837
+			));
838 838
 
839
-			if ( ! is_wp_error( $terms ) ) {
840
-				foreach ( $terms as $term ) {
841
-					$return .= '<li><input class="' . $taxonomy . '" ' . $this->checked( $selected,$term->term_id,false ) . ' type="checkbox" value="' . $term->term_id . '" /> ' . $term->name . '</li>';
839
+			if (!is_wp_error($terms)) {
840
+				foreach ($terms as $term) {
841
+					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected, $term->term_id, false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
842 842
 				}
843
-			} else {
844
-				$return .= '<li><input type="checkbox" value="" /> ' . __( 'None', 'lsx-wetu-importer' ) . '</li>';
843
+			}else {
844
+				$return .= '<li><input type="checkbox" value="" /> '.__('None', 'lsx-wetu-importer').'</li>';
845 845
 			}
846 846
 
847 847
 			$return .= '</ul>';
@@ -855,44 +855,44 @@  discard block
 block discarded – undo
855 855
 	/**
856 856
 	 * Saves the longitude and lattitude, as well as sets the map marker.
857 857
 	 */
858
-	public function set_map_data( $data, $id, $zoom = '10' ) {
858
+	public function set_map_data($data, $id, $zoom = '10') {
859 859
 		$longitude = false;
860 860
 		$latitude = false;
861 861
 		$address = false;
862 862
 
863
-		if ( isset( $data[0]['position'] ) ) {
864
-			if ( isset( $data[0]['position']['driving_latitude'] ) ) {
863
+		if (isset($data[0]['position'])) {
864
+			if (isset($data[0]['position']['driving_latitude'])) {
865 865
 				$latitude = $data[0]['position']['driving_latitude'];
866
-			} elseif ( isset( $data[0]['position']['latitude'] ) ) {
866
+			} elseif (isset($data[0]['position']['latitude'])) {
867 867
 				$latitude = $data[0]['position']['latitude'];
868 868
 			}
869 869
 
870
-			if ( isset( $data[0]['position']['driving_longitude'] ) ) {
870
+			if (isset($data[0]['position']['driving_longitude'])) {
871 871
 				$longitude = $data[0]['position']['driving_longitude'];
872
-			} elseif ( isset( $data[0]['position']['longitude'] ) ) {
872
+			} elseif (isset($data[0]['position']['longitude'])) {
873 873
 				$longitude = $data[0]['position']['longitude'];
874 874
 			}
875 875
 		}
876 876
 
877
-		if ( isset( $data[0]['content'] ) && isset( $data[0]['content']['contact_information'] ) ) {
878
-			if ( isset( $data[0]['content']['contact_information']['address'] ) ) {
879
-				$address = strip_tags( $data[0]['content']['contact_information']['address'] );
880
-				$address = explode( "\n", $address );
877
+		if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) {
878
+			if (isset($data[0]['content']['contact_information']['address'])) {
879
+				$address = strip_tags($data[0]['content']['contact_information']['address']);
880
+				$address = explode("\n", $address);
881 881
 
882
-				foreach ( $address as $bitkey => $bit ) {
883
-					$bit = ltrim( rtrim( $bit ) );
882
+				foreach ($address as $bitkey => $bit) {
883
+					$bit = ltrim(rtrim($bit));
884 884
 
885
-					if ( false === $bit || '' === $bit || null === $bit || empty( $bit ) ) {
886
-						unset( $address[ $bitkey ] );
885
+					if (false === $bit || '' === $bit || null === $bit || empty($bit)) {
886
+						unset($address[$bitkey]);
887 887
 					}
888 888
 				}
889 889
 
890
-				$address = implode( ', ',$address );
891
-				$address = str_replace( ', , ', ', ', $address );
890
+				$address = implode(', ', $address);
891
+				$address = str_replace(', , ', ', ', $address);
892 892
 			}
893 893
 		}
894 894
 
895
-		if ( false !== $longitude ) {
895
+		if (false !== $longitude) {
896 896
 			$location_data = array(
897 897
 				'address'	=> (string) $address,
898 898
 				'lat'		=> (string) $latitude,
@@ -901,11 +901,11 @@  discard block
 block discarded – undo
901 901
 				'elevation'	=> '',
902 902
 			);
903 903
 
904
-			if ( false !== $id && '0' !== $id ) {
905
-				$prev = get_post_meta( $id,'location',true );
906
-				update_post_meta( $id,'location',$location_data,$prev );
907
-			} else {
908
-				add_post_meta( $id,'location',$location_data,true );
904
+			if (false !== $id && '0' !== $id) {
905
+				$prev = get_post_meta($id, 'location', true);
906
+				update_post_meta($id, 'location', $location_data, $prev);
907
+			}else {
908
+				add_post_meta($id, 'location', $location_data, true);
909 909
 			}
910 910
 		}
911 911
 	}
@@ -915,17 +915,17 @@  discard block
 block discarded – undo
915 915
 	/**
916 916
 	 * Creates the main gallery data
917 917
 	 */
918
-	public function set_featured_image( $data, $id ) {
919
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
920
-			$this->featured_image = $this->attach_image( $data[0]['content']['images'][0], $id,  array(
918
+	public function set_featured_image($data, $id) {
919
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
920
+			$this->featured_image = $this->attach_image($data[0]['content']['images'][0], $id, array(
921 921
 				'width' => '800',
922 922
 				'height' => '600',
923 923
 				'cropping' => 'h',
924
-			) );
924
+			));
925 925
 
926
-			if ( false !== $this->featured_image ) {
927
-				delete_post_meta( $id,'_thumbnail_id' );
928
-				add_post_meta( $id,'_thumbnail_id',$this->featured_image,true );
926
+			if (false !== $this->featured_image) {
927
+				delete_post_meta($id, '_thumbnail_id');
928
+				add_post_meta($id, '_thumbnail_id', $this->featured_image, true);
929 929
 			}
930 930
 		}
931 931
 	}
@@ -933,26 +933,26 @@  discard block
 block discarded – undo
933 933
 	/**
934 934
 	 * Sets a banner image
935 935
 	 */
936
-	public function set_banner_image( $data, $id, $content = array( 'none' ) ) {
937
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
938
-			if ( in_array( 'unique_banner_image', $content ) && isset( $data[0]['destination_image'] ) && is_array( $data[0]['destination_image'] ) ) {
939
-				$temp_banner = $this->attach_image( $data[0]['destination_image'], $id, array(
936
+	public function set_banner_image($data, $id, $content = array('none')) {
937
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
938
+			if (in_array('unique_banner_image', $content) && isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) {
939
+				$temp_banner = $this->attach_image($data[0]['destination_image'], $id, array(
940 940
 					'width' => '1920',
941 941
 					'height' => '600',
942 942
 					'cropping' => 'c',
943 943
 				));
944
-			} else {
945
-				$temp_banner = $this->attach_image( $data[0]['content']['images'][1], $id, array(
944
+			}else {
945
+				$temp_banner = $this->attach_image($data[0]['content']['images'][1], $id, array(
946 946
 					'width' => '1920',
947 947
 					'height' => '600',
948 948
 					'cropping' => 'c',
949 949
 				));
950 950
 			}
951 951
 
952
-			if ( false !== $temp_banner ) {
952
+			if (false !== $temp_banner) {
953 953
 				$this->banner_image = $temp_banner;
954 954
 
955
-				delete_post_meta( $id,'image_group' );
955
+				delete_post_meta($id, 'image_group');
956 956
 
957 957
 				$new_banner = array(
958 958
 					'banner_image' => array(
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
 					),
961 961
 				);
962 962
 
963
-				add_post_meta( $id,'image_group',$new_banner,true );
963
+				add_post_meta($id, 'image_group', $new_banner, true);
964 964
 			}
965 965
 		}
966 966
 	}
@@ -968,17 +968,17 @@  discard block
 block discarded – undo
968 968
 	/**
969 969
 	 * Creates the main gallery data
970 970
 	 */
971
-	public function create_main_gallery( $data, $id ) {
972
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
973
-			if ( isset( $this->options['image_replacing'] ) && 'on' === $this->options['image_replacing'] ) {
974
-				$current_gallery = get_post_meta( $id, 'gallery', false );
971
+	public function create_main_gallery($data, $id) {
972
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
973
+			if (isset($this->options['image_replacing']) && 'on' === $this->options['image_replacing']) {
974
+				$current_gallery = get_post_meta($id, 'gallery', false);
975 975
 
976
-				if ( false !== $current_gallery && ! empty( $current_gallery ) ) {
977
-					foreach ( $current_gallery as $g ) {
978
-						delete_post_meta( $id,'gallery', $g );
976
+				if (false !== $current_gallery && !empty($current_gallery)) {
977
+					foreach ($current_gallery as $g) {
978
+						delete_post_meta($id, 'gallery', $g);
979 979
 
980
-						if ( 'attachment' === get_post_type( $g ) ) {
981
-							wp_delete_attachment( $g, true );
980
+						if ('attachment' === get_post_type($g)) {
981
+							wp_delete_attachment($g, true);
982 982
 						}
983 983
 					}
984 984
 				}
@@ -986,32 +986,32 @@  discard block
 block discarded – undo
986 986
 
987 987
 			$counter = 0;
988 988
 
989
-			foreach ( $data[0]['content']['images'] as $image_data ) {
990
-				if ( ( 0 === $counter && false !== $this->featured_image ) || ( 1 === $counter && false !== $this->banner_image ) ) {
989
+			foreach ($data[0]['content']['images'] as $image_data) {
990
+				if ((0 === $counter && false !== $this->featured_image) || (1 === $counter && false !== $this->banner_image)) {
991 991
 					$counter++;
992 992
 
993
-					if ( false !== $this->image_limit && false !== $this->image_limit ) {
993
+					if (false !== $this->image_limit && false !== $this->image_limit) {
994 994
 						$this->image_limit++;
995 995
 					}
996 996
 
997 997
 					continue;
998 998
 				}
999 999
 
1000
-				if ( false !== $this->image_limit && $counter >= $this->image_limit ) {
1000
+				if (false !== $this->image_limit && $counter >= $this->image_limit) {
1001 1001
 					continue;
1002 1002
 				}
1003 1003
 
1004
-				$this->gallery_meta[] = $this->attach_image( $image_data,$id );
1004
+				$this->gallery_meta[] = $this->attach_image($image_data, $id);
1005 1005
 				$counter++;
1006 1006
 			}
1007 1007
 
1008
-			if ( ! empty( $this->gallery_meta ) ) {
1009
-				delete_post_meta( $id,'gallery' );
1010
-				$this->gallery_meta = array_unique( $this->gallery_meta );
1008
+			if (!empty($this->gallery_meta)) {
1009
+				delete_post_meta($id, 'gallery');
1010
+				$this->gallery_meta = array_unique($this->gallery_meta);
1011 1011
 
1012
-				foreach ( $this->gallery_meta as $gallery_id ) {
1013
-					if ( false !== $gallery_id && '' !== $gallery_id && ! is_array( $gallery_id ) ) {
1014
-						add_post_meta( $id,'gallery',$gallery_id,false );
1012
+				foreach ($this->gallery_meta as $gallery_id) {
1013
+					if (false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)) {
1014
+						add_post_meta($id, 'gallery', $gallery_id, false);
1015 1015
 					}
1016 1016
 				}
1017 1017
 			}
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
 	/**
1022 1022
 	 * search_form
1023 1023
 	 */
1024
-	public function get_scaling_url( $args = array() ) {
1024
+	public function get_scaling_url($args = array()) {
1025 1025
 		$defaults = array(
1026 1026
 			'width' => '1024',
1027 1027
 			'height' => '768',
@@ -1029,59 +1029,59 @@  discard block
 block discarded – undo
1029 1029
 			'cropping' => 'h',
1030 1030
 		);
1031 1031
 
1032
-		if ( false !== $this->options ) {
1033
-			if ( isset( $this->options['width'] ) && '' !== $this->options['width'] ) {
1032
+		if (false !== $this->options) {
1033
+			if (isset($this->options['width']) && '' !== $this->options['width']) {
1034 1034
 				$defaults['width'] = $this->options['width'];
1035 1035
 			}
1036 1036
 
1037
-			if ( isset( $this->options['height'] ) && '' !== $this->options['height'] ) {
1037
+			if (isset($this->options['height']) && '' !== $this->options['height']) {
1038 1038
 				$defaults['height'] = $this->options['height'];
1039 1039
 			}
1040 1040
 
1041
-			if ( isset( $this->options['cropping'] ) && '' !== $this->options['cropping'] ) {
1041
+			if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
1042 1042
 				$defaults['cropping'] = $this->options['cropping'];
1043 1043
 			}
1044 1044
 		}
1045 1045
 
1046
-		$args = wp_parse_args( $args, $defaults );
1046
+		$args = wp_parse_args($args, $defaults);
1047 1047
 		$cropping = $args['cropping'];
1048 1048
 		$width = $args['width'];
1049 1049
 		$height = $args['height'];
1050 1050
 
1051
-		return 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
1051
+		return 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/';
1052 1052
 	}
1053 1053
 
1054 1054
 	/**
1055 1055
 	 * Attaches 1 image
1056 1056
 	 */
1057
-	public function attach_image( $v = false, $parent_id, $image_sizes = false, $banner = false ) {
1058
-		if ( false !== $v ) {
1059
-			$temp_fragment = explode( '/',$v['url_fragment'] );
1060
-			$url_filename = $temp_fragment[ count( $temp_fragment ) -1 ];
1061
-			$url_filename = str_replace( array( '.jpg', '.png', '.jpeg' ),'',$url_filename );
1062
-			$url_filename = trim( $url_filename );
1057
+	public function attach_image($v = false, $parent_id, $image_sizes = false, $banner = false) {
1058
+		if (false !== $v) {
1059
+			$temp_fragment = explode('/', $v['url_fragment']);
1060
+			$url_filename = $temp_fragment[count($temp_fragment) - 1];
1061
+			$url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename);
1062
+			$url_filename = trim($url_filename);
1063 1063
 			$title = $url_filename;
1064
-			$url_filename = str_replace( ' ','_',$url_filename );
1064
+			$url_filename = str_replace(' ', '_', $url_filename);
1065 1065
 
1066
-			if ( ! isset( $this->options['image_replacing'] ) && in_array( $url_filename, $this->found_attachments ) ) {
1067
-				return array_search( $url_filename,$this->found_attachments );
1066
+			if (!isset($this->options['image_replacing']) && in_array($url_filename, $this->found_attachments)) {
1067
+				return array_search($url_filename, $this->found_attachments);
1068 1068
 			}
1069 1069
 
1070 1070
 			$postdata = array();
1071 1071
 
1072
-			if ( empty( $v['label'] ) ) {
1072
+			if (empty($v['label'])) {
1073 1073
 				$v['label'] = '';
1074 1074
 			}
1075 1075
 
1076
-			if ( ! empty( $v['description'] ) ) {
1077
-				$desc = wp_strip_all_tags( $v['description'] );
1076
+			if (!empty($v['description'])) {
1077
+				$desc = wp_strip_all_tags($v['description']);
1078 1078
 				$posdata = array(
1079 1079
 					'post_excerpt' => $desc,
1080 1080
 				);
1081 1081
 			}
1082 1082
 
1083
-			if ( ! empty( $v['section'] ) ) {
1084
-				$desc = wp_strip_all_tags( $v['section'] );
1083
+			if (!empty($v['section'])) {
1084
+				$desc = wp_strip_all_tags($v['section']);
1085 1085
 				$posdata = array(
1086 1086
 					'post_excerpt' => $desc,
1087 1087
 				);
@@ -1089,88 +1089,88 @@  discard block
 block discarded – undo
1089 1089
 
1090 1090
 			$attach_id = null;
1091 1091
 			//Resizor - add option to setting if required
1092
-			$fragment = str_replace( ' ','%20',$v['url_fragment'] );
1093
-			$url = $this->get_scaling_url( $image_sizes ) . $fragment;
1092
+			$fragment = str_replace(' ', '%20', $v['url_fragment']);
1093
+			$url = $this->get_scaling_url($image_sizes).$fragment;
1094 1094
 
1095
-			$attach_id = $this->attach_external_image2( $url,$parent_id,'',$v['label'],$postdata );
1095
+			$attach_id = $this->attach_external_image2($url, $parent_id, '', $v['label'], $postdata);
1096 1096
 
1097
-			$this->found_attachments[ $attach_id ] = $url_filename;
1097
+			$this->found_attachments[$attach_id] = $url_filename;
1098 1098
 
1099 1099
 			//echo($attach_id.' add image');
1100
-			if ( ! empty( $attach_id ) ) {
1100
+			if (!empty($attach_id)) {
1101 1101
 				return $attach_id;
1102 1102
 			}
1103 1103
 		}
1104 1104
 		return 	false;
1105 1105
 	}
1106 1106
 
1107
-	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
1108
-		if ( ! $url || ! $post_id ) { return new WP_Error( 'missing', 'Need a valid URL and post ID...' ); }
1107
+	public function attach_external_image2($url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array()) {
1108
+		if (!$url || !$post_id) { return new WP_Error('missing', 'Need a valid URL and post ID...'); }
1109 1109
 
1110
-		require_once( ABSPATH . 'wp-admin/includes/file.php' );
1111
-		require_once( ABSPATH . 'wp-admin/includes/media.php' );
1112
-		require_once( ABSPATH . 'wp-admin/includes/image.php' );
1110
+		require_once(ABSPATH.'wp-admin/includes/file.php');
1111
+		require_once(ABSPATH.'wp-admin/includes/media.php');
1112
+		require_once(ABSPATH.'wp-admin/includes/image.php');
1113 1113
 		// Download file to temp location, returns full server path to temp file
1114 1114
 		//$tmp = download_url( $url );
1115 1115
 
1116 1116
 		//var_dump($tmp);
1117
-		$tmp = tempnam( '/tmp', 'FOO' );
1117
+		$tmp = tempnam('/tmp', 'FOO');
1118 1118
 
1119
-		$image = file_get_contents( $url );
1120
-		file_put_contents( $tmp, $image );
1121
-		chmod( $tmp,'777' );
1119
+		$image = file_get_contents($url);
1120
+		file_put_contents($tmp, $image);
1121
+		chmod($tmp, '777');
1122 1122
 
1123
-		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
1124
-		$url_filename = basename( $matches[0] );
1125
-		$url_filename = str_replace( '%20','_',$url_filename );
1123
+		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
1124
+		$url_filename = basename($matches[0]);
1125
+		$url_filename = str_replace('%20', '_', $url_filename);
1126 1126
 		// extract filename from url for title
1127
-		$url_type = wp_check_filetype( $url_filename );                                           // determine file type (ext and mime/type)
1127
+		$url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type)
1128 1128
 
1129 1129
 		// override filename if given, reconstruct server path
1130
-		if ( ! empty( $filename ) && ' ' != $filename ) {
1131
-			$filename = sanitize_file_name( $filename );
1132
-			$tmppath = pathinfo( $tmp );
1130
+		if (!empty($filename) && ' ' != $filename) {
1131
+			$filename = sanitize_file_name($filename);
1132
+			$tmppath = pathinfo($tmp);
1133 1133
 
1134 1134
 			$extension = '';
1135
-			if ( isset( $tmppath['extension'] ) ) {
1135
+			if (isset($tmppath['extension'])) {
1136 1136
 				$extension = $tmppath['extension'];
1137 1137
 			}
1138 1138
 
1139
-			$new = $tmppath['dirname'] . '/' . $filename . '.' . $extension;
1140
-			rename( $tmp, $new );                                                                 // renames temp file on server
1141
-			$tmp = $new;                                                                        // push new filename (in path) to be used in file array later
1139
+			$new = $tmppath['dirname'].'/'.$filename.'.'.$extension;
1140
+			rename($tmp, $new); // renames temp file on server
1141
+			$tmp = $new; // push new filename (in path) to be used in file array later
1142 1142
 		}
1143 1143
 
1144 1144
 		// assemble file data (should be built like $_FILES since wp_handle_sideload() will be using)
1145
-		$file_array['tmp_name'] = $tmp;                                                         // full server path to temp file
1145
+		$file_array['tmp_name'] = $tmp; // full server path to temp file
1146 1146
 
1147
-		if ( ! empty( $filename ) && ' ' != $filename ) {
1148
-			$file_array['name'] = $filename . '.' . $url_type['ext'];                           // user given filename for title, add original URL extension
1149
-		} else {
1150
-			$file_array['name'] = $url_filename;                                                // just use original URL filename
1147
+		if (!empty($filename) && ' ' != $filename) {
1148
+			$file_array['name'] = $filename.'.'.$url_type['ext']; // user given filename for title, add original URL extension
1149
+		}else {
1150
+			$file_array['name'] = $url_filename; // just use original URL filename
1151 1151
 		}
1152 1152
 
1153 1153
 		// set additional wp_posts columns
1154
-		if ( empty( $post_data['post_title'] ) ) {
1154
+		if (empty($post_data['post_title'])) {
1155 1155
 
1156
-			$url_filename = str_replace( '%20',' ',$url_filename );
1156
+			$url_filename = str_replace('%20', ' ', $url_filename);
1157 1157
 
1158
-			$post_data['post_title'] = basename( $url_filename, '.' . $url_type['ext'] );         // just use the original filename (no extension)
1158
+			$post_data['post_title'] = basename($url_filename, '.'.$url_type['ext']); // just use the original filename (no extension)
1159 1159
 		}
1160 1160
 
1161 1161
 		// make sure gets tied to parent
1162
-		if ( empty( $post_data['post_parent'] ) ) {
1162
+		if (empty($post_data['post_parent'])) {
1163 1163
 			$post_data['post_parent'] = $post_id;
1164 1164
 		}
1165 1165
 
1166 1166
 		// required libraries for media_handle_sideload
1167 1167
 
1168 1168
 		// do the validation and storage stuff
1169
-		$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
1169
+		$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
1170 1170
 
1171 1171
 		// If error storing permanently, unlink
1172
-		if ( is_wp_error( $att_id ) ) {
1173
-			unlink( $file_array['tmp_name'] );   // clean up
1172
+		if (is_wp_error($att_id)) {
1173
+			unlink($file_array['tmp_name']); // clean up
1174 1174
 			return false; // output wp_error
1175 1175
 			//return $att_id; // output wp_error
1176 1176
 		}
@@ -1198,33 +1198,33 @@  discard block
 block discarded – undo
1198 1198
 	/**
1199 1199
 	 * Formats the row for the completed list.
1200 1200
 	 */
1201
-	public function format_completed_row( $response ) {
1202
-		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>' );
1201
+	public function format_completed_row($response) {
1202
+		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>');
1203 1203
 	}
1204 1204
 
1205 1205
 	/**
1206 1206
 	 * Formats the error.
1207 1207
 	 */
1208
-	public function format_error( $response ) {
1209
-		echo wp_kses_post( '<li class="post-error"><span class="dashicons dashicons-no"></span>' . $response . '</li>' );
1208
+	public function format_error($response) {
1209
+		echo wp_kses_post('<li class="post-error"><span class="dashicons dashicons-no"></span>'.$response.'</li>');
1210 1210
 	}
1211 1211
 
1212 1212
 	/**
1213 1213
 	 * Does a multine search
1214 1214
 	 */
1215
-	public function multineedle_stripos( $haystack, $needles, $offset = 0 ) {
1215
+	public function multineedle_stripos($haystack, $needles, $offset = 0) {
1216 1216
 		$found = false;
1217
-		$needle_count = count( $needles );
1217
+		$needle_count = count($needles);
1218 1218
 
1219
-		foreach ( $needles as $needle ) {
1220
-			if ( false !== stripos( $haystack, $needle, $offset ) ) {
1219
+		foreach ($needles as $needle) {
1220
+			if (false !== stripos($haystack, $needle, $offset)) {
1221 1221
 				$found[] = true;
1222 1222
 			}
1223 1223
 		}
1224 1224
 
1225
-		if ( false !== $found && count( $found ) === $needle_count ) {
1225
+		if (false !== $found && count($found) === $needle_count) {
1226 1226
 			return true;
1227
-		} else {
1227
+		}else {
1228 1228
 			return false;
1229 1229
 		}
1230 1230
 	}
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
 	/**
1233 1233
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
1234 1234
 	 */
1235
-	public function find_current_accommodation( $post_type = 'accommodation' ) {
1235
+	public function find_current_accommodation($post_type = 'accommodation') {
1236 1236
 		global $wpdb;
1237 1237
 		$return = array();
1238 1238
 
@@ -1251,9 +1251,9 @@  discard block
 block discarded – undo
1251 1251
 		");
1252 1252
 		// @codingStandardsIgnoreEnd
1253 1253
 
1254
-		if ( null !== $current_accommodation && ! empty( $current_accommodation ) ) {
1255
-			foreach ( $current_accommodation as $accom ) {
1256
-				$return[ $accom->meta_value ] = $accom;
1254
+		if (null !== $current_accommodation && !empty($current_accommodation)) {
1255
+			foreach ($current_accommodation as $accom) {
1256
+				$return[$accom->meta_value] = $accom;
1257 1257
 			}
1258 1258
 		}
1259 1259
 
@@ -1263,20 +1263,20 @@  discard block
 block discarded – undo
1263 1263
 	/**
1264 1264
 	 * Set the Video date
1265 1265
 	 */
1266
-	public function set_video_data( $data, $id ) {
1267
-		if ( ! empty( $data[0]['content']['youtube_videos'] ) && is_array( $data[0]['content']['youtube_videos'] ) ) {
1266
+	public function set_video_data($data, $id) {
1267
+		if (!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])) {
1268 1268
 			$videos = false;
1269 1269
 
1270
-			foreach ( $data[0]['content']['youtube_videos'] as $video ) {
1270
+			foreach ($data[0]['content']['youtube_videos'] as $video) {
1271 1271
 				$temp_video = array();
1272 1272
 
1273
-				if ( isset( $video['label'] ) ) {
1273
+				if (isset($video['label'])) {
1274 1274
 					$temp_video['title'] = $video['label'];
1275 1275
 				}
1276
-				if ( isset( $video['description'] ) ) {
1277
-					$temp_video['description'] = strip_tags( $video['description'] );
1276
+				if (isset($video['description'])) {
1277
+					$temp_video['description'] = strip_tags($video['description']);
1278 1278
 				}
1279
-				if ( isset( $video['url'] ) ) {
1279
+				if (isset($video['url'])) {
1280 1280
 					$temp_video['url'] = $video['url'];
1281 1281
 				}
1282 1282
 
@@ -1284,24 +1284,24 @@  discard block
 block discarded – undo
1284 1284
 				$videos[] = $temp_video;
1285 1285
 			}
1286 1286
 
1287
-			if ( false !== $id && '0' !== $id ) {
1288
-				delete_post_meta( $id, 'videos' );
1287
+			if (false !== $id && '0' !== $id) {
1288
+				delete_post_meta($id, 'videos');
1289 1289
 			}
1290 1290
 
1291
-			foreach ( $videos as $video ) {
1292
-				add_post_meta( $id,'videos',$video,false );
1291
+			foreach ($videos as $video) {
1292
+				add_post_meta($id, 'videos', $video, false);
1293 1293
 			}
1294 1294
 		}
1295 1295
 	}
1296 1296
 
1297
-	public function shuffle_assoc( &$array ) {
1297
+	public function shuffle_assoc(&$array) {
1298 1298
 		$new = array();
1299
-		$keys = array_keys( $array );
1299
+		$keys = array_keys($array);
1300 1300
 
1301
-		shuffle( $keys );
1301
+		shuffle($keys);
1302 1302
 
1303
-		foreach ( $keys as $key ) {
1304
-			$new[ $key ] = $array[ $key ];
1303
+		foreach ($keys as $key) {
1304
+			$new[$key] = $array[$key];
1305 1305
 		}
1306 1306
 
1307 1307
 		$array = $new;
@@ -1315,29 +1315,29 @@  discard block
 block discarded – undo
1315 1315
 	public function update_options() {
1316 1316
 		$own = '';
1317 1317
 		$options = array();
1318
-		delete_option( 'lsx_ti_tours_api_options' );
1318
+		delete_option('lsx_ti_tours_api_options');
1319 1319
 
1320
-		if ( isset( $_GET['own'] ) ) {
1320
+		if (isset($_GET['own'])) {
1321 1321
 			$this->current_importer->url_qs .= '&own=true';
1322 1322
 			$options[] = 'own';
1323 1323
 		}
1324 1324
 
1325
-		if ( isset( $_GET['type'] ) && 'allitineraries' !== $_GET['type'] ) {
1326
-			$this->current_importer->url_qs .= '&type=' . implode( '', $_GET['type'] );
1327
-			$options[] = implode( '', $_GET['type'] );
1325
+		if (isset($_GET['type']) && 'allitineraries' !== $_GET['type']) {
1326
+			$this->current_importer->url_qs .= '&type='.implode('', $_GET['type']);
1327
+			$options[] = implode('', $_GET['type']);
1328 1328
 		}
1329 1329
 
1330 1330
 		$this->current_importer->url_qs .= '&results=2000';
1331 1331
 
1332
-		add_option( 'lsx_ti_tours_api_options', $options );
1332
+		add_option('lsx_ti_tours_api_options', $options);
1333 1333
 
1334
-		$data = wp_remote_get( $this->current_importer->url . '/V8/List?' . $this->current_importer->url_qs );
1335
-		$tours = json_decode( wp_remote_retrieve_body( $data ), true );
1334
+		$data = wp_remote_get($this->current_importer->url.'/V8/List?'.$this->current_importer->url_qs);
1335
+		$tours = json_decode(wp_remote_retrieve_body($data), true);
1336 1336
 
1337
-		if ( isset( $tours['error'] ) ) {
1337
+		if (isset($tours['error'])) {
1338 1338
 			return $tours['error'];
1339
-		} elseif ( isset( $tours['itineraries'] ) && ! empty( $tours['itineraries'] ) ) {
1340
-			set_transient( 'lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2 );
1339
+		} elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
1340
+			set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2);
1341 1341
 			return true;
1342 1342
 		}
1343 1343
 	}
Please login to merge, or discard this patch.
classes/class-lsx-wetu-importer-tours.php 1 patch
Spacing   +388 added lines, -388 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(); ?>
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 					<tbody id="the-list">
135 135
 						<tr class="post-0 type-tour status-none" id="post-0">
136 136
 							<th class="check-column" scope="row">
137
-								<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>
137
+								<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>
138 138
 							</th>
139 139
 							<td class="date column-date column-ref" colspan="4">
140 140
 								<strong>
141
-									<?php esc_html_e( 'Search for tours using the search form above','lsx-wetu-importer' ); ?>
141
+									<?php esc_html_e('Search for tours using the search form above', 'lsx-wetu-importer'); ?>
142 142
 								</strong>
143 143
 							</td>
144 144
 						</tr>
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 
149 149
 				</table>
150 150
 
151
-				<p><input class="button button-primary add" type="button" value="<?php esc_html_e( 'Add to List','lsx-wetu-importer' ); ?>" />
152
-					<input class="button button-primary clear" type="button" value="<?php esc_html_e( 'Clear','lsx-wetu-importer' ); ?>" />
151
+				<p><input class="button button-primary add" type="button" value="<?php esc_html_e('Add to List', 'lsx-wetu-importer'); ?>" />
152
+					<input class="button button-primary clear" type="button" value="<?php esc_html_e('Clear', 'lsx-wetu-importer'); ?>" />
153 153
 				</p>
154 154
 			</form>
155 155
 
@@ -159,51 +159,51 @@  discard block
 block discarded – undo
159 159
 
160 160
 					<div class="row">
161 161
 						<div class="settings-all" style="width:30%;display:block;float:left;">
162
-							<h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3>
162
+							<h3><?php esc_html_e('What content to Sync from WETU'); ?></h3>
163 163
 							<ul>
164
-								<li><input class="content select-all" <?php $this->checked( $this->tour_options,'all' ); ?> type="checkbox"name="content[]"  value="all" /> <?php esc_html_e( 'Select All','lsx-wetu-importer' ); ?></li>
164
+								<li><input class="content select-all" <?php $this->checked($this->tour_options, 'all'); ?> type="checkbox"name="content[]"  value="all" /> <?php esc_html_e('Select All', 'lsx-wetu-importer'); ?></li>
165 165
 
166
-								<?php if ( isset( $this->options ) && ! isset( $this->options['disable_tour_descriptions'] ) ) { ?>
167
-									<li><input class="content" <?php $this->checked( $this->tour_options,'description' ); ?> type="checkbox" name="content[]" value="description" /> <?php esc_html_e( 'Description','lsx-wetu-importer' ); ?></li>
166
+								<?php if (isset($this->options) && !isset($this->options['disable_tour_descriptions'])) { ?>
167
+									<li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li>
168 168
 								<?php } ?>
169 169
 
170
-								<li><input class="content" <?php $this->checked( $this->tour_options,'price' ); ?> type="checkbox" name="content[]" value="price" /> <?php esc_html_e( 'Price','lsx-wetu-importer' ); ?></li>
171
-								<li><input class="content" <?php $this->checked( $this->tour_options,'duration' ); ?> type="checkbox" name="content[]" value="duration" /> <?php esc_html_e( 'Duration','lsx-wetu-importer' ); ?></li>
172
-								<li><input class="content" <?php $this->checked( $this->tour_options,'group_size' ); ?> type="checkbox" name="content[]" value="group_size" /> <?php esc_html_e( 'Group Size','lsx-wetu-importer' ); ?></li>
173
-								<li><input class="content" <?php $this->checked( $this->tour_options,'category' ); ?> type="checkbox" name="content[]" value="category" /> <?php esc_html_e( 'Category','lsx-wetu-importer' ); ?></li>
174
-								<li><input class="content" <?php $this->checked( $this->tour_options,'tags' ); ?> type="checkbox" name="content[]" value="tags" /> <?php esc_html_e( 'Tags','lsx-wetu-importer' ); ?></li>
170
+								<li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php esc_html_e('Price', 'lsx-wetu-importer'); ?></li>
171
+								<li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php esc_html_e('Duration', 'lsx-wetu-importer'); ?></li>
172
+								<li><input class="content" <?php $this->checked($this->tour_options, 'group_size'); ?> type="checkbox" name="content[]" value="group_size" /> <?php esc_html_e('Group Size', 'lsx-wetu-importer'); ?></li>
173
+								<li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php esc_html_e('Category', 'lsx-wetu-importer'); ?></li>
174
+								<li><input class="content" <?php $this->checked($this->tour_options, 'tags'); ?> type="checkbox" name="content[]" value="tags" /> <?php esc_html_e('Tags', 'lsx-wetu-importer'); ?></li>
175 175
 
176
-								<li><input class="content" <?php $this->checked( $this->tour_options,'itineraries' ); ?> type="checkbox" name="content[]" value="itineraries" /> <?php esc_html_e( 'Itinerary Days','lsx-wetu-importer' ); ?></li>
176
+								<li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php esc_html_e('Itinerary Days', 'lsx-wetu-importer'); ?></li>
177 177
 							</ul>
178 178
 						</div>
179 179
 						<div class="settings-all" style="width:30%;display:block;float:left;">
180
-							<h3><?php esc_html_e( 'Itinerary Info' ); ?></h3>
180
+							<h3><?php esc_html_e('Itinerary Info'); ?></h3>
181 181
 							<ul>
182
-								<li><input class="content" <?php $this->checked( $this->tour_options,'itinerary_description' ); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php esc_html_e( 'Description','lsx-wetu-importer' ); ?></li>
183
-								<li><input class="content" <?php $this->checked( $this->tour_options,'itinerary_included' ); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php esc_html_e( 'Included','lsx-wetu-importer' ); ?></li>
184
-								<li><input class="content" <?php $this->checked( $this->tour_options,'itinerary_excluded' ); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php esc_html_e( 'Excluded','lsx-wetu-importer' ); ?></li>
182
+								<li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li>
183
+								<li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php esc_html_e('Included', 'lsx-wetu-importer'); ?></li>
184
+								<li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php esc_html_e('Excluded', 'lsx-wetu-importer'); ?></li>
185 185
 							</ul>
186 186
 
187
-							<h4><?php esc_html_e( 'Additional Content' ); ?></h4>
187
+							<h4><?php esc_html_e('Additional Content'); ?></h4>
188 188
 							<ul>
189
-								<li><input class="content" <?php $this->checked( $this->tour_options,'accommodation' ); ?> type="checkbox" name="content[]" value="accommodation" /> <?php esc_html_e( 'Sync Accommodation','lsx-wetu-importer' ); ?></li>
190
-								<li><input class="content" <?php $this->checked( $this->tour_options,'destination' ); ?> type="checkbox" name="content[]" value="destination" /> <?php esc_html_e( 'Sync Destinations','lsx-wetu-importer' ); ?></li>
191
-								<li><input class="content" <?php $this->checked( $this->tour_options,'featured_image' ); ?> type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e( 'Featured Image','lsx-wetu-importer' ); ?></li>
192
-								<li><input class="content" <?php $this->checked( $this->tour_options,'banner_image' ); ?> type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e( 'Banner Image','lsx-wetu-importer' ); ?></li>
189
+								<li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php esc_html_e('Sync Accommodation', 'lsx-wetu-importer'); ?></li>
190
+								<li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php esc_html_e('Sync Destinations', 'lsx-wetu-importer'); ?></li>
191
+								<li><input class="content" <?php $this->checked($this->tour_options, 'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e('Featured Image', 'lsx-wetu-importer'); ?></li>
192
+								<li><input class="content" <?php $this->checked($this->tour_options, 'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e('Banner Image', 'lsx-wetu-importer'); ?></li>
193 193
 							</ul>
194 194
 						</div>
195
-						<?php if ( class_exists( 'LSX_TO_Team' ) ) { ?>
195
+						<?php if (class_exists('LSX_TO_Team')) { ?>
196 196
 							<div style="width:30%;display:block;float:left;">
197
-								<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3>
198
-								<?php $this->team_member_checkboxes( $this->tour_options ); ?>
197
+								<h3><?php esc_html_e('Assign a Team Member'); ?></h3>
198
+								<?php $this->team_member_checkboxes($this->tour_options); ?>
199 199
 							</div>
200 200
 						<?php } ?>
201 201
 
202 202
 						<br clear="both" />
203 203
 					</div>
204 204
 
205
-					<h3><?php esc_html_e( 'Your List' ); ?></h3>
206
-					<p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync','lsx-wetu-importer' ); ?>" /></p>
205
+					<h3><?php esc_html_e('Your List'); ?></h3>
206
+					<p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>" /></p>
207 207
 					<table class="wp-list-table widefat fixed posts">
208 208
 						<?php $this->table_header(); ?>
209 209
 
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 
216 216
 					</table>
217 217
 
218
-					<p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync','lsx-wetu-importer' ); ?>" /></p>
218
+					<p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>" /></p>
219 219
 				</form>
220 220
 			</div>
221 221
 
222 222
 			<div style="display:none;" class="completed-list-wrapper">
223
-				<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
+				<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>
224 224
 				<ul>
225 225
 				</ul>
226 226
 			</div>
@@ -234,23 +234,23 @@  discard block
 block discarded – undo
234 234
 	 * @return void
235 235
 	 */
236 236
 	public function update_options_form() {
237
-		$form_options = get_option( 'lsx_ti_tours_api_options' );
238
-		if ( false === $form_options ) {
239
-			$form_options = array( 'sample' );
237
+		$form_options = get_option('lsx_ti_tours_api_options');
238
+		if (false === $form_options) {
239
+			$form_options = array('sample');
240 240
 		}
241 241
 		?>
242 242
 		<form method="get" class="tour-refresh-form">
243
-			<input type="hidden" name="page" value="<?php echo esc_attr( $this->plugin_slug ); ?>" />
243
+			<input type="hidden" name="page" value="<?php echo esc_attr($this->plugin_slug); ?>" />
244 244
 			<input type="hidden" name="tab" value="tour" />
245 245
 			<input type="hidden" name="refresh_tours" value="true" />
246 246
 			<input class="content" type="hidden" name="own" value="true" />
247 247
 
248 248
 			<select name="type" id="wpseo-readability-filter">
249
-				<option <?php if ( in_array( 'allitineraries', $form_options ) ) { echo esc_attr( 'selected="selected"' ); } ?> value="allitineraries"><?php esc_html_e( 'All Itineraries','lsx-wetu-importer' ); ?></option>
250
-				<option <?php if ( in_array( 'sample', $form_options ) ) { echo esc_attr( 'selected="selected"' ); } ?>value="bad"><?php esc_html_e( 'Sample','lsx-wetu-importer' ); ?></option>
251
-				<option <?php if ( in_array( 'personal', $form_options ) ) { echo esc_attr( 'selected="selected"' ); } ?>value="ok"><?php esc_html_e( 'Personal','lsx-wetu-importer' ); ?></option>
249
+				<option <?php if (in_array('allitineraries', $form_options)) { echo esc_attr('selected="selected"'); } ?> value="allitineraries"><?php esc_html_e('All Itineraries', 'lsx-wetu-importer'); ?></option>
250
+				<option <?php if (in_array('sample', $form_options)) { echo esc_attr('selected="selected"'); } ?>value="bad"><?php esc_html_e('Sample', 'lsx-wetu-importer'); ?></option>
251
+				<option <?php if (in_array('personal', $form_options)) { echo esc_attr('selected="selected"'); } ?>value="ok"><?php esc_html_e('Personal', 'lsx-wetu-importer'); ?></option>
252 252
 			</select>
253
-			<input class="button submit" type="submit" value="<?php esc_attr_e( 'Refresh', 'lsx-wetu-importer' ); ?>" />
253
+			<input class="button submit" type="submit" value="<?php esc_attr_e('Refresh', 'lsx-wetu-importer'); ?>" />
254 254
 		</form>
255 255
 		<?php
256 256
 	}
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 			LIMIT 0,500
276 276
 		");
277 277
 
278
-		if ( null !== $current_tours && ! empty( $current_tours ) ) {
279
-			foreach ( $current_tours as $tour ) {
280
-				$return[ $tour->meta_value ] = $tour;
278
+		if (null !== $current_tours && !empty($current_tours)) {
279
+			foreach ($current_tours as $tour) {
280
+				$return[$tour->meta_value] = $tour;
281 281
 			}
282 282
 		}
283 283
 
@@ -289,45 +289,45 @@  discard block
 block discarded – undo
289 289
 	 */
290 290
 	public function process_ajax_search() {
291 291
 		$return = false;
292
-		check_ajax_referer( 'lsx_wetu_ajax_action', 'security' );
292
+		check_ajax_referer('lsx_wetu_ajax_action', 'security');
293 293
 
294
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_tour_importer' && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug ) {
295
-			$tours = get_transient( 'lsx_ti_tours' );
294
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) {
295
+			$tours = get_transient('lsx_ti_tours');
296 296
 
297
-			if ( false !== $tours ) {
297
+			if (false !== $tours) {
298 298
 				$searched_items = false;
299
-				if ( isset( $_POST['keyword'] ) ) {
300
-					$keyphrases = wp_unslash( $_POST['keyword'] );
301
-				} else {
302
-					$keyphrases = array( 0 );
299
+				if (isset($_POST['keyword'])) {
300
+					$keyphrases = wp_unslash($_POST['keyword']);
301
+				}else {
302
+					$keyphrases = array(0);
303 303
 				}
304 304
 
305
-				if ( ! is_array( $keyphrases ) ) {
306
-					$keyphrases = array( $keyphrases );
305
+				if (!is_array($keyphrases)) {
306
+					$keyphrases = array($keyphrases);
307 307
 				}
308
-				foreach ( $keyphrases as &$keyword ) {
309
-					$keyword = ltrim( rtrim( $keyword ) );
308
+				foreach ($keyphrases as &$keyword) {
309
+					$keyword = ltrim(rtrim($keyword));
310 310
 				}
311 311
 
312 312
 				$post_status = false;
313
-				if ( in_array( 'publish',$keyphrases ) ) {
313
+				if (in_array('publish', $keyphrases)) {
314 314
 					$post_status = 'publish';
315 315
 				}
316
-				if ( in_array( 'pending',$keyphrases ) ) {
316
+				if (in_array('pending', $keyphrases)) {
317 317
 					$post_status = 'pending';
318 318
 				}
319
-				if ( in_array( 'draft',$keyphrases ) ) {
319
+				if (in_array('draft', $keyphrases)) {
320 320
 					$post_status = 'draft';
321 321
 				}
322
-				if ( in_array( 'import',$keyphrases ) ) {
322
+				if (in_array('import', $keyphrases)) {
323 323
 					$post_status = 'import';
324 324
 				}
325 325
 
326
-				if ( ! empty( $tours ) ) {
326
+				if (!empty($tours)) {
327 327
 					$current_tours = $this->find_current_tours();
328 328
 
329
-					foreach ( $tours as $row_key => $row ) {
330
-						if ( isset( $row['is_disabled'] ) && true === $row['is_disabled'] ) {
329
+					foreach ($tours as $row_key => $row) {
330
+						if (isset($row['is_disabled']) && true === $row['is_disabled']) {
331 331
 							continue;
332 332
 						}
333 333
 
@@ -338,60 +338,60 @@  discard block
 block discarded – undo
338 338
 						//If this is a current tour, add its ID to the row.
339 339
 						$row['post_id'] = 0;
340 340
 
341
-						if ( false !== $current_tours && array_key_exists( $row['identifier'], $current_tours ) ) {
342
-							$row['post_id'] = $current_tours[ $row['identifier'] ]->post_id;
341
+						if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) {
342
+							$row['post_id'] = $current_tours[$row['identifier']]->post_id;
343 343
 						}
344 344
 
345 345
 						//If we are searching for
346
-						if ( false !== $post_status ) {
347
-							if ( 'import' === $post_status ) {
346
+						if (false !== $post_status) {
347
+							if ('import' === $post_status) {
348 348
 
349
-								if ( 0 !== $row['post_id'] ) {
349
+								if (0 !== $row['post_id']) {
350 350
 									continue;
351
-								} else {
352
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
351
+								}else {
352
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
353 353
 								}
354
-							} else {
355
-								if ( 0 === $row['post_id'] ) {
354
+							}else {
355
+								if (0 === $row['post_id']) {
356 356
 									continue;
357
-								} else {
358
-									$current_status = get_post_status( $row['post_id'] );
357
+								}else {
358
+									$current_status = get_post_status($row['post_id']);
359 359
 
360
-									if ( $current_status !== $post_status ) {
360
+									if ($current_status !== $post_status) {
361 361
 										continue;
362 362
 									}
363 363
 								}
364 364
 
365
-								$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
365
+								$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
366 366
 							}
367
-						} else {
367
+						}else {
368 368
 							// Search through each keyword.
369
-							foreach ( $keyphrases as $keyphrase ) {
369
+							foreach ($keyphrases as $keyphrase) {
370 370
 
371 371
 								// Make sure the keyphrase is turned into an array.
372
-								$keywords = explode( ' ',$keyphrase );
373
-								if ( ! is_array( $keywords ) ) {
374
-									$keywords = array( $keywords );
372
+								$keywords = explode(' ', $keyphrase);
373
+								if (!is_array($keywords)) {
374
+									$keywords = array($keywords);
375 375
 								}
376 376
 
377
-								if ( $this->multineedle_stripos( ltrim( rtrim( $row['name'] ) ), $keywords ) !== false ) {
378
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
379
-								} else if ( $this->multineedle_stripos( ltrim( rtrim( $row['reference_number'] ) ), $keywords ) !== false ) {
380
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
381
-								} else if ( $this->multineedle_stripos( ltrim( rtrim( $row['identifier_key'] ) ), $keywords ) !== false ) {
382
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
377
+								if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) {
378
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
379
+								}else if ($this->multineedle_stripos(ltrim(rtrim($row['reference_number'])), $keywords) !== false) {
380
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
381
+								}else if ($this->multineedle_stripos(ltrim(rtrim($row['identifier_key'])), $keywords) !== false) {
382
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
383 383
 								}
384 384
 							}
385 385
 						}
386 386
 					}
387 387
 				}
388 388
 
389
-				if ( false !== $searched_items ) {
390
-					ksort( $searched_items );
391
-					$return = implode( $searched_items );
389
+				if (false !== $searched_items) {
390
+					ksort($searched_items);
391
+					$return = implode($searched_items);
392 392
 				}
393 393
 			}
394
-			print_r( $return );
394
+			print_r($return);
395 395
 			die();
396 396
 		}
397 397
 	}
@@ -399,31 +399,31 @@  discard block
 block discarded – undo
399 399
 	/**
400 400
 	 * Formats the row for output on the screen.
401 401
 	 */
402
-	public function format_row( $row = false ) {
403
-		if ( false !== $row ) {
402
+	public function format_row($row = false) {
403
+		if (false !== $row) {
404 404
 			$status = 'import';
405 405
 
406
-			if ( 0 !== $row['post_id'] ) {
407
-				$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>';
406
+			if (0 !== $row['post_id']) {
407
+				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
408 408
 			}
409 409
 
410 410
 			$row_html = '
411
-			<tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '">
411
+			<tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'">
412 412
 				<th class="check-column" scope="row">
413
-					<label for="cb-select-' . $row['identifier'] . '" class="screen-reader-text">' . $row['name'] . '</label>
414
-					<input type="checkbox" data-identifier="' . $row['identifier'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['identifier'] . '">
413
+					<label for="cb-select-' . $row['identifier'].'" class="screen-reader-text">'.$row['name'].'</label>
414
+					<input type="checkbox" data-identifier="' . $row['identifier'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['identifier'].'">
415 415
 				</th>			
416 416
 				<td class="post-title page-title column-title">
417
-					<strong>' . $row['name'] . '</strong> - ' . $status . '
417
+					<strong>' . $row['name'].'</strong> - '.$status.'
418 418
 				</td>
419 419
 				<td class="date column-date">
420
-					' . $row['reference_number'] . '
420
+					' . $row['reference_number'].'
421 421
 				</td>				
422 422
 				<td class="date column-date">
423
-					<abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified
423
+					<abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
424 424
 				</td>
425 425
 				<td class="ssid column-ssid">
426
-					' . $row['identifier'] . '
426
+					' . $row['identifier'].'
427 427
 				</td>
428 428
 			</tr>';
429 429
 			return $row_html;
@@ -433,45 +433,45 @@  discard block
 block discarded – undo
433 433
 	/**
434 434
 	 * Connect to wetu
435 435
 	 */
436
-	public function process_ajax_import( $force = false ) {
436
+	public function process_ajax_import($force = false) {
437 437
 		$return = false;
438 438
 
439 439
 		// @codingStandardsIgnoreLine
440
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug && isset( $_POST['wetu_id'] ) ) {
440
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) {
441 441
 
442 442
 			// @codingStandardsIgnoreLine
443 443
 			$wetu_id = $_POST['wetu_id'];
444 444
 
445 445
 			// @codingStandardsIgnoreLine
446
-			if ( isset( $_POST['post_id'] ) ) {
446
+			if (isset($_POST['post_id'])) {
447 447
 				// @codingStandardsIgnoreLine
448 448
 				$post_id = $_POST['post_id'];
449
-			} else {
449
+			}else {
450 450
 				$post_id = 0;
451 451
 			}
452 452
 
453
-			delete_option( 'lsx_wetu_importer_tour_settings' );
453
+			delete_option('lsx_wetu_importer_tour_settings');
454 454
 
455 455
 			// @codingStandardsIgnoreLine
456
-			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
456
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
457 457
 				// @codingStandardsIgnoreLine
458 458
 				$content = $_POST['content'];
459
-				add_option( 'lsx_wetu_importer_tour_settings',$content );
460
-			} else {
459
+				add_option('lsx_wetu_importer_tour_settings', $content);
460
+			}else {
461 461
 				$content = false;
462 462
 			}
463
-			$jdata = wp_remote_get( 'https://wetu.com/API/Itinerary/V8/Get?id=' . $wetu_id );
463
+			$jdata = wp_remote_get('https://wetu.com/API/Itinerary/V8/Get?id='.$wetu_id);
464 464
 
465
-			if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
466
-				$jdata = json_decode( $jdata['body'], true );
467
-				$return = $this->import_row( $jdata, $wetu_id, $post_id, $content );
468
-				$this->format_completed_row( $return );
465
+			if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
466
+				$jdata = json_decode($jdata['body'], true);
467
+				$return = $this->import_row($jdata, $wetu_id, $post_id, $content);
468
+				$this->format_completed_row($return);
469 469
 				$this->save_queue();
470 470
 				$this->cleanup_posts();
471
-				$this->attach_destination_images( $content );
472
-				$this->clean_attached_destinations( $return );
473
-			} else {
474
-				$this->format_error( esc_html__( 'There was a problem importing your tour, please contact support.', 'lsx-wetu-importer' ) );
471
+				$this->attach_destination_images($content);
472
+				$this->clean_attached_destinations($return);
473
+			}else {
474
+				$this->format_error(esc_html__('There was a problem importing your tour, please contact support.', 'lsx-wetu-importer'));
475 475
 			}
476 476
 		}
477 477
 	}
@@ -482,13 +482,13 @@  discard block
 block discarded – undo
482 482
 	 * @param $id string
483 483
 	 * @return void
484 484
 	 */
485
-	public function clean_attached_destinations( $id ) {
486
-		$current_connections = get_post_meta( $id, 'destination_to_tour', false );
487
-		delete_post_meta( $id,'destination_to_tour' );
488
-		$current_connections = array_unique( $current_connections );
485
+	public function clean_attached_destinations($id) {
486
+		$current_connections = get_post_meta($id, 'destination_to_tour', false);
487
+		delete_post_meta($id, 'destination_to_tour');
488
+		$current_connections = array_unique($current_connections);
489 489
 
490
-		foreach ( $current_connections as $connection ) {
491
-			add_post_meta( $id, 'destination_to_tour',$connection, false );
490
+		foreach ($current_connections as $connection) {
491
+			add_post_meta($id, 'destination_to_tour', $connection, false);
492 492
 		}
493 493
 	}
494 494
 
@@ -498,12 +498,12 @@  discard block
 block discarded – undo
498 498
 	 * @param $data array
499 499
 	 * @param $wetu_id string
500 500
 	 */
501
-	public function import_row( $data, $wetu_id, $id = 0, $importable_content = array(), $old1 = false, $old2 = false ) {
501
+	public function import_row($data, $wetu_id, $id = 0, $importable_content = array(), $old1 = false, $old2 = false) {
502 502
 		$post_name = '';
503 503
 		$data_post_content = '';
504 504
 		$data_post_excerpt = '';
505 505
 
506
-		$current_post = get_post( $id );
506
+		$current_post = get_post($id);
507 507
 
508 508
 		$post = array(
509 509
 			'post_type' => 'tour',
@@ -511,70 +511,70 @@  discard block
 block discarded – undo
511 511
 
512 512
 		$content_used_general_description = false;
513 513
 
514
-		if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) {
514
+		if (!empty($importable_content) && in_array('description', $importable_content)) {
515 515
 			$data_post_content = $current_post->post_content;
516
-			if ( isset( $data['summary'] ) && ! empty( $data['summary'] ) ) {
516
+			if (isset($data['summary']) && !empty($data['summary'])) {
517 517
 				$data_post_content = $data['summary'];
518 518
 			}
519 519
 			$post['post_content'] = $data_post_content;
520 520
 		}
521 521
 
522 522
 		// Create or update the post.
523
-		if ( false !== $id && '0' !== $id ) {
523
+		if (false !== $id && '0' !== $id) {
524 524
 			$post['ID'] = $id;
525 525
 			$post['post_status'] = 'publish';
526
-			$id = wp_update_post( $post );
527
-			$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
528
-			update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data['last_modified'] ), $prev_date );
526
+			$id = wp_update_post($post);
527
+			$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
528
+			update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']), $prev_date);
529 529
 
530
-		} else {
530
+		}else {
531 531
 			// Set the name.
532
-			if ( isset( $data['name'] ) ) {
533
-				$post_name = wp_unique_post_slug( sanitize_title( $data['name'] ), $id, 'draft', 'tour', 0 );
532
+			if (isset($data['name'])) {
533
+				$post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0);
534 534
 			}
535 535
 
536
-			if ( ! isset( $post['post_content'] ) ) {
536
+			if (!isset($post['post_content'])) {
537 537
 				$post['post_content'] = ' ';
538 538
 			}
539 539
 
540 540
 			$post['post_name']   = $post_name;
541 541
 			$post['post_title']  = $data['name'];
542 542
 			$post['post_status'] = 'publish';
543
-			$id = wp_insert_post( $post );
543
+			$id = wp_insert_post($post);
544 544
 
545 545
 			// Save the WETU ID and the Last date it was modified.
546
-			if ( false !== $id ) {
547
-				add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
548
-				add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data['last_modified'] ) );
546
+			if (false !== $id) {
547
+				add_post_meta($id, 'lsx_wetu_id', $wetu_id);
548
+				add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']));
549 549
 			}
550 550
 		}
551 551
 
552 552
 		// Set the price.
553
-		if ( false !== $importable_content && in_array( 'price', $importable_content ) ) {
554
-			$this->set_price( $data, $id );
553
+		if (false !== $importable_content && in_array('price', $importable_content)) {
554
+			$this->set_price($data, $id);
555 555
 		}
556 556
 
557 557
 		// Set the Duration.
558
-		if ( false !== $importable_content && in_array( 'duration', $importable_content ) ) {
559
-			$this->set_duration( $data, $id );
558
+		if (false !== $importable_content && in_array('duration', $importable_content)) {
559
+			$this->set_duration($data, $id);
560 560
 		}
561 561
 
562 562
 		// Set the Group Size.
563
-		if ( false !== $importable_content && in_array( 'group_size', $importable_content ) ) {
564
-			$this->set_group_size( $data, $id );
563
+		if (false !== $importable_content && in_array('group_size', $importable_content)) {
564
+			$this->set_group_size($data, $id);
565 565
 		}
566 566
 
567 567
 		// Set the Group Size.
568
-		if ( false !== $importable_content && in_array( 'tags', $importable_content ) ) {
569
-			$this->set_travel_styles( $id, $data );
568
+		if (false !== $importable_content && in_array('tags', $importable_content)) {
569
+			$this->set_travel_styles($id, $data);
570 570
 		}
571 571
 
572
-		if ( false !== $importable_content && in_array( 'itineraries', $importable_content ) && isset( $data['legs'] ) && ! empty( $data['legs'] ) ) {
573
-			$this->process_itineraries( $data, $id, $importable_content );
572
+		if (false !== $importable_content && in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) {
573
+			$this->process_itineraries($data, $id, $importable_content);
574 574
 		}
575 575
 
576
-		if ( in_array( 'map', $importable_content ) && isset( $data['routes'] ) && ! empty( $data['routes'] ) ) {
577
-			$this->set_map_data( $data, $id );
576
+		if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) {
577
+			$this->set_map_data($data, $id);
578 578
 		}
579 579
 
580 580
 		return $id;
@@ -583,195 +583,195 @@  discard block
 block discarded – undo
583 583
 	/**
584 584
 	 * A loop which runs through each leg on the tour.
585 585
 	 */
586
-	public function process_itineraries( $data, $id, $importable_content ) {
586
+	public function process_itineraries($data, $id, $importable_content) {
587 587
 		$day_counter = 1;
588 588
 		$leg_counter = 0;
589 589
 
590
-		delete_post_meta( $id, 'itinerary' );
590
+		delete_post_meta($id, 'itinerary');
591 591
 
592
-		if ( false !== $importable_content && in_array( 'accommodation', $importable_content ) ) {
593
-			delete_post_meta( $id, 'accommodation_to_tour' );
592
+		if (false !== $importable_content && in_array('accommodation', $importable_content)) {
593
+			delete_post_meta($id, 'accommodation_to_tour');
594 594
 		}
595
-		if ( false !== $importable_content && in_array( 'destination', $importable_content ) ) {
596
-			delete_post_meta( $id, 'departs_from' );
597
-			delete_post_meta( $id, 'ends_in' );
595
+		if (false !== $importable_content && in_array('destination', $importable_content)) {
596
+			delete_post_meta($id, 'departs_from');
597
+			delete_post_meta($id, 'ends_in');
598 598
 		}
599 599
 
600 600
 		$departs_from = false;
601 601
 		$ends_in = false;
602 602
 
603
-		foreach ( $data['legs'] as $leg ) {
603
+		foreach ($data['legs'] as $leg) {
604 604
 			// Itinerary Accommodation.
605 605
 			$current_accommodation = false;
606
-			if ( false !== $importable_content && in_array( 'accommodation', $importable_content ) ) {
607
-				$current_accommodation = $this->set_accommodation( $leg, $id );
606
+			if (false !== $importable_content && in_array('accommodation', $importable_content)) {
607
+				$current_accommodation = $this->set_accommodation($leg, $id);
608 608
 			}
609 609
 
610 610
 			// Itinerary Destination.
611 611
 			$current_destination = false;
612
-			if ( false !== $importable_content && in_array( 'destination', $importable_content ) ) {
613
-				$current_destination = $this->set_destination( $leg, $id, $leg_counter );
612
+			if (false !== $importable_content && in_array('destination', $importable_content)) {
613
+				$current_destination = $this->set_destination($leg, $id, $leg_counter);
614 614
 			}
615 615
 
616 616
 			// If the Nights are the same mount of days in the array,  then it isnt "By Destination".
617
-			if ( ( (1 <= (int) $leg['nights'] && isset( $leg['periods'] ) ) ) || 0 === $leg['itinerary_leg_id'] ) {
618
-				foreach ( $leg['periods'] as $day ) {
617
+			if (((1 <= (int) $leg['nights'] && isset($leg['periods']))) || 0 === $leg['itinerary_leg_id']) {
618
+				foreach ($leg['periods'] as $day) {
619 619
 					$current_day = array();
620
-					$current_day['title'] = esc_attr( 'Day ', 'lsx-wetu-importer' ) . $day_counter;
620
+					$current_day['title'] = esc_attr('Day ', 'lsx-wetu-importer').$day_counter;
621 621
 
622 622
 					//print_r('<pre>');print_r($day['notes']);print_r('</pre>');
623 623
 
624 624
 					// Description.
625
-					if ( false !== $importable_content && in_array( 'itinerary_description', $importable_content ) && isset( $day['notes'] ) ) {
625
+					if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) {
626 626
 						$current_day['description'] = $day['notes'];
627
-					} else {
627
+					}else {
628 628
 						$current_day['description'] = '';
629 629
 					}
630 630
 
631 631
 					// Itinerary Gallery.
632
-					if ( false !== $importable_content && in_array( 'itinerary_gallery', $importable_content ) && isset( $day['images'] ) ) {
632
+					if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) {
633 633
 						$current_day['featured_image'] = '';
634
-					} else {
634
+					}else {
635 635
 						$current_day['featured_image'] = '';
636 636
 					}
637 637
 
638 638
 					// Accommodation.
639
-					if ( false !== $current_accommodation ) {
640
-						$current_day['accommodation_to_tour'] = array( $current_accommodation );
641
-					} else {
639
+					if (false !== $current_accommodation) {
640
+						$current_day['accommodation_to_tour'] = array($current_accommodation);
641
+					}else {
642 642
 						$current_day['accommodation_to_tour'] = array();
643 643
 					}
644 644
 
645 645
 					// Destination.
646
-					if ( false !== $current_destination ) {
647
-						$current_day['destination_to_tour'] = array( $current_destination );
648
-					} else {
646
+					if (false !== $current_destination) {
647
+						$current_day['destination_to_tour'] = array($current_destination);
648
+					}else {
649 649
 						$current_day['destination_to_tour'] = array();
650 650
 					}
651 651
 
652 652
 					// Included.
653
-					if ( false !== $importable_content && in_array( 'itinerary_included', $importable_content ) && isset( $day['included'] ) && '' !== $day['included'] ) {
653
+					if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) {
654 654
 						$current_day['included'] = $day['included'];
655
-					} else {
655
+					}else {
656 656
 						$current_day['included'] = '';
657 657
 					}
658 658
 
659 659
 					// Excluded.
660
-					if ( false !== $importable_content && in_array( 'itinerary_excluded', $importable_content ) && isset( $day['excluded'] ) && '' !== $day['excluded'] ) {
660
+					if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) {
661 661
 						$current_day['excluded'] = $day['excluded'];
662
-					} else {
662
+					}else {
663 663
 						$current_day['excluded'] = '';
664 664
 					}
665 665
 
666
-					$this->set_itinerary_day( $current_day,$id );
666
+					$this->set_itinerary_day($current_day, $id);
667 667
 					$day_counter++;
668 668
 				}
669
-			} else {
669
+			}else {
670 670
 				// This is for the by destination.
671 671
 
672 672
 				$current_day = array();
673 673
 				$next_day_count = $day_counter + (int) $leg['nights'];
674 674
 				$day_count_label = $next_day_count - 1;
675 675
 
676
-				$current_day['title'] = esc_attr( 'Day ', 'lsx-wetu-importer' ) . $day_counter;
676
+				$current_day['title'] = esc_attr('Day ', 'lsx-wetu-importer').$day_counter;
677 677
 
678
-				if ( 0 !== (int) $leg['nights'] ) {
679
-					$current_day['title'] .= ' - ' . $day_count_label;
678
+				if (0 !== (int) $leg['nights']) {
679
+					$current_day['title'] .= ' - '.$day_count_label;
680 680
 				}
681 681
 
682 682
 				// Description.
683
-				if ( false !== $importable_content && in_array( 'itinerary_description', $importable_content ) && isset( $leg['notes'] ) ) {
683
+				if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($leg['notes'])) {
684 684
 					$current_day['description'] = $leg['notes'];
685
-				} else {
685
+				}else {
686 686
 					$current_day['description'] = '';
687 687
 				}
688 688
 
689 689
 				// Itinerary Gallery.
690
-				if ( false !== $importable_content && in_array( 'itinerary_gallery', $importable_content ) && isset( $leg['images'] ) ) {
690
+				if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($leg['images'])) {
691 691
 					$current_day['featured_image'] = '';
692
-				} else {
692
+				}else {
693 693
 					$current_day['featured_image'] = '';
694 694
 				}
695 695
 
696 696
 				// Accommodation.
697
-				if ( false !== $current_accommodation ) {
698
-					$current_day['accommodation_to_tour'] = array( $current_accommodation );
699
-				} else {
697
+				if (false !== $current_accommodation) {
698
+					$current_day['accommodation_to_tour'] = array($current_accommodation);
699
+				}else {
700 700
 					$current_day['accommodation_to_tour'] = array();
701 701
 				}
702 702
 
703 703
 				// Destination.
704
-				if ( false !== $current_destination ) {
705
-					$current_day['destination_to_tour'] = array( $current_destination );
706
-				} else {
704
+				if (false !== $current_destination) {
705
+					$current_day['destination_to_tour'] = array($current_destination);
706
+				}else {
707 707
 					$current_day['destination_to_tour'] = array();
708 708
 				}
709 709
 
710 710
 				//Included
711
-				if ( false !== $importable_content && in_array( 'itinerary_included', $importable_content ) && isset( $leg['included'] ) && '' !== $leg['included'] ) {
711
+				if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($leg['included']) && '' !== $leg['included']) {
712 712
 					$current_day['included'] = $leg['included'];
713
-				} else {
713
+				}else {
714 714
 					$current_day['included'] = '';
715 715
 				}
716 716
 
717 717
 				//Excluded
718
-				if ( false !== $importable_content && in_array( 'itinerary_excluded', $importable_content ) && isset( $leg['excluded'] ) && '' !== $leg['excluded'] ) {
718
+				if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($leg['excluded']) && '' !== $leg['excluded']) {
719 719
 					$current_day['excluded'] = $leg['excluded'];
720
-				} else {
720
+				}else {
721 721
 					$current_day['excluded'] = '';
722 722
 				}
723 723
 
724
-				$this->set_itinerary_day( $current_day,$id );
724
+				$this->set_itinerary_day($current_day, $id);
725 725
 				$day_counter = $next_day_count;
726 726
 			}
727 727
 
728 728
 			// If we are in the first leg,  and the destination was attached then save it as the departure field.
729
-			if ( 0 === $leg_counter && false !== $current_destination ) {
729
+			if (0 === $leg_counter && false !== $current_destination) {
730 730
 				$departs_from = $current_destination;
731 731
 			}
732 732
 
733 733
 			// If its the last leg then save it as the ends in.
734
-			if ( $leg_counter === (count( $data['legs'] ) -2) && false !== $current_destination ) {
734
+			if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) {
735 735
 				$ends_in = $current_destination;
736 736
 			}
737 737
 
738 738
 			$leg_counter++;
739 739
 		}
740 740
 
741
-		if ( false !== $departs_from ) {
742
-			add_post_meta( $id, 'departs_from', $departs_from, true );
741
+		if (false !== $departs_from) {
742
+			add_post_meta($id, 'departs_from', $departs_from, true);
743 743
 		}
744
-		if ( false !== $ends_in ) {
745
-			add_post_meta( $id, 'ends_in', $ends_in, true );
744
+		if (false !== $ends_in) {
745
+			add_post_meta($id, 'ends_in', $ends_in, true);
746 746
 		}
747 747
 	}
748 748
 
749 749
 	/**
750 750
 	 * Run through your routes and save the points as a KML file.
751 751
 	 */
752
-	public function set_map_data( $data, $id, $zoom = 9 ) {
753
-		if ( ! empty( $data['routes'] ) ) {
754
-			delete_post_meta( $id,'wetu_map_points' );
752
+	public function set_map_data($data, $id, $zoom = 9) {
753
+		if (!empty($data['routes'])) {
754
+			delete_post_meta($id, 'wetu_map_points');
755 755
 
756 756
 			$points = array();
757 757
 
758
-			foreach ( $data['routes'] as $route ) {
758
+			foreach ($data['routes'] as $route) {
759 759
 
760
-				if ( isset( $route['points'] ) && '' !== $route['points'] ) {
760
+				if (isset($route['points']) && '' !== $route['points']) {
761 761
 
762
-					$temp_points = explode( ';',$route['points'] );
763
-					$point_counter = count( $temp_points );
762
+					$temp_points = explode(';', $route['points']);
763
+					$point_counter = count($temp_points);
764 764
 
765
-					for ( $x = 0; $x <= $point_counter; $x++ ) {
765
+					for ($x = 0; $x <= $point_counter; $x++) {
766 766
 						$y = $x + 1;
767
-						$points[] = $temp_points[ $x ] . ',' . $temp_points[ $y ];
767
+						$points[] = $temp_points[$x].','.$temp_points[$y];
768 768
 						$x++;
769 769
 					}
770 770
 				}
771 771
 			}
772 772
 
773
-			if ( ! empty( $points ) ) {
774
-				$this->save_custom_field( implode( ' ',$points ),'wetu_map_points',$id,false,true );
773
+			if (!empty($points)) {
774
+				$this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true);
775 775
 			}
776 776
 		}
777 777
 
@@ -782,49 +782,49 @@  discard block
 block discarded – undo
782 782
 	/**
783 783
 	 * Set the Itinerary Day
784 784
 	 */
785
-	public function set_itinerary_day( $day, $id ) {
786
-		$this->save_custom_field( $day,'itinerary',$id,false,false );
785
+	public function set_itinerary_day($day, $id) {
786
+		$this->save_custom_field($day, 'itinerary', $id, false, false);
787 787
 	}
788 788
 
789 789
 	/**
790 790
 	 * Set the price
791 791
 	 */
792
-	public function set_price( $data, $id ) {
792
+	public function set_price($data, $id) {
793 793
 		//Price
794
-		if ( isset( $data['price'] ) && '' !== $data['price'] ) {
795
-			$price = preg_replace( '/[^0-9,.]/', '', $data['price'] );
796
-			$this->save_custom_field( $price,'price',$id );
794
+		if (isset($data['price']) && '' !== $data['price']) {
795
+			$price = preg_replace('/[^0-9,.]/', '', $data['price']);
796
+			$this->save_custom_field($price, 'price', $id);
797 797
 		}
798 798
 
799 799
 		//Price includes
800
-		if ( isset( $data['price_includes'] ) && '' !== $data['price_includes'] ) {
801
-			$this->save_custom_field( $data['price_includes'],'included',$id );
800
+		if (isset($data['price_includes']) && '' !== $data['price_includes']) {
801
+			$this->save_custom_field($data['price_includes'], 'included', $id);
802 802
 		}
803 803
 
804 804
 		//Price Excludes
805
-		if ( isset( $data['price_excludes'] ) && '' !== $data['price_excludes'] ) {
806
-			$this->save_custom_field( $data['price_excludes'],'not_included',$id );
805
+		if (isset($data['price_excludes']) && '' !== $data['price_excludes']) {
806
+			$this->save_custom_field($data['price_excludes'], 'not_included', $id);
807 807
 		}
808 808
 	}
809 809
 
810 810
 	/**
811 811
 	 * Set the duration
812 812
 	 */
813
-	public function set_duration( $data, $id ) {
814
-		if ( isset( $data['days'] ) && ! empty( $data['days'] ) ) {
813
+	public function set_duration($data, $id) {
814
+		if (isset($data['days']) && !empty($data['days'])) {
815 815
 			$price = $data['days'];
816
-			$price = preg_replace( '/[^0-9,.]/', '', $price );
817
-			$this->save_custom_field( $price,'duration',$id );
816
+			$price = preg_replace('/[^0-9,.]/', '', $price);
817
+			$this->save_custom_field($price, 'duration', $id);
818 818
 		}
819 819
 	}
820 820
 
821 821
 	/**
822 822
 	 * Set the group size
823 823
 	 */
824
-	public function set_group_size( $data, $id ) {
825
-		if ( isset( $data['group_size'] ) && ! empty( $data['group_size'] ) ) {
824
+	public function set_group_size($data, $id) {
825
+		if (isset($data['group_size']) && !empty($data['group_size'])) {
826 826
 			$group_size = $data['group_size'];
827
-			$this->save_custom_field( $group_size,'group_size',$id );
827
+			$this->save_custom_field($group_size, 'group_size', $id);
828 828
 		}
829 829
 	}
830 830
 
@@ -835,10 +835,10 @@  discard block
 block discarded – undo
835 835
 	 * @param array $travel_styles
836 836
 	 * @return void
837 837
 	 */
838
-	public function set_travel_styles( $id, $data ) {
839
-		if ( isset( $data['tags'] ) ) {
840
-			foreach ( $data['tags'] as $tag ) {
841
-				$this->set_term( $id, $tag, 'travel-style' );
838
+	public function set_travel_styles($id, $data) {
839
+		if (isset($data['tags'])) {
840
+			foreach ($data['tags'] as $tag) {
841
+				$this->set_term($id, $tag, 'travel-style');
842 842
 			}
843 843
 		}
844 844
 	}
@@ -846,27 +846,27 @@  discard block
 block discarded – undo
846 846
 	/**
847 847
 	 * Connects the Accommodation if its available
848 848
 	 */
849
-	public function set_accommodation( $day, $id ) {
849
+	public function set_accommodation($day, $id) {
850 850
 		$ac_id = false;
851 851
 		$this->current_accommodation = $this->find_current_accommodation();
852 852
 
853
-		if ( isset( $day['content_entity_id'] ) && ! empty( $day['content_entity_id'] ) ) {
854
-			if ( false !== $this->current_accommodation && ! empty( $this->current_accommodation ) && array_key_exists( $day['content_entity_id'],$this->current_accommodation ) ) {
855
-				$ac_id = $this->current_accommodation[ $day['content_entity_id'] ];
856
-			} else {
853
+		if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) {
854
+			if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) {
855
+				$ac_id = $this->current_accommodation[$day['content_entity_id']];
856
+			}else {
857 857
 				$ac_id = wp_insert_post(array(
858 858
 					'post_type' => 'accommodation',
859 859
 					'post_status' => 'draft',
860 860
 					'post_title' => $day['content_entity_id'],
861 861
 				));
862 862
 
863
-				$this->save_custom_field( $day['content_entity_id'],'lsx_wetu_id',$ac_id );
863
+				$this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id);
864 864
 			}
865 865
 
866
-			if ( '' !== $ac_id && false !== $ac_id ) {
867
-				$this->save_custom_field( $ac_id,'accommodation_to_tour',$id,false,false );
868
-				$this->save_custom_field( $id,'tour_to_accommodation',$ac_id,false,false );
869
-				$this->queue_item( $ac_id );
866
+			if ('' !== $ac_id && false !== $ac_id) {
867
+				$this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false);
868
+				$this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false);
869
+				$this->queue_item($ac_id);
870 870
 			}
871 871
 		}
872 872
 		return $ac_id;
@@ -878,14 +878,14 @@  discard block
 block discarded – undo
878 878
 	 * @param $post_type string
879 879
 	 * @return boolean / array
880 880
 	 */
881
-	public function find_current_accommodation( $post_type = 'accommodation' ) {
881
+	public function find_current_accommodation($post_type = 'accommodation') {
882 882
 		global $wpdb;
883
-		$accommodation = parent::find_current_accommodation( $post_type );
883
+		$accommodation = parent::find_current_accommodation($post_type);
884 884
 		$return = false;
885 885
 
886
-		if ( ! empty( $accommodation ) ) {
887
-			foreach ( $accommodation as $key => $acc ) {
888
-				$return[ $acc->meta_value ] = $acc->post_id;
886
+		if (!empty($accommodation)) {
887
+			foreach ($accommodation as $key => $acc) {
888
+				$return[$acc->meta_value] = $acc->post_id;
889 889
 			}
890 890
 		}
891 891
 
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 	 * @return boolean / array
898 898
 	 */
899 899
 	public function find_current_destinations() {
900
-		return $this->find_current_accommodation( 'destination' );
900
+		return $this->find_current_accommodation('destination');
901 901
 	}
902 902
 
903 903
 	/**
@@ -907,44 +907,44 @@  discard block
 block discarded – undo
907 907
 	 * @param $id string
908 908
 	 * @return boolean / string
909 909
 	 */
910
-	public function set_destination( $day, $id, $leg_counter ) {
910
+	public function set_destination($day, $id, $leg_counter) {
911 911
 		$dest_id    = false;
912 912
 		$country_id = false;
913 913
 
914 914
 		$this->current_destinations = $this->find_current_destinations();
915 915
 
916
-		if ( isset( $day['destination_content_entity_id'] ) && ! empty( $day['destination_content_entity_id'] ) ) {
917
-			if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $day['destination_content_entity_id'], $this->current_destinations ) ) {
918
-				$dest_id = $this->current_destinations[ $day['destination_content_entity_id'] ];
916
+		if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) {
917
+			if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) {
918
+				$dest_id = $this->current_destinations[$day['destination_content_entity_id']];
919 919
 
920 920
 				//TODO Check for attachments here.
921
-				$this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] );
921
+				$this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']);
922 922
 
923 923
 				//Check if there is a country asigned.
924
-				$potential_id = wp_get_post_parent_id( $dest_id );
925
-				$country_wetu_id = get_post_meta( $potential_id, 'lsx_wetu_id', true );
924
+				$potential_id = wp_get_post_parent_id($dest_id);
925
+				$country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true);
926 926
 
927
-				if ( false !== $country_wetu_id ) {
928
-					$country_id = $this->set_country( $country_wetu_id, $id );
927
+				if (false !== $country_wetu_id) {
928
+					$country_id = $this->set_country($country_wetu_id, $id);
929 929
 				}
930
-			} else {
931
-				$destination_json = wp_remote_get( 'https://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $day['destination_content_entity_id'] );
930
+			}else {
931
+				$destination_json = wp_remote_get('https://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$day['destination_content_entity_id']);
932 932
 
933
-				if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
933
+				if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
934 934
 
935
-					$destination_data = json_decode( $destination_json['body'], true );
935
+					$destination_data = json_decode($destination_json['body'], true);
936 936
 
937
-					if ( ! empty( $destination_data ) && ! isset( $destination_data['error'] ) ) {
937
+					if (!empty($destination_data) && !isset($destination_data['error'])) {
938 938
 						$destination_title = $day['destination_content_entity_id'];
939 939
 
940
-						if ( isset( $destination_data[0]['name'] ) ) {
940
+						if (isset($destination_data[0]['name'])) {
941 941
 							$destination_title = $destination_data[0]['name'];
942 942
 						}
943 943
 
944
-						if ( isset( $destination_data[0]['map_object_id'] ) && isset( $destination_data[0]['position']['country_content_entity_id'] )
945
-							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id'] ) {
944
+						if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
945
+							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) {
946 946
 
947
-							$country_id = $this->set_country( $destination_data[0]['position']['country_content_entity_id'], $id );
947
+							$country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id);
948 948
 							// Save the destination so we can grab the tour featured image and banner from them.
949 949
 						}
950 950
 
@@ -954,40 +954,40 @@  discard block
 block discarded – undo
954 954
 							'post_title' => $destination_title,
955 955
 						);
956 956
 
957
-						if ( false !== $country_id ) {
957
+						if (false !== $country_id) {
958 958
 							$dest_post['post_parent'] = $country_id;
959 959
 						}
960
-						$dest_id = wp_insert_post( $dest_post );
960
+						$dest_id = wp_insert_post($dest_post);
961 961
 
962 962
 						// Make sure we register the.
963
-						$this->current_destinations[ $day['destination_content_entity_id'] ] = $dest_id;
963
+						$this->current_destinations[$day['destination_content_entity_id']] = $dest_id;
964 964
 
965 965
 						// If there are images attached then use the destination.
966
-						if ( isset( $destination_data[0]['content']['images'] ) && ! empty( $destination_data[0]['content']['images'] ) ) {
967
-							$this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] );
966
+						if (isset($destination_data[0]['content']['images']) && !empty($destination_data[0]['content']['images'])) {
967
+							$this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']);
968 968
 						}
969 969
 
970
-						$this->save_custom_field( $day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id );
970
+						$this->save_custom_field($day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id);
971 971
 					}
972 972
 				}
973 973
 			}
974 974
 
975
-			if ( '' !== $dest_id && false !== $dest_id ) {
976
-				$this->save_custom_field( $dest_id, 'destination_to_tour', $id, false, false );
977
-				$this->save_custom_field( $id, 'tour_to_destination', $dest_id, false, false );
975
+			if ('' !== $dest_id && false !== $dest_id) {
976
+				$this->save_custom_field($dest_id, 'destination_to_tour', $id, false, false);
977
+				$this->save_custom_field($id, 'tour_to_destination', $dest_id, false, false);
978 978
 
979 979
 				//Save the item to display in the queue
980
-				$this->queue_item( $dest_id );
980
+				$this->queue_item($dest_id);
981 981
 
982 982
 				//Save the item to clean up the amount of connections.
983
-				$this->cleanup_posts[ $dest_id ] = 'tour_to_destination';
983
+				$this->cleanup_posts[$dest_id] = 'tour_to_destination';
984 984
 
985 985
 				//Add this relation info so we can make sure certain items are set as countries.
986
-				if ( 0 !== $country_id && false !== $country_id ) {
987
-					$this->relation_meta[ $dest_id ] = $country_id;
988
-					$this->relation_meta[ $country_id ] = 0;
989
-				} else {
990
-					$this->relation_meta[ $dest_id ] = 0;
986
+				if (0 !== $country_id && false !== $country_id) {
987
+					$this->relation_meta[$dest_id] = $country_id;
988
+					$this->relation_meta[$country_id] = 0;
989
+				}else {
990
+					$this->relation_meta[$dest_id] = 0;
991 991
 				}
992 992
 			}
993 993
 		}
@@ -1003,25 +1003,25 @@  discard block
 block discarded – undo
1003 1003
 	 *
1004 1004
 	 * @return string
1005 1005
 	 */
1006
-	public function set_country( $country_wetu_id, $id ) {
1006
+	public function set_country($country_wetu_id, $id) {
1007 1007
 		$country_id = false;
1008 1008
 		$this->current_destinations = $this->find_current_destinations();
1009 1009
 
1010
-		if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $country_wetu_id, $this->current_destinations ) ) {
1011
-			$country_id = $this->current_destinations[ $country_wetu_id ];
1012
-			$this->destination_images[ $id ][] = array( $country_id, $country_wetu_id );
1013
-		} else {
1014
-			$country_json = file_get_contents( 'https://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $country_wetu_id );
1010
+		if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
1011
+			$country_id = $this->current_destinations[$country_wetu_id];
1012
+			$this->destination_images[$id][] = array($country_id, $country_wetu_id);
1013
+		}else {
1014
+			$country_json = file_get_contents('https://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$country_wetu_id);
1015 1015
 
1016
-			if ( $country_json ) {
1017
-				$country_data = json_decode( $country_json, true );
1016
+			if ($country_json) {
1017
+				$country_data = json_decode($country_json, true);
1018 1018
 
1019
-				if ( ! empty( $country_data ) && ! isset( $country_data['error'] ) ) {
1019
+				if (!empty($country_data) && !isset($country_data['error'])) {
1020 1020
 
1021 1021
 					//Format the title of the destination if its available,  otherwise default to the WETU ID.
1022 1022
 					$country_title = $country_wetu_id;
1023 1023
 
1024
-					if ( isset( $country_data[0]['name'] ) ) {
1024
+					if (isset($country_data[0]['name'])) {
1025 1025
 						$country_title = $country_data[0]['name'];
1026 1026
 					}
1027 1027
 
@@ -1032,24 +1032,24 @@  discard block
 block discarded – undo
1032 1032
 					));
1033 1033
 
1034 1034
 					//add the country to the current destination stack
1035
-					$this->current_destinations[ $country_wetu_id ] = $country_id;
1035
+					$this->current_destinations[$country_wetu_id] = $country_id;
1036 1036
 
1037 1037
 					// Check if there are images and save fore use later.
1038
-					if ( isset( $country_data[0]['content']['images'] ) && ! empty( $country_data[0]['content']['images'] ) ) {
1039
-						$this->destination_images[ $id ][] = array( $country_id,$country_wetu_id );
1038
+					if (isset($country_data[0]['content']['images']) && !empty($country_data[0]['content']['images'])) {
1039
+						$this->destination_images[$id][] = array($country_id, $country_wetu_id);
1040 1040
 					}
1041 1041
 
1042 1042
 					//Save the wetu field
1043
-					$this->save_custom_field( $country_wetu_id, 'lsx_wetu_id', $country_id );
1043
+					$this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
1044 1044
 				}
1045 1045
 			}
1046 1046
 		}
1047 1047
 
1048
-		if ( '' !== $country_id && false !== $country_id ) {
1049
-			$this->save_custom_field( $country_id, 'destination_to_tour', $id, false, false );
1050
-			$this->save_custom_field( $id, 'tour_to_destination', $country_id, false, false );
1051
-			$this->queue_item( $country_id );
1052
-			$this->cleanup_posts[ $country_id ] = 'tour_to_destination';
1048
+		if ('' !== $country_id && false !== $country_id) {
1049
+			$this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
1050
+			$this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
1051
+			$this->queue_item($country_id);
1052
+			$this->cleanup_posts[$country_id] = 'tour_to_destination';
1053 1053
 
1054 1054
 			return $country_id;
1055 1055
 		}
@@ -1064,44 +1064,44 @@  discard block
 block discarded – undo
1064 1064
 	 *
1065 1065
 	 * @return string
1066 1066
 	 */
1067
-	public function attach_destination_images( $importable_content = array() ) {
1068
-		if ( false !== $this->destination_images ) {
1069
-			$this->shuffle_assoc( $this->destination_images );
1067
+	public function attach_destination_images($importable_content = array()) {
1068
+		if (false !== $this->destination_images) {
1069
+			$this->shuffle_assoc($this->destination_images);
1070 1070
 
1071
-			foreach ( $this->destination_images as $tour => $destinations ) {
1071
+			foreach ($this->destination_images as $tour => $destinations) {
1072 1072
 				//$this->shuffle_assoc( $destinations );
1073 1073
 
1074 1074
 				$image_set = false;
1075 1075
 				$forced = false;
1076 1076
 
1077
-				foreach ( $destinations as $destination ) {
1078
-					if ( false === $image_set && false === $forced ) {
1079
-						$url = 'https://wetu.com/API/Pins/' . $this->api_key;
1077
+				foreach ($destinations as $destination) {
1078
+					if (false === $image_set && false === $forced) {
1079
+						$url = 'https://wetu.com/API/Pins/'.$this->api_key;
1080 1080
 						$url_qs = '';
1081 1081
 
1082
-						$jdata = file_get_contents( $url . '/Get?' . $url_qs . '&ids=' . $destination[1] );
1082
+						$jdata = file_get_contents($url.'/Get?'.$url_qs.'&ids='.$destination[1]);
1083 1083
 
1084
-						if ( $jdata ) {
1085
-							$adata = json_decode( $jdata, true );
1084
+						if ($jdata) {
1085
+							$adata = json_decode($jdata, true);
1086 1086
 
1087
-							if ( ! empty( $adata ) && ! empty( $adata[0]['content']['images'] ) ) {
1088
-								$this->find_attachments( $destination[0] );
1087
+							if (!empty($adata) && !empty($adata[0]['content']['images'])) {
1088
+								$this->find_attachments($destination[0]);
1089 1089
 
1090 1090
 								//Set the featured image
1091
-								if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
1092
-									$image_set = $this->set_featured_image( $adata, $tour );
1093
-									if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
1094
-										$image_set = $this->set_banner_image( $adata, $tour );
1091
+								if (false !== $importable_content && in_array('featured_image', $importable_content)) {
1092
+									$image_set = $this->set_featured_image($adata, $tour);
1093
+									if (false !== $importable_content && in_array('banner_image', $importable_content)) {
1094
+										$image_set = $this->set_banner_image($adata, $tour);
1095 1095
 										$forced = true;
1096 1096
 									}
1097 1097
 									continue;
1098 1098
 								}
1099
-								if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
1100
-									$image_set = $this->set_banner_image( $adata, $tour );
1099
+								if (false !== $importable_content && in_array('banner_image', $importable_content)) {
1100
+									$image_set = $this->set_banner_image($adata, $tour);
1101 1101
 								}
1102 1102
 							}
1103 1103
 						}
1104
-					} else {
1104
+					}else {
1105 1105
 						continue;
1106 1106
 					}
1107 1107
 				}
@@ -1112,28 +1112,28 @@  discard block
 block discarded – undo
1112 1112
 	/**
1113 1113
 	 * Creates the main gallery data
1114 1114
 	 */
1115
-	public function set_featured_image( $data, $id ) {
1115
+	public function set_featured_image($data, $id) {
1116 1116
 		$image_set = false;
1117 1117
 		$counter = 0;
1118 1118
 
1119
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
1120
-			foreach ( $data[0]['content']['images'] as $v ) {
1119
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
1120
+			foreach ($data[0]['content']['images'] as $v) {
1121 1121
 				/*print_r('<pre>');
1122 1122
 				print_r( $v );
1123 1123
 				print_r('</pre>');*/
1124 1124
 
1125
-				if ( true === $image_set ) {
1125
+				if (true === $image_set) {
1126 1126
 					$counter++;
1127 1127
 					continue;
1128 1128
 				}
1129 1129
 
1130
-				if ( ! $this->check_if_image_is_used( $v ) ) {
1131
-					$temp_featured_image = $this->attach_image( $v , $id );
1130
+				if (!$this->check_if_image_is_used($v)) {
1131
+					$temp_featured_image = $this->attach_image($v, $id);
1132 1132
 
1133
-					if ( false !== $temp_featured_image ) {
1133
+					if (false !== $temp_featured_image) {
1134 1134
 						$this->featured_image = $temp_featured_image;
1135
-						delete_post_meta( $id, '_thumbnail_id' );
1136
-						add_post_meta( $id, '_thumbnail_id', $this->featured_image, true );
1135
+						delete_post_meta($id, '_thumbnail_id');
1136
+						add_post_meta($id, '_thumbnail_id', $this->featured_image, true);
1137 1137
 						$image_set = true;
1138 1138
 					}
1139 1139
 				}
@@ -1147,40 +1147,40 @@  discard block
 block discarded – undo
1147 1147
 	/**
1148 1148
 	 * Sets a banner image
1149 1149
 	 */
1150
-	public function set_banner_image( $data, $id, $content = array( 'none' ) ) {
1150
+	public function set_banner_image($data, $id, $content = array('none')) {
1151 1151
 		$image_set = false;
1152 1152
 		$counter = 0;
1153 1153
 
1154
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
1154
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
1155 1155
 
1156
-			foreach ( $data[0]['content']['images'] as $v ) {
1156
+			foreach ($data[0]['content']['images'] as $v) {
1157 1157
 				/*print_r('<pre>');
1158 1158
 				print_r( $v );
1159 1159
 				print_r('</pre>');*/
1160 1160
 
1161
-				if ( true === $image_set || 0 === $counter ) {
1161
+				if (true === $image_set || 0 === $counter) {
1162 1162
 					$counter++;
1163 1163
 					continue;
1164 1164
 				}
1165 1165
 
1166
-				if ( ! $this->check_if_image_is_used( $v ) ) {
1167
-					$temp_banner = $this->attach_image( $v, $id, array(
1166
+				if (!$this->check_if_image_is_used($v)) {
1167
+					$temp_banner = $this->attach_image($v, $id, array(
1168 1168
 						'width' => '1920',
1169 1169
 						'height' => '600',
1170 1170
 						'cropping' => 'c',
1171
-					) );
1171
+					));
1172 1172
 
1173
-					if ( false !== $temp_banner ) {
1173
+					if (false !== $temp_banner) {
1174 1174
 						$this->banner_image = $temp_banner;
1175 1175
 
1176
-						delete_post_meta( $id,'image_group' );
1176
+						delete_post_meta($id, 'image_group');
1177 1177
 
1178 1178
 						$new_banner = array(
1179 1179
 							'banner_image' => array(
1180 1180
 								'cmb-field-0' => $this->banner_image,
1181 1181
 							),
1182 1182
 						);
1183
-						add_post_meta( $id,'image_group',$new_banner,true );
1183
+						add_post_meta($id, 'image_group', $new_banner, true);
1184 1184
 						$image_set = true;
1185 1185
 					}
1186 1186
 				}
@@ -1194,18 +1194,18 @@  discard block
 block discarded – undo
1194 1194
 	/**
1195 1195
 	 * Grabs all of the current used featured images on the site.
1196 1196
 	 */
1197
-	public function check_if_image_is_used( $v ) {
1197
+	public function check_if_image_is_used($v) {
1198 1198
 		global $wpdb;
1199 1199
 
1200
-		$temp_fragment = explode( '/', $v['url_fragment'] );
1201
-		$url_filename = $temp_fragment[ count( $temp_fragment ) -1 ];
1202
-		$url_filename = str_replace( array( '.jpg', '.png', '.jpeg' ), '', $url_filename );
1203
-		$url_filename = trim( $url_filename );
1204
-		$url_filename = str_replace( ' ', '_', $url_filename );
1200
+		$temp_fragment = explode('/', $v['url_fragment']);
1201
+		$url_filename = $temp_fragment[count($temp_fragment) - 1];
1202
+		$url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename);
1203
+		$url_filename = trim($url_filename);
1204
+		$url_filename = str_replace(' ', '_', $url_filename);
1205 1205
 
1206
-		if ( in_array( $url_filename, $this->found_attachments ) ) {
1206
+		if (in_array($url_filename, $this->found_attachments)) {
1207 1207
 			//check to see if there is a featured image set with this ID.
1208
-			$found_id = array_search( $url_filename, $this->found_attachments );
1208
+			$found_id = array_search($url_filename, $this->found_attachments);
1209 1209
 
1210 1210
 			$querystring = "
1211 1211
 				SELECT      post_id
@@ -1214,22 +1214,22 @@  discard block
 block discarded – undo
1214 1214
 				AND 		meta_key = '_thumbnail_id'
1215 1215
 			";
1216 1216
 			// @codingStandardsIgnoreLine
1217
-			$results = $wpdb->get_results( $querystring );
1217
+			$results = $wpdb->get_results($querystring);
1218 1218
 
1219
-			if ( ! empty( $results ) ) {
1219
+			if (!empty($results)) {
1220 1220
 				return true;
1221
-			} else {
1221
+			}else {
1222 1222
 				return false;
1223 1223
 			}
1224
-		} else {
1224
+		}else {
1225 1225
 			$querystring = "
1226 1226
 				SELECT      ID
1227 1227
 				FROM        {$wpdb->posts}
1228 1228
 				WHERE       post_name = '{$url_filename}'
1229 1229
 			";
1230 1230
 			// @codingStandardsIgnoreLine
1231
-			$results = $wpdb->get_results( $querystring );
1232
-			if ( ! empty( $results ) ) {
1231
+			$results = $wpdb->get_results($querystring);
1232
+			if (!empty($results)) {
1233 1233
 				$querystring = "
1234 1234
 					SELECT      post_id
1235 1235
 					FROM        {$wpdb->postmeta}
@@ -1237,13 +1237,13 @@  discard block
 block discarded – undo
1237 1237
 					AND 		meta_key = '_thumbnail_id'
1238 1238
 				";
1239 1239
 				// @codingStandardsIgnoreLine
1240
-				$results = $wpdb->get_results( $querystring );
1241
-				if ( ! empty( $results ) ) {
1240
+				$results = $wpdb->get_results($querystring);
1241
+				if (!empty($results)) {
1242 1242
 					return true;
1243
-				} else {
1243
+				}else {
1244 1244
 					return false;
1245 1245
 				}
1246
-			} else {
1246
+			}else {
1247 1247
 				return false;
1248 1248
 			}
1249 1249
 		}
@@ -1254,10 +1254,10 @@  discard block
 block discarded – undo
1254 1254
 	 *
1255 1255
 	 * @param   $id     int
1256 1256
 	 */
1257
-	public function queue_item( $id ) {
1258
-		if ( is_array( $this->import_queue ) && ! in_array( $id,$this->import_queue ) ) {
1257
+	public function queue_item($id) {
1258
+		if (is_array($this->import_queue) && !in_array($id, $this->import_queue)) {
1259 1259
 			$this->import_queue[] = $id;
1260
-		} else {
1260
+		}else {
1261 1261
 			$this->import_queue[] = $id;
1262 1262
 		}
1263 1263
 	}
@@ -1266,18 +1266,18 @@  discard block
 block discarded – undo
1266 1266
 	 * Saves the queue to the option.
1267 1267
 	 */
1268 1268
 	public function save_queue() {
1269
-		if ( ! empty( $this->import_queue ) ) {
1270
-			if ( ! empty( $this->queued_imports ) ) {
1271
-				$saved_imports = array_merge( $this->queued_imports,$this->import_queue );
1272
-			} else {
1269
+		if (!empty($this->import_queue)) {
1270
+			if (!empty($this->queued_imports)) {
1271
+				$saved_imports = array_merge($this->queued_imports, $this->import_queue);
1272
+			}else {
1273 1273
 				$saved_imports = $this->import_queue;
1274 1274
 			}
1275 1275
 
1276
-			delete_option( 'lsx_wetu_importer_que' );
1276
+			delete_option('lsx_wetu_importer_que');
1277 1277
 
1278
-			if ( ! empty( $saved_imports ) ) {
1279
-				$saved_imports = array_unique( $saved_imports );
1280
-				update_option( 'lsx_wetu_importer_que',$saved_imports );
1278
+			if (!empty($saved_imports)) {
1279
+				$saved_imports = array_unique($saved_imports);
1280
+				update_option('lsx_wetu_importer_que', $saved_imports);
1281 1281
 			}
1282 1282
 		}
1283 1283
 	}
@@ -1290,13 +1290,13 @@  discard block
 block discarded – undo
1290 1290
 		<thead>
1291 1291
 		<tr>
1292 1292
 			<th style="" class="manage-column column-cb check-column" id="cb" scope="col">
1293
-				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'lsx-wetu-importer' ); ?></label>
1293
+				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'lsx-wetu-importer'); ?></label>
1294 1294
 				<input type="checkbox" id="cb-select-all-1">
1295 1295
 			</th>
1296
-			<th style="" class="manage-column column-title " id="title" style="width:50%;" scope="col"><?php esc_attr_e( 'Title', 'lsx-wetu-importer' ); ?></th>
1297
-			<th style="" class="manage-column column-date" id="ref" style="width:10%;" scope="col"><?php esc_attr_e( 'Ref', 'lsx-wetu-importer' ); ?></th>
1298
-			<th style="" class="manage-column column-date" id="date" scope="col"><?php esc_attr_e( 'Date', 'lsx-wetu-importer' ); ?></th>
1299
-			<th style="" class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'lsx-wetu-importer' ); ?></th>
1296
+			<th style="" class="manage-column column-title " id="title" style="width:50%;" scope="col"><?php esc_attr_e('Title', 'lsx-wetu-importer'); ?></th>
1297
+			<th style="" class="manage-column column-date" id="ref" style="width:10%;" scope="col"><?php esc_attr_e('Ref', 'lsx-wetu-importer'); ?></th>
1298
+			<th style="" class="manage-column column-date" id="date" scope="col"><?php esc_attr_e('Date', 'lsx-wetu-importer'); ?></th>
1299
+			<th style="" class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e('WETU ID', 'lsx-wetu-importer'); ?></th>
1300 1300
 		</tr>
1301 1301
 		</thead>
1302 1302
 		<?php
@@ -1310,13 +1310,13 @@  discard block
 block discarded – undo
1310 1310
 		<tfoot>
1311 1311
 		<tr>
1312 1312
 			<th style="" class="manage-column column-cb check-column" id="cb" scope="col">
1313
-				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'lsx-wetu-importer' ); ?></label>
1313
+				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'lsx-wetu-importer'); ?></label>
1314 1314
 				<input type="checkbox" id="cb-select-all-1">
1315 1315
 			</th>
1316
-			<th style="" class="manage-column column-title" scope="col"><?php esc_attr_e( 'Title', 'lsx-wetu-importer' ); ?></th>
1317
-			<th style="" class="manage-column column-date" id="ref" style="width:10%;" scope="col"><?php esc_attr_e( 'Ref', 'lsx-wetu-importer' ); ?></th>			
1318
-			<th style="" class="manage-column column-date" scope="col"><?php esc_attr_e( 'Date', 'lsx-wetu-importer' ); ?></th>
1319
-			<th style="" class="manage-column column-ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'lsx-wetu-importer' ); ?></th>
1316
+			<th style="" class="manage-column column-title" scope="col"><?php esc_attr_e('Title', 'lsx-wetu-importer'); ?></th>
1317
+			<th style="" class="manage-column column-date" id="ref" style="width:10%;" scope="col"><?php esc_attr_e('Ref', 'lsx-wetu-importer'); ?></th>			
1318
+			<th style="" class="manage-column column-date" scope="col"><?php esc_attr_e('Date', 'lsx-wetu-importer'); ?></th>
1319
+			<th style="" class="manage-column column-ssid" scope="col"><?php esc_attr_e('WETU ID', 'lsx-wetu-importer'); ?></th>
1320 1320
 		</tr>
1321 1321
 		</tfoot>
1322 1322
 		<?php
Please login to merge, or discard this patch.