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