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