Completed
Push — master ( 0913ec...1abe84 )
by Joseph
03:19
created
classes/class-wetu-importer-banner-integration.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -232,6 +232,9 @@
 block discarded – undo
232 232
 		}
233 233
 	}
234 234
 
235
+	/**
236
+	 * @param string $url
237
+	 */
235 238
 	public function attach_external_image2( $url = null, $post_data = array() ) {
236 239
 		if ( ! $url ) { return new WP_Error( 'missing', 'Need a valid URL' ); }
237 240
 
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 	 * @access private
27 27
 	 */
28 28
 	public function __construct() {
29
-		add_action( 'wp_ajax_lsx_import_sync_banners',array( $this, 'sync_new_banner' ) );
30
-		add_action( 'wp_ajax_nopriv_lsx_import_sync_banners',array( $this, 'sync_new_banner' ) );
29
+		add_action('wp_ajax_lsx_import_sync_banners', array($this, 'sync_new_banner'));
30
+		add_action('wp_ajax_nopriv_lsx_import_sync_banners', array($this, 'sync_new_banner'));
31 31
 	}
32 32
 
33 33
 	/**
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 36
 	public function display_page() {
37 37
 		?>
38 38
 		<div class="wrap">
39
-			<h2><?php esc_html_e( 'Download new banners straight from WETU','wetu-importer' ); ?></h2>
39
+			<h2><?php esc_html_e('Download new banners straight from WETU', 'wetu-importer'); ?></h2>
40 40
 
41 41
 			<form method="get" action="" id="banners-filter">
42
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
42
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" />
43 43
 
44 44
 			   <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
45
-					<img style="width:32px;" src="<?php echo esc_url( WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" />
45
+					<img style="width:32px;" src="<?php echo esc_url(WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" />
46 46
 				</div>
47 47
 
48 48
 				<table class="wp-list-table widefat fixed posts">
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 					<?php
61 61
 						$accommodation_args = array(
62 62
 							'post_type' => 'accommodation',
63
-							'post_status' => array( 'publish','pending','draft','future','private' ),
63
+							'post_status' => array('publish', 'pending', 'draft', 'future', 'private'),
64 64
 							'nopagin' => 'true',
65 65
 							'posts_per_page' => '1000',
66 66
 							'meta_query' => array(
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 								),
81 81
 							),
82 82
 						);
83
-						$accommodation = new WP_Query( $accommodation_args );
83
+						$accommodation = new WP_Query($accommodation_args);
84 84
 					?>
85 85
 
86 86
 					<tbody id="the-list">
87 87
 						<?php
88
-							if ( $accommodation->have_posts() ) {
89
-								while ( $accommodation->have_posts() ) {
88
+							if ($accommodation->have_posts()) {
89
+								while ($accommodation->have_posts()) {
90 90
 									$accommodation->the_post();
91 91
 									?>
92 92
 									<tr class="post-<?php the_ID(); ?> type-tour status-none" id="post-<?php the_ID(); ?>">
@@ -95,26 +95,26 @@  discard block
 block discarded – undo
95 95
 									$min_width = '1920';
96 96
 									$min_height = '500';
97 97
 
98
-									$img_group = get_post_meta( get_the_ID(),'image_group',true );
98
+									$img_group = get_post_meta(get_the_ID(), 'image_group', true);
99 99
 
100 100
 									$thumbnails_html = false;
101 101
 
102
-									if ( false !== $img_group ) {
103
-										foreach ( $img_group['banner_image'] as $banner_image ) {
104
-											$large = wp_get_attachment_image_src( $banner_image,'full' );
102
+									if (false !== $img_group) {
103
+										foreach ($img_group['banner_image'] as $banner_image) {
104
+											$large = wp_get_attachment_image_src($banner_image, 'full');
105 105
 											$real_width = $large[1];
106 106
 											$real_height = $large[2];
107 107
 
108 108
 											$status = 'optimized';
109
-											if ( $real_width < intval( $real_width ) ) {
109
+											if ($real_width < intval($real_width)) {
110 110
 												$status = 'width not enough.';
111 111
 												}
112 112
 
113
-											$thumbnail = wp_get_attachment_image_src( $banner_image,'thumbnail' );
113
+											$thumbnail = wp_get_attachment_image_src($banner_image, 'thumbnail');
114 114
 											$thumbnails_html[] = '
115 115
 													<div style="display:block;float:left;">
116
-														<img src="' . $thumbnail[0] . '" />
117
-														<p style="text-align:center;">' . $real_width . 'px by ' . $real_height . 'px</p>
116
+														<img src="' . $thumbnail[0].'" />
117
+														<p style="text-align:center;">' . $real_width.'px by '.$real_height.'px</p>
118 118
 													</div>';
119 119
 											}
120 120
 										}
@@ -124,16 +124,16 @@  discard block
 block discarded – undo
124 124
 										<input type="checkbox" data-identifier="<?php the_ID(); ?>" value="<?php the_ID(); ?>" name="post[]" id="cb-select-<?php the_ID(); ?>">
125 125
 										</th>
126 126
 
127
-										<td class="post-title page-title column-title"><?php echo '<a href="' . esc_url( admin_url( '/post.php?post=' . get_the_ID() . '&action=edit' ) ) . '" target="_blank">';
127
+										<td class="post-title page-title column-title"><?php echo '<a href="'.esc_url(admin_url('/post.php?post='.get_the_ID().'&action=edit')).'" target="_blank">';
128 128
 										the_title();
129 129
 										echo '</a>'; ?></td>
130 130
 
131 131
 										<td colspan="2" class="thumbnails column-thumbnails">
132 132
 										<?php
133
-											if ( false !== $thumbnails_html ) {
133
+											if (false !== $thumbnails_html) {
134 134
 												// @codingStandardsIgnoreLine
135
-												echo implode( '', $thumbnails_html );
136
-											} else {
135
+												echo implode('', $thumbnails_html);
136
+											}else {
137 137
 												echo '<p>There was an error retrieving your images.</p>';
138 138
 											}
139 139
 										?>
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
 				</table>
159 159
 
160
-				<p><input class="button button-primary download" type="button" value="<?php esc_html_e( 'Download new Banners','wetu-importer' ); ?>" />
160
+				<p><input class="button button-primary download" type="button" value="<?php esc_html_e('Download new Banners', 'wetu-importer'); ?>" />
161 161
 				</p>
162 162
 			</form>
163 163
 		</div>
@@ -169,33 +169,33 @@  discard block
 block discarded – undo
169 169
 	 */
170 170
 	public function sync_new_banner() {
171 171
 		// @codingStandardsIgnoreLine
172
-		if ( isset( $_POST['action'] ) && 'lsx_import_sync_banners' === $_POST['action'] && isset( $_POST['post_id'] ) ) {
172
+		if (isset($_POST['action']) && 'lsx_import_sync_banners' === $_POST['action'] && isset($_POST['post_id'])) {
173 173
 			// @codingStandardsIgnoreLine
174
-			$banners = get_post_meta( $_POST['post_id'],'image_group',true );
174
+			$banners = get_post_meta($_POST['post_id'], 'image_group', true);
175 175
 			// @codingStandardsIgnoreLine
176
-			$this->wetu_id = get_post_meta( $_POST['post_id'],'lsx_wetu_id',true );
176
+			$this->wetu_id = get_post_meta($_POST['post_id'], 'lsx_wetu_id', true);
177 177
 
178 178
 			$new_banner_array = false;
179 179
 			$array_index = 0;
180 180
 
181
-			foreach ( $banners['banner_image'] as $banner_image ) {
182
-				$image_id = $this->attach_external_image2( $this->format_wetu_url( $banner_image ) );
183
-				if ( null !== $image_id && '' !== $image_id ) {
184
-					$new_banner_array['banner_image'][ 'cmb-field-' . $array_index ] = $image_id;
181
+			foreach ($banners['banner_image'] as $banner_image) {
182
+				$image_id = $this->attach_external_image2($this->format_wetu_url($banner_image));
183
+				if (null !== $image_id && '' !== $image_id) {
184
+					$new_banner_array['banner_image']['cmb-field-'.$array_index] = $image_id;
185 185
 					$array_index++;
186 186
 				}
187 187
 			}
188 188
 
189
-			if ( false !== $new_banner_array ) {
189
+			if (false !== $new_banner_array) {
190 190
 				// @codingStandardsIgnoreLine
191
-				delete_post_meta( $_POST['post_id'],'image_group' );
191
+				delete_post_meta($_POST['post_id'], 'image_group');
192 192
 				// @codingStandardsIgnoreLine
193
-				add_post_meta( $_POST['post_id'],'image_group',$new_banner_array,true );
193
+				add_post_meta($_POST['post_id'], 'image_group', $new_banner_array, true);
194 194
 				echo true;
195
-			} else {
195
+			}else {
196 196
 				echo false;
197 197
 			}
198
-		} else {
198
+		}else {
199 199
 			echo false;
200 200
 		}
201 201
 
@@ -205,71 +205,71 @@  discard block
 block discarded – undo
205 205
 	/**
206 206
 	 * formats the url
207 207
 	 */
208
-	public function format_wetu_url( $post_id ) {
209
-		return 'https://wetu.com/ImageHandler/c1920x800/' . $this->wetu_id . '/' . $this->format_filename( $post_id );
208
+	public function format_wetu_url($post_id) {
209
+		return 'https://wetu.com/ImageHandler/c1920x800/'.$this->wetu_id.'/'.$this->format_filename($post_id);
210 210
 	}
211 211
 
212 212
 	/**
213 213
 	 * formats the filename
214 214
 	 */
215
-	public function format_filename( $post_id ) {
216
-		$base = str_replace( '_',' ',get_the_title( $post_id ) );
217
-		$base = rawurlencode( $base );
218
-		$type = get_post_mime_type( $post_id );
215
+	public function format_filename($post_id) {
216
+		$base = str_replace('_', ' ', get_the_title($post_id));
217
+		$base = rawurlencode($base);
218
+		$type = get_post_mime_type($post_id);
219 219
 
220
-		switch ( $type ) {
220
+		switch ($type) {
221 221
 			case 'image/jpeg':
222
-				return $base . '.jpg';
222
+				return $base.'.jpg';
223 223
 			break;
224 224
 			case 'image/png':
225
-				return $base . '.png';
225
+				return $base.'.png';
226 226
 			break;
227 227
 			case 'image/gif':
228
-				return $base . '.gif';
228
+				return $base.'.gif';
229 229
 			break;
230 230
 			default:
231 231
 				return false;
232 232
 		}
233 233
 	}
234 234
 
235
-	public function attach_external_image2( $url = null, $post_data = array() ) {
236
-		if ( ! $url ) { return new WP_Error( 'missing', 'Need a valid URL' ); }
235
+	public function attach_external_image2($url = null, $post_data = array()) {
236
+		if (!$url) { return new WP_Error('missing', 'Need a valid URL'); }
237 237
 
238
-		require_once( ABSPATH . 'wp-admin/includes/file.php' );
239
-		require_once( ABSPATH . 'wp-admin/includes/media.php' );
240
-		require_once( ABSPATH . 'wp-admin/includes/image.php' );
238
+		require_once(ABSPATH.'wp-admin/includes/file.php');
239
+		require_once(ABSPATH.'wp-admin/includes/media.php');
240
+		require_once(ABSPATH.'wp-admin/includes/image.php');
241 241
 
242 242
 		//var_dump($tmp);
243
-		$tmp = tempnam( '/tmp', 'FOO' );
244
-		print_r( $url );
245
-		$image = file_get_contents( $url );
246
-		print_r( $image );
247
-		file_put_contents( $tmp, $image );
248
-		chmod( $tmp,'777' );
249
-
250
-		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
251
-		$url_filename = basename( $matches[0] );
252
-		$url_filename = str_replace( '%20','_',$url_filename );
243
+		$tmp = tempnam('/tmp', 'FOO');
244
+		print_r($url);
245
+		$image = file_get_contents($url);
246
+		print_r($image);
247
+		file_put_contents($tmp, $image);
248
+		chmod($tmp, '777');
249
+
250
+		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
251
+		$url_filename = basename($matches[0]);
252
+		$url_filename = str_replace('%20', '_', $url_filename);
253 253
 		// extract filename from url for title
254
-		$url_type = wp_check_filetype( $url_filename );                                           // determine file type (ext and mime/type)
254
+		$url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type)
255 255
 
256 256
 		// assemble file data (should be built like $_FILES since wp_handle_sideload() will be using)
257
-		$file_array['tmp_name'] = $tmp;                                                         // full server path to temp file
257
+		$file_array['tmp_name'] = $tmp; // full server path to temp file
258 258
 
259
-		if ( ! empty( $filename ) && ' ' != $filename ) {
260
-			$file_array['name'] = $filename . '.' . $url_type['ext'];                           // user given filename for title, add original URL extension
261
-		} else {
262
-			$file_array['name'] = $url_filename;                                                // just use original URL filename
259
+		if (!empty($filename) && ' ' != $filename) {
260
+			$file_array['name'] = $filename.'.'.$url_type['ext']; // user given filename for title, add original URL extension
261
+		}else {
262
+			$file_array['name'] = $url_filename; // just use original URL filename
263 263
 		}
264 264
 
265 265
 		// set additional wp_posts columns
266
-		if ( empty( $post_data['post_title'] ) ) {
267
-			$url_filename = str_replace( '%20',' ',$url_filename );
268
-			$post_data['post_title'] = basename( $url_filename, '.' . $url_type['ext'] );         // just use the original filename (no extension)
266
+		if (empty($post_data['post_title'])) {
267
+			$url_filename = str_replace('%20', ' ', $url_filename);
268
+			$post_data['post_title'] = basename($url_filename, '.'.$url_type['ext']); // just use the original filename (no extension)
269 269
 		}
270 270
 
271 271
 		// make sure gets tied to parent
272
-		if ( empty( $post_data['post_parent'] ) ) {
272
+		if (empty($post_data['post_parent'])) {
273 273
 			// @codingStandardsIgnoreLine
274 274
 			$post_data['post_parent'] = $_POST['post_id'];
275 275
 		}
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
 
279 279
 		// do the validation and storage stuff
280 280
 		// @codingStandardsIgnoreLine
281
-		$att_id = media_handle_sideload( $file_array, $_POST['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
281
+		$att_id = media_handle_sideload($file_array, $_POST['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
282 282
 
283 283
 		// If error storing permanently, unlink
284
-		if ( is_wp_error( $att_id ) ) {
285
-			unlink( $file_array['tmp_name'] );   // clean up
284
+		if (is_wp_error($att_id)) {
285
+			unlink($file_array['tmp_name']); // clean up
286 286
 			return false; // output wp_error
287 287
 			//return $att_id; // output wp_error
288 288
 		}
Please login to merge, or discard this patch.
classes/class-wetu-importer-connect-accommodation.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -214,6 +214,7 @@
 block discarded – undo
214 214
 
215 215
 	/**
216 216
 	 * format the array
217
+	 * @param string $key
217 218
 	 */
218 219
 	public function format_array( $array, $key ) {
219 220
 		$new_array = array();
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -35,17 +35,17 @@  discard block
 block discarded – undo
35 35
 	 * @access private
36 36
 	 */
37 37
 	public function __construct() {
38
-		$temp_options = get_option( '_lsx-to_settings',false );
38
+		$temp_options = get_option('_lsx-to_settings', false);
39 39
 
40
-		if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) {
41
-			$this->options = $temp_options[ $this->plugin_slug ];
40
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
41
+			$this->options = $temp_options[$this->plugin_slug];
42 42
 		}
43 43
 
44
-		$this->url = 'http://wetu.com/API/Pins/' . $this->options['api_key'] . '/List';
44
+		$this->url = 'http://wetu.com/API/Pins/'.$this->options['api_key'].'/List';
45 45
 
46
-		add_action( 'lsx_tour_importer_admin_tab_' . $this->tab_slug, array( $this, 'display_page' ) );
47
-		add_action( 'wp_ajax_lsx_import_connect_accommodation',array( $this, 'process_connection' ) );
48
-		add_action( 'wp_ajax_nopriv_lsx_import_connect_accommodation',array( $this, 'process_connection' ) );
46
+		add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page'));
47
+		add_action('wp_ajax_lsx_import_connect_accommodation', array($this, 'process_connection'));
48
+		add_action('wp_ajax_nopriv_lsx_import_connect_accommodation', array($this, 'process_connection'));
49 49
 	}
50 50
 
51 51
 	/**
@@ -55,45 +55,45 @@  discard block
 block discarded – undo
55 55
 		global $post;
56 56
 		?>
57 57
 		<div class="wrap">
58
-			<h3><span class="dashicons dashicons-admin-multisite"></span> <?php esc_html_e( 'Connect your Accommodation','wetu-importer' ); ?></h3>
58
+			<h3><span class="dashicons dashicons-admin-multisite"></span> <?php esc_html_e('Connect your Accommodation', 'wetu-importer'); ?></h3>
59 59
 
60 60
 			<form method="get" action="" id="connect-accommodation-filter">
61
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
61
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" />
62 62
 
63
-				<p><?php esc_html_e( 'Below is a list of your accommodation that does not contain a WETU ID, but its Title matches a name in the WETU DB. Connecting it will all you to pull through information from WETU.','wetu-importer' ); ?></p>
63
+				<p><?php esc_html_e('Below is a list of your accommodation that does not contain a WETU ID, but its Title matches a name in the WETU DB. Connecting it will all you to pull through information from WETU.', 'wetu-importer'); ?></p>
64 64
 
65 65
 				<div class="ajax-loader-small" style="display:none;width:100%;text-align:center;">
66
-					<img style="width:32px;" src="<?php echo esc_url( WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" />
66
+					<img style="width:32px;" src="<?php echo esc_url(WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" />
67 67
 				</div>
68 68
 
69 69
 				<?php
70 70
 					$loose_accommodation = $this->find_current_accommodation();
71 71
 				?>
72
-				<p><input class="button button-primary connect" type="button" value="<?php esc_html_e( 'Connect','wetu-importer' ); ?>" /></p>
72
+				<p><input class="button button-primary connect" type="button" value="<?php esc_html_e('Connect', 'wetu-importer'); ?>" /></p>
73 73
 				<table class="wp-list-table widefat fixed posts">
74 74
 					<?php $this->table_header(); ?>
75 75
 
76 76
 					<tbody>
77
-						<?php if ( false !== $loose_accommodation ) {
77
+						<?php if (false !== $loose_accommodation) {
78 78
 
79 79
 							$loose_args = array(
80 80
 								'post_type' => 'accommodation',
81
-								'post_status' => array( 'publish','pending' ),
81
+								'post_status' => array('publish', 'pending'),
82 82
 								'nopagin' => true,
83 83
 								'post__in' => $loose_accommodation,
84 84
 							);
85
-							$loose_accommodation_query = new WP_Query( $loose_args );
86
-							$accommodation = get_transient( 'lsx_ti_accommodation' );
85
+							$loose_accommodation_query = new WP_Query($loose_args);
86
+							$accommodation = get_transient('lsx_ti_accommodation');
87 87
 							$identifier = '';
88 88
 
89
-							if ( $loose_accommodation_query->have_posts() && false !== $accommodation ) {
90
-								while ( $loose_accommodation_query->have_posts() ) {
89
+							if ($loose_accommodation_query->have_posts() && false !== $accommodation) {
90
+								while ($loose_accommodation_query->have_posts()) {
91 91
 									$loose_accommodation_query->the_post();
92 92
 
93
-									foreach ( $accommodation as $row_key => $row ) {
94
-										if ( stripos( ltrim( rtrim( $row->name ) ), $post->post_title ) !== false ) {
93
+									foreach ($accommodation as $row_key => $row) {
94
+										if (stripos(ltrim(rtrim($row->name)), $post->post_title) !== false) {
95 95
 											$identifier = $row->id;
96
-										} else {
96
+										}else {
97 97
 											continue;
98 98
 										}
99 99
 									}
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 									<tr class="post-<?php the_ID(); ?> type-accommodation status-none" id="post-<?php the_ID(); ?>">
102 102
 										<th class="check-column" scope="row">
103 103
 											<label for="cb-select-<?php the_ID(); ?>" class="screen-reader-text"><?php the_title(); ?></label>
104
-											<input type="checkbox" data-identifier="<?php echo esc_attr( $identifier ); ?>" value="<?php the_ID(); ?>" name="post[]" id="cb-select-<?php the_ID(); ?>">
104
+											<input type="checkbox" data-identifier="<?php echo esc_attr($identifier); ?>" value="<?php the_ID(); ?>" name="post[]" id="cb-select-<?php the_ID(); ?>">
105 105
 										</th>
106 106
 										<td class="post-title page-title column-title">
107
-											<strong><?php the_title(); ?></strong> - <a href="<?php echo esc_url( admin_url( '/post.php?post=' . $post->ID . '&action=edit' ) ); ?>" target="_blank"><?php echo esc_html( $post->post_status ); ?></a>
107
+											<strong><?php the_title(); ?></strong> - <a href="<?php echo esc_url(admin_url('/post.php?post='.$post->ID.'&action=edit')); ?>" target="_blank"><?php echo esc_html($post->post_status); ?></a>
108 108
 										</td>
109 109
 										<td class="excerpt column-excerpt">
110 110
 											<?php
111 111
 												// @codingStandardsIgnoreLine
112
-												echo strip_tags( get_the_excerpt() );
112
+												echo strip_tags(get_the_excerpt());
113 113
 											?>
114 114
 										</td>
115 115
 									</tr>
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
 
123 123
 				</table>
124 124
 
125
-				<p><input class="button button-primary connect" type="button" value="<?php esc_html_e( 'Connect','wetu-importer' ); ?>" /></p>
125
+				<p><input class="button button-primary connect" type="button" value="<?php esc_html_e('Connect', 'wetu-importer'); ?>" /></p>
126 126
 
127 127
 			</form>
128 128
 
129 129
 			<div style="display:none;" class="completed-list-wrapper">
130
-				<h3><?php esc_html_e( 'Completed' ); ?></h3>
130
+				<h3><?php esc_html_e('Completed'); ?></h3>
131 131
 				<ul>
132 132
 				</ul>
133 133
 			</div>
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			FROM {$wpdb->posts}
184 184
 			WHERE post_type = 'accommodation'
185 185
 			LIMIT 0,500
186
-		",ARRAY_A);
186
+		", ARRAY_A);
187 187
 
188 188
 		$current_accommodation = $wpdb->get_results("
189 189
 			SELECT key1.post_id
@@ -196,14 +196,14 @@  discard block
 block discarded – undo
196 196
 			AND key2.post_type = 'accommodation'
197 197
 
198 198
 			LIMIT 0,500
199
-		",ARRAY_A);
199
+		", ARRAY_A);
200 200
 
201
-		if ( null !== $all_accommodation && ! empty( $all_accommodation ) ) {
201
+		if (null !== $all_accommodation && !empty($all_accommodation)) {
202 202
 			//remove the extra accommodation
203
-			if ( null !== $current_accommodation && ! empty( $current_accommodation ) ) {
204
-				$all_accommodation = array_diff( $this->format_array( $all_accommodation,'ID' ), $this->format_array( $current_accommodation,'post_id' ) );
205
-			} elseif ( null !== $current_accommodation && empty( $current_accommodation ) ) {
206
-				$all_accommodation = $this->format_array( $current_accommodation,'post_id' );
203
+			if (null !== $current_accommodation && !empty($current_accommodation)) {
204
+				$all_accommodation = array_diff($this->format_array($all_accommodation, 'ID'), $this->format_array($current_accommodation, 'post_id'));
205
+			} elseif (null !== $current_accommodation && empty($current_accommodation)) {
206
+				$all_accommodation = $this->format_array($current_accommodation, 'post_id');
207 207
 			}
208 208
 
209 209
 			$return = $all_accommodation;
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
 	/**
216 216
 	 * format the array
217 217
 	 */
218
-	public function format_array( $array, $key ) {
218
+	public function format_array($array, $key) {
219 219
 		$new_array = array();
220 220
 
221
-		foreach ( $array as $value ) {
222
-			$new_array[] = $value[ $key ];
221
+		foreach ($array as $value) {
222
+			$new_array[] = $value[$key];
223 223
 		}
224 224
 
225 225
 		return $new_array;
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		$return = false;
233 233
 
234 234
 		// @codingStandardsIgnoreLine
235
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_connect_accommodation' && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug && isset( $_POST['post_id'] ) && isset( $_POST['wetu_id'] ) ) {
235
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_connect_accommodation' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['post_id']) && isset($_POST['wetu_id'])) {
236 236
 			$post_id = false;
237 237
 			$matching_id = false;
238 238
 
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 			// @codingStandardsIgnoreLine
242 242
 			$matching_id = $_POST['wetu_id'];
243 243
 
244
-			add_post_meta( $post_id,'lsx_wetu_id',$matching_id );
245
-			$return = '<li class="post-' . $post_id . '"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="' . get_permalink( $post_id ) . '">' . get_the_title( $post_id ) . '</a></li>';
244
+			add_post_meta($post_id, 'lsx_wetu_id', $matching_id);
245
+			$return = '<li class="post-'.$post_id.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($post_id).'">'.get_the_title($post_id).'</a></li>';
246 246
 		}
247 247
 
248
-		print_r( $return );
248
+		print_r($return);
249 249
 		die();
250 250
 	}
251 251
 
Please login to merge, or discard this patch.
classes/class-wetu-importer-settings.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -17,26 +17,26 @@  discard block
 block discarded – undo
17 17
 	 * @access private
18 18
 	 */
19 19
 	public function __construct() {
20
-		$temp_options = get_option( '_lsx-to_settings', false );
20
+		$temp_options = get_option('_lsx-to_settings', false);
21 21
 
22
-		if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) {
23
-			$this->options = $temp_options[ $this->plugin_slug ];
22
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
23
+			$this->options = $temp_options[$this->plugin_slug];
24 24
 			$this->set_variables();
25 25
 		}
26 26
 
27
-		add_filter( 'lsx_to_framework_settings_tabs', array( $this, 'settings_page_array' ) );
28
-		add_action( 'lsx_to_framework_api_tab_content',array( $this, 'api_settings' ),10,1 );
27
+		add_filter('lsx_to_framework_settings_tabs', array($this, 'settings_page_array'));
28
+		add_action('lsx_to_framework_api_tab_content', array($this, 'api_settings'), 10, 1);
29 29
 	}
30 30
 
31 31
 	/**
32 32
 	 * Returns the array of settings to the UIX Class in the lsx framework
33 33
 	 */
34
-	public function settings_page_array( $tabs ) {
35
-		$tabs[ $this->plugin_slug ] = array(
34
+	public function settings_page_array($tabs) {
35
+		$tabs[$this->plugin_slug] = array(
36 36
 			'page_title'        => '',
37 37
 			'page_description'  => '',
38
-			'menu_title'        => __( 'Importer', 'wetu-importer' ),
39
-			'template'          => WETU_IMPORTER_PATH . 'settings/wetu.php',
38
+			'menu_title'        => __('Importer', 'wetu-importer'),
39
+			'template'          => WETU_IMPORTER_PATH.'settings/wetu.php',
40 40
 			'default'	 		=> false,
41 41
 		);
42 42
 
@@ -46,16 +46,16 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * Adds the API key to the API Tab
48 48
 	 */
49
-	public function api_settings( $tab = 'general' ) {
50
-		if ( 'settings' === $tab ) { ?>
49
+	public function api_settings($tab = 'general') {
50
+		if ('settings' === $tab) { ?>
51 51
 			<tr class="form-field-wrap">
52 52
 				<th class="tour-operator_table_heading" style="padding-bottom:0px;" scope="row" colspan="2">
53
-					<h4 style="margin-bottom:0px;"><span><?php esc_html_e( 'WETU API', 'wetu-importer' ); ?></span></h4>
53
+					<h4 style="margin-bottom:0px;"><span><?php esc_html_e('WETU API', 'wetu-importer'); ?></span></h4>
54 54
 				</th>
55 55
 			</tr>
56 56
 			<tr class="form-field">
57 57
 				<th scope="row">
58
-					<i class="dashicons-before dashicons-admin-network"></i> <label for="wetu_api_key"> <?php esc_html_e( 'Key', 'wetu-importer' ); ?></label>
58
+					<i class="dashicons-before dashicons-admin-network"></i> <label for="wetu_api_key"> <?php esc_html_e('Key', 'wetu-importer'); ?></label>
59 59
 				</th>
60 60
 				<td>
61 61
 					<input type="text" {{#if wetu_api_key}} value="{{wetu_api_key}}" {{/if}} name="wetu_api_key" />
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			</tr>
64 64
 			<tr class="form-field">
65 65
 				<th scope="row">
66
-					<i class="dashicons-before dashicons-admin-users"></i> <label for="wetu_api_username"> <?php esc_html_e( 'Username', 'wetu-importer' ); ?></label>
66
+					<i class="dashicons-before dashicons-admin-users"></i> <label for="wetu_api_username"> <?php esc_html_e('Username', 'wetu-importer'); ?></label>
67 67
 				</th>
68 68
 				<td>
69 69
 					<input type="text" {{#if wetu_api_username}} value="{{wetu_api_username}}" {{/if}} name="wetu_api_username" />
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 			</tr>
72 72
 			<tr class="form-field">
73 73
 				<th scope="row">
74
-					<i class="dashicons-before dashicons-lock"></i> <label for="wetu_api_password"> <?php esc_html_e( 'Password', 'wetu-importer' ); ?></label>
74
+					<i class="dashicons-before dashicons-lock"></i> <label for="wetu_api_password"> <?php esc_html_e('Password', 'wetu-importer'); ?></label>
75 75
 				</th>
76 76
 				<td>
77 77
 					<input type="text" {{#if wetu_api_password}} value="{{wetu_api_password}}" {{/if}} name="wetu_api_password" />
Please login to merge, or discard this patch.
classes/class-wetu-importer.php 2 patches
Doc Comments   +11 added lines patch added patch discarded remove patch
@@ -769,6 +769,9 @@  discard block
 block discarded – undo
769 769
 		return $result;
770 770
 	}
771 771
 
772
+	/**
773
+	 * @return boolean
774
+	 */
772 775
 	public function set_term( $id = false, $name = false, $taxonomy = false, $parent = false ) {
773 776
 		// @codingStandardsIgnoreLine
774 777
 		if ( ! $term = term_exists( $name, $taxonomy ) ) {
@@ -1074,6 +1077,10 @@  discard block
 block discarded – undo
1074 1077
 		return 	false;
1075 1078
 	}
1076 1079
 
1080
+	/**
1081
+	 * @param string $url
1082
+	 * @param string $thumb
1083
+	 */
1077 1084
 	public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
1078 1085
 		if ( ! $url || ! $post_id ) { return new WP_Error( 'missing', 'Need a valid URL and post ID...' ); }
1079 1086
 
@@ -1184,6 +1191,7 @@  discard block
 block discarded – undo
1184 1191
 
1185 1192
 	/**
1186 1193
 	 * Does a multine search
1194
+	 * @param string $haystack
1187 1195
 	 */
1188 1196
 	public function multineedle_stripos( $haystack, $needles, $offset = 0 ) {
1189 1197
 		$found = false;
@@ -1267,6 +1275,9 @@  discard block
 block discarded – undo
1267 1275
 		}
1268 1276
 	}
1269 1277
 
1278
+	/**
1279
+	 * @param string $array
1280
+	 */
1270 1281
 	public function shuffle_assoc( &$array ) {
1271 1282
 		$new = array();
1272 1283
 		$keys = array_keys( $array );
Please login to merge, or discard this patch.
Spacing   +316 added lines, -316 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'];
@@ -266,59 +266,59 @@  discard block
 block discarded – undo
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;
@@ -1305,13 +1305,13 @@  discard block
 block discarded – undo
1305 1305
 	 * @param boolean $wetu_id the wetu ID.
1306 1306
 	 * @return boolean | string
1307 1307
 	 */
1308
-	private function get_post_id_by_key_value( $wetu_id = false ) {
1308
+	private function get_post_id_by_key_value($wetu_id = false) {
1309 1309
 		global $wpdb;
1310 1310
 		$id = false;
1311 1311
 
1312
-		if ( false !== $wetu_id && '' !== $wetu_id ) {
1313
-			$result = $wpdb->get_var( "SELECT post_id FROM `{$wpdb->postmeta}` WHERE `meta_key` = 'lsx_wetu_id' AND `meta_value` = '{$wetu_id}'" );
1314
-			if ( false !== $result && ! empty( $result ) ) {
1312
+		if (false !== $wetu_id && '' !== $wetu_id) {
1313
+			$result = $wpdb->get_var("SELECT post_id FROM `{$wpdb->postmeta}` WHERE `meta_key` = 'lsx_wetu_id' AND `meta_value` = '{$wetu_id}'");
1314
+			if (false !== $result && !empty($result)) {
1315 1315
 				$id = $result;
1316 1316
 			}
1317 1317
 		}
Please login to merge, or discard this patch.
classes/class-wetu-importer-destination.php 2 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -685,6 +685,7 @@  discard block
 block discarded – undo
685 685
 
686 686
 	/**
687 687
 	 * Set the team memberon each item.
688
+	 * @param boolean $team_members
688 689
 	 */
689 690
 	public function set_team_member( $id, $team_members ) {
690 691
 		delete_post_meta( $id, 'team_to_' . $this->tab_slug );
@@ -696,6 +697,7 @@  discard block
 block discarded – undo
696 697
 
697 698
 	/**
698 699
 	 * Saves the room data
700
+	 * @param string $meta_key
699 701
 	 */
700 702
 	public function set_travel_info( $data, $id, $meta_key, $importable = array( 'none' ) ) {
701 703
 		if ( ! empty( $data[0]['travel_information'] ) && isset( $data[0]['travel_information'][ $meta_key ] ) ) {
Please login to merge, or discard this patch.
Spacing   +249 added lines, -249 removed lines patch added patch discarded remove patch
@@ -70,17 +70,17 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	public function set_variables() {
72 72
 		parent::set_variables();
73
-		$this->url    = 'https://wetu.com/API/Pins/' . $this->api_key;
73
+		$this->url    = 'https://wetu.com/API/Pins/'.$this->api_key;
74 74
 		$this->url_qs = 'all=include';
75
-		$temp_options = get_option( '_lsx-to_settings', false );
75
+		$temp_options = get_option('_lsx-to_settings', false);
76 76
 
77
-		if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) {
78
-			$this->options = $temp_options[ $this->plugin_slug ];
77
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
78
+			$this->options = $temp_options[$this->plugin_slug];
79 79
 		}
80 80
 
81
-		$destination_options = get_option( 'wetu_importer_destination_settings', false );
81
+		$destination_options = get_option('wetu_importer_destination_settings', false);
82 82
 
83
-		if ( false !== $destination_options ) {
83
+		if (false !== $destination_options) {
84 84
 			$this->destination_options = $destination_options;
85 85
 		}
86 86
 	}
@@ -91,17 +91,17 @@  discard block
 block discarded – undo
91 91
 	public function display_page() {
92 92
 		?>
93 93
 		<div class="wrap">
94
-			<?php $this->navigation( 'destination' ); ?>
94
+			<?php $this->navigation('destination'); ?>
95 95
 
96 96
 			<?php $this->search_form(); ?>
97 97
 
98 98
 			<form method="get" action="" id="posts-filter">
99
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>"/>
99
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>"/>
100 100
 
101 101
 				<p><input class="button button-primary add" type="button"
102
-						  value="<?php esc_html_e( 'Add to List', 'wetu-importer' ); ?>"/>
102
+						  value="<?php esc_html_e('Add to List', 'wetu-importer'); ?>"/>
103 103
 					<input class="button button-primary clear" type="button"
104
-						   value="<?php esc_html_e( 'Clear', 'wetu-importer' ); ?>"/>
104
+						   value="<?php esc_html_e('Clear', 'wetu-importer'); ?>"/>
105 105
 				</p>
106 106
 
107 107
 				<table class="wp-list-table widefat fixed posts">
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 					<tr class="post-0 type-tour status-none" id="post-0">
112 112
 						<th class="check-column" scope="row">
113 113
 							<label for="cb-select-0"
114
-								   class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter', 'wetu-importer' ); ?></label>
114
+								   class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'wetu-importer'); ?></label>
115 115
 						</th>
116 116
 						<td class="post-title page-title column-title">
117 117
 							<strong>
118
-								<?php esc_html_e( 'Enter a title to search for', 'wetu-importer' ); ?>
118
+								<?php esc_html_e('Enter a title to search for', 'wetu-importer'); ?>
119 119
 							</strong>
120 120
 						</td>
121 121
 						<td class="date column-date">
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 				</table>
131 131
 
132 132
 				<p><input class="button button-primary add" type="button"
133
-						  value="<?php esc_html_e( 'Add to List', 'wetu-importer' ); ?>"/>
133
+						  value="<?php esc_html_e('Add to List', 'wetu-importer'); ?>"/>
134 134
 					<input class="button button-primary clear" type="button"
135
-						   value="<?php esc_html_e( 'Clear', 'wetu-importer' ); ?>"/>
135
+						   value="<?php esc_html_e('Clear', 'wetu-importer'); ?>"/>
136 136
 				</p>
137 137
 			</form>
138 138
 
@@ -142,118 +142,118 @@  discard block
 block discarded – undo
142 142
 
143 143
 					<div class="row">
144 144
 						<div class="settings-all" style="width:30%;display:block;float:left;">
145
-							<h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3>
145
+							<h3><?php esc_html_e('What content to Sync from WETU'); ?></h3>
146 146
 							<ul>
147 147
 								<li>
148
-									<input class="content select-all" <?php $this->checked( $this->destination_options, 'all' ); ?>
148
+									<input class="content select-all" <?php $this->checked($this->destination_options, 'all'); ?>
149 149
 										   type="checkbox" name="content[]"
150
-										   value="all"/> <?php esc_html_e( 'Select All', 'wetu-importer' ); ?></li>
151
-								<?php if ( isset( $this->options ) && 'on' !== $this->options['disable_destination_descriptions'] ) { ?>
150
+										   value="all"/> <?php esc_html_e('Select All', 'wetu-importer'); ?></li>
151
+								<?php if (isset($this->options) && 'on' !== $this->options['disable_destination_descriptions']) { ?>
152 152
 								<li>
153
-									<input class="content" <?php $this->checked( $this->destination_options, 'description' ); ?>
153
+									<input class="content" <?php $this->checked($this->destination_options, 'description'); ?>
154 154
 										   type="checkbox" name="content[]"
155
-										   value="description"/> <?php esc_html_e( 'Description', 'wetu-importer' ); ?></li>
155
+										   value="description"/> <?php esc_html_e('Description', 'wetu-importer'); ?></li>
156 156
 								<?php } ?>
157 157
 
158 158
 								<li>
159
-									<input class="content" <?php $this->checked( $this->destination_options, 'gallery' ); ?>
159
+									<input class="content" <?php $this->checked($this->destination_options, 'gallery'); ?>
160 160
 										   type="checkbox" name="content[]"
161
-										   value="gallery"/> <?php esc_html_e( 'Main Gallery', 'wetu-importer' ); ?></li>
162
-								<?php if ( class_exists( 'LSX_TO_Maps' ) ) { ?>
161
+										   value="gallery"/> <?php esc_html_e('Main Gallery', 'wetu-importer'); ?></li>
162
+								<?php if (class_exists('LSX_TO_Maps')) { ?>
163 163
 									<li>
164
-										<input class="content" <?php $this->checked( $this->destination_options, 'location' ); ?>
164
+										<input class="content" <?php $this->checked($this->destination_options, 'location'); ?>
165 165
 											   type="checkbox" name="content[]"
166
-											   value="location"/> <?php esc_html_e( 'Location', 'wetu-importer' ); ?></li>
166
+											   value="location"/> <?php esc_html_e('Location', 'wetu-importer'); ?></li>
167 167
 								<?php } ?>
168 168
 
169
-								<?php if ( class_exists( 'LSX_TO_Videos' ) ) { ?>
169
+								<?php if (class_exists('LSX_TO_Videos')) { ?>
170 170
 									<li>
171
-										<input class="content" <?php $this->checked( $this->destination_options, 'videos' ); ?>
171
+										<input class="content" <?php $this->checked($this->destination_options, 'videos'); ?>
172 172
 											   type="checkbox" name="content[]"
173
-											   value="videos"/> <?php esc_html_e( 'Videos', 'wetu-importer' ); ?></li>
173
+											   value="videos"/> <?php esc_html_e('Videos', 'wetu-importer'); ?></li>
174 174
 								<?php } ?>
175 175
 
176 176
 							</ul>
177
-							<h4><?php esc_html_e( 'Additional Content' ); ?></h4>
177
+							<h4><?php esc_html_e('Additional Content'); ?></h4>
178 178
 							<ul>
179 179
 								<li>
180
-									<input class="content" <?php $this->checked( $this->destination_options, 'country' ); ?>
180
+									<input class="content" <?php $this->checked($this->destination_options, 'country'); ?>
181 181
 										   type="checkbox" name="content[]"
182
-										   value="country"/> <?php esc_html_e( 'Set Country', 'wetu-importer' ); ?></li>
182
+										   value="country"/> <?php esc_html_e('Set Country', 'wetu-importer'); ?></li>
183 183
 								<li>
184
-									<input class="content" <?php $this->checked( $this->destination_options, 'continent' ); ?>
184
+									<input class="content" <?php $this->checked($this->destination_options, 'continent'); ?>
185 185
 										   type="checkbox" name="content[]"
186
-										   value="continent"/> <?php esc_html_e( 'Set Continent', 'wetu-importer' ); ?></li>
186
+										   value="continent"/> <?php esc_html_e('Set Continent', 'wetu-importer'); ?></li>
187 187
 
188 188
 								<li>
189
-									<input class="content" <?php $this->checked( $this->destination_options, 'featured_image' ); ?>
189
+									<input class="content" <?php $this->checked($this->destination_options, 'featured_image'); ?>
190 190
 										   type="checkbox" name="content[]"
191
-										   value="featured_image"/> <?php esc_html_e( 'Set Featured Image', 'wetu-importer' ); ?>
191
+										   value="featured_image"/> <?php esc_html_e('Set Featured Image', 'wetu-importer'); ?>
192 192
 								</li>
193
-								<?php if ( class_exists( 'LSX_Banners' ) ) { ?>
193
+								<?php if (class_exists('LSX_Banners')) { ?>
194 194
 									<li>
195
-										<input class="content" <?php $this->checked( $this->destination_options, 'banner_image' ); ?>
195
+										<input class="content" <?php $this->checked($this->destination_options, 'banner_image'); ?>
196 196
 											   type="checkbox" name="content[]"
197
-											   value="banner_image"/> <?php esc_html_e( 'Set Banner Image', 'wetu-importer' ); ?>
197
+											   value="banner_image"/> <?php esc_html_e('Set Banner Image', 'wetu-importer'); ?>
198 198
 									</li>
199 199
 									<li>
200
-										<input class="content" <?php $this->checked( $this->destination_options, 'unique_banner_image' ); ?>
200
+										<input class="content" <?php $this->checked($this->destination_options, 'unique_banner_image'); ?>
201 201
 											   type="checkbox" name="content[]"
202
-											   value="unique_banner_image"/> <?php esc_html_e( 'Use the WETU banner field', 'wetu-importer' ); ?>
202
+											   value="unique_banner_image"/> <?php esc_html_e('Use the WETU banner field', 'wetu-importer'); ?>
203 203
 									</li>
204 204
 								<?php } ?>
205 205
 
206 206
 								<li>
207
-									<input class="content" <?php $this->checked( $this->destination_options, 'strip_tags' ); ?>
207
+									<input class="content" <?php $this->checked($this->destination_options, 'strip_tags'); ?>
208 208
 										   type="checkbox" name="content[]"
209
-										   value="strip_tags"/> <?php esc_html_e( 'Strip HTML from the description', 'wetu-importer' ); ?></li>
209
+										   value="strip_tags"/> <?php esc_html_e('Strip HTML from the description', 'wetu-importer'); ?></li>
210 210
 							</ul>
211 211
 						</div>
212 212
 						<div class="settings-all" style="width:30%;display:block;float:left;">
213
-							<h3><?php esc_html_e( 'Travel Information' ); ?></h3>
213
+							<h3><?php esc_html_e('Travel Information'); ?></h3>
214 214
 							<ul>
215 215
 								<li>
216
-									<input class="content" <?php $this->checked( $this->destination_options, 'electricity' ); ?>
216
+									<input class="content" <?php $this->checked($this->destination_options, 'electricity'); ?>
217 217
 										   type="checkbox" name="content[]"
218
-										   value="electricity"/> <?php esc_html_e( 'Electricity', 'wetu-importer' ); ?></li>
218
+										   value="electricity"/> <?php esc_html_e('Electricity', 'wetu-importer'); ?></li>
219 219
 								<li>
220
-									<input class="content" <?php $this->checked( $this->destination_options, 'banking' ); ?>
220
+									<input class="content" <?php $this->checked($this->destination_options, 'banking'); ?>
221 221
 										   type="checkbox" name="content[]"
222
-										   value="banking"/> <?php esc_html_e( 'Banking', 'wetu-importer' ); ?></li>
222
+										   value="banking"/> <?php esc_html_e('Banking', 'wetu-importer'); ?></li>
223 223
 								<li>
224
-									<input class="content" <?php $this->checked( $this->destination_options, 'cuisine' ); ?>
224
+									<input class="content" <?php $this->checked($this->destination_options, 'cuisine'); ?>
225 225
 										   type="checkbox" name="content[]"
226
-										   value="cuisine"/> <?php esc_html_e( 'Cuisine', 'wetu-importer' ); ?></li>
226
+										   value="cuisine"/> <?php esc_html_e('Cuisine', 'wetu-importer'); ?></li>
227 227
 								<li>
228
-									<input class="content" <?php $this->checked( $this->destination_options, 'climate' ); ?>
228
+									<input class="content" <?php $this->checked($this->destination_options, 'climate'); ?>
229 229
 										   type="checkbox" name="content[]"
230
-										   value="climate"/> <?php esc_html_e( 'Climate', 'wetu-importer' ); ?></li>
230
+										   value="climate"/> <?php esc_html_e('Climate', 'wetu-importer'); ?></li>
231 231
 								<li>
232
-									<input class="content" <?php $this->checked( $this->destination_options, 'transport' ); ?>
232
+									<input class="content" <?php $this->checked($this->destination_options, 'transport'); ?>
233 233
 										   type="checkbox" name="content[]"
234
-										   value="transport"/> <?php esc_html_e( 'Transport', 'wetu-importer' ); ?></li>
235
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'dress' ); ?>
234
+										   value="transport"/> <?php esc_html_e('Transport', 'wetu-importer'); ?></li>
235
+								<li><input class="content" <?php $this->checked($this->destination_options, 'dress'); ?>
236 236
 										   type="checkbox" name="content[]"
237
-										   value="dress"/> <?php esc_html_e( 'Dress', 'wetu-importer' ); ?></li>
238
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'health' ); ?>
237
+										   value="dress"/> <?php esc_html_e('Dress', 'wetu-importer'); ?></li>
238
+								<li><input class="content" <?php $this->checked($this->destination_options, 'health'); ?>
239 239
 										   type="checkbox" name="content[]"
240
-										   value="health"/> <?php esc_html_e( 'Health', 'wetu-importer' ); ?></li>
241
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'safety' ); ?>
240
+										   value="health"/> <?php esc_html_e('Health', 'wetu-importer'); ?></li>
241
+								<li><input class="content" <?php $this->checked($this->destination_options, 'safety'); ?>
242 242
 										   type="checkbox" name="content[]"
243
-										   value="safety"/> <?php esc_html_e( 'Safety', 'wetu-importer' ); ?></li>
244
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'visa' ); ?>
243
+										   value="safety"/> <?php esc_html_e('Safety', 'wetu-importer'); ?></li>
244
+								<li><input class="content" <?php $this->checked($this->destination_options, 'visa'); ?>
245 245
 										   type="checkbox" name="content[]"
246
-										   value="visa"/> <?php esc_html_e( 'Visa', 'wetu-importer' ); ?></li>
247
-								<li><input class="content" <?php $this->checked( $this->destination_options, 'additional_info' ); ?>
246
+										   value="visa"/> <?php esc_html_e('Visa', 'wetu-importer'); ?></li>
247
+								<li><input class="content" <?php $this->checked($this->destination_options, 'additional_info'); ?>
248 248
 										   type="checkbox" name="content[]"
249
-										   value="additional_info"/> <?php esc_html_e( 'General', 'wetu-importer' ); ?></li>
249
+										   value="additional_info"/> <?php esc_html_e('General', 'wetu-importer'); ?></li>
250 250
 							</ul>
251 251
 						</div>
252 252
 
253
-						<?php if ( class_exists( 'LSX_TO_Team' ) ) { ?>
253
+						<?php if (class_exists('LSX_TO_Team')) { ?>
254 254
 							<div style="width:30%;display:block;float:left;">
255
-								<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3>
256
-								<?php $this->team_member_checkboxes( $this->destination_options ); ?>
255
+								<h3><?php esc_html_e('Assign a Team Member'); ?></h3>
256
+								<?php $this->team_member_checkboxes($this->destination_options); ?>
257 257
 							</div>
258 258
 						<?php } ?>
259 259
 
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
 					</div>
262 262
 
263 263
 
264
-					<h3><?php esc_html_e( 'Your List' ); ?></h3>
264
+					<h3><?php esc_html_e('Your List'); ?></h3>
265 265
 					<p><input class="button button-primary" type="submit"
266
-							  value="<?php esc_html_e( 'Sync', 'wetu-importer' ); ?>"/></p>
266
+							  value="<?php esc_html_e('Sync', 'wetu-importer'); ?>"/></p>
267 267
 					<table class="wp-list-table widefat fixed posts">
268 268
 						<?php $this->table_header(); ?>
269 269
 
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
 					</table>
277 277
 
278 278
 					<p><input class="button button-primary" type="submit"
279
-							  value="<?php esc_html_e( 'Sync', 'wetu-importer' ); ?>"/></p>
279
+							  value="<?php esc_html_e('Sync', 'wetu-importer'); ?>"/></p>
280 280
 				</form>
281 281
 			</div>
282 282
 
283 283
 			<div style="display:none;" class="completed-list-wrapper">
284
-				<h3><?php esc_html_e( 'Completed' ); ?></h3>
284
+				<h3><?php esc_html_e('Completed'); ?></h3>
285 285
 				<ul>
286 286
 				</ul>
287 287
 			</div>
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	/**
293 293
 	 * Grab all the current destination posts via the lsx_wetu_id field.
294 294
 	 */
295
-	public function find_current_destination( $post_type = 'destination' ) {
295
+	public function find_current_destination($post_type = 'destination') {
296 296
 		global $wpdb;
297 297
 		$return = array();
298 298
 
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 		");
312 312
 		// @codingStandardsIgnoreEnd
313 313
 
314
-		if ( null !== $current_destination && ! empty( $current_destination ) ) {
315
-			foreach ( $current_destination as $accom ) {
316
-				$return[ $accom->meta_value ] = $accom;
314
+		if (null !== $current_destination && !empty($current_destination)) {
315
+			foreach ($current_destination as $accom) {
316
+				$return[$accom->meta_value] = $accom;
317 317
 			}
318 318
 		}
319 319
 
@@ -327,120 +327,120 @@  discard block
 block discarded – undo
327 327
 		$return = false;
328 328
 
329 329
 		// @codingStandardsIgnoreLine
330
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_tour_importer' && isset( $_POST['type'] ) && $_POST['type'] === 'destination' ) {
330
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'destination') {
331 331
 
332 332
 			$searched_items = false;
333 333
 
334 334
 			// @codingStandardsIgnoreLine
335
-			if ( isset( $_POST['keyword'] ) ) {
335
+			if (isset($_POST['keyword'])) {
336 336
 				// @codingStandardsIgnoreLine
337 337
 				$keyphrases = $_POST['keyword'];
338
-			} else {
339
-				$keyphrases = array( 0 );
338
+			}else {
339
+				$keyphrases = array(0);
340 340
 			}
341 341
 
342
-			if ( ! is_array( $keyphrases ) ) {
343
-				$keyphrases = array( $keyphrases );
342
+			if (!is_array($keyphrases)) {
343
+				$keyphrases = array($keyphrases);
344 344
 			}
345
-			foreach ( $keyphrases as &$keyword ) {
346
-				$keyword = ltrim( rtrim( $keyword ) );
345
+			foreach ($keyphrases as &$keyword) {
346
+				$keyword = ltrim(rtrim($keyword));
347 347
 			}
348 348
 
349 349
 			$post_status = false;
350 350
 
351
-			if ( in_array( 'publish', $keyphrases ) ) {
351
+			if (in_array('publish', $keyphrases)) {
352 352
 				$post_status = 'publish';
353 353
 			}
354
-			if ( in_array( 'pending', $keyphrases ) ) {
354
+			if (in_array('pending', $keyphrases)) {
355 355
 				$post_status = 'pending';
356 356
 			}
357
-			if ( in_array( 'draft', $keyphrases ) ) {
357
+			if (in_array('draft', $keyphrases)) {
358 358
 				$post_status = 'draft';
359 359
 			}
360
-			if ( in_array( 'import', $keyphrases ) ) {
360
+			if (in_array('import', $keyphrases)) {
361 361
 				$post_status = 'import';
362 362
 			}
363 363
 
364 364
 			// If there is a post status use it.
365
-			if ( false !== $post_status ) {
365
+			if (false !== $post_status) {
366 366
 
367 367
 				$accommodation = array();
368
-				$current_accommodation = $this->find_current_accommodation( 'destination' );
369
-				if ( ! empty( $current_accommodation ) ) {
370
-					foreach ( $current_accommodation as $cs_key => $ccs_id ) {
371
-						$accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id );
368
+				$current_accommodation = $this->find_current_accommodation('destination');
369
+				if (!empty($current_accommodation)) {
370
+					foreach ($current_accommodation as $cs_key => $ccs_id) {
371
+						$accommodation[] = $this->prepare_row_attributes($cs_key, $ccs_id->post_id);
372 372
 					}
373 373
 				}
374 374
 
375 375
 				// Run through each accommodation and use it.
376
-				if ( ! empty( $accommodation ) ) {
377
-					foreach ( $accommodation as $row_key => $row ) {
378
-						if ( 'import' === $post_status ) {
379
-
380
-							if ( is_array( $this->queued_imports ) && in_array( $row['post_id'], $this->queued_imports ) ) {
381
-								$current_status = get_post_status( $row['post_id'] );
382
-								if ( 'draft' === $current_status ) {
383
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
376
+				if (!empty($accommodation)) {
377
+					foreach ($accommodation as $row_key => $row) {
378
+						if ('import' === $post_status) {
379
+
380
+							if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) {
381
+								$current_status = get_post_status($row['post_id']);
382
+								if ('draft' === $current_status) {
383
+									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
384 384
 								}
385
-							} else {
385
+							}else {
386 386
 								continue;
387 387
 							}
388
-						} else {
389
-							if ( 0 === $row['post_id'] ) {
388
+						}else {
389
+							if (0 === $row['post_id']) {
390 390
 								continue;
391
-							} else {
392
-								$current_status = get_post_status( $row['post_id'] );
391
+							}else {
392
+								$current_status = get_post_status($row['post_id']);
393 393
 
394
-								if ( $current_status !== $post_status ) {
394
+								if ($current_status !== $post_status) {
395 395
 									continue;
396 396
 								}
397 397
 							}
398
-							$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
398
+							$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
399 399
 						}
400 400
 					}
401 401
 				}
402 402
 
403
-			} else {
403
+			}else {
404 404
 
405
-				$key_string_search = implode( '+', $keyphrases );
406
-				$search_data = file_get_contents( $this->url . '/Search/' . $key_string_search . '/?all=include' );
407
-				$search_data = json_decode( $search_data, true );
405
+				$key_string_search = implode('+', $keyphrases);
406
+				$search_data = file_get_contents($this->url.'/Search/'.$key_string_search.'/?all=include');
407
+				$search_data = json_decode($search_data, true);
408 408
 
409
-				if ( ! isset( $search_data['error'] ) ) {
410
-					foreach ( $search_data as $sdata ) {
409
+				if (!isset($search_data['error'])) {
410
+					foreach ($search_data as $sdata) {
411 411
 
412
-						if ( 'Destination' !== trim( $sdata['type'] ) ) {
412
+						if ('Destination' !== trim($sdata['type'])) {
413 413
 							continue;
414 414
 						}
415 415
 
416
-						$temp_id = $this->get_post_id_by_key_value( $sdata['id'] );
417
-						if ( false === $temp_id ) {
416
+						$temp_id = $this->get_post_id_by_key_value($sdata['id']);
417
+						if (false === $temp_id) {
418 418
 							$sdata['post_id'] = 0;
419
-						} else {
419
+						}else {
420 420
 							$sdata['post_id'] = $temp_id;
421 421
 						}
422
-						$searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata );
422
+						$searched_items[sanitize_title($sdata['name']).'-'.$sdata['id']] = $this->format_row($sdata);
423 423
 					}
424 424
 				}
425 425
 			}
426 426
 
427
-			if ( false !== $searched_items ) {
428
-				ksort( $searched_items );
429
-				$return = implode( $searched_items );
427
+			if (false !== $searched_items) {
428
+				ksort($searched_items);
429
+				$return = implode($searched_items);
430 430
 			}
431 431
 
432
-			print_r( $return );
432
+			print_r($return);
433 433
 		}
434 434
 
435 435
 		die();
436 436
 	}
437 437
 
438
-	public function prepare_row_attributes( $cs_key, $ccs_id ) {
438
+	public function prepare_row_attributes($cs_key, $ccs_id) {
439 439
 		return 	$row_item = array(
440 440
 			'id' => $cs_key,
441 441
 			'type' => 'Destination',
442
-			'name' => get_the_title( $ccs_id ),
443
-			'last_modified' => date('Y-m-d', strtotime( 'now' ) ),
442
+			'name' => get_the_title($ccs_id),
443
+			'last_modified' => date('Y-m-d', strtotime('now')),
444 444
 			'post_id' => $ccs_id,
445 445
 		);
446 446
 	}
@@ -448,28 +448,28 @@  discard block
 block discarded – undo
448 448
 	/**
449 449
 	 * Formats the row for output on the screen.
450 450
 	 */
451
-	public function format_row( $row = false ) {
452
-		if ( false !== $row ) {
451
+	public function format_row($row = false) {
452
+		if (false !== $row) {
453 453
 
454 454
 			$status = 'import';
455
-			if ( 0 !== $row['post_id'] ) {
456
-				$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>';
455
+			if (0 !== $row['post_id']) {
456
+				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
457 457
 			}
458 458
 
459 459
 			$row_html = '
460
-			<tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '">
460
+			<tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'">
461 461
 				<th class="check-column" scope="row">
462
-					<label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label>
463
-					<input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '">
462
+					<label for="cb-select-' . $row['id'].'" class="screen-reader-text">'.$row['name'].'</label>
463
+					<input type="checkbox" data-identifier="' . $row['id'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['id'].'">
464 464
 				</th>
465 465
 				<td class="post-title page-title column-title">
466
-					<strong>' . $row['name'] . '</strong> - ' . $status . '
466
+					<strong>' . $row['name'].'</strong> - '.$status.'
467 467
 				</td>
468 468
 				<td class="date column-date">
469
-					<abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified
469
+					<abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
470 470
 				</td>
471 471
 				<td class="ssid column-ssid">
472
-					' . $row['id'] . '
472
+					' . $row['id'].'
473 473
 				</td>
474 474
 			</tr>';
475 475
 			return $row_html;
@@ -483,49 +483,49 @@  discard block
 block discarded – undo
483 483
 		$return = false;
484 484
 
485 485
 		// @codingStandardsIgnoreLine
486
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === 'destination' && isset( $_POST['wetu_id'] ) ) {
486
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'destination' && isset($_POST['wetu_id'])) {
487 487
 			// @codingStandardsIgnoreLine
488 488
 			$wetu_id = $_POST['wetu_id'];
489 489
 
490 490
 			// @codingStandardsIgnoreLine
491
-			if ( isset( $_POST['post_id'] ) ) {
491
+			if (isset($_POST['post_id'])) {
492 492
 				// @codingStandardsIgnoreLine
493 493
 				$post_id = $_POST['post_id'];
494
-				$this->current_post = get_post( $post_id );
495
-			} else {
494
+				$this->current_post = get_post($post_id);
495
+			}else {
496 496
 				$post_id = 0;
497 497
 			}
498 498
 
499 499
 			// @codingStandardsIgnoreLine
500
-			if ( isset( $_POST['team_members'] ) ) {
500
+			if (isset($_POST['team_members'])) {
501 501
 				// @codingStandardsIgnoreLine
502 502
 				$team_members = $_POST['team_members'];
503
-			} else {
503
+			}else {
504 504
 				$team_members = false;
505 505
 			}
506 506
 
507 507
 			$safari_brands = false;
508 508
 
509
-			delete_option( 'wetu_importer_destination_settings' );
509
+			delete_option('wetu_importer_destination_settings');
510 510
 
511 511
 			// @codingStandardsIgnoreLine
512
-			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
512
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
513 513
 				// @codingStandardsIgnoreLine
514 514
 				$content = $_POST['content'];
515
-				add_option( 'wetu_importer_destination_settings', $content );
516
-			} else {
515
+				add_option('wetu_importer_destination_settings', $content);
516
+			}else {
517 517
 				$content = false;
518 518
 			}
519 519
 
520
-			$jdata = wp_remote_get( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
520
+			$jdata = wp_remote_get($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
521 521
 
522
-			if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
523
-				$adata = json_decode( $jdata, true );
524
-				$return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands );
525
-				$this->remove_from_queue( $return );
526
-				$this->format_completed_row( $return );
527
-			} else {
528
-				$this->format_error( esc_html__( 'There was a problem importing your destination, please try refreshing the page.', 'wetu-importer' ) );
522
+			if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
523
+				$adata = json_decode($jdata, true);
524
+				$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
525
+				$this->remove_from_queue($return);
526
+				$this->format_completed_row($return);
527
+			}else {
528
+				$this->format_error(esc_html__('There was a problem importing your destination, please try refreshing the page.', 'wetu-importer'));
529 529
 			}
530 530
 		}
531 531
 	}
@@ -533,14 +533,14 @@  discard block
 block discarded – undo
533 533
 	/**
534 534
 	 * Saves the queue to the option.
535 535
 	 */
536
-	public function remove_from_queue( $id ) {
537
-		if ( ! empty( $this->queued_imports ) ) {
536
+	public function remove_from_queue($id) {
537
+		if (!empty($this->queued_imports)) {
538 538
 			// @codingStandardsIgnoreLine
539
-			if ( ( $key = array_search( $id, $this->queued_imports ) ) !== false ) {
540
-				unset( $this->queued_imports[ $key ] );
539
+			if (($key = array_search($id, $this->queued_imports)) !== false) {
540
+				unset($this->queued_imports[$key]);
541 541
 
542
-				delete_option( 'wetu_importer_que' );
543
-				update_option( 'wetu_importer_que', $this->queued_imports );
542
+				delete_option('wetu_importer_que');
543
+				update_option('wetu_importer_que', $this->queued_imports);
544 544
 			}
545 545
 		}
546 546
 	}
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
 	/**
549 549
 	 * Connect to wetu
550 550
 	 */
551
-	public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false ) {
552
-		if ( 'Destination' === trim( $data[0]['type'] ) ) {
551
+	public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false) {
552
+		if ('Destination' === trim($data[0]['type'])) {
553 553
 			$post_name = '';
554 554
 			$data_post_content = '';
555 555
 			$data_post_excerpt = '';
@@ -558,132 +558,132 @@  discard block
 block discarded – undo
558 558
 				'post_type' => 'destination',
559 559
 			);
560 560
 
561
-			if ( ! empty( $importable_content ) && in_array( 'country', $importable_content ) ) {
562
-				$parent = $this->check_for_parent( $data );
563
-				if( false !== $parent ) {
561
+			if (!empty($importable_content) && in_array('country', $importable_content)) {
562
+				$parent = $this->check_for_parent($data);
563
+				if (false !== $parent) {
564 564
 					$post['post_parent'] = $parent;
565 565
 				}
566 566
 			}
567 567
 
568 568
 			//Set the post_content
569
-			if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) {
570
-				if ( isset( $data[0]['content']['general_description'] ) ) {
569
+			if (!empty($importable_content) && in_array('description', $importable_content)) {
570
+				if (isset($data[0]['content']['general_description'])) {
571 571
 
572
-					if ( in_array( 'strip_tags', $importable_content ) ) {
573
-						$post['post_content'] = wp_strip_all_tags( $data[0]['content']['general_description'] );
574
-					} else {
572
+					if (in_array('strip_tags', $importable_content)) {
573
+						$post['post_content'] = wp_strip_all_tags($data[0]['content']['general_description']);
574
+					}else {
575 575
 						$post['post_content'] = $data[0]['content']['general_description'];
576 576
 					}
577 577
 				}
578 578
 			}
579 579
 
580
-			if ( false !== $id && '0' !== $id ) {
580
+			if (false !== $id && '0' !== $id) {
581 581
 				$post['ID'] = $id;
582 582
 
583
-				if ( isset( $data[0]['name'] ) ) {
583
+				if (isset($data[0]['name'])) {
584 584
 					$post['post_title'] = $data[0]['name'];
585 585
 					$post['post_status'] = 'publish';
586
-					$post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 );
586
+					$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
587 587
 				}
588 588
 
589
-				$id = wp_update_post( $post );
590
-				$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
591
-				update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date );
592
-			} else {
589
+				$id = wp_update_post($post);
590
+				$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
591
+				update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
592
+			}else {
593 593
 				// Set the name.
594
-				if ( isset( $data[0]['name'] ) ) {
595
-					$post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 );
594
+				if (isset($data[0]['name'])) {
595
+					$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0);
596 596
 				}
597 597
 
598 598
 				$post['post_name'] = $post_name;
599 599
 				$post['post_title'] = $data[0]['name'];
600 600
 				$post['post_status'] = 'publish';
601
-				$id = wp_insert_post( $post );
601
+				$id = wp_insert_post($post);
602 602
 
603 603
 				// Save the WETU ID and the Last date it was modified.
604
-				if ( false !== $id ) {
605
-					add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
606
-					add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) );
604
+				if (false !== $id) {
605
+					add_post_meta($id, 'lsx_wetu_id', $wetu_id);
606
+					add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']));
607 607
 				}
608 608
 			}
609 609
 
610
-			$this->find_attachments( $id );
610
+			$this->find_attachments($id);
611 611
 
612 612
 			// Set the team member if it is there.
613
-			if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) {
614
-				$this->set_team_member( $id, $team_members );
613
+			if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
614
+				$this->set_team_member($id, $team_members);
615 615
 			}
616 616
 
617
-			if ( class_exists( 'LSX_TO_Maps' ) ) {
618
-				$this->set_map_data( $data, $id, 9 );
617
+			if (class_exists('LSX_TO_Maps')) {
618
+				$this->set_map_data($data, $id, 9);
619 619
 			}
620 620
 
621 621
 			// Set the Room Data.
622
-			if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) {
623
-				$this->set_video_data( $data, $id );
622
+			if (false !== $importable_content && in_array('videos', $importable_content)) {
623
+				$this->set_video_data($data, $id);
624 624
 			}
625 625
 
626 626
 			// Set the Electricity.
627
-			if ( false !== $importable_content && in_array( 'electricity', $importable_content ) ) {
628
-				$this->set_travel_info( $data, $id, 'electricity', $importable_content );
627
+			if (false !== $importable_content && in_array('electricity', $importable_content)) {
628
+				$this->set_travel_info($data, $id, 'electricity', $importable_content);
629 629
 			}
630 630
 			// Set the cuisine.
631
-			if ( false !== $importable_content && in_array( 'cuisine', $importable_content ) ) {
632
-				$this->set_travel_info( $data, $id, 'cuisine', $importable_content );
631
+			if (false !== $importable_content && in_array('cuisine', $importable_content)) {
632
+				$this->set_travel_info($data, $id, 'cuisine', $importable_content);
633 633
 			}
634 634
 			// Set the banking.
635
-			if ( false !== $importable_content && in_array( 'banking', $importable_content ) ) {
636
-				$this->set_travel_info( $data, $id, 'banking', $importable_content );
635
+			if (false !== $importable_content && in_array('banking', $importable_content)) {
636
+				$this->set_travel_info($data, $id, 'banking', $importable_content);
637 637
 			}
638 638
 			// Set the transport.
639
-			if ( false !== $importable_content && in_array( 'transport', $importable_content ) ) {
640
-				$this->set_travel_info( $data, $id, 'transport', $importable_content );
639
+			if (false !== $importable_content && in_array('transport', $importable_content)) {
640
+				$this->set_travel_info($data, $id, 'transport', $importable_content);
641 641
 			}
642 642
 			// Set the dress.
643
-			if ( false !== $importable_content && in_array( 'dress', $importable_content ) ) {
644
-				$this->set_travel_info( $data, $id, 'dress', $importable_content );
643
+			if (false !== $importable_content && in_array('dress', $importable_content)) {
644
+				$this->set_travel_info($data, $id, 'dress', $importable_content);
645 645
 			}
646 646
 			// Set the climate.
647
-			if ( false !== $importable_content && in_array( 'climate', $importable_content ) ) {
648
-				$this->set_travel_info( $data, $id, 'climate', $importable_content );
647
+			if (false !== $importable_content && in_array('climate', $importable_content)) {
648
+				$this->set_travel_info($data, $id, 'climate', $importable_content);
649 649
 			}
650 650
 			// Set the Health.
651
-			if ( false !== $importable_content && in_array( 'health', $importable_content ) ) {
652
-				$this->set_travel_info( $data, $id, 'health', $importable_content );
651
+			if (false !== $importable_content && in_array('health', $importable_content)) {
652
+				$this->set_travel_info($data, $id, 'health', $importable_content);
653 653
 			}
654 654
 			// Set the Safety.
655
-			if ( false !== $importable_content && in_array( 'safety', $importable_content ) ) {
656
-				$this->set_travel_info( $data, $id, 'safety', $importable_content );
655
+			if (false !== $importable_content && in_array('safety', $importable_content)) {
656
+				$this->set_travel_info($data, $id, 'safety', $importable_content);
657 657
 			}
658 658
 			// Set the Visa.
659
-			if ( false !== $importable_content && in_array( 'visa', $importable_content ) ) {
660
-				$this->set_travel_info( $data, $id, 'visa', $importable_content );
659
+			if (false !== $importable_content && in_array('visa', $importable_content)) {
660
+				$this->set_travel_info($data, $id, 'visa', $importable_content);
661 661
 			}
662 662
 			// Set the General.
663
-			if ( false !== $importable_content && in_array( 'additional_info', $importable_content ) ) {
664
-				$this->set_travel_info( $data, $id, 'additional_info', $importable_content );
663
+			if (false !== $importable_content && in_array('additional_info', $importable_content)) {
664
+				$this->set_travel_info($data, $id, 'additional_info', $importable_content);
665 665
 			}
666 666
 
667 667
 			// Setup some default for use in the import.
668
-			if ( false !== $importable_content && (in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content )) ) {
669
-				$this->find_attachments( $id );
668
+			if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) {
669
+				$this->find_attachments($id);
670 670
 
671 671
 				// Set the featured image.
672
-				if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
673
-					$this->set_featured_image( $data, $id );
672
+				if (false !== $importable_content && in_array('featured_image', $importable_content)) {
673
+					$this->set_featured_image($data, $id);
674 674
 				}
675
-				if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
676
-					$this->set_banner_image( $data, $id, $importable_content );
675
+				if (false !== $importable_content && in_array('banner_image', $importable_content)) {
676
+					$this->set_banner_image($data, $id, $importable_content);
677 677
 				}
678 678
 				// Import the main gallery.
679
-				if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) {
680
-					$this->create_main_gallery( $data, $id );
679
+				if (false !== $importable_content && in_array('gallery', $importable_content)) {
680
+					$this->create_main_gallery($data, $id);
681 681
 				}
682 682
 			}
683 683
 
684 684
 			// Set the continent.
685
-			if ( false !== $importable_content && in_array( 'continent', $importable_content ) ) {
686
-				$this->set_continent( $data, $id );
685
+			if (false !== $importable_content && in_array('continent', $importable_content)) {
686
+				$this->set_continent($data, $id);
687 687
 			}
688 688
 		}
689 689
 
@@ -693,49 +693,49 @@  discard block
 block discarded – undo
693 693
 	/**
694 694
 	 * Set the team memberon each item.
695 695
 	 */
696
-	public function set_team_member( $id, $team_members ) {
697
-		delete_post_meta( $id, 'team_to_' . $this->tab_slug );
696
+	public function set_team_member($id, $team_members) {
697
+		delete_post_meta($id, 'team_to_'.$this->tab_slug);
698 698
 
699
-		foreach ( $team_members as $team ) {
700
-			add_post_meta( $id, 'team_to_' . $this->tab_slug, $team );
699
+		foreach ($team_members as $team) {
700
+			add_post_meta($id, 'team_to_'.$this->tab_slug, $team);
701 701
 		}
702 702
 	}
703 703
 
704 704
 	/**
705 705
 	 * Saves the room data
706 706
 	 */
707
-	public function set_travel_info( $data, $id, $meta_key, $importable = array( 'none' ) ) {
708
-		if ( ! empty( $data[0]['travel_information'] ) && isset( $data[0]['travel_information'][ $meta_key ] ) ) {
709
-			$content = $data[0]['travel_information'][ $meta_key ];
707
+	public function set_travel_info($data, $id, $meta_key, $importable = array('none')) {
708
+		if (!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])) {
709
+			$content = $data[0]['travel_information'][$meta_key];
710 710
 
711
-			if ( in_array( 'strip_tags', $importable ) ) {
712
-				$content = strip_tags( $content );
711
+			if (in_array('strip_tags', $importable)) {
712
+				$content = strip_tags($content);
713 713
 			}
714 714
 
715
-			$this->save_custom_field( $content, $meta_key, $id );
715
+			$this->save_custom_field($content, $meta_key, $id);
716 716
 		}
717 717
 	}
718 718
 
719 719
 	/**
720 720
 	 * Set the Travel Style
721 721
 	 */
722
-	public function set_continent( $data, $id ) {
722
+	public function set_continent($data, $id) {
723 723
 
724
-		if ( isset( $data[0]['position']['country'] ) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id'] ) {
724
+		if (isset($data[0]['position']['country']) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id']) {
725 725
 			//get the continent code.
726
-			$continent_code = to_continent_label( to_continent_code( to_country_data( $data[0]['position']['country'], false ) ) );
726
+			$continent_code = to_continent_label(to_continent_code(to_country_data($data[0]['position']['country'], false)));
727 727
 
728
-			if ( '' !== $continent_code ) {
728
+			if ('' !== $continent_code) {
729 729
 				// @codingStandardsIgnoreLine
730
-				if ( ! $term = term_exists( trim( $continent_code ), 'continent' ) ) {
731
-					$term = wp_insert_term( trim( $continent_code ), 'continent' );
730
+				if (!$term = term_exists(trim($continent_code), 'continent')) {
731
+					$term = wp_insert_term(trim($continent_code), 'continent');
732 732
 
733
-					if ( is_wp_error( $term ) ) {
733
+					if (is_wp_error($term)) {
734 734
 						// @codingStandardsIgnoreLine
735 735
 						echo $term->get_error_message();
736 736
 					}
737
-				} else {
738
-					wp_set_object_terms( $id, sanitize_title( $continent_code ), 'continent', true );
737
+				}else {
738
+					wp_set_object_terms($id, sanitize_title($continent_code), 'continent', true);
739 739
 				}
740 740
 			}
741 741
 		}
@@ -745,14 +745,14 @@  discard block
 block discarded – undo
745 745
 	 * Save the list of Accommodation into an option
746 746
 	 */
747 747
 	public function update_options() {
748
-		$data = file_get_contents( $this->url . '/List?' . $this->url_qs );
748
+		$data = file_get_contents($this->url.'/List?'.$this->url_qs);
749 749
 
750
-		$accommodation = json_decode( $data, true );
750
+		$accommodation = json_decode($data, true);
751 751
 
752
-		if ( isset( $accommodation['error'] ) ) {
752
+		if (isset($accommodation['error'])) {
753 753
 			return $accommodation['error'];
754
-		} elseif ( isset( $accommodation ) && ! empty( $accommodation ) ) {
755
-			set_transient( 'lsx_ti_accommodation', $accommodation,60 * 60 * 2 );
754
+		} elseif (isset($accommodation) && !empty($accommodation)) {
755
+			set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2);
756 756
 			return true;
757 757
 		}
758 758
 	}
@@ -761,11 +761,11 @@  discard block
 block discarded – undo
761 761
 	 * search_form
762 762
 	 */
763 763
 	public function update_options_form() {
764
-		echo '<div style="display:none;" class="wetu-status"><h3>' . esc_html__( 'Wetu Status', 'wetu-importer' ) . '</h3>';
764
+		echo '<div style="display:none;" class="wetu-status"><h3>'.esc_html__('Wetu Status', 'wetu-importer').'</h3>';
765 765
 
766
-		$accommodation = get_transient( 'lsx_ti_accommodation' );
766
+		$accommodation = get_transient('lsx_ti_accommodation');
767 767
 
768
-		if ( '' === $accommodation || false === $accommodation || isset( $_GET['refresh_accommodation'] ) ) {
768
+		if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) {
769 769
 			$this->update_options();
770 770
 		}
771 771
 
@@ -775,19 +775,19 @@  discard block
 block discarded – undo
775 775
 	/**
776 776
 	 * Save the list of Accommodation into an option
777 777
 	 */
778
-	public function check_for_parent( $data = array() ) {
778
+	public function check_for_parent($data = array()) {
779 779
 		global $wpdb;
780 780
 
781
-		if ( $data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id'] ) {
781
+		if ($data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id']) {
782 782
 			$query = "
783 783
 			SELECT post_id
784 784
 			FROM {$wpdb->postmeta}
785 785
 			WHERE meta_key = 'lsx_wetu_id'
786 786
 			AND meta_value = {$data[0]['position']['country_content_entity_id']}";
787 787
 
788
-			$result = $wpdb->get_var( $query );
788
+			$result = $wpdb->get_var($query);
789 789
 
790
-			if ( ! empty( $result ) && '' !== $result && false !== $result ) {
790
+			if (!empty($result) && '' !== $result && false !== $result) {
791 791
 				return $result;
792 792
 			}
793 793
 		}
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.
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.
classes/class-wetu-importer-accommodation.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -349,11 +349,11 @@
 block discarded – undo
349 349
 					foreach ( $search_data as $sdata ) {
350 350
 
351 351
 						if ( 'Destination'  	 === trim( $sdata['type'] ) ||
352
-						     'Activity' 		 === trim( $sdata['type'] ) ||
353
-						     'Restaurant' 		 === trim( $sdata['type'] ) ||
354
-						     'None' 			 === trim( $sdata['type'] ) ||
355
-						     'Site / Attraction' === trim( $sdata['type'] ) ||
356
-						     '' 				 === trim( $sdata['type'] )
352
+							 'Activity' 		 === trim( $sdata['type'] ) ||
353
+							 'Restaurant' 		 === trim( $sdata['type'] ) ||
354
+							 'None' 			 === trim( $sdata['type'] ) ||
355
+							 'Site / Attraction' === trim( $sdata['type'] ) ||
356
+							 '' 				 === trim( $sdata['type'] )
357 357
 						) {
358 358
 							continue;
359 359
 						}
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 	 * Formats the row for output on the screen.
394 394
 	 *
395 395
 	 * @param boolean $row the current row to format.
396
-	 * @return void
396
+	 * @return string|null
397 397
 	 */
398 398
 	public function format_row( $row = false ) {
399 399
 		if ( false !== $row ) {
@@ -652,6 +652,7 @@  discard block
 block discarded – undo
652 652
 
653 653
 	/**
654 654
 	 * Set the team memberon each item.
655
+	 * @param boolean $team_members
655 656
 	 */
656 657
 	public function set_team_member( $id, $team_members ) {
657 658
 		delete_post_meta( $id, 'team_to_' . $this->tab_slug );
@@ -663,6 +664,7 @@  discard block
 block discarded – undo
663 664
 
664 665
 	/**
665 666
 	 * Set the safari brand
667
+	 * @param boolean $safari_brands
666 668
 	 */
667 669
 	public function set_safari_brands( $id, $safari_brands ) {
668 670
 		foreach ( $safari_brands as $safari_brand ) {
Please login to merge, or discard this patch.
Spacing   +293 added lines, -293 removed lines patch added patch discarded remove patch
@@ -76,19 +76,19 @@  discard block
 block discarded – undo
76 76
 		//	$this->url    = 'https://wetu.com/API/Pins/';
77 77
 		//	$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
78 78
 		//} elseif ( false !== $this->api_key ) {
79
-			$this->url    = 'https://wetu.com/API/Pins/' . $this->api_key;
79
+			$this->url    = 'https://wetu.com/API/Pins/'.$this->api_key;
80 80
 			$this->url_qs = 'all=include';
81 81
 		//}
82 82
 
83
-		$temp_options = get_option( '_lsx-to_settings', false );
83
+		$temp_options = get_option('_lsx-to_settings', false);
84 84
 
85
-		if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) {
86
-			$this->options = $temp_options[ $this->plugin_slug ];
85
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
86
+			$this->options = $temp_options[$this->plugin_slug];
87 87
 		}
88 88
 
89
-		$accommodation_options = get_option( 'wetu_importer_accommodation_settings',false );
89
+		$accommodation_options = get_option('wetu_importer_accommodation_settings', false);
90 90
 
91
-		if ( false !== $accommodation_options ) {
91
+		if (false !== $accommodation_options) {
92 92
 			$this->accommodation_options = $accommodation_options;
93 93
 		}
94 94
 	}
@@ -99,17 +99,17 @@  discard block
 block discarded – undo
99 99
 	public function display_page() {
100 100
 		?>
101 101
 		<div class="wrap">
102
-			<?php $this->navigation( 'accommodation' ); ?>
102
+			<?php $this->navigation('accommodation'); ?>
103 103
 
104 104
 			<?php $this->update_options_form(); ?>
105 105
 
106 106
 			<?php $this->search_form(); ?>
107 107
 
108 108
 			<form method="get" action="" id="posts-filter">
109
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
109
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" />
110 110
 
111
-				<p><input class="button button-primary add" type="button" value="<?php esc_attr_e( 'Add to List', 'wetu-importer' ); ?>" />
112
-					<input class="button button-primary clear" type="button" value="<?php esc_attr_e( 'Clear', 'wetu-importer' ); ?>" />
111
+				<p><input class="button button-primary add" type="button" value="<?php esc_attr_e('Add to List', 'wetu-importer'); ?>" />
112
+					<input class="button button-primary clear" type="button" value="<?php esc_attr_e('Clear', 'wetu-importer'); ?>" />
113 113
 				</p>
114 114
 
115 115
 				<table class="wp-list-table widefat fixed posts">
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
 					<tbody id="the-list">
119 119
 						<tr class="post-0 type-tour status-none" id="post-0">
120 120
 							<th class="check-column" scope="row">
121
-								<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>
121
+								<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>
122 122
 							</th>
123 123
 							<td class="post-title page-title column-title">
124 124
 								<strong>
125
-									<?php esc_html_e( 'Enter a title to search for', 'wetu-importer' ); ?>
125
+									<?php esc_html_e('Enter a title to search for', 'wetu-importer'); ?>
126 126
 								</strong>
127 127
 							</td>
128 128
 							<td class="date column-date">
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 
137 137
 				</table>
138 138
 
139
-				<p><input class="button button-primary add" type="button" value="<?php esc_attr_e( 'Add to List', 'wetu-importer' ); ?>" />
140
-					<input class="button button-primary clear" type="button" value="<?php esc_attr_e( 'Clear', 'wetu-importer' ); ?>" />
139
+				<p><input class="button button-primary add" type="button" value="<?php esc_attr_e('Add to List', 'wetu-importer'); ?>" />
140
+					<input class="button button-primary clear" type="button" value="<?php esc_attr_e('Clear', 'wetu-importer'); ?>" />
141 141
 				</p>
142 142
 			</form>
143 143
 
@@ -147,66 +147,66 @@  discard block
 block discarded – undo
147 147
 
148 148
 					<div class="row">
149 149
 						<div class="settings-all" style="width:30%;display:block;float:left;">
150
-							<h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3>
150
+							<h3><?php esc_html_e('What content to Sync from WETU'); ?></h3>
151 151
 							<ul>
152
-								<li><input class="content select-all" <?php $this->checked( $this->accommodation_options, 'all' ); ?> type="checkbox" name="content[]" value="all" /> <?php esc_html_e( 'Select All', 'wetu-importer' ); ?></li>
153
-								<?php if ( ! isset( $this->options['disable_accommodation_descriptions'] ) ) { ?>
154
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'description' ); ?>" type="checkbox" name="content[]" value="description" /> <?php esc_html_e( 'Description', 'wetu-importer' ); ?></li>
152
+								<li><input class="content select-all" <?php $this->checked($this->accommodation_options, 'all'); ?> type="checkbox" name="content[]" value="all" /> <?php esc_html_e('Select All', 'wetu-importer'); ?></li>
153
+								<?php if (!isset($this->options['disable_accommodation_descriptions'])) { ?>
154
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php esc_html_e('Description', 'wetu-importer'); ?></li>
155 155
 								<?php } ?>
156
-								<?php if ( ! isset( $this->options['disable_accommodation_excerpts'] ) ) { ?>
157
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'excerpt' ); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php esc_html_e( 'Excerpt', 'wetu-importer' ); ?></li>
156
+								<?php if (!isset($this->options['disable_accommodation_excerpts'])) { ?>
157
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php esc_html_e('Excerpt', 'wetu-importer'); ?></li>
158 158
 								<?php } ?>
159 159
 
160
-								<?php if ( ! isset( $this->accommodation_settings['disable_single'] ) ) { ?>
161
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'gallery' ); ?>" type="checkbox" name="content[]" value="gallery" /> <?php esc_html_e( 'Main Gallery', 'wetu-importer' ); ?></li>
160
+								<?php if (!isset($this->accommodation_settings['disable_single'])) { ?>
161
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php esc_html_e('Main Gallery', 'wetu-importer'); ?></li>
162 162
 								<?php } ?>
163
-								<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'category' ); ?>" type="checkbox" name="content[]" value="category" /> <?php esc_html_e( 'Category', 'wetu-importer' ); ?></li>
164
-								<?php if ( class_exists( 'LSX_TO_Maps' ) && ! isset( $this->accommodation_settings['disable_single'] ) ) { ?>
165
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'location' ); ?>" type="checkbox" name="content[]" value="location" /> <?php esc_html_e( 'Location', 'wetu-importer' ); ?></li>
163
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php esc_html_e('Category', 'wetu-importer'); ?></li>
164
+								<?php if (class_exists('LSX_TO_Maps') && !isset($this->accommodation_settings['disable_single'])) { ?>
165
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php esc_html_e('Location', 'wetu-importer'); ?></li>
166 166
 								<?php } ?>
167
-								<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'destination' ); ?>" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e( 'Connect Destinations', 'wetu-importer' ); ?></li>
168
-								<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'rating' ); ?>" type="checkbox" name="content[]" value="rating" /> <?php esc_html_e( 'Rating', 'wetu-importer' ); ?></li>
169
-								<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'rooms' ); ?>" type="checkbox" name="content[]" value="rooms" /> <?php esc_html_e( 'Rooms', 'wetu-importer' ); ?></li>
170
-
171
-								<?php if ( ! isset( $this->accommodation_settings['disable_single'] ) ) { ?>
172
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'checkin' ); ?>" type="checkbox" name="content[]" value="checkin" /> <?php esc_html_e( 'Check In / Check Out', 'wetu-importer' ); ?></li>
173
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'facilities' ); ?>" type="checkbox" name="content[]" value="facilities" /> <?php esc_html_e( 'Facilities', 'wetu-importer' ); ?></li>
174
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'friendly' ); ?>" type="checkbox" name="content[]" value="friendly" /> <?php esc_html_e( 'Friendly', 'wetu-importer' ); ?></li>
167
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e('Connect Destinations', 'wetu-importer'); ?></li>
168
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php esc_html_e('Rating', 'wetu-importer'); ?></li>
169
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php esc_html_e('Rooms', 'wetu-importer'); ?></li>
170
+
171
+								<?php if (!isset($this->accommodation_settings['disable_single'])) { ?>
172
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php esc_html_e('Check In / Check Out', 'wetu-importer'); ?></li>
173
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php esc_html_e('Facilities', 'wetu-importer'); ?></li>
174
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php esc_html_e('Friendly', 'wetu-importer'); ?></li>
175 175
 								<?php } ?>
176 176
 
177
-								<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'special_interests' ); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php esc_html_e( 'Special Interests', 'wetu-importer' ); ?></li>
178
-								<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'spoken_languages' ); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php esc_html_e( 'Spoken Languages', 'wetu-importer' ); ?></li>
177
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php esc_html_e('Special Interests', 'wetu-importer'); ?></li>
178
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php esc_html_e('Spoken Languages', 'wetu-importer'); ?></li>
179 179
 
180
-								<?php if ( class_exists( 'LSX_TO_Videos' ) && ! isset( $this->accommodation_settings['disable_single'] ) ) { ?>
181
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'videos' ); ?>" type="checkbox" name="content[]" value="videos" /> <?php esc_html_e( 'Videos', 'wetu-importer' ); ?></li>
180
+								<?php if (class_exists('LSX_TO_Videos') && !isset($this->accommodation_settings['disable_single'])) { ?>
181
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php esc_html_e('Videos', 'wetu-importer'); ?></li>
182 182
 								<?php } ?>
183 183
 							</ul>
184
-							<h4><?php esc_html_e( 'Additional Content' ); ?></h4>
184
+							<h4><?php esc_html_e('Additional Content'); ?></h4>
185 185
 							<ul>
186
-								<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'featured_image' ); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e( 'Set Featured Image', 'wetu-importer' ); ?></li>
187
-								<?php if ( class_exists( 'LSX_Banners' ) && ! isset( $this->accommodation_settings['disable_single'] ) ) { ?>
188
-									<li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'banner_image' ); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e( 'Set Banner Image', 'wetu-importer' ); ?></li>
186
+								<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e('Set Featured Image', 'wetu-importer'); ?></li>
187
+								<?php if (class_exists('LSX_Banners') && !isset($this->accommodation_settings['disable_single'])) { ?>
188
+									<li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e('Set Banner Image', 'wetu-importer'); ?></li>
189 189
 								<?php } ?>
190 190
 							</ul>
191 191
 						</div>
192 192
 						<div style="width:30%;display:block;float:left;">
193
-							<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3>
194
-							<?php $this->team_member_checkboxes( $this->accommodation_options ); ?>
193
+							<h3><?php esc_html_e('Assign a Team Member'); ?></h3>
194
+							<?php $this->team_member_checkboxes($this->accommodation_options); ?>
195 195
 						</div>
196 196
 
197 197
 						<div style="width:30%;display:block;float:left;">
198
-							<h3><?php esc_html_e( 'Assign a Safari Brand' ); ?></h3>
198
+							<h3><?php esc_html_e('Assign a Safari Brand'); ?></h3>
199 199
 							<?php
200 200
 								// @codingStandardsIgnoreLine
201
-								echo $this->taxonomy_checkboxes( 'accommodation-brand', $this->accommodation_options );
201
+								echo $this->taxonomy_checkboxes('accommodation-brand', $this->accommodation_options);
202 202
 							?>
203 203
 						</div>
204 204
 
205 205
 						<br clear="both" />
206 206
 					</div>
207 207
 
208
-					<h3><?php esc_html_e( 'Your List' ); ?></h3>
209
-					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'wetu-importer' ); ?>" /></p>
208
+					<h3><?php esc_html_e('Your List'); ?></h3>
209
+					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e('Sync', 'wetu-importer'); ?>" /></p>
210 210
 					<table class="wp-list-table widefat fixed posts">
211 211
 						<?php $this->table_header(); ?>
212 212
 
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
 
219 219
 					</table>
220 220
 
221
-					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'wetu-importer' ); ?>" /></p>
221
+					<p><input class="button button-primary" type="submit" value="<?php esc_attr_e('Sync', 'wetu-importer'); ?>" /></p>
222 222
 				</form>
223 223
 			</div>
224 224
 
225 225
 			<div style="display:none;" class="completed-list-wrapper">
226
-				<h3><?php esc_html_e( 'Completed' ); ?> - <small><?php esc_html_e( 'Import your', 'wetu-importer' ); ?> <a href="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->plugin_slug ); ?>&tab=destination"><?php esc_html_e( 'destinations' ); ?></a> <?php esc_html_e( 'next', 'wetu-importer' ); ?></small></h3>
226
+				<h3><?php esc_html_e('Completed'); ?> - <small><?php esc_html_e('Import your', 'wetu-importer'); ?> <a href="<?php echo esc_url(admin_url('admin.php')); ?>?page=<?php echo esc_attr($this->plugin_slug); ?>&tab=destination"><?php esc_html_e('destinations'); ?></a> <?php esc_html_e('next', 'wetu-importer'); ?></small></h3>
227 227
 				<ul>
228 228
 				</ul>
229 229
 			</div>
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
 	 * search_form
236 236
 	 */
237 237
 	public function update_options_form() {
238
-		echo '<div style="display:none;" class="wetu-status"><h3>' . esc_html__( 'Wetu Status', 'wetu-importer' ) . '</h3>';
238
+		echo '<div style="display:none;" class="wetu-status"><h3>'.esc_html__('Wetu Status', 'wetu-importer').'</h3>';
239 239
 
240
-		$accommodation = get_transient( 'lsx_ti_accommodation' );
240
+		$accommodation = get_transient('lsx_ti_accommodation');
241 241
 
242 242
 		//if ( '' === $accommodation || false === $accommodation || isset( $_GET['refresh_accommodation'] ) ) {
243 243
 			//$this->update_options();
@@ -250,14 +250,14 @@  discard block
 block discarded – undo
250 250
 	 * Save the list of Accommodation into an option
251 251
 	 */
252 252
 	public function update_options() {
253
-		$data = file_get_contents( $this->url . '/List?' . $this->url_qs );
253
+		$data = file_get_contents($this->url.'/List?'.$this->url_qs);
254 254
 
255
-		$accommodation = json_decode( $data, true );
255
+		$accommodation = json_decode($data, true);
256 256
 
257
-		if ( isset( $accommodation['error'] ) ) {
257
+		if (isset($accommodation['error'])) {
258 258
 			return $accommodation['error'];
259
-		} elseif ( isset( $accommodation ) && ! empty( $accommodation ) ) {
260
-			set_transient( 'lsx_ti_accommodation',$accommodation,60 * 60 * 2 );
259
+		} elseif (isset($accommodation) && !empty($accommodation)) {
260
+			set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2);
261 261
 			return true;
262 262
 		}
263 263
 	}
@@ -269,122 +269,122 @@  discard block
 block discarded – undo
269 269
 		$return = false;
270 270
 
271 271
 		// @codingStandardsIgnoreLine
272
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_tour_importer' && isset( $_POST['type'] ) && $_POST['type'] === 'accommodation' ) {
272
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation') {
273 273
 
274 274
 			$searched_items = false;
275 275
 
276 276
 			// @codingStandardsIgnoreLine
277
-			if ( isset( $_POST['keyword'] ) ) {
277
+			if (isset($_POST['keyword'])) {
278 278
 				// @codingStandardsIgnoreLine
279 279
 				$keyphrases = $_POST['keyword'];
280
-			} else {
281
-				$keyphrases = array( 0 );
280
+			}else {
281
+				$keyphrases = array(0);
282 282
 			}
283 283
 
284
-			if ( ! is_array( $keyphrases ) ) {
285
-				$keyphrases = array( $keyphrases );
284
+			if (!is_array($keyphrases)) {
285
+				$keyphrases = array($keyphrases);
286 286
 			}
287
-			foreach ( $keyphrases as &$keyword ) {
288
-				$keyword = ltrim( rtrim( $keyword ) );
287
+			foreach ($keyphrases as &$keyword) {
288
+				$keyword = ltrim(rtrim($keyword));
289 289
 			}
290 290
 
291 291
 			$post_status = false;
292 292
 
293
-			if ( in_array( 'publish', $keyphrases ) ) {
293
+			if (in_array('publish', $keyphrases)) {
294 294
 				$post_status = 'publish';
295 295
 			}
296
-			if ( in_array( 'pending', $keyphrases ) ) {
296
+			if (in_array('pending', $keyphrases)) {
297 297
 				$post_status = 'pending';
298 298
 			}
299
-			if ( in_array( 'draft', $keyphrases ) ) {
299
+			if (in_array('draft', $keyphrases)) {
300 300
 				$post_status = 'draft';
301 301
 			}
302
-			if ( in_array( 'import', $keyphrases ) ) {
302
+			if (in_array('import', $keyphrases)) {
303 303
 				$post_status = 'import';
304 304
 			}
305 305
 
306 306
 			// If there is a post status use it.
307
-			if ( false !== $post_status ) {
307
+			if (false !== $post_status) {
308 308
 
309 309
 				$accommodation = array();
310 310
 				$current_accommodation = $this->find_current_accommodation();
311
-				if ( ! empty( $current_accommodation ) ) {
312
-					foreach ( $current_accommodation as $cs_key => $ccs_id ) {
313
-						$accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id );
311
+				if (!empty($current_accommodation)) {
312
+					foreach ($current_accommodation as $cs_key => $ccs_id) {
313
+						$accommodation[] = $this->prepare_row_attributes($cs_key, $ccs_id->post_id);
314 314
 					}
315 315
 				}
316 316
 
317 317
 				// Run through each accommodation and use it.
318
-				if ( ! empty( $accommodation ) ) {
319
-					foreach ( $accommodation as $row_key => $row ) {
320
-						if ( 'import' === $post_status ) {
321
-							if ( is_array( $this->queued_imports ) && in_array( $row['post_id'],$this->queued_imports ) ) {
322
-								$current_status = get_post_status( $row['post_id'] );
323
-								if ( 'draft' === $current_status ) {
324
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
318
+				if (!empty($accommodation)) {
319
+					foreach ($accommodation as $row_key => $row) {
320
+						if ('import' === $post_status) {
321
+							if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) {
322
+								$current_status = get_post_status($row['post_id']);
323
+								if ('draft' === $current_status) {
324
+									$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
325 325
 								}
326
-							} else {
326
+							}else {
327 327
 								continue;
328 328
 							}
329
-						} else {
330
-							if ( 0 === $row['post_id'] ) {
329
+						}else {
330
+							if (0 === $row['post_id']) {
331 331
 								continue;
332
-							} else {
333
-								$current_status = get_post_status( $row['post_id'] );
334
-								if ( $current_status !== $post_status ) {
332
+							}else {
333
+								$current_status = get_post_status($row['post_id']);
334
+								if ($current_status !== $post_status) {
335 335
 									continue;
336 336
 								}
337 337
 							}
338
-							$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row );
338
+							$searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row);
339 339
 						}
340 340
 					}
341 341
 				}
342
-			} else {
343
-				$key_string_search = implode( '+', $keyphrases );
344
-				$search_data = file_get_contents( $this->url . '/Search/' . $key_string_search );
345
-				$search_data = json_decode( $search_data, true );
346
-
347
-				if ( ! isset( $search_data['error'] ) ) {
348
-					foreach ( $search_data as $sdata ) {
349
-
350
-						if ( 'Destination'  	 === trim( $sdata['type'] ) ||
351
-						     'Activity' 		 === trim( $sdata['type'] ) ||
352
-						     'Restaurant' 		 === trim( $sdata['type'] ) ||
353
-						     'None' 			 === trim( $sdata['type'] ) ||
354
-						     'Site / Attraction' === trim( $sdata['type'] ) ||
355
-						     '' 				 === trim( $sdata['type'] )
342
+			}else {
343
+				$key_string_search = implode('+', $keyphrases);
344
+				$search_data = file_get_contents($this->url.'/Search/'.$key_string_search);
345
+				$search_data = json_decode($search_data, true);
346
+
347
+				if (!isset($search_data['error'])) {
348
+					foreach ($search_data as $sdata) {
349
+
350
+						if ('Destination' === trim($sdata['type']) ||
351
+						     'Activity' === trim($sdata['type']) ||
352
+						     'Restaurant' === trim($sdata['type']) ||
353
+						     'None' === trim($sdata['type']) ||
354
+						     'Site / Attraction' === trim($sdata['type']) ||
355
+						     '' === trim($sdata['type'])
356 356
 						) {
357 357
 							continue;
358 358
 						}
359 359
 
360
-						$temp_id = $this->get_post_id_by_key_value( $sdata['id'] );
361
-						if ( false === $temp_id ) {
360
+						$temp_id = $this->get_post_id_by_key_value($sdata['id']);
361
+						if (false === $temp_id) {
362 362
 							$sdata['post_id'] = 0;
363
-						} else {
363
+						}else {
364 364
 							$sdata['post_id'] = $temp_id;
365 365
 						}
366
-						$searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata );
366
+						$searched_items[sanitize_title($sdata['name']).'-'.$sdata['id']] = $this->format_row($sdata);
367 367
 					}
368 368
 				}
369 369
 			}
370 370
 
371
-			if ( false !== $searched_items ) {
372
-				ksort( $searched_items );
373
-				$return = implode( $searched_items );
371
+			if (false !== $searched_items) {
372
+				ksort($searched_items);
373
+				$return = implode($searched_items);
374 374
 			}
375 375
 
376
-			print_r( $return );
376
+			print_r($return);
377 377
 		}
378 378
 
379 379
 		die();
380 380
 	}
381 381
 
382
-	public function prepare_row_attributes( $cs_key, $ccs_id ) {
382
+	public function prepare_row_attributes($cs_key, $ccs_id) {
383 383
 		return 	$row_item = array(
384 384
 			'id' => $cs_key,
385 385
 			'type' => 'Accommodation',
386
-			'name' => get_the_title( $ccs_id ),
387
-			'last_modified' => date('Y-m-d', strtotime( 'now' ) ),
386
+			'name' => get_the_title($ccs_id),
387
+			'last_modified' => date('Y-m-d', strtotime('now')),
388 388
 			'post_id' => $ccs_id,
389 389
 		);
390 390
 	}
@@ -395,28 +395,28 @@  discard block
 block discarded – undo
395 395
 	 * @param boolean $row the current row to format.
396 396
 	 * @return void
397 397
 	 */
398
-	public function format_row( $row = false ) {
399
-		if ( false !== $row ) {
398
+	public function format_row($row = false) {
399
+		if (false !== $row) {
400 400
 
401 401
 			$status = 'import';
402
-			if ( 0 !== $row['post_id'] ) {
403
-				$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>';
402
+			if (0 !== $row['post_id']) {
403
+				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
404 404
 			}
405 405
 
406 406
 			$row_html = '
407
-			<tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '">
407
+			<tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'">
408 408
 				<th class="check-column" scope="row">
409
-					<label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label>
410
-					<input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '">
409
+					<label for="cb-select-' . $row['id'].'" class="screen-reader-text">'.$row['name'].'</label>
410
+					<input type="checkbox" data-identifier="' . $row['id'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['id'].'">
411 411
 				</th>
412 412
 				<td class="post-title page-title column-title">
413
-					<strong>' . $row['name'] . '</strong> - ' . $status . '
413
+					<strong>' . $row['name'].'</strong> - '.$status.'
414 414
 				</td>
415 415
 				<td class="date column-date">
416
-					<abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified
416
+					<abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
417 417
 				</td>
418 418
 				<td class="ssid column-ssid">
419
-					' . $row['id'] . '
419
+					' . $row['id'].'
420 420
 				</td>
421 421
 			</tr>';
422 422
 			return $row_html;
@@ -426,14 +426,14 @@  discard block
 block discarded – undo
426 426
 	/**
427 427
 	 * Saves the queue to the option.
428 428
 	 */
429
-	public function remove_from_queue( $id ) {
430
-		if ( ! empty( $this->queued_imports ) ) {
429
+	public function remove_from_queue($id) {
430
+		if (!empty($this->queued_imports)) {
431 431
 			// @codingStandardsIgnoreLine
432
-			if ( ( $key = array_search( $id, $this->queued_imports ) ) !== false ) {
433
-				unset( $this->queued_imports[ $key ] );
432
+			if (($key = array_search($id, $this->queued_imports)) !== false) {
433
+				unset($this->queued_imports[$key]);
434 434
 
435
-				delete_option( 'wetu_importer_que' );
436
-				update_option( 'wetu_importer_que', $this->queued_imports );
435
+				delete_option('wetu_importer_que');
436
+				update_option('wetu_importer_que', $this->queued_imports);
437 437
 			}
438 438
 		}
439 439
 	}
@@ -445,55 +445,55 @@  discard block
 block discarded – undo
445 445
 		$return = false;
446 446
 
447 447
 		// @codingStandardsIgnoreLine
448
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === 'accommodation' && isset( $_POST['wetu_id'] ) ) {
448
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])) {
449 449
 			// @codingStandardsIgnoreLine
450 450
 			$wetu_id = $_POST['wetu_id'];
451 451
 
452 452
 			// @codingStandardsIgnoreLine
453
-			if ( isset( $_POST['post_id'] ) ) {
453
+			if (isset($_POST['post_id'])) {
454 454
 				// @codingStandardsIgnoreLine
455 455
 				$post_id = $_POST['post_id'];
456
-			} else {
456
+			}else {
457 457
 				$post_id = 0;
458 458
 			}
459 459
 
460 460
 			// @codingStandardsIgnoreLine
461
-			if ( isset( $_POST['team_members'] ) ) {
461
+			if (isset($_POST['team_members'])) {
462 462
 				// @codingStandardsIgnoreLine
463 463
 				$team_members = $_POST['team_members'];
464
-			} else {
464
+			}else {
465 465
 				$team_members = false;
466 466
 			}
467 467
 
468 468
 			// @codingStandardsIgnoreLine
469
-			if ( isset( $_POST['safari_brands'] ) ) {
469
+			if (isset($_POST['safari_brands'])) {
470 470
 				// @codingStandardsIgnoreLine
471 471
 				$safari_brands = $_POST['safari_brands'];
472
-			} else {
472
+			}else {
473 473
 				$safari_brands = false;
474 474
 			}
475 475
 
476
-			delete_option( 'wetu_importer_accommodation_settings' );
476
+			delete_option('wetu_importer_accommodation_settings');
477 477
 
478 478
 			// @codingStandardsIgnoreLine
479
-			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
479
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
480 480
 				// @codingStandardsIgnoreLine
481 481
 				$content = $_POST['content'];
482
-				add_option( 'wetu_importer_accommodation_settings',$content );
483
-			} else {
482
+				add_option('wetu_importer_accommodation_settings', $content);
483
+			}else {
484 484
 				$content = false;
485 485
 			}
486 486
 
487
-			$jdata = wp_remote_get( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id );
487
+			$jdata = wp_remote_get($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id);
488 488
 
489
-			if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
490
-				$adata = json_decode( $jdata['body'], true );
491
-				$return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands );
492
-				$this->format_completed_row( $return );
493
-				$this->remove_from_queue( $return );
489
+			if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
490
+				$adata = json_decode($jdata['body'], true);
491
+				$return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands);
492
+				$this->format_completed_row($return);
493
+				$this->remove_from_queue($return);
494 494
 				$this->cleanup_posts();
495
-			} else {
496
-				$this->format_error( esc_html__( 'There was a problem importing your accommodation, please try refreshing the page.', 'wetu-importer' ) );
495
+			}else {
496
+				$this->format_error(esc_html__('There was a problem importing your accommodation, please try refreshing the page.', 'wetu-importer'));
497 497
 			}
498 498
 		}
499 499
 	}
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 	/**
502 502
 	 * Connect to wetu
503 503
 	 */
504
-	public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false ) {
504
+	public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false) {
505 505
 		$post_name = '';
506 506
 		$data_post_content = '';
507 507
 		$data_post_excerpt = '';
@@ -512,139 +512,139 @@  discard block
 block discarded – undo
512 512
 		$content_used_general_description = false;
513 513
 
514 514
 		// Set the post_content.
515
-		if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) {
516
-			if ( isset( $data[0]['content']['extended_description'] ) ) {
515
+		if (!empty($importable_content) && in_array('description', $importable_content)) {
516
+			if (isset($data[0]['content']['extended_description'])) {
517 517
 				$data_post_content = $data[0]['content']['extended_description'];
518
-			} elseif ( isset( $data[0]['content']['general_description'] ) ) {
518
+			} elseif (isset($data[0]['content']['general_description'])) {
519 519
 				$data_post_content = $data[0]['content']['general_description'];
520 520
 				$content_used_general_description = true;
521
-			} elseif ( isset( $data[0]['content']['teaser_description'] ) ) {
521
+			} elseif (isset($data[0]['content']['teaser_description'])) {
522 522
 				$data_post_content = $data[0]['content']['teaser_description'];
523 523
 			}
524 524
 
525
-			$post['post_content'] = wp_strip_all_tags( $data_post_content );
525
+			$post['post_content'] = wp_strip_all_tags($data_post_content);
526 526
 		}
527 527
 
528 528
 		// set the post_excerpt.
529
-		if ( ! empty( $importable_content ) && in_array( 'excerpt', $importable_content ) ) {
530
-			if ( isset( $data[0]['content']['teaser_description'] ) ) {
529
+		if (!empty($importable_content) && in_array('excerpt', $importable_content)) {
530
+			if (isset($data[0]['content']['teaser_description'])) {
531 531
 				$data_post_excerpt = $data[0]['content']['teaser_description'];
532
-			} elseif ( isset( $data[0]['content']['general_description'] ) && false === $content_used_general_description ) {
532
+			} elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) {
533 533
 				$data_post_excerpt = $data[0]['content']['general_description'];
534 534
 			}
535 535
 
536 536
 			$post['post_excerpt'] = $data_post_excerpt;
537 537
 		}
538 538
 
539
-		if ( false !== $id && '0' !== $id ) {
539
+		if (false !== $id && '0' !== $id) {
540 540
 			$post['ID'] = $id;
541 541
 
542
-			if ( isset( $data[0]['name'] ) ) {
542
+			if (isset($data[0]['name'])) {
543 543
 				$post['post_title'] = $data[0]['name'];
544 544
 				$post['post_status'] = 'publish';
545
-				$post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'accommodation', 0 );
545
+				$post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0);
546 546
 			}
547 547
 
548
-			$id = wp_update_post( $post );
549
-			$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
550
-			update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date );
551
-		} else {
548
+			$id = wp_update_post($post);
549
+			$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
550
+			update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date);
551
+		}else {
552 552
 			// Set the name.
553
-			if ( isset( $data[0]['name'] ) ) {
554
-				$post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'accommodation', 0 );
553
+			if (isset($data[0]['name'])) {
554
+				$post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0);
555 555
 			}
556 556
 
557 557
 			$post['post_name']   = $post_name;
558 558
 			$post['post_title']  = $data[0]['name'];
559 559
 			$post['post_status'] = 'publish';
560
-			$id                  = wp_insert_post( $post );
560
+			$id                  = wp_insert_post($post);
561 561
 
562 562
 			// Save the WETU ID and the Last date it was modified.
563
-			if ( false !== $id ) {
564
-				add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
565
-				add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) );
563
+			if (false !== $id) {
564
+				add_post_meta($id, 'lsx_wetu_id', $wetu_id);
565
+				add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']));
566 566
 			}
567 567
 		}
568 568
 
569 569
 		// Setup some default for use in the import.
570
-		if ( false !== $importable_content && ( in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content ) ) ) {
571
-			$this->find_attachments( $id );
570
+		if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) {
571
+			$this->find_attachments($id);
572 572
 		}
573 573
 
574 574
 		// Set the team member if it is there.
575
-		if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) {
576
-			$this->set_team_member( $id, $team_members );
575
+		if (post_type_exists('team') && false !== $team_members && '' !== $team_members) {
576
+			$this->set_team_member($id, $team_members);
577 577
 		}
578 578
 
579 579
 		// Set the safari brand.
580
-		if ( false !== $safari_brands && '' !== $safari_brands ) {
581
-			$this->set_safari_brands( $id, $safari_brands );
580
+		if (false !== $safari_brands && '' !== $safari_brands) {
581
+			$this->set_safari_brands($id, $safari_brands);
582 582
 		}
583 583
 
584
-		if ( class_exists( 'LSX_TO_Maps' ) ) {
585
-			$this->set_map_data( $data, $id, 9 );
584
+		if (class_exists('LSX_TO_Maps')) {
585
+			$this->set_map_data($data, $id, 9);
586 586
 		}
587 587
 
588
-		if ( post_type_exists( 'destination' ) && false !== $importable_content && in_array( 'destination', $importable_content ) ) {
589
-			$this->connect_destinations( $data, $id );
588
+		if (post_type_exists('destination') && false !== $importable_content && in_array('destination', $importable_content)) {
589
+			$this->connect_destinations($data, $id);
590 590
 		}
591 591
 
592
-		if ( false !== $importable_content && in_array( 'category', $importable_content ) ) {
593
-			$this->set_taxonomy_style( $data, $id );
592
+		if (false !== $importable_content && in_array('category', $importable_content)) {
593
+			$this->set_taxonomy_style($data, $id);
594 594
 		}
595 595
 
596 596
 		// Set the Room Data.
597
-		if ( false !== $importable_content && in_array( 'rooms', $importable_content ) ) {
598
-			$this->set_room_data( $data, $id );
597
+		if (false !== $importable_content && in_array('rooms', $importable_content)) {
598
+			$this->set_room_data($data, $id);
599 599
 		}
600 600
 
601 601
 		// Set the rating.
602
-		if ( false !== $importable_content && in_array( 'rating', $importable_content ) ) {
603
-			$this->set_rating( $data, $id );
602
+		if (false !== $importable_content && in_array('rating', $importable_content)) {
603
+			$this->set_rating($data, $id);
604 604
 		}
605 605
 
606 606
 		// Set the checkin checkout data.
607
-		if ( false !== $importable_content && in_array( 'checkin', $importable_content ) ) {
608
-			$this->set_checkin_checkout( $data, $id );
607
+		if (false !== $importable_content && in_array('checkin', $importable_content)) {
608
+			$this->set_checkin_checkout($data, $id);
609 609
 		}
610 610
 
611 611
 		// Set the Spoken Languages.
612
-		if ( false !== $importable_content && in_array( 'spoken_languages', $importable_content ) ) {
613
-			$this->set_spoken_languages( $data, $id );
612
+		if (false !== $importable_content && in_array('spoken_languages', $importable_content)) {
613
+			$this->set_spoken_languages($data, $id);
614 614
 		}
615 615
 
616 616
 		// Set the friendly options.
617
-		if ( false !== $importable_content && in_array( 'friendly', $importable_content ) ) {
618
-			$this->set_friendly( $data, $id );
617
+		if (false !== $importable_content && in_array('friendly', $importable_content)) {
618
+			$this->set_friendly($data, $id);
619 619
 		}
620 620
 
621 621
 		// Set the special_interests.
622
-		if ( false !== $importable_content && in_array( 'special_interests', $importable_content ) ) {
623
-			$this->set_special_interests( $data, $id );
622
+		if (false !== $importable_content && in_array('special_interests', $importable_content)) {
623
+			$this->set_special_interests($data, $id);
624 624
 		}
625 625
 
626 626
 		// Import the videos.
627
-		if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) {
628
-			$this->set_video_data( $data, $id );
627
+		if (false !== $importable_content && in_array('videos', $importable_content)) {
628
+			$this->set_video_data($data, $id);
629 629
 		}
630 630
 
631 631
 		// Import the facilities.
632
-		if ( false !== $importable_content && in_array( 'facilities', $importable_content ) ) {
633
-			$this->set_facilities( $data, $id );
632
+		if (false !== $importable_content && in_array('facilities', $importable_content)) {
633
+			$this->set_facilities($data, $id);
634 634
 		}
635 635
 
636 636
 		// Set the featured image.
637
-		if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
638
-			$this->set_featured_image( $data, $id );
637
+		if (false !== $importable_content && in_array('featured_image', $importable_content)) {
638
+			$this->set_featured_image($data, $id);
639 639
 		}
640 640
 
641
-		if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
642
-			$this->set_banner_image( $data, $id );
641
+		if (false !== $importable_content && in_array('banner_image', $importable_content)) {
642
+			$this->set_banner_image($data, $id);
643 643
 		}
644 644
 
645 645
 		// Import the main gallery.
646
-		if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) {
647
-			$this->create_main_gallery( $data, $id );
646
+		if (false !== $importable_content && in_array('gallery', $importable_content)) {
647
+			$this->create_main_gallery($data, $id);
648 648
 		}
649 649
 
650 650
 		return $id;
@@ -653,55 +653,55 @@  discard block
 block discarded – undo
653 653
 	/**
654 654
 	 * Set the team memberon each item.
655 655
 	 */
656
-	public function set_team_member( $id, $team_members ) {
657
-		delete_post_meta( $id, 'team_to_' . $this->tab_slug );
656
+	public function set_team_member($id, $team_members) {
657
+		delete_post_meta($id, 'team_to_'.$this->tab_slug);
658 658
 
659
-		foreach ( $team_members as $team ) {
660
-			add_post_meta( $id, 'team_to_' . $this->tab_slug, $team );
659
+		foreach ($team_members as $team) {
660
+			add_post_meta($id, 'team_to_'.$this->tab_slug, $team);
661 661
 		}
662 662
 	}
663 663
 
664 664
 	/**
665 665
 	 * Set the safari brand
666 666
 	 */
667
-	public function set_safari_brands( $id, $safari_brands ) {
668
-		foreach ( $safari_brands as $safari_brand ) {
669
-			wp_set_object_terms( $id, intval( $safari_brand ), 'accommodation-brand', true );
667
+	public function set_safari_brands($id, $safari_brands) {
668
+		foreach ($safari_brands as $safari_brand) {
669
+			wp_set_object_terms($id, intval($safari_brand), 'accommodation-brand', true);
670 670
 		}
671 671
 	}
672 672
 
673 673
 	/**
674 674
 	 * Connects the destinations post type
675 675
 	 */
676
-	public function connect_destinations( $data, $id ) {
677
-		if ( isset( $data[0]['position'] ) ) {
676
+	public function connect_destinations($data, $id) {
677
+		if (isset($data[0]['position'])) {
678 678
 			$destinations = false;
679 679
 
680
-			if ( isset( $data[0]['position']['country'] ) ) {
680
+			if (isset($data[0]['position']['country'])) {
681 681
 				$destinations['country'] = $data[0]['position']['country'];
682 682
 			}
683 683
 
684
-			if ( isset( $data[0]['position']['destination'] ) ) {
684
+			if (isset($data[0]['position']['destination'])) {
685 685
 				$destinations['destination'] = $data[0]['position']['destination'];
686 686
 			}
687 687
 
688
-			if ( false !== $destinations ) {
689
-				$prev_values = get_post_meta( $id, 'destination_to_accommodation', false );
688
+			if (false !== $destinations) {
689
+				$prev_values = get_post_meta($id, 'destination_to_accommodation', false);
690 690
 
691
-				if ( false === $prev_values || ! is_array( $prev_values ) ) {
691
+				if (false === $prev_values || !is_array($prev_values)) {
692 692
 					$prev_values = array();
693 693
 				}
694 694
 
695
-				delete_post_meta( $id, 'destination_to_accommodation', $prev_values );
696
-				$destinations = array_unique( $destinations );
695
+				delete_post_meta($id, 'destination_to_accommodation', $prev_values);
696
+				$destinations = array_unique($destinations);
697 697
 
698
-				foreach ( $destinations as $key => $value ) {
699
-					$destination = get_page_by_title( ltrim( rtrim( $value ) ), 'OBJECT', 'destination' );
700
-					if ( null !== $destination ) {
701
-						if ( ! in_array( $destination->ID, $prev_values ) ) {
702
-							add_post_meta( $id, 'destination_to_accommodation', $destination->ID, false );
703
-							add_post_meta( $destination->ID, 'accommodation_to_destination', $id, false );
704
-							$this->cleanup_posts[ $destination->ID ] = 'accommodation_to_destination';
698
+				foreach ($destinations as $key => $value) {
699
+					$destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination');
700
+					if (null !== $destination) {
701
+						if (!in_array($destination->ID, $prev_values)) {
702
+							add_post_meta($id, 'destination_to_accommodation', $destination->ID, false);
703
+							add_post_meta($destination->ID, 'accommodation_to_destination', $id, false);
704
+							$this->cleanup_posts[$destination->ID] = 'accommodation_to_destination';
705 705
 						}
706 706
 					}
707 707
 				}
@@ -712,73 +712,73 @@  discard block
 block discarded – undo
712 712
 	/**
713 713
 	 * Set the Travel Style
714 714
 	 */
715
-	public function set_taxonomy_style( $data, $id ) {
715
+	public function set_taxonomy_style($data, $id) {
716 716
 		$terms = false;
717 717
 
718
-		if ( isset( $data[0]['category'] ) ) {
718
+		if (isset($data[0]['category'])) {
719 719
 			// @codingStandardsIgnoreLine
720
-			if ( ! $term = term_exists( trim( $data[0]['category'] ), 'accommodation-type' ) ) {
721
-				$term = wp_insert_term( trim( $data[0]['category'] ), 'accommodation-type' );
720
+			if (!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) {
721
+				$term = wp_insert_term(trim($data[0]['category']), 'accommodation-type');
722 722
 
723
-				if ( is_wp_error( $term ) ) {
723
+				if (is_wp_error($term)) {
724 724
 					// @codingStandardsIgnoreLine
725 725
 					echo $term->get_error_message();
726 726
 				}
727
-			} else {
728
-				wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type', true );
727
+			}else {
728
+				wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true);
729 729
 			}
730
-		} else {
731
-			wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type', true );
730
+		}else {
731
+			wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true);
732 732
 		}
733 733
 	}
734 734
 
735 735
 	/**
736 736
 	 * Saves the room data
737 737
 	 */
738
-	public function set_room_data( $data, $id ) {
739
-		if ( ! empty( $data[0]['rooms'] ) && is_array( $data[0]['rooms'] ) ) {
738
+	public function set_room_data($data, $id) {
739
+		if (!empty($data[0]['rooms']) && is_array($data[0]['rooms'])) {
740 740
 			$rooms = false;
741 741
 
742
-			foreach ( $data[0]['rooms'] as $room ) {
742
+			foreach ($data[0]['rooms'] as $room) {
743 743
 				$temp_room = array();
744 744
 
745
-				if ( isset( $room['name'] ) ) {
745
+				if (isset($room['name'])) {
746 746
 					$temp_room['title'] = $room['name'];
747 747
 				}
748 748
 
749
-				if ( isset( $room['description'] ) ) {
750
-					$temp_room['description'] = strip_tags( $room['description'] );
749
+				if (isset($room['description'])) {
750
+					$temp_room['description'] = strip_tags($room['description']);
751 751
 				}
752 752
 
753 753
 				$temp_room['price'] = 0;
754 754
 				$temp_room['type']  = 'room';
755 755
 
756
-				if ( ! empty( $room['images'] ) && is_array( $room['images'] ) ) {
756
+				if (!empty($room['images']) && is_array($room['images'])) {
757 757
 					$temp_room['gallery'] = array();
758
-					$temp_room['gallery'][] = $this->attach_image( $room['images'][0], $id );
758
+					$temp_room['gallery'][] = $this->attach_image($room['images'][0], $id);
759 759
 				}
760 760
 				$rooms[] = $temp_room;
761 761
 			}
762 762
 
763
-			if ( false !== $id && '0' !== $id ) {
764
-				delete_post_meta( $id, 'units' );
763
+			if (false !== $id && '0' !== $id) {
764
+				delete_post_meta($id, 'units');
765 765
 			}
766 766
 
767
-			foreach ( $rooms as $room ) {
768
-				add_post_meta( $id, 'units', $room, false );
767
+			foreach ($rooms as $room) {
768
+				add_post_meta($id, 'units', $room, false);
769 769
 			}
770 770
 
771
-			if ( isset( $data[0]['features'] ) && isset( $data[0]['features']['rooms'] ) ) {
771
+			if (isset($data[0]['features']) && isset($data[0]['features']['rooms'])) {
772 772
 				$room_count = $data[0]['features']['rooms'];
773
-			} else {
774
-				$room_count = count( $data[0]['rooms'] );
773
+			}else {
774
+				$room_count = count($data[0]['rooms']);
775 775
 			}
776 776
 
777
-			if ( false !== $id && '0' !== $id ) {
778
-				$prev_rooms = get_post_meta( $id, 'number_of_rooms', true );
779
-				update_post_meta( $id, 'number_of_rooms', $room_count, $prev_rooms );
780
-			} else {
781
-				add_post_meta( $id, 'number_of_rooms', $room_count, true );
777
+			if (false !== $id && '0' !== $id) {
778
+				$prev_rooms = get_post_meta($id, 'number_of_rooms', true);
779
+				update_post_meta($id, 'number_of_rooms', $room_count, $prev_rooms);
780
+			}else {
781
+				add_post_meta($id, 'number_of_rooms', $room_count, true);
782 782
 			}
783 783
 		}
784 784
 	}
@@ -786,33 +786,33 @@  discard block
 block discarded – undo
786 786
 	/**
787 787
 	 * Set the ratings
788 788
 	 */
789
-	public function set_rating( $data, $id ) {
790
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['star_authority'] ) ) {
789
+	public function set_rating($data, $id) {
790
+		if (!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])) {
791 791
 			$rating_type = $data[0]['features']['star_authority'];
792
-		} else {
792
+		}else {
793 793
 			$rating_type = 'Unspecified2';
794 794
 		}
795 795
 
796
-		$this->save_custom_field( $rating_type, 'rating_type', $id );
796
+		$this->save_custom_field($rating_type, 'rating_type', $id);
797 797
 
798
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['stars'] ) ) {
799
-			$this->save_custom_field( $data[0]['features']['stars'], 'rating', $id, true );
798
+		if (!empty($data[0]['features']) && isset($data[0]['features']['stars'])) {
799
+			$this->save_custom_field($data[0]['features']['stars'], 'rating', $id, true);
800 800
 		}
801 801
 	}
802 802
 
803 803
 	/**
804 804
 	 * Set the spoken_languages
805 805
 	 */
806
-	public function set_spoken_languages( $data, $id ) {
807
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['spoken_languages'] ) && ! empty( $data[0]['features']['spoken_languages'] ) ) {
806
+	public function set_spoken_languages($data, $id) {
807
+		if (!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])) {
808 808
 			$languages = false;
809 809
 
810
-			foreach ( $data[0]['features']['spoken_languages'] as $spoken_language ) {
811
-				$languages[] = sanitize_title( $spoken_language );
810
+			foreach ($data[0]['features']['spoken_languages'] as $spoken_language) {
811
+				$languages[] = sanitize_title($spoken_language);
812 812
 			}
813 813
 
814
-			if ( false !== $languages ) {
815
-				$this->save_custom_field( $languages, 'spoken_languages', $id );
814
+			if (false !== $languages) {
815
+				$this->save_custom_field($languages, 'spoken_languages', $id);
816 816
 			}
817 817
 		}
818 818
 	}
@@ -820,16 +820,16 @@  discard block
 block discarded – undo
820 820
 	/**
821 821
 	 * Set the friendly
822 822
 	 */
823
-	public function set_friendly( $data, $id ) {
824
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['suggested_visitor_types'] ) && ! empty( $data[0]['features']['suggested_visitor_types'] ) ) {
823
+	public function set_friendly($data, $id) {
824
+		if (!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])) {
825 825
 			$friendly_options = false;
826 826
 
827
-			foreach ( $data[0]['features']['suggested_visitor_types'] as $visitor_type ) {
828
-				$friendly_options[] = sanitize_title( $visitor_type );
827
+			foreach ($data[0]['features']['suggested_visitor_types'] as $visitor_type) {
828
+				$friendly_options[] = sanitize_title($visitor_type);
829 829
 			}
830 830
 
831
-			if ( false !== $friendly_options ) {
832
-				$this->save_custom_field( $friendly_options, 'suggested_visitor_types', $id );
831
+			if (false !== $friendly_options) {
832
+				$this->save_custom_field($friendly_options, 'suggested_visitor_types', $id);
833 833
 			}
834 834
 		}
835 835
 	}
@@ -837,16 +837,16 @@  discard block
 block discarded – undo
837 837
 	/**
838 838
 	 * Set the special interests
839 839
 	 */
840
-	public function set_special_interests( $data, $id ) {
841
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['special_interests'] ) && ! empty( $data[0]['features']['special_interests'] ) ) {
840
+	public function set_special_interests($data, $id) {
841
+		if (!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])) {
842 842
 			$interests = false;
843 843
 
844
-			foreach ( $data[0]['features']['special_interests'] as $special_interest ) {
845
-				$interests[] = sanitize_title( $special_interest );
844
+			foreach ($data[0]['features']['special_interests'] as $special_interest) {
845
+				$interests[] = sanitize_title($special_interest);
846 846
 			}
847 847
 
848
-			if ( false !== $interests ) {
849
-				$this->save_custom_field( $interests, 'special_interests', $id );
848
+			if (false !== $interests) {
849
+				$this->save_custom_field($interests, 'special_interests', $id);
850 850
 			}
851 851
 		}
852 852
 	}
@@ -854,24 +854,24 @@  discard block
 block discarded – undo
854 854
 	/**
855 855
 	 * Set the Check in and Check out Date
856 856
 	 */
857
-	public function set_checkin_checkout( $data, $id ) {
858
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_in_time'] ) ) {
859
-			$time = str_replace( 'h', ':', $data[0]['features']['check_in_time'] );
860
-			$time = date( 'h:ia', strtotime( $time ) );
861
-			$this->save_custom_field( $time, 'checkin_time', $id );
857
+	public function set_checkin_checkout($data, $id) {
858
+		if (!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])) {
859
+			$time = str_replace('h', ':', $data[0]['features']['check_in_time']);
860
+			$time = date('h:ia', strtotime($time));
861
+			$this->save_custom_field($time, 'checkin_time', $id);
862 862
 		}
863 863
 
864
-		if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_out_time'] ) ) {
865
-			$time = str_replace( 'h', ':', $data[0]['features']['check_out_time'] );
866
-			$time = date( 'h:ia', strtotime( $time ) );
867
-			$this->save_custom_field( $time, 'checkout_time', $id );
864
+		if (!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])) {
865
+			$time = str_replace('h', ':', $data[0]['features']['check_out_time']);
866
+			$time = date('h:ia', strtotime($time));
867
+			$this->save_custom_field($time, 'checkout_time', $id);
868 868
 		}
869 869
 	}
870 870
 
871 871
 	/**
872 872
 	 * Set the Facilities
873 873
 	 */
874
-	public function set_facilities( $data, $id ) {
874
+	public function set_facilities($data, $id) {
875 875
 		$parent_facilities = array(
876 876
 			'available_services' => 'Available Services',
877 877
 			'property_facilities' => 'Property Facilities',
@@ -879,15 +879,15 @@  discard block
 block discarded – undo
879 879
 			'activities_on_site' => 'Activities on Site',
880 880
 		);
881 881
 
882
-		foreach ( $parent_facilities as $key => $label ) {
882
+		foreach ($parent_facilities as $key => $label) {
883 883
 			$terms = false;
884 884
 
885
-			if ( isset( $data[0]['features'] ) && isset( $data[0]['features'][ $key ] ) ) {
886
-				$parent_id = $this->set_term( $id, $label, 'facility' );
885
+			if (isset($data[0]['features']) && isset($data[0]['features'][$key])) {
886
+				$parent_id = $this->set_term($id, $label, 'facility');
887 887
 			}
888 888
 
889
-			foreach ( $data[0]['features'][ $key ] as $child_facility ) {
890
-				$this->set_term( $id, $child_facility, 'facility', $parent_id );
889
+			foreach ($data[0]['features'][$key] as $child_facility) {
890
+				$this->set_term($id, $child_facility, 'facility', $parent_id);
891 891
 			}
892 892
 		}
893 893
 	}
Please login to merge, or discard this patch.
classes/class-wetu-importer-tours.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -924,7 +924,6 @@  discard block
 block discarded – undo
924 924
 	 * Takes the WETU tags and sets the Travel Styles.
925 925
 	 *
926 926
 	 * @param string $id
927
-	 * @param array $travel_styles
928 927
 	 * @return void
929 928
 	 */
930 929
 	public function set_travel_styles( $id, $data ) {
@@ -997,6 +996,7 @@  discard block
 block discarded – undo
997 996
 	 *
998 997
 	 * @param $day array
999 998
 	 * @param $id string
999
+	 * @param integer $leg_counter
1000 1000
 	 * @return boolean / string
1001 1001
 	 */
1002 1002
 	public function set_destination( $day, $id, $leg_counter ) {
Please login to merge, or discard this patch.
Spacing   +421 added lines, -421 removed lines patch added patch discarded remove patch
@@ -99,23 +99,23 @@  discard block
 block discarded – undo
99 99
 		parent::set_variables();
100 100
 
101 101
 		//https://wetu.com/API/Itinerary/V8/Get
102
-		if ( false !== $this->api_username && false !== $this->api_password ) {
102
+		if (false !== $this->api_username && false !== $this->api_password) {
103 103
 			$this->url    = 'https://wetu.com/API/Itinerary/';
104
-			$this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password;
105
-		} elseif ( false !== $this->api_key ) {
106
-			$this->url    = 'https://wetu.com/API/Itinerary/' . $this->api_key;
104
+			$this->url_qs = 'username='.$this->api_username.'&password='.$this->api_password;
105
+		} elseif (false !== $this->api_key) {
106
+			$this->url    = 'https://wetu.com/API/Itinerary/'.$this->api_key;
107 107
 			$this->url_qs = '';
108 108
 		}
109 109
 
110
-		$temp_options = get_option( '_lsx-to_settings',false );
110
+		$temp_options = get_option('_lsx-to_settings', false);
111 111
 
112
-		if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) {
113
-			$this->options = $temp_options[ $this->plugin_slug ];
112
+		if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) {
113
+			$this->options = $temp_options[$this->plugin_slug];
114 114
 		}
115 115
 
116
-		$tour_options = get_option( 'wetu_importer_tour_settings',false );
116
+		$tour_options = get_option('wetu_importer_tour_settings', false);
117 117
 
118
-		if ( false !== $tour_options ) {
118
+		if (false !== $tour_options) {
119 119
 			$this->tour_options = $tour_options;
120 120
 		}
121 121
 	}
@@ -126,17 +126,17 @@  discard block
 block discarded – undo
126 126
 	public function display_page() {
127 127
 		?>
128 128
 		<div class="wrap">
129
-			<?php $this->navigation( 'tour' ); ?>
129
+			<?php $this->navigation('tour'); ?>
130 130
 
131 131
 			<?php $this->update_options_form(); ?>
132 132
 
133 133
 			<?php $this->search_form(); ?>
134 134
 
135 135
 			<form method="get" action="" id="posts-filter">
136
-				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" />
136
+				<input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" />
137 137
 
138
-				<p><input class="button button-primary add" type="button" value="<?php esc_html_e( 'Add to List','wetu-importer' ); ?>" />
139
-					<input class="button button-primary clear" type="button" value="<?php esc_html_e( 'Clear','wetu-importer' ); ?>" />
138
+				<p><input class="button button-primary add" type="button" value="<?php esc_html_e('Add to List', 'wetu-importer'); ?>" />
139
+					<input class="button button-primary clear" type="button" value="<?php esc_html_e('Clear', 'wetu-importer'); ?>" />
140 140
 				</p>
141 141
 
142 142
 				<table class="wp-list-table widefat fixed posts">
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
 					<tbody id="the-list">
146 146
 						<tr class="post-0 type-tour status-none" id="post-0">
147 147
 							<th class="check-column" scope="row">
148
-								<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
+								<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>
149 149
 							</th>
150 150
 							<td class="date column-date column-ref" colspan="4">
151 151
 								<strong>
152
-									<?php esc_html_e( 'Search for tours using the search form above','wetu-importer' ); ?>
152
+									<?php esc_html_e('Search for tours using the search form above', 'wetu-importer'); ?>
153 153
 								</strong>							
154 154
 							</td>
155 155
 						</tr>
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 
160 160
 				</table>
161 161
 
162
-				<p><input class="button button-primary add" type="button" value="<?php esc_html_e( 'Add to List','wetu-importer' ); ?>" />
163
-					<input class="button button-primary clear" type="button" value="<?php esc_html_e( 'Clear','wetu-importer' ); ?>" />
162
+				<p><input class="button button-primary add" type="button" value="<?php esc_html_e('Add to List', 'wetu-importer'); ?>" />
163
+					<input class="button button-primary clear" type="button" value="<?php esc_html_e('Clear', 'wetu-importer'); ?>" />
164 164
 				</p>
165 165
 			</form>
166 166
 
@@ -170,21 +170,21 @@  discard block
 block discarded – undo
170 170
 
171 171
 					<div class="row">
172 172
 						<div class="settings-all" style="width:30%;display:block;float:left;">
173
-							<h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3>
173
+							<h3><?php esc_html_e('What content to Sync from WETU'); ?></h3>
174 174
 							<ul>
175
-								<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>
175
+								<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>
176 176
 
177
-								<?php if ( isset( $this->options ) && ! isset( $this->options['disable_tour_descriptions'] ) ) { ?>
178
-									<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>
177
+								<?php if (isset($this->options) && !isset($this->options['disable_tour_descriptions'])) { ?>
178
+									<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>
179 179
 								<?php } ?>
180 180
 
181
-								<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>
182
-								<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>
183
-								<li><input class="content" <?php $this->checked( $this->tour_options,'group_size' ); ?> type="checkbox" name="content[]" value="group_size" /> <?php esc_html_e( 'Group Size','wetu-importer' ); ?></li>
184
-								<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>
185
-								<li><input class="content" <?php $this->checked( $this->tour_options,'tags' ); ?> type="checkbox" name="content[]" value="tags" /> <?php esc_html_e( 'Tags','wetu-importer' ); ?></li>
181
+								<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>
182
+								<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>
183
+								<li><input class="content" <?php $this->checked($this->tour_options, 'group_size'); ?> type="checkbox" name="content[]" value="group_size" /> <?php esc_html_e('Group Size', 'wetu-importer'); ?></li>
184
+								<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>
185
+								<li><input class="content" <?php $this->checked($this->tour_options, 'tags'); ?> type="checkbox" name="content[]" value="tags" /> <?php esc_html_e('Tags', 'wetu-importer'); ?></li>
186 186
 
187
-								<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>
187
+								<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>
188 188
 
189 189
 								<?php
190 190
 								/*
@@ -196,33 +196,33 @@  discard block
 block discarded – undo
196 196
 							</ul>
197 197
 						</div>
198 198
 						<div class="settings-all" style="width:30%;display:block;float:left;">
199
-							<h3><?php esc_html_e( 'Itinerary Info' ); ?></h3>
199
+							<h3><?php esc_html_e('Itinerary Info'); ?></h3>
200 200
 							<ul>
201
-								<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>
202
-								<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>
203
-								<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>
201
+								<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>
202
+								<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>
203
+								<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>
204 204
 							</ul>
205 205
 
206
-							<h4><?php esc_html_e( 'Additional Content' ); ?></h4>
206
+							<h4><?php esc_html_e('Additional Content'); ?></h4>
207 207
 							<ul>
208
-								<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>
209
-								<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>
210
-								<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>
211
-								<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>
208
+								<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>
209
+								<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>
210
+								<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>
211
+								<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>
212 212
 							</ul>
213 213
 						</div>
214
-						<?php if ( class_exists( 'LSX_TO_Team' ) ) { ?>
214
+						<?php if (class_exists('LSX_TO_Team')) { ?>
215 215
 							<div style="width:30%;display:block;float:left;">
216
-								<h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3>
217
-								<?php $this->team_member_checkboxes( $this->tour_options ); ?>
216
+								<h3><?php esc_html_e('Assign a Team Member'); ?></h3>
217
+								<?php $this->team_member_checkboxes($this->tour_options); ?>
218 218
 							</div>
219 219
 						<?php } ?>
220 220
 
221 221
 						<br clear="both" />
222 222
 					</div>
223 223
 
224
-					<h3><?php esc_html_e( 'Your List' ); ?></h3>
225
-					<p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync','wetu-importer' ); ?>" /></p>
224
+					<h3><?php esc_html_e('Your List'); ?></h3>
225
+					<p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'wetu-importer'); ?>" /></p>
226 226
 					<table class="wp-list-table widefat fixed posts">
227 227
 						<?php $this->table_header(); ?>
228 228
 
@@ -234,12 +234,12 @@  discard block
 block discarded – undo
234 234
 
235 235
 					</table>
236 236
 
237
-					<p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync','wetu-importer' ); ?>" /></p>
237
+					<p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'wetu-importer'); ?>" /></p>
238 238
 				</form>
239 239
 			</div>
240 240
 
241 241
 			<div style="display:none;" class="completed-list-wrapper">
242
-				<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>
242
+				<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>
243 243
 				<ul>
244 244
 				</ul>
245 245
 			</div>
@@ -251,46 +251,46 @@  discard block
 block discarded – undo
251 251
 	 * search_form
252 252
 	 */
253 253
 	public function update_options_form() {
254
-		$tours = get_transient( 'lsx_ti_tours' );
254
+		$tours = get_transient('lsx_ti_tours');
255 255
 
256
-		echo '<div class="wetu-status tour-wetu-status"><h3>' . esc_html__( 'Wetu Status','wetu-importer' ) . ' - ';
256
+		echo '<div class="wetu-status tour-wetu-status"><h3>'.esc_html__('Wetu Status', 'wetu-importer').' - ';
257 257
 
258
-		if ( '' === $tours || false === $tours || isset( $_GET['refresh_tours'] ) ) {
258
+		if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) {
259 259
 			$result = $this->update_options();
260 260
 
261
-			if ( true === $result ) {
262
-				echo '<span style="color:green;">' . esc_attr( 'Connected','wetu-importer' ) . '</span>';
263
-				echo ' - <small><a href="#">' . esc_attr( 'Refresh','wetu-importer' ) . '</a></small>';
264
-			} else {
265
-				echo '<span style="color:red;">' . wp_kses_post( $result ) . '</span>';
261
+			if (true === $result) {
262
+				echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>';
263
+				echo ' - <small><a href="#">'.esc_attr('Refresh', 'wetu-importer').'</a></small>';
264
+			}else {
265
+				echo '<span style="color:red;">'.wp_kses_post($result).'</span>';
266 266
 			}
267
-		} else {
268
-			echo '<span style="color:green;">' . esc_attr( 'Connected','wetu-importer' ) . '</span> - <small><a href="#">' . esc_attr( 'Refresh','wetu-importer' ) . '</a></small>';
267
+		}else {
268
+			echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh', 'wetu-importer').'</a></small>';
269 269
 		}
270 270
 
271 271
 		echo '</h3>';
272 272
 
273
-		$form_options = get_option( 'lsx_ti_tours_api_options' );
274
-		if ( false === $form_options ) {
275
-			$form_options = array( 0 );
273
+		$form_options = get_option('lsx_ti_tours_api_options');
274
+		if (false === $form_options) {
275
+			$form_options = array(0);
276 276
 		}
277 277
 		?>
278
-		<form method="get" class="tour-refresh-form" action="<?php echo esc_attr( admin_url( 'admin.php' ) ); ?>">
279
-			<input type="hidden" name="page" value="<?php echo esc_attr( $this->plugin_slug ); ?>" />
278
+		<form method="get" class="tour-refresh-form" action="<?php echo esc_attr(admin_url('admin.php')); ?>">
279
+			<input type="hidden" name="page" value="<?php echo esc_attr($this->plugin_slug); ?>" />
280 280
 			<input type="hidden" name="tab" value="tour" />
281 281
 			<input type="hidden" name="refresh_tours" value="true" />
282 282
 
283 283
 			<p class="tour-search-options">
284
-				<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>
284
+				<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>
285 285
 			</p>
286 286
 
287 287
 			<p class="tour-search-options">
288
-				<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>
289
-				<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>
290
-				<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>
288
+				<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>
289
+				<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>
290
+				<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>
291 291
 			</p>
292 292
 
293
-			<p><input class="button button-primary submit" type="submit" value="<?php echo esc_attr( 'Refresh Tours','wetu-importer' ); ?>"></p>
293
+			<p><input class="button button-primary submit" type="submit" value="<?php echo esc_attr('Refresh Tours', 'wetu-importer'); ?>"></p>
294 294
 		</form>
295 295
 		<br />
296 296
 		<?php
@@ -304,29 +304,29 @@  discard block
 block discarded – undo
304 304
 		$own = '';
305 305
 		$options = array();
306 306
 
307
-		delete_option( 'lsx_ti_tours_api_options' );
307
+		delete_option('lsx_ti_tours_api_options');
308 308
 
309
-		if ( isset( $_GET['own'] ) ) {
309
+		if (isset($_GET['own'])) {
310 310
 			$this->url_qs .= '&own=true';
311 311
 			$options[] = 'own';
312 312
 		}
313 313
 
314
-		if ( isset( $_GET['type'] ) ) {
315
-			$this->url_qs .= '&type=' . implode( '',$_GET['type'] );
316
-			$options[] = implode( '',$_GET['type'] );
314
+		if (isset($_GET['type'])) {
315
+			$this->url_qs .= '&type='.implode('', $_GET['type']);
316
+			$options[] = implode('', $_GET['type']);
317 317
 		}
318 318
 
319 319
 		$this->url_qs .= '&results=2000';
320 320
 
321
-		add_option( 'lsx_ti_tours_api_options',$options );
321
+		add_option('lsx_ti_tours_api_options', $options);
322 322
 
323
-		$data = wp_remote_get( $this->url . '/V8/List?' . $this->url_qs );
324
-		$tours = json_decode( wp_remote_retrieve_body( $data ), true );
323
+		$data = wp_remote_get($this->url.'/V8/List?'.$this->url_qs);
324
+		$tours = json_decode(wp_remote_retrieve_body($data), true);
325 325
 
326
-		if ( isset( $tours['error'] ) ) {
326
+		if (isset($tours['error'])) {
327 327
 			return $tours['error'];
328
-		} elseif ( isset( $tours['itineraries'] ) && ! empty( $tours['itineraries'] ) ) {
329
-			set_transient( 'lsx_ti_tours',$tours['itineraries'],60 * 60 * 2 );
328
+		} elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) {
329
+			set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2);
330 330
 			return true;
331 331
 		}
332 332
 	}
@@ -351,9 +351,9 @@  discard block
 block discarded – undo
351 351
 			LIMIT 0,500
352 352
 		");
353 353
 
354
-		if ( null !== $current_tours && ! empty( $current_tours ) ) {
355
-			foreach ( $current_tours as $tour ) {
356
-				$return[ $tour->meta_value ] = $tour;
354
+		if (null !== $current_tours && !empty($current_tours)) {
355
+			foreach ($current_tours as $tour) {
356
+				$return[$tour->meta_value] = $tour;
357 357
 			}
358 358
 		}
359 359
 
@@ -367,47 +367,47 @@  discard block
 block discarded – undo
367 367
 		$return = false;
368 368
 
369 369
 		// @codingStandardsIgnoreLine
370
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_tour_importer' && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug ) {
371
-			$tours = get_transient( 'lsx_ti_tours' );
370
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) {
371
+			$tours = get_transient('lsx_ti_tours');
372 372
 
373
-			if ( false !== $tours ) {
373
+			if (false !== $tours) {
374 374
 
375 375
 				$searched_items = false;
376 376
 
377 377
 				// @codingStandardsIgnoreLine
378
-				if ( isset( $_POST['keyword'] ) ) {
378
+				if (isset($_POST['keyword'])) {
379 379
 					// @codingStandardsIgnoreLine
380 380
 					$keyphrases = $_POST['keyword'];
381
-				} else {
382
-					$keyphrases = array( 0 );
381
+				}else {
382
+					$keyphrases = array(0);
383 383
 				}
384 384
 
385
-				if ( ! is_array( $keyphrases ) ) {
386
-					$keyphrases = array( $keyphrases );
385
+				if (!is_array($keyphrases)) {
386
+					$keyphrases = array($keyphrases);
387 387
 				}
388
-				foreach ( $keyphrases as &$keyword ) {
389
-					$keyword = ltrim( rtrim( $keyword ) );
388
+				foreach ($keyphrases as &$keyword) {
389
+					$keyword = ltrim(rtrim($keyword));
390 390
 				}
391 391
 
392 392
 				$post_status = false;
393
-				if ( in_array( 'publish',$keyphrases ) ) {
393
+				if (in_array('publish', $keyphrases)) {
394 394
 					$post_status = 'publish';
395 395
 				}
396
-				if ( in_array( 'pending',$keyphrases ) ) {
396
+				if (in_array('pending', $keyphrases)) {
397 397
 					$post_status = 'pending';
398 398
 				}
399
-				if ( in_array( 'draft',$keyphrases ) ) {
399
+				if (in_array('draft', $keyphrases)) {
400 400
 					$post_status = 'draft';
401 401
 				}
402
-				if ( in_array( 'import',$keyphrases ) ) {
402
+				if (in_array('import', $keyphrases)) {
403 403
 					$post_status = 'import';
404 404
 				}
405 405
 
406
-				if ( ! empty( $tours ) ) {
406
+				if (!empty($tours)) {
407 407
 					$current_tours = $this->find_current_tours();
408 408
 
409
-					foreach ( $tours as $row_key => $row ) {
410
-						if ( isset( $row['is_disabled'] ) && true === $row['is_disabled'] ) {
409
+					foreach ($tours as $row_key => $row) {
410
+						if (isset($row['is_disabled']) && true === $row['is_disabled']) {
411 411
 							continue;
412 412
 						}
413 413
 
@@ -418,48 +418,48 @@  discard block
 block discarded – undo
418 418
 						//If this is a current tour, add its ID to the row.
419 419
 						$row['post_id'] = 0;
420 420
 
421
-						if ( false !== $current_tours && array_key_exists( $row['identifier'], $current_tours ) ) {
422
-							$row['post_id'] = $current_tours[ $row['identifier'] ]->post_id;
421
+						if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) {
422
+							$row['post_id'] = $current_tours[$row['identifier']]->post_id;
423 423
 						}
424 424
 
425 425
 						//If we are searching for
426
-						if ( false !== $post_status ) {
427
-							if ( 'import' === $post_status ) {
426
+						if (false !== $post_status) {
427
+							if ('import' === $post_status) {
428 428
 
429
-								if ( 0 !== $row['post_id'] ) {
429
+								if (0 !== $row['post_id']) {
430 430
 									continue;
431
-								} else {
432
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
431
+								}else {
432
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
433 433
 								}
434
-							} else {
435
-								if ( 0 === $row['post_id'] ) {
434
+							}else {
435
+								if (0 === $row['post_id']) {
436 436
 									continue;
437
-								} else {
438
-									$current_status = get_post_status( $row['post_id'] );
437
+								}else {
438
+									$current_status = get_post_status($row['post_id']);
439 439
 
440
-									if ( $current_status !== $post_status ) {
440
+									if ($current_status !== $post_status) {
441 441
 										continue;
442 442
 									}
443 443
 								}
444 444
 
445
-								$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
445
+								$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
446 446
 							}
447
-						} else {
447
+						}else {
448 448
 							//Search through each keyword.
449
-							foreach ( $keyphrases as $keyphrase ) {
449
+							foreach ($keyphrases as $keyphrase) {
450 450
 
451 451
 								//Make sure the keyphrase is turned into an array
452
-								$keywords = explode( ' ',$keyphrase );
453
-								if ( ! is_array( $keywords ) ) {
454
-									$keywords = array( $keywords );
452
+								$keywords = explode(' ', $keyphrase);
453
+								if (!is_array($keywords)) {
454
+									$keywords = array($keywords);
455 455
 								}
456 456
 
457
-								if ( $this->multineedle_stripos( ltrim( rtrim( $row['name'] ) ), $keywords ) !== false ) {
458
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
459
-								} else if ( $this->multineedle_stripos( ltrim( rtrim( $row['reference_number'] ) ), $keywords ) !== false ) {
460
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
461
-								}else if ( $this->multineedle_stripos( ltrim( rtrim( $row['identifier_key'] ) ), $keywords ) !== false ) {
462
-									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
457
+								if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) {
458
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
459
+								}else if ($this->multineedle_stripos(ltrim(rtrim($row['reference_number'])), $keywords) !== false) {
460
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
461
+								}else if ($this->multineedle_stripos(ltrim(rtrim($row['identifier_key'])), $keywords) !== false) {
462
+									$searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row);
463 463
 								}
464 464
 
465 465
 								//Add in the year and ref
@@ -468,12 +468,12 @@  discard block
 block discarded – undo
468 468
 					}
469 469
 				}
470 470
 
471
-				if ( false !== $searched_items ) {
472
-					ksort( $searched_items );
473
-					$return = implode( $searched_items );
471
+				if (false !== $searched_items) {
472
+					ksort($searched_items);
473
+					$return = implode($searched_items);
474 474
 				}
475 475
 			}
476
-			print_r( $return );
476
+			print_r($return);
477 477
 			die();
478 478
 		}
479 479
 	}
@@ -481,31 +481,31 @@  discard block
 block discarded – undo
481 481
 	/**
482 482
 	 * Formats the row for output on the screen.
483 483
 	 */
484
-	public function format_row( $row = false ) {
485
-		if ( false !== $row ) {
484
+	public function format_row($row = false) {
485
+		if (false !== $row) {
486 486
 			$status = 'import';
487 487
 
488
-			if ( 0 !== $row['post_id'] ) {
489
-				$status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>';
488
+			if (0 !== $row['post_id']) {
489
+				$status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>';
490 490
 			}
491 491
 
492 492
 			$row_html = '
493
-			<tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '">
493
+			<tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'">
494 494
 				<th class="check-column" scope="row">
495
-					<label for="cb-select-' . $row['identifier'] . '" class="screen-reader-text">' . $row['name'] . '</label>
496
-					<input type="checkbox" data-identifier="' . $row['identifier'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['identifier'] . '">
495
+					<label for="cb-select-' . $row['identifier'].'" class="screen-reader-text">'.$row['name'].'</label>
496
+					<input type="checkbox" data-identifier="' . $row['identifier'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['identifier'].'">
497 497
 				</th>			
498 498
 				<td class="post-title page-title column-title">
499
-					<strong>' . $row['name'] . '</strong> - ' . $status . '
499
+					<strong>' . $row['name'].'</strong> - '.$status.'
500 500
 				</td>
501 501
 				<td class="date column-date">
502
-					' . $row['reference_number'] . '
502
+					' . $row['reference_number'].'
503 503
 				</td>				
504 504
 				<td class="date column-date">
505
-					<abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified
505
+					<abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified
506 506
 				</td>
507 507
 				<td class="ssid column-ssid">
508
-					' . $row['identifier'] . '
508
+					' . $row['identifier'].'
509 509
 				</td>
510 510
 			</tr>';
511 511
 			return $row_html;
@@ -515,45 +515,45 @@  discard block
 block discarded – undo
515 515
 	/**
516 516
 	 * Connect to wetu
517 517
 	 */
518
-	public function process_ajax_import( $force = false ) {
518
+	public function process_ajax_import($force = false) {
519 519
 		$return = false;
520 520
 
521 521
 		// @codingStandardsIgnoreLine
522
-		if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug && isset( $_POST['wetu_id'] ) ) {
522
+		if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) {
523 523
 
524 524
 			// @codingStandardsIgnoreLine
525 525
 			$wetu_id = $_POST['wetu_id'];
526 526
 
527 527
 			// @codingStandardsIgnoreLine
528
-			if ( isset( $_POST['post_id'] ) ) {
528
+			if (isset($_POST['post_id'])) {
529 529
 				// @codingStandardsIgnoreLine
530 530
 				$post_id = $_POST['post_id'];
531
-			} else {
531
+			}else {
532 532
 				$post_id = 0;
533 533
 			}
534 534
 
535
-			delete_option( 'wetu_importer_tour_settings' );
535
+			delete_option('wetu_importer_tour_settings');
536 536
 
537 537
 			// @codingStandardsIgnoreLine
538
-			if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) {
538
+			if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) {
539 539
 				// @codingStandardsIgnoreLine
540 540
 				$content = $_POST['content'];
541
-				add_option( 'wetu_importer_tour_settings',$content );
542
-			} else {
541
+				add_option('wetu_importer_tour_settings', $content);
542
+			}else {
543 543
 				$content = false;
544 544
 			}
545
-			$jdata = wp_remote_get( 'https://wetu.com/API/Itinerary/V8/Get?id=' . $wetu_id );		
545
+			$jdata = wp_remote_get('https://wetu.com/API/Itinerary/V8/Get?id='.$wetu_id);		
546 546
 
547
-			if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
548
-				$jdata = json_decode( $jdata['body'], true );
549
-				$return = $this->import_row( $jdata, $wetu_id, $post_id, $content );
550
-				$this->format_completed_row( $return );
547
+			if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
548
+				$jdata = json_decode($jdata['body'], true);
549
+				$return = $this->import_row($jdata, $wetu_id, $post_id, $content);
550
+				$this->format_completed_row($return);
551 551
 				$this->save_queue();
552 552
 				$this->cleanup_posts();
553
-				$this->attach_destination_images( $content );
554
-				$this->clean_attached_destinations( $return );
555
-			} else {
556
-				$this->format_error( esc_html__( 'There was a problem importing your tour, please contact support.', 'wetu-importer' ) );
553
+				$this->attach_destination_images($content);
554
+				$this->clean_attached_destinations($return);
555
+			}else {
556
+				$this->format_error(esc_html__('There was a problem importing your tour, please contact support.', 'wetu-importer'));
557 557
 			}
558 558
 		}
559 559
 	}
@@ -564,13 +564,13 @@  discard block
 block discarded – undo
564 564
 	 * @param $id string
565 565
 	 * @return void
566 566
 	 */
567
-	public function clean_attached_destinations( $id ) {
568
-		$current_connections = get_post_meta( $id, 'destination_to_tour', false );
569
-		delete_post_meta( $id,'destination_to_tour' );
570
-		$current_connections = array_unique( $current_connections );
567
+	public function clean_attached_destinations($id) {
568
+		$current_connections = get_post_meta($id, 'destination_to_tour', false);
569
+		delete_post_meta($id, 'destination_to_tour');
570
+		$current_connections = array_unique($current_connections);
571 571
 
572
-		foreach ( $current_connections as $connection ) {
573
-			add_post_meta( $id, 'destination_to_tour',$connection, false );
572
+		foreach ($current_connections as $connection) {
573
+			add_post_meta($id, 'destination_to_tour', $connection, false);
574 574
 		}
575 575
 	}
576 576
 
@@ -580,12 +580,12 @@  discard block
 block discarded – undo
580 580
 	 * @param $data array
581 581
 	 * @param $wetu_id string
582 582
 	 */
583
-	public function import_row( $data, $wetu_id, $id = 0, $importable_content = array(), $old1 = false, $old2 = false ) {
583
+	public function import_row($data, $wetu_id, $id = 0, $importable_content = array(), $old1 = false, $old2 = false) {
584 584
 		$post_name = '';
585 585
 		$data_post_content = '';
586 586
 		$data_post_excerpt = '';
587 587
 
588
-		$current_post = get_post( $id );
588
+		$current_post = get_post($id);
589 589
 
590 590
 		$post = array(
591 591
 			'post_type' => 'tour',
@@ -593,33 +593,33 @@  discard block
 block discarded – undo
593 593
 
594 594
 		$content_used_general_description = false;
595 595
 
596
-		if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) {
596
+		if (!empty($importable_content) && in_array('description', $importable_content)) {
597 597
 			$data_post_content = $current_post->post_content;
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
 			$post['post_content'] = $data_post_content;
602 602
 		}
603 603
 
604 604
 		// Create or update the post.
605
-		if ( false !== $id && '0' !== $id ) {
605
+		if (false !== $id && '0' !== $id) {
606 606
 			$post['ID'] = $id;
607 607
 			$post['post_status'] = 'publish';
608
-			$id = wp_update_post( $post );
609
-			$prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true );
610
-			update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data['last_modified'] ), $prev_date );
608
+			$id = wp_update_post($post);
609
+			$prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true);
610
+			update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']), $prev_date);
611 611
 
612 612
 			// If the logger is enabled then log the data being saved.
613
-			if ( $this->debug_enabled ) {
614
-				$this->logger->log( 'wetu-importer', 'Creating Tour', print_r( $post, true ) );
613
+			if ($this->debug_enabled) {
614
+				$this->logger->log('wetu-importer', 'Creating Tour', print_r($post, true));
615 615
 			}
616
-		} else {
616
+		}else {
617 617
 			// Set the name.
618
-			if ( isset( $data['name'] ) ) {
619
-				$post_name = wp_unique_post_slug( sanitize_title( $data['name'] ), $id, 'draft', 'tour', 0 );
618
+			if (isset($data['name'])) {
619
+				$post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0);
620 620
 			}
621 621
 
622
-			if ( ! isset( $post['post_content'] ) ) {
622
+			if (!isset($post['post_content'])) {
623 623
 				$post['post_content'] = ' ';
624 624
 			}
625 625
 
@@ -628,44 +628,44 @@  discard block
 block discarded – undo
628 628
 			$post['post_status'] = 'publish';
629 629
 
630 630
 			// If the logger is enabled then log the data being saved.
631
-			if ( $this->debug_enabled ) {
632
-				$this->logger->log( 'wetu-importer', 'Creating Tour', print_r( $post, true ) );
631
+			if ($this->debug_enabled) {
632
+				$this->logger->log('wetu-importer', 'Creating Tour', print_r($post, true));
633 633
 			}
634
-			$id = wp_insert_post( $post );
634
+			$id = wp_insert_post($post);
635 635
 
636 636
 			// Save the WETU ID and the Last date it was modified.
637
-			if ( false !== $id ) {
638
-				add_post_meta( $id, 'lsx_wetu_id', $wetu_id );
639
-				add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data['last_modified'] ) );
637
+			if (false !== $id) {
638
+				add_post_meta($id, 'lsx_wetu_id', $wetu_id);
639
+				add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']));
640 640
 			}
641 641
 		}
642 642
 
643 643
 		// Set the price.
644
-		if ( false !== $importable_content && in_array( 'price', $importable_content ) ) {
645
-			$this->set_price( $data, $id );
644
+		if (false !== $importable_content && in_array('price', $importable_content)) {
645
+			$this->set_price($data, $id);
646 646
 		}
647 647
 
648 648
 		// Set the Duration.
649
-		if ( false !== $importable_content && in_array( 'duration', $importable_content ) ) {
650
-			$this->set_duration( $data, $id );
649
+		if (false !== $importable_content && in_array('duration', $importable_content)) {
650
+			$this->set_duration($data, $id);
651 651
 		}
652 652
 
653 653
 		// Set the Group Size.
654
-		if ( false !== $importable_content && in_array( 'group_size', $importable_content ) ) {
655
-			$this->set_group_size( $data, $id );
654
+		if (false !== $importable_content && in_array('group_size', $importable_content)) {
655
+			$this->set_group_size($data, $id);
656 656
 		}
657 657
 
658 658
 		// Set the Group Size.
659
-		if ( false !== $importable_content && in_array( 'tags', $importable_content ) ) {
660
-			$this->set_travel_styles( $id, $data );
659
+		if (false !== $importable_content && in_array('tags', $importable_content)) {
660
+			$this->set_travel_styles($id, $data);
661 661
 		}
662 662
 
663
-		if ( false !== $importable_content && in_array( 'itineraries', $importable_content ) && isset( $data['legs'] ) && ! empty( $data['legs'] ) ) {
664
-			$this->process_itineraries( $data, $id, $importable_content );
663
+		if (false !== $importable_content && in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) {
664
+			$this->process_itineraries($data, $id, $importable_content);
665 665
 		}
666 666
 
667
-		if ( in_array( 'map', $importable_content ) && isset( $data['routes'] ) && ! empty( $data['routes'] ) ) {
668
-			$this->set_map_data( $data, $id );
667
+		if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) {
668
+			$this->set_map_data($data, $id);
669 669
 		}
670 670
 
671 671
 		return $id;
@@ -674,196 +674,196 @@  discard block
 block discarded – undo
674 674
 	/**
675 675
 	 * A loop which runs through each leg on the tour.
676 676
 	 */
677
-	public function process_itineraries( $data, $id, $importable_content ) {
677
+	public function process_itineraries($data, $id, $importable_content) {
678 678
 		$day_counter = 1;
679 679
 		$leg_counter = 0;
680 680
 
681
-		delete_post_meta( $id, 'itinerary' );
681
+		delete_post_meta($id, 'itinerary');
682 682
 
683
-		if ( false !== $importable_content && in_array( 'accommodation', $importable_content ) ) {
684
-			delete_post_meta( $id, 'accommodation_to_tour' );
683
+		if (false !== $importable_content && in_array('accommodation', $importable_content)) {
684
+			delete_post_meta($id, 'accommodation_to_tour');
685 685
 		}
686
-		if ( false !== $importable_content && in_array( 'destination', $importable_content ) ) {
687
-			delete_post_meta( $id, 'departs_from' );
688
-			delete_post_meta( $id, 'ends_in' );
686
+		if (false !== $importable_content && in_array('destination', $importable_content)) {
687
+			delete_post_meta($id, 'departs_from');
688
+			delete_post_meta($id, 'ends_in');
689 689
 		}
690 690
 
691 691
 		$departs_from = false;
692 692
 		$ends_in = false;
693 693
 
694
-		foreach ( $data['legs'] as $leg ) {
694
+		foreach ($data['legs'] as $leg) {
695 695
 			// Itinerary Accommodation.
696 696
 			$current_accommodation = false;
697
-			if ( false !== $importable_content && in_array( 'accommodation', $importable_content ) ) {
698
-				$current_accommodation = $this->set_accommodation( $leg, $id );
697
+			if (false !== $importable_content && in_array('accommodation', $importable_content)) {
698
+				$current_accommodation = $this->set_accommodation($leg, $id);
699 699
 			}
700 700
 
701 701
 			// Itinerary Destination.
702 702
 			$current_destination = false;
703
-			if ( false !== $importable_content && in_array( 'destination', $importable_content ) ) {
704
-				$current_destination = $this->set_destination( $leg, $id, $leg_counter );
703
+			if (false !== $importable_content && in_array('destination', $importable_content)) {
704
+				$current_destination = $this->set_destination($leg, $id, $leg_counter);
705 705
 			}
706 706
 
707 707
 			// If the Nights are the same mount of days in the array,  then it isnt "By Destination".
708
-			if ( ( (1 <= (int) $leg['nights'] && isset( $leg['periods'] ) ) ) || 0 === $leg['itinerary_leg_id'] ) {
709
-				foreach ( $leg['periods'] as $day ) {
708
+			if (((1 <= (int) $leg['nights'] && isset($leg['periods']))) || 0 === $leg['itinerary_leg_id']) {
709
+				foreach ($leg['periods'] as $day) {
710 710
 					$current_day = array();
711
-					$current_day['title'] = esc_attr( 'Day ', 'wetu-importer' ) . $day_counter;
711
+					$current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter;
712 712
 
713 713
 					//print_r('<pre>');print_r($day['notes']);print_r('</pre>');
714 714
 
715 715
 					// Description.
716
-					if ( false !== $importable_content && in_array( 'itinerary_description', $importable_content ) && isset( $day['notes'] ) ) {
716
+					if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) {
717 717
 						$current_day['description'] = $day['notes'];
718
-					} else {
718
+					}else {
719 719
 						$current_day['description'] = '';
720 720
 					}
721 721
 
722 722
 					// Itinerary Gallery.
723
-					if ( false !== $importable_content && in_array( 'itinerary_gallery', $importable_content ) && isset( $day['images'] ) ) {
723
+					if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) {
724 724
 						$current_day['featured_image'] = '';
725
-					} else {
725
+					}else {
726 726
 						$current_day['featured_image'] = '';
727 727
 					}
728 728
 
729 729
 					// Accommodation.
730
-					if ( false !== $current_accommodation ) {
731
-						$current_day['accommodation_to_tour'] = array( $current_accommodation );
732
-					} else {
730
+					if (false !== $current_accommodation) {
731
+						$current_day['accommodation_to_tour'] = array($current_accommodation);
732
+					}else {
733 733
 						$current_day['accommodation_to_tour'] = array();
734 734
 					}
735 735
 
736 736
 					// Destination.
737
-					if ( false !== $current_destination ) {
738
-						$current_day['destination_to_tour'] = array( $current_destination );
739
-					} else {
737
+					if (false !== $current_destination) {
738
+						$current_day['destination_to_tour'] = array($current_destination);
739
+					}else {
740 740
 						$current_day['destination_to_tour'] = array();
741 741
 					}
742 742
 
743 743
 					// Included.
744
-					if ( false !== $importable_content && in_array( 'itinerary_included', $importable_content ) && isset( $day['included'] ) && '' !== $day['included'] ) {
744
+					if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) {
745 745
 						$current_day['included'] = $day['included'];
746
-					} else {
746
+					}else {
747 747
 						$current_day['included'] = '';
748 748
 					}
749 749
 
750 750
 					// Excluded.
751
-					if ( false !== $importable_content && in_array( 'itinerary_excluded', $importable_content ) && isset( $day['excluded'] ) && '' !== $day['excluded'] ) {
751
+					if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) {
752 752
 						$current_day['excluded'] = $day['excluded'];
753
-					} else {
753
+					}else {
754 754
 						$current_day['excluded'] = '';
755 755
 					}
756 756
 
757
-					$this->set_itinerary_day( $current_day,$id );
757
+					$this->set_itinerary_day($current_day, $id);
758 758
 					$day_counter++;
759 759
 				}
760
-			} else {
760
+			}else {
761 761
 				// This is for the by destination.
762 762
 
763 763
 				$current_day = array();
764 764
 				$next_day_count = $day_counter + (int) $leg['nights'];
765 765
 				$day_count_label = $next_day_count - 1;
766 766
 
767
-				$current_day['title'] = esc_attr( 'Day ', 'wetu-importer' ) . $day_counter;
767
+				$current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter;
768 768
 
769
-				if ( 0 !== (int) $leg['nights'] ) {
770
-					$current_day['title'] .= ' - ' . $day_count_label;
769
+				if (0 !== (int) $leg['nights']) {
770
+					$current_day['title'] .= ' - '.$day_count_label;
771 771
 				}
772 772
 
773 773
 				// Description.
774
-				if ( false !== $importable_content && in_array( 'itinerary_description', $importable_content ) && isset( $leg['notes'] ) ) {
774
+				if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($leg['notes'])) {
775 775
 					$current_day['description'] = $leg['notes'];
776
-				} else {
776
+				}else {
777 777
 					$current_day['description'] = '';
778 778
 				}
779 779
 
780 780
 				// Itinerary Gallery.
781
-				if ( false !== $importable_content && in_array( 'itinerary_gallery', $importable_content ) && isset( $leg['images'] ) ) {
781
+				if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($leg['images'])) {
782 782
 					$current_day['featured_image'] = '';
783
-				} else {
783
+				}else {
784 784
 					$current_day['featured_image'] = '';
785 785
 				}
786 786
 
787 787
 				// Accommodation.
788
-				if ( false !== $current_accommodation ) {
789
-					$current_day['accommodation_to_tour'] = array( $current_accommodation );
790
-				} else {
788
+				if (false !== $current_accommodation) {
789
+					$current_day['accommodation_to_tour'] = array($current_accommodation);
790
+				}else {
791 791
 					$current_day['accommodation_to_tour'] = array();
792 792
 				}
793 793
 
794 794
 				// Destination.
795
-				if ( false !== $current_destination ) {
796
-					$current_day['destination_to_tour'] = array( $current_destination );
797
-				} else {
795
+				if (false !== $current_destination) {
796
+					$current_day['destination_to_tour'] = array($current_destination);
797
+				}else {
798 798
 					$current_day['destination_to_tour'] = array();
799 799
 				}
800 800
 
801 801
 				//Included
802
-				if ( false !== $importable_content && in_array( 'itinerary_included', $importable_content ) && isset( $leg['included'] ) && '' !== $leg['included'] ) {
802
+				if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($leg['included']) && '' !== $leg['included']) {
803 803
 					$current_day['included'] = $leg['included'];
804
-				} else {
804
+				}else {
805 805
 					$current_day['included'] = '';
806 806
 				}
807 807
 
808 808
 				//Excluded
809
-				if ( false !== $importable_content && in_array( 'itinerary_excluded', $importable_content ) && isset( $leg['excluded'] ) && '' !== $leg['excluded'] ) {
809
+				if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($leg['excluded']) && '' !== $leg['excluded']) {
810 810
 					$current_day['excluded'] = $leg['excluded'];
811
-				} else {
811
+				}else {
812 812
 					$current_day['excluded'] = '';
813 813
 				}
814 814
 
815
-				$this->set_itinerary_day( $current_day,$id );
815
+				$this->set_itinerary_day($current_day, $id);
816 816
 				$day_counter = $next_day_count;
817 817
 			}
818 818
 
819 819
 			//If we are in the first leg,  and the destination was attached then save it as the departure field.
820
-			if ( 0 === $leg_counter && false !== $current_destination ) {
820
+			if (0 === $leg_counter && false !== $current_destination) {
821 821
 				$departs_from = $current_destination;
822 822
 			}
823 823
 
824 824
 			//If its the last leg then save it as the ends in.
825 825
 			// @codingStandardsIgnoreLine
826
-			if ( $leg_counter === (count( $data['legs'] ) -2) && false !== $current_destination ) {
826
+			if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) {
827 827
 				$ends_in = $current_destination;
828 828
 			}
829 829
 
830 830
 			$leg_counter++;
831 831
 		}
832 832
 
833
-		if ( false !== $departs_from ) {
834
-			add_post_meta( $id, 'departs_from', $departs_from, true );
833
+		if (false !== $departs_from) {
834
+			add_post_meta($id, 'departs_from', $departs_from, true);
835 835
 		}
836
-		if ( false !== $ends_in ) {
837
-			add_post_meta( $id, 'ends_in', $ends_in, true );
836
+		if (false !== $ends_in) {
837
+			add_post_meta($id, 'ends_in', $ends_in, true);
838 838
 		}
839 839
 	}
840 840
 
841 841
 	/**
842 842
 	 * Run through your routes and save the points as a KML file.
843 843
 	 */
844
-	public function set_map_data( $data, $id, $zoom = 9 ) {
845
-		if ( ! empty( $data['routes'] ) ) {
846
-			delete_post_meta( $id,'wetu_map_points' );
844
+	public function set_map_data($data, $id, $zoom = 9) {
845
+		if (!empty($data['routes'])) {
846
+			delete_post_meta($id, 'wetu_map_points');
847 847
 
848 848
 			$points = array();
849 849
 
850
-			foreach ( $data['routes'] as $route ) {
850
+			foreach ($data['routes'] as $route) {
851 851
 
852
-				if ( isset( $route['points'] ) && '' !== $route['points'] ) {
852
+				if (isset($route['points']) && '' !== $route['points']) {
853 853
 
854
-					$temp_points = explode( ';',$route['points'] );
855
-					$point_counter = count( $temp_points );
854
+					$temp_points = explode(';', $route['points']);
855
+					$point_counter = count($temp_points);
856 856
 
857
-					for ( $x = 0; $x <= $point_counter; $x++ ) {
857
+					for ($x = 0; $x <= $point_counter; $x++) {
858 858
 						$y = $x + 1;
859
-						$points[] = $temp_points[ $x ] . ',' . $temp_points[ $y ];
859
+						$points[] = $temp_points[$x].','.$temp_points[$y];
860 860
 						$x++;
861 861
 					}
862 862
 				}
863 863
 			}
864 864
 
865
-			if ( ! empty( $points ) ) {
866
-				$this->save_custom_field( implode( ' ',$points ),'wetu_map_points',$id,false,true );
865
+			if (!empty($points)) {
866
+				$this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true);
867 867
 			}
868 868
 		}
869 869
 
@@ -874,49 +874,49 @@  discard block
 block discarded – undo
874 874
 	/**
875 875
 	 * Set the Itinerary Day
876 876
 	 */
877
-	public function set_itinerary_day( $day, $id ) {
878
-		$this->save_custom_field( $day,'itinerary',$id,false,false );
877
+	public function set_itinerary_day($day, $id) {
878
+		$this->save_custom_field($day, 'itinerary', $id, false, false);
879 879
 	}
880 880
 
881 881
 	/**
882 882
 	 * Set the price
883 883
 	 */
884
-	public function set_price( $data, $id ) {
884
+	public function set_price($data, $id) {
885 885
 		//Price
886
-		if ( isset( $data['price'] ) && '' !== $data['price'] ) {
887
-			$price = preg_replace( '/[^0-9,.]/', '', $data['price'] );
888
-			$this->save_custom_field( $price,'price',$id );
886
+		if (isset($data['price']) && '' !== $data['price']) {
887
+			$price = preg_replace('/[^0-9,.]/', '', $data['price']);
888
+			$this->save_custom_field($price, 'price', $id);
889 889
 		}
890 890
 
891 891
 		//Price includes
892
-		if ( isset( $data['price_includes'] ) && '' !== $data['price_includes'] ) {
893
-			$this->save_custom_field( $data['price_includes'],'included',$id );
892
+		if (isset($data['price_includes']) && '' !== $data['price_includes']) {
893
+			$this->save_custom_field($data['price_includes'], 'included', $id);
894 894
 		}
895 895
 
896 896
 		//Price Excludes
897
-		if ( isset( $data['price_excludes'] ) && '' !== $data['price_excludes'] ) {
898
-			$this->save_custom_field( $data['price_excludes'],'not_included',$id );
897
+		if (isset($data['price_excludes']) && '' !== $data['price_excludes']) {
898
+			$this->save_custom_field($data['price_excludes'], 'not_included', $id);
899 899
 		}
900 900
 	}
901 901
 
902 902
 	/**
903 903
 	 * Set the duration
904 904
 	 */
905
-	public function set_duration( $data, $id ) {
906
-		if ( isset( $data['days'] ) && ! empty( $data['days'] ) ) {
905
+	public function set_duration($data, $id) {
906
+		if (isset($data['days']) && !empty($data['days'])) {
907 907
 			$price = $data['days'];
908
-			$price = preg_replace( '/[^0-9,.]/', '', $price );
909
-			$this->save_custom_field( $price,'duration',$id );
908
+			$price = preg_replace('/[^0-9,.]/', '', $price);
909
+			$this->save_custom_field($price, 'duration', $id);
910 910
 		}
911 911
 	}
912 912
 
913 913
 	/**
914 914
 	 * Set the group size
915 915
 	 */
916
-	public function set_group_size( $data, $id ) {
917
-		if ( isset( $data['group_size'] ) && ! empty( $data['group_size'] ) ) {
916
+	public function set_group_size($data, $id) {
917
+		if (isset($data['group_size']) && !empty($data['group_size'])) {
918 918
 			$group_size = $data['group_size'];
919
-			$this->save_custom_field( $group_size,'group_size',$id );
919
+			$this->save_custom_field($group_size, 'group_size', $id);
920 920
 		}
921 921
 	}
922 922
 
@@ -927,10 +927,10 @@  discard block
 block discarded – undo
927 927
 	 * @param array $travel_styles
928 928
 	 * @return void
929 929
 	 */
930
-	public function set_travel_styles( $id, $data ) {
931
-		if ( isset( $data['tags'] ) ) {
932
-			foreach ( $data['tags'] as $tag ) {
933
-				$this->set_term( $id, $tag, 'travel-style' );
930
+	public function set_travel_styles($id, $data) {
931
+		if (isset($data['tags'])) {
932
+			foreach ($data['tags'] as $tag) {
933
+				$this->set_term($id, $tag, 'travel-style');
934 934
 			}
935 935
 		}
936 936
 	}
@@ -938,27 +938,27 @@  discard block
 block discarded – undo
938 938
 	/**
939 939
 	 * Connects the Accommodation if its available
940 940
 	 */
941
-	public function set_accommodation( $day, $id ) {
941
+	public function set_accommodation($day, $id) {
942 942
 		$ac_id = false;
943 943
 		$this->current_accommodation = $this->find_current_accommodation();
944 944
 
945
-		if ( isset( $day['content_entity_id'] ) && ! empty( $day['content_entity_id'] ) ) {
946
-			if ( false !== $this->current_accommodation && ! empty( $this->current_accommodation ) && array_key_exists( $day['content_entity_id'],$this->current_accommodation ) ) {
947
-				$ac_id = $this->current_accommodation[ $day['content_entity_id'] ];
948
-			} else {
945
+		if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) {
946
+			if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) {
947
+				$ac_id = $this->current_accommodation[$day['content_entity_id']];
948
+			}else {
949 949
 				$ac_id = wp_insert_post(array(
950 950
 					'post_type' => 'accommodation',
951 951
 					'post_status' => 'draft',
952 952
 					'post_title' => $day['content_entity_id'],
953 953
 				));
954 954
 
955
-				$this->save_custom_field( $day['content_entity_id'],'lsx_wetu_id',$ac_id );
955
+				$this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id);
956 956
 			}
957 957
 
958
-			if ( '' !== $ac_id && false !== $ac_id ) {
959
-				$this->save_custom_field( $ac_id,'accommodation_to_tour',$id,false,false );
960
-				$this->save_custom_field( $id,'tour_to_accommodation',$ac_id,false,false );
961
-				$this->queue_item( $ac_id );
958
+			if ('' !== $ac_id && false !== $ac_id) {
959
+				$this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false);
960
+				$this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false);
961
+				$this->queue_item($ac_id);
962 962
 			}
963 963
 		}
964 964
 		return $ac_id;
@@ -970,14 +970,14 @@  discard block
 block discarded – undo
970 970
 	 * @param $post_type string
971 971
 	 * @return boolean / array
972 972
 	 */
973
-	public function find_current_accommodation( $post_type = 'accommodation' ) {
973
+	public function find_current_accommodation($post_type = 'accommodation') {
974 974
 		global $wpdb;
975
-		$accommodation = parent::find_current_accommodation( $post_type );
975
+		$accommodation = parent::find_current_accommodation($post_type);
976 976
 		$return = false;
977 977
 
978
-		if ( ! empty( $accommodation ) ) {
979
-			foreach ( $accommodation as $key => $acc ) {
980
-				$return[ $acc->meta_value ] = $acc->post_id;
978
+		if (!empty($accommodation)) {
979
+			foreach ($accommodation as $key => $acc) {
980
+				$return[$acc->meta_value] = $acc->post_id;
981 981
 			}
982 982
 		}
983 983
 
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
 	 * @return boolean / array
990 990
 	 */
991 991
 	public function find_current_destinations() {
992
-		return $this->find_current_accommodation( 'destination' );
992
+		return $this->find_current_accommodation('destination');
993 993
 	}
994 994
 
995 995
 	/**
@@ -999,44 +999,44 @@  discard block
 block discarded – undo
999 999
 	 * @param $id string
1000 1000
 	 * @return boolean / string
1001 1001
 	 */
1002
-	public function set_destination( $day, $id, $leg_counter ) {
1002
+	public function set_destination($day, $id, $leg_counter) {
1003 1003
 		$dest_id    = false;
1004 1004
 		$country_id = false;
1005 1005
 		
1006 1006
 		$this->current_destinations = $this->find_current_destinations();
1007 1007
 
1008
-		if ( isset( $day['destination_content_entity_id'] ) && ! empty( $day['destination_content_entity_id'] ) ) {
1009
-			if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $day['destination_content_entity_id'], $this->current_destinations ) ) {
1010
-				$dest_id = $this->current_destinations[ $day['destination_content_entity_id'] ];
1008
+		if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) {
1009
+			if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) {
1010
+				$dest_id = $this->current_destinations[$day['destination_content_entity_id']];
1011 1011
 
1012 1012
 				//TODO Check for attachments here.
1013
-				$this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] );
1013
+				$this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']);
1014 1014
 
1015 1015
 				//Check if there is a country asigned.
1016
-				$potential_id = wp_get_post_parent_id( $dest_id );
1017
-				$country_wetu_id = get_post_meta( $potential_id, 'lsx_wetu_id', true );
1016
+				$potential_id = wp_get_post_parent_id($dest_id);
1017
+				$country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true);
1018 1018
 
1019
-				if ( false !== $country_wetu_id ) {
1020
-					$country_id = $this->set_country( $country_wetu_id, $id );
1019
+				if (false !== $country_wetu_id) {
1020
+					$country_id = $this->set_country($country_wetu_id, $id);
1021 1021
 				}
1022
-			} else {
1023
-				$destination_json = wp_remote_get( 'https://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $day['destination_content_entity_id'] );
1022
+			}else {
1023
+				$destination_json = wp_remote_get('https://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$day['destination_content_entity_id']);
1024 1024
 
1025
-				if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) {
1025
+				if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) {
1026 1026
 
1027
-					$destination_data = json_decode( $destination_json['body'], true );
1027
+					$destination_data = json_decode($destination_json['body'], true);
1028 1028
 
1029
-					if ( ! empty( $destination_data ) && ! isset( $destination_data['error'] ) ) {
1029
+					if (!empty($destination_data) && !isset($destination_data['error'])) {
1030 1030
 						$destination_title = $day['destination_content_entity_id'];
1031 1031
 
1032
-						if ( isset( $destination_data[0]['name'] ) ) {
1032
+						if (isset($destination_data[0]['name'])) {
1033 1033
 							$destination_title = $destination_data[0]['name'];
1034 1034
 						}
1035 1035
 
1036
-						if ( isset( $destination_data[0]['map_object_id'] ) && isset( $destination_data[0]['position']['country_content_entity_id'] )
1037
-							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id'] ) {
1036
+						if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id'])
1037
+							&& $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) {
1038 1038
 
1039
-							$country_id = $this->set_country( $destination_data[0]['position']['country_content_entity_id'], $id );
1039
+							$country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id);
1040 1040
 							// Save the destination so we can grab the tour featured image and banner from them.
1041 1041
 						}
1042 1042
 
@@ -1046,40 +1046,40 @@  discard block
 block discarded – undo
1046 1046
 							'post_title' => $destination_title,
1047 1047
 						);
1048 1048
 
1049
-						if ( false !== $country_id ) {
1049
+						if (false !== $country_id) {
1050 1050
 							$dest_post['post_parent'] = $country_id;
1051 1051
 						}
1052
-						$dest_id = wp_insert_post( $dest_post );
1052
+						$dest_id = wp_insert_post($dest_post);
1053 1053
 
1054 1054
 						// Make sure we register the.
1055
-						$this->current_destinations[ $day['destination_content_entity_id'] ] = $dest_id;
1055
+						$this->current_destinations[$day['destination_content_entity_id']] = $dest_id;
1056 1056
 
1057 1057
 						// If there are images attached then use the destination.
1058
-						if ( isset( $destination_data[0]['content']['images'] ) && ! empty( $destination_data[0]['content']['images'] ) ) {
1059
-							$this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] );
1058
+						if (isset($destination_data[0]['content']['images']) && !empty($destination_data[0]['content']['images'])) {
1059
+							$this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']);
1060 1060
 						}
1061 1061
 
1062
-						$this->save_custom_field( $day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id );
1062
+						$this->save_custom_field($day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id);
1063 1063
 					}
1064 1064
 				}
1065 1065
 			}
1066 1066
 
1067
-			if ( '' !== $dest_id && false !== $dest_id ) {
1068
-				$this->save_custom_field( $dest_id, 'destination_to_tour', $id, false, false );
1069
-				$this->save_custom_field( $id, 'tour_to_destination', $dest_id, false, false );
1067
+			if ('' !== $dest_id && false !== $dest_id) {
1068
+				$this->save_custom_field($dest_id, 'destination_to_tour', $id, false, false);
1069
+				$this->save_custom_field($id, 'tour_to_destination', $dest_id, false, false);
1070 1070
 
1071 1071
 				//Save the item to display in the queue
1072
-				$this->queue_item( $dest_id );
1072
+				$this->queue_item($dest_id);
1073 1073
 
1074 1074
 				//Save the item to clean up the amount of connections.
1075
-				$this->cleanup_posts[ $dest_id ] = 'tour_to_destination';
1075
+				$this->cleanup_posts[$dest_id] = 'tour_to_destination';
1076 1076
 
1077 1077
 				//Add this relation info so we can make sure certain items are set as countries.
1078
-				if ( 0 !== $country_id && false !== $country_id ) {
1079
-					$this->relation_meta[ $dest_id ] = $country_id;
1080
-					$this->relation_meta[ $country_id ] = 0;
1081
-				} else {
1082
-					$this->relation_meta[ $dest_id ] = 0;
1078
+				if (0 !== $country_id && false !== $country_id) {
1079
+					$this->relation_meta[$dest_id] = $country_id;
1080
+					$this->relation_meta[$country_id] = 0;
1081
+				}else {
1082
+					$this->relation_meta[$dest_id] = 0;
1083 1083
 				}
1084 1084
 			}
1085 1085
 		}
@@ -1095,25 +1095,25 @@  discard block
 block discarded – undo
1095 1095
 	 *
1096 1096
 	 * @return string
1097 1097
 	 */
1098
-	public function set_country( $country_wetu_id, $id ) {
1098
+	public function set_country($country_wetu_id, $id) {
1099 1099
 		$country_id = false;
1100 1100
 		$this->current_destinations = $this->find_current_destinations();
1101 1101
 
1102
-		if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $country_wetu_id, $this->current_destinations ) ) {
1103
-			$country_id = $this->current_destinations[ $country_wetu_id ];
1104
-			$this->destination_images[ $id ][] = array( $country_id, $country_wetu_id );
1105
-		} else {
1106
-			$country_json = file_get_contents( 'https://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $country_wetu_id );
1102
+		if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) {
1103
+			$country_id = $this->current_destinations[$country_wetu_id];
1104
+			$this->destination_images[$id][] = array($country_id, $country_wetu_id);
1105
+		}else {
1106
+			$country_json = file_get_contents('https://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$country_wetu_id);
1107 1107
 
1108
-			if ( $country_json ) {
1109
-				$country_data = json_decode( $country_json, true );
1108
+			if ($country_json) {
1109
+				$country_data = json_decode($country_json, true);
1110 1110
 
1111
-				if ( ! empty( $country_data ) && ! isset( $country_data['error'] ) ) {
1111
+				if (!empty($country_data) && !isset($country_data['error'])) {
1112 1112
 
1113 1113
 					//Format the title of the destination if its available,  otherwise default to the WETU ID.
1114 1114
 					$country_title = $country_wetu_id;
1115 1115
 
1116
-					if ( isset( $country_data[0]['name'] ) ) {
1116
+					if (isset($country_data[0]['name'])) {
1117 1117
 						$country_title = $country_data[0]['name'];
1118 1118
 					}
1119 1119
 
@@ -1124,24 +1124,24 @@  discard block
 block discarded – undo
1124 1124
 					));
1125 1125
 
1126 1126
 					//add the country to the current destination stack
1127
-					$this->current_destinations[ $country_wetu_id ] = $country_id;
1127
+					$this->current_destinations[$country_wetu_id] = $country_id;
1128 1128
 
1129 1129
 					// Check if there are images and save fore use later.
1130
-					if ( isset( $country_data[0]['content']['images'] ) && ! empty( $country_data[0]['content']['images'] ) ) {
1131
-						$this->destination_images[ $id ][] = array( $country_id,$country_wetu_id );
1130
+					if (isset($country_data[0]['content']['images']) && !empty($country_data[0]['content']['images'])) {
1131
+						$this->destination_images[$id][] = array($country_id, $country_wetu_id);
1132 1132
 					}
1133 1133
 
1134 1134
 					//Save the wetu field
1135
-					$this->save_custom_field( $country_wetu_id, 'lsx_wetu_id', $country_id );
1135
+					$this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id);
1136 1136
 				}
1137 1137
 			}
1138 1138
 		}
1139 1139
 
1140
-		if ( '' !== $country_id && false !== $country_id ) {
1141
-			$this->save_custom_field( $country_id, 'destination_to_tour', $id, false, false );
1142
-			$this->save_custom_field( $id, 'tour_to_destination', $country_id, false, false );
1143
-			$this->queue_item( $country_id );
1144
-			$this->cleanup_posts[ $country_id ] = 'tour_to_destination';
1140
+		if ('' !== $country_id && false !== $country_id) {
1141
+			$this->save_custom_field($country_id, 'destination_to_tour', $id, false, false);
1142
+			$this->save_custom_field($id, 'tour_to_destination', $country_id, false, false);
1143
+			$this->queue_item($country_id);
1144
+			$this->cleanup_posts[$country_id] = 'tour_to_destination';
1145 1145
 
1146 1146
 			return $country_id;
1147 1147
 		}
@@ -1156,44 +1156,44 @@  discard block
 block discarded – undo
1156 1156
 	 *
1157 1157
 	 * @return string
1158 1158
 	 */
1159
-	public function attach_destination_images( $importable_content = array() ) {
1160
-		if ( false !== $this->destination_images ) {
1161
-			$this->shuffle_assoc( $this->destination_images );
1159
+	public function attach_destination_images($importable_content = array()) {
1160
+		if (false !== $this->destination_images) {
1161
+			$this->shuffle_assoc($this->destination_images);
1162 1162
 
1163
-			foreach ( $this->destination_images as $tour => $destinations ) {
1163
+			foreach ($this->destination_images as $tour => $destinations) {
1164 1164
 				//$this->shuffle_assoc( $destinations );
1165 1165
 
1166 1166
 				$image_set = false;
1167 1167
 				$forced = false;
1168 1168
 
1169
-				foreach ( $destinations as $destination ) {
1170
-					if ( false === $image_set && false === $forced ) {
1171
-						$url = 'https://wetu.com/API/Pins/' . $this->api_key;
1169
+				foreach ($destinations as $destination) {
1170
+					if (false === $image_set && false === $forced) {
1171
+						$url = 'https://wetu.com/API/Pins/'.$this->api_key;
1172 1172
 						$url_qs = '';
1173 1173
 
1174
-						$jdata = file_get_contents( $url . '/Get?' . $url_qs . '&ids=' . $destination[1] );
1174
+						$jdata = file_get_contents($url.'/Get?'.$url_qs.'&ids='.$destination[1]);
1175 1175
 
1176
-						if ( $jdata ) {
1177
-							$adata = json_decode( $jdata, true );
1176
+						if ($jdata) {
1177
+							$adata = json_decode($jdata, true);
1178 1178
 
1179
-							if ( ! empty( $adata ) && ! empty( $adata[0]['content']['images'] ) ) {
1180
-								$this->find_attachments( $destination[0] );
1179
+							if (!empty($adata) && !empty($adata[0]['content']['images'])) {
1180
+								$this->find_attachments($destination[0]);
1181 1181
 
1182 1182
 								//Set the featured image
1183
-								if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) {
1184
-									$image_set = $this->set_featured_image( $adata, $tour );
1185
-									if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
1186
-										$image_set = $this->set_banner_image( $adata, $tour );
1183
+								if (false !== $importable_content && in_array('featured_image', $importable_content)) {
1184
+									$image_set = $this->set_featured_image($adata, $tour);
1185
+									if (false !== $importable_content && in_array('banner_image', $importable_content)) {
1186
+										$image_set = $this->set_banner_image($adata, $tour);
1187 1187
 										$forced = true;
1188 1188
 									}
1189 1189
 									continue;
1190 1190
 								}
1191
-								if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) {
1192
-									$image_set = $this->set_banner_image( $adata, $tour );
1191
+								if (false !== $importable_content && in_array('banner_image', $importable_content)) {
1192
+									$image_set = $this->set_banner_image($adata, $tour);
1193 1193
 								}
1194 1194
 							}
1195 1195
 						}
1196
-					} else {
1196
+					}else {
1197 1197
 						continue;
1198 1198
 					}
1199 1199
 				}
@@ -1204,28 +1204,28 @@  discard block
 block discarded – undo
1204 1204
 	/**
1205 1205
 	 * Creates the main gallery data
1206 1206
 	 */
1207
-	public function set_featured_image( $data, $id ) {
1207
+	public function set_featured_image($data, $id) {
1208 1208
 		$image_set = false;
1209 1209
 		$counter = 0;
1210 1210
 
1211
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
1212
-			foreach ( $data[0]['content']['images'] as $v ) {
1211
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
1212
+			foreach ($data[0]['content']['images'] as $v) {
1213 1213
 				/*print_r('<pre>');
1214 1214
 				print_r( $v );
1215 1215
 				print_r('</pre>');*/
1216 1216
 
1217
-				if ( true === $image_set ) {
1217
+				if (true === $image_set) {
1218 1218
 					$counter++;
1219 1219
 					continue;
1220 1220
 				}
1221 1221
 
1222
-				if ( ! $this->check_if_image_is_used( $v ) ) {
1223
-					$temp_featured_image = $this->attach_image( $v , $id );
1222
+				if (!$this->check_if_image_is_used($v)) {
1223
+					$temp_featured_image = $this->attach_image($v, $id);
1224 1224
 
1225
-					if ( false !== $temp_featured_image ) {
1225
+					if (false !== $temp_featured_image) {
1226 1226
 						$this->featured_image = $temp_featured_image;
1227
-						delete_post_meta( $id, '_thumbnail_id' );
1228
-						add_post_meta( $id, '_thumbnail_id', $this->featured_image, true );
1227
+						delete_post_meta($id, '_thumbnail_id');
1228
+						add_post_meta($id, '_thumbnail_id', $this->featured_image, true);
1229 1229
 						$image_set = true;
1230 1230
 					}
1231 1231
 				}
@@ -1239,40 +1239,40 @@  discard block
 block discarded – undo
1239 1239
 	/**
1240 1240
 	 * Sets a banner image
1241 1241
 	 */
1242
-	public function set_banner_image( $data, $id, $content = array( 'none' ) ) {
1242
+	public function set_banner_image($data, $id, $content = array('none')) {
1243 1243
 		$image_set = false;
1244 1244
 		$counter = 0;
1245 1245
 
1246
-		if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) {
1246
+		if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) {
1247 1247
 
1248
-			foreach ( $data[0]['content']['images'] as $v ) {
1248
+			foreach ($data[0]['content']['images'] as $v) {
1249 1249
 				/*print_r('<pre>');
1250 1250
 				print_r( $v );
1251 1251
 				print_r('</pre>');*/
1252 1252
 
1253
-				if ( true === $image_set || 0 === $counter ) {
1253
+				if (true === $image_set || 0 === $counter) {
1254 1254
 					$counter++;
1255 1255
 					continue;
1256 1256
 				}
1257 1257
 
1258
-				if ( ! $this->check_if_image_is_used( $v ) ) {
1259
-					$temp_banner = $this->attach_image( $v, $id, array(
1258
+				if (!$this->check_if_image_is_used($v)) {
1259
+					$temp_banner = $this->attach_image($v, $id, array(
1260 1260
 						'width' => '1920',
1261 1261
 						'height' => '600',
1262 1262
 						'cropping' => 'c',
1263
-					) );
1263
+					));
1264 1264
 
1265
-					if ( false !== $temp_banner ) {
1265
+					if (false !== $temp_banner) {
1266 1266
 						$this->banner_image = $temp_banner;
1267 1267
 
1268
-						delete_post_meta( $id,'image_group' );
1268
+						delete_post_meta($id, 'image_group');
1269 1269
 
1270 1270
 						$new_banner = array(
1271 1271
 							'banner_image' => array(
1272 1272
 								'cmb-field-0' => $this->banner_image,
1273 1273
 							),
1274 1274
 						);
1275
-						add_post_meta( $id,'image_group',$new_banner,true );
1275
+						add_post_meta($id, 'image_group', $new_banner, true);
1276 1276
 						$image_set = true;
1277 1277
 					}
1278 1278
 				}
@@ -1286,18 +1286,18 @@  discard block
 block discarded – undo
1286 1286
 	/**
1287 1287
 	 * Grabs all of the current used featured images on the site.
1288 1288
 	 */
1289
-	public function check_if_image_is_used( $v ) {
1289
+	public function check_if_image_is_used($v) {
1290 1290
 		global $wpdb;
1291 1291
 
1292
-		$temp_fragment = explode( '/',$v['url_fragment'] );
1293
-		$url_filename = $temp_fragment[ count( $temp_fragment ) -1 ];
1294
-		$url_filename = str_replace( array( '.jpg', '.png', '.jpeg' ),'',$url_filename );
1295
-		$url_filename = trim( $url_filename );
1296
-		$url_filename = str_replace( ' ','_',$url_filename );
1292
+		$temp_fragment = explode('/', $v['url_fragment']);
1293
+		$url_filename = $temp_fragment[count($temp_fragment) - 1];
1294
+		$url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename);
1295
+		$url_filename = trim($url_filename);
1296
+		$url_filename = str_replace(' ', '_', $url_filename);
1297 1297
 
1298
-		if ( in_array( $url_filename,$this->found_attachments ) ) {
1298
+		if (in_array($url_filename, $this->found_attachments)) {
1299 1299
 			//check to see if there is a featured image set with this ID.
1300
-			$found_id = array_search( $url_filename,$this->found_attachments );
1300
+			$found_id = array_search($url_filename, $this->found_attachments);
1301 1301
 
1302 1302
 			$querystring = "
1303 1303
 				SELECT      post_id
@@ -1306,22 +1306,22 @@  discard block
 block discarded – undo
1306 1306
 				AND 		meta_key = '_thumbnail_id'
1307 1307
 			";
1308 1308
 			// @codingStandardsIgnoreLine
1309
-			$results = $wpdb->get_results( $querystring );
1309
+			$results = $wpdb->get_results($querystring);
1310 1310
 
1311
-			if ( ! empty( $results ) ) {
1311
+			if (!empty($results)) {
1312 1312
 				return true;
1313
-			} else {
1313
+			}else {
1314 1314
 				return false;
1315 1315
 			}
1316
-		} else {
1316
+		}else {
1317 1317
 			$querystring = "
1318 1318
 				SELECT      ID
1319 1319
 				FROM        {$wpdb->posts}
1320 1320
 				WHERE       post_name = '{$url_filename}'
1321 1321
 			";
1322 1322
 			// @codingStandardsIgnoreLine
1323
-			$results = $wpdb->get_results( $querystring );
1324
-			if ( ! empty( $results ) ) {
1323
+			$results = $wpdb->get_results($querystring);
1324
+			if (!empty($results)) {
1325 1325
 				$querystring = "
1326 1326
 					SELECT      post_id
1327 1327
 					FROM        {$wpdb->postmeta}
@@ -1329,13 +1329,13 @@  discard block
 block discarded – undo
1329 1329
 					AND 		meta_key = '_thumbnail_id'
1330 1330
 				";
1331 1331
 				// @codingStandardsIgnoreLine
1332
-				$results = $wpdb->get_results( $querystring );
1333
-				if ( ! empty( $results ) ) {
1332
+				$results = $wpdb->get_results($querystring);
1333
+				if (!empty($results)) {
1334 1334
 					return true;
1335
-				} else {
1335
+				}else {
1336 1336
 					return false;
1337 1337
 				}
1338
-			} else {
1338
+			}else {
1339 1339
 				return false;
1340 1340
 			}
1341 1341
 		}
@@ -1346,10 +1346,10 @@  discard block
 block discarded – undo
1346 1346
 	 *
1347 1347
 	 * @param   $id     int
1348 1348
 	 */
1349
-	public function queue_item( $id ) {
1350
-		if ( is_array( $this->import_queue ) && ! in_array( $id,$this->import_queue ) ) {
1349
+	public function queue_item($id) {
1350
+		if (is_array($this->import_queue) && !in_array($id, $this->import_queue)) {
1351 1351
 			$this->import_queue[] = $id;
1352
-		} else {
1352
+		}else {
1353 1353
 			$this->import_queue[] = $id;
1354 1354
 		}
1355 1355
 	}
@@ -1358,18 +1358,18 @@  discard block
 block discarded – undo
1358 1358
 	 * Saves the queue to the option.
1359 1359
 	 */
1360 1360
 	public function save_queue() {
1361
-		if ( ! empty( $this->import_queue ) ) {
1362
-			if ( ! empty( $this->queued_imports ) ) {
1363
-				$saved_imports = array_merge( $this->queued_imports,$this->import_queue );
1364
-			} else {
1361
+		if (!empty($this->import_queue)) {
1362
+			if (!empty($this->queued_imports)) {
1363
+				$saved_imports = array_merge($this->queued_imports, $this->import_queue);
1364
+			}else {
1365 1365
 				$saved_imports = $this->import_queue;
1366 1366
 			}
1367 1367
 
1368
-			delete_option( 'wetu_importer_que' );
1368
+			delete_option('wetu_importer_que');
1369 1369
 
1370
-			if ( ! empty( $saved_imports ) ) {
1371
-				$saved_imports = array_unique( $saved_imports );
1372
-				update_option( 'wetu_importer_que',$saved_imports );
1370
+			if (!empty($saved_imports)) {
1371
+				$saved_imports = array_unique($saved_imports);
1372
+				update_option('wetu_importer_que', $saved_imports);
1373 1373
 			}
1374 1374
 		}
1375 1375
 	}
@@ -1382,13 +1382,13 @@  discard block
 block discarded – undo
1382 1382
 		<thead>
1383 1383
 		<tr>
1384 1384
 			<th style="" class="manage-column column-cb check-column" id="cb" scope="col">
1385
-				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'wetu-importer' ); ?></label>
1385
+				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'wetu-importer'); ?></label>
1386 1386
 				<input type="checkbox" id="cb-select-all-1">
1387 1387
 			</th>
1388
-			<th style="" class="manage-column column-title " id="title" style="width:50%;" scope="col"><?php esc_attr_e( 'Title', 'wetu-importer' ); ?></th>
1389
-			<th style="" class="manage-column column-date" id="ref" style="width:10%;" scope="col"><?php esc_attr_e( 'Ref', 'wetu-importer' ); ?></th>
1390
-			<th style="" class="manage-column column-date" id="date" scope="col"><?php esc_attr_e( 'Date', 'wetu-importer' ); ?></th>
1391
-			<th style="" class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'wetu-importer' ); ?></th>
1388
+			<th style="" class="manage-column column-title " id="title" style="width:50%;" scope="col"><?php esc_attr_e('Title', 'wetu-importer'); ?></th>
1389
+			<th style="" class="manage-column column-date" id="ref" style="width:10%;" scope="col"><?php esc_attr_e('Ref', 'wetu-importer'); ?></th>
1390
+			<th style="" class="manage-column column-date" id="date" scope="col"><?php esc_attr_e('Date', 'wetu-importer'); ?></th>
1391
+			<th style="" class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e('WETU ID', 'wetu-importer'); ?></th>
1392 1392
 		</tr>
1393 1393
 		</thead>
1394 1394
 		<?php
@@ -1402,13 +1402,13 @@  discard block
 block discarded – undo
1402 1402
 		<tfoot>
1403 1403
 		<tr>
1404 1404
 			<th style="" class="manage-column column-cb check-column" id="cb" scope="col">
1405
-				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'wetu-importer' ); ?></label>
1405
+				<label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'wetu-importer'); ?></label>
1406 1406
 				<input type="checkbox" id="cb-select-all-1">
1407 1407
 			</th>
1408
-			<th style="" class="manage-column column-title" scope="col"><?php esc_attr_e( 'Title', 'wetu-importer' ); ?></th>
1409
-			<th style="" class="manage-column column-date" id="ref" style="width:10%;" scope="col"><?php esc_attr_e( 'Ref', 'wetu-importer' ); ?></th>			
1410
-			<th style="" class="manage-column column-date" scope="col"><?php esc_attr_e( 'Date', 'wetu-importer' ); ?></th>
1411
-			<th style="" class="manage-column column-ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'wetu-importer' ); ?></th>
1408
+			<th style="" class="manage-column column-title" scope="col"><?php esc_attr_e('Title', 'wetu-importer'); ?></th>
1409
+			<th style="" class="manage-column column-date" id="ref" style="width:10%;" scope="col"><?php esc_attr_e('Ref', 'wetu-importer'); ?></th>			
1410
+			<th style="" class="manage-column column-date" scope="col"><?php esc_attr_e('Date', 'wetu-importer'); ?></th>
1411
+			<th style="" class="manage-column column-ssid" scope="col"><?php esc_attr_e('WETU ID', 'wetu-importer'); ?></th>
1412 1412
 		</tr>
1413 1413
 		</tfoot>
1414 1414
 		<?php
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -458,7 +458,7 @@
 block discarded – undo
458 458
 									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
459 459
 								} else if ( $this->multineedle_stripos( ltrim( rtrim( $row['reference_number'] ) ), $keywords ) !== false ) {
460 460
 									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
461
-								}else if ( $this->multineedle_stripos( ltrim( rtrim( $row['identifier_key'] ) ), $keywords ) !== false ) {
461
+								} else if ( $this->multineedle_stripos( ltrim( rtrim( $row['identifier_key'] ) ), $keywords ) !== false ) {
462 462
 									$searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row );
463 463
 								}
464 464
 
Please login to merge, or discard this patch.