Passed
Push — master ( 0999b3...037742 )
by Warwick
02:35
created
classes/class-wetu-importer.php 1 patch
Spacing   +334 added lines, -334 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 WETU_IMPORTER_PATH . 'includes/helpers.php';
200
+		add_action('admin_init', array($this, 'compatible_version_check'));
201
+		require_once 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 WETU_IMPORTER_PATH . 'classes/class-welcome.php';
215
-		require_once WETU_IMPORTER_PATH . 'classes/class-wetu-importer-accommodation.php';
216
-		require_once WETU_IMPORTER_PATH . 'classes/class-wetu-importer-destination.php';
217
-		require_once WETU_IMPORTER_PATH . 'classes/class-wetu-importer-tours.php';
218
-		require_once WETU_IMPORTER_PATH . 'classes/class-settings.php';
214
+		require_once WETU_IMPORTER_PATH.'classes/class-welcome.php';
215
+		require_once WETU_IMPORTER_PATH.'classes/class-wetu-importer-accommodation.php';
216
+		require_once WETU_IMPORTER_PATH.'classes/class-wetu-importer-destination.php';
217
+		require_once WETU_IMPORTER_PATH.'classes/class-wetu-importer-tours.php';
218
+		require_once 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( 'wetu-importer', false, basename( WETU_IMPORTER_PATH ) . '/languages' );
239
+		load_plugin_textdomain('wetu-importer', false, basename(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 = \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( 'wetu_importer_que', array() );
280
+				$this->queued_imports = get_option('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( WETU_IMPORTER_CORE ) ) ) {
344
-				deactivate_plugins( plugin_basename( 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(WETU_IMPORTER_CORE))) {
344
+				deactivate_plugins(plugin_basename(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__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' );
362
-		printf( '<div class="%1$s"><p>%2$s</p></div>', esc_html( $class ), esc_html( $message ) );
361
+		$message = esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', '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( WETU_IMPORTER_CORE ) );
374
-			wp_die( esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' ) );
372
+		if (!self::compatible_version()) {
373
+			deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE));
374
+			wp_die(esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', '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 WETU_Importer_Accommodation();
387 387
 				break;
@@ -408,31 +408,31 @@  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', 'wetu-importer', array( $this, 'display_page' ) );
411
+		add_submenu_page('tour-operator', esc_html__('Importer', 'tour-operator'), esc_html__('Importer', 'tour-operator'), 'manage_options', '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( 'wetu-importer-style', WETU_IMPORTER_URL . 'assets/css/wetu-importer.css', WETU_IMPORTER_VER, true );
429
-			wp_enqueue_script( 'wetu-importers-script', WETU_IMPORTER_URL . 'assets/js/wetu-importer' . $min . '.js', array( 'jquery' ), WETU_IMPORTER_VER, true );
428
+			wp_enqueue_style('wetu-importer-style', WETU_IMPORTER_URL.'assets/css/wetu-importer.css', WETU_IMPORTER_VER, true);
429
+			wp_enqueue_script('wetu-importers-script', WETU_IMPORTER_URL.'assets/js/wetu-importer'.$min.'.js', array('jquery'), WETU_IMPORTER_VER, true);
430 430
 
431 431
 			wp_localize_script(
432 432
 				'wetu-importers-script',
433 433
 				'lsx_tour_importer_params',
434 434
 				array(
435
-					'ajax_url' => admin_url( 'admin-ajax.php' ),
435
+					'ajax_url' => admin_url('admin-ajax.php'),
436 436
 				)
437 437
 			);
438 438
 		}
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 		?>
446 446
 		<div class="wrap">
447 447
 			<?php
448
-			$this->navigation( $this->tab_slug );
449
-			if ( 'default' !== $this->tab_slug && 'settings' !== $this->tab_slug ) {
448
+			$this->navigation($this->tab_slug);
449
+			if ('default' !== $this->tab_slug && 'settings' !== $this->tab_slug) {
450 450
 				$this->wetu_status();
451 451
 				$this->post_status_navigation();
452 452
 			}
@@ -464,15 +464,15 @@  discard block
 block discarded – undo
464 464
 	public function post_status_navigation() {
465 465
 		?>
466 466
 		<ul class="subsubsub">
467
-			<li class="searchform"><a class="current" href="#search"><?php esc_attr_e( 'Search', 'wetu-importer' ); ?></a> | </li>
468
-			<li class="publish"><a href="#publish"><?php esc_attr_e( 'Published', 'wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( \wetu_importer\includes\helpers\get_post_count( $this->tab_slug, 'publish ' ) ); ?>)</span></a> | </li>
469
-			<li class="pending"><a href="#pending"><?php esc_attr_e( 'Pending', 'wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( \wetu_importer\includes\helpers\get_post_count( $this->tab_slug, 'pending ' ) ); ?>)</span></a>| </li> 
470
-			<li class="draft"><a href="#draft"><?php esc_attr_e( 'Draft', 'wetu-importer' ); ?></a> <span class="count"> (<?php echo esc_attr( \wetu_importer\includes\helpers\get_post_count( $this->tab_slug, 'draft ' ) ); ?>)</span></li>
471
-
472
-			<?php if ( 'tour' === $this->tab_slug ) { ?>
473
-				<li class="import"> | <a class="import search-toggle"  href="#import"><?php esc_attr_e( 'WETU', 'wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( \wetu_importer\includes\helpers\get_wetu_tour_count() ); ?>)</span></a></li>
474
-			<?php } else if ( ! empty( $this->queued_imports ) ) { ?>
475
-				<li class="import"> | <a class="import search-toggle"  href="#import"><?php esc_attr_e( 'WETU Queue', 'wetu-importer' ); ?> <span class="count"> (<?php echo esc_attr( \wetu_importer\includes\helpers\get_wetu_queue_count( $this->tab_slug ) ); ?>)</span></a></li>
467
+			<li class="searchform"><a class="current" href="#search"><?php esc_attr_e('Search', 'wetu-importer'); ?></a> | </li>
468
+			<li class="publish"><a href="#publish"><?php esc_attr_e('Published', 'wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(\wetu_importer\includes\helpers\get_post_count($this->tab_slug, 'publish ')); ?>)</span></a> | </li>
469
+			<li class="pending"><a href="#pending"><?php esc_attr_e('Pending', 'wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(\wetu_importer\includes\helpers\get_post_count($this->tab_slug, 'pending ')); ?>)</span></a>| </li> 
470
+			<li class="draft"><a href="#draft"><?php esc_attr_e('Draft', 'wetu-importer'); ?></a> <span class="count"> (<?php echo esc_attr(\wetu_importer\includes\helpers\get_post_count($this->tab_slug, 'draft ')); ?>)</span></li>
471
+
472
+			<?php if ('tour' === $this->tab_slug) { ?>
473
+				<li class="import"> | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU', 'wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(\wetu_importer\includes\helpers\get_wetu_tour_count()); ?>)</span></a></li>
474
+			<?php }else if (!empty($this->queued_imports)) { ?>
475
+				<li class="import"> | <a class="import search-toggle"  href="#import"><?php esc_attr_e('WETU Queue', 'wetu-importer'); ?> <span class="count"> (<?php echo esc_attr(\wetu_importer\includes\helpers\get_wetu_queue_count($this->tab_slug)); ?>)</span></a></li>
476 476
 			<?php } ?>
477 477
 		</ul>
478 478
 		<?php
@@ -483,29 +483,29 @@  discard block
 block discarded – undo
483 483
 	 */
484 484
 	public function search_form() {
485 485
 		?>
486
-		<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 ); ?>">
487
-			<input type="hidden" name="page" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
486
+		<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); ?>">
487
+			<input type="hidden" name="page" value="<?php echo esc_attr($this->tab_slug); ?>" />
488 488
 
489
-			<?php do_action( 'wetu_importer_search_form',$this ); ?>
489
+			<?php do_action('wetu_importer_search_form', $this); ?>
490 490
 
491 491
 			<div class="normal-search">
492
-				<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', 'wetu-importer' ); ?>" />
492
+				<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', 'wetu-importer'); ?>" />
493 493
 			</div>
494 494
 
495 495
 			<div class="advanced-search hidden" style="display:none;">
496 496
 				<textarea rows="10" cols="40" name="bulk-keywords"></textarea>
497
-				<input class="button button-primary submit" type="submit" value="<?php esc_attr_e( 'Search', 'wetu-importer' ); ?>" />
497
+				<input class="button button-primary submit" type="submit" value="<?php esc_attr_e('Search', 'wetu-importer'); ?>" />
498 498
 			</div>
499 499
 
500 500
 			<div class="ajax-loader" style="display:none;width:100%;text-align:center;">
501
-				<img style="width:64px;" src="<?php echo esc_url( WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" />
501
+				<img style="width:64px;" src="<?php echo esc_url(WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" />
502 502
 			</div>
503 503
 
504 504
 			<div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
505
-				<img style="width:32px;" src="<?php echo esc_url( WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" />
505
+				<img style="width:32px;" src="<?php echo esc_url(WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" />
506 506
 			</div>
507 507
 
508
-			<a class="button advanced-search-toggle" href="#"><?php esc_html_e( 'Bulk Search', 'wetu-importer' ); ?></a>
508
+			<a class="button advanced-search-toggle" href="#"><?php esc_html_e('Bulk Search', 'wetu-importer'); ?></a>
509 509
 		</form>
510 510
 		<?php
511 511
 	}
@@ -553,43 +553,43 @@  discard block
 block discarded – undo
553 553
 	 *
554 554
 	 * @param $tab string
555 555
 	 */
556
-	public function navigation( $tab = '' ) {
556
+	public function navigation($tab = '') {
557 557
 		$post_types = array(
558
-			'tour'          => esc_attr( 'Tours', 'wetu-importer' ),
559
-			'accommodation' => esc_attr( 'Accommodation', 'wetu-importer' ),
560
-			'destination'   => esc_attr( 'Destinations', 'wetu-importer' ),
558
+			'tour'          => esc_attr('Tours', 'wetu-importer'),
559
+			'accommodation' => esc_attr('Accommodation', 'wetu-importer'),
560
+			'destination'   => esc_attr('Destinations', 'wetu-importer'),
561 561
 		);
562 562
 
563
-		echo wp_kses_post( '<div class="wp-filter">' );
564
-		echo wp_kses_post( '<ul class="filter-links">' );
565
-		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', 'wetu-importer' ) . '</a></li>' );
563
+		echo wp_kses_post('<div class="wp-filter">');
564
+		echo wp_kses_post('<ul class="filter-links">');
565
+		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', 'wetu-importer').'</a></li>');
566 566
 
567
-		foreach ( $post_types as $post_type => $label ) {
568
-			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>' );
567
+		foreach ($post_types as $post_type => $label) {
568
+			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>');
569 569
 		}
570 570
 
571
-		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', 'wetu-importer' ) . '</a></li>' );
572
-		echo wp_kses_post( '</ul> </div>' );
571
+		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', 'wetu-importer').'</a></li>');
572
+		echo wp_kses_post('</ul> </div>');
573 573
 	}
574 574
 
575 575
 	/**
576 576
 	 * Wetu Status Bar.
577 577
 	 */
578 578
 	public function wetu_status() {
579
-		$tours = get_transient( 'lsx_ti_tours' );
580
-		echo '<div class="wetu-status tour-wetu-status"><h3>' . esc_html__( 'Wetu Status','wetu-importer' ) . ' - ';
579
+		$tours = get_transient('lsx_ti_tours');
580
+		echo '<div class="wetu-status tour-wetu-status"><h3>'.esc_html__('Wetu Status', 'wetu-importer').' - ';
581 581
 
582
-		if ( '' === $tours || false === $tours || isset( $_GET['refresh_tours'] ) ) {
582
+		if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) {
583 583
 			$result = $this->update_options();
584 584
 
585
-			if ( true === $result ) {
586
-				echo '<span style="color:green;">' . esc_attr( 'Connected','wetu-importer' ) . '</span>';
587
-				echo ' - <small><a href="#">' . esc_attr( 'Refresh','wetu-importer' ) . '</a></small>';
588
-			} else {
589
-				echo '<span style="color:red;">' . wp_kses_post( $result ) . '</span>';
585
+			if (true === $result) {
586
+				echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>';
587
+				echo ' - <small><a href="#">'.esc_attr('Refresh', 'wetu-importer').'</a></small>';
588
+			}else {
589
+				echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
590 590
 			}
591
-		} else {
592
-			echo '<span style="color:green;">' . esc_attr( 'Connected','wetu-importer' ) . '</span> - <small><a href="#">' . esc_attr( 'Refresh','wetu-importer' ) . '</a></small>';
591
+		}else {
592
+			echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh', 'wetu-importer').'</a></small>';
593 593
 		}
594 594
 		echo '</h3>';
595 595
 		echo '</div>';
@@ -598,8 +598,8 @@  discard block
 block discarded – undo
598 598
 	/**
599 599
 	 * Set_taxonomy with some terms
600 600
 	 */
601
-	public function team_member_checkboxes( $selected = array() ) {
602
-		if ( post_type_exists( 'team' ) ) { ?>
601
+	public function team_member_checkboxes($selected = array()) {
602
+		if (post_type_exists('team')) { ?>
603 603
 			<ul>
604 604
 				<?php
605 605
 					$team_args = array(
@@ -609,15 +609,15 @@  discard block
 block discarded – undo
609 609
 						'fields' => 'ids',
610 610
 					);
611 611
 
612
-					$team_members = new WP_Query( $team_args );
612
+					$team_members = new WP_Query($team_args);
613 613
 
614
-					if ( $team_members->have_posts() ) {
615
-						foreach ( $team_members->posts as $member ) {
614
+					if ($team_members->have_posts()) {
615
+						foreach ($team_members->posts as $member) {
616 616
 							// @codingStandardsIgnoreLine ?>
617
-							<li><input class="team" <?php $this->checked( $selected, $member ); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title( $member ); ?></li>
617
+							<li><input class="team" <?php $this->checked($selected, $member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li>
618 618
 						<?php }
619
-					} else { ?>
620
-						<li><input class="team" type="checkbox" value="0" /> <?php esc_html_e( 'None', 'wetu-importer' ); ?></li>
619
+					}else { ?>
620
+						<li><input class="team" type="checkbox" value="0" /> <?php esc_html_e('None', 'wetu-importer'); ?></li>
621 621
 					<?php }
622 622
 				?>
623 623
 			</ul>
@@ -634,14 +634,14 @@  discard block
 block discarded – undo
634 634
 	 * @param $needle string
635 635
 	 * @param $echo bool
636 636
 	 */
637
-	public function checked( $haystack = false, $needle = '', $echo = true ) {
638
-		$return = $this->itemd( $haystack,$needle, 'checked' );
637
+	public function checked($haystack = false, $needle = '', $echo = true) {
638
+		$return = $this->itemd($haystack, $needle, 'checked');
639 639
 
640
-		if ( '' !== $return ) {
641
-			if ( true === $echo ) {
640
+		if ('' !== $return) {
641
+			if (true === $echo) {
642 642
 				// @codingStandardsIgnoreLine
643 643
 				echo $return;
644
-			} else {
644
+			}else {
645 645
 				return $return;
646 646
 			}
647 647
 		}
@@ -654,14 +654,14 @@  discard block
 block discarded – undo
654 654
 	 * @param $needle string
655 655
 	 * @param $echo bool
656 656
 	 */
657
-	public function selected( $haystack = false, $needle = '', $echo = true ) {
658
-		$return = $this->itemd( $haystack, $needle, 'selected' );
657
+	public function selected($haystack = false, $needle = '', $echo = true) {
658
+		$return = $this->itemd($haystack, $needle, 'selected');
659 659
 
660
-		if ( '' !== $return ) {
661
-			if ( true === $echo ) {
660
+		if ('' !== $return) {
661
+			if (true === $echo) {
662 662
 				// @codingStandardsIgnoreLine
663 663
 				echo $return;
664
-			} else {
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,27 +766,27 @@  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 ) {
772
+		if (!empty($data)) {
773
+			foreach ($data as $k) {
774
+				if ($id) {
775 775
 					// @codingStandardsIgnoreLine
776
-					if ( ! $term = term_exists( trim( $k ), $tax ) ) {
777
-						$term = wp_insert_term( trim( $k ), $tax );
776
+					if (!$term = term_exists(trim($k), $tax)) {
777
+						$term = wp_insert_term(trim($k), $tax);
778 778
 
779
-						if ( is_wp_error( $term ) ) {
779
+						if (is_wp_error($term)) {
780 780
 							// @codingStandardsIgnoreLine
781 781
 							echo $term->get_error_message();
782
-						} else {
783
-							wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true );
782
+						}else {
783
+							wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
784 784
 						}
785
-					} else {
786
-						wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true );
785
+					}else {
786
+						wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
787 787
 					}
788
-				} else {
789
-					$result[] = trim( $k );
788
+				}else {
789
+					$result[] = trim($k);
790 790
 				}
791 791
 			}
792 792
 		}
@@ -802,25 +802,25 @@  discard block
 block discarded – undo
802 802
 	 * @param boolean $parent
803 803
 	 * @return void
804 804
 	 */
805
-	public function set_term( $id = false, $name = false, $taxonomy = false, $parent = false ) {
805
+	public function set_term($id = false, $name = false, $taxonomy = false, $parent = false) {
806 806
 		// @codingStandardsIgnoreLine
807
-		if ( ! $term = term_exists( $name, $taxonomy ) ) {
808
-			if ( false !== $parent ) {
807
+		if (!$term = term_exists($name, $taxonomy)) {
808
+			if (false !== $parent) {
809 809
 				$parent = array(
810 810
 					'parent' => $parent,
811 811
 				);
812 812
 			}
813 813
 
814
-			$term = wp_insert_term( trim( $name ), $taxonomy,$parent );
814
+			$term = wp_insert_term(trim($name), $taxonomy, $parent);
815 815
 
816
-			if ( is_wp_error( $term ) ) {
816
+			if (is_wp_error($term)) {
817 817
 				// @codingStandardsIgnoreLine
818 818
 				echo $term->get_error_message();
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
-		} else {
823
-			wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true );
822
+		}else {
823
+			wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true);
824 824
 		}
825 825
 
826 826
 		return $term['term_id'];
@@ -829,22 +829,22 @@  discard block
 block discarded – undo
829 829
 	/**
830 830
 	 * set_taxonomy with some terms
831 831
 	 */
832
-	public function taxonomy_checkboxes( $taxonomy = false, $selected = array() ) {
832
+	public function taxonomy_checkboxes($taxonomy = false, $selected = array()) {
833 833
 		$return = '';
834 834
 
835
-		if ( false !== $taxonomy ) {
835
+		if (false !== $taxonomy) {
836 836
 			$return .= '<ul>';
837
-			$terms = get_terms( array(
837
+			$terms = get_terms(array(
838 838
 				'taxonomy' => $taxonomy,
839 839
 				'hide_empty' => false,
840
-			) );
840
+			));
841 841
 
842
-			if ( ! is_wp_error( $terms ) ) {
843
-				foreach ( $terms as $term ) {
844
-					$return .= '<li><input class="' . $taxonomy . '" ' . $this->checked( $selected,$term->term_id,false ) . ' type="checkbox" value="' . $term->term_id . '" /> ' . $term->name . '</li>';
842
+			if (!is_wp_error($terms)) {
843
+				foreach ($terms as $term) {
844
+					$return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected, $term->term_id, false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>';
845 845
 				}
846
-			} else {
847
-				$return .= '<li><input type="checkbox" value="" /> ' . __( 'None', 'wetu-importer' ) . '</li>';
846
+			}else {
847
+				$return .= '<li><input type="checkbox" value="" /> '.__('None', 'wetu-importer').'</li>';
848 848
 			}
849 849
 
850 850
 			$return .= '</ul>';
@@ -858,44 +858,44 @@  discard block
 block discarded – undo
858 858
 	/**
859 859
 	 * Saves the longitude and lattitude, as well as sets the map marker.
860 860
 	 */
861
-	public function set_map_data( $data, $id, $zoom = '10' ) {
861
+	public function set_map_data($data, $id, $zoom = '10') {
862 862
 		$longitude = false;
863 863
 		$latitude = false;
864 864
 		$address = false;
865 865
 
866
-		if ( isset( $data[0]['position'] ) ) {
867
-			if ( isset( $data[0]['position']['driving_latitude'] ) ) {
866
+		if (isset($data[0]['position'])) {
867
+			if (isset($data[0]['position']['driving_latitude'])) {
868 868
 				$latitude = $data[0]['position']['driving_latitude'];
869
-			} elseif ( isset( $data[0]['position']['latitude'] ) ) {
869
+			} elseif (isset($data[0]['position']['latitude'])) {
870 870
 				$latitude = $data[0]['position']['latitude'];
871 871
 			}
872 872
 
873
-			if ( isset( $data[0]['position']['driving_longitude'] ) ) {
873
+			if (isset($data[0]['position']['driving_longitude'])) {
874 874
 				$longitude = $data[0]['position']['driving_longitude'];
875
-			} elseif ( isset( $data[0]['position']['longitude'] ) ) {
875
+			} elseif (isset($data[0]['position']['longitude'])) {
876 876
 				$longitude = $data[0]['position']['longitude'];
877 877
 			}
878 878
 		}
879 879
 
880
-		if ( isset( $data[0]['content'] ) && isset( $data[0]['content']['contact_information'] ) ) {
881
-			if ( isset( $data[0]['content']['contact_information']['address'] ) ) {
882
-				$address = strip_tags( $data[0]['content']['contact_information']['address'] );
883
-				$address = explode( "\n", $address );
880
+		if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) {
881
+			if (isset($data[0]['content']['contact_information']['address'])) {
882
+				$address = strip_tags($data[0]['content']['contact_information']['address']);
883
+				$address = explode("\n", $address);
884 884
 
885
-				foreach ( $address as $bitkey => $bit ) {
886
-					$bit = ltrim( rtrim( $bit ) );
885
+				foreach ($address as $bitkey => $bit) {
886
+					$bit = ltrim(rtrim($bit));
887 887
 
888
-					if ( false === $bit || '' === $bit || null === $bit || empty( $bit ) ) {
889
-						unset( $address[ $bitkey ] );
888
+					if (false === $bit || '' === $bit || null === $bit || empty($bit)) {
889
+						unset($address[$bitkey]);
890 890
 					}
891 891
 				}
892 892
 
893
-				$address = implode( ', ',$address );
894
-				$address = str_replace( ', , ', ', ', $address );
893
+				$address = implode(', ', $address);
894
+				$address = str_replace(', , ', ', ', $address);
895 895
 			}
896 896
 		}
897 897
 
898
-		if ( false !== $longitude ) {
898
+		if (false !== $longitude) {
899 899
 			$location_data = array(
900 900
 				'address'	=> (string) $address,
901 901
 				'lat'		=> (string) $latitude,
@@ -904,11 +904,11 @@  discard block
 block discarded – undo
904 904
 				'elevation'	=> '',
905 905
 			);
906 906
 
907
-			if ( false !== $id && '0' !== $id ) {
908
-				$prev = get_post_meta( $id,'location',true );
909
-				update_post_meta( $id,'location',$location_data,$prev );
910
-			} else {
911
-				add_post_meta( $id,'location',$location_data,true );
907
+			if (false !== $id && '0' !== $id) {
908
+				$prev = get_post_meta($id, 'location', true);
909
+				update_post_meta($id, 'location', $location_data, $prev);
910
+			}else {
911
+				add_post_meta($id, 'location', $location_data, true);
912 912
 			}
913 913
 		}
914 914
 	}
@@ -918,17 +918,17 @@  discard block
 block discarded – undo
918 918
 	/**
919 919
 	 * Creates the main gallery data
920 920
 	 */
921
-	public function set_featured_image( $data, $id ) {
922
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
923
-			$this->featured_image = $this->attach_image( $data[0]['content']['images'][0], $id,  array(
921
+	public function set_featured_image($data, $id) {
922
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
923
+			$this->featured_image = $this->attach_image($data[0]['content']['images'][0], $id, array(
924 924
 				'width' => '800',
925 925
 				'height' => '600',
926 926
 				'cropping' => 'h',
927
-			) );
927
+			));
928 928
 
929
-			if ( false !== $this->featured_image ) {
930
-				delete_post_meta( $id,'_thumbnail_id' );
931
-				add_post_meta( $id,'_thumbnail_id',$this->featured_image,true );
929
+			if (false !== $this->featured_image) {
930
+				delete_post_meta($id, '_thumbnail_id');
931
+				add_post_meta($id, '_thumbnail_id', $this->featured_image, true);
932 932
 			}
933 933
 		}
934 934
 	}
@@ -936,26 +936,26 @@  discard block
 block discarded – undo
936 936
 	/**
937 937
 	 * Sets a banner image
938 938
 	 */
939
-	public function set_banner_image( $data, $id, $content = array( 'none' ) ) {
940
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
941
-			if ( in_array( 'unique_banner_image', $content ) && isset( $data[0]['destination_image'] ) && is_array( $data[0]['destination_image'] ) ) {
942
-				$temp_banner = $this->attach_image( $data[0]['destination_image'], $id, array(
939
+	public function set_banner_image($data, $id, $content = array('none')) {
940
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
941
+			if (in_array('unique_banner_image', $content) && isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) {
942
+				$temp_banner = $this->attach_image($data[0]['destination_image'], $id, array(
943 943
 					'width' => '1920',
944 944
 					'height' => '600',
945 945
 					'cropping' => 'c',
946 946
 				));
947
-			} else {
948
-				$temp_banner = $this->attach_image( $data[0]['content']['images'][1], $id, array(
947
+			}else {
948
+				$temp_banner = $this->attach_image($data[0]['content']['images'][1], $id, array(
949 949
 					'width' => '1920',
950 950
 					'height' => '600',
951 951
 					'cropping' => 'c',
952 952
 				));
953 953
 			}
954 954
 
955
-			if ( false !== $temp_banner ) {
955
+			if (false !== $temp_banner) {
956 956
 				$this->banner_image = $temp_banner;
957 957
 
958
-				delete_post_meta( $id,'image_group' );
958
+				delete_post_meta($id, 'image_group');
959 959
 
960 960
 				$new_banner = array(
961 961
 					'banner_image' => array(
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
 					),
964 964
 				);
965 965
 
966
-				add_post_meta( $id,'image_group',$new_banner,true );
966
+				add_post_meta($id, 'image_group', $new_banner, true);
967 967
 			}
968 968
 		}
969 969
 	}
@@ -971,17 +971,17 @@  discard block
 block discarded – undo
971 971
 	/**
972 972
 	 * Creates the main gallery data
973 973
 	 */
974
-	public function create_main_gallery( $data, $id ) {
975
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
976
-			if ( isset( $this->options['image_replacing'] ) && 'on' === $this->options['image_replacing'] ) {
977
-				$current_gallery = get_post_meta( $id, 'gallery', false );
974
+	public function create_main_gallery($data, $id) {
975
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
976
+			if (isset($this->options['image_replacing']) && 'on' === $this->options['image_replacing']) {
977
+				$current_gallery = get_post_meta($id, 'gallery', false);
978 978
 
979
-				if ( false !== $current_gallery && ! empty( $current_gallery ) ) {
980
-					foreach ( $current_gallery as $g ) {
981
-						delete_post_meta( $id,'gallery', $g );
979
+				if (false !== $current_gallery && !empty($current_gallery)) {
980
+					foreach ($current_gallery as $g) {
981
+						delete_post_meta($id, 'gallery', $g);
982 982
 
983
-						if ( 'attachment' === get_post_type( $g ) ) {
984
-							wp_delete_attachment( $g, true );
983
+						if ('attachment' === get_post_type($g)) {
984
+							wp_delete_attachment($g, true);
985 985
 						}
986 986
 					}
987 987
 				}
@@ -989,32 +989,32 @@  discard block
 block discarded – undo
989 989
 
990 990
 			$counter = 0;
991 991
 
992
-			foreach ( $data[0]['content']['images'] as $image_data ) {
993
-				if ( ( 0 === $counter && false !== $this->featured_image ) || ( 1 === $counter && false !== $this->banner_image ) ) {
992
+			foreach ($data[0]['content']['images'] as $image_data) {
993
+				if ((0 === $counter && false !== $this->featured_image) || (1 === $counter && false !== $this->banner_image)) {
994 994
 					$counter++;
995 995
 
996
-					if ( false !== $this->image_limit && false !== $this->image_limit ) {
996
+					if (false !== $this->image_limit && false !== $this->image_limit) {
997 997
 						$this->image_limit++;
998 998
 					}
999 999
 
1000 1000
 					continue;
1001 1001
 				}
1002 1002
 
1003
-				if ( false !== $this->image_limit && $counter >= $this->image_limit ) {
1003
+				if (false !== $this->image_limit && $counter >= $this->image_limit) {
1004 1004
 					continue;
1005 1005
 				}
1006 1006
 
1007
-				$this->gallery_meta[] = $this->attach_image( $image_data,$id );
1007
+				$this->gallery_meta[] = $this->attach_image($image_data, $id);
1008 1008
 				$counter++;
1009 1009
 			}
1010 1010
 
1011
-			if ( ! empty( $this->gallery_meta ) ) {
1012
-				delete_post_meta( $id,'gallery' );
1013
-				$this->gallery_meta = array_unique( $this->gallery_meta );
1011
+			if (!empty($this->gallery_meta)) {
1012
+				delete_post_meta($id, 'gallery');
1013
+				$this->gallery_meta = array_unique($this->gallery_meta);
1014 1014
 
1015
-				foreach ( $this->gallery_meta as $gallery_id ) {
1016
-					if ( false !== $gallery_id && '' !== $gallery_id && ! is_array( $gallery_id ) ) {
1017
-						add_post_meta( $id,'gallery',$gallery_id,false );
1015
+				foreach ($this->gallery_meta as $gallery_id) {
1016
+					if (false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)) {
1017
+						add_post_meta($id, 'gallery', $gallery_id, false);
1018 1018
 					}
1019 1019
 				}
1020 1020
 			}
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 	/**
1025 1025
 	 * search_form
1026 1026
 	 */
1027
-	public function get_scaling_url( $args = array() ) {
1027
+	public function get_scaling_url($args = array()) {
1028 1028
 		$defaults = array(
1029 1029
 			'width' => '1024',
1030 1030
 			'height' => '768',
@@ -1032,59 +1032,59 @@  discard block
 block discarded – undo
1032 1032
 			'cropping' => 'h',
1033 1033
 		);
1034 1034
 
1035
-		if ( false !== $this->options ) {
1036
-			if ( isset( $this->options['width'] ) && '' !== $this->options['width'] ) {
1035
+		if (false !== $this->options) {
1036
+			if (isset($this->options['width']) && '' !== $this->options['width']) {
1037 1037
 				$defaults['width'] = $this->options['width'];
1038 1038
 			}
1039 1039
 
1040
-			if ( isset( $this->options['height'] ) && '' !== $this->options['height'] ) {
1040
+			if (isset($this->options['height']) && '' !== $this->options['height']) {
1041 1041
 				$defaults['height'] = $this->options['height'];
1042 1042
 			}
1043 1043
 
1044
-			if ( isset( $this->options['cropping'] ) && '' !== $this->options['cropping'] ) {
1044
+			if (isset($this->options['cropping']) && '' !== $this->options['cropping']) {
1045 1045
 				$defaults['cropping'] = $this->options['cropping'];
1046 1046
 			}
1047 1047
 		}
1048 1048
 
1049
-		$args = wp_parse_args( $args, $defaults );
1049
+		$args = wp_parse_args($args, $defaults);
1050 1050
 		$cropping = $args['cropping'];
1051 1051
 		$width = $args['width'];
1052 1052
 		$height = $args['height'];
1053 1053
 
1054
-		return 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/';
1054
+		return 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/';
1055 1055
 	}
1056 1056
 
1057 1057
 	/**
1058 1058
 	 * Attaches 1 image
1059 1059
 	 */
1060
-	public function attach_image( $v = false, $parent_id, $image_sizes = false, $banner = false ) {
1061
-		if ( false !== $v ) {
1062
-			$temp_fragment = explode( '/',$v['url_fragment'] );
1063
-			$url_filename = $temp_fragment[ count( $temp_fragment ) -1 ];
1064
-			$url_filename = str_replace( array( '.jpg', '.png', '.jpeg' ),'',$url_filename );
1065
-			$url_filename = trim( $url_filename );
1060
+	public function attach_image($v = false, $parent_id, $image_sizes = false, $banner = false) {
1061
+		if (false !== $v) {
1062
+			$temp_fragment = explode('/', $v['url_fragment']);
1063
+			$url_filename = $temp_fragment[count($temp_fragment) - 1];
1064
+			$url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename);
1065
+			$url_filename = trim($url_filename);
1066 1066
 			$title = $url_filename;
1067
-			$url_filename = str_replace( ' ','_',$url_filename );
1067
+			$url_filename = str_replace(' ', '_', $url_filename);
1068 1068
 
1069
-			if ( ! isset( $this->options['image_replacing'] ) && in_array( $url_filename, $this->found_attachments ) ) {
1070
-				return array_search( $url_filename,$this->found_attachments );
1069
+			if (!isset($this->options['image_replacing']) && in_array($url_filename, $this->found_attachments)) {
1070
+				return array_search($url_filename, $this->found_attachments);
1071 1071
 			}
1072 1072
 
1073 1073
 			$postdata = array();
1074 1074
 
1075
-			if ( empty( $v['label'] ) ) {
1075
+			if (empty($v['label'])) {
1076 1076
 				$v['label'] = '';
1077 1077
 			}
1078 1078
 
1079
-			if ( ! empty( $v['description'] ) ) {
1080
-				$desc = wp_strip_all_tags( $v['description'] );
1079
+			if (!empty($v['description'])) {
1080
+				$desc = wp_strip_all_tags($v['description']);
1081 1081
 				$posdata = array(
1082 1082
 					'post_excerpt' => $desc,
1083 1083
 				);
1084 1084
 			}
1085 1085
 
1086
-			if ( ! empty( $v['section'] ) ) {
1087
-				$desc = wp_strip_all_tags( $v['section'] );
1086
+			if (!empty($v['section'])) {
1087
+				$desc = wp_strip_all_tags($v['section']);
1088 1088
 				$posdata = array(
1089 1089
 					'post_excerpt' => $desc,
1090 1090
 				);
@@ -1092,88 +1092,88 @@  discard block
 block discarded – undo
1092 1092
 
1093 1093
 			$attach_id = null;
1094 1094
 			//Resizor - add option to setting if required
1095
-			$fragment = str_replace( ' ','%20',$v['url_fragment'] );
1096
-			$url = $this->get_scaling_url( $image_sizes ) . $fragment;
1095
+			$fragment = str_replace(' ', '%20', $v['url_fragment']);
1096
+			$url = $this->get_scaling_url($image_sizes).$fragment;
1097 1097
 
1098
-			$attach_id = $this->attach_external_image2( $url,$parent_id,'',$v['label'],$postdata );
1098
+			$attach_id = $this->attach_external_image2($url, $parent_id, '', $v['label'], $postdata);
1099 1099
 
1100
-			$this->found_attachments[ $attach_id ] = $url_filename;
1100
+			$this->found_attachments[$attach_id] = $url_filename;
1101 1101
 
1102 1102
 			//echo($attach_id.' add image');
1103
-			if ( ! empty( $attach_id ) ) {
1103
+			if (!empty($attach_id)) {
1104 1104
 				return $attach_id;
1105 1105
 			}
1106 1106
 		}
1107 1107
 		return 	false;
1108 1108
 	}
1109 1109
 
1110
-	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
1111
-		if ( ! $url || ! $post_id ) { return new WP_Error( 'missing', 'Need a valid URL and post ID...' ); }
1110
+	public function attach_external_image2($url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array()) {
1111
+		if (!$url || !$post_id) { return new WP_Error('missing', 'Need a valid URL and post ID...'); }
1112 1112
 
1113
-		require_once( ABSPATH . 'wp-admin/includes/file.php' );
1114
-		require_once( ABSPATH . 'wp-admin/includes/media.php' );
1115
-		require_once( ABSPATH . 'wp-admin/includes/image.php' );
1113
+		require_once(ABSPATH.'wp-admin/includes/file.php');
1114
+		require_once(ABSPATH.'wp-admin/includes/media.php');
1115
+		require_once(ABSPATH.'wp-admin/includes/image.php');
1116 1116
 		// Download file to temp location, returns full server path to temp file
1117 1117
 		//$tmp = download_url( $url );
1118 1118
 
1119 1119
 		//var_dump($tmp);
1120
-		$tmp = tempnam( '/tmp', 'FOO' );
1120
+		$tmp = tempnam('/tmp', 'FOO');
1121 1121
 
1122
-		$image = file_get_contents( $url );
1123
-		file_put_contents( $tmp, $image );
1124
-		chmod( $tmp,'777' );
1122
+		$image = file_get_contents($url);
1123
+		file_put_contents($tmp, $image);
1124
+		chmod($tmp, '777');
1125 1125
 
1126
-		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
1127
-		$url_filename = basename( $matches[0] );
1128
-		$url_filename = str_replace( '%20','_',$url_filename );
1126
+		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
1127
+		$url_filename = basename($matches[0]);
1128
+		$url_filename = str_replace('%20', '_', $url_filename);
1129 1129
 		// extract filename from url for title
1130
-		$url_type = wp_check_filetype( $url_filename );                                           // determine file type (ext and mime/type)
1130
+		$url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type)
1131 1131
 
1132 1132
 		// override filename if given, reconstruct server path
1133
-		if ( ! empty( $filename ) && ' ' != $filename ) {
1134
-			$filename = sanitize_file_name( $filename );
1135
-			$tmppath = pathinfo( $tmp );
1133
+		if (!empty($filename) && ' ' != $filename) {
1134
+			$filename = sanitize_file_name($filename);
1135
+			$tmppath = pathinfo($tmp);
1136 1136
 
1137 1137
 			$extension = '';
1138
-			if ( isset( $tmppath['extension'] ) ) {
1138
+			if (isset($tmppath['extension'])) {
1139 1139
 				$extension = $tmppath['extension'];
1140 1140
 			}
1141 1141
 
1142
-			$new = $tmppath['dirname'] . '/' . $filename . '.' . $extension;
1143
-			rename( $tmp, $new );                                                                 // renames temp file on server
1144
-			$tmp = $new;                                                                        // push new filename (in path) to be used in file array later
1142
+			$new = $tmppath['dirname'].'/'.$filename.'.'.$extension;
1143
+			rename($tmp, $new); // renames temp file on server
1144
+			$tmp = $new; // push new filename (in path) to be used in file array later
1145 1145
 		}
1146 1146
 
1147 1147
 		// assemble file data (should be built like $_FILES since wp_handle_sideload() will be using)
1148
-		$file_array['tmp_name'] = $tmp;                                                         // full server path to temp file
1148
+		$file_array['tmp_name'] = $tmp; // full server path to temp file
1149 1149
 
1150
-		if ( ! empty( $filename ) && ' ' != $filename ) {
1151
-			$file_array['name'] = $filename . '.' . $url_type['ext'];                           // user given filename for title, add original URL extension
1152
-		} else {
1153
-			$file_array['name'] = $url_filename;                                                // just use original URL filename
1150
+		if (!empty($filename) && ' ' != $filename) {
1151
+			$file_array['name'] = $filename.'.'.$url_type['ext']; // user given filename for title, add original URL extension
1152
+		}else {
1153
+			$file_array['name'] = $url_filename; // just use original URL filename
1154 1154
 		}
1155 1155
 
1156 1156
 		// set additional wp_posts columns
1157
-		if ( empty( $post_data['post_title'] ) ) {
1157
+		if (empty($post_data['post_title'])) {
1158 1158
 
1159
-			$url_filename = str_replace( '%20',' ',$url_filename );
1159
+			$url_filename = str_replace('%20', ' ', $url_filename);
1160 1160
 
1161
-			$post_data['post_title'] = basename( $url_filename, '.' . $url_type['ext'] );         // just use the original filename (no extension)
1161
+			$post_data['post_title'] = basename($url_filename, '.'.$url_type['ext']); // just use the original filename (no extension)
1162 1162
 		}
1163 1163
 
1164 1164
 		// make sure gets tied to parent
1165
-		if ( empty( $post_data['post_parent'] ) ) {
1165
+		if (empty($post_data['post_parent'])) {
1166 1166
 			$post_data['post_parent'] = $post_id;
1167 1167
 		}
1168 1168
 
1169 1169
 		// required libraries for media_handle_sideload
1170 1170
 
1171 1171
 		// do the validation and storage stuff
1172
-		$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
1172
+		$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
1173 1173
 
1174 1174
 		// If error storing permanently, unlink
1175
-		if ( is_wp_error( $att_id ) ) {
1176
-			unlink( $file_array['tmp_name'] );   // clean up
1175
+		if (is_wp_error($att_id)) {
1176
+			unlink($file_array['tmp_name']); // clean up
1177 1177
 			return false; // output wp_error
1178 1178
 			//return $att_id; // output wp_error
1179 1179
 		}
@@ -1201,35 +1201,35 @@  discard block
 block discarded – undo
1201 1201
 	/**
1202 1202
 	 * Formats the row for the completed list.
1203 1203
 	 */
1204
-	public function format_completed_row( $response ) {
1204
+	public function format_completed_row($response) {
1205 1205
 		// @codingStandardsIgnoreLine
1206
-		echo '<li class="post-' . $response . '"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="' . get_permalink( $response ) . '">' . get_the_title( $response ) . '</a></li>';
1206
+		echo '<li class="post-'.$response.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($response).'">'.get_the_title($response).'</a></li>';
1207 1207
 	}
1208 1208
 
1209 1209
 	/**
1210 1210
 	 * Formats the error.
1211 1211
 	 */
1212
-	public function format_error( $response ) {
1212
+	public function format_error($response) {
1213 1213
 		// @codingStandardsIgnoreLine
1214
-		echo '<li class="post-error"><span class="dashicons dashicons-no"></span>' . $response . '</li>';
1214
+		echo '<li class="post-error"><span class="dashicons dashicons-no"></span>'.$response.'</li>';
1215 1215
 	}
1216 1216
 
1217 1217
 	/**
1218 1218
 	 * Does a multine search
1219 1219
 	 */
1220
-	public function multineedle_stripos( $haystack, $needles, $offset = 0 ) {
1220
+	public function multineedle_stripos($haystack, $needles, $offset = 0) {
1221 1221
 		$found = false;
1222
-		$needle_count = count( $needles );
1222
+		$needle_count = count($needles);
1223 1223
 
1224
-		foreach ( $needles as $needle ) {
1225
-			if ( false !== stripos( $haystack, $needle, $offset ) ) {
1224
+		foreach ($needles as $needle) {
1225
+			if (false !== stripos($haystack, $needle, $offset)) {
1226 1226
 				$found[] = true;
1227 1227
 			}
1228 1228
 		}
1229 1229
 
1230
-		if ( false !== $found && count( $found ) === $needle_count ) {
1230
+		if (false !== $found && count($found) === $needle_count) {
1231 1231
 			return true;
1232
-		} else {
1232
+		}else {
1233 1233
 			return false;
1234 1234
 		}
1235 1235
 	}
@@ -1237,7 +1237,7 @@  discard block
 block discarded – undo
1237 1237
 	/**
1238 1238
 	 * Grab all the current accommodation posts via the lsx_wetu_id field.
1239 1239
 	 */
1240
-	public function find_current_accommodation( $post_type = 'accommodation' ) {
1240
+	public function find_current_accommodation($post_type = 'accommodation') {
1241 1241
 		global $wpdb;
1242 1242
 		$return = array();
1243 1243
 
@@ -1256,9 +1256,9 @@  discard block
 block discarded – undo
1256 1256
 		");
1257 1257
 		// @codingStandardsIgnoreEnd
1258 1258
 
1259
-		if ( null !== $current_accommodation && ! empty( $current_accommodation ) ) {
1260
-			foreach ( $current_accommodation as $accom ) {
1261
-				$return[ $accom->meta_value ] = $accom;
1259
+		if (null !== $current_accommodation && !empty($current_accommodation)) {
1260
+			foreach ($current_accommodation as $accom) {
1261
+				$return[$accom->meta_value] = $accom;
1262 1262
 			}
1263 1263
 		}
1264 1264
 
@@ -1268,20 +1268,20 @@  discard block
 block discarded – undo
1268 1268
 	/**
1269 1269
 	 * Set the Video date
1270 1270
 	 */
1271
-	public function set_video_data( $data, $id ) {
1272
-		if ( ! empty( $data[0]['content']['youtube_videos'] ) && is_array( $data[0]['content']['youtube_videos'] ) ) {
1271
+	public function set_video_data($data, $id) {
1272
+		if (!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])) {
1273 1273
 			$videos = false;
1274 1274
 
1275
-			foreach ( $data[0]['content']['youtube_videos'] as $video ) {
1275
+			foreach ($data[0]['content']['youtube_videos'] as $video) {
1276 1276
 				$temp_video = array();
1277 1277
 
1278
-				if ( isset( $video['label'] ) ) {
1278
+				if (isset($video['label'])) {
1279 1279
 					$temp_video['title'] = $video['label'];
1280 1280
 				}
1281
-				if ( isset( $video['description'] ) ) {
1282
-					$temp_video['description'] = strip_tags( $video['description'] );
1281
+				if (isset($video['description'])) {
1282
+					$temp_video['description'] = strip_tags($video['description']);
1283 1283
 				}
1284
-				if ( isset( $video['url'] ) ) {
1284
+				if (isset($video['url'])) {
1285 1285
 					$temp_video['url'] = $video['url'];
1286 1286
 				}
1287 1287
 
@@ -1289,24 +1289,24 @@  discard block
 block discarded – undo
1289 1289
 				$videos[] = $temp_video;
1290 1290
 			}
1291 1291
 
1292
-			if ( false !== $id && '0' !== $id ) {
1293
-				delete_post_meta( $id, 'videos' );
1292
+			if (false !== $id && '0' !== $id) {
1293
+				delete_post_meta($id, 'videos');
1294 1294
 			}
1295 1295
 
1296
-			foreach ( $videos as $video ) {
1297
-				add_post_meta( $id,'videos',$video,false );
1296
+			foreach ($videos as $video) {
1297
+				add_post_meta($id, 'videos', $video, false);
1298 1298
 			}
1299 1299
 		}
1300 1300
 	}
1301 1301
 
1302
-	public function shuffle_assoc( &$array ) {
1302
+	public function shuffle_assoc(&$array) {
1303 1303
 		$new = array();
1304
-		$keys = array_keys( $array );
1304
+		$keys = array_keys($array);
1305 1305
 
1306
-		shuffle( $keys );
1306
+		shuffle($keys);
1307 1307
 
1308
-		foreach ( $keys as $key ) {
1309
-			$new[ $key ] = $array[ $key ];
1308
+		foreach ($keys as $key) {
1309
+			$new[$key] = $array[$key];
1310 1310
 		}
1311 1311
 
1312 1312
 		$array = $new;
@@ -1320,29 +1320,29 @@  discard block
 block discarded – undo
1320 1320
 	public function update_options() {
1321 1321
 		$own = '';
1322 1322
 		$options = array();
1323
-		delete_option( 'lsx_ti_tours_api_options' );
1323
+		delete_option('lsx_ti_tours_api_options');
1324 1324
 
1325
-		if ( isset( $_GET['own'] ) ) {
1325
+		if (isset($_GET['own'])) {
1326 1326
 			$this->current_importer->url_qs .= '&own=true';
1327 1327
 			$options[] = 'own';
1328 1328
 		}
1329 1329
 
1330
-		if ( isset( $_GET['type'] ) && 'allitineraries' !== $_GET['type'] ) {
1331
-			$this->current_importer->url_qs .= '&type=' . implode( '', $_GET['type'] );
1332
-			$options[] = implode( '', $_GET['type'] );
1330
+		if (isset($_GET['type']) && 'allitineraries' !== $_GET['type']) {
1331
+			$this->current_importer->url_qs .= '&type='.implode('', $_GET['type']);
1332
+			$options[] = implode('', $_GET['type']);
1333 1333
 		}
1334 1334
 
1335 1335
 		$this->current_importer->url_qs .= '&results=2000';
1336 1336
 
1337
-		add_option( 'lsx_ti_tours_api_options', $options );
1337
+		add_option('lsx_ti_tours_api_options', $options);
1338 1338
 
1339
-		$data = wp_remote_get( $this->current_importer->url . '/V8/List?' . $this->current_importer->url_qs );
1340
-		$tours = json_decode( wp_remote_retrieve_body( $data ), true );
1339
+		$data = wp_remote_get($this->current_importer->url.'/V8/List?'.$this->current_importer->url_qs);
1340
+		$tours = json_decode(wp_remote_retrieve_body($data), true);
1341 1341
 
1342
-		if ( isset( $tours['error'] ) ) {
1342
+		if (isset($tours['error'])) {
1343 1343
 			return $tours['error'];
1344
-		} elseif ( isset( $tours['itineraries'] ) && ! empty( $tours['itineraries'] ) ) {
1345
-			set_transient( 'lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2 );
1344
+		} elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
1345
+			set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2);
1346 1346
 			return true;
1347 1347
 		}
1348 1348
 	}
Please login to merge, or discard this patch.
classes/class-wetu-importer-destination.php 1 patch
Spacing   +246 added lines, -246 removed lines patch added patch discarded remove patch
@@ -70,17 +70,17 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	public function set_variables() {
72 72
 		parent::set_variables();
73
-		$this->url    = 'https://wetu.com/API/Pins/' . $this->api_key;
73
+		$this->url    = 'https://wetu.com/API/Pins/'.$this->api_key;
74 74
 		$this->url_qs = 'all=include';
75
-		$temp_options = get_option( '_lsx-to_settings', false );
75
+		$temp_options = get_option('_lsx-to_settings', false);
76 76
 
77
-		if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) {
78
-			$this->options = $temp_options[ $this->plugin_slug ];
77
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
78
+			$this->options = $temp_options[$this->plugin_slug];
79 79
 		}
80 80
 
81
-		$destination_options = get_option( 'wetu_importer_destination_settings', false );
81
+		$destination_options = get_option('wetu_importer_destination_settings', false);
82 82
 
83
-		if ( false !== $destination_options ) {
83
+		if (false !== $destination_options) {
84 84
 			$this->destination_options = $destination_options;
85 85
 		}
86 86
 	}
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 			<?php $this->search_form(); ?>
95 95
 
96 96
 			<form method="get" action="" id="posts-filter">
97
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>"/>
97
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>"/>
98 98
 
99 99
 				<table class="wp-list-table widefat fixed posts">
100 100
 					<?php $this->table_header(); ?>
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 					<tr class="post-0 type-tour status-none" id="post-0">
104 104
 						<th class="check-column" scope="row">
105 105
 							<label for="cb-select-0"
106
-								   class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter', 'wetu-importer' ); ?></label>
106
+								   class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'wetu-importer'); ?></label>
107 107
 						</th>
108 108
 						<td class="post-title page-title column-title">
109 109
 							<strong>
110
-								<?php esc_html_e( 'Enter a title to search for', 'wetu-importer' ); ?>
110
+								<?php esc_html_e('Enter a title to search for', 'wetu-importer'); ?>
111 111
 							</strong>
112 112
 						</td>
113 113
 						<td class="date column-date">
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 				</table>
123 123
 
124 124
 				<p><input class="button button-primary add" type="button"
125
-						  value="<?php esc_html_e( 'Add to List', 'wetu-importer' ); ?>"/>
125
+						  value="<?php esc_html_e('Add to List', 'wetu-importer'); ?>"/>
126 126
 					<input class="button button-primary clear" type="button"
127
-						   value="<?php esc_html_e( 'Clear', 'wetu-importer' ); ?>"/>
127
+						   value="<?php esc_html_e('Clear', 'wetu-importer'); ?>"/>
128 128
 				</p>
129 129
 			</form>
130 130
 
@@ -134,118 +134,118 @@  discard block
 block discarded – undo
134 134
 
135 135
 					<div class="row">
136 136
 						<div class="settings-all" style="width:30%;display:block;float:left;">
137
-							<h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3>
137
+							<h3><?php esc_html_e('What content to Sync from WETU'); ?></h3>
138 138
 							<ul>
139 139
 								<li>
140
-									<input class="content select-all" <?php $this->checked( $this->destination_options, 'all' ); ?>
140
+									<input class="content select-all" <?php $this->checked($this->destination_options, 'all'); ?>
141 141
 										   type="checkbox" name="content[]"
142
-										   value="all"/> <?php esc_html_e( 'Select All', 'wetu-importer' ); ?></li>
143
-								<?php if ( isset( $this->options ) && 'on' !== $this->options['disable_destination_descriptions'] ) { ?>
142
+										   value="all"/> <?php esc_html_e('Select All', 'wetu-importer'); ?></li>
143
+								<?php if (isset($this->options) && 'on' !== $this->options['disable_destination_descriptions']) { ?>
144 144
 								<li>
145
-									<input class="content" <?php $this->checked( $this->destination_options, 'description' ); ?>
145
+									<input class="content" <?php $this->checked($this->destination_options, 'description'); ?>
146 146
 										   type="checkbox" name="content[]"
147
-										   value="description"/> <?php esc_html_e( 'Description', 'wetu-importer' ); ?></li>
147
+										   value="description"/> <?php esc_html_e('Description', 'wetu-importer'); ?></li>
148 148
 								<?php } ?>
149 149
 
150 150
 								<li>
151
-									<input class="content" <?php $this->checked( $this->destination_options, 'gallery' ); ?>
151
+									<input class="content" <?php $this->checked($this->destination_options, 'gallery'); ?>
152 152
 										   type="checkbox" name="content[]"
153
-										   value="gallery"/> <?php esc_html_e( 'Main Gallery', 'wetu-importer' ); ?></li>
154
-								<?php if ( class_exists( 'LSX_TO_Maps' ) ) { ?>
153
+										   value="gallery"/> <?php esc_html_e('Main Gallery', 'wetu-importer'); ?></li>
154
+								<?php if (class_exists('LSX_TO_Maps')) { ?>
155 155
 									<li>
156
-										<input class="content" <?php $this->checked( $this->destination_options, 'location' ); ?>
156
+										<input class="content" <?php $this->checked($this->destination_options, 'location'); ?>
157 157
 											   type="checkbox" name="content[]"
158
-											   value="location"/> <?php esc_html_e( 'Location', 'wetu-importer' ); ?></li>
158
+											   value="location"/> <?php esc_html_e('Location', 'wetu-importer'); ?></li>
159 159
 								<?php } ?>
160 160
 
161
-								<?php if ( class_exists( 'LSX_TO_Videos' ) ) { ?>
161
+								<?php if (class_exists('LSX_TO_Videos')) { ?>
162 162
 									<li>
163
-										<input class="content" <?php $this->checked( $this->destination_options, 'videos' ); ?>
163
+										<input class="content" <?php $this->checked($this->destination_options, 'videos'); ?>
164 164
 											   type="checkbox" name="content[]"
165
-											   value="videos"/> <?php esc_html_e( 'Videos', 'wetu-importer' ); ?></li>
165
+											   value="videos"/> <?php esc_html_e('Videos', 'wetu-importer'); ?></li>
166 166
 								<?php } ?>
167 167
 
168 168
 							</ul>
169
-							<h4><?php esc_html_e( 'Additional Content' ); ?></h4>
169
+							<h4><?php esc_html_e('Additional Content'); ?></h4>
170 170
 							<ul>
171 171
 								<li>
172
-									<input class="content" <?php $this->checked( $this->destination_options, 'country' ); ?>
172
+									<input class="content" <?php $this->checked($this->destination_options, 'country'); ?>
173 173
 										   type="checkbox" name="content[]"
174
-										   value="country"/> <?php esc_html_e( 'Set Country', 'wetu-importer' ); ?></li>
174
+										   value="country"/> <?php esc_html_e('Set Country', 'wetu-importer'); ?></li>
175 175
 								<li>
176
-									<input class="content" <?php $this->checked( $this->destination_options, 'continent' ); ?>
176
+									<input class="content" <?php $this->checked($this->destination_options, 'continent'); ?>
177 177
 										   type="checkbox" name="content[]"
178
-										   value="continent"/> <?php esc_html_e( 'Set Continent', 'wetu-importer' ); ?></li>
178
+										   value="continent"/> <?php esc_html_e('Set Continent', 'wetu-importer'); ?></li>
179 179
 
180 180
 								<li>
181
-									<input class="content" <?php $this->checked( $this->destination_options, 'featured_image' ); ?>
181
+									<input class="content" <?php $this->checked($this->destination_options, 'featured_image'); ?>
182 182
 										   type="checkbox" name="content[]"
183
-										   value="featured_image"/> <?php esc_html_e( 'Set Featured Image', 'wetu-importer' ); ?>
183
+										   value="featured_image"/> <?php esc_html_e('Set Featured Image', 'wetu-importer'); ?>
184 184
 								</li>
185
-								<?php if ( class_exists( 'LSX_Banners' ) ) { ?>
185
+								<?php if (class_exists('LSX_Banners')) { ?>
186 186
 									<li>
187
-										<input class="content" <?php $this->checked( $this->destination_options, 'banner_image' ); ?>
187
+										<input class="content" <?php $this->checked($this->destination_options, 'banner_image'); ?>
188 188
 											   type="checkbox" name="content[]"
189
-											   value="banner_image"/> <?php esc_html_e( 'Set Banner Image', 'wetu-importer' ); ?>
189
+											   value="banner_image"/> <?php esc_html_e('Set Banner Image', 'wetu-importer'); ?>
190 190
 									</li>
191 191
 									<li>
192
-										<input class="content" <?php $this->checked( $this->destination_options, 'unique_banner_image' ); ?>
192
+										<input class="content" <?php $this->checked($this->destination_options, 'unique_banner_image'); ?>
193 193
 											   type="checkbox" name="content[]"
194
-											   value="unique_banner_image"/> <?php esc_html_e( 'Use the WETU banner field', 'wetu-importer' ); ?>
194
+											   value="unique_banner_image"/> <?php esc_html_e('Use the WETU banner field', 'wetu-importer'); ?>
195 195
 									</li>
196 196
 								<?php } ?>
197 197
 
198 198
 								<li>
199
-									<input class="content" <?php $this->checked( $this->destination_options, 'strip_tags' ); ?>
199
+									<input class="content" <?php $this->checked($this->destination_options, 'strip_tags'); ?>
200 200
 										   type="checkbox" name="content[]"
201
-										   value="strip_tags"/> <?php esc_html_e( 'Strip HTML from the description', 'wetu-importer' ); ?></li>
201
+										   value="strip_tags"/> <?php esc_html_e('Strip HTML from the description', 'wetu-importer'); ?></li>
202 202
 							</ul>
203 203
 						</div>
204 204
 						<div class="settings-all" style="width:30%;display:block;float:left;">
205
-							<h3><?php esc_html_e( 'Travel Information' ); ?></h3>
205
+							<h3><?php esc_html_e('Travel Information'); ?></h3>
206 206
 							<ul>
207 207
 								<li>
208
-									<input class="content" <?php $this->checked( $this->destination_options, 'electricity' ); ?>
208
+									<input class="content" <?php $this->checked($this->destination_options, 'electricity'); ?>
209 209
 										   type="checkbox" name="content[]"
210
-										   value="electricity"/> <?php esc_html_e( 'Electricity', 'wetu-importer' ); ?></li>
210
+										   value="electricity"/> <?php esc_html_e('Electricity', 'wetu-importer'); ?></li>
211 211
 								<li>
212
-									<input class="content" <?php $this->checked( $this->destination_options, 'banking' ); ?>
212
+									<input class="content" <?php $this->checked($this->destination_options, 'banking'); ?>
213 213
 										   type="checkbox" name="content[]"
214
-										   value="banking"/> <?php esc_html_e( 'Banking', 'wetu-importer' ); ?></li>
214
+										   value="banking"/> <?php esc_html_e('Banking', 'wetu-importer'); ?></li>
215 215
 								<li>
216
-									<input class="content" <?php $this->checked( $this->destination_options, 'cuisine' ); ?>
216
+									<input class="content" <?php $this->checked($this->destination_options, 'cuisine'); ?>
217 217
 										   type="checkbox" name="content[]"
218
-										   value="cuisine"/> <?php esc_html_e( 'Cuisine', 'wetu-importer' ); ?></li>
218
+										   value="cuisine"/> <?php esc_html_e('Cuisine', 'wetu-importer'); ?></li>
219 219
 								<li>
220
-									<input class="content" <?php $this->checked( $this->destination_options, 'climate' ); ?>
220
+									<input class="content" <?php $this->checked($this->destination_options, 'climate'); ?>
221 221
 										   type="checkbox" name="content[]"
222
-										   value="climate"/> <?php esc_html_e( 'Climate', 'wetu-importer' ); ?></li>
222
+										   value="climate"/> <?php esc_html_e('Climate', 'wetu-importer'); ?></li>
223 223
 								<li>
224
-									<input class="content" <?php $this->checked( $this->destination_options, 'transport' ); ?>
224
+									<input class="content" <?php $this->checked($this->destination_options, 'transport'); ?>
225 225
 										   type="checkbox" name="content[]"
226
-										   value="transport"/> <?php esc_html_e( 'Transport', 'wetu-importer' ); ?></li>
227
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'dress' ); ?>
226
+										   value="transport"/> <?php esc_html_e('Transport', 'wetu-importer'); ?></li>
227
+								<li><input class="content" <?php $this->checked($this->destination_options, 'dress'); ?>
228 228
 										   type="checkbox" name="content[]"
229
-										   value="dress"/> <?php esc_html_e( 'Dress', 'wetu-importer' ); ?></li>
230
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'health' ); ?>
229
+										   value="dress"/> <?php esc_html_e('Dress', 'wetu-importer'); ?></li>
230
+								<li><input class="content" <?php $this->checked($this->destination_options, 'health'); ?>
231 231
 										   type="checkbox" name="content[]"
232
-										   value="health"/> <?php esc_html_e( 'Health', 'wetu-importer' ); ?></li>
233
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'safety' ); ?>
232
+										   value="health"/> <?php esc_html_e('Health', 'wetu-importer'); ?></li>
233
+								<li><input class="content" <?php $this->checked($this->destination_options, 'safety'); ?>
234 234
 										   type="checkbox" name="content[]"
235
-										   value="safety"/> <?php esc_html_e( 'Safety', 'wetu-importer' ); ?></li>
236
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'visa' ); ?>
235
+										   value="safety"/> <?php esc_html_e('Safety', 'wetu-importer'); ?></li>
236
+								<li><input class="content" <?php $this->checked($this->destination_options, 'visa'); ?>
237 237
 										   type="checkbox" name="content[]"
238
-										   value="visa"/> <?php esc_html_e( 'Visa', 'wetu-importer' ); ?></li>
239
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'additional_info' ); ?>
238
+										   value="visa"/> <?php esc_html_e('Visa', 'wetu-importer'); ?></li>
239
+								<li><input class="content" <?php $this->checked($this->destination_options, 'additional_info'); ?>
240 240
 										   type="checkbox" name="content[]"
241
-										   value="additional_info"/> <?php esc_html_e( 'General', 'wetu-importer' ); ?></li>
241
+										   value="additional_info"/> <?php esc_html_e('General', 'wetu-importer'); ?></li>
242 242
 							</ul>
243 243
 						</div>
244 244
 
245
-						<?php if ( class_exists( 'LSX_TO_Team' ) ) { ?>
245
+						<?php if (class_exists('LSX_TO_Team')) { ?>
246 246
 							<div style="width:30%;display:block;float:left;">
247
-								<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3>
248
-								<?php $this->team_member_checkboxes( $this->destination_options ); ?>
247
+								<h3><?php esc_html_e('Assign a Team Member'); ?></h3>
248
+								<?php $this->team_member_checkboxes($this->destination_options); ?>
249 249
 							</div>
250 250
 						<?php } ?>
251 251
 
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
 					</div>
254 254
 
255 255
 
256
-					<h3><?php esc_html_e( 'Your List' ); ?></h3>
256
+					<h3><?php esc_html_e('Your List'); ?></h3>
257 257
 					<p><input class="button button-primary" type="submit"
258
-							  value="<?php esc_html_e( 'Sync', 'wetu-importer' ); ?>"/></p>
258
+							  value="<?php esc_html_e('Sync', 'wetu-importer'); ?>"/></p>
259 259
 					<table class="wp-list-table widefat fixed posts">
260 260
 						<?php $this->table_header(); ?>
261 261
 
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
 					</table>
269 269
 
270 270
 					<p><input class="button button-primary" type="submit"
271
-							  value="<?php esc_html_e( 'Sync', 'wetu-importer' ); ?>"/></p>
271
+							  value="<?php esc_html_e('Sync', 'wetu-importer'); ?>"/></p>
272 272
 				</form>
273 273
 			</div>
274 274
 
275 275
 			<div style="display:none;" class="completed-list-wrapper">
276
-				<h3><?php esc_html_e( 'Completed' ); ?></h3>
276
+				<h3><?php esc_html_e('Completed'); ?></h3>
277 277
 				<ul>
278 278
 				</ul>
279 279
 			</div>
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	/**
285 285
 	 * Grab all the current destination posts via the lsx_wetu_id field.
286 286
 	 */
287
-	public function find_current_destination( $post_type = 'destination' ) {
287
+	public function find_current_destination($post_type = 'destination') {
288 288
 		global $wpdb;
289 289
 		$return = array();
290 290
 
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
 		");
304 304
 		// @codingStandardsIgnoreEnd
305 305
 
306
-		if ( null !== $current_destination && ! empty( $current_destination ) ) {
307
-			foreach ( $current_destination as $accom ) {
308
-				$return[ $accom->meta_value ] = $accom;
306
+		if (null !== $current_destination && !empty($current_destination)) {
307
+			foreach ($current_destination as $accom) {
308
+				$return[$accom->meta_value] = $accom;
309 309
 			}
310 310
 		}
311 311
 
@@ -319,119 +319,119 @@  discard block
 block discarded – undo
319 319
 		$return = false;
320 320
 
321 321
 		// @codingStandardsIgnoreLine
322
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_tour_importer' && isset( $_POST['type'] ) && $_POST['type'] === 'destination' ) {
322
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'destination') {
323 323
 
324 324
 			$searched_items = false;
325 325
 
326 326
 			// @codingStandardsIgnoreLine
327
-			if ( isset( $_POST['keyword'] ) ) {
327
+			if (isset($_POST['keyword'])) {
328 328
 				// @codingStandardsIgnoreLine
329 329
 				$keyphrases = $_POST['keyword'];
330
-			} else {
331
-				$keyphrases = array( 0 );
330
+			}else {
331
+				$keyphrases = array(0);
332 332
 			}
333 333
 
334
-			if ( ! is_array( $keyphrases ) ) {
335
-				$keyphrases = array( $keyphrases );
334
+			if (!is_array($keyphrases)) {
335
+				$keyphrases = array($keyphrases);
336 336
 			}
337
-			foreach ( $keyphrases as &$keyword ) {
338
-				$keyword = ltrim( rtrim( $keyword ) );
337
+			foreach ($keyphrases as &$keyword) {
338
+				$keyword = ltrim(rtrim($keyword));
339 339
 			}
340 340
 
341 341
 			$post_status = false;
342 342
 
343
-			if ( in_array( 'publish', $keyphrases ) ) {
343
+			if (in_array('publish', $keyphrases)) {
344 344
 				$post_status = 'publish';
345 345
 			}
346
-			if ( in_array( 'pending', $keyphrases ) ) {
346
+			if (in_array('pending', $keyphrases)) {
347 347
 				$post_status = 'pending';
348 348
 			}
349
-			if ( in_array( 'draft', $keyphrases ) ) {
349
+			if (in_array('draft', $keyphrases)) {
350 350
 				$post_status = 'draft';
351 351
 			}
352
-			if ( in_array( 'import', $keyphrases ) ) {
352
+			if (in_array('import', $keyphrases)) {
353 353
 				$post_status = 'import';
354 354
 			}
355 355
 
356 356
 			// If there is a post status use it.
357
-			if ( false !== $post_status ) {
357
+			if (false !== $post_status) {
358 358
 
359 359
 				$accommodation = array();
360
-				$current_accommodation = $this->find_current_accommodation( 'destination' );
361
-				if ( ! empty( $current_accommodation ) ) {
362
-					foreach ( $current_accommodation as $cs_key => $ccs_id ) {
363
-						$accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id );
360
+				$current_accommodation = $this->find_current_accommodation('destination');
361
+				if (!empty($current_accommodation)) {
362
+					foreach ($current_accommodation as $cs_key => $ccs_id) {
363
+						$accommodation[] = $this->prepare_row_attributes($cs_key, $ccs_id->post_id);
364 364
 					}
365 365
 				}
366 366
 
367 367
 				// Run through each accommodation and use it.
368
-				if ( ! empty( $accommodation ) ) {
369
-					foreach ( $accommodation as $row_key => $row ) {
370
-						if ( 'import' === $post_status ) {
371
-
372
-							if ( is_array( $this->queued_imports ) && in_array( $row['post_id'], $this->queued_imports ) ) {
373
-								$current_status = get_post_status( $row['post_id'] );
374
-								if ( 'draft' === $current_status ) {
375
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
368
+				if (!empty($accommodation)) {
369
+					foreach ($accommodation as $row_key => $row) {
370
+						if ('import' === $post_status) {
371
+
372
+							if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) {
373
+								$current_status = get_post_status($row['post_id']);
374
+								if ('draft' === $current_status) {
375
+									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
376 376
 								}
377
-							} else {
377
+							}else {
378 378
 								continue;
379 379
 							}
380
-						} else {
381
-							if ( 0 === $row['post_id'] ) {
380
+						}else {
381
+							if (0 === $row['post_id']) {
382 382
 								continue;
383
-							} else {
384
-								$current_status = get_post_status( $row['post_id'] );
383
+							}else {
384
+								$current_status = get_post_status($row['post_id']);
385 385
 
386
-								if ( $current_status !== $post_status ) {
386
+								if ($current_status !== $post_status) {
387 387
 									continue;
388 388
 								}
389 389
 							}
390
-							$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
390
+							$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
391 391
 						}
392 392
 					}
393 393
 				}
394
-			} else {
394
+			}else {
395 395
 
396
-				$key_string_search = implode( '+', $keyphrases );
397
-				$search_data = file_get_contents( $this->url . '/Search/' . $key_string_search . '/?all=include' );
398
-				$search_data = json_decode( $search_data, true );
396
+				$key_string_search = implode('+', $keyphrases);
397
+				$search_data = file_get_contents($this->url.'/Search/'.$key_string_search.'/?all=include');
398
+				$search_data = json_decode($search_data, true);
399 399
 
400
-				if ( ! isset( $search_data['error'] ) ) {
401
-					foreach ( $search_data as $sdata ) {
400
+				if (!isset($search_data['error'])) {
401
+					foreach ($search_data as $sdata) {
402 402
 
403
-						if ( 'Destination' !== trim( $sdata['type'] ) ) {
403
+						if ('Destination' !== trim($sdata['type'])) {
404 404
 							continue;
405 405
 						}
406 406
 
407
-						$temp_id = $this->get_post_id_by_key_value( $sdata['id'] );
408
-						if ( false === $temp_id ) {
407
+						$temp_id = $this->get_post_id_by_key_value($sdata['id']);
408
+						if (false === $temp_id) {
409 409
 							$sdata['post_id'] = 0;
410
-						} else {
410
+						}else {
411 411
 							$sdata['post_id'] = $temp_id;
412 412
 						}
413
-						$searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata );
413
+						$searched_items[sanitize_title($sdata['name']).'-'.$sdata['id']] = $this->format_row($sdata);
414 414
 					}
415 415
 				}
416 416
 			}
417 417
 
418
-			if ( false !== $searched_items ) {
419
-				ksort( $searched_items );
420
-				$return = implode( $searched_items );
418
+			if (false !== $searched_items) {
419
+				ksort($searched_items);
420
+				$return = implode($searched_items);
421 421
 			}
422 422
 
423
-			print_r( $return );
423
+			print_r($return);
424 424
 		}
425 425
 
426 426
 		die();
427 427
 	}
428 428
 
429
-	public function prepare_row_attributes( $cs_key, $ccs_id ) {
429
+	public function prepare_row_attributes($cs_key, $ccs_id) {
430 430
 		$row_item = array(
431 431
 			'id' => $cs_key,
432 432
 			'type' => 'Destination',
433
-			'name' => get_the_title( $ccs_id ),
434
-			'last_modified' => date( 'Y-m-d', strtotime( 'now' ) ),
433
+			'name' => get_the_title($ccs_id),
434
+			'last_modified' => date('Y-m-d', strtotime('now')),
435 435
 			'post_id' => $ccs_id,
436 436
 		);
437 437
 		return $row_item;
@@ -440,28 +440,28 @@  discard block
 block discarded – undo
440 440
 	/**
441 441
 	 * Formats the row for output on the screen.
442 442
 	 */
443
-	public function format_row( $row = false ) {
444
-		if ( false !== $row ) {
443
+	public function format_row($row = false) {
444
+		if (false !== $row) {
445 445
 
446 446
 			$status = 'import';
447
-			if ( 0 !== $row['post_id'] ) {
448
-				$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>';
447
+			if (0 !== $row['post_id']) {
448
+				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
449 449
 			}
450 450
 
451 451
 			$row_html = '
452
-			<tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '">
452
+			<tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'">
453 453
 				<th class="check-column" scope="row">
454
-					<label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label>
455
-					<input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '">
454
+					<label for="cb-select-' . $row['id'].'" class="screen-reader-text">'.$row['name'].'</label>
455
+					<input type="checkbox" data-identifier="' . $row['id'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['id'].'">
456 456
 				</th>
457 457
 				<td class="post-title page-title column-title">
458
-					<strong>' . $row['name'] . '</strong> - ' . $status . '
458
+					<strong>' . $row['name'].'</strong> - '.$status.'
459 459
 				</td>
460 460
 				<td class="date column-date">
461
-					<abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified
461
+					<abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
462 462
 				</td>
463 463
 				<td class="ssid column-ssid">
464
-					' . $row['id'] . '
464
+					' . $row['id'].'
465 465
 				</td>
466 466
 			</tr>';
467 467
 			return $row_html;
@@ -475,49 +475,49 @@  discard block
 block discarded – undo
475 475
 		$return = false;
476 476
 
477 477
 		// @codingStandardsIgnoreLine
478
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === 'destination' && isset( $_POST['wetu_id'] ) ) {
478
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'destination' && isset($_POST['wetu_id'])) {
479 479
 			// @codingStandardsIgnoreLine
480 480
 			$wetu_id = $_POST['wetu_id'];
481 481
 
482 482
 			// @codingStandardsIgnoreLine
483
-			if ( isset( $_POST['post_id'] ) ) {
483
+			if (isset($_POST['post_id'])) {
484 484
 				// @codingStandardsIgnoreLine
485 485
 				$post_id = $_POST['post_id'];
486
-				$this->current_post = get_post( $post_id );
487
-			} else {
486
+				$this->current_post = get_post($post_id);
487
+			}else {
488 488
 				$post_id = 0;
489 489
 			}
490 490
 
491 491
 			// @codingStandardsIgnoreLine
492
-			if ( isset( $_POST['team_members'] ) ) {
492
+			if (isset($_POST['team_members'])) {
493 493
 				// @codingStandardsIgnoreLine
494 494
 				$team_members = $_POST['team_members'];
495
-			} else {
495
+			}else {
496 496
 				$team_members = false;
497 497
 			}
498 498
 
499 499
 			$safari_brands = false;
500 500
 
501
-			delete_option( 'wetu_importer_destination_settings' );
501
+			delete_option('wetu_importer_destination_settings');
502 502
 
503 503
 			// @codingStandardsIgnoreLine
504
-			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
504
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
505 505
 				// @codingStandardsIgnoreLine
506 506
 				$content = $_POST['content'];
507
-				add_option( 'wetu_importer_destination_settings', $content );
508
-			} else {
507
+				add_option('wetu_importer_destination_settings', $content);
508
+			}else {
509 509
 				$content = false;
510 510
 			}
511 511
 
512
-			$jdata = wp_remote_get( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
512
+			$jdata = wp_remote_get($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
513 513
 
514
-			if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
515
-				$adata = json_decode( $jdata, true );
516
-				$return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands );
517
-				$this->remove_from_queue( $return );
518
-				$this->format_completed_row( $return );
519
-			} else {
520
-				$this->format_error( esc_html__( 'There was a problem importing your destination, please try refreshing the page.', 'wetu-importer' ) );
514
+			if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
515
+				$adata = json_decode($jdata, true);
516
+				$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
517
+				$this->remove_from_queue($return);
518
+				$this->format_completed_row($return);
519
+			}else {
520
+				$this->format_error(esc_html__('There was a problem importing your destination, please try refreshing the page.', 'wetu-importer'));
521 521
 			}
522 522
 		}
523 523
 	}
@@ -525,14 +525,14 @@  discard block
 block discarded – undo
525 525
 	/**
526 526
 	 * Saves the queue to the option.
527 527
 	 */
528
-	public function remove_from_queue( $id ) {
529
-		if ( ! empty( $this->queued_imports ) ) {
528
+	public function remove_from_queue($id) {
529
+		if (!empty($this->queued_imports)) {
530 530
 			// @codingStandardsIgnoreLine
531
-			if ( ( $key = array_search( $id, $this->queued_imports ) ) !== false ) {
532
-				unset( $this->queued_imports[ $key ] );
531
+			if (($key = array_search($id, $this->queued_imports)) !== false) {
532
+				unset($this->queued_imports[$key]);
533 533
 
534
-				delete_option( 'wetu_importer_que' );
535
-				update_option( 'wetu_importer_que', $this->queued_imports );
534
+				delete_option('wetu_importer_que');
535
+				update_option('wetu_importer_que', $this->queued_imports);
536 536
 			}
537 537
 		}
538 538
 	}
@@ -540,8 +540,8 @@  discard block
 block discarded – undo
540 540
 	/**
541 541
 	 * Connect to wetu
542 542
 	 */
543
-	public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false ) {
544
-		if ( 'Destination' === trim( $data[0]['type'] ) ) {
543
+	public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false) {
544
+		if ('Destination' === trim($data[0]['type'])) {
545 545
 			$post_name = '';
546 546
 			$data_post_content = '';
547 547
 			$data_post_excerpt = '';
@@ -550,132 +550,132 @@  discard block
 block discarded – undo
550 550
 				'post_type' => 'destination',
551 551
 			);
552 552
 
553
-			if ( ! empty( $importable_content ) && in_array( 'country', $importable_content ) ) {
554
-				$parent = $this->check_for_parent( $data );
555
-				if ( false !== $parent ) {
553
+			if (!empty($importable_content) && in_array('country', $importable_content)) {
554
+				$parent = $this->check_for_parent($data);
555
+				if (false !== $parent) {
556 556
 					$post['post_parent'] = $parent;
557 557
 				}
558 558
 			}
559 559
 
560 560
 			// Set the post_content.
561
-			if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) {
562
-				if ( isset( $data[0]['content']['general_description'] ) ) {
561
+			if (!empty($importable_content) && in_array('description', $importable_content)) {
562
+				if (isset($data[0]['content']['general_description'])) {
563 563
 
564
-					if ( in_array( 'strip_tags', $importable_content ) ) {
565
-						$post['post_content'] = wp_strip_all_tags( $data[0]['content']['general_description'] );
566
-					} else {
564
+					if (in_array('strip_tags', $importable_content)) {
565
+						$post['post_content'] = wp_strip_all_tags($data[0]['content']['general_description']);
566
+					}else {
567 567
 						$post['post_content'] = $data[0]['content']['general_description'];
568 568
 					}
569 569
 				}
570 570
 			}
571 571
 
572
-			if ( false !== $id && '0' !== $id ) {
572
+			if (false !== $id && '0' !== $id) {
573 573
 				$post['ID'] = $id;
574 574
 
575
-				if ( isset( $data[0]['name'] ) ) {
575
+				if (isset($data[0]['name'])) {
576 576
 					$post['post_title'] = $data[0]['name'];
577 577
 					$post['post_status'] = 'publish';
578
-					$post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 );
578
+					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
579 579
 				}
580 580
 
581
-				$id = wp_update_post( $post );
582
-				$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
583
-				update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date );
584
-			} else {
581
+				$id = wp_update_post($post);
582
+				$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
583
+				update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
584
+			}else {
585 585
 				// Set the name.
586
-				if ( isset( $data[0]['name'] ) ) {
587
-					$post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 );
586
+				if (isset($data[0]['name'])) {
587
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
588 588
 				}
589 589
 
590 590
 				$post['post_name'] = $post_name;
591 591
 				$post['post_title'] = $data[0]['name'];
592 592
 				$post['post_status'] = 'publish';
593
-				$id = wp_insert_post( $post );
593
+				$id = wp_insert_post($post);
594 594
 
595 595
 				// Save the WETU ID and the Last date it was modified.
596
-				if ( false !== $id ) {
597
-					add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
598
-					add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) );
596
+				if (false !== $id) {
597
+					add_post_meta($id, 'lsx_wetu_id', $wetu_id);
598
+					add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']));
599 599
 				}
600 600
 			}
601 601
 
602
-			$this->find_attachments( $id );
602
+			$this->find_attachments($id);
603 603
 
604 604
 			// Set the team member if it is there.
605
-			if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) {
606
-				$this->set_team_member( $id, $team_members );
605
+			if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
606
+				$this->set_team_member($id, $team_members);
607 607
 			}
608 608
 
609
-			if ( class_exists( 'LSX_TO_Maps' ) ) {
610
-				$this->set_map_data( $data, $id, 9 );
609
+			if (class_exists('LSX_TO_Maps')) {
610
+				$this->set_map_data($data, $id, 9);
611 611
 			}
612 612
 
613 613
 			// Set the Room Data.
614
-			if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) {
615
-				$this->set_video_data( $data, $id );
614
+			if (false !== $importable_content && in_array('videos', $importable_content)) {
615
+				$this->set_video_data($data, $id);
616 616
 			}
617 617
 
618 618
 			// Set the Electricity.
619
-			if ( false !== $importable_content && in_array( 'electricity', $importable_content ) ) {
620
-				$this->set_travel_info( $data, $id, 'electricity', $importable_content );
619
+			if (false !== $importable_content && in_array('electricity', $importable_content)) {
620
+				$this->set_travel_info($data, $id, 'electricity', $importable_content);
621 621
 			}
622 622
 			// Set the cuisine.
623
-			if ( false !== $importable_content && in_array( 'cuisine', $importable_content ) ) {
624
-				$this->set_travel_info( $data, $id, 'cuisine', $importable_content );
623
+			if (false !== $importable_content && in_array('cuisine', $importable_content)) {
624
+				$this->set_travel_info($data, $id, 'cuisine', $importable_content);
625 625
 			}
626 626
 			// Set the banking.
627
-			if ( false !== $importable_content && in_array( 'banking', $importable_content ) ) {
628
-				$this->set_travel_info( $data, $id, 'banking', $importable_content );
627
+			if (false !== $importable_content && in_array('banking', $importable_content)) {
628
+				$this->set_travel_info($data, $id, 'banking', $importable_content);
629 629
 			}
630 630
 			// Set the transport.
631
-			if ( false !== $importable_content && in_array( 'transport', $importable_content ) ) {
632
-				$this->set_travel_info( $data, $id, 'transport', $importable_content );
631
+			if (false !== $importable_content && in_array('transport', $importable_content)) {
632
+				$this->set_travel_info($data, $id, 'transport', $importable_content);
633 633
 			}
634 634
 			// Set the dress.
635
-			if ( false !== $importable_content && in_array( 'dress', $importable_content ) ) {
636
-				$this->set_travel_info( $data, $id, 'dress', $importable_content );
635
+			if (false !== $importable_content && in_array('dress', $importable_content)) {
636
+				$this->set_travel_info($data, $id, 'dress', $importable_content);
637 637
 			}
638 638
 			// Set the climate.
639
-			if ( false !== $importable_content && in_array( 'climate', $importable_content ) ) {
640
-				$this->set_travel_info( $data, $id, 'climate', $importable_content );
639
+			if (false !== $importable_content && in_array('climate', $importable_content)) {
640
+				$this->set_travel_info($data, $id, 'climate', $importable_content);
641 641
 			}
642 642
 			// Set the Health.
643
-			if ( false !== $importable_content && in_array( 'health', $importable_content ) ) {
644
-				$this->set_travel_info( $data, $id, 'health', $importable_content );
643
+			if (false !== $importable_content && in_array('health', $importable_content)) {
644
+				$this->set_travel_info($data, $id, 'health', $importable_content);
645 645
 			}
646 646
 			// Set the Safety.
647
-			if ( false !== $importable_content && in_array( 'safety', $importable_content ) ) {
648
-				$this->set_travel_info( $data, $id, 'safety', $importable_content );
647
+			if (false !== $importable_content && in_array('safety', $importable_content)) {
648
+				$this->set_travel_info($data, $id, 'safety', $importable_content);
649 649
 			}
650 650
 			// Set the Visa.
651
-			if ( false !== $importable_content && in_array( 'visa', $importable_content ) ) {
652
-				$this->set_travel_info( $data, $id, 'visa', $importable_content );
651
+			if (false !== $importable_content && in_array('visa', $importable_content)) {
652
+				$this->set_travel_info($data, $id, 'visa', $importable_content);
653 653
 			}
654 654
 			// Set the General.
655
-			if ( false !== $importable_content && in_array( 'additional_info', $importable_content ) ) {
656
-				$this->set_travel_info( $data, $id, 'additional_info', $importable_content );
655
+			if (false !== $importable_content && in_array('additional_info', $importable_content)) {
656
+				$this->set_travel_info($data, $id, 'additional_info', $importable_content);
657 657
 			}
658 658
 
659 659
 			// Setup some default for use in the import.
660
-			if ( false !== $importable_content && (in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content )) ) {
661
-				$this->find_attachments( $id );
660
+			if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) {
661
+				$this->find_attachments($id);
662 662
 
663 663
 				// Set the featured image.
664
-				if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
665
-					$this->set_featured_image( $data, $id );
664
+				if (false !== $importable_content && in_array('featured_image', $importable_content)) {
665
+					$this->set_featured_image($data, $id);
666 666
 				}
667
-				if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
668
-					$this->set_banner_image( $data, $id, $importable_content );
667
+				if (false !== $importable_content && in_array('banner_image', $importable_content)) {
668
+					$this->set_banner_image($data, $id, $importable_content);
669 669
 				}
670 670
 				// Import the main gallery.
671
-				if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) {
672
-					$this->create_main_gallery( $data, $id );
671
+				if (false !== $importable_content && in_array('gallery', $importable_content)) {
672
+					$this->create_main_gallery($data, $id);
673 673
 				}
674 674
 			}
675 675
 
676 676
 			// Set the continent.
677
-			if ( false !== $importable_content && in_array( 'continent', $importable_content ) ) {
678
-				$this->set_continent( $data, $id );
677
+			if (false !== $importable_content && in_array('continent', $importable_content)) {
678
+				$this->set_continent($data, $id);
679 679
 			}
680 680
 		}
681 681
 
@@ -685,49 +685,49 @@  discard block
 block discarded – undo
685 685
 	/**
686 686
 	 * Set the team memberon each item.
687 687
 	 */
688
-	public function set_team_member( $id, $team_members ) {
689
-		delete_post_meta( $id, 'team_to_' . $this->tab_slug );
688
+	public function set_team_member($id, $team_members) {
689
+		delete_post_meta($id, 'team_to_'.$this->tab_slug);
690 690
 
691
-		foreach ( $team_members as $team ) {
692
-			add_post_meta( $id, 'team_to_' . $this->tab_slug, $team );
691
+		foreach ($team_members as $team) {
692
+			add_post_meta($id, 'team_to_'.$this->tab_slug, $team);
693 693
 		}
694 694
 	}
695 695
 
696 696
 	/**
697 697
 	 * Saves the room data
698 698
 	 */
699
-	public function set_travel_info( $data, $id, $meta_key, $importable = array( 'none' ) ) {
700
-		if ( ! empty( $data[0]['travel_information'] ) && isset( $data[0]['travel_information'][ $meta_key ] ) ) {
701
-			$content = $data[0]['travel_information'][ $meta_key ];
699
+	public function set_travel_info($data, $id, $meta_key, $importable = array('none')) {
700
+		if (!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])) {
701
+			$content = $data[0]['travel_information'][$meta_key];
702 702
 
703
-			if ( in_array( 'strip_tags', $importable ) ) {
704
-				$content = strip_tags( $content );
703
+			if (in_array('strip_tags', $importable)) {
704
+				$content = strip_tags($content);
705 705
 			}
706 706
 
707
-			$this->save_custom_field( $content, $meta_key, $id );
707
+			$this->save_custom_field($content, $meta_key, $id);
708 708
 		}
709 709
 	}
710 710
 
711 711
 	/**
712 712
 	 * Set the Travel Style
713 713
 	 */
714
-	public function set_continent( $data, $id ) {
714
+	public function set_continent($data, $id) {
715 715
 
716
-		if ( isset( $data[0]['position']['country'] ) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id'] ) {
716
+		if (isset($data[0]['position']['country']) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id']) {
717 717
 			//get the continent code.
718
-			$continent_code = to_continent_label( to_continent_code( to_country_data( $data[0]['position']['country'], false ) ) );
718
+			$continent_code = to_continent_label(to_continent_code(to_country_data($data[0]['position']['country'], false)));
719 719
 
720
-			if ( '' !== $continent_code ) {
720
+			if ('' !== $continent_code) {
721 721
 				// @codingStandardsIgnoreLine
722
-				if ( ! $term = term_exists( trim( $continent_code ), 'continent' ) ) {
723
-					$term = wp_insert_term( trim( $continent_code ), 'continent' );
722
+				if (!$term = term_exists(trim($continent_code), 'continent')) {
723
+					$term = wp_insert_term(trim($continent_code), 'continent');
724 724
 
725
-					if ( is_wp_error( $term ) ) {
725
+					if (is_wp_error($term)) {
726 726
 						// @codingStandardsIgnoreLine
727 727
 						echo $term->get_error_message();
728 728
 					}
729
-				} else {
730
-					wp_set_object_terms( $id, sanitize_title( $continent_code ), 'continent', true );
729
+				}else {
730
+					wp_set_object_terms($id, sanitize_title($continent_code), 'continent', true);
731 731
 				}
732 732
 			}
733 733
 		}
@@ -737,14 +737,14 @@  discard block
 block discarded – undo
737 737
 	 * Save the list of Accommodation into an option
738 738
 	 */
739 739
 	public function update_options() {
740
-		$data = file_get_contents( $this->url . '/List?' . $this->url_qs );
740
+		$data = file_get_contents($this->url.'/List?'.$this->url_qs);
741 741
 
742
-		$accommodation = json_decode( $data, true );
742
+		$accommodation = json_decode($data, true);
743 743
 
744
-		if ( isset( $accommodation['error'] ) ) {
744
+		if (isset($accommodation['error'])) {
745 745
 			return $accommodation['error'];
746
-		} elseif ( isset( $accommodation ) && ! empty( $accommodation ) ) {
747
-			set_transient( 'lsx_ti_accommodation', $accommodation,60 * 60 * 2 );
746
+		} elseif (isset($accommodation) && !empty($accommodation)) {
747
+			set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2);
748 748
 			return true;
749 749
 		}
750 750
 	}
@@ -753,11 +753,11 @@  discard block
 block discarded – undo
753 753
 	 * search_form
754 754
 	 */
755 755
 	public function update_options_form() {
756
-		echo '<div style="display:none;" class="wetu-status"><h3>' . esc_html__( 'Wetu Status', 'wetu-importer' ) . '</h3>';
756
+		echo '<div style="display:none;" class="wetu-status"><h3>'.esc_html__('Wetu Status', 'wetu-importer').'</h3>';
757 757
 
758
-		$accommodation = get_transient( 'lsx_ti_accommodation' );
758
+		$accommodation = get_transient('lsx_ti_accommodation');
759 759
 
760
-		if ( '' === $accommodation || false === $accommodation || isset( $_GET['refresh_accommodation'] ) ) {
760
+		if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) {
761 761
 			$this->update_options();
762 762
 		}
763 763
 
@@ -767,12 +767,12 @@  discard block
 block discarded – undo
767 767
 	/**
768 768
 	 * Save the list of Accommodation into an option
769 769
 	 */
770
-	public function check_for_parent( $data = array() ) {
770
+	public function check_for_parent($data = array()) {
771 771
 		global $wpdb;
772 772
 
773
-		if ( $data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id'] ) {
774
-			$result = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'lsx_wetu_id' AND meta_value = '%s'", array( $data[0]['position']['country_content_entity_id'] ) ) );
775
-			if ( ! empty( $result ) && '' !== $result && false !== $result ) {
773
+		if ($data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id']) {
774
+			$result = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'lsx_wetu_id' AND meta_value = '%s'", array($data[0]['position']['country_content_entity_id'])));
775
+			if (!empty($result) && '' !== $result && false !== $result) {
776 776
 				return $result;
777 777
 			}
778 778
 		}
Please login to merge, or discard this patch.
includes/helpers.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
  * @return array
18 18
  */
19 19
 function get_options() {
20
-	$options = get_option( 'wetu_importer_settings', array() );
21
-	if ( empty( $options ) ) {
20
+	$options = get_option('wetu_importer_settings', array());
21
+	if (empty($options)) {
22 22
 		// Check for any previous options.
23
-		$temp_options = get_option( '_lsx-to_settings', false );
24
-		if ( false !== $temp_options && isset( $temp_options['wetu-importer'] ) && ! empty( $temp_options['wetu-importer'] ) ) {
23
+		$temp_options = get_option('_lsx-to_settings', false);
24
+		if (false !== $temp_options && isset($temp_options['wetu-importer']) && !empty($temp_options['wetu-importer'])) {
25 25
 			$options = $temp_options['wetu-importer'];
26 26
 		}
27
-		if ( false !== $temp_options && isset( $temp_options['api']['wetu_api_key'] ) && '' !== $temp_options['api']['wetu_api_key'] ) {
27
+		if (false !== $temp_options && isset($temp_options['api']['wetu_api_key']) && '' !== $temp_options['api']['wetu_api_key']) {
28 28
 			$options['api_key'] = $temp_options['api']['wetu_api_key'];
29 29
 		}
30 30
 	}
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
  * @param string $post_status
39 39
  * @return void
40 40
  */
41
-function get_post_count( $post_type = '', $post_status = '' ) {
41
+function get_post_count($post_type = '', $post_status = '') {
42 42
 	global $wpdb;
43 43
 	$count = '0';
44
-	if ( '' !== $post_type && '' !== $post_status ) {
45
-		$result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(`ID`) FROM $wpdb->posts WHERE `post_status` = '%s' AND `post_type` = '%s'", array( trim( $post_status ), $post_type ) ) );
46
-		if ( false !== $result && '' !== $result ) {
44
+	if ('' !== $post_type && '' !== $post_status) {
45
+		$result = $wpdb->get_var($wpdb->prepare("SELECT COUNT(`ID`) FROM $wpdb->posts WHERE `post_status` = '%s' AND `post_type` = '%s'", array(trim($post_status), $post_type)));
46
+		if (false !== $result && '' !== $result) {
47 47
 			$count = $result;
48 48
 		}
49 49
 	}
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
  * @param string $post_type
57 57
  * @return void
58 58
  */
59
-function get_wetu_queue_count( $post_type = '' ) {
59
+function get_wetu_queue_count($post_type = '') {
60 60
 	$count = '0';
61
-	$queued_imports = get_option( 'wetu_importer_que', array() );
62
-	if ( isset( $queued_imports[ $post_type ] ) ) {
63
-		$count = count( $queued_imports[ $post_type ] );
61
+	$queued_imports = get_option('wetu_importer_que', array());
62
+	if (isset($queued_imports[$post_type])) {
63
+		$count = count($queued_imports[$post_type]);
64 64
 	}
65 65
 	return $count;
66 66
 }
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
  * @param string $post_type
72 72
  * @return void
73 73
  */
74
-function get_wetu_tour_count( $post_type = '' ) {
74
+function get_wetu_tour_count($post_type = '') {
75 75
 	$count = '0';
76
-	$wetu_tours = get_transient( 'lsx_ti_tours', array() );
77
-	if ( ! empty( $wetu_tours ) ) {
78
-		$count = count( $wetu_tours );
76
+	$wetu_tours = get_transient('lsx_ti_tours', array());
77
+	if (!empty($wetu_tours)) {
78
+		$count = count($wetu_tours);
79 79
 	}
80 80
 	return $count;
81 81
 }
Please login to merge, or discard this patch.