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