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