@@ -82,20 +82,20 @@ discard block |
||
82 | 82 | public function __construct() { |
83 | 83 | $this->set_variables(); |
84 | 84 | |
85 | - add_action( 'lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this,'display_page') ); |
|
86 | - add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search')); |
|
87 | - add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search')); |
|
85 | + add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page')); |
|
86 | + add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
87 | + add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
88 | 88 | |
89 | - add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import')); |
|
90 | - add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import')); |
|
89 | + add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import')); |
|
90 | + add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import')); |
|
91 | 91 | |
92 | - $temp_options = get_option('_lsx-to_settings',false); |
|
93 | - if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){ |
|
92 | + $temp_options = get_option('_lsx-to_settings', false); |
|
93 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
94 | 94 | $this->options = $temp_options[$this->plugin_slug]; |
95 | 95 | } |
96 | 96 | |
97 | - $tour_options = get_option('wetu_importer_tour_settings',false); |
|
98 | - if(false !== $tour_options){ |
|
97 | + $tour_options = get_option('wetu_importer_tour_settings', false); |
|
98 | + if (false !== $tour_options) { |
|
99 | 99 | $this->tour_options = $tour_options; |
100 | 100 | } |
101 | 101 | } |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | { |
108 | 108 | parent::set_variables(); |
109 | 109 | |
110 | - if ( false !== $this->api_username && false !== $this->api_password ) { |
|
110 | + if (false !== $this->api_username && false !== $this->api_password) { |
|
111 | 111 | $this->url = 'https://wetu.com/API/Itinerary/'; |
112 | - $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
|
113 | - } elseif ( false !== $this->api_key ) { |
|
114 | - $this->url = 'https://wetu.com/API/Itinerary/' . $this->api_key; |
|
112 | + $this->url_qs = 'username='.$this->api_username.'&password='.$this->api_password; |
|
113 | + } elseif (false !== $this->api_key) { |
|
114 | + $this->url = 'https://wetu.com/API/Itinerary/'.$this->api_key; |
|
115 | 115 | $this->url_qs = ''; |
116 | 116 | } |
117 | 117 | } |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | <form method="get" action="" id="posts-filter"> |
132 | 132 | <input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" /> |
133 | 133 | |
134 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
135 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
134 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
135 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
136 | 136 | </p> |
137 | 137 | |
138 | 138 | <table class="wp-list-table widefat fixed posts"> |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | <tbody id="the-list"> |
142 | 142 | <tr class="post-0 type-tour status-none" id="post-0"> |
143 | 143 | <th class="check-column" scope="row"> |
144 | - <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label> |
|
144 | + <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label> |
|
145 | 145 | </th> |
146 | 146 | <td class="post-title page-title column-title"> |
147 | 147 | <strong> |
148 | - <?php _e('Enter a title to search for','wetu-importer'); ?> |
|
148 | + <?php _e('Enter a title to search for', 'wetu-importer'); ?> |
|
149 | 149 | </strong> |
150 | 150 | </td> |
151 | 151 | <td class="date column-date"> |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | |
160 | 160 | </table> |
161 | 161 | |
162 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
163 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
162 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
163 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
164 | 164 | </p> |
165 | 165 | </form> |
166 | 166 | |
@@ -172,36 +172,36 @@ discard block |
||
172 | 172 | <div style="width:30%;display:block;float:left;"> |
173 | 173 | <h3><?php _e('What content to Sync from WETU'); ?></h3> |
174 | 174 | <ul> |
175 | - <li><input class="content" <?php $this->checked($this->tour_options,'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
176 | - <li><input class="content" <?php $this->checked($this->tour_options,'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li> |
|
175 | + <li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
176 | + <li><input class="content" <?php $this->checked($this->tour_options, 'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li> |
|
177 | 177 | |
178 | - <li><input class="content" <?php $this->checked($this->tour_options,'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price','wetu-importer'); ?></li> |
|
179 | - <li><input class="content" <?php $this->checked($this->tour_options,'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration','wetu-importer'); ?></li> |
|
178 | + <li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price', 'wetu-importer'); ?></li> |
|
179 | + <li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration', 'wetu-importer'); ?></li> |
|
180 | 180 | |
181 | - <li><input class="content" <?php $this->checked($this->tour_options,'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li> |
|
181 | + <li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li> |
|
182 | 182 | |
183 | - <li><input class="content" <?php $this->checked($this->tour_options,'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days','wetu-importer'); ?></li> |
|
183 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days', 'wetu-importer'); ?></li> |
|
184 | 184 | |
185 | - <?php if(class_exists('TO_Maps')){ ?> |
|
186 | - <li><input class="content" <?php $this->checked($this->tour_options,'map'); ?> type="checkbox" name="content[]" value="map" /> <?php _e('Map Coordinates (generates a KML file)','wetu-importer'); ?></li> |
|
185 | + <?php if (class_exists('TO_Maps')) { ?> |
|
186 | + <li><input class="content" <?php $this->checked($this->tour_options, 'map'); ?> type="checkbox" name="content[]" value="map" /> <?php _e('Map Coordinates (generates a KML file)', 'wetu-importer'); ?></li> |
|
187 | 187 | <?php } ?> |
188 | 188 | </ul> |
189 | 189 | </div> |
190 | 190 | <div style="width:30%;display:block;float:left;"> |
191 | 191 | <h3><?php _e('Itinerary Info'); ?></h3> |
192 | 192 | <ul> |
193 | - <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
194 | - <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included','wetu-importer'); ?></li> |
|
195 | - <li><input class="content" <?php $this->checked($this->tour_options,'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded','wetu-importer'); ?></li> |
|
193 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
194 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php _e('Included', 'wetu-importer'); ?></li> |
|
195 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php _e('Excluded', 'wetu-importer'); ?></li> |
|
196 | 196 | </ul> |
197 | 197 | |
198 | 198 | <h4><?php _e('Additional Content'); ?></h4> |
199 | 199 | <ul> |
200 | - <li><input class="content" <?php $this->checked($this->tour_options,'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation','wetu-importer'); ?></li> |
|
201 | - <li><input class="content" <?php $this->checked($this->tour_options,'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations','wetu-importer'); ?></li> |
|
200 | + <li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation', 'wetu-importer'); ?></li> |
|
201 | + <li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations', 'wetu-importer'); ?></li> |
|
202 | 202 | </ul> |
203 | 203 | </div> |
204 | - <?php if(class_exists('TO_Team')){ ?> |
|
204 | + <?php if (class_exists('TO_Team')) { ?> |
|
205 | 205 | <div style="width:30%;display:block;float:left;"> |
206 | 206 | <h3><?php _e('Assign a Team Member'); ?></h3> |
207 | 207 | <?php $this->team_member_checkboxes($this->tour_options); ?> |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | |
215 | 215 | <h3><?php _e('Your List'); ?></h3> |
216 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
216 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
217 | 217 | <table class="wp-list-table widefat fixed posts"> |
218 | 218 | <?php $this->table_header(); ?> |
219 | 219 | |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | |
226 | 226 | </table> |
227 | 227 | |
228 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
228 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
229 | 229 | </form> |
230 | 230 | </div> |
231 | 231 | |
232 | 232 | <div style="display:none;" class="completed-list-wrapper"> |
233 | - <h3><?php _e('Completed','wetu-importer'); ?> - <small><?php _e('Import your','wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next','wetu-importer'); ?></small></h3> |
|
233 | + <h3><?php _e('Completed', 'wetu-importer'); ?> - <small><?php _e('Import your', 'wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation'); ?></a> <?php _e('next', 'wetu-importer'); ?></small></h3> |
|
234 | 234 | <ul> |
235 | 235 | </ul> |
236 | 236 | </div> |
@@ -243,17 +243,17 @@ discard block |
||
243 | 243 | */ |
244 | 244 | public function update_options_form() { |
245 | 245 | $tours = get_transient('lsx_ti_tours'); |
246 | - echo '<div class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').' - '; |
|
247 | - if('' === $tours || false === $tours || isset($_GET['refresh_tours'])){ |
|
246 | + echo '<div class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').' - '; |
|
247 | + if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) { |
|
248 | 248 | $result = $this->update_options(); |
249 | 249 | |
250 | - if(true === $result){ |
|
251 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
252 | - }else{ |
|
250 | + if (true === $result) { |
|
251 | + echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>'; |
|
252 | + }else { |
|
253 | 253 | echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
254 | 254 | } |
255 | - }else{ |
|
256 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
255 | + }else { |
|
256 | + echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>'; |
|
257 | 257 | } |
258 | 258 | echo '</h3></div>'; |
259 | 259 | } |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | * Save the list of Tours into an option |
263 | 263 | */ |
264 | 264 | public function update_options() { |
265 | - $data = file_get_contents( $this->url . '/V7/List?' . $this->url_qs . '&own=true&type=All' ); |
|
265 | + $data = file_get_contents($this->url.'/V7/List?'.$this->url_qs.'&own=true&type=All'); |
|
266 | 266 | $tours = json_decode($data, true); |
267 | 267 | |
268 | - if(isset($tours['error'])){ |
|
268 | + if (isset($tours['error'])) { |
|
269 | 269 | return $tours['error']; |
270 | 270 | }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
271 | - set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2); |
|
271 | + set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2); |
|
272 | 272 | return true; |
273 | 273 | } |
274 | 274 | } |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | |
293 | 293 | LIMIT 0,500 |
294 | 294 | "); |
295 | - if(null !== $current_tours && !empty($current_tours)){ |
|
296 | - foreach($current_tours as $tour){ |
|
295 | + if (null !== $current_tours && !empty($current_tours)) { |
|
296 | + foreach ($current_tours as $tour) { |
|
297 | 297 | $return[$tour->meta_value] = $tour; |
298 | 298 | } |
299 | 299 | } |
@@ -306,36 +306,36 @@ discard block |
||
306 | 306 | public function process_ajax_search() { |
307 | 307 | $return = false; |
308 | 308 | |
309 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug){ |
|
309 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) { |
|
310 | 310 | $tours = get_transient('lsx_ti_tours'); |
311 | - if ( false !== $tours) { |
|
311 | + if (false !== $tours) { |
|
312 | 312 | |
313 | 313 | $searched_items = false; |
314 | 314 | |
315 | - if(isset($_POST['keyword'] )) { |
|
315 | + if (isset($_POST['keyword'])) { |
|
316 | 316 | $keyphrases = $_POST['keyword']; |
317 | - }else{ |
|
317 | + }else { |
|
318 | 318 | $keyphrases = array(0); |
319 | 319 | } |
320 | 320 | |
321 | - if(!is_array($keyphrases)){ |
|
321 | + if (!is_array($keyphrases)) { |
|
322 | 322 | $keyphrases = array($keyphrases); |
323 | 323 | } |
324 | - foreach($keyphrases as &$keyword){ |
|
324 | + foreach ($keyphrases as &$keyword) { |
|
325 | 325 | $keyword = ltrim(rtrim($keyword)); |
326 | 326 | } |
327 | 327 | |
328 | 328 | $post_status = false; |
329 | - if(in_array('publish',$keyphrases)){ |
|
329 | + if (in_array('publish', $keyphrases)) { |
|
330 | 330 | $post_status = 'publish'; |
331 | 331 | } |
332 | - if(in_array('pending',$keyphrases)){ |
|
332 | + if (in_array('pending', $keyphrases)) { |
|
333 | 333 | $post_status = 'pending'; |
334 | 334 | } |
335 | - if(in_array('draft',$keyphrases)){ |
|
335 | + if (in_array('draft', $keyphrases)) { |
|
336 | 336 | $post_status = 'draft'; |
337 | 337 | } |
338 | - if(in_array('import',$keyphrases)){ |
|
338 | + if (in_array('import', $keyphrases)) { |
|
339 | 339 | $post_status = 'import'; |
340 | 340 | } |
341 | 341 | |
@@ -343,9 +343,9 @@ discard block |
||
343 | 343 | if (!empty($tours)) { |
344 | 344 | $current_tours = $this->find_current_tours(); |
345 | 345 | |
346 | - foreach($tours as $row_key => $row){ |
|
346 | + foreach ($tours as $row_key => $row) { |
|
347 | 347 | |
348 | - if(isset($row['is_disabled']) && true === $row['is_disabled']){ |
|
348 | + if (isset($row['is_disabled']) && true === $row['is_disabled']) { |
|
349 | 349 | continue; |
350 | 350 | } |
351 | 351 | |
@@ -355,29 +355,29 @@ discard block |
||
355 | 355 | |
356 | 356 | //If this is a current tour, add its ID to the row. |
357 | 357 | $row['post_id'] = 0; |
358 | - if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){ |
|
358 | + if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) { |
|
359 | 359 | $row['post_id'] = $current_tours[$row['identifier']]->post_id; |
360 | 360 | } |
361 | 361 | |
362 | 362 | //If we are searching for |
363 | - if(false !== $post_status){ |
|
363 | + if (false !== $post_status) { |
|
364 | 364 | |
365 | - if('import' === $post_status){ |
|
365 | + if ('import' === $post_status) { |
|
366 | 366 | |
367 | - if(0 !== $row['post_id']){ |
|
367 | + if (0 !== $row['post_id']) { |
|
368 | 368 | continue; |
369 | - }else{ |
|
369 | + }else { |
|
370 | 370 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
371 | 371 | } |
372 | 372 | |
373 | 373 | |
374 | - }else{ |
|
374 | + }else { |
|
375 | 375 | |
376 | - if(0 === $row['post_id']){ |
|
376 | + if (0 === $row['post_id']) { |
|
377 | 377 | continue; |
378 | - }else{ |
|
378 | + }else { |
|
379 | 379 | $current_status = get_post_status($row['post_id']); |
380 | - if($current_status !== $post_status){ |
|
380 | + if ($current_status !== $post_status) { |
|
381 | 381 | continue; |
382 | 382 | } |
383 | 383 | |
@@ -386,17 +386,17 @@ discard block |
||
386 | 386 | |
387 | 387 | } |
388 | 388 | |
389 | - }else{ |
|
389 | + }else { |
|
390 | 390 | //Search through each keyword. |
391 | - foreach($keyphrases as $keyphrase){ |
|
391 | + foreach ($keyphrases as $keyphrase) { |
|
392 | 392 | |
393 | 393 | //Make sure the keyphrase is turned into an array |
394 | - $keywords = explode(" ",$keyphrase); |
|
395 | - if(!is_array($keywords)){ |
|
394 | + $keywords = explode(" ", $keyphrase); |
|
395 | + if (!is_array($keywords)) { |
|
396 | 396 | $keywords = array($keywords); |
397 | 397 | } |
398 | 398 | |
399 | - if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){ |
|
399 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
400 | 400 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
401 | 401 | } |
402 | 402 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
407 | - if(false !== $searched_items){ |
|
407 | + if (false !== $searched_items) { |
|
408 | 408 | ksort($searched_items); |
409 | 409 | $return = implode($searched_items); |
410 | 410 | } |
@@ -417,11 +417,11 @@ discard block |
||
417 | 417 | /** |
418 | 418 | * Formats the row for output on the screen. |
419 | 419 | */ |
420 | - public function format_row($row = false){ |
|
421 | - if(false !== $row){ |
|
420 | + public function format_row($row = false) { |
|
421 | + if (false !== $row) { |
|
422 | 422 | |
423 | 423 | $status = 'import'; |
424 | - if(0 !== $row['post_id']){ |
|
424 | + if (0 !== $row['post_id']) { |
|
425 | 425 | $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
426 | 426 | } |
427 | 427 | |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | <strong>'.$row['name'].'</strong> - '.$status.' |
436 | 436 | </td> |
437 | 437 | <td class="date column-date"> |
438 | - <abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
438 | + <abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
439 | 439 | </td> |
440 | 440 | <td class="ssid column-ssid"> |
441 | 441 | '.$row['identifier'].' |
@@ -450,31 +450,31 @@ discard block |
||
450 | 450 | */ |
451 | 451 | public function process_ajax_import($force = false) { |
452 | 452 | $return = false; |
453 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])){ |
|
453 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) { |
|
454 | 454 | |
455 | 455 | $wetu_id = $_POST['wetu_id']; |
456 | - if(isset($_POST['post_id'])){ |
|
456 | + if (isset($_POST['post_id'])) { |
|
457 | 457 | $post_id = $_POST['post_id']; |
458 | - }else{ |
|
458 | + }else { |
|
459 | 459 | $post_id = 0; |
460 | 460 | } |
461 | 461 | |
462 | - if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
|
462 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
463 | 463 | $content = $_POST['content']; |
464 | - add_option('wetu_importer_tour_settings',$content); |
|
465 | - }else{ |
|
464 | + add_option('wetu_importer_tour_settings', $content); |
|
465 | + }else { |
|
466 | 466 | delete_option('wetu_importer_tour_settings'); |
467 | 467 | $content = false; |
468 | 468 | } |
469 | 469 | |
470 | - $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
470 | + $jdata = file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
471 | 471 | |
472 | - if($jdata) |
|
472 | + if ($jdata) |
|
473 | 473 | { |
474 | - $jdata=json_decode($jdata,true); |
|
475 | - if(!empty($jdata)) |
|
474 | + $jdata = json_decode($jdata, true); |
|
475 | + if (!empty($jdata)) |
|
476 | 476 | { |
477 | - $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
477 | + $return = $this->import_row($jdata, $wetu_id, $post_id, $content); |
|
478 | 478 | $this->format_completed_row($return); |
479 | 479 | } |
480 | 480 | } |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | * @param $data array |
490 | 490 | * @param $wetu_id string |
491 | 491 | */ |
492 | - public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) { |
|
492 | + public function import_row($data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false) { |
|
493 | 493 | $post_name = $data_post_content = $data_post_excerpt = ''; |
494 | 494 | $post = array( |
495 | 495 | 'post_type' => 'tour', |
@@ -497,29 +497,29 @@ discard block |
||
497 | 497 | |
498 | 498 | //Set the post_content |
499 | 499 | $content_used_general_description = false; |
500 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
500 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
501 | 501 | $data_post_content = ''; |
502 | 502 | |
503 | - if(isset($data['description'])){ |
|
503 | + if (isset($data['description'])) { |
|
504 | 504 | $data_post_content = $data['description']; |
505 | - }elseif(isset($data['summary'])){ |
|
505 | + }elseif (isset($data['summary'])) { |
|
506 | 506 | $data_post_content = $data['summary']; |
507 | 507 | } |
508 | 508 | $post['post_content'] = $data_post_content; |
509 | 509 | } |
510 | 510 | |
511 | 511 | //Create or update the post |
512 | - if(false !== $id && '0' !== $id){ |
|
512 | + if (false !== $id && '0' !== $id) { |
|
513 | 513 | $post['ID'] = $id; |
514 | 514 | $post['post_status'] = 'publish'; |
515 | 515 | $id = wp_update_post($post); |
516 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
517 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
518 | - }else{ |
|
516 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
517 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']), $prev_date); |
|
518 | + }else { |
|
519 | 519 | |
520 | 520 | //Set the name |
521 | - if(isset($data['name'])){ |
|
522 | - $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
521 | + if (isset($data['name'])) { |
|
522 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0); |
|
523 | 523 | } |
524 | 524 | $post['post_name'] = $post_name; |
525 | 525 | $post['post_title'] = $data['name']; |
@@ -527,51 +527,51 @@ discard block |
||
527 | 527 | $id = wp_insert_post($post); |
528 | 528 | |
529 | 529 | //Save the WETU ID and the Last date it was modified. |
530 | - if(false !== $id){ |
|
531 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
532 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
530 | + if (false !== $id) { |
|
531 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
532 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified'])); |
|
533 | 533 | } |
534 | 534 | } |
535 | 535 | |
536 | 536 | |
537 | 537 | //Set the price |
538 | - if(false !== $importable_content && in_array('price',$importable_content)){ |
|
539 | - $this->set_price($data,$id); |
|
538 | + if (false !== $importable_content && in_array('price', $importable_content)) { |
|
539 | + $this->set_price($data, $id); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | //Set the Duration |
543 | - if(false !== $importable_content && in_array('duration',$importable_content)){ |
|
544 | - $this->set_duration($data,$id); |
|
543 | + if (false !== $importable_content && in_array('duration', $importable_content)) { |
|
544 | + $this->set_duration($data, $id); |
|
545 | 545 | } |
546 | 546 | |
547 | - if(in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
548 | - $this->process_itineraries($data,$id,$importable_content); |
|
547 | + if (in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) { |
|
548 | + $this->process_itineraries($data, $id, $importable_content); |
|
549 | 549 | } |
550 | 550 | |
551 | - if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){ |
|
552 | - $this->process_map_points($data,$id); |
|
551 | + if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) { |
|
552 | + $this->process_map_points($data, $id); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | //TODO Test These |
556 | 556 | //Setup some default for use in the import |
557 | - if(false !== $importable_content && (in_array('itinerary_gallery',$importable_content) || in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
|
557 | + if (false !== $importable_content && (in_array('itinerary_gallery', $importable_content) || in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) { |
|
558 | 558 | $this->find_attachments($id); |
559 | 559 | } |
560 | 560 | //Set the featured image |
561 | 561 | //TODO Test These |
562 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
563 | - $this->set_featured_image($data,$id); |
|
562 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
563 | + $this->set_featured_image($data, $id); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | //TODO Test These |
567 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
568 | - $this->set_banner_image($data,$id); |
|
567 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
568 | + $this->set_banner_image($data, $id); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | //TODO Test These |
572 | 572 | //Import the main gallery |
573 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
574 | - $this->create_main_gallery($data,$id); |
|
573 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
574 | + $this->create_main_gallery($data, $id); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | return $id; |
@@ -580,151 +580,151 @@ discard block |
||
580 | 580 | /** |
581 | 581 | * A loop which runs through each leg on the tour. |
582 | 582 | */ |
583 | - public function process_itineraries($data,$id,$importable_content) { |
|
583 | + public function process_itineraries($data, $id, $importable_content) { |
|
584 | 584 | $day_counter = 1; |
585 | 585 | $leg_counter = 0; |
586 | 586 | |
587 | - delete_post_meta($id,'itinerary'); |
|
587 | + delete_post_meta($id, 'itinerary'); |
|
588 | 588 | |
589 | - if(false !== $importable_content && in_array('accommodation',$importable_content)){ |
|
590 | - delete_post_meta($id,'accommodation_to_tour'); |
|
589 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
590 | + delete_post_meta($id, 'accommodation_to_tour'); |
|
591 | 591 | } |
592 | - if(false !== $importable_content && in_array('destination',$importable_content)){ |
|
593 | - delete_post_meta($id,'destination_to_tour'); |
|
594 | - delete_post_meta($id,'departs_from'); |
|
595 | - delete_post_meta($id,'ends_in'); |
|
592 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
593 | + delete_post_meta($id, 'destination_to_tour'); |
|
594 | + delete_post_meta($id, 'departs_from'); |
|
595 | + delete_post_meta($id, 'ends_in'); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | $departs_from = false; |
599 | 599 | $ends_in = false; |
600 | 600 | |
601 | - foreach($data['legs'] as $leg){ |
|
601 | + foreach ($data['legs'] as $leg) { |
|
602 | 602 | |
603 | - if(isset($leg['days']) && !empty($leg['days'])){ |
|
603 | + if (isset($leg['days']) && !empty($leg['days'])) { |
|
604 | 604 | |
605 | 605 | //Itinerary Accommodation |
606 | 606 | $current_accommodation = false; |
607 | - if(false !== $importable_content && in_array('accommodation',$importable_content)){ |
|
608 | - $current_accommodation = $this->set_accommodation($leg,$id); |
|
607 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
608 | + $current_accommodation = $this->set_accommodation($leg, $id); |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | //Itinerary Destination |
612 | 612 | $current_destination = false; |
613 | - if(false !== $importable_content && in_array('destination',$importable_content)){ |
|
614 | - $current_destination = $this->set_destination($leg,$id); |
|
613 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
614 | + $current_destination = $this->set_destination($leg, $id); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | //If the Nights are the same mount of days in the array, then it isnt "By Destination" |
618 | - if($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']){ |
|
618 | + if ($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']) { |
|
619 | 619 | |
620 | - foreach($leg['days'] as $day){ |
|
620 | + foreach ($leg['days'] as $day) { |
|
621 | 621 | |
622 | 622 | $current_day = array(); |
623 | 623 | |
624 | - $current_day['title'] = esc_attr('Day ','wetu-importer').$day_counter; |
|
624 | + $current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter; |
|
625 | 625 | |
626 | 626 | //print_r('<pre>');print_r($day['notes']);print_r('</pre>'); |
627 | 627 | |
628 | 628 | //Description |
629 | - if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){ |
|
629 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) { |
|
630 | 630 | $current_day['description'] = $day['notes']; |
631 | - }else{ |
|
631 | + }else { |
|
632 | 632 | $current_day['description'] = ''; |
633 | 633 | } |
634 | 634 | |
635 | 635 | //Itinerary Gallery |
636 | - if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){ |
|
636 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) { |
|
637 | 637 | $current_day['featured_image'] = ''; |
638 | - }else{ |
|
638 | + }else { |
|
639 | 639 | $current_day['featured_image'] = ''; |
640 | 640 | } |
641 | 641 | |
642 | 642 | //Accommodation |
643 | - if(false !== $current_accommodation){ |
|
643 | + if (false !== $current_accommodation) { |
|
644 | 644 | $current_day['accommodation_to_tour'] = array($current_accommodation); |
645 | - }else{ |
|
645 | + }else { |
|
646 | 646 | $current_day['accommodation_to_tour'] = array(); |
647 | 647 | } |
648 | 648 | |
649 | 649 | //Destination |
650 | - if(false !== $current_destination){ |
|
650 | + if (false !== $current_destination) { |
|
651 | 651 | $current_day['destination_to_tour'] = array($current_destination); |
652 | - }else{ |
|
652 | + }else { |
|
653 | 653 | $current_day['destination_to_tour'] = array(); |
654 | 654 | } |
655 | 655 | |
656 | 656 | //Included |
657 | - if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){ |
|
657 | + if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) { |
|
658 | 658 | $current_day['included'] = $day['included']; |
659 | - }else{ |
|
659 | + }else { |
|
660 | 660 | $current_day['included'] = ''; |
661 | 661 | } |
662 | 662 | |
663 | 663 | //Excluded |
664 | - if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){ |
|
664 | + if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) { |
|
665 | 665 | $current_day['excluded'] = $day['excluded']; |
666 | - }else{ |
|
666 | + }else { |
|
667 | 667 | $current_day['excluded'] = ''; |
668 | 668 | } |
669 | 669 | |
670 | - $this->set_itinerary_day($current_day,$id); |
|
670 | + $this->set_itinerary_day($current_day, $id); |
|
671 | 671 | $day_counter++; |
672 | 672 | } |
673 | 673 | |
674 | - }else{ |
|
675 | - $day_counter = $day_counter + (int)$leg['nights']; |
|
674 | + }else { |
|
675 | + $day_counter = $day_counter + (int) $leg['nights']; |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | } |
679 | 679 | |
680 | 680 | //If we are in the first leg, and the destination was attached then save it as the departure field. |
681 | - if( 0 === $leg_counter && false !== $current_destination){ |
|
681 | + if (0 === $leg_counter && false !== $current_destination) { |
|
682 | 682 | $departs_from = $current_destination; |
683 | 683 | } |
684 | 684 | |
685 | 685 | //If its the last leg then save it as the ends in. |
686 | - if( $leg_counter === (count($data['legs'])-2) && false !== $current_destination){ |
|
686 | + if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) { |
|
687 | 687 | $ends_in = $current_destination; |
688 | 688 | } |
689 | 689 | $leg_counter++; |
690 | 690 | } |
691 | 691 | |
692 | - if(false !== $departs_from){ |
|
693 | - add_post_meta($id,'departs_from',$departs_from,true); |
|
692 | + if (false !== $departs_from) { |
|
693 | + add_post_meta($id, 'departs_from', $departs_from, true); |
|
694 | 694 | } |
695 | - if(false !== $ends_in){ |
|
696 | - add_post_meta($id,'ends_in',$ends_in,true); |
|
695 | + if (false !== $ends_in) { |
|
696 | + add_post_meta($id, 'ends_in', $ends_in, true); |
|
697 | 697 | } |
698 | 698 | } |
699 | 699 | |
700 | 700 | /** |
701 | 701 | * Run through your routes and save the points as a KML file. |
702 | 702 | */ |
703 | - public function process_map_points($data,$id) { |
|
703 | + public function process_map_points($data, $id) { |
|
704 | 704 | |
705 | - if(!empty($data['routes'])){ |
|
705 | + if (!empty($data['routes'])) { |
|
706 | 706 | |
707 | - delete_post_meta($id,'wetu_map_points'); |
|
707 | + delete_post_meta($id, 'wetu_map_points'); |
|
708 | 708 | |
709 | 709 | $points = array(); |
710 | 710 | |
711 | - foreach($data['routes'] as $route){ |
|
711 | + foreach ($data['routes'] as $route) { |
|
712 | 712 | |
713 | 713 | |
714 | - if(isset($route['points']) && '' !== $route['points']){ |
|
714 | + if (isset($route['points']) && '' !== $route['points']) { |
|
715 | 715 | |
716 | - $temp_points = explode(';',$route['points']); |
|
716 | + $temp_points = explode(';', $route['points']); |
|
717 | 717 | $point_counter = count($temp_points); |
718 | 718 | |
719 | 719 | for ($x = 0; $x <= $point_counter; $x++) { |
720 | - $y = $x+1; |
|
720 | + $y = $x + 1; |
|
721 | 721 | $points[] = $temp_points[$x].','.$temp_points[$y]; |
722 | 722 | $x++; |
723 | 723 | } |
724 | 724 | } |
725 | 725 | } |
726 | - if(!empty($points)){ |
|
727 | - $this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true); |
|
726 | + if (!empty($points)) { |
|
727 | + $this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true); |
|
728 | 728 | } |
729 | 729 | } |
730 | 730 | |
@@ -733,28 +733,28 @@ discard block |
||
733 | 733 | /** |
734 | 734 | * Set the Itinerary Day |
735 | 735 | */ |
736 | - public function set_itinerary_day($day,$id) { |
|
737 | - $this->save_custom_field($day,'itinerary',$id,false,false); |
|
736 | + public function set_itinerary_day($day, $id) { |
|
737 | + $this->save_custom_field($day, 'itinerary', $id, false, false); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | /** |
741 | 741 | * Set the price |
742 | 742 | */ |
743 | - public function set_price($data,$id) { |
|
743 | + public function set_price($data, $id) { |
|
744 | 744 | //Price |
745 | - if(isset($data['price']) && ''!== $data['price']){ |
|
745 | + if (isset($data['price']) && '' !== $data['price']) { |
|
746 | 746 | $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
747 | - $this->save_custom_field($price,'price',$id); |
|
747 | + $this->save_custom_field($price, 'price', $id); |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | //Price includes |
751 | - if(isset($data['price_includes']) && ''!== $data['price_includes']){ |
|
752 | - $this->save_custom_field($data['price_includes'],'included',$id); |
|
751 | + if (isset($data['price_includes']) && '' !== $data['price_includes']) { |
|
752 | + $this->save_custom_field($data['price_includes'], 'included', $id); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | //Price Excludes |
756 | - if(isset($data['price_excludes']) && ''!== $data['price_excludes']){ |
|
757 | - $this->save_custom_field($data['price_excludes'],'not_included',$id); |
|
756 | + if (isset($data['price_excludes']) && '' !== $data['price_excludes']) { |
|
757 | + $this->save_custom_field($data['price_excludes'], 'not_included', $id); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | } |
@@ -762,11 +762,11 @@ discard block |
||
762 | 762 | /** |
763 | 763 | * Set the duration |
764 | 764 | */ |
765 | - public function set_duration($data,$id) { |
|
766 | - if(isset($data['days']) && !empty($data['days'])){ |
|
765 | + public function set_duration($data, $id) { |
|
766 | + if (isset($data['days']) && !empty($data['days'])) { |
|
767 | 767 | $price = $data['days']; |
768 | 768 | $price = preg_replace("/[^0-9,.]/", "", $price); |
769 | - $this->save_custom_field($price,'duration',$id); |
|
769 | + $this->save_custom_field($price, 'duration', $id); |
|
770 | 770 | } |
771 | 771 | } |
772 | 772 | |
@@ -774,27 +774,27 @@ discard block |
||
774 | 774 | /** |
775 | 775 | * Connects the Accommodation if its available |
776 | 776 | */ |
777 | - public function set_accommodation($day,$id) { |
|
777 | + public function set_accommodation($day, $id) { |
|
778 | 778 | |
779 | 779 | $ac_id = false; |
780 | 780 | $this->current_accommodation = $this->find_current_accommodation(); |
781 | 781 | |
782 | - if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){ |
|
782 | + if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) { |
|
783 | 783 | |
784 | - if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
|
784 | + if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) { |
|
785 | 785 | $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
786 | - }else{ |
|
786 | + }else { |
|
787 | 787 | $ac_id = wp_insert_post(array( |
788 | 788 | 'post_type' => 'accommodation', |
789 | 789 | 'post_status' => 'draft', |
790 | 790 | 'post_title' => $day['content_entity_id'] |
791 | 791 | )); |
792 | - $this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id); |
|
792 | + $this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id); |
|
793 | 793 | } |
794 | 794 | |
795 | - if('' !== $ac_id && false !== $ac_id){ |
|
796 | - $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
797 | - $this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false); |
|
795 | + if ('' !== $ac_id && false !== $ac_id) { |
|
796 | + $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false); |
|
797 | + $this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false); |
|
798 | 798 | } |
799 | 799 | } |
800 | 800 | return $ac_id; |
@@ -806,13 +806,13 @@ discard block |
||
806 | 806 | * @param $post_type string |
807 | 807 | * @return boolean / array |
808 | 808 | */ |
809 | - public function find_current_accommodation($post_type='accommodation') { |
|
809 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
810 | 810 | global $wpdb; |
811 | 811 | $accommodation = parent::find_current_accommodation($post_type); |
812 | 812 | |
813 | 813 | $return = false; |
814 | - if(!empty($accommodation)){ |
|
815 | - foreach($accommodation as $key => $acc){ |
|
814 | + if (!empty($accommodation)) { |
|
815 | + foreach ($accommodation as $key => $acc) { |
|
816 | 816 | $return[$acc->meta_value] = $acc->post_id; |
817 | 817 | } |
818 | 818 | } |
@@ -834,25 +834,25 @@ discard block |
||
834 | 834 | * @param $id string |
835 | 835 | * @return boolean / string |
836 | 836 | */ |
837 | - public function set_destination($day,$id) { |
|
837 | + public function set_destination($day, $id) { |
|
838 | 838 | $dest_id = false; |
839 | 839 | $country_id = false; |
840 | 840 | $this->current_destinations = $this->find_current_destinations(); |
841 | 841 | |
842 | - if(isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])){ |
|
842 | + if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) { |
|
843 | 843 | |
844 | - if(false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'],$this->current_destinations)){ |
|
844 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) { |
|
845 | 845 | $dest_id = $this->current_destinations[$day['destination_content_entity_id']]; |
846 | 846 | |
847 | 847 | $potential_id = wp_get_post_parent_id($dest_id); |
848 | - $country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true); |
|
849 | - if(false !== $country_wetu_id){ |
|
848 | + $country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true); |
|
849 | + if (false !== $country_wetu_id) { |
|
850 | 850 | $this->set_country($country_wetu_id, $id); |
851 | 851 | } |
852 | 852 | |
853 | 853 | }else { |
854 | 854 | |
855 | - $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']); |
|
855 | + $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$day['destination_content_entity_id']); |
|
856 | 856 | |
857 | 857 | if ($destination_json) { |
858 | 858 | $destination_data = json_decode($destination_json, true); |
@@ -861,12 +861,12 @@ discard block |
||
861 | 861 | |
862 | 862 | $destination_title = $day['destination_content_entity_id']; |
863 | 863 | |
864 | - if(isset($destination_data[0]['name'])){ |
|
864 | + if (isset($destination_data[0]['name'])) { |
|
865 | 865 | $destination_title = $destination_data[0]['name']; |
866 | 866 | } |
867 | 867 | |
868 | - if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
869 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
868 | + if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
869 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) { |
|
870 | 870 | |
871 | 871 | $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
872 | 872 | } |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | 'post_title' => $destination_title |
878 | 878 | ); |
879 | 879 | |
880 | - if(false !== $country_id){ |
|
880 | + if (false !== $country_id) { |
|
881 | 881 | $dest_post['post_parent'] = $country_id; |
882 | 882 | } |
883 | 883 | $dest_id = wp_insert_post($dest_post); |
@@ -910,9 +910,9 @@ discard block |
||
910 | 910 | |
911 | 911 | if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
912 | 912 | $country_id = $this->current_destinations[$country_wetu_id]; |
913 | - } else { |
|
913 | + }else { |
|
914 | 914 | |
915 | - $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
915 | + $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$country_wetu_id); |
|
916 | 916 | |
917 | 917 | if ($country_json) { |
918 | 918 | $country_data = json_decode($country_json, true); |
@@ -249,10 +249,10 @@ discard block |
||
249 | 249 | |
250 | 250 | if(true === $result){ |
251 | 251 | echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
252 | - }else{ |
|
252 | + } else{ |
|
253 | 253 | echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
254 | 254 | } |
255 | - }else{ |
|
255 | + } else{ |
|
256 | 256 | echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
257 | 257 | } |
258 | 258 | echo '</h3></div>'; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | |
268 | 268 | if(isset($tours['error'])){ |
269 | 269 | return $tours['error']; |
270 | - }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
270 | + } elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
271 | 271 | set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2); |
272 | 272 | return true; |
273 | 273 | } |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | |
315 | 315 | if(isset($_POST['keyword'] )) { |
316 | 316 | $keyphrases = $_POST['keyword']; |
317 | - }else{ |
|
317 | + } else{ |
|
318 | 318 | $keyphrases = array(0); |
319 | 319 | } |
320 | 320 | |
@@ -366,16 +366,16 @@ discard block |
||
366 | 366 | |
367 | 367 | if(0 !== $row['post_id']){ |
368 | 368 | continue; |
369 | - }else{ |
|
369 | + } else{ |
|
370 | 370 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
371 | 371 | } |
372 | 372 | |
373 | 373 | |
374 | - }else{ |
|
374 | + } else{ |
|
375 | 375 | |
376 | 376 | if(0 === $row['post_id']){ |
377 | 377 | continue; |
378 | - }else{ |
|
378 | + } else{ |
|
379 | 379 | $current_status = get_post_status($row['post_id']); |
380 | 380 | if($current_status !== $post_status){ |
381 | 381 | continue; |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | |
387 | 387 | } |
388 | 388 | |
389 | - }else{ |
|
389 | + } else{ |
|
390 | 390 | //Search through each keyword. |
391 | 391 | foreach($keyphrases as $keyphrase){ |
392 | 392 | |
@@ -455,14 +455,14 @@ discard block |
||
455 | 455 | $wetu_id = $_POST['wetu_id']; |
456 | 456 | if(isset($_POST['post_id'])){ |
457 | 457 | $post_id = $_POST['post_id']; |
458 | - }else{ |
|
458 | + } else{ |
|
459 | 459 | $post_id = 0; |
460 | 460 | } |
461 | 461 | |
462 | 462 | if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
463 | 463 | $content = $_POST['content']; |
464 | 464 | add_option('wetu_importer_tour_settings',$content); |
465 | - }else{ |
|
465 | + } else{ |
|
466 | 466 | delete_option('wetu_importer_tour_settings'); |
467 | 467 | $content = false; |
468 | 468 | } |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | |
503 | 503 | if(isset($data['description'])){ |
504 | 504 | $data_post_content = $data['description']; |
505 | - }elseif(isset($data['summary'])){ |
|
505 | + } elseif(isset($data['summary'])){ |
|
506 | 506 | $data_post_content = $data['summary']; |
507 | 507 | } |
508 | 508 | $post['post_content'] = $data_post_content; |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | $id = wp_update_post($post); |
516 | 516 | $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
517 | 517 | update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
518 | - }else{ |
|
518 | + } else{ |
|
519 | 519 | |
520 | 520 | //Set the name |
521 | 521 | if(isset($data['name'])){ |
@@ -628,42 +628,42 @@ discard block |
||
628 | 628 | //Description |
629 | 629 | if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){ |
630 | 630 | $current_day['description'] = $day['notes']; |
631 | - }else{ |
|
631 | + } else{ |
|
632 | 632 | $current_day['description'] = ''; |
633 | 633 | } |
634 | 634 | |
635 | 635 | //Itinerary Gallery |
636 | 636 | if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){ |
637 | 637 | $current_day['featured_image'] = ''; |
638 | - }else{ |
|
638 | + } else{ |
|
639 | 639 | $current_day['featured_image'] = ''; |
640 | 640 | } |
641 | 641 | |
642 | 642 | //Accommodation |
643 | 643 | if(false !== $current_accommodation){ |
644 | 644 | $current_day['accommodation_to_tour'] = array($current_accommodation); |
645 | - }else{ |
|
645 | + } else{ |
|
646 | 646 | $current_day['accommodation_to_tour'] = array(); |
647 | 647 | } |
648 | 648 | |
649 | 649 | //Destination |
650 | 650 | if(false !== $current_destination){ |
651 | 651 | $current_day['destination_to_tour'] = array($current_destination); |
652 | - }else{ |
|
652 | + } else{ |
|
653 | 653 | $current_day['destination_to_tour'] = array(); |
654 | 654 | } |
655 | 655 | |
656 | 656 | //Included |
657 | 657 | if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){ |
658 | 658 | $current_day['included'] = $day['included']; |
659 | - }else{ |
|
659 | + } else{ |
|
660 | 660 | $current_day['included'] = ''; |
661 | 661 | } |
662 | 662 | |
663 | 663 | //Excluded |
664 | 664 | if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){ |
665 | 665 | $current_day['excluded'] = $day['excluded']; |
666 | - }else{ |
|
666 | + } else{ |
|
667 | 667 | $current_day['excluded'] = ''; |
668 | 668 | } |
669 | 669 | |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | $day_counter++; |
672 | 672 | } |
673 | 673 | |
674 | - }else{ |
|
674 | + } else{ |
|
675 | 675 | $day_counter = $day_counter + (int)$leg['nights']; |
676 | 676 | } |
677 | 677 | |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | |
784 | 784 | if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
785 | 785 | $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
786 | - }else{ |
|
786 | + } else{ |
|
787 | 787 | $ac_id = wp_insert_post(array( |
788 | 788 | 'post_type' => 'accommodation', |
789 | 789 | 'post_status' => 'draft', |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | $this->set_country($country_wetu_id, $id); |
851 | 851 | } |
852 | 852 | |
853 | - }else { |
|
853 | + } else { |
|
854 | 854 | |
855 | 855 | $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']); |
856 | 856 |