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