@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function __construct() { |
92 | 92 | $this->set_variables(); |
93 | - add_action('wetu_importer_search_form',array($this,'tour_search_options'),10); |
|
93 | + add_action('wetu_importer_search_form', array($this, 'tour_search_options'), 10); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -100,21 +100,21 @@ discard block |
||
100 | 100 | { |
101 | 101 | parent::set_variables(); |
102 | 102 | |
103 | - if ( false !== $this->api_username && false !== $this->api_password ) { |
|
103 | + if (false !== $this->api_username && false !== $this->api_password) { |
|
104 | 104 | $this->url = 'https://wetu.com/API/Itinerary/'; |
105 | - $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
|
106 | - } elseif ( false !== $this->api_key ) { |
|
107 | - $this->url = 'https://wetu.com/API/Itinerary/' . $this->api_key; |
|
105 | + $this->url_qs = 'username='.$this->api_username.'&password='.$this->api_password; |
|
106 | + } elseif (false !== $this->api_key) { |
|
107 | + $this->url = 'https://wetu.com/API/Itinerary/'.$this->api_key; |
|
108 | 108 | $this->url_qs = ''; |
109 | 109 | } |
110 | 110 | |
111 | - $temp_options = get_option('_lsx-to_settings',false); |
|
112 | - if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){ |
|
111 | + $temp_options = get_option('_lsx-to_settings', false); |
|
112 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
113 | 113 | $this->options = $temp_options[$this->plugin_slug]; |
114 | 114 | } |
115 | 115 | |
116 | - $tour_options = get_option('wetu_importer_tour_settings',false); |
|
117 | - if(false !== $tour_options){ |
|
116 | + $tour_options = get_option('wetu_importer_tour_settings', false); |
|
117 | + if (false !== $tour_options) { |
|
118 | 118 | $this->tour_options = $tour_options; |
119 | 119 | } |
120 | 120 | } |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | <form method="get" action="" id="posts-filter"> |
135 | 135 | <input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" /> |
136 | 136 | |
137 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
138 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
137 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
138 | + <input class="button button-primary clear" type="button" value="<?php _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 |
||
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 _e('Enter a title to search for and press enter','wetu-importer'); ?></label> |
|
147 | + <label for="cb-select-0" class="screen-reader-text"><?php _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 _e('Enter a title to search for','wetu-importer'); ?> |
|
151 | + <?php _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 |
||
162 | 162 | |
163 | 163 | </table> |
164 | 164 | |
165 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
166 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
165 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
166 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
167 | 167 | </p> |
168 | 168 | </form> |
169 | 169 | |
@@ -175,16 +175,16 @@ discard block |
||
175 | 175 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
176 | 176 | <h3><?php _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 _e('Select All','wetu-importer'); ?></li> |
|
179 | - <li><input class="content" <?php $this->checked($this->tour_options,'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
180 | - <li><input class="content" <?php $this->checked($this->tour_options,'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li> |
|
178 | + <li><input class="content select-all" <?php $this->checked($this->tour_options, 'all'); ?> type="checkbox"name="content[]" value="all" /> <?php _e('Select All', 'wetu-importer'); ?></li> |
|
179 | + <li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
180 | + <li><input class="content" <?php $this->checked($this->tour_options, 'excerpt'); ?> type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li> |
|
181 | 181 | |
182 | - <li><input class="content" <?php $this->checked($this->tour_options,'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price','wetu-importer'); ?></li> |
|
183 | - <li><input class="content" <?php $this->checked($this->tour_options,'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration','wetu-importer'); ?></li> |
|
182 | + <li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php _e('Price', 'wetu-importer'); ?></li> |
|
183 | + <li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php _e('Duration', 'wetu-importer'); ?></li> |
|
184 | 184 | |
185 | - <li><input class="content" <?php $this->checked($this->tour_options,'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li> |
|
185 | + <li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li> |
|
186 | 186 | |
187 | - <li><input class="content" <?php $this->checked($this->tour_options,'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days','wetu-importer'); ?></li> |
|
187 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php _e('Itinerary Days', 'wetu-importer'); ?></li> |
|
188 | 188 | |
189 | 189 | <?php /*if(class_exists('LSX_TO_Maps')){ ?> |
190 | 190 | <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> |
@@ -194,20 +194,20 @@ discard block |
||
194 | 194 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
195 | 195 | <h3><?php _e('Itinerary Info'); ?></h3> |
196 | 196 | <ul> |
197 | - <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> |
|
198 | - <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> |
|
199 | - <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> |
|
197 | + <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> |
|
198 | + <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> |
|
199 | + <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> |
|
200 | 200 | </ul> |
201 | 201 | |
202 | 202 | <h4><?php _e('Additional Content'); ?></h4> |
203 | 203 | <ul> |
204 | - <li><input class="content" <?php $this->checked($this->tour_options,'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation','wetu-importer'); ?></li> |
|
205 | - <li><input class="content" <?php $this->checked($this->tour_options,'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations','wetu-importer'); ?></li> |
|
206 | - <li><input class="content" <?php $this->checked($this->tour_options,'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php _e('Featured Image','wetu-importer'); ?></li> |
|
207 | - <li><input class="content" <?php $this->checked($this->tour_options,'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php _e('Banner Image','wetu-importer'); ?></li> |
|
204 | + <li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php _e('Sync Accommodation', 'wetu-importer'); ?></li> |
|
205 | + <li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php _e('Sync Destinations', 'wetu-importer'); ?></li> |
|
206 | + <li><input class="content" <?php $this->checked($this->tour_options, 'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php _e('Featured Image', 'wetu-importer'); ?></li> |
|
207 | + <li><input class="content" <?php $this->checked($this->tour_options, 'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php _e('Banner Image', 'wetu-importer'); ?></li> |
|
208 | 208 | </ul> |
209 | 209 | </div> |
210 | - <?php if(class_exists('LSX_TO_Team')){ ?> |
|
210 | + <?php if (class_exists('LSX_TO_Team')) { ?> |
|
211 | 211 | <div style="width:30%;display:block;float:left;"> |
212 | 212 | <h3><?php _e('Assign a Team Member'); ?></h3> |
213 | 213 | <?php $this->team_member_checkboxes($this->tour_options); ?> |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | |
220 | 220 | |
221 | 221 | <h3><?php _e('Your List'); ?></h3> |
222 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
222 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
223 | 223 | <table class="wp-list-table widefat fixed posts"> |
224 | 224 | <?php $this->table_header(); ?> |
225 | 225 | |
@@ -231,12 +231,12 @@ discard block |
||
231 | 231 | |
232 | 232 | </table> |
233 | 233 | |
234 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
234 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
235 | 235 | </form> |
236 | 236 | </div> |
237 | 237 | |
238 | 238 | <div style="display:none;" class="completed-list-wrapper"> |
239 | - <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> |
|
239 | + <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> |
|
240 | 240 | <ul> |
241 | 241 | </ul> |
242 | 242 | </div> |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | public function tour_search_options() { |
251 | 251 | ?> |
252 | 252 | <p class="tour-search-options"> |
253 | - <label for="type"><input class="content" checked type="radio" name="type[]" value="all" /> <?php _e('All','wetu-importer'); ?></label> |
|
254 | - <label for="type"><input class="content" type="radio" name="type[]" value="sample" /> <?php _e('Sample','wetu-importer'); ?></label> |
|
255 | - <label for="type"><input class="content" type="radio" name="type[]" value="personal" /> <?php _e('Personal','wetu-importer'); ?></label> |
|
253 | + <label for="type"><input class="content" checked type="radio" name="type[]" value="all" /> <?php _e('All', 'wetu-importer'); ?></label> |
|
254 | + <label for="type"><input class="content" type="radio" name="type[]" value="sample" /> <?php _e('Sample', 'wetu-importer'); ?></label> |
|
255 | + <label for="type"><input class="content" type="radio" name="type[]" value="personal" /> <?php _e('Personal', 'wetu-importer'); ?></label> |
|
256 | 256 | </p> |
257 | 257 | <?php |
258 | 258 | } |
@@ -262,20 +262,20 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public function update_options_form() { |
264 | 264 | $tours = get_transient('lsx_ti_tours'); |
265 | - echo '<div class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').' - '; |
|
266 | - if('' === $tours || false === $tours || isset($_GET['refresh_tours'])){ |
|
265 | + echo '<div class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').' - '; |
|
266 | + if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) { |
|
267 | 267 | $result = $this->update_options(); |
268 | 268 | |
269 | - if(true === $result){ |
|
270 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span>'; |
|
271 | - if(!isset($_GET['refresh_tours'])){ |
|
272 | - echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
269 | + if (true === $result) { |
|
270 | + echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>'; |
|
271 | + if (!isset($_GET['refresh_tours'])) { |
|
272 | + echo ' - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh', 'wetu-importer').'</a></small>'; |
|
273 | 273 | } |
274 | - }else{ |
|
274 | + }else { |
|
275 | 275 | echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
276 | 276 | } |
277 | - }else{ |
|
278 | - echo '<span style="color:green;">'.esc_attr('Connected','wetu-importer').'</span> - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh','wetu-importer').'</a></small>'; |
|
277 | + }else { |
|
278 | + echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span> - <small><a href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab=tour&refresh_tours=true">'.esc_attr('Refresh', 'wetu-importer').'</a></small>'; |
|
279 | 279 | } |
280 | 280 | echo '</h3></div>'; |
281 | 281 | } |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | * Save the list of Tours into an option |
285 | 285 | */ |
286 | 286 | public function update_options() { |
287 | - $data = file_get_contents( $this->url . '/V7/List?' . $this->url_qs . '&own=true&type=All' ); |
|
287 | + $data = file_get_contents($this->url.'/V7/List?'.$this->url_qs.'&own=true&type=All'); |
|
288 | 288 | $tours = json_decode($data, true); |
289 | 289 | |
290 | - if(isset($tours['error'])){ |
|
290 | + if (isset($tours['error'])) { |
|
291 | 291 | return $tours['error']; |
292 | 292 | }elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
293 | - set_transient('lsx_ti_tours',$tours['itineraries'],60*60*2); |
|
293 | + set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2); |
|
294 | 294 | return true; |
295 | 295 | } |
296 | 296 | } |
@@ -314,8 +314,8 @@ discard block |
||
314 | 314 | |
315 | 315 | LIMIT 0,500 |
316 | 316 | "); |
317 | - if(null !== $current_tours && !empty($current_tours)){ |
|
318 | - foreach($current_tours as $tour){ |
|
317 | + if (null !== $current_tours && !empty($current_tours)) { |
|
318 | + foreach ($current_tours as $tour) { |
|
319 | 319 | $return[$tour->meta_value] = $tour; |
320 | 320 | } |
321 | 321 | } |
@@ -328,38 +328,38 @@ discard block |
||
328 | 328 | public function process_ajax_search() { |
329 | 329 | $return = false; |
330 | 330 | |
331 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug){ |
|
331 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) { |
|
332 | 332 | |
333 | 333 | |
334 | 334 | $tours = get_transient('lsx_ti_tours'); |
335 | - if ( false !== $tours) { |
|
335 | + if (false !== $tours) { |
|
336 | 336 | |
337 | 337 | $searched_items = false; |
338 | 338 | |
339 | - if(isset($_POST['keyword'] )) { |
|
339 | + if (isset($_POST['keyword'])) { |
|
340 | 340 | $keyphrases = $_POST['keyword']; |
341 | - }else{ |
|
341 | + }else { |
|
342 | 342 | $keyphrases = array(0); |
343 | 343 | } |
344 | 344 | |
345 | - if(!is_array($keyphrases)){ |
|
345 | + if (!is_array($keyphrases)) { |
|
346 | 346 | $keyphrases = array($keyphrases); |
347 | 347 | } |
348 | - foreach($keyphrases as &$keyword){ |
|
348 | + foreach ($keyphrases as &$keyword) { |
|
349 | 349 | $keyword = ltrim(rtrim($keyword)); |
350 | 350 | } |
351 | 351 | |
352 | 352 | $post_status = false; |
353 | - if(in_array('publish',$keyphrases)){ |
|
353 | + if (in_array('publish', $keyphrases)) { |
|
354 | 354 | $post_status = 'publish'; |
355 | 355 | } |
356 | - if(in_array('pending',$keyphrases)){ |
|
356 | + if (in_array('pending', $keyphrases)) { |
|
357 | 357 | $post_status = 'pending'; |
358 | 358 | } |
359 | - if(in_array('draft',$keyphrases)){ |
|
359 | + if (in_array('draft', $keyphrases)) { |
|
360 | 360 | $post_status = 'draft'; |
361 | 361 | } |
362 | - if(in_array('import',$keyphrases)){ |
|
362 | + if (in_array('import', $keyphrases)) { |
|
363 | 363 | $post_status = 'import'; |
364 | 364 | } |
365 | 365 | |
@@ -367,9 +367,9 @@ discard block |
||
367 | 367 | if (!empty($tours)) { |
368 | 368 | $current_tours = $this->find_current_tours(); |
369 | 369 | |
370 | - foreach($tours as $row_key => $row){ |
|
370 | + foreach ($tours as $row_key => $row) { |
|
371 | 371 | |
372 | - if(isset($row['is_disabled']) && true === $row['is_disabled']){ |
|
372 | + if (isset($row['is_disabled']) && true === $row['is_disabled']) { |
|
373 | 373 | continue; |
374 | 374 | } |
375 | 375 | |
@@ -379,29 +379,29 @@ discard block |
||
379 | 379 | |
380 | 380 | //If this is a current tour, add its ID to the row. |
381 | 381 | $row['post_id'] = 0; |
382 | - if(false !== $current_tours && array_key_exists($row['identifier'], $current_tours)){ |
|
382 | + if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) { |
|
383 | 383 | $row['post_id'] = $current_tours[$row['identifier']]->post_id; |
384 | 384 | } |
385 | 385 | |
386 | 386 | //If we are searching for |
387 | - if(false !== $post_status){ |
|
387 | + if (false !== $post_status) { |
|
388 | 388 | |
389 | - if('import' === $post_status){ |
|
389 | + if ('import' === $post_status) { |
|
390 | 390 | |
391 | - if(0 !== $row['post_id']){ |
|
391 | + if (0 !== $row['post_id']) { |
|
392 | 392 | continue; |
393 | - }else{ |
|
393 | + }else { |
|
394 | 394 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
395 | 395 | } |
396 | 396 | |
397 | 397 | |
398 | - }else{ |
|
398 | + }else { |
|
399 | 399 | |
400 | - if(0 === $row['post_id']){ |
|
400 | + if (0 === $row['post_id']) { |
|
401 | 401 | continue; |
402 | - }else{ |
|
402 | + }else { |
|
403 | 403 | $current_status = get_post_status($row['post_id']); |
404 | - if($current_status !== $post_status){ |
|
404 | + if ($current_status !== $post_status) { |
|
405 | 405 | continue; |
406 | 406 | } |
407 | 407 | |
@@ -410,17 +410,17 @@ discard block |
||
410 | 410 | |
411 | 411 | } |
412 | 412 | |
413 | - }else{ |
|
413 | + }else { |
|
414 | 414 | //Search through each keyword. |
415 | - foreach($keyphrases as $keyphrase){ |
|
415 | + foreach ($keyphrases as $keyphrase) { |
|
416 | 416 | |
417 | 417 | //Make sure the keyphrase is turned into an array |
418 | - $keywords = explode(" ",$keyphrase); |
|
419 | - if(!is_array($keywords)){ |
|
418 | + $keywords = explode(" ", $keyphrase); |
|
419 | + if (!is_array($keywords)) { |
|
420 | 420 | $keywords = array($keywords); |
421 | 421 | } |
422 | 422 | |
423 | - if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){ |
|
423 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
424 | 424 | $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
425 | 425 | } |
426 | 426 | } |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | } |
429 | 429 | } |
430 | 430 | |
431 | - if(false !== $searched_items){ |
|
431 | + if (false !== $searched_items) { |
|
432 | 432 | ksort($searched_items); |
433 | 433 | $return = implode($searched_items); |
434 | 434 | } |
@@ -441,11 +441,11 @@ discard block |
||
441 | 441 | /** |
442 | 442 | * Formats the row for output on the screen. |
443 | 443 | */ |
444 | - public function format_row($row = false){ |
|
445 | - if(false !== $row){ |
|
444 | + public function format_row($row = false) { |
|
445 | + if (false !== $row) { |
|
446 | 446 | |
447 | 447 | $status = 'import'; |
448 | - if(0 !== $row['post_id']){ |
|
448 | + if (0 !== $row['post_id']) { |
|
449 | 449 | $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
450 | 450 | } |
451 | 451 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | <strong>'.$row['name'].'</strong> - '.$status.' |
460 | 460 | </td> |
461 | 461 | <td class="date column-date"> |
462 | - <abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
462 | + <abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
463 | 463 | </td> |
464 | 464 | <td class="ssid column-ssid"> |
465 | 465 | '.$row['identifier'].' |
@@ -475,31 +475,31 @@ discard block |
||
475 | 475 | public function process_ajax_import($force = false) { |
476 | 476 | $return = false; |
477 | 477 | |
478 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])){ |
|
478 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) { |
|
479 | 479 | |
480 | 480 | $wetu_id = $_POST['wetu_id']; |
481 | - if(isset($_POST['post_id'])){ |
|
481 | + if (isset($_POST['post_id'])) { |
|
482 | 482 | $post_id = $_POST['post_id']; |
483 | - }else{ |
|
483 | + }else { |
|
484 | 484 | $post_id = 0; |
485 | 485 | } |
486 | 486 | |
487 | 487 | delete_option('wetu_importer_tour_settings'); |
488 | - if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
|
488 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
489 | 489 | $content = $_POST['content']; |
490 | - add_option('wetu_importer_tour_settings',$content); |
|
491 | - }else{ |
|
490 | + add_option('wetu_importer_tour_settings', $content); |
|
491 | + }else { |
|
492 | 492 | $content = false; |
493 | 493 | } |
494 | 494 | |
495 | - $jdata=file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
495 | + $jdata = file_get_contents("http://wetu.com/API/Itinerary/V7/Get?id=".$wetu_id); |
|
496 | 496 | |
497 | - if($jdata) |
|
497 | + if ($jdata) |
|
498 | 498 | { |
499 | - $jdata=json_decode($jdata,true); |
|
500 | - if(!empty($jdata)) |
|
499 | + $jdata = json_decode($jdata, true); |
|
500 | + if (!empty($jdata)) |
|
501 | 501 | { |
502 | - $return = $this->import_row($jdata,$wetu_id,$post_id,$content); |
|
502 | + $return = $this->import_row($jdata, $wetu_id, $post_id, $content); |
|
503 | 503 | $this->format_completed_row($return); |
504 | 504 | $this->cleanup_posts(); |
505 | 505 | $this->attach_destination_images($content); |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | * @param $data array |
515 | 515 | * @param $wetu_id string |
516 | 516 | */ |
517 | - public function import_row($data,$wetu_id,$id=0,$importable_content=false,$old1=false,$old2=false) { |
|
517 | + public function import_row($data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false) { |
|
518 | 518 | $post_name = $data_post_content = $data_post_excerpt = ''; |
519 | 519 | $post = array( |
520 | 520 | 'post_type' => 'tour', |
@@ -522,29 +522,29 @@ discard block |
||
522 | 522 | |
523 | 523 | //Set the post_content |
524 | 524 | $content_used_general_description = false; |
525 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
525 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
526 | 526 | $data_post_content = ''; |
527 | 527 | |
528 | - if(isset($data['description'])){ |
|
528 | + if (isset($data['description'])) { |
|
529 | 529 | $data_post_content = $data['description']; |
530 | - }elseif(isset($data['summary'])){ |
|
530 | + }elseif (isset($data['summary'])) { |
|
531 | 531 | $data_post_content = $data['summary']; |
532 | 532 | } |
533 | 533 | $post['post_content'] = $data_post_content; |
534 | 534 | } |
535 | 535 | |
536 | 536 | //Create or update the post |
537 | - if(false !== $id && '0' !== $id){ |
|
537 | + if (false !== $id && '0' !== $id) { |
|
538 | 538 | $post['ID'] = $id; |
539 | 539 | $post['post_status'] = 'publish'; |
540 | 540 | $id = wp_update_post($post); |
541 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
542 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified']),$prev_date); |
|
543 | - }else{ |
|
541 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
542 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']), $prev_date); |
|
543 | + }else { |
|
544 | 544 | |
545 | 545 | //Set the name |
546 | - if(isset($data['name'])){ |
|
547 | - $post_name = wp_unique_post_slug(sanitize_title($data['name']),$id, 'draft', 'tour', 0); |
|
546 | + if (isset($data['name'])) { |
|
547 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0); |
|
548 | 548 | } |
549 | 549 | $post['post_name'] = $post_name; |
550 | 550 | $post['post_title'] = $data['name']; |
@@ -552,29 +552,29 @@ discard block |
||
552 | 552 | $id = wp_insert_post($post); |
553 | 553 | |
554 | 554 | //Save the WETU ID and the Last date it was modified. |
555 | - if(false !== $id){ |
|
556 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
557 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data['last_modified'])); |
|
555 | + if (false !== $id) { |
|
556 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
557 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified'])); |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
561 | 561 | |
562 | 562 | //Set the price |
563 | - if(false !== $importable_content && in_array('price',$importable_content)){ |
|
564 | - $this->set_price($data,$id); |
|
563 | + if (false !== $importable_content && in_array('price', $importable_content)) { |
|
564 | + $this->set_price($data, $id); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | //Set the Duration |
568 | - if(false !== $importable_content && in_array('duration',$importable_content)){ |
|
569 | - $this->set_duration($data,$id); |
|
568 | + if (false !== $importable_content && in_array('duration', $importable_content)) { |
|
569 | + $this->set_duration($data, $id); |
|
570 | 570 | } |
571 | 571 | |
572 | - if(false !== $importable_content && in_array('itineraries',$importable_content) && isset($data['legs']) && !empty($data['legs'])){ |
|
573 | - $this->process_itineraries($data,$id,$importable_content); |
|
572 | + if (false !== $importable_content && in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) { |
|
573 | + $this->process_itineraries($data, $id, $importable_content); |
|
574 | 574 | } |
575 | 575 | |
576 | - if(in_array('map',$importable_content) && isset($data['routes']) && !empty($data['routes'])){ |
|
577 | - $this->set_map_data($data,$id); |
|
576 | + if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) { |
|
577 | + $this->set_map_data($data, $id); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | return $id; |
@@ -583,151 +583,151 @@ discard block |
||
583 | 583 | /** |
584 | 584 | * A loop which runs through each leg on the tour. |
585 | 585 | */ |
586 | - public function process_itineraries($data,$id,$importable_content) { |
|
586 | + public function process_itineraries($data, $id, $importable_content) { |
|
587 | 587 | $day_counter = 1; |
588 | 588 | $leg_counter = 0; |
589 | 589 | |
590 | - delete_post_meta($id,'itinerary'); |
|
590 | + delete_post_meta($id, 'itinerary'); |
|
591 | 591 | |
592 | - if(false !== $importable_content && in_array('accommodation',$importable_content)){ |
|
593 | - delete_post_meta($id,'accommodation_to_tour'); |
|
592 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
593 | + delete_post_meta($id, 'accommodation_to_tour'); |
|
594 | 594 | } |
595 | - if(false !== $importable_content && in_array('destination',$importable_content)){ |
|
596 | - delete_post_meta($id,'destination_to_tour'); |
|
597 | - delete_post_meta($id,'departs_from'); |
|
598 | - delete_post_meta($id,'ends_in'); |
|
595 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
596 | + delete_post_meta($id, 'destination_to_tour'); |
|
597 | + delete_post_meta($id, 'departs_from'); |
|
598 | + delete_post_meta($id, 'ends_in'); |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | $departs_from = false; |
602 | 602 | $ends_in = false; |
603 | 603 | |
604 | - foreach($data['legs'] as $leg){ |
|
604 | + foreach ($data['legs'] as $leg) { |
|
605 | 605 | |
606 | - if(isset($leg['days']) && !empty($leg['days'])){ |
|
606 | + if (isset($leg['days']) && !empty($leg['days'])) { |
|
607 | 607 | |
608 | 608 | //Itinerary Accommodation |
609 | 609 | $current_accommodation = false; |
610 | - if(false !== $importable_content && in_array('accommodation',$importable_content)){ |
|
611 | - $current_accommodation = $this->set_accommodation($leg,$id); |
|
610 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
611 | + $current_accommodation = $this->set_accommodation($leg, $id); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | //Itinerary Destination |
615 | 615 | $current_destination = false; |
616 | - if(false !== $importable_content && in_array('destination',$importable_content)){ |
|
617 | - $current_destination = $this->set_destination($leg,$id,$leg_counter); |
|
616 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
617 | + $current_destination = $this->set_destination($leg, $id, $leg_counter); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | //If the Nights are the same mount of days in the array, then it isnt "By Destination" |
621 | - if($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']){ |
|
621 | + if ($leg['nights'] === count($leg['days']) || 0 === $leg['itinerary_leg_id']) { |
|
622 | 622 | |
623 | - foreach($leg['days'] as $day){ |
|
623 | + foreach ($leg['days'] as $day) { |
|
624 | 624 | |
625 | 625 | $current_day = array(); |
626 | 626 | |
627 | - $current_day['title'] = esc_attr('Day ','wetu-importer').$day_counter; |
|
627 | + $current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter; |
|
628 | 628 | |
629 | 629 | //print_r('<pre>');print_r($day['notes']);print_r('</pre>'); |
630 | 630 | |
631 | 631 | //Description |
632 | - if(false !== $importable_content && in_array('itinerary_description',$importable_content) && isset($day['notes'])){ |
|
632 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) { |
|
633 | 633 | $current_day['description'] = $day['notes']; |
634 | - }else{ |
|
634 | + }else { |
|
635 | 635 | $current_day['description'] = ''; |
636 | 636 | } |
637 | 637 | |
638 | 638 | //Itinerary Gallery |
639 | - if(false !== $importable_content && in_array('itinerary_gallery',$importable_content) && isset($day['images'])){ |
|
639 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) { |
|
640 | 640 | $current_day['featured_image'] = ''; |
641 | - }else{ |
|
641 | + }else { |
|
642 | 642 | $current_day['featured_image'] = ''; |
643 | 643 | } |
644 | 644 | |
645 | 645 | //Accommodation |
646 | - if(false !== $current_accommodation){ |
|
646 | + if (false !== $current_accommodation) { |
|
647 | 647 | $current_day['accommodation_to_tour'] = array($current_accommodation); |
648 | - }else{ |
|
648 | + }else { |
|
649 | 649 | $current_day['accommodation_to_tour'] = array(); |
650 | 650 | } |
651 | 651 | |
652 | 652 | //Destination |
653 | - if(false !== $current_destination){ |
|
653 | + if (false !== $current_destination) { |
|
654 | 654 | $current_day['destination_to_tour'] = array($current_destination); |
655 | - }else{ |
|
655 | + }else { |
|
656 | 656 | $current_day['destination_to_tour'] = array(); |
657 | 657 | } |
658 | 658 | |
659 | 659 | //Included |
660 | - if(false !== $importable_content && in_array('itinerary_included',$importable_content) && isset($day['included']) && '' !== $day['included']){ |
|
660 | + if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) { |
|
661 | 661 | $current_day['included'] = $day['included']; |
662 | - }else{ |
|
662 | + }else { |
|
663 | 663 | $current_day['included'] = ''; |
664 | 664 | } |
665 | 665 | |
666 | 666 | //Excluded |
667 | - if(false !== $importable_content && in_array('itinerary_excluded',$importable_content) && isset($day['excluded']) && '' !== $day['excluded']){ |
|
667 | + if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) { |
|
668 | 668 | $current_day['excluded'] = $day['excluded']; |
669 | - }else{ |
|
669 | + }else { |
|
670 | 670 | $current_day['excluded'] = ''; |
671 | 671 | } |
672 | 672 | |
673 | - $this->set_itinerary_day($current_day,$id); |
|
673 | + $this->set_itinerary_day($current_day, $id); |
|
674 | 674 | $day_counter++; |
675 | 675 | } |
676 | 676 | |
677 | - }else{ |
|
678 | - $day_counter = $day_counter + (int)$leg['nights']; |
|
677 | + }else { |
|
678 | + $day_counter = $day_counter + (int) $leg['nights']; |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | } |
682 | 682 | |
683 | 683 | //If we are in the first leg, and the destination was attached then save it as the departure field. |
684 | - if( 0 === $leg_counter && false !== $current_destination){ |
|
684 | + if (0 === $leg_counter && false !== $current_destination) { |
|
685 | 685 | $departs_from = $current_destination; |
686 | 686 | } |
687 | 687 | |
688 | 688 | //If its the last leg then save it as the ends in. |
689 | - if( $leg_counter === (count($data['legs'])-2) && false !== $current_destination){ |
|
689 | + if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) { |
|
690 | 690 | $ends_in = $current_destination; |
691 | 691 | } |
692 | 692 | $leg_counter++; |
693 | 693 | } |
694 | 694 | |
695 | - if(false !== $departs_from){ |
|
696 | - add_post_meta($id,'departs_from',$departs_from,true); |
|
695 | + if (false !== $departs_from) { |
|
696 | + add_post_meta($id, 'departs_from', $departs_from, true); |
|
697 | 697 | } |
698 | - if(false !== $ends_in){ |
|
699 | - add_post_meta($id,'ends_in',$ends_in,true); |
|
698 | + if (false !== $ends_in) { |
|
699 | + add_post_meta($id, 'ends_in', $ends_in, true); |
|
700 | 700 | } |
701 | 701 | } |
702 | 702 | |
703 | 703 | /** |
704 | 704 | * Run through your routes and save the points as a KML file. |
705 | 705 | */ |
706 | - public function set_map_data($data,$id,$zoom=9) { |
|
706 | + public function set_map_data($data, $id, $zoom = 9) { |
|
707 | 707 | |
708 | - if(!empty($data['routes'])){ |
|
708 | + if (!empty($data['routes'])) { |
|
709 | 709 | |
710 | - delete_post_meta($id,'wetu_map_points'); |
|
710 | + delete_post_meta($id, 'wetu_map_points'); |
|
711 | 711 | |
712 | 712 | $points = array(); |
713 | 713 | |
714 | - foreach($data['routes'] as $route){ |
|
714 | + foreach ($data['routes'] as $route) { |
|
715 | 715 | |
716 | 716 | |
717 | - if(isset($route['points']) && '' !== $route['points']){ |
|
717 | + if (isset($route['points']) && '' !== $route['points']) { |
|
718 | 718 | |
719 | - $temp_points = explode(';',$route['points']); |
|
719 | + $temp_points = explode(';', $route['points']); |
|
720 | 720 | $point_counter = count($temp_points); |
721 | 721 | |
722 | 722 | for ($x = 0; $x <= $point_counter; $x++) { |
723 | - $y = $x+1; |
|
723 | + $y = $x + 1; |
|
724 | 724 | $points[] = $temp_points[$x].','.$temp_points[$y]; |
725 | 725 | $x++; |
726 | 726 | } |
727 | 727 | } |
728 | 728 | } |
729 | - if(!empty($points)){ |
|
730 | - $this->save_custom_field(implode(' ',$points),'wetu_map_points',$id,false,true); |
|
729 | + if (!empty($points)) { |
|
730 | + $this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true); |
|
731 | 731 | } |
732 | 732 | } |
733 | 733 | |
@@ -738,28 +738,28 @@ discard block |
||
738 | 738 | /** |
739 | 739 | * Set the Itinerary Day |
740 | 740 | */ |
741 | - public function set_itinerary_day($day,$id) { |
|
742 | - $this->save_custom_field($day,'itinerary',$id,false,false); |
|
741 | + public function set_itinerary_day($day, $id) { |
|
742 | + $this->save_custom_field($day, 'itinerary', $id, false, false); |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | /** |
746 | 746 | * Set the price |
747 | 747 | */ |
748 | - public function set_price($data,$id) { |
|
748 | + public function set_price($data, $id) { |
|
749 | 749 | //Price |
750 | - if(isset($data['price']) && ''!== $data['price']){ |
|
750 | + if (isset($data['price']) && '' !== $data['price']) { |
|
751 | 751 | $price = preg_replace("/[^0-9,.]/", "", $data['price']); |
752 | - $this->save_custom_field($price,'price',$id); |
|
752 | + $this->save_custom_field($price, 'price', $id); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | //Price includes |
756 | - if(isset($data['price_includes']) && ''!== $data['price_includes']){ |
|
757 | - $this->save_custom_field($data['price_includes'],'included',$id); |
|
756 | + if (isset($data['price_includes']) && '' !== $data['price_includes']) { |
|
757 | + $this->save_custom_field($data['price_includes'], 'included', $id); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | //Price Excludes |
761 | - if(isset($data['price_excludes']) && ''!== $data['price_excludes']){ |
|
762 | - $this->save_custom_field($data['price_excludes'],'not_included',$id); |
|
761 | + if (isset($data['price_excludes']) && '' !== $data['price_excludes']) { |
|
762 | + $this->save_custom_field($data['price_excludes'], 'not_included', $id); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | } |
@@ -767,38 +767,38 @@ discard block |
||
767 | 767 | /** |
768 | 768 | * Set the duration |
769 | 769 | */ |
770 | - public function set_duration($data,$id) { |
|
771 | - if(isset($data['days']) && !empty($data['days'])){ |
|
770 | + public function set_duration($data, $id) { |
|
771 | + if (isset($data['days']) && !empty($data['days'])) { |
|
772 | 772 | $price = $data['days']; |
773 | 773 | $price = preg_replace("/[^0-9,.]/", "", $price); |
774 | - $this->save_custom_field($price,'duration',$id); |
|
774 | + $this->save_custom_field($price, 'duration', $id); |
|
775 | 775 | } |
776 | 776 | } |
777 | 777 | |
778 | 778 | /** |
779 | 779 | * Connects the Accommodation if its available |
780 | 780 | */ |
781 | - public function set_accommodation($day,$id) { |
|
781 | + public function set_accommodation($day, $id) { |
|
782 | 782 | |
783 | 783 | $ac_id = false; |
784 | 784 | $this->current_accommodation = $this->find_current_accommodation(); |
785 | 785 | |
786 | - if(isset($day['content_entity_id']) && !empty($day['content_entity_id'])){ |
|
786 | + if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) { |
|
787 | 787 | |
788 | - if(false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'],$this->current_accommodation)){ |
|
788 | + if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) { |
|
789 | 789 | $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
790 | - }else{ |
|
790 | + }else { |
|
791 | 791 | $ac_id = wp_insert_post(array( |
792 | 792 | 'post_type' => 'accommodation', |
793 | 793 | 'post_status' => 'draft', |
794 | 794 | 'post_title' => $day['content_entity_id'] |
795 | 795 | )); |
796 | - $this->save_custom_field($day['content_entity_id'],'lsx_wetu_id',$ac_id); |
|
796 | + $this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id); |
|
797 | 797 | } |
798 | 798 | |
799 | - if('' !== $ac_id && false !== $ac_id){ |
|
800 | - $this->save_custom_field($ac_id,'accommodation_to_tour',$id,false,false); |
|
801 | - $this->save_custom_field($id,'tour_to_accommodation',$ac_id,false,false); |
|
799 | + if ('' !== $ac_id && false !== $ac_id) { |
|
800 | + $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false); |
|
801 | + $this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false); |
|
802 | 802 | } |
803 | 803 | } |
804 | 804 | return $ac_id; |
@@ -810,13 +810,13 @@ discard block |
||
810 | 810 | * @param $post_type string |
811 | 811 | * @return boolean / array |
812 | 812 | */ |
813 | - public function find_current_accommodation($post_type='accommodation') { |
|
813 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
814 | 814 | global $wpdb; |
815 | 815 | $accommodation = parent::find_current_accommodation($post_type); |
816 | 816 | |
817 | 817 | $return = false; |
818 | - if(!empty($accommodation)){ |
|
819 | - foreach($accommodation as $key => $acc){ |
|
818 | + if (!empty($accommodation)) { |
|
819 | + foreach ($accommodation as $key => $acc) { |
|
820 | 820 | $return[$acc->meta_value] = $acc->post_id; |
821 | 821 | } |
822 | 822 | } |
@@ -838,26 +838,26 @@ discard block |
||
838 | 838 | * @param $id string |
839 | 839 | * @return boolean / string |
840 | 840 | */ |
841 | - public function set_destination($day,$id,$leg_counter) { |
|
841 | + public function set_destination($day, $id, $leg_counter) { |
|
842 | 842 | $dest_id = false; |
843 | 843 | $country_id = false; |
844 | 844 | $this->current_destinations = $this->find_current_destinations(); |
845 | 845 | |
846 | - if(isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])){ |
|
846 | + if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) { |
|
847 | 847 | |
848 | - if(false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'],$this->current_destinations)){ |
|
848 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) { |
|
849 | 849 | $dest_id = $this->current_destinations[$day['destination_content_entity_id']]; |
850 | 850 | |
851 | 851 | //Check if there is a country asigned. |
852 | 852 | $potential_id = wp_get_post_parent_id($dest_id); |
853 | - $country_wetu_id = get_post_meta($potential_id,'lsx_wetu_id',true); |
|
854 | - if(false !== $country_wetu_id){ |
|
853 | + $country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true); |
|
854 | + if (false !== $country_wetu_id) { |
|
855 | 855 | $country_id = $this->set_country($country_wetu_id, $id); |
856 | 856 | } |
857 | 857 | |
858 | 858 | }else { |
859 | 859 | |
860 | - $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $day['destination_content_entity_id']); |
|
860 | + $destination_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$day['destination_content_entity_id']); |
|
861 | 861 | |
862 | 862 | if ($destination_json) { |
863 | 863 | $destination_data = json_decode($destination_json, true); |
@@ -866,12 +866,12 @@ discard block |
||
866 | 866 | |
867 | 867 | $destination_title = $day['destination_content_entity_id']; |
868 | 868 | |
869 | - if(isset($destination_data[0]['name'])){ |
|
869 | + if (isset($destination_data[0]['name'])) { |
|
870 | 870 | $destination_title = $destination_data[0]['name']; |
871 | 871 | } |
872 | 872 | |
873 | - if(isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
874 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']){ |
|
873 | + if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
874 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) { |
|
875 | 875 | |
876 | 876 | $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
877 | 877 | } |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | 'post_title' => $destination_title |
883 | 883 | ); |
884 | 884 | |
885 | - if(false !== $country_id){ |
|
885 | + if (false !== $country_id) { |
|
886 | 886 | $dest_post['post_parent'] = $country_id; |
887 | 887 | } |
888 | 888 | $dest_id = wp_insert_post($dest_post); |
@@ -901,15 +901,15 @@ discard block |
||
901 | 901 | $this->cleanup_posts[$dest_id] = 'tour_to_destination'; |
902 | 902 | |
903 | 903 | // Save the first destination so we can grab the tour featured image and banner |
904 | - if(0 === $leg_counter){ |
|
905 | - $this->destination_images[$id] = array($dest_id,$day['destination_content_entity_id']); |
|
904 | + if (0 === $leg_counter) { |
|
905 | + $this->destination_images[$id] = array($dest_id, $day['destination_content_entity_id']); |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | //Add this relation info so we can make sure certain items are set as countries. |
909 | - if(0 !== $country_id && false !== $country_id){ |
|
909 | + if (0 !== $country_id && false !== $country_id) { |
|
910 | 910 | $this->relation_meta[$dest_id] = $country_id; |
911 | 911 | $this->relation_meta[$country_id] = 0; |
912 | - }else{ |
|
912 | + }else { |
|
913 | 913 | $this->relation_meta[$dest_id] = 0; |
914 | 914 | } |
915 | 915 | } |
@@ -932,9 +932,9 @@ discard block |
||
932 | 932 | |
933 | 933 | if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
934 | 934 | $country_id = $this->current_destinations[$country_wetu_id]; |
935 | - } else { |
|
935 | + }else { |
|
936 | 936 | |
937 | - $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=" . $country_wetu_id); |
|
937 | + $country_json = file_get_contents("http://wetu.com/API/Pins/".$this->api_key."/Get?ids=".$country_wetu_id); |
|
938 | 938 | |
939 | 939 | if ($country_json) { |
940 | 940 | $country_data = json_decode($country_json, true); |
@@ -979,15 +979,15 @@ discard block |
||
979 | 979 | * |
980 | 980 | * @return string |
981 | 981 | */ |
982 | - public function attach_destination_images($importable_content=array()) { |
|
983 | - if(false !== $this->destination_images){ |
|
982 | + public function attach_destination_images($importable_content = array()) { |
|
983 | + if (false !== $this->destination_images) { |
|
984 | 984 | |
985 | - foreach($this->destination_images as $tour => $destination){ |
|
985 | + foreach ($this->destination_images as $tour => $destination) { |
|
986 | 986 | |
987 | - $url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
987 | + $url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
988 | 988 | $url_qs = ''; |
989 | 989 | |
990 | - $jdata = file_get_contents($url . '/Get?' . $url_qs . '&ids=' . $destination[1]); |
|
990 | + $jdata = file_get_contents($url.'/Get?'.$url_qs.'&ids='.$destination[1]); |
|
991 | 991 | if ($jdata) { |
992 | 992 | $adata = json_decode($jdata, true); |
993 | 993 |
@@ -141,31 +141,31 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function __construct() { |
143 | 143 | |
144 | - add_action( 'admin_init', array( $this, 'compatible_version_check' ) ); |
|
144 | + add_action('admin_init', array($this, 'compatible_version_check')); |
|
145 | 145 | |
146 | 146 | // Don't run anything else in the plugin, if we're on an incompatible PHP version |
147 | - if ( ! self::compatible_version() ) { |
|
147 | + if (!self::compatible_version()) { |
|
148 | 148 | return; |
149 | 149 | } |
150 | 150 | |
151 | 151 | $this->set_variables(); |
152 | 152 | |
153 | - add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
|
154 | - add_action( 'admin_enqueue_scripts', array($this,'admin_scripts') ,11 ); |
|
155 | - add_action( 'admin_menu', array( $this, 'register_importer_page' ),20 ); |
|
153 | + add_action('init', array($this, 'load_plugin_textdomain')); |
|
154 | + add_action('admin_enqueue_scripts', array($this, 'admin_scripts'), 11); |
|
155 | + add_action('admin_menu', array($this, 'register_importer_page'), 20); |
|
156 | 156 | |
157 | 157 | require_once(WETU_IMPORTER_PATH.'classes/class-accommodation.php'); |
158 | 158 | require_once(WETU_IMPORTER_PATH.'classes/class-destination.php'); |
159 | 159 | require_once(WETU_IMPORTER_PATH.'classes/class-tours.php'); |
160 | 160 | |
161 | - add_action( 'init', array( $this, 'load_class' ) ); |
|
161 | + add_action('init', array($this, 'load_class')); |
|
162 | 162 | |
163 | - if('default' !== $this->tab_slug){ |
|
164 | - add_action('wp_ajax_lsx_tour_importer',array($this,'process_ajax_search')); |
|
165 | - add_action('wp_ajax_nopriv_lsx_tour_importer',array($this,'process_ajax_search')); |
|
163 | + if ('default' !== $this->tab_slug) { |
|
164 | + add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
165 | + add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
166 | 166 | |
167 | - add_action('wp_ajax_lsx_import_items',array($this,'process_ajax_import')); |
|
168 | - add_action('wp_ajax_nopriv_lsx_import_items',array($this,'process_ajax_import')); |
|
167 | + add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import')); |
|
168 | + add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import')); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
@@ -177,25 +177,25 @@ discard block |
||
177 | 177 | * @since 1.0.0 |
178 | 178 | */ |
179 | 179 | public function load_plugin_textdomain() { |
180 | - load_plugin_textdomain( 'wetu-importer', FALSE, basename( WETU_IMPORTER_PATH ) . '/languages'); |
|
180 | + load_plugin_textdomain('wetu-importer', FALSE, basename(WETU_IMPORTER_PATH).'/languages'); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
184 | 184 | * Sets the variables used throughout the plugin. |
185 | 185 | */ |
186 | 186 | public function set_variables() { |
187 | - $this->post_types = array('accommodation','destination','tour'); |
|
188 | - $temp_options = get_option('_lsx-to_settings',false); |
|
187 | + $this->post_types = array('accommodation', 'destination', 'tour'); |
|
188 | + $temp_options = get_option('_lsx-to_settings', false); |
|
189 | 189 | |
190 | - if(isset($_GET['tab']) || isset($_POST['type'])) { |
|
191 | - if(isset($_GET['tab'])) { |
|
190 | + if (isset($_GET['tab']) || isset($_POST['type'])) { |
|
191 | + if (isset($_GET['tab'])) { |
|
192 | 192 | $this->tab_slug = $_GET['tab']; |
193 | - }else{ |
|
193 | + }else { |
|
194 | 194 | $this->tab_slug = $_POST['type']; |
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
198 | - if(isset($temp_options[$this->plugin_slug])) { |
|
198 | + if (isset($temp_options[$this->plugin_slug])) { |
|
199 | 199 | $this->options = $temp_options[$this->plugin_slug]; |
200 | 200 | |
201 | 201 | $this->api_key = false; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | if (isset($this->options['cropping']) && '' !== $this->options['cropping']) { |
227 | 227 | $cropping = $this->options['cropping']; |
228 | 228 | } |
229 | - $this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/'; |
|
229 | + $this->image_scaling_url = 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/'; |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @since 1.0.0 |
250 | 250 | */ |
251 | 251 | public static function compatible_version() { |
252 | - if ( version_compare( PHP_VERSION, '5.6', '<' ) ) { |
|
252 | + if (version_compare(PHP_VERSION, '5.6', '<')) { |
|
253 | 253 | return false; |
254 | 254 | } |
255 | 255 | |
@@ -263,13 +263,13 @@ discard block |
||
263 | 263 | * @since 1.0.0 |
264 | 264 | */ |
265 | 265 | public function compatible_version_check() { |
266 | - if ( ! self::compatible_version() ) { |
|
267 | - if ( is_plugin_active( plugin_basename( WETU_IMPORTER_CORE ) ) ) { |
|
268 | - deactivate_plugins( plugin_basename( WETU_IMPORTER_CORE ) ); |
|
269 | - add_action( 'admin_notices', array( $this, 'compatible_version_notice' ) ); |
|
266 | + if (!self::compatible_version()) { |
|
267 | + if (is_plugin_active(plugin_basename(WETU_IMPORTER_CORE))) { |
|
268 | + deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE)); |
|
269 | + add_action('admin_notices', array($this, 'compatible_version_notice')); |
|
270 | 270 | |
271 | - if ( isset( $_GET['activate'] ) ) { |
|
272 | - unset( $_GET['activate'] ); |
|
271 | + if (isset($_GET['activate'])) { |
|
272 | + unset($_GET['activate']); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | } |
@@ -282,8 +282,8 @@ discard block |
||
282 | 282 | */ |
283 | 283 | public function compatible_version_notice() { |
284 | 284 | $class = 'notice notice-error'; |
285 | - $message = esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' ); |
|
286 | - printf( '<div class="%1$s"><p>%2$s</p></div>', esc_html( $class ), esc_html( $message ) ); |
|
285 | + $message = esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer'); |
|
286 | + printf('<div class="%1$s"><p>%2$s</p></div>', esc_html($class), esc_html($message)); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -293,9 +293,9 @@ discard block |
||
293 | 293 | * @since 1.0.0 |
294 | 294 | */ |
295 | 295 | public static function compatible_version_check_on_activation() { |
296 | - if ( ! self::compatible_version() ) { |
|
297 | - deactivate_plugins( plugin_basename( WETU_IMPORTER_CORE ) ); |
|
298 | - wp_die( esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' ) ); |
|
296 | + if (!self::compatible_version()) { |
|
297 | + deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE)); |
|
298 | + wp_die(esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer')); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
@@ -304,9 +304,9 @@ discard block |
||
304 | 304 | /* |
305 | 305 | * Load the importer class you want to use |
306 | 306 | */ |
307 | - public function load_class(){ |
|
307 | + public function load_class() { |
|
308 | 308 | |
309 | - switch($this->tab_slug){ |
|
309 | + switch ($this->tab_slug) { |
|
310 | 310 | case 'accommodation': |
311 | 311 | $this->current_importer = new WETU_Importer_Accommodation(); |
312 | 312 | break; |
@@ -330,25 +330,25 @@ discard block |
||
330 | 330 | * Registers the admin page which will house the importer form. |
331 | 331 | */ |
332 | 332 | public function register_importer_page() { |
333 | - add_submenu_page( 'tour-operator',esc_html__( 'Importer', 'tour-operator' ), esc_html__( 'Importer', 'tour-operator' ), 'manage_options', 'wetu-importer', array( $this, 'display_page' ) ); |
|
333 | + add_submenu_page('tour-operator', esc_html__('Importer', 'tour-operator'), esc_html__('Importer', 'tour-operator'), 'manage_options', 'wetu-importer', array($this, 'display_page')); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
337 | 337 | * Enqueue the JS needed to contact wetu and return your result. |
338 | 338 | */ |
339 | 339 | public function admin_scripts() { |
340 | - if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { |
|
340 | + if (defined('WP_DEBUG') && true === WP_DEBUG) { |
|
341 | 341 | $min = ''; |
342 | - } else { |
|
342 | + }else { |
|
343 | 343 | $min = '.min'; |
344 | 344 | } |
345 | 345 | $min = ''; |
346 | 346 | |
347 | - if(is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']){ |
|
348 | - wp_enqueue_script( 'wetu-importers-script', WETU_IMPORTER_URL . 'assets/js/wetu-importer' . $min . '.js', array( 'jquery' ), WETU_IMPORTER_VER, true ); |
|
349 | - wp_localize_script( 'wetu-importers-script', 'lsx_tour_importer_params', array( |
|
347 | + if (is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']) { |
|
348 | + wp_enqueue_script('wetu-importers-script', WETU_IMPORTER_URL.'assets/js/wetu-importer'.$min.'.js', array('jquery'), WETU_IMPORTER_VER, true); |
|
349 | + wp_localize_script('wetu-importers-script', 'lsx_tour_importer_params', array( |
|
350 | 350 | 'ajax_url' => admin_url('admin-ajax.php'), |
351 | - ) ); |
|
351 | + )); |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
@@ -360,25 +360,25 @@ discard block |
||
360 | 360 | <div class="wrap"> |
361 | 361 | <?php screen_icon(); ?> |
362 | 362 | |
363 | - <?php if(!is_object($this->current_importer)){ |
|
363 | + <?php if (!is_object($this->current_importer)) { |
|
364 | 364 | ?> |
365 | - <h2><?php _e('Welcome to the LSX Wetu Importer','wetu-importer'); ?></h2> |
|
365 | + <h2><?php _e('Welcome to the LSX Wetu Importer', 'wetu-importer'); ?></h2> |
|
366 | 366 | <p>If this is the first time you are running the import, then follow the steps below.</p> |
367 | 367 | <ul> |
368 | - <li>Step 1 - Import your <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=tour"><?php _e('Tours','wetu-importer'); ?></a></li> |
|
369 | - <li>Step 2 - The tour import will have created draft <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation','wetu-importer'); ?></a> that will need to be imported.</li> |
|
370 | - <li>Step 3 - Lastly import the <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations','wetu-importer'); ?></a> draft posts created during the previous two steps.</li> |
|
368 | + <li>Step 1 - Import your <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=tour"><?php _e('Tours', 'wetu-importer'); ?></a></li> |
|
369 | + <li>Step 2 - The tour import will have created draft <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=accommodation"><?php _e('accommodation', 'wetu-importer'); ?></a> that will need to be imported.</li> |
|
370 | + <li>Step 3 - Lastly import the <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations', 'wetu-importer'); ?></a> draft posts created during the previous two steps.</li> |
|
371 | 371 | </ul> |
372 | 372 | |
373 | - <h3><?php _e('Additional Tools','wetu-importer'); ?></h3> |
|
373 | + <h3><?php _e('Additional Tools', 'wetu-importer'); ?></h3> |
|
374 | 374 | <ul> |
375 | - <li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=connect_accommodation"><?php _e('Connect Accommodation','wetu-importer'); ?></a> <small><?php _e('If you already have accommodation, you can "connect" it with its WETU counter part, so it works with the importer.','wetu-importer'); ?></small></li> |
|
376 | - <?php if(class_exists('Lsx_Banners')){ ?> |
|
377 | - <li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=banners"><?php _e('Sync High Res Banner Images','wetu-importer'); ?></a></li> |
|
375 | + <li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=connect_accommodation"><?php _e('Connect Accommodation', 'wetu-importer'); ?></a> <small><?php _e('If you already have accommodation, you can "connect" it with its WETU counter part, so it works with the importer.', 'wetu-importer'); ?></small></li> |
|
376 | + <?php if (class_exists('Lsx_Banners')) { ?> |
|
377 | + <li><a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=banners"><?php _e('Sync High Res Banner Images', 'wetu-importer'); ?></a></li> |
|
378 | 378 | <?php } ?> |
379 | 379 | </ul> |
380 | 380 | <?php |
381 | - }else{ |
|
381 | + }else { |
|
382 | 382 | $this->current_importer->display_page(); |
383 | 383 | }; ?> |
384 | 384 | </div> |
@@ -393,33 +393,33 @@ discard block |
||
393 | 393 | <form class="ajax-form" id="<?php echo $this->plugin_slug; ?>-search-form" method="get" action="tools.php" data-type="<?php echo $this->tab_slug; ?>"> |
394 | 394 | <input type="hidden" name="page" value="<?php echo $this->tab_slug; ?>" /> |
395 | 395 | |
396 | - <h3><span class="dashicons dashicons-search"></span> <?php _e('Search','wetu-importer'); ?></h3> |
|
396 | + <h3><span class="dashicons dashicons-search"></span> <?php _e('Search', 'wetu-importer'); ?></h3> |
|
397 | 397 | |
398 | - <?php do_action('wetu_importer_search_form',$this); ?> |
|
398 | + <?php do_action('wetu_importer_search_form', $this); ?> |
|
399 | 399 | |
400 | 400 | <div class="normal-search"> |
401 | - <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" /> |
|
401 | + <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" /> |
|
402 | 402 | </div> |
403 | 403 | <div class="advanced-search hidden" style="display:none;"> |
404 | - <p><?php _e('Enter several keywords, each on a new line.','wetu-importer'); ?></p> |
|
404 | + <p><?php _e('Enter several keywords, each on a new line.', 'wetu-importer'); ?></p> |
|
405 | 405 | <textarea rows="10" cols="40" name="bulk-keywords"></textarea> |
406 | - <input class="button button-primary submit" type="submit" value="<?php _e('Search','wetu-importer'); ?>" /> |
|
406 | + <input class="button button-primary submit" type="submit" value="<?php _e('Search', 'wetu-importer'); ?>" /> |
|
407 | 407 | </div> |
408 | 408 | |
409 | 409 | <p> |
410 | - <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search','wetu-importer'); ?></a> | |
|
411 | - <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published','wetu-importer'); ?></a> | |
|
412 | - <a class="pending search-toggle" href="#pending"><?php esc_attr_e('Pending','wetu-importer'); ?></a> | |
|
413 | - <a class="draft search-toggle" href="#draft"><?php esc_attr_e('Draft','wetu-importer'); ?></a> | |
|
414 | - <a class="import search-toggle" href="#import"><?php esc_attr_e('WETU','wetu-importer'); ?></a> |
|
410 | + <a class="advanced-search-toggle" href="#"><?php _e('Bulk Search', 'wetu-importer'); ?></a> | |
|
411 | + <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published', 'wetu-importer'); ?></a> | |
|
412 | + <a class="pending search-toggle" href="#pending"><?php esc_attr_e('Pending', 'wetu-importer'); ?></a> | |
|
413 | + <a class="draft search-toggle" href="#draft"><?php esc_attr_e('Draft', 'wetu-importer'); ?></a> | |
|
414 | + <a class="import search-toggle" href="#import"><?php esc_attr_e('WETU', 'wetu-importer'); ?></a> |
|
415 | 415 | </p> |
416 | 416 | |
417 | 417 | <div class="ajax-loader" style="display:none;width:100%;text-align:center;"> |
418 | - <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" /> |
|
418 | + <img style="width:64px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" /> |
|
419 | 419 | </div> |
420 | 420 | |
421 | 421 | <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;"> |
422 | - <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif';?>" /> |
|
422 | + <img style="width:32px;" src="<?php echo WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'; ?>" /> |
|
423 | 423 | </div> |
424 | 424 | </form> |
425 | 425 | <?php |
@@ -468,15 +468,15 @@ discard block |
||
468 | 468 | * |
469 | 469 | * @param $tab string |
470 | 470 | */ |
471 | - public function navigation($tab='') { |
|
471 | + public function navigation($tab = '') { |
|
472 | 472 | $post_types = array( |
473 | - 'tour' => esc_attr('Tours','wetu-importer'), |
|
474 | - 'accommodation' => esc_attr('Accommodation','wetu-importer'), |
|
475 | - 'destination' => esc_attr('Destinations','wetu-importer'), |
|
473 | + 'tour' => esc_attr('Tours', 'wetu-importer'), |
|
474 | + 'accommodation' => esc_attr('Accommodation', 'wetu-importer'), |
|
475 | + 'destination' => esc_attr('Destinations', 'wetu-importer'), |
|
476 | 476 | ); |
477 | - 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>'; |
|
478 | - foreach($post_types as $post_type => $label){ |
|
479 | - echo ' | <a class="'.$this->itemd($tab,$post_type,'current',false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>'; |
|
477 | + 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>'; |
|
478 | + foreach ($post_types as $post_type => $label) { |
|
479 | + echo ' | <a class="'.$this->itemd($tab, $post_type, 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>'; |
|
480 | 480 | } |
481 | 481 | echo '</div><br clear="both"/></div>'; |
482 | 482 | } |
@@ -484,23 +484,23 @@ discard block |
||
484 | 484 | /** |
485 | 485 | * set_taxonomy with some terms |
486 | 486 | */ |
487 | - public function team_member_checkboxes($selected=array()) { |
|
488 | - if(post_type_exists('team')) { ?> |
|
487 | + public function team_member_checkboxes($selected = array()) { |
|
488 | + if (post_type_exists('team')) { ?> |
|
489 | 489 | <ul> |
490 | 490 | <?php |
491 | - $team_args=array( |
|
491 | + $team_args = array( |
|
492 | 492 | 'post_type' => 'team', |
493 | 493 | 'post_status' => 'publish', |
494 | 494 | 'nopagin' => true, |
495 | 495 | 'fields' => 'ids' |
496 | 496 | ); |
497 | 497 | $team_members = new WP_Query($team_args); |
498 | - if($team_members->have_posts()){ |
|
499 | - foreach($team_members->posts as $member){ ?> |
|
500 | - <li><input class="team" <?php $this->checked($selected,$member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li> |
|
498 | + if ($team_members->have_posts()) { |
|
499 | + foreach ($team_members->posts as $member) { ?> |
|
500 | + <li><input class="team" <?php $this->checked($selected, $member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li> |
|
501 | 501 | <?php } |
502 | - }else{ ?> |
|
503 | - <li><input class="team" type="checkbox" value="0" /> <?php _e('None','wetu-importer'); ?></li> |
|
502 | + }else { ?> |
|
503 | + <li><input class="team" type="checkbox" value="0" /> <?php _e('None', 'wetu-importer'); ?></li> |
|
504 | 504 | <?php } |
505 | 505 | ?> |
506 | 506 | </ul> |
@@ -517,12 +517,12 @@ discard block |
||
517 | 517 | * @param $needle string |
518 | 518 | * @param $echo bool |
519 | 519 | */ |
520 | - public function checked($haystack=false,$needle='',$echo=true) { |
|
521 | - $return = $this->itemd($haystack,$needle,'checked'); |
|
522 | - if('' !== $return) { |
|
520 | + public function checked($haystack = false, $needle = '', $echo = true) { |
|
521 | + $return = $this->itemd($haystack, $needle, 'checked'); |
|
522 | + if ('' !== $return) { |
|
523 | 523 | if (true === $echo) { |
524 | 524 | echo $return; |
525 | - } else { |
|
525 | + }else { |
|
526 | 526 | return $return; |
527 | 527 | } |
528 | 528 | } |
@@ -535,12 +535,12 @@ discard block |
||
535 | 535 | * @param $needle string |
536 | 536 | * @param $echo bool |
537 | 537 | */ |
538 | - public function selected($haystack=false,$needle='',$echo=true) { |
|
539 | - $return = $this->itemd($haystack,$needle,'selected'); |
|
540 | - if('' !== $return) { |
|
538 | + public function selected($haystack = false, $needle = '', $echo = true) { |
|
539 | + $return = $this->itemd($haystack, $needle, 'selected'); |
|
540 | + if ('' !== $return) { |
|
541 | 541 | if (true === $echo) { |
542 | 542 | echo $return; |
543 | - } else { |
|
543 | + }else { |
|
544 | 544 | return $return; |
545 | 545 | } |
546 | 546 | } |
@@ -555,16 +555,16 @@ discard block |
||
555 | 555 | * @param $wrap bool |
556 | 556 | * @return $html string |
557 | 557 | */ |
558 | - public function itemd($haystack=false,$needle='',$type='',$wrap=true) { |
|
558 | + public function itemd($haystack = false, $needle = '', $type = '', $wrap = true) { |
|
559 | 559 | $html = ''; |
560 | - if('' !== $type) { |
|
560 | + if ('' !== $type) { |
|
561 | 561 | if (!is_array($haystack)) { |
562 | 562 | $haystack = array($haystack); |
563 | 563 | } |
564 | 564 | if (in_array($needle, $haystack)) { |
565 | - if(true === $wrap || 'true' === $wrap) { |
|
566 | - $html = $type . '="' . $type . '"'; |
|
567 | - }else{ |
|
565 | + if (true === $wrap || 'true' === $wrap) { |
|
566 | + $html = $type.'="'.$type.'"'; |
|
567 | + }else { |
|
568 | 568 | $html = $type; |
569 | 569 | } |
570 | 570 | } |
@@ -576,9 +576,9 @@ discard block |
||
576 | 576 | /** |
577 | 577 | * grabs any attachments for the current item |
578 | 578 | */ |
579 | - public function find_attachments($id=false) { |
|
580 | - if(false !== $id){ |
|
581 | - if(empty($this->found_attachments)){ |
|
579 | + public function find_attachments($id = false) { |
|
580 | + if (false !== $id) { |
|
581 | + if (empty($this->found_attachments)) { |
|
582 | 582 | |
583 | 583 | $attachments_args = array( |
584 | 584 | 'post_parent' => $id, |
@@ -590,9 +590,9 @@ discard block |
||
590 | 590 | ); |
591 | 591 | |
592 | 592 | $attachments = new WP_Query($attachments_args); |
593 | - if($attachments->have_posts()){ |
|
594 | - foreach($attachments->posts as $attachment){ |
|
595 | - $this->found_attachments[$attachment->ID] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
593 | + if ($attachments->have_posts()) { |
|
594 | + foreach ($attachments->posts as $attachment) { |
|
595 | + $this->found_attachments[$attachment->ID] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title); |
|
596 | 596 | $this->gallery_meta[] = $attachment->ID; |
597 | 597 | } |
598 | 598 | } |
@@ -606,18 +606,18 @@ discard block |
||
606 | 606 | /** |
607 | 607 | * Saves the room data |
608 | 608 | */ |
609 | - public function save_custom_field($value=false,$meta_key,$id,$decrease=false,$unique=true) { |
|
610 | - if(false !== $value){ |
|
611 | - if(false !== $decrease){ |
|
609 | + public function save_custom_field($value = false, $meta_key, $id, $decrease = false, $unique = true) { |
|
610 | + if (false !== $value) { |
|
611 | + if (false !== $decrease) { |
|
612 | 612 | $value = intval($value); |
613 | 613 | $value--; |
614 | 614 | } |
615 | - $prev = get_post_meta($id,$meta_key,true); |
|
615 | + $prev = get_post_meta($id, $meta_key, true); |
|
616 | 616 | |
617 | - if(false !== $id && '0' !== $id && false !== $prev && true === $unique){ |
|
618 | - update_post_meta($id,$meta_key,$value,$prev); |
|
619 | - }else{ |
|
620 | - add_post_meta($id,$meta_key,$value,$unique); |
|
617 | + if (false !== $id && '0' !== $id && false !== $prev && true === $unique) { |
|
618 | + update_post_meta($id, $meta_key, $value, $prev); |
|
619 | + }else { |
|
620 | + add_post_meta($id, $meta_key, $value, $unique); |
|
621 | 621 | } |
622 | 622 | } |
623 | 623 | } |
@@ -626,12 +626,12 @@ discard block |
||
626 | 626 | * Grabs the custom fields, and resaves an array of unique items. |
627 | 627 | */ |
628 | 628 | public function cleanup_posts() { |
629 | - if(!empty($this->cleanup_posts)){ |
|
630 | - foreach($this->cleanup_posts as $id => $key) { |
|
629 | + if (!empty($this->cleanup_posts)) { |
|
630 | + foreach ($this->cleanup_posts as $id => $key) { |
|
631 | 631 | $prev_items = get_post_meta($id, $key, false); |
632 | 632 | $new_items = array_unique($prev_items); |
633 | 633 | delete_post_meta($id, $key); |
634 | - foreach($new_items as $new_item) { |
|
634 | + foreach ($new_items as $new_item) { |
|
635 | 635 | add_post_meta($id, $key, $new_item, false); |
636 | 636 | } |
637 | 637 | } |
@@ -643,51 +643,51 @@ discard block |
||
643 | 643 | /** |
644 | 644 | * set_taxonomy with some terms |
645 | 645 | */ |
646 | - public function set_taxonomy($taxonomy,$terms,$id) { |
|
647 | - $result=array(); |
|
648 | - if(!empty($data)) |
|
646 | + public function set_taxonomy($taxonomy, $terms, $id) { |
|
647 | + $result = array(); |
|
648 | + if (!empty($data)) |
|
649 | 649 | { |
650 | - foreach($data as $k) |
|
650 | + foreach ($data as $k) |
|
651 | 651 | { |
652 | - if($id) |
|
652 | + if ($id) |
|
653 | 653 | { |
654 | - if(!$term = term_exists(trim($k), $tax)) |
|
654 | + if (!$term = term_exists(trim($k), $tax)) |
|
655 | 655 | { |
656 | 656 | $term = wp_insert_term(trim($k), $tax); |
657 | - if ( is_wp_error($term) ) |
|
657 | + if (is_wp_error($term)) |
|
658 | 658 | { |
659 | 659 | echo $term->get_error_message(); |
660 | 660 | } |
661 | 661 | else |
662 | 662 | { |
663 | - wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
663 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
664 | 664 | } |
665 | 665 | } |
666 | 666 | else |
667 | 667 | { |
668 | - wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
668 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
669 | 669 | } |
670 | 670 | } |
671 | 671 | else |
672 | 672 | { |
673 | - $result[]=trim($k); |
|
673 | + $result[] = trim($k); |
|
674 | 674 | } |
675 | 675 | } |
676 | 676 | } |
677 | 677 | return $result; |
678 | 678 | } |
679 | 679 | |
680 | - public function set_term($id=false,$name=false,$taxonomy=false,$parent=false){ |
|
681 | - if(!$term = term_exists($name, $taxonomy)) |
|
680 | + public function set_term($id = false, $name = false, $taxonomy = false, $parent = false) { |
|
681 | + if (!$term = term_exists($name, $taxonomy)) |
|
682 | 682 | { |
683 | - if(false !== $parent){ $parent = array('parent'=>$parent); } |
|
684 | - $term = wp_insert_term(trim($name), $taxonomy,$parent); |
|
685 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
686 | - else { wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); } |
|
683 | + if (false !== $parent) { $parent = array('parent'=>$parent); } |
|
684 | + $term = wp_insert_term(trim($name), $taxonomy, $parent); |
|
685 | + if (is_wp_error($term)) {echo $term->get_error_message(); } |
|
686 | + else { wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); } |
|
687 | 687 | } |
688 | 688 | else |
689 | 689 | { |
690 | - wp_set_object_terms( $id, intval($term['term_id']), $taxonomy,true); |
|
690 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
691 | 691 | } |
692 | 692 | return $term['term_id']; |
693 | 693 | } |
@@ -695,18 +695,18 @@ discard block |
||
695 | 695 | /** |
696 | 696 | * set_taxonomy with some terms |
697 | 697 | */ |
698 | - public function taxonomy_checkboxes($taxonomy=false,$selected=array()) { |
|
698 | + public function taxonomy_checkboxes($taxonomy = false, $selected = array()) { |
|
699 | 699 | $return = ''; |
700 | - if(false !== $taxonomy){ |
|
700 | + if (false !== $taxonomy) { |
|
701 | 701 | $return .= '<ul>'; |
702 | - $terms = get_terms(array('taxonomy'=>$taxonomy,'hide_empty'=>false)); |
|
702 | + $terms = get_terms(array('taxonomy'=>$taxonomy, 'hide_empty'=>false)); |
|
703 | 703 | |
704 | - if(!is_wp_error($terms)){ |
|
705 | - foreach($terms as $term){ |
|
706 | - $return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected,$term->term_id,false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>'; |
|
704 | + if (!is_wp_error($terms)) { |
|
705 | + foreach ($terms as $term) { |
|
706 | + $return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected, $term->term_id, false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>'; |
|
707 | 707 | } |
708 | - }else{ |
|
709 | - $return .= '<li><input type="checkbox" value="" /> '.__('None','wetu-importer').'</li>'; |
|
708 | + }else { |
|
709 | + $return .= '<li><input type="checkbox" value="" /> '.__('None', 'wetu-importer').'</li>'; |
|
710 | 710 | } |
711 | 711 | $return .= '</ul>'; |
712 | 712 | } |
@@ -717,53 +717,53 @@ discard block |
||
717 | 717 | /** |
718 | 718 | * Saves the longitude and lattitude, as well as sets the map marker. |
719 | 719 | */ |
720 | - public function set_map_data($data,$id,$zoom = '10') { |
|
720 | + public function set_map_data($data, $id, $zoom = '10') { |
|
721 | 721 | $longitude = $latitude = $address = false; |
722 | 722 | |
723 | - if(isset($data[0]['position'])){ |
|
723 | + if (isset($data[0]['position'])) { |
|
724 | 724 | |
725 | - if(isset($data[0]['position']['driving_latitude'])){ |
|
725 | + if (isset($data[0]['position']['driving_latitude'])) { |
|
726 | 726 | $latitude = $data[0]['position']['driving_latitude']; |
727 | - }elseif(isset($data[0]['position']['latitude'])){ |
|
727 | + }elseif (isset($data[0]['position']['latitude'])) { |
|
728 | 728 | $latitude = $data[0]['position']['latitude']; |
729 | 729 | } |
730 | 730 | |
731 | - if(isset($data[0]['position']['driving_longitude'])){ |
|
731 | + if (isset($data[0]['position']['driving_longitude'])) { |
|
732 | 732 | $longitude = $data[0]['position']['driving_longitude']; |
733 | - }elseif(isset($data[0]['position']['longitude'])){ |
|
733 | + }elseif (isset($data[0]['position']['longitude'])) { |
|
734 | 734 | $longitude = $data[0]['position']['longitude']; |
735 | 735 | } |
736 | 736 | |
737 | 737 | } |
738 | - if(isset($data[0]['content']) && isset($data[0]['content']['contact_information'])){ |
|
739 | - if(isset($data[0]['content']['contact_information']['address'])){ |
|
738 | + if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) { |
|
739 | + if (isset($data[0]['content']['contact_information']['address'])) { |
|
740 | 740 | $address = strip_tags($data[0]['content']['contact_information']['address']); |
741 | 741 | |
742 | - $address = explode("\n",$address); |
|
743 | - foreach($address as $bitkey => $bit){ |
|
742 | + $address = explode("\n", $address); |
|
743 | + foreach ($address as $bitkey => $bit) { |
|
744 | 744 | $bit = ltrim(rtrim($bit)); |
745 | - if(false === $bit || '' === $bit || null === $bit or empty($bit)){ |
|
745 | + if (false === $bit || '' === $bit || null === $bit or empty($bit)) { |
|
746 | 746 | unset($address[$bitkey]); |
747 | 747 | } |
748 | 748 | } |
749 | - $address = implode(', ',$address); |
|
749 | + $address = implode(', ', $address); |
|
750 | 750 | $address = str_replace(', , ', ', ', $address); |
751 | 751 | } |
752 | 752 | } |
753 | 753 | |
754 | - if(false !== $longitude){ |
|
754 | + if (false !== $longitude) { |
|
755 | 755 | $location_data = array( |
756 | - 'address' => (string)$address, |
|
757 | - 'lat' => (string)$latitude, |
|
758 | - 'long' => (string)$longitude, |
|
759 | - 'zoom' => (string)$zoom, |
|
756 | + 'address' => (string) $address, |
|
757 | + 'lat' => (string) $latitude, |
|
758 | + 'long' => (string) $longitude, |
|
759 | + 'zoom' => (string) $zoom, |
|
760 | 760 | 'elevation' => '', |
761 | 761 | ); |
762 | - if(false !== $id && '0' !== $id){ |
|
763 | - $prev = get_post_meta($id,'location',true); |
|
764 | - update_post_meta($id,'location',$location_data,$prev); |
|
765 | - }else{ |
|
766 | - add_post_meta($id,'location',$location_data,true); |
|
762 | + if (false !== $id && '0' !== $id) { |
|
763 | + $prev = get_post_meta($id, 'location', true); |
|
764 | + update_post_meta($id, 'location', $location_data, $prev); |
|
765 | + }else { |
|
766 | + add_post_meta($id, 'location', $location_data, true); |
|
767 | 767 | } |
768 | 768 | } |
769 | 769 | } |
@@ -773,16 +773,16 @@ discard block |
||
773 | 773 | /** |
774 | 774 | * Creates the main gallery data |
775 | 775 | */ |
776 | - public function set_featured_image($data,$id) { |
|
777 | - if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
|
778 | - $this->featured_image = $this->attach_image($data[0]['content']['images'][0],$id); |
|
776 | + public function set_featured_image($data, $id) { |
|
777 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
778 | + $this->featured_image = $this->attach_image($data[0]['content']['images'][0], $id); |
|
779 | 779 | |
780 | - if(false !== $this->featured_image){ |
|
781 | - delete_post_meta($id,'_thumbnail_id'); |
|
782 | - add_post_meta($id,'_thumbnail_id',$this->featured_image,true); |
|
780 | + if (false !== $this->featured_image) { |
|
781 | + delete_post_meta($id, '_thumbnail_id'); |
|
782 | + add_post_meta($id, '_thumbnail_id', $this->featured_image, true); |
|
783 | 783 | |
784 | - if(!empty($this->gallery_meta) && !in_array($this->featured_image,$this->gallery_meta)){ |
|
785 | - add_post_meta($id,'gallery',$this->featured_image,false); |
|
784 | + if (!empty($this->gallery_meta) && !in_array($this->featured_image, $this->gallery_meta)) { |
|
785 | + add_post_meta($id, 'gallery', $this->featured_image, false); |
|
786 | 786 | $this->gallery_meta[] = $this->featured_image; |
787 | 787 | } |
788 | 788 | } |
@@ -792,17 +792,17 @@ discard block |
||
792 | 792 | /** |
793 | 793 | * Sets a banner image |
794 | 794 | */ |
795 | - public function set_banner_image($data,$id) { |
|
796 | - if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
|
797 | - $this->banner_image = $this->attach_image($data[0]['content']['images'][1],$id,array('width'=>'1920','height'=>'800','cropping'=>'c')); |
|
795 | + public function set_banner_image($data, $id) { |
|
796 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
797 | + $this->banner_image = $this->attach_image($data[0]['content']['images'][1], $id, array('width'=>'1920', 'height'=>'800', 'cropping'=>'c')); |
|
798 | 798 | |
799 | - if(false !== $this->banner_image){ |
|
800 | - delete_post_meta($id,'image_group'); |
|
799 | + if (false !== $this->banner_image) { |
|
800 | + delete_post_meta($id, 'image_group'); |
|
801 | 801 | $new_banner = array('banner_image'=>array('cmb-field-0'=>$this->banner_image)); |
802 | - add_post_meta($id,'image_group',$new_banner,true); |
|
802 | + add_post_meta($id, 'image_group', $new_banner, true); |
|
803 | 803 | |
804 | - if(!empty($this->gallery_meta) && !in_array($this->banner_image,$this->gallery_meta)){ |
|
805 | - add_post_meta($id,'gallery',$this->banner_image,false); |
|
804 | + if (!empty($this->gallery_meta) && !in_array($this->banner_image, $this->gallery_meta)) { |
|
805 | + add_post_meta($id, 'gallery', $this->banner_image, false); |
|
806 | 806 | $this->gallery_meta[] = $this->banner_image; |
807 | 807 | } |
808 | 808 | } |
@@ -812,24 +812,24 @@ discard block |
||
812 | 812 | /** |
813 | 813 | * Creates the main gallery data |
814 | 814 | */ |
815 | - public function create_main_gallery($data,$id) { |
|
815 | + public function create_main_gallery($data, $id) { |
|
816 | 816 | |
817 | - if(is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])){ |
|
817 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
818 | 818 | $counter = 0; |
819 | - foreach($data[0]['content']['images'] as $image_data){ |
|
820 | - if($counter === 0 && false !== $this->featured_image){$counter++;continue;} |
|
821 | - if($counter === 1 && false !== $this->banner_image){$counter++;continue;} |
|
819 | + foreach ($data[0]['content']['images'] as $image_data) { |
|
820 | + if ($counter === 0 && false !== $this->featured_image) {$counter++; continue; } |
|
821 | + if ($counter === 1 && false !== $this->banner_image) {$counter++; continue; } |
|
822 | 822 | |
823 | - $this->gallery_meta[] = $this->attach_image($image_data,$id); |
|
823 | + $this->gallery_meta[] = $this->attach_image($image_data, $id); |
|
824 | 824 | $counter++; |
825 | 825 | } |
826 | 826 | |
827 | - if(!empty($this->gallery_meta)){ |
|
828 | - delete_post_meta($id,'gallery'); |
|
827 | + if (!empty($this->gallery_meta)) { |
|
828 | + delete_post_meta($id, 'gallery'); |
|
829 | 829 | $this->gallery_meta = array_unique($this->gallery_meta); |
830 | - foreach($this->gallery_meta as $gallery_id){ |
|
831 | - if(false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)){ |
|
832 | - add_post_meta($id,'gallery',$gallery_id,false); |
|
830 | + foreach ($this->gallery_meta as $gallery_id) { |
|
831 | + if (false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)) { |
|
832 | + add_post_meta($id, 'gallery', $gallery_id, false); |
|
833 | 833 | } |
834 | 834 | } |
835 | 835 | } |
@@ -839,27 +839,27 @@ discard block |
||
839 | 839 | /** |
840 | 840 | * search_form |
841 | 841 | */ |
842 | - public function get_scaling_url($args=array()) { |
|
842 | + public function get_scaling_url($args = array()) { |
|
843 | 843 | |
844 | 844 | $defaults = array( |
845 | 845 | 'width' => '640', |
846 | 846 | 'height' => '480', |
847 | 847 | 'cropping' => 'c' |
848 | 848 | ); |
849 | - if(false !== $this->options){ |
|
850 | - if(isset($this->options['width']) && '' !== $this->options['width']){ |
|
849 | + if (false !== $this->options) { |
|
850 | + if (isset($this->options['width']) && '' !== $this->options['width']) { |
|
851 | 851 | $defaults['width'] = $this->options['width']; |
852 | 852 | } |
853 | 853 | |
854 | - if(isset($this->options['height']) && '' !== $this->options['height']){ |
|
854 | + if (isset($this->options['height']) && '' !== $this->options['height']) { |
|
855 | 855 | $defaults['height'] = $this->options['height']; |
856 | 856 | } |
857 | 857 | |
858 | - if(isset($this->options['cropping']) && '' !== $this->options['cropping']){ |
|
858 | + if (isset($this->options['cropping']) && '' !== $this->options['cropping']) { |
|
859 | 859 | $defaults['cropping'] = $this->options['cropping']; |
860 | 860 | } |
861 | 861 | } |
862 | - $args = wp_parse_args($args,$defaults); |
|
862 | + $args = wp_parse_args($args, $defaults); |
|
863 | 863 | |
864 | 864 | $cropping = $args['cropping']; |
865 | 865 | $width = $args['width']; |
@@ -872,40 +872,40 @@ discard block |
||
872 | 872 | /** |
873 | 873 | * Attaches 1 image |
874 | 874 | */ |
875 | - public function attach_image($v=false,$parent_id,$image_sizes=false){ |
|
876 | - if(false !== $v){ |
|
877 | - $temp_fragment = explode('/',$v['url_fragment']); |
|
878 | - $url_filename = $temp_fragment[count($temp_fragment)-1]; |
|
879 | - $url_filename = str_replace(array('.jpg','.png','.jpeg'),'',$url_filename); |
|
880 | - |
|
881 | - if(in_array($url_filename,$this->found_attachments)){ |
|
882 | - return array_search($url_filename,$this->found_attachments); |
|
875 | + public function attach_image($v = false, $parent_id, $image_sizes = false) { |
|
876 | + if (false !== $v) { |
|
877 | + $temp_fragment = explode('/', $v['url_fragment']); |
|
878 | + $url_filename = $temp_fragment[count($temp_fragment) - 1]; |
|
879 | + $url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename); |
|
880 | + |
|
881 | + if (in_array($url_filename, $this->found_attachments)) { |
|
882 | + return array_search($url_filename, $this->found_attachments); |
|
883 | 883 | } |
884 | 884 | |
885 | - $postdata=array(); |
|
886 | - if(empty($v['label'])) |
|
885 | + $postdata = array(); |
|
886 | + if (empty($v['label'])) |
|
887 | 887 | { |
888 | - $v['label']=''; |
|
888 | + $v['label'] = ''; |
|
889 | 889 | } |
890 | - if(!empty($v['description'])) |
|
890 | + if (!empty($v['description'])) |
|
891 | 891 | { |
892 | - $desc=wp_strip_all_tags($v['description']); |
|
893 | - $posdata=array('post_excerpt'=>$desc); |
|
892 | + $desc = wp_strip_all_tags($v['description']); |
|
893 | + $posdata = array('post_excerpt'=>$desc); |
|
894 | 894 | } |
895 | - if(!empty($v['section'])) |
|
895 | + if (!empty($v['section'])) |
|
896 | 896 | { |
897 | - $desc=wp_strip_all_tags($v['section']); |
|
898 | - $posdata=array('post_excerpt'=>$desc); |
|
897 | + $desc = wp_strip_all_tags($v['section']); |
|
898 | + $posdata = array('post_excerpt'=>$desc); |
|
899 | 899 | } |
900 | 900 | |
901 | - $attachID=NULL; |
|
901 | + $attachID = NULL; |
|
902 | 902 | //Resizor - add option to setting if required |
903 | - $fragment = str_replace(' ','%20',$v['url_fragment']); |
|
903 | + $fragment = str_replace(' ', '%20', $v['url_fragment']); |
|
904 | 904 | $url = $this->get_scaling_url($image_sizes).$fragment; |
905 | - $attachID = $this->attach_external_image2($url,$parent_id,'',$v['label'],$postdata); |
|
905 | + $attachID = $this->attach_external_image2($url, $parent_id, '', $v['label'], $postdata); |
|
906 | 906 | |
907 | 907 | //echo($attachID.' add image'); |
908 | - if($attachID!=NULL) |
|
908 | + if ($attachID != NULL) |
|
909 | 909 | { |
910 | 910 | return $attachID; |
911 | 911 | } |
@@ -913,13 +913,13 @@ discard block |
||
913 | 913 | return false; |
914 | 914 | } |
915 | 915 | |
916 | - public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) { |
|
916 | + public function attach_external_image2($url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array()) { |
|
917 | 917 | |
918 | - if ( !$url || !$post_id ) { return new WP_Error('missing', "Need a valid URL and post ID..."); } |
|
918 | + if (!$url || !$post_id) { return new WP_Error('missing', "Need a valid URL and post ID..."); } |
|
919 | 919 | |
920 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
921 | - require_once(ABSPATH . 'wp-admin/includes/media.php'); |
|
922 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
920 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
921 | + require_once(ABSPATH.'wp-admin/includes/media.php'); |
|
922 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
923 | 923 | // Download file to temp location, returns full server path to temp file |
924 | 924 | //$tmp = download_url( $url ); |
925 | 925 | |
@@ -928,53 +928,53 @@ discard block |
||
928 | 928 | |
929 | 929 | $image = file_get_contents($url); |
930 | 930 | file_put_contents($tmp, $image); |
931 | - chmod($tmp,'777'); |
|
931 | + chmod($tmp, '777'); |
|
932 | 932 | |
933 | - 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 |
|
933 | + 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 |
|
934 | 934 | $url_filename = basename($matches[0]); |
935 | - $url_filename=str_replace('%20','_',$url_filename); |
|
935 | + $url_filename = str_replace('%20', '_', $url_filename); |
|
936 | 936 | // extract filename from url for title |
937 | - $url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type) |
|
937 | + $url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type) |
|
938 | 938 | |
939 | 939 | // override filename if given, reconstruct server path |
940 | - if ( !empty( $filename ) && " " != $filename ) |
|
940 | + if (!empty($filename) && " " != $filename) |
|
941 | 941 | { |
942 | 942 | $filename = sanitize_file_name($filename); |
943 | - $tmppath = pathinfo( $tmp ); |
|
943 | + $tmppath = pathinfo($tmp); |
|
944 | 944 | |
945 | 945 | $extension = ''; |
946 | - if(isset($tmppath['extension'])){ |
|
946 | + if (isset($tmppath['extension'])) { |
|
947 | 947 | $extension = $tmppath['extension']; |
948 | 948 | } |
949 | 949 | |
950 | - $new = $tmppath['dirname'] . "/". $filename . "." . $extension; |
|
951 | - rename($tmp, $new); // renames temp file on server |
|
952 | - $tmp = $new; // push new filename (in path) to be used in file array later |
|
950 | + $new = $tmppath['dirname']."/".$filename.".".$extension; |
|
951 | + rename($tmp, $new); // renames temp file on server |
|
952 | + $tmp = $new; // push new filename (in path) to be used in file array later |
|
953 | 953 | } |
954 | 954 | |
955 | 955 | // assemble file data (should be built like $_FILES since wp_handle_sideload() will be using) |
956 | - $file_array['tmp_name'] = $tmp; // full server path to temp file |
|
956 | + $file_array['tmp_name'] = $tmp; // full server path to temp file |
|
957 | 957 | |
958 | - if ( !empty( $filename) && " " != $filename ) |
|
958 | + if (!empty($filename) && " " != $filename) |
|
959 | 959 | { |
960 | - $file_array['name'] = $filename . "." . $url_type['ext']; // user given filename for title, add original URL extension |
|
960 | + $file_array['name'] = $filename.".".$url_type['ext']; // user given filename for title, add original URL extension |
|
961 | 961 | } |
962 | 962 | else |
963 | 963 | { |
964 | - $file_array['name'] = $url_filename; // just use original URL filename |
|
964 | + $file_array['name'] = $url_filename; // just use original URL filename |
|
965 | 965 | } |
966 | 966 | |
967 | 967 | // set additional wp_posts columns |
968 | - if ( empty( $post_data['post_title'] ) ) |
|
968 | + if (empty($post_data['post_title'])) |
|
969 | 969 | { |
970 | 970 | |
971 | - $url_filename=str_replace('%20',' ',$url_filename); |
|
971 | + $url_filename = str_replace('%20', ' ', $url_filename); |
|
972 | 972 | |
973 | - $post_data['post_title'] = basename($url_filename, "." . $url_type['ext']); // just use the original filename (no extension) |
|
973 | + $post_data['post_title'] = basename($url_filename, ".".$url_type['ext']); // just use the original filename (no extension) |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | // make sure gets tied to parent |
977 | - if ( empty( $post_data['post_parent'] ) ) |
|
977 | + if (empty($post_data['post_parent'])) |
|
978 | 978 | { |
979 | 979 | $post_data['post_parent'] = $post_id; |
980 | 980 | } |
@@ -982,12 +982,12 @@ discard block |
||
982 | 982 | // required libraries for media_handle_sideload |
983 | 983 | |
984 | 984 | // do the validation and storage stuff |
985 | - $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 |
|
985 | + $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 |
|
986 | 986 | |
987 | 987 | // If error storing permanently, unlink |
988 | - if ( is_wp_error($att_id) ) |
|
988 | + if (is_wp_error($att_id)) |
|
989 | 989 | { |
990 | - unlink($file_array['tmp_name']); // clean up |
|
990 | + unlink($file_array['tmp_name']); // clean up |
|
991 | 991 | return false; // output wp_error |
992 | 992 | //return $att_id; // output wp_error |
993 | 993 | } |
@@ -1015,24 +1015,24 @@ discard block |
||
1015 | 1015 | /** |
1016 | 1016 | * Formats the row for the completed list. |
1017 | 1017 | */ |
1018 | - public function format_completed_row($response){ |
|
1018 | + public function format_completed_row($response) { |
|
1019 | 1019 | echo '<li class="post-'.$response.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($response).'">'.get_the_title($response).'</a></li>'; |
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | /** |
1023 | 1023 | * Does a multine search |
1024 | 1024 | */ |
1025 | - public function multineedle_stripos($haystack, $needles, $offset=0) { |
|
1025 | + public function multineedle_stripos($haystack, $needles, $offset = 0) { |
|
1026 | 1026 | $found = false; |
1027 | 1027 | $needle_count = count($needles); |
1028 | - foreach($needles as $needle) { |
|
1029 | - if(false !== stripos($haystack, $needle, $offset)){ |
|
1028 | + foreach ($needles as $needle) { |
|
1029 | + if (false !== stripos($haystack, $needle, $offset)) { |
|
1030 | 1030 | $found[] = true; |
1031 | 1031 | } |
1032 | 1032 | } |
1033 | - if(false !== $found && $needle_count === count($found)){ |
|
1033 | + if (false !== $found && $needle_count === count($found)) { |
|
1034 | 1034 | return true; |
1035 | - }else{ |
|
1035 | + }else { |
|
1036 | 1036 | return false; |
1037 | 1037 | } |
1038 | 1038 | } |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | /** |
1041 | 1041 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
1042 | 1042 | */ |
1043 | - public function find_current_accommodation($post_type='accommodation') { |
|
1043 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
1044 | 1044 | global $wpdb; |
1045 | 1045 | $return = array(); |
1046 | 1046 | |
@@ -1056,8 +1056,8 @@ discard block |
||
1056 | 1056 | |
1057 | 1057 | LIMIT 0,500 |
1058 | 1058 | "); |
1059 | - if(null !== $current_accommodation && !empty($current_accommodation)){ |
|
1060 | - foreach($current_accommodation as $accom){ |
|
1059 | + if (null !== $current_accommodation && !empty($current_accommodation)) { |
|
1060 | + foreach ($current_accommodation as $accom) { |
|
1061 | 1061 | $return[$accom->meta_value] = $accom; |
1062 | 1062 | } |
1063 | 1063 | } |