@@ -76,17 +76,17 @@ discard block |
||
| 76 | 76 | // $this->url = 'https://wetu.com/API/Pins/'; |
| 77 | 77 | // $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
| 78 | 78 | //} elseif ( false !== $this->api_key ) { |
| 79 | - $this->url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
| 79 | + $this->url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
| 80 | 80 | $this->url_qs = 'all=include'; |
| 81 | 81 | //} |
| 82 | 82 | |
| 83 | - $temp_options = get_option('_lsx-to_settings',false); |
|
| 84 | - if(false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])){ |
|
| 83 | + $temp_options = get_option('_lsx-to_settings', false); |
|
| 84 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
| 85 | 85 | $this->options = $temp_options[$this->plugin_slug]; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - $accommodation_options = get_option('wetu_importer_accommodation_settings',false); |
|
| 89 | - if(false !== $accommodation_options){ |
|
| 88 | + $accommodation_options = get_option('wetu_importer_accommodation_settings', false); |
|
| 89 | + if (false !== $accommodation_options) { |
|
| 90 | 90 | $this->accommodation_options = $accommodation_options; |
| 91 | 91 | } |
| 92 | 92 | } |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | <form method="get" action="" id="posts-filter"> |
| 107 | 107 | <input type="hidden" name="post_type" class="post_type" value="<?php echo $this->tab_slug; ?>" /> |
| 108 | 108 | |
| 109 | - <p><input class="button button-primary add" type="button" value="<?php _e('Add to List','wetu-importer'); ?>" /> |
|
| 110 | - <input class="button button-primary clear" type="button" value="<?php _e('Clear','wetu-importer'); ?>" /> |
|
| 109 | + <p><input class="button button-primary add" type="button" value="<?php _e('Add to List', 'wetu-importer'); ?>" /> |
|
| 110 | + <input class="button button-primary clear" type="button" value="<?php _e('Clear', 'wetu-importer'); ?>" /> |
|
| 111 | 111 | </p> |
| 112 | 112 | |
| 113 | 113 | <table class="wp-list-table widefat fixed posts"> |
@@ -116,11 +116,11 @@ discard block |
||
| 116 | 116 | <tbody id="the-list"> |
| 117 | 117 | <tr class="post-0 type-tour status-none" id="post-0"> |
| 118 | 118 | <th class="check-column" scope="row"> |
| 119 | - <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter','wetu-importer'); ?></label> |
|
| 119 | + <label for="cb-select-0" class="screen-reader-text"><?php _e('Enter a title to search for and press enter', 'wetu-importer'); ?></label> |
|
| 120 | 120 | </th> |
| 121 | 121 | <td class="post-title page-title column-title"> |
| 122 | 122 | <strong> |
| 123 | - <?php _e('Enter a title to search for','wetu-importer'); ?> |
|
| 123 | + <?php _e('Enter a title to search for', 'wetu-importer'); ?> |
|
| 124 | 124 | </strong> |
| 125 | 125 | </td> |
| 126 | 126 | <td class="date column-date"> |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | </table> |
| 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 | </form> |
| 141 | 141 | |
@@ -147,32 +147,32 @@ discard block |
||
| 147 | 147 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 148 | 148 | <h3><?php _e('What content to Sync from WETU'); ?></h3> |
| 149 | 149 | <ul> |
| 150 | - <li><input class="content select-all" <?php $this->checked($this->accommodation_options,'all'); ?> type="checkbox"name="content[]" value="all" /> <?php _e('Select All','wetu-importer'); ?></li> |
|
| 151 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php _e('Description','wetu-importer'); ?></li> |
|
| 152 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt','wetu-importer'); ?></li> |
|
| 153 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery','wetu-importer'); ?></li> |
|
| 154 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php _e('Category','wetu-importer'); ?></li> |
|
| 155 | - <?php if(class_exists('LSX_TO_Maps')){ ?> |
|
| 156 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php _e('Location','wetu-importer'); ?></li> |
|
| 150 | + <li><input class="content select-all" <?php $this->checked($this->accommodation_options, 'all'); ?> type="checkbox"name="content[]" value="all" /> <?php _e('Select All', 'wetu-importer'); ?></li> |
|
| 151 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php _e('Description', 'wetu-importer'); ?></li> |
|
| 152 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php _e('Excerpt', 'wetu-importer'); ?></li> |
|
| 153 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php _e('Main Gallery', 'wetu-importer'); ?></li> |
|
| 154 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php _e('Category', 'wetu-importer'); ?></li> |
|
| 155 | + <?php if (class_exists('LSX_TO_Maps')) { ?> |
|
| 156 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php _e('Location', 'wetu-importer'); ?></li> |
|
| 157 | 157 | <?php } ?> |
| 158 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php _e('Connect Destinations','wetu-importer'); ?></li> |
|
| 159 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php _e('Check In / Check Out','wetu-importer'); ?></li> |
|
| 160 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php _e('Facilities','wetu-importer'); ?></li> |
|
| 161 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php _e('Friendly','wetu-importer'); ?></li> |
|
| 162 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php _e('Rating','wetu-importer'); ?></li> |
|
| 163 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php _e('Rooms','wetu-importer'); ?></li> |
|
| 164 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php _e('Special Interests','wetu-importer'); ?></li> |
|
| 165 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php _e('Spoken Languages','wetu-importer'); ?></li> |
|
| 166 | - |
|
| 167 | - <?php if(class_exists('LSX_TO_Videos')){ ?> |
|
| 168 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos','wetu-importer'); ?></li> |
|
| 158 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php _e('Connect Destinations', 'wetu-importer'); ?></li> |
|
| 159 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php _e('Check In / Check Out', 'wetu-importer'); ?></li> |
|
| 160 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php _e('Facilities', 'wetu-importer'); ?></li> |
|
| 161 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php _e('Friendly', 'wetu-importer'); ?></li> |
|
| 162 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php _e('Rating', 'wetu-importer'); ?></li> |
|
| 163 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php _e('Rooms', 'wetu-importer'); ?></li> |
|
| 164 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php _e('Special Interests', 'wetu-importer'); ?></li> |
|
| 165 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php _e('Spoken Languages', 'wetu-importer'); ?></li> |
|
| 166 | + |
|
| 167 | + <?php if (class_exists('LSX_TO_Videos')) { ?> |
|
| 168 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php _e('Videos', 'wetu-importer'); ?></li> |
|
| 169 | 169 | <?php } ?> |
| 170 | 170 | </ul> |
| 171 | 171 | <h4><?php _e('Additional Content'); ?></h4> |
| 172 | 172 | <ul> |
| 173 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image','wetu-importer'); ?></li> |
|
| 174 | - <?php if(class_exists('LSX_Banners')){ ?> |
|
| 175 | - <li><input class="content" checked="<?php $this->checked($this->accommodation_options,'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image','wetu-importer'); ?></li> |
|
| 173 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php _e('Set Featured Image', 'wetu-importer'); ?></li> |
|
| 174 | + <?php if (class_exists('LSX_Banners')) { ?> |
|
| 175 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php _e('Set Banner Image', 'wetu-importer'); ?></li> |
|
| 176 | 176 | <?php } ?> |
| 177 | 177 | </ul> |
| 178 | 178 | </div> |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | <div style="width:30%;display:block;float:left;"> |
| 185 | 185 | <h3><?php _e('Assign a Safari Brand'); ?></h3> |
| 186 | - <?php echo $this->taxonomy_checkboxes('accommodation-brand',$this->accommodation_options); ?> |
|
| 186 | + <?php echo $this->taxonomy_checkboxes('accommodation-brand', $this->accommodation_options); ?> |
|
| 187 | 187 | </div> |
| 188 | 188 | |
| 189 | 189 | <br clear="both" /> |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | |
| 193 | 193 | <h3><?php _e('Your List'); ?></h3> |
| 194 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
| 194 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
| 195 | 195 | <table class="wp-list-table widefat fixed posts"> |
| 196 | 196 | <?php $this->table_header(); ?> |
| 197 | 197 | |
@@ -203,12 +203,12 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | </table> |
| 205 | 205 | |
| 206 | - <p><input class="button button-primary" type="submit" value="<?php _e('Sync','wetu-importer'); ?>" /></p> |
|
| 206 | + <p><input class="button button-primary" type="submit" value="<?php _e('Sync', 'wetu-importer'); ?>" /></p> |
|
| 207 | 207 | </form> |
| 208 | 208 | </div> |
| 209 | 209 | |
| 210 | 210 | <div style="display:none;" class="completed-list-wrapper"> |
| 211 | - <h3><?php _e('Completed'); ?> - <small><?php _e('Import your','wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations'); ?></a> <?php _e('next','wetu-importer'); ?></small></h3> |
|
| 211 | + <h3><?php _e('Completed'); ?> - <small><?php _e('Import your', 'wetu-importer'); ?> <a href="<?php echo admin_url('admin.php'); ?>?page=<?php echo $this->plugin_slug; ?>&tab=destination"><?php _e('destinations'); ?></a> <?php _e('next', 'wetu-importer'); ?></small></h3> |
|
| 212 | 212 | <ul> |
| 213 | 213 | </ul> |
| 214 | 214 | </div> |
@@ -220,9 +220,9 @@ discard block |
||
| 220 | 220 | * search_form |
| 221 | 221 | */ |
| 222 | 222 | public function update_options_form() { |
| 223 | - echo '<div style="display:none;" class="wetu-status"><h3>'.__('Wetu Status','wetu-importer').'</h3>'; |
|
| 223 | + echo '<div style="display:none;" class="wetu-status"><h3>'.__('Wetu Status', 'wetu-importer').'</h3>'; |
|
| 224 | 224 | $accommodation = get_transient('lsx_ti_accommodation'); |
| 225 | - if('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])){ |
|
| 225 | + if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) { |
|
| 226 | 226 | $this->update_options(); |
| 227 | 227 | } |
| 228 | 228 | echo '</div>'; |
@@ -232,13 +232,13 @@ discard block |
||
| 232 | 232 | * Save the list of Accommodation into an option |
| 233 | 233 | */ |
| 234 | 234 | public function update_options() { |
| 235 | - $data = file_get_contents( $this->url . '/List?' . $this->url_qs ); |
|
| 235 | + $data = file_get_contents($this->url.'/List?'.$this->url_qs); |
|
| 236 | 236 | $accommodation = json_decode($data, true); |
| 237 | 237 | |
| 238 | - if(isset($accommodation['error'])){ |
|
| 238 | + if (isset($accommodation['error'])) { |
|
| 239 | 239 | return $accommodation['error']; |
| 240 | 240 | }elseif (isset($accommodation) && !empty($accommodation)) { |
| 241 | - set_transient('lsx_ti_accommodation',$accommodation,60*60*2); |
|
| 241 | + set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2); |
|
| 242 | 242 | return true; |
| 243 | 243 | } |
| 244 | 244 | } |
@@ -249,41 +249,41 @@ discard block |
||
| 249 | 249 | public function process_ajax_search() { |
| 250 | 250 | $return = false; |
| 251 | 251 | |
| 252 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation'){ |
|
| 252 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation') { |
|
| 253 | 253 | $accommodation = get_transient('lsx_ti_accommodation'); |
| 254 | 254 | |
| 255 | - if(false === $accommodation){ |
|
| 255 | + if (false === $accommodation) { |
|
| 256 | 256 | $this->update_options(); |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - if ( false !== $accommodation ) { |
|
| 259 | + if (false !== $accommodation) { |
|
| 260 | 260 | $searched_items = false; |
| 261 | 261 | |
| 262 | - if(isset($_POST['keyword'] )) { |
|
| 262 | + if (isset($_POST['keyword'])) { |
|
| 263 | 263 | $keyphrases = $_POST['keyword']; |
| 264 | - }else{ |
|
| 264 | + }else { |
|
| 265 | 265 | $keyphrases = array(0); |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if(!is_array($keyphrases)){ |
|
| 268 | + if (!is_array($keyphrases)) { |
|
| 269 | 269 | $keyphrases = array($keyphrases); |
| 270 | 270 | } |
| 271 | - foreach($keyphrases as &$keyword){ |
|
| 271 | + foreach ($keyphrases as &$keyword) { |
|
| 272 | 272 | $keyword = ltrim(rtrim($keyword)); |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | |
| 276 | 276 | $post_status = false; |
| 277 | - if(in_array('publish',$keyphrases)){ |
|
| 277 | + if (in_array('publish', $keyphrases)) { |
|
| 278 | 278 | $post_status = 'publish'; |
| 279 | 279 | } |
| 280 | - if(in_array('pending',$keyphrases)){ |
|
| 280 | + if (in_array('pending', $keyphrases)) { |
|
| 281 | 281 | $post_status = 'pending'; |
| 282 | 282 | } |
| 283 | - if(in_array('draft',$keyphrases)){ |
|
| 283 | + if (in_array('draft', $keyphrases)) { |
|
| 284 | 284 | $post_status = 'draft'; |
| 285 | 285 | } |
| 286 | - if(in_array('import',$keyphrases)){ |
|
| 286 | + if (in_array('import', $keyphrases)) { |
|
| 287 | 287 | $post_status = 'import'; |
| 288 | 288 | } |
| 289 | 289 | |
@@ -291,32 +291,32 @@ discard block |
||
| 291 | 291 | |
| 292 | 292 | $current_accommodation = $this->find_current_accommodation(); |
| 293 | 293 | |
| 294 | - foreach($accommodation as $row_key => $row){ |
|
| 294 | + foreach ($accommodation as $row_key => $row) { |
|
| 295 | 295 | |
| 296 | 296 | //If this is a current tour, add its ID to the row. |
| 297 | 297 | $row['post_id'] = 0; |
| 298 | - if(false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)){ |
|
| 298 | + if (false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)) { |
|
| 299 | 299 | $row['post_id'] = $current_accommodation[$row['id']]->post_id; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | //If we are searching for |
| 303 | - if(false !== $post_status){ |
|
| 303 | + if (false !== $post_status) { |
|
| 304 | 304 | |
| 305 | - if('import' === $post_status){ |
|
| 305 | + if ('import' === $post_status) { |
|
| 306 | 306 | |
| 307 | - if(is_array($this->queued_imports) && in_array($row['post_id'],$this->queued_imports)){ |
|
| 307 | + if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) { |
|
| 308 | 308 | $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
| 309 | - }else{ |
|
| 309 | + }else { |
|
| 310 | 310 | continue; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - }else{ |
|
| 313 | + }else { |
|
| 314 | 314 | |
| 315 | - if(0 === $row['post_id']){ |
|
| 315 | + if (0 === $row['post_id']) { |
|
| 316 | 316 | continue; |
| 317 | - }else{ |
|
| 317 | + }else { |
|
| 318 | 318 | $current_status = get_post_status($row['post_id']); |
| 319 | - if($current_status !== $post_status){ |
|
| 319 | + if ($current_status !== $post_status) { |
|
| 320 | 320 | continue; |
| 321 | 321 | } |
| 322 | 322 | |
@@ -324,17 +324,17 @@ discard block |
||
| 324 | 324 | $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - }else{ |
|
| 327 | + }else { |
|
| 328 | 328 | //Search through each keyword. |
| 329 | - foreach($keyphrases as $keyphrase){ |
|
| 329 | + foreach ($keyphrases as $keyphrase) { |
|
| 330 | 330 | |
| 331 | 331 | //Make sure the keyphrase is turned into an array |
| 332 | - $keywords = explode(" ",$keyphrase); |
|
| 333 | - if(!is_array($keywords)){ |
|
| 332 | + $keywords = explode(" ", $keyphrase); |
|
| 333 | + if (!is_array($keywords)) { |
|
| 334 | 334 | $keywords = array($keywords); |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - if($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false){ |
|
| 337 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
| 338 | 338 | $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
| 339 | 339 | } |
| 340 | 340 | } |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | |
| 346 | - if(false !== $searched_items){ |
|
| 346 | + if (false !== $searched_items) { |
|
| 347 | 347 | ksort($searched_items); |
| 348 | 348 | $return = implode($searched_items); |
| 349 | 349 | } |
@@ -355,11 +355,11 @@ discard block |
||
| 355 | 355 | /** |
| 356 | 356 | * Formats the row for output on the screen. |
| 357 | 357 | */ |
| 358 | - public function format_row($row = false){ |
|
| 359 | - if(false !== $row){ |
|
| 358 | + public function format_row($row = false) { |
|
| 359 | + if (false !== $row) { |
|
| 360 | 360 | |
| 361 | 361 | $status = 'import'; |
| 362 | - if(0 !== $row['post_id']){ |
|
| 362 | + if (0 !== $row['post_id']) { |
|
| 363 | 363 | $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
| 364 | 364 | } |
| 365 | 365 | |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | <strong>'.$row['name'].'</strong> - '.$status.' |
| 374 | 374 | </td> |
| 375 | 375 | <td class="date column-date"> |
| 376 | - <abbr title="'.date('Y/m/d',strtotime($row['last_modified'])).'">'.date('Y/m/d',strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
| 376 | + <abbr title="'.date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
| 377 | 377 | </td> |
| 378 | 378 | <td class="ssid column-ssid"> |
| 379 | 379 | '.$row['id'].' |
@@ -389,11 +389,11 @@ discard block |
||
| 389 | 389 | public function remove_from_queue($id) { |
| 390 | 390 | if (!empty($this->queued_imports)) { |
| 391 | 391 | |
| 392 | - if(($key = array_search($id, $this->queued_imports)) !== false) { |
|
| 392 | + if (($key = array_search($id, $this->queued_imports)) !== false) { |
|
| 393 | 393 | unset($this->queued_imports[$key]); |
| 394 | 394 | |
| 395 | 395 | delete_option('wetu_importer_que'); |
| 396 | - update_option('wetu_importer_que',$this->queued_imports); |
|
| 396 | + update_option('wetu_importer_que', $this->queued_imports); |
|
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | } |
@@ -403,43 +403,43 @@ discard block |
||
| 403 | 403 | */ |
| 404 | 404 | public function process_ajax_import() { |
| 405 | 405 | $return = false; |
| 406 | - if(isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])){ |
|
| 406 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])) { |
|
| 407 | 407 | |
| 408 | 408 | $wetu_id = $_POST['wetu_id']; |
| 409 | - if(isset($_POST['post_id'])){ |
|
| 409 | + if (isset($_POST['post_id'])) { |
|
| 410 | 410 | $post_id = $_POST['post_id']; |
| 411 | - }else{ |
|
| 411 | + }else { |
|
| 412 | 412 | $post_id = 0; |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - if(isset($_POST['team_members'])){ |
|
| 415 | + if (isset($_POST['team_members'])) { |
|
| 416 | 416 | $team_members = $_POST['team_members']; |
| 417 | - }else{ |
|
| 417 | + }else { |
|
| 418 | 418 | $team_members = false; |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - if(isset($_POST['safari_brands'])){ |
|
| 421 | + if (isset($_POST['safari_brands'])) { |
|
| 422 | 422 | $safari_brands = $_POST['safari_brands']; |
| 423 | - }else{ |
|
| 423 | + }else { |
|
| 424 | 424 | $safari_brands = false; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | delete_option('wetu_importer_accommodation_settings'); |
| 428 | - if(isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])){ |
|
| 428 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
| 429 | 429 | $content = $_POST['content']; |
| 430 | - add_option('wetu_importer_accommodation_settings',$content); |
|
| 431 | - }else{ |
|
| 430 | + add_option('wetu_importer_accommodation_settings', $content); |
|
| 431 | + }else { |
|
| 432 | 432 | |
| 433 | 433 | $content = false; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
| 437 | - if($jdata) |
|
| 436 | + $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id); |
|
| 437 | + if ($jdata) |
|
| 438 | 438 | { |
| 439 | - $adata=json_decode($jdata,true); |
|
| 440 | - if(!empty($adata)) |
|
| 439 | + $adata = json_decode($jdata, true); |
|
| 440 | + if (!empty($adata)) |
|
| 441 | 441 | { |
| 442 | - $return = $this->import_row($adata,$wetu_id,$post_id,$team_members,$content,$safari_brands); |
|
| 442 | + $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
|
| 443 | 443 | $this->format_completed_row($return); |
| 444 | 444 | $this->remove_from_queue($return); |
| 445 | 445 | $this->cleanup_posts(); |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | /** |
| 452 | 452 | * Connect to wetu |
| 453 | 453 | */ |
| 454 | - public function import_row($data,$wetu_id,$id=0,$team_members=false,$importable_content=false,$safari_brands=false) { |
|
| 454 | + public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false) { |
|
| 455 | 455 | |
| 456 | 456 | |
| 457 | 457 | $post_name = $data_post_content = $data_post_excerpt = ''; |
@@ -462,44 +462,44 @@ discard block |
||
| 462 | 462 | $content_used_general_description = false; |
| 463 | 463 | |
| 464 | 464 | //Set the post_content |
| 465 | - if(false !== $importable_content && in_array('description',$importable_content)){ |
|
| 466 | - if(isset($data[0]['content']['extended_description'])) |
|
| 465 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
| 466 | + if (isset($data[0]['content']['extended_description'])) |
|
| 467 | 467 | { |
| 468 | 468 | $data_post_content = $data[0]['content']['extended_description']; |
| 469 | - }elseif(isset($data[0]['content']['general_description'])){ |
|
| 469 | + }elseif (isset($data[0]['content']['general_description'])) { |
|
| 470 | 470 | $data_post_content = $data[0]['content']['general_description']; |
| 471 | 471 | $content_used_general_description = true; |
| 472 | - }elseif(isset($data[0]['content']['teaser_description'])){ |
|
| 472 | + }elseif (isset($data[0]['content']['teaser_description'])) { |
|
| 473 | 473 | $data_post_content = $data[0]['content']['teaser_description']; |
| 474 | 474 | } |
| 475 | 475 | $post['post_content'] = wp_strip_all_tags($data_post_content); |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | //set the post_excerpt |
| 479 | - if(false !== $importable_content && in_array('excerpt',$importable_content)){ |
|
| 480 | - if(isset($data[0]['content']['teaser_description'])){ |
|
| 479 | + if (false !== $importable_content && in_array('excerpt', $importable_content)) { |
|
| 480 | + if (isset($data[0]['content']['teaser_description'])) { |
|
| 481 | 481 | $data_post_excerpt = $data[0]['content']['teaser_description']; |
| 482 | - }elseif(isset($data[0]['content']['general_description']) && false === $content_used_general_description){ |
|
| 482 | + }elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) { |
|
| 483 | 483 | $data_post_excerpt = $data[0]['content']['general_description']; |
| 484 | 484 | } |
| 485 | 485 | $post['post_excerpt'] = $data_post_excerpt; |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - if(false !== $id && '0' !== $id){ |
|
| 488 | + if (false !== $id && '0' !== $id) { |
|
| 489 | 489 | $post['ID'] = $id; |
| 490 | - if(isset($data[0]['name'])){ |
|
| 490 | + if (isset($data[0]['name'])) { |
|
| 491 | 491 | $post['post_title'] = $data[0]['name']; |
| 492 | 492 | $post['post_status'] = 'publish'; |
| 493 | - $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
| 493 | + $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0); |
|
| 494 | 494 | } |
| 495 | 495 | $id = wp_update_post($post); |
| 496 | - $prev_date = get_post_meta($id,'lsx_wetu_modified_date',true); |
|
| 497 | - update_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified']),$prev_date); |
|
| 498 | - }else{ |
|
| 496 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
| 497 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date); |
|
| 498 | + }else { |
|
| 499 | 499 | |
| 500 | 500 | //Set the name |
| 501 | - if(isset($data[0]['name'])){ |
|
| 502 | - $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']),$id, 'draft', 'accommodation', 0); |
|
| 501 | + if (isset($data[0]['name'])) { |
|
| 502 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0); |
|
| 503 | 503 | } |
| 504 | 504 | $post['post_name'] = $post_name; |
| 505 | 505 | $post['post_title'] = $data[0]['name']; |
@@ -507,89 +507,89 @@ discard block |
||
| 507 | 507 | $id = wp_insert_post($post); |
| 508 | 508 | |
| 509 | 509 | //Save the WETU ID and the Last date it was modified. |
| 510 | - if(false !== $id){ |
|
| 511 | - add_post_meta($id,'lsx_wetu_id',$wetu_id); |
|
| 512 | - add_post_meta($id,'lsx_wetu_modified_date',strtotime($data[0]['last_modified'])); |
|
| 510 | + if (false !== $id) { |
|
| 511 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
| 512 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified'])); |
|
| 513 | 513 | } |
| 514 | 514 | } |
| 515 | 515 | //Setup some default for use in the import |
| 516 | - if(false !== $importable_content && (in_array('gallery',$importable_content) || in_array('banner_image',$importable_content) || in_array('featured_image',$importable_content))){ |
|
| 516 | + if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) { |
|
| 517 | 517 | $this->find_attachments($id); |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | //Set the team member if it is there |
| 521 | - if(post_type_exists('team') && false !== $team_members && '' !== $team_members){ |
|
| 522 | - $this->set_team_member($id,$team_members); |
|
| 521 | + if (post_type_exists('team') && false !== $team_members && '' !== $team_members) { |
|
| 522 | + $this->set_team_member($id, $team_members); |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | //Set the safari brand |
| 526 | - if(false !== $safari_brands && '' !== $safari_brands){ |
|
| 527 | - $this->set_safari_brands($id,$safari_brands); |
|
| 526 | + if (false !== $safari_brands && '' !== $safari_brands) { |
|
| 527 | + $this->set_safari_brands($id, $safari_brands); |
|
| 528 | 528 | |
| 529 | 529 | } |
| 530 | 530 | |
| 531 | - if(class_exists('LSX_TO_Maps')){ |
|
| 532 | - $this->set_map_data($data,$id,9); |
|
| 531 | + if (class_exists('LSX_TO_Maps')) { |
|
| 532 | + $this->set_map_data($data, $id, 9); |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - if(post_type_exists('destination') && false !== $importable_content && in_array('destination',$importable_content)){ |
|
| 536 | - $this->connect_destinations($data,$id); |
|
| 535 | + if (post_type_exists('destination') && false !== $importable_content && in_array('destination', $importable_content)) { |
|
| 536 | + $this->connect_destinations($data, $id); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - if(false !== $importable_content && in_array('category',$importable_content)){ |
|
| 540 | - $this->set_taxonomy_style($data,$id); |
|
| 539 | + if (false !== $importable_content && in_array('category', $importable_content)) { |
|
| 540 | + $this->set_taxonomy_style($data, $id); |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | //Set the Room Data |
| 544 | - if(false !== $importable_content && in_array('rooms',$importable_content)){ |
|
| 545 | - $this->set_room_data($data,$id); |
|
| 544 | + if (false !== $importable_content && in_array('rooms', $importable_content)) { |
|
| 545 | + $this->set_room_data($data, $id); |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | //Set the rating |
| 549 | - if(false !== $importable_content && in_array('rating',$importable_content)){ |
|
| 550 | - $this->set_rating($data,$id); |
|
| 549 | + if (false !== $importable_content && in_array('rating', $importable_content)) { |
|
| 550 | + $this->set_rating($data, $id); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | //Set the checkin checkout data |
| 554 | - if(false !== $importable_content && in_array('checkin',$importable_content)){ |
|
| 555 | - $this->set_checkin_checkout($data,$id); |
|
| 554 | + if (false !== $importable_content && in_array('checkin', $importable_content)) { |
|
| 555 | + $this->set_checkin_checkout($data, $id); |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | //Set the Spoken Languages |
| 559 | - if(false !== $importable_content && in_array('spoken_languages',$importable_content)){ |
|
| 560 | - $this->set_spoken_languages($data,$id); |
|
| 559 | + if (false !== $importable_content && in_array('spoken_languages', $importable_content)) { |
|
| 560 | + $this->set_spoken_languages($data, $id); |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | //Set the friendly options |
| 564 | - if(false !== $importable_content && in_array('friendly',$importable_content)){ |
|
| 565 | - $this->set_friendly($data,$id); |
|
| 564 | + if (false !== $importable_content && in_array('friendly', $importable_content)) { |
|
| 565 | + $this->set_friendly($data, $id); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | //Set the special_interests |
| 569 | - if(false !== $importable_content && in_array('special_interests',$importable_content)){ |
|
| 570 | - $this->set_special_interests($data,$id); |
|
| 569 | + if (false !== $importable_content && in_array('special_interests', $importable_content)) { |
|
| 570 | + $this->set_special_interests($data, $id); |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | //Import the videos |
| 574 | - if(false !== $importable_content && in_array('videos',$importable_content)){ |
|
| 575 | - $this->set_video_data($data,$id); |
|
| 574 | + if (false !== $importable_content && in_array('videos', $importable_content)) { |
|
| 575 | + $this->set_video_data($data, $id); |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | //Import the facilities |
| 579 | - if(false !== $importable_content && in_array('facilities',$importable_content)){ |
|
| 580 | - $this->set_facilities($data,$id); |
|
| 579 | + if (false !== $importable_content && in_array('facilities', $importable_content)) { |
|
| 580 | + $this->set_facilities($data, $id); |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | //Set the featured image |
| 584 | - if(false !== $importable_content && in_array('featured_image',$importable_content)){ |
|
| 585 | - $this->set_featured_image($data,$id); |
|
| 584 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
| 585 | + $this->set_featured_image($data, $id); |
|
| 586 | 586 | } |
| 587 | - if(false !== $importable_content && in_array('banner_image',$importable_content)){ |
|
| 588 | - $this->set_banner_image($data,$id); |
|
| 587 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
| 588 | + $this->set_banner_image($data, $id); |
|
| 589 | 589 | } |
| 590 | 590 | //Import the main gallery |
| 591 | - if(false !== $importable_content && in_array('gallery',$importable_content)){ |
|
| 592 | - $this->create_main_gallery($data,$id); |
|
| 591 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
| 592 | + $this->create_main_gallery($data, $id); |
|
| 593 | 593 | } |
| 594 | 594 | return $id; |
| 595 | 595 | } |
@@ -597,50 +597,50 @@ discard block |
||
| 597 | 597 | /** |
| 598 | 598 | * Set the team memberon each item. |
| 599 | 599 | */ |
| 600 | - public function set_team_member($id,$team_members) { |
|
| 600 | + public function set_team_member($id, $team_members) { |
|
| 601 | 601 | |
| 602 | 602 | delete_post_meta($id, 'team_to_'.$this->tab_slug); |
| 603 | - foreach($team_members as $team){ |
|
| 604 | - add_post_meta($id,'team_to_'.$this->tab_slug,$team); |
|
| 603 | + foreach ($team_members as $team) { |
|
| 604 | + add_post_meta($id, 'team_to_'.$this->tab_slug, $team); |
|
| 605 | 605 | } |
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | /** |
| 609 | 609 | * Set the safari brand |
| 610 | 610 | */ |
| 611 | - public function set_safari_brands($id,$safari_brands) { |
|
| 612 | - foreach($safari_brands as $safari_brand){ |
|
| 613 | - wp_set_object_terms( $id, intval($safari_brand), 'accommodation-brand',true); |
|
| 611 | + public function set_safari_brands($id, $safari_brands) { |
|
| 612 | + foreach ($safari_brands as $safari_brand) { |
|
| 613 | + wp_set_object_terms($id, intval($safari_brand), 'accommodation-brand', true); |
|
| 614 | 614 | } |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | /** |
| 618 | 618 | * Connects the destinations post type |
| 619 | 619 | */ |
| 620 | - public function connect_destinations($data,$id) { |
|
| 621 | - if(isset($data[0]['position'])){ |
|
| 620 | + public function connect_destinations($data, $id) { |
|
| 621 | + if (isset($data[0]['position'])) { |
|
| 622 | 622 | $destinations = false; |
| 623 | - if(isset($data[0]['position']['country'])){ |
|
| 623 | + if (isset($data[0]['position']['country'])) { |
|
| 624 | 624 | $destinations['country'] = $data[0]['position']['country']; |
| 625 | 625 | } |
| 626 | - if(isset($data[0]['position']['destination'])){ |
|
| 626 | + if (isset($data[0]['position']['destination'])) { |
|
| 627 | 627 | $destinations['destination'] = $data[0]['position']['destination']; |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | - if(false !== $destinations){ |
|
| 631 | - $prev_values = get_post_meta($id,'destination_to_accommodation',false); |
|
| 632 | - if(false === $prev_values || !is_array($prev_values)){ |
|
| 630 | + if (false !== $destinations) { |
|
| 631 | + $prev_values = get_post_meta($id, 'destination_to_accommodation', false); |
|
| 632 | + if (false === $prev_values || !is_array($prev_values)) { |
|
| 633 | 633 | $prev_values = array(); |
| 634 | 634 | } |
| 635 | 635 | //print_r($destinations); |
| 636 | 636 | $destinations = array_unique($destinations); |
| 637 | 637 | //print_r($destinations); |
| 638 | - foreach($destinations as $key => $value){ |
|
| 638 | + foreach ($destinations as $key => $value) { |
|
| 639 | 639 | $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
| 640 | 640 | if (null !== $destination) { |
| 641 | - if(!in_array($destination->ID,$prev_values)){ |
|
| 642 | - add_post_meta($id,'destination_to_accommodation',$destination->ID,false); |
|
| 643 | - add_post_meta($destination->ID,'accommodation_to_destination',$id,false); |
|
| 641 | + if (!in_array($destination->ID, $prev_values)) { |
|
| 642 | + add_post_meta($id, 'destination_to_accommodation', $destination->ID, false); |
|
| 643 | + add_post_meta($destination->ID, 'accommodation_to_destination', $id, false); |
|
| 644 | 644 | $this->cleanup_posts[$destination->ID] = 'accommodation_to_destination'; |
| 645 | 645 | } |
| 646 | 646 | } |
@@ -652,18 +652,18 @@ discard block |
||
| 652 | 652 | /** |
| 653 | 653 | * Set the Travel Style |
| 654 | 654 | */ |
| 655 | - public function set_taxonomy_style($data,$id) { |
|
| 655 | + public function set_taxonomy_style($data, $id) { |
|
| 656 | 656 | $terms = false; |
| 657 | - if(isset($data[0]['category'])){ |
|
| 658 | - if(!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) |
|
| 657 | + if (isset($data[0]['category'])) { |
|
| 658 | + if (!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) |
|
| 659 | 659 | { |
| 660 | 660 | $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type'); |
| 661 | - if ( is_wp_error($term) ){echo $term->get_error_message();} |
|
| 662 | - else { wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); } |
|
| 661 | + if (is_wp_error($term)) {echo $term->get_error_message(); } |
|
| 662 | + else { wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true); } |
|
| 663 | 663 | } |
| 664 | 664 | else |
| 665 | 665 | { |
| 666 | - wp_set_object_terms( $id, intval($term['term_id']), 'accommodation-type',true); |
|
| 666 | + wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true); |
|
| 667 | 667 | } |
| 668 | 668 | } |
| 669 | 669 | } |
@@ -671,23 +671,23 @@ discard block |
||
| 671 | 671 | /** |
| 672 | 672 | * Saves the room data |
| 673 | 673 | */ |
| 674 | - public function set_room_data($data,$id) { |
|
| 675 | - if(!empty($data[0]['rooms']) && is_array($data[0]['rooms'])){ |
|
| 674 | + public function set_room_data($data, $id) { |
|
| 675 | + if (!empty($data[0]['rooms']) && is_array($data[0]['rooms'])) { |
|
| 676 | 676 | $rooms = false; |
| 677 | 677 | |
| 678 | - foreach($data[0]['rooms'] as $room){ |
|
| 678 | + foreach ($data[0]['rooms'] as $room) { |
|
| 679 | 679 | |
| 680 | 680 | $temp_room = array(); |
| 681 | - if(isset($room['name'])){ |
|
| 681 | + if (isset($room['name'])) { |
|
| 682 | 682 | $temp_room['title'] = $room['name']; |
| 683 | 683 | } |
| 684 | - if(isset($room['description'])){ |
|
| 684 | + if (isset($room['description'])) { |
|
| 685 | 685 | $temp_room['description'] = strip_tags($room['description']); |
| 686 | 686 | } |
| 687 | 687 | $temp_room['price'] = 0; |
| 688 | 688 | $temp_room['type'] = 'room'; |
| 689 | 689 | |
| 690 | - if(!empty($room['images']) && is_array($room['images'])){ |
|
| 690 | + if (!empty($room['images']) && is_array($room['images'])) { |
|
| 691 | 691 | $attachments_args = array( |
| 692 | 692 | 'post_parent' => $id, |
| 693 | 693 | 'post_status' => 'inherit', |
@@ -697,38 +697,38 @@ discard block |
||
| 697 | 697 | $attachments = new WP_Query($attachments_args); |
| 698 | 698 | $found_attachments = array(); |
| 699 | 699 | |
| 700 | - if($attachments->have_posts()){ |
|
| 701 | - foreach($attachments->posts as $attachment){ |
|
| 702 | - $found_attachments[] = str_replace(array('.jpg','.png','.jpeg'),'',$attachment->post_title); |
|
| 700 | + if ($attachments->have_posts()) { |
|
| 701 | + foreach ($attachments->posts as $attachment) { |
|
| 702 | + $found_attachments[] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title); |
|
| 703 | 703 | } |
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | $temp_room['gallery'] = array(); |
| 707 | - foreach($room['images'] as $image_data){ |
|
| 708 | - $temp_room['gallery'][] = $this->attach_image($image_data,$id,$found_attachments); |
|
| 707 | + foreach ($room['images'] as $image_data) { |
|
| 708 | + $temp_room['gallery'][] = $this->attach_image($image_data, $id, $found_attachments); |
|
| 709 | 709 | } |
| 710 | 710 | } |
| 711 | 711 | $rooms[] = $temp_room; |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | - if(false !== $id && '0' !== $id){ |
|
| 714 | + if (false !== $id && '0' !== $id) { |
|
| 715 | 715 | delete_post_meta($id, 'units'); |
| 716 | 716 | } |
| 717 | - foreach($rooms as $room){ |
|
| 718 | - add_post_meta($id,'units',$room,false); |
|
| 717 | + foreach ($rooms as $room) { |
|
| 718 | + add_post_meta($id, 'units', $room, false); |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | - if(isset($data[0]['features']) && isset($data[0]['features']['rooms'])){ |
|
| 721 | + if (isset($data[0]['features']) && isset($data[0]['features']['rooms'])) { |
|
| 722 | 722 | $room_count = $data[0]['features']['rooms']; |
| 723 | - }else{ |
|
| 723 | + }else { |
|
| 724 | 724 | $room_count = count($data[0]['rooms']); |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | - if(false !== $id && '0' !== $id){ |
|
| 728 | - $prev_rooms = get_post_meta($id,'number_of_rooms',true); |
|
| 729 | - update_post_meta($id,'number_of_rooms',$room_count,$prev_rooms); |
|
| 730 | - }else{ |
|
| 731 | - add_post_meta($id,'number_of_rooms',$room_count,true); |
|
| 727 | + if (false !== $id && '0' !== $id) { |
|
| 728 | + $prev_rooms = get_post_meta($id, 'number_of_rooms', true); |
|
| 729 | + update_post_meta($id, 'number_of_rooms', $room_count, $prev_rooms); |
|
| 730 | + }else { |
|
| 731 | + add_post_meta($id, 'number_of_rooms', $room_count, true); |
|
| 732 | 732 | } |
| 733 | 733 | } |
| 734 | 734 | } |
@@ -736,31 +736,31 @@ discard block |
||
| 736 | 736 | /** |
| 737 | 737 | * Set the ratings |
| 738 | 738 | */ |
| 739 | - public function set_rating($data,$id) { |
|
| 739 | + public function set_rating($data, $id) { |
|
| 740 | 740 | |
| 741 | - if(!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])){ |
|
| 741 | + if (!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])) { |
|
| 742 | 742 | $rating_type = $data[0]['features']['star_authority']; |
| 743 | - }else{ |
|
| 743 | + }else { |
|
| 744 | 744 | $rating_type = 'Unspecified2'; |
| 745 | 745 | } |
| 746 | - $this->save_custom_field($rating_type,'rating_type',$id); |
|
| 746 | + $this->save_custom_field($rating_type, 'rating_type', $id); |
|
| 747 | 747 | |
| 748 | - if(!empty($data[0]['features']) && isset($data[0]['features']['stars'])){ |
|
| 749 | - $this->save_custom_field($data[0]['features']['stars'],'rating',$id,true); |
|
| 748 | + if (!empty($data[0]['features']) && isset($data[0]['features']['stars'])) { |
|
| 749 | + $this->save_custom_field($data[0]['features']['stars'], 'rating', $id, true); |
|
| 750 | 750 | } |
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | /** |
| 754 | 754 | * Set the spoken_languages |
| 755 | 755 | */ |
| 756 | - public function set_spoken_languages($data,$id) { |
|
| 757 | - if(!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])){ |
|
| 756 | + public function set_spoken_languages($data, $id) { |
|
| 757 | + if (!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])) { |
|
| 758 | 758 | $languages = false; |
| 759 | - foreach($data[0]['features']['spoken_languages'] as $spoken_language){ |
|
| 759 | + foreach ($data[0]['features']['spoken_languages'] as $spoken_language) { |
|
| 760 | 760 | $languages[] = sanitize_title($spoken_language); |
| 761 | 761 | } |
| 762 | - if(false !== $languages){ |
|
| 763 | - $this->save_custom_field($languages,'spoken_languages',$id); |
|
| 762 | + if (false !== $languages) { |
|
| 763 | + $this->save_custom_field($languages, 'spoken_languages', $id); |
|
| 764 | 764 | } |
| 765 | 765 | } |
| 766 | 766 | } |
@@ -768,14 +768,14 @@ discard block |
||
| 768 | 768 | /** |
| 769 | 769 | * Set the friendly |
| 770 | 770 | */ |
| 771 | - public function set_friendly($data,$id) { |
|
| 772 | - if(!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])){ |
|
| 771 | + public function set_friendly($data, $id) { |
|
| 772 | + if (!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])) { |
|
| 773 | 773 | $friendly_options = false; |
| 774 | - foreach($data[0]['features']['suggested_visitor_types'] as $visitor_type){ |
|
| 774 | + foreach ($data[0]['features']['suggested_visitor_types'] as $visitor_type) { |
|
| 775 | 775 | $friendly_options[] = sanitize_title($visitor_type); |
| 776 | 776 | } |
| 777 | - if(false !== $friendly_options){ |
|
| 778 | - $this->save_custom_field($friendly_options,'suggested_visitor_types',$id); |
|
| 777 | + if (false !== $friendly_options) { |
|
| 778 | + $this->save_custom_field($friendly_options, 'suggested_visitor_types', $id); |
|
| 779 | 779 | } |
| 780 | 780 | } |
| 781 | 781 | } |
@@ -783,14 +783,14 @@ discard block |
||
| 783 | 783 | /** |
| 784 | 784 | * Set the special interests |
| 785 | 785 | */ |
| 786 | - public function set_special_interests($data,$id) { |
|
| 787 | - if(!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])){ |
|
| 786 | + public function set_special_interests($data, $id) { |
|
| 787 | + if (!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])) { |
|
| 788 | 788 | $interests = false; |
| 789 | - foreach($data[0]['features']['special_interests'] as $special_interest){ |
|
| 789 | + foreach ($data[0]['features']['special_interests'] as $special_interest) { |
|
| 790 | 790 | $interests[] = sanitize_title($special_interest); |
| 791 | 791 | } |
| 792 | - if(false !== $interests){ |
|
| 793 | - $this->save_custom_field($interests,'special_interests',$id); |
|
| 792 | + if (false !== $interests) { |
|
| 793 | + $this->save_custom_field($interests, 'special_interests', $id); |
|
| 794 | 794 | } |
| 795 | 795 | } |
| 796 | 796 | } |
@@ -798,24 +798,24 @@ discard block |
||
| 798 | 798 | /** |
| 799 | 799 | * Set the Check in and Check out Date |
| 800 | 800 | */ |
| 801 | - public function set_checkin_checkout($data,$id) { |
|
| 801 | + public function set_checkin_checkout($data, $id) { |
|
| 802 | 802 | |
| 803 | - if(!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])){ |
|
| 804 | - $time = str_replace('h',':',$data[0]['features']['check_in_time']); |
|
| 805 | - $time = date('h:ia',strtotime($time)); |
|
| 806 | - $this->save_custom_field($time,'checkin_time',$id); |
|
| 803 | + if (!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])) { |
|
| 804 | + $time = str_replace('h', ':', $data[0]['features']['check_in_time']); |
|
| 805 | + $time = date('h:ia', strtotime($time)); |
|
| 806 | + $this->save_custom_field($time, 'checkin_time', $id); |
|
| 807 | 807 | } |
| 808 | - if(!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])){ |
|
| 809 | - $time = str_replace('h',':',$data[0]['features']['check_out_time']); |
|
| 810 | - $time = date('h:ia',strtotime($time)); |
|
| 811 | - $this->save_custom_field($time,'checkout_time',$id); |
|
| 808 | + if (!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])) { |
|
| 809 | + $time = str_replace('h', ':', $data[0]['features']['check_out_time']); |
|
| 810 | + $time = date('h:ia', strtotime($time)); |
|
| 811 | + $this->save_custom_field($time, 'checkout_time', $id); |
|
| 812 | 812 | } |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | /** |
| 816 | 816 | * Set the Facilities |
| 817 | 817 | */ |
| 818 | - public function set_facilities($data,$id) { |
|
| 818 | + public function set_facilities($data, $id) { |
|
| 819 | 819 | |
| 820 | 820 | $parent_facilities = array( |
| 821 | 821 | 'available_services' => 'Available Services', |
@@ -823,13 +823,13 @@ discard block |
||
| 823 | 823 | 'room_facilities' => 'Room Facilities', |
| 824 | 824 | 'activities_on_site' => 'Activities on Site' |
| 825 | 825 | ); |
| 826 | - foreach($parent_facilities as $key => $label){ |
|
| 826 | + foreach ($parent_facilities as $key => $label) { |
|
| 827 | 827 | $terms = false; |
| 828 | - if(isset($data[0]['features']) && isset($data[0]['features'][$key])){ |
|
| 829 | - $parent_id = $this->set_term($id,$label,'facility'); |
|
| 828 | + if (isset($data[0]['features']) && isset($data[0]['features'][$key])) { |
|
| 829 | + $parent_id = $this->set_term($id, $label, 'facility'); |
|
| 830 | 830 | } |
| 831 | - foreach($data[0]['features'][$key] as $child_facility){ |
|
| 832 | - $this->set_term($id,$child_facility,'facility',$parent_id); |
|
| 831 | + foreach ($data[0]['features'][$key] as $child_facility) { |
|
| 832 | + $this->set_term($id, $child_facility, 'facility', $parent_id); |
|
| 833 | 833 | } |
| 834 | 834 | } |
| 835 | 835 | } |