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