@@ -76,19 +76,19 @@ 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 ); |
|
| 83 | + $temp_options = get_option('_lsx-to_settings', false); |
|
| 84 | 84 | |
| 85 | - if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) { |
|
| 86 | - $this->options = $temp_options[ $this->plugin_slug ]; |
|
| 85 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
| 86 | + $this->options = $temp_options[$this->plugin_slug]; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - $accommodation_options = get_option( 'wetu_importer_accommodation_settings',false ); |
|
| 89 | + $accommodation_options = get_option('wetu_importer_accommodation_settings', false); |
|
| 90 | 90 | |
| 91 | - if ( false !== $accommodation_options ) { |
|
| 91 | + if (false !== $accommodation_options) { |
|
| 92 | 92 | $this->accommodation_options = $accommodation_options; |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | <?php $this->search_form(); ?> |
| 106 | 106 | |
| 107 | 107 | <form method="get" action="" id="posts-filter"> |
| 108 | - <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" /> |
|
| 108 | + <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" /> |
|
| 109 | 109 | |
| 110 | 110 | <table class="wp-list-table widefat fixed posts"> |
| 111 | 111 | <?php $this->table_header(); ?> |
@@ -113,11 +113,11 @@ discard block |
||
| 113 | 113 | <tbody id="the-list"> |
| 114 | 114 | <tr class="post-0 type-tour status-none" id="post-0"> |
| 115 | 115 | <th class="check-column" scope="row"> |
| 116 | - <label for="cb-select-0" class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter', 'wetu-importer' ); ?></label> |
|
| 116 | + <label for="cb-select-0" class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'wetu-importer'); ?></label> |
|
| 117 | 117 | </th> |
| 118 | 118 | <td class="post-title page-title column-title"> |
| 119 | 119 | <strong> |
| 120 | - <?php esc_html_e( 'Enter a title to search for', 'wetu-importer' ); ?> |
|
| 120 | + <?php esc_html_e('Enter a title to search for', 'wetu-importer'); ?> |
|
| 121 | 121 | </strong> |
| 122 | 122 | </td> |
| 123 | 123 | <td class="date column-date"> |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | </table> |
| 133 | 133 | |
| 134 | - <p><input class="button button-primary add" type="button" value="<?php esc_attr_e( 'Add to List', 'wetu-importer' ); ?>" /> |
|
| 135 | - <input class="button button-primary clear" type="button" value="<?php esc_attr_e( 'Clear', 'wetu-importer' ); ?>" /> |
|
| 134 | + <p><input class="button button-primary add" type="button" value="<?php esc_attr_e('Add to List', 'wetu-importer'); ?>" /> |
|
| 135 | + <input class="button button-primary clear" type="button" value="<?php esc_attr_e('Clear', 'wetu-importer'); ?>" /> |
|
| 136 | 136 | </p> |
| 137 | 137 | </form> |
| 138 | 138 | |
@@ -142,66 +142,66 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | <div class="row"> |
| 144 | 144 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 145 | - <h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3> |
|
| 145 | + <h3><?php esc_html_e('What content to Sync from WETU'); ?></h3> |
|
| 146 | 146 | <ul> |
| 147 | - <li><input class="content select-all" <?php $this->checked( $this->accommodation_options, 'all' ); ?> type="checkbox" name="content[]" value="all" /> <?php esc_html_e( 'Select All', 'wetu-importer' ); ?></li> |
|
| 148 | - <?php if ( ! isset( $this->options['disable_accommodation_descriptions'] ) ) { ?> |
|
| 149 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'description' ); ?>" type="checkbox" name="content[]" value="description" /> <?php esc_html_e( 'Description', 'wetu-importer' ); ?></li> |
|
| 147 | + <li><input class="content select-all" <?php $this->checked($this->accommodation_options, 'all'); ?> type="checkbox" name="content[]" value="all" /> <?php esc_html_e('Select All', 'wetu-importer'); ?></li> |
|
| 148 | + <?php if (!isset($this->options['disable_accommodation_descriptions'])) { ?> |
|
| 149 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php esc_html_e('Description', 'wetu-importer'); ?></li> |
|
| 150 | 150 | <?php } ?> |
| 151 | - <?php if ( ! isset( $this->options['disable_accommodation_excerpts'] ) ) { ?> |
|
| 152 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'excerpt' ); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php esc_html_e( 'Excerpt', 'wetu-importer' ); ?></li> |
|
| 151 | + <?php if (!isset($this->options['disable_accommodation_excerpts'])) { ?> |
|
| 152 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php esc_html_e('Excerpt', 'wetu-importer'); ?></li> |
|
| 153 | 153 | <?php } ?> |
| 154 | 154 | |
| 155 | - <?php if ( ! isset( $this->accommodation_settings['disable_single'] ) ) { ?> |
|
| 156 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'gallery' ); ?>" type="checkbox" name="content[]" value="gallery" /> <?php esc_html_e( 'Main Gallery', 'wetu-importer' ); ?></li> |
|
| 155 | + <?php if (!isset($this->accommodation_settings['disable_single'])) { ?> |
|
| 156 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php esc_html_e('Main Gallery', 'wetu-importer'); ?></li> |
|
| 157 | 157 | <?php } ?> |
| 158 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'category' ); ?>" type="checkbox" name="content[]" value="category" /> <?php esc_html_e( 'Category', 'wetu-importer' ); ?></li> |
|
| 159 | - <?php if ( class_exists( 'LSX_TO_Maps' ) && ! isset( $this->accommodation_settings['disable_single'] ) ) { ?> |
|
| 160 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'location' ); ?>" type="checkbox" name="content[]" value="location" /> <?php esc_html_e( 'Location', 'wetu-importer' ); ?></li> |
|
| 158 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php esc_html_e('Category', 'wetu-importer'); ?></li> |
|
| 159 | + <?php if (class_exists('LSX_TO_Maps') && !isset($this->accommodation_settings['disable_single'])) { ?> |
|
| 160 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php esc_html_e('Location', 'wetu-importer'); ?></li> |
|
| 161 | 161 | <?php } ?> |
| 162 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'destination' ); ?>" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e( 'Connect Destinations', 'wetu-importer' ); ?></li> |
|
| 163 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'rating' ); ?>" type="checkbox" name="content[]" value="rating" /> <?php esc_html_e( 'Rating', 'wetu-importer' ); ?></li> |
|
| 164 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'rooms' ); ?>" type="checkbox" name="content[]" value="rooms" /> <?php esc_html_e( 'Rooms', 'wetu-importer' ); ?></li> |
|
| 165 | - |
|
| 166 | - <?php if ( ! isset( $this->accommodation_settings['disable_single'] ) ) { ?> |
|
| 167 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'checkin' ); ?>" type="checkbox" name="content[]" value="checkin" /> <?php esc_html_e( 'Check In / Check Out', 'wetu-importer' ); ?></li> |
|
| 168 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'facilities' ); ?>" type="checkbox" name="content[]" value="facilities" /> <?php esc_html_e( 'Facilities', 'wetu-importer' ); ?></li> |
|
| 169 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'friendly' ); ?>" type="checkbox" name="content[]" value="friendly" /> <?php esc_html_e( 'Friendly', 'wetu-importer' ); ?></li> |
|
| 162 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e('Connect Destinations', 'wetu-importer'); ?></li> |
|
| 163 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php esc_html_e('Rating', 'wetu-importer'); ?></li> |
|
| 164 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php esc_html_e('Rooms', 'wetu-importer'); ?></li> |
|
| 165 | + |
|
| 166 | + <?php if (!isset($this->accommodation_settings['disable_single'])) { ?> |
|
| 167 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php esc_html_e('Check In / Check Out', 'wetu-importer'); ?></li> |
|
| 168 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php esc_html_e('Facilities', 'wetu-importer'); ?></li> |
|
| 169 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php esc_html_e('Friendly', 'wetu-importer'); ?></li> |
|
| 170 | 170 | <?php } ?> |
| 171 | 171 | |
| 172 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'special_interests' ); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php esc_html_e( 'Special Interests', 'wetu-importer' ); ?></li> |
|
| 173 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'spoken_languages' ); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php esc_html_e( 'Spoken Languages', 'wetu-importer' ); ?></li> |
|
| 172 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php esc_html_e('Special Interests', 'wetu-importer'); ?></li> |
|
| 173 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php esc_html_e('Spoken Languages', 'wetu-importer'); ?></li> |
|
| 174 | 174 | |
| 175 | - <?php if ( class_exists( 'LSX_TO_Videos' ) && ! isset( $this->accommodation_settings['disable_single'] ) ) { ?> |
|
| 176 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'videos' ); ?>" type="checkbox" name="content[]" value="videos" /> <?php esc_html_e( 'Videos', 'wetu-importer' ); ?></li> |
|
| 175 | + <?php if (class_exists('LSX_TO_Videos') && !isset($this->accommodation_settings['disable_single'])) { ?> |
|
| 176 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php esc_html_e('Videos', 'wetu-importer'); ?></li> |
|
| 177 | 177 | <?php } ?> |
| 178 | 178 | </ul> |
| 179 | - <h4><?php esc_html_e( 'Additional Content' ); ?></h4> |
|
| 179 | + <h4><?php esc_html_e('Additional Content'); ?></h4> |
|
| 180 | 180 | <ul> |
| 181 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'featured_image' ); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e( 'Set Featured Image', 'wetu-importer' ); ?></li> |
|
| 182 | - <?php if ( class_exists( 'LSX_Banners' ) && ! isset( $this->accommodation_settings['disable_single'] ) ) { ?> |
|
| 183 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'banner_image' ); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e( 'Set Banner Image', 'wetu-importer' ); ?></li> |
|
| 181 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e('Set Featured Image', 'wetu-importer'); ?></li> |
|
| 182 | + <?php if (class_exists('LSX_Banners') && !isset($this->accommodation_settings['disable_single'])) { ?> |
|
| 183 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e('Set Banner Image', 'wetu-importer'); ?></li> |
|
| 184 | 184 | <?php } ?> |
| 185 | 185 | </ul> |
| 186 | 186 | </div> |
| 187 | 187 | <div style="width:30%;display:block;float:left;"> |
| 188 | - <h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3> |
|
| 189 | - <?php $this->team_member_checkboxes( $this->accommodation_options ); ?> |
|
| 188 | + <h3><?php esc_html_e('Assign a Team Member'); ?></h3> |
|
| 189 | + <?php $this->team_member_checkboxes($this->accommodation_options); ?> |
|
| 190 | 190 | </div> |
| 191 | 191 | |
| 192 | 192 | <div style="width:30%;display:block;float:left;"> |
| 193 | - <h3><?php esc_html_e( 'Assign a Safari Brand' ); ?></h3> |
|
| 193 | + <h3><?php esc_html_e('Assign a Safari Brand'); ?></h3> |
|
| 194 | 194 | <?php |
| 195 | 195 | // @codingStandardsIgnoreLine |
| 196 | - echo $this->taxonomy_checkboxes( 'accommodation-brand', $this->accommodation_options ); |
|
| 196 | + echo $this->taxonomy_checkboxes('accommodation-brand', $this->accommodation_options); |
|
| 197 | 197 | ?> |
| 198 | 198 | </div> |
| 199 | 199 | |
| 200 | 200 | <br clear="both" /> |
| 201 | 201 | </div> |
| 202 | 202 | |
| 203 | - <h3><?php esc_html_e( 'Your List' ); ?></h3> |
|
| 204 | - <p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'wetu-importer' ); ?>" /></p> |
|
| 203 | + <h3><?php esc_html_e('Your List'); ?></h3> |
|
| 204 | + <p><input class="button button-primary" type="submit" value="<?php esc_attr_e('Sync', 'wetu-importer'); ?>" /></p> |
|
| 205 | 205 | <table class="wp-list-table widefat fixed posts"> |
| 206 | 206 | <?php $this->table_header(); ?> |
| 207 | 207 | |
@@ -213,12 +213,12 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | </table> |
| 215 | 215 | |
| 216 | - <p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'wetu-importer' ); ?>" /></p> |
|
| 216 | + <p><input class="button button-primary" type="submit" value="<?php esc_attr_e('Sync', 'wetu-importer'); ?>" /></p> |
|
| 217 | 217 | </form> |
| 218 | 218 | </div> |
| 219 | 219 | |
| 220 | 220 | <div style="display:none;" class="completed-list-wrapper"> |
| 221 | - <h3><?php esc_html_e( 'Completed' ); ?> - <small><?php esc_html_e( 'Import your', 'wetu-importer' ); ?> <a href="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->plugin_slug ); ?>&tab=destination"><?php esc_html_e( 'destinations' ); ?></a> <?php esc_html_e( 'next', 'wetu-importer' ); ?></small></h3> |
|
| 221 | + <h3><?php esc_html_e('Completed'); ?> - <small><?php esc_html_e('Import your', 'wetu-importer'); ?> <a href="<?php echo esc_url(admin_url('admin.php')); ?>?page=<?php echo esc_attr($this->plugin_slug); ?>&tab=destination"><?php esc_html_e('destinations'); ?></a> <?php esc_html_e('next', 'wetu-importer'); ?></small></h3> |
|
| 222 | 222 | <ul> |
| 223 | 223 | </ul> |
| 224 | 224 | </div> |
@@ -230,9 +230,9 @@ discard block |
||
| 230 | 230 | * search_form |
| 231 | 231 | */ |
| 232 | 232 | public function update_options_form() { |
| 233 | - echo '<div style="display:none;" class="wetu-status"><h3>' . esc_html__( 'Wetu Status', 'wetu-importer' ) . '</h3>'; |
|
| 233 | + echo '<div style="display:none;" class="wetu-status"><h3>'.esc_html__('Wetu Status', 'wetu-importer').'</h3>'; |
|
| 234 | 234 | |
| 235 | - $accommodation = get_transient( 'lsx_ti_accommodation' ); |
|
| 235 | + $accommodation = get_transient('lsx_ti_accommodation'); |
|
| 236 | 236 | |
| 237 | 237 | //if ( '' === $accommodation || false === $accommodation || isset( $_GET['refresh_accommodation'] ) ) { |
| 238 | 238 | //$this->update_options(); |
@@ -245,14 +245,14 @@ discard block |
||
| 245 | 245 | * Save the list of Accommodation into an option |
| 246 | 246 | */ |
| 247 | 247 | public function update_options() { |
| 248 | - $data = file_get_contents( $this->url . '/List?' . $this->url_qs ); |
|
| 248 | + $data = file_get_contents($this->url.'/List?'.$this->url_qs); |
|
| 249 | 249 | |
| 250 | - $accommodation = json_decode( $data, true ); |
|
| 250 | + $accommodation = json_decode($data, true); |
|
| 251 | 251 | |
| 252 | - if ( isset( $accommodation['error'] ) ) { |
|
| 252 | + if (isset($accommodation['error'])) { |
|
| 253 | 253 | return $accommodation['error']; |
| 254 | - } elseif ( isset( $accommodation ) && ! empty( $accommodation ) ) { |
|
| 255 | - set_transient( 'lsx_ti_accommodation',$accommodation,60 * 60 * 2 ); |
|
| 254 | + } elseif (isset($accommodation) && !empty($accommodation)) { |
|
| 255 | + set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2); |
|
| 256 | 256 | return true; |
| 257 | 257 | } |
| 258 | 258 | } |
@@ -264,116 +264,116 @@ discard block |
||
| 264 | 264 | $return = false; |
| 265 | 265 | |
| 266 | 266 | // @codingStandardsIgnoreLine |
| 267 | - if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_tour_importer' && isset( $_POST['type'] ) && $_POST['type'] === 'accommodation' ) { |
|
| 267 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation') { |
|
| 268 | 268 | |
| 269 | 269 | $searched_items = false; |
| 270 | 270 | |
| 271 | 271 | // @codingStandardsIgnoreLine |
| 272 | - if ( isset( $_POST['keyword'] ) ) { |
|
| 272 | + if (isset($_POST['keyword'])) { |
|
| 273 | 273 | // @codingStandardsIgnoreLine |
| 274 | 274 | $keyphrases = $_POST['keyword']; |
| 275 | - } else { |
|
| 276 | - $keyphrases = array( 0 ); |
|
| 275 | + }else { |
|
| 276 | + $keyphrases = array(0); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - if ( ! is_array( $keyphrases ) ) { |
|
| 280 | - $keyphrases = array( $keyphrases ); |
|
| 279 | + if (!is_array($keyphrases)) { |
|
| 280 | + $keyphrases = array($keyphrases); |
|
| 281 | 281 | } |
| 282 | - foreach ( $keyphrases as &$keyword ) { |
|
| 283 | - $keyword = ltrim( rtrim( $keyword ) ); |
|
| 282 | + foreach ($keyphrases as &$keyword) { |
|
| 283 | + $keyword = ltrim(rtrim($keyword)); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | $post_status = false; |
| 287 | 287 | |
| 288 | - if ( in_array( 'publish', $keyphrases ) ) { |
|
| 288 | + if (in_array('publish', $keyphrases)) { |
|
| 289 | 289 | $post_status = 'publish'; |
| 290 | 290 | } |
| 291 | - if ( in_array( 'pending', $keyphrases ) ) { |
|
| 291 | + if (in_array('pending', $keyphrases)) { |
|
| 292 | 292 | $post_status = 'pending'; |
| 293 | 293 | } |
| 294 | - if ( in_array( 'draft', $keyphrases ) ) { |
|
| 294 | + if (in_array('draft', $keyphrases)) { |
|
| 295 | 295 | $post_status = 'draft'; |
| 296 | 296 | } |
| 297 | - if ( in_array( 'import', $keyphrases ) ) { |
|
| 297 | + if (in_array('import', $keyphrases)) { |
|
| 298 | 298 | $post_status = 'import'; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | // If there is a post status use it. |
| 302 | - if ( false !== $post_status ) { |
|
| 302 | + if (false !== $post_status) { |
|
| 303 | 303 | |
| 304 | 304 | $accommodation = array(); |
| 305 | 305 | $current_accommodation = $this->find_current_accommodation(); |
| 306 | - if ( ! empty( $current_accommodation ) ) { |
|
| 307 | - foreach ( $current_accommodation as $cs_key => $ccs_id ) { |
|
| 308 | - $accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id ); |
|
| 306 | + if (!empty($current_accommodation)) { |
|
| 307 | + foreach ($current_accommodation as $cs_key => $ccs_id) { |
|
| 308 | + $accommodation[] = $this->prepare_row_attributes($cs_key, $ccs_id->post_id); |
|
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | // Run through each accommodation and use it. |
| 313 | - if ( ! empty( $accommodation ) ) { |
|
| 314 | - foreach ( $accommodation as $row_key => $row ) { |
|
| 315 | - if ( 'import' === $post_status ) { |
|
| 316 | - if ( is_array( $this->queued_imports ) && in_array( $row['post_id'],$this->queued_imports ) ) { |
|
| 317 | - $current_status = get_post_status( $row['post_id'] ); |
|
| 318 | - if ( 'draft' === $current_status ) { |
|
| 319 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
|
| 313 | + if (!empty($accommodation)) { |
|
| 314 | + foreach ($accommodation as $row_key => $row) { |
|
| 315 | + if ('import' === $post_status) { |
|
| 316 | + if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) { |
|
| 317 | + $current_status = get_post_status($row['post_id']); |
|
| 318 | + if ('draft' === $current_status) { |
|
| 319 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
|
| 320 | 320 | } |
| 321 | - } else { |
|
| 321 | + }else { |
|
| 322 | 322 | continue; |
| 323 | 323 | } |
| 324 | - } else { |
|
| 325 | - if ( 0 === $row['post_id'] ) { |
|
| 324 | + }else { |
|
| 325 | + if (0 === $row['post_id']) { |
|
| 326 | 326 | continue; |
| 327 | - } else { |
|
| 328 | - $current_status = get_post_status( $row['post_id'] ); |
|
| 329 | - if ( $current_status !== $post_status ) { |
|
| 327 | + }else { |
|
| 328 | + $current_status = get_post_status($row['post_id']); |
|
| 329 | + if ($current_status !== $post_status) { |
|
| 330 | 330 | continue; |
| 331 | 331 | } |
| 332 | 332 | } |
| 333 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
|
| 333 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
|
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | - } else { |
|
| 338 | - $key_string_search = implode( '+', $keyphrases ); |
|
| 339 | - $search_data = file_get_contents( $this->url . '/Search/' . $key_string_search ); |
|
| 340 | - $search_data = json_decode( $search_data, true ); |
|
| 337 | + }else { |
|
| 338 | + $key_string_search = implode('+', $keyphrases); |
|
| 339 | + $search_data = file_get_contents($this->url.'/Search/'.$key_string_search); |
|
| 340 | + $search_data = json_decode($search_data, true); |
|
| 341 | 341 | |
| 342 | - if ( ! isset( $search_data['error'] ) ) { |
|
| 343 | - foreach ( $search_data as $sdata ) { |
|
| 342 | + if (!isset($search_data['error'])) { |
|
| 343 | + foreach ($search_data as $sdata) { |
|
| 344 | 344 | |
| 345 | - if ( 'Destination' === trim( $sdata['type'] ) || 'Activity' === trim( $sdata['type'] ) || 'Restaurant' === trim( $sdata['type'] ) || 'None' === trim( $sdata['type'] ) || 'Site / Attraction' === trim( $sdata['type'] ) || '' === trim( $sdata['type'] ) ) { |
|
| 345 | + if ('Destination' === trim($sdata['type']) || 'Activity' === trim($sdata['type']) || 'Restaurant' === trim($sdata['type']) || 'None' === trim($sdata['type']) || 'Site / Attraction' === trim($sdata['type']) || '' === trim($sdata['type'])) { |
|
| 346 | 346 | continue; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - $temp_id = $this->get_post_id_by_key_value( $sdata['id'] ); |
|
| 350 | - if ( false === $temp_id ) { |
|
| 349 | + $temp_id = $this->get_post_id_by_key_value($sdata['id']); |
|
| 350 | + if (false === $temp_id) { |
|
| 351 | 351 | $sdata['post_id'] = 0; |
| 352 | - } else { |
|
| 352 | + }else { |
|
| 353 | 353 | $sdata['post_id'] = $temp_id; |
| 354 | 354 | } |
| 355 | - $searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata ); |
|
| 355 | + $searched_items[sanitize_title($sdata['name']).'-'.$sdata['id']] = $this->format_row($sdata); |
|
| 356 | 356 | } |
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - if ( false !== $searched_items ) { |
|
| 361 | - ksort( $searched_items ); |
|
| 362 | - $return = implode( $searched_items ); |
|
| 360 | + if (false !== $searched_items) { |
|
| 361 | + ksort($searched_items); |
|
| 362 | + $return = implode($searched_items); |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - print_r( $return ); |
|
| 365 | + print_r($return); |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | die(); |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - public function prepare_row_attributes( $cs_key, $ccs_id ) { |
|
| 371 | + public function prepare_row_attributes($cs_key, $ccs_id) { |
|
| 372 | 372 | return $row_item = array( |
| 373 | 373 | 'id' => $cs_key, |
| 374 | 374 | 'type' => 'Accommodation', |
| 375 | - 'name' => get_the_title( $ccs_id ), |
|
| 376 | - 'last_modified' => date('Y-m-d', strtotime( 'now' ) ), |
|
| 375 | + 'name' => get_the_title($ccs_id), |
|
| 376 | + 'last_modified' => date('Y-m-d', strtotime('now')), |
|
| 377 | 377 | 'post_id' => $ccs_id, |
| 378 | 378 | ); |
| 379 | 379 | } |
@@ -384,28 +384,28 @@ discard block |
||
| 384 | 384 | * @param boolean $row the current row to format. |
| 385 | 385 | * @return void |
| 386 | 386 | */ |
| 387 | - public function format_row( $row = false ) { |
|
| 388 | - if ( false !== $row ) { |
|
| 387 | + public function format_row($row = false) { |
|
| 388 | + if (false !== $row) { |
|
| 389 | 389 | |
| 390 | 390 | $status = 'import'; |
| 391 | - if ( 0 !== $row['post_id'] ) { |
|
| 392 | - $status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>'; |
|
| 391 | + if (0 !== $row['post_id']) { |
|
| 392 | + $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | $row_html = ' |
| 396 | - <tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '"> |
|
| 396 | + <tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'"> |
|
| 397 | 397 | <th class="check-column" scope="row"> |
| 398 | - <label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label> |
|
| 399 | - <input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '"> |
|
| 398 | + <label for="cb-select-' . $row['id'].'" class="screen-reader-text">'.$row['name'].'</label> |
|
| 399 | + <input type="checkbox" data-identifier="' . $row['id'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['id'].'"> |
|
| 400 | 400 | </th> |
| 401 | 401 | <td class="post-title page-title column-title"> |
| 402 | - <strong>' . $row['name'] . '</strong> - ' . $status . ' |
|
| 402 | + <strong>' . $row['name'].'</strong> - '.$status.' |
|
| 403 | 403 | </td> |
| 404 | 404 | <td class="date column-date"> |
| 405 | - <abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified |
|
| 405 | + <abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
| 406 | 406 | </td> |
| 407 | 407 | <td class="ssid column-ssid"> |
| 408 | - ' . $row['id'] . ' |
|
| 408 | + ' . $row['id'].' |
|
| 409 | 409 | </td> |
| 410 | 410 | </tr>'; |
| 411 | 411 | return $row_html; |
@@ -415,14 +415,14 @@ discard block |
||
| 415 | 415 | /** |
| 416 | 416 | * Saves the queue to the option. |
| 417 | 417 | */ |
| 418 | - public function remove_from_queue( $id ) { |
|
| 419 | - if ( ! empty( $this->queued_imports ) ) { |
|
| 418 | + public function remove_from_queue($id) { |
|
| 419 | + if (!empty($this->queued_imports)) { |
|
| 420 | 420 | // @codingStandardsIgnoreLine |
| 421 | - if ( ( $key = array_search( $id, $this->queued_imports ) ) !== false ) { |
|
| 422 | - unset( $this->queued_imports[ $key ] ); |
|
| 421 | + if (($key = array_search($id, $this->queued_imports)) !== false) { |
|
| 422 | + unset($this->queued_imports[$key]); |
|
| 423 | 423 | |
| 424 | - delete_option( 'wetu_importer_que' ); |
|
| 425 | - update_option( 'wetu_importer_que', $this->queued_imports ); |
|
| 424 | + delete_option('wetu_importer_que'); |
|
| 425 | + update_option('wetu_importer_que', $this->queued_imports); |
|
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | } |
@@ -434,55 +434,55 @@ discard block |
||
| 434 | 434 | $return = false; |
| 435 | 435 | |
| 436 | 436 | // @codingStandardsIgnoreLine |
| 437 | - if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === 'accommodation' && isset( $_POST['wetu_id'] ) ) { |
|
| 437 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])) { |
|
| 438 | 438 | // @codingStandardsIgnoreLine |
| 439 | 439 | $wetu_id = $_POST['wetu_id']; |
| 440 | 440 | |
| 441 | 441 | // @codingStandardsIgnoreLine |
| 442 | - if ( isset( $_POST['post_id'] ) ) { |
|
| 442 | + if (isset($_POST['post_id'])) { |
|
| 443 | 443 | // @codingStandardsIgnoreLine |
| 444 | 444 | $post_id = $_POST['post_id']; |
| 445 | - } else { |
|
| 445 | + }else { |
|
| 446 | 446 | $post_id = 0; |
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | // @codingStandardsIgnoreLine |
| 450 | - if ( isset( $_POST['team_members'] ) ) { |
|
| 450 | + if (isset($_POST['team_members'])) { |
|
| 451 | 451 | // @codingStandardsIgnoreLine |
| 452 | 452 | $team_members = $_POST['team_members']; |
| 453 | - } else { |
|
| 453 | + }else { |
|
| 454 | 454 | $team_members = false; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | // @codingStandardsIgnoreLine |
| 458 | - if ( isset( $_POST['safari_brands'] ) ) { |
|
| 458 | + if (isset($_POST['safari_brands'])) { |
|
| 459 | 459 | // @codingStandardsIgnoreLine |
| 460 | 460 | $safari_brands = $_POST['safari_brands']; |
| 461 | - } else { |
|
| 461 | + }else { |
|
| 462 | 462 | $safari_brands = false; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | - delete_option( 'wetu_importer_accommodation_settings' ); |
|
| 465 | + delete_option('wetu_importer_accommodation_settings'); |
|
| 466 | 466 | |
| 467 | 467 | // @codingStandardsIgnoreLine |
| 468 | - if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) { |
|
| 468 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
| 469 | 469 | // @codingStandardsIgnoreLine |
| 470 | 470 | $content = $_POST['content']; |
| 471 | - add_option( 'wetu_importer_accommodation_settings',$content ); |
|
| 472 | - } else { |
|
| 471 | + add_option('wetu_importer_accommodation_settings', $content); |
|
| 472 | + }else { |
|
| 473 | 473 | $content = false; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - $jdata = wp_remote_get( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
| 476 | + $jdata = wp_remote_get($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id); |
|
| 477 | 477 | |
| 478 | - if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) { |
|
| 479 | - $adata = json_decode( $jdata['body'], true ); |
|
| 480 | - $return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands ); |
|
| 481 | - $this->format_completed_row( $return ); |
|
| 482 | - $this->remove_from_queue( $return ); |
|
| 478 | + if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) { |
|
| 479 | + $adata = json_decode($jdata['body'], true); |
|
| 480 | + $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
|
| 481 | + $this->format_completed_row($return); |
|
| 482 | + $this->remove_from_queue($return); |
|
| 483 | 483 | $this->cleanup_posts(); |
| 484 | - } else { |
|
| 485 | - $this->format_error( esc_html__( 'There was a problem importing your accommodation, please try refreshing the page.', 'wetu-importer' ) ); |
|
| 484 | + }else { |
|
| 485 | + $this->format_error(esc_html__('There was a problem importing your accommodation, please try refreshing the page.', 'wetu-importer')); |
|
| 486 | 486 | } |
| 487 | 487 | } |
| 488 | 488 | } |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | /** |
| 491 | 491 | * Connect to wetu |
| 492 | 492 | */ |
| 493 | - public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false ) { |
|
| 493 | + public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false) { |
|
| 494 | 494 | $post_name = ''; |
| 495 | 495 | $data_post_content = ''; |
| 496 | 496 | $data_post_excerpt = ''; |
@@ -501,139 +501,139 @@ discard block |
||
| 501 | 501 | $content_used_general_description = false; |
| 502 | 502 | |
| 503 | 503 | // Set the post_content. |
| 504 | - if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) { |
|
| 505 | - if ( isset( $data[0]['content']['extended_description'] ) ) { |
|
| 504 | + if (!empty($importable_content) && in_array('description', $importable_content)) { |
|
| 505 | + if (isset($data[0]['content']['extended_description'])) { |
|
| 506 | 506 | $data_post_content = $data[0]['content']['extended_description']; |
| 507 | - } elseif ( isset( $data[0]['content']['general_description'] ) ) { |
|
| 507 | + } elseif (isset($data[0]['content']['general_description'])) { |
|
| 508 | 508 | $data_post_content = $data[0]['content']['general_description']; |
| 509 | 509 | $content_used_general_description = true; |
| 510 | - } elseif ( isset( $data[0]['content']['teaser_description'] ) ) { |
|
| 510 | + } elseif (isset($data[0]['content']['teaser_description'])) { |
|
| 511 | 511 | $data_post_content = $data[0]['content']['teaser_description']; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - $post['post_content'] = wp_strip_all_tags( $data_post_content ); |
|
| 514 | + $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | // set the post_excerpt. |
| 518 | - if ( ! empty( $importable_content ) && in_array( 'excerpt', $importable_content ) ) { |
|
| 519 | - if ( isset( $data[0]['content']['teaser_description'] ) ) { |
|
| 518 | + if (!empty($importable_content) && in_array('excerpt', $importable_content)) { |
|
| 519 | + if (isset($data[0]['content']['teaser_description'])) { |
|
| 520 | 520 | $data_post_excerpt = $data[0]['content']['teaser_description']; |
| 521 | - } elseif ( isset( $data[0]['content']['general_description'] ) && false === $content_used_general_description ) { |
|
| 521 | + } elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) { |
|
| 522 | 522 | $data_post_excerpt = $data[0]['content']['general_description']; |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | $post['post_excerpt'] = $data_post_excerpt; |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - if ( false !== $id && '0' !== $id ) { |
|
| 528 | + if (false !== $id && '0' !== $id) { |
|
| 529 | 529 | $post['ID'] = $id; |
| 530 | 530 | |
| 531 | - if ( isset( $data[0]['name'] ) ) { |
|
| 531 | + if (isset($data[0]['name'])) { |
|
| 532 | 532 | $post['post_title'] = $data[0]['name']; |
| 533 | 533 | $post['post_status'] = 'publish'; |
| 534 | - $post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'accommodation', 0 ); |
|
| 534 | + $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | - $id = wp_update_post( $post ); |
|
| 538 | - $prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true ); |
|
| 539 | - update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date ); |
|
| 540 | - } else { |
|
| 537 | + $id = wp_update_post($post); |
|
| 538 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
| 539 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date); |
|
| 540 | + }else { |
|
| 541 | 541 | // Set the name. |
| 542 | - if ( isset( $data[0]['name'] ) ) { |
|
| 543 | - $post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'accommodation', 0 ); |
|
| 542 | + if (isset($data[0]['name'])) { |
|
| 543 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0); |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | $post['post_name'] = $post_name; |
| 547 | 547 | $post['post_title'] = $data[0]['name']; |
| 548 | 548 | $post['post_status'] = 'publish'; |
| 549 | - $id = wp_insert_post( $post ); |
|
| 549 | + $id = wp_insert_post($post); |
|
| 550 | 550 | |
| 551 | 551 | // Save the WETU ID and the Last date it was modified. |
| 552 | - if ( false !== $id ) { |
|
| 553 | - add_post_meta( $id, 'lsx_wetu_id', $wetu_id ); |
|
| 554 | - add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) ); |
|
| 552 | + if (false !== $id) { |
|
| 553 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
| 554 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified'])); |
|
| 555 | 555 | } |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | // Setup some default for use in the import. |
| 559 | - if ( false !== $importable_content && ( in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content ) ) ) { |
|
| 560 | - $this->find_attachments( $id ); |
|
| 559 | + if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) { |
|
| 560 | + $this->find_attachments($id); |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | // Set the team member if it is there. |
| 564 | - if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) { |
|
| 565 | - $this->set_team_member( $id, $team_members ); |
|
| 564 | + if (post_type_exists('team') && false !== $team_members && '' !== $team_members) { |
|
| 565 | + $this->set_team_member($id, $team_members); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | // Set the safari brand. |
| 569 | - if ( false !== $safari_brands && '' !== $safari_brands ) { |
|
| 570 | - $this->set_safari_brands( $id, $safari_brands ); |
|
| 569 | + if (false !== $safari_brands && '' !== $safari_brands) { |
|
| 570 | + $this->set_safari_brands($id, $safari_brands); |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | - if ( class_exists( 'LSX_TO_Maps' ) ) { |
|
| 574 | - $this->set_map_data( $data, $id, 9 ); |
|
| 573 | + if (class_exists('LSX_TO_Maps')) { |
|
| 574 | + $this->set_map_data($data, $id, 9); |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | - if ( post_type_exists( 'destination' ) && false !== $importable_content && in_array( 'destination', $importable_content ) ) { |
|
| 578 | - $this->connect_destinations( $data, $id ); |
|
| 577 | + if (post_type_exists('destination') && false !== $importable_content && in_array('destination', $importable_content)) { |
|
| 578 | + $this->connect_destinations($data, $id); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - if ( false !== $importable_content && in_array( 'category', $importable_content ) ) { |
|
| 582 | - $this->set_taxonomy_style( $data, $id ); |
|
| 581 | + if (false !== $importable_content && in_array('category', $importable_content)) { |
|
| 582 | + $this->set_taxonomy_style($data, $id); |
|
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | // Set the Room Data. |
| 586 | - if ( false !== $importable_content && in_array( 'rooms', $importable_content ) ) { |
|
| 587 | - $this->set_room_data( $data, $id ); |
|
| 586 | + if (false !== $importable_content && in_array('rooms', $importable_content)) { |
|
| 587 | + $this->set_room_data($data, $id); |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | // Set the rating. |
| 591 | - if ( false !== $importable_content && in_array( 'rating', $importable_content ) ) { |
|
| 592 | - $this->set_rating( $data, $id ); |
|
| 591 | + if (false !== $importable_content && in_array('rating', $importable_content)) { |
|
| 592 | + $this->set_rating($data, $id); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | // Set the checkin checkout data. |
| 596 | - if ( false !== $importable_content && in_array( 'checkin', $importable_content ) ) { |
|
| 597 | - $this->set_checkin_checkout( $data, $id ); |
|
| 596 | + if (false !== $importable_content && in_array('checkin', $importable_content)) { |
|
| 597 | + $this->set_checkin_checkout($data, $id); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | // Set the Spoken Languages. |
| 601 | - if ( false !== $importable_content && in_array( 'spoken_languages', $importable_content ) ) { |
|
| 602 | - $this->set_spoken_languages( $data, $id ); |
|
| 601 | + if (false !== $importable_content && in_array('spoken_languages', $importable_content)) { |
|
| 602 | + $this->set_spoken_languages($data, $id); |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | // Set the friendly options. |
| 606 | - if ( false !== $importable_content && in_array( 'friendly', $importable_content ) ) { |
|
| 607 | - $this->set_friendly( $data, $id ); |
|
| 606 | + if (false !== $importable_content && in_array('friendly', $importable_content)) { |
|
| 607 | + $this->set_friendly($data, $id); |
|
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | // Set the special_interests. |
| 611 | - if ( false !== $importable_content && in_array( 'special_interests', $importable_content ) ) { |
|
| 612 | - $this->set_special_interests( $data, $id ); |
|
| 611 | + if (false !== $importable_content && in_array('special_interests', $importable_content)) { |
|
| 612 | + $this->set_special_interests($data, $id); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | // Import the videos. |
| 616 | - if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) { |
|
| 617 | - $this->set_video_data( $data, $id ); |
|
| 616 | + if (false !== $importable_content && in_array('videos', $importable_content)) { |
|
| 617 | + $this->set_video_data($data, $id); |
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | // Import the facilities. |
| 621 | - if ( false !== $importable_content && in_array( 'facilities', $importable_content ) ) { |
|
| 622 | - $this->set_facilities( $data, $id ); |
|
| 621 | + if (false !== $importable_content && in_array('facilities', $importable_content)) { |
|
| 622 | + $this->set_facilities($data, $id); |
|
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | // Set the featured image. |
| 626 | - if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) { |
|
| 627 | - $this->set_featured_image( $data, $id ); |
|
| 626 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
| 627 | + $this->set_featured_image($data, $id); |
|
| 628 | 628 | } |
| 629 | 629 | |
| 630 | - if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) { |
|
| 631 | - $this->set_banner_image( $data, $id ); |
|
| 630 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
| 631 | + $this->set_banner_image($data, $id); |
|
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | // Import the main gallery. |
| 635 | - if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) { |
|
| 636 | - $this->create_main_gallery( $data, $id ); |
|
| 635 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
| 636 | + $this->create_main_gallery($data, $id); |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | return $id; |
@@ -642,55 +642,55 @@ discard block |
||
| 642 | 642 | /** |
| 643 | 643 | * Set the team memberon each item. |
| 644 | 644 | */ |
| 645 | - public function set_team_member( $id, $team_members ) { |
|
| 646 | - delete_post_meta( $id, 'team_to_' . $this->tab_slug ); |
|
| 645 | + public function set_team_member($id, $team_members) { |
|
| 646 | + delete_post_meta($id, 'team_to_'.$this->tab_slug); |
|
| 647 | 647 | |
| 648 | - foreach ( $team_members as $team ) { |
|
| 649 | - add_post_meta( $id, 'team_to_' . $this->tab_slug, $team ); |
|
| 648 | + foreach ($team_members as $team) { |
|
| 649 | + add_post_meta($id, 'team_to_'.$this->tab_slug, $team); |
|
| 650 | 650 | } |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | /** |
| 654 | 654 | * Set the safari brand |
| 655 | 655 | */ |
| 656 | - public function set_safari_brands( $id, $safari_brands ) { |
|
| 657 | - foreach ( $safari_brands as $safari_brand ) { |
|
| 658 | - wp_set_object_terms( $id, intval( $safari_brand ), 'accommodation-brand', true ); |
|
| 656 | + public function set_safari_brands($id, $safari_brands) { |
|
| 657 | + foreach ($safari_brands as $safari_brand) { |
|
| 658 | + wp_set_object_terms($id, intval($safari_brand), 'accommodation-brand', true); |
|
| 659 | 659 | } |
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | /** |
| 663 | 663 | * Connects the destinations post type |
| 664 | 664 | */ |
| 665 | - public function connect_destinations( $data, $id ) { |
|
| 666 | - if ( isset( $data[0]['position'] ) ) { |
|
| 665 | + public function connect_destinations($data, $id) { |
|
| 666 | + if (isset($data[0]['position'])) { |
|
| 667 | 667 | $destinations = false; |
| 668 | 668 | |
| 669 | - if ( isset( $data[0]['position']['country'] ) ) { |
|
| 669 | + if (isset($data[0]['position']['country'])) { |
|
| 670 | 670 | $destinations['country'] = $data[0]['position']['country']; |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - if ( isset( $data[0]['position']['destination'] ) ) { |
|
| 673 | + if (isset($data[0]['position']['destination'])) { |
|
| 674 | 674 | $destinations['destination'] = $data[0]['position']['destination']; |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | - if ( false !== $destinations ) { |
|
| 678 | - $prev_values = get_post_meta( $id, 'destination_to_accommodation', false ); |
|
| 677 | + if (false !== $destinations) { |
|
| 678 | + $prev_values = get_post_meta($id, 'destination_to_accommodation', false); |
|
| 679 | 679 | |
| 680 | - if ( false === $prev_values || ! is_array( $prev_values ) ) { |
|
| 680 | + if (false === $prev_values || !is_array($prev_values)) { |
|
| 681 | 681 | $prev_values = array(); |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | - delete_post_meta( $id, 'destination_to_accommodation', $prev_values ); |
|
| 685 | - $destinations = array_unique( $destinations ); |
|
| 684 | + delete_post_meta($id, 'destination_to_accommodation', $prev_values); |
|
| 685 | + $destinations = array_unique($destinations); |
|
| 686 | 686 | |
| 687 | - foreach ( $destinations as $key => $value ) { |
|
| 688 | - $destination = get_page_by_title( ltrim( rtrim( $value ) ), 'OBJECT', 'destination' ); |
|
| 689 | - if ( null !== $destination ) { |
|
| 690 | - if ( ! in_array( $destination->ID, $prev_values ) ) { |
|
| 691 | - add_post_meta( $id, 'destination_to_accommodation', $destination->ID, false ); |
|
| 692 | - add_post_meta( $destination->ID, 'accommodation_to_destination', $id, false ); |
|
| 693 | - $this->cleanup_posts[ $destination->ID ] = 'accommodation_to_destination'; |
|
| 687 | + foreach ($destinations as $key => $value) { |
|
| 688 | + $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
|
| 689 | + if (null !== $destination) { |
|
| 690 | + if (!in_array($destination->ID, $prev_values)) { |
|
| 691 | + add_post_meta($id, 'destination_to_accommodation', $destination->ID, false); |
|
| 692 | + add_post_meta($destination->ID, 'accommodation_to_destination', $id, false); |
|
| 693 | + $this->cleanup_posts[$destination->ID] = 'accommodation_to_destination'; |
|
| 694 | 694 | } |
| 695 | 695 | } |
| 696 | 696 | } |
@@ -701,73 +701,73 @@ discard block |
||
| 701 | 701 | /** |
| 702 | 702 | * Set the Travel Style |
| 703 | 703 | */ |
| 704 | - public function set_taxonomy_style( $data, $id ) { |
|
| 704 | + public function set_taxonomy_style($data, $id) { |
|
| 705 | 705 | $terms = false; |
| 706 | 706 | |
| 707 | - if ( isset( $data[0]['category'] ) ) { |
|
| 707 | + if (isset($data[0]['category'])) { |
|
| 708 | 708 | // @codingStandardsIgnoreLine |
| 709 | - if ( ! $term = term_exists( trim( $data[0]['category'] ), 'accommodation-type' ) ) { |
|
| 710 | - $term = wp_insert_term( trim( $data[0]['category'] ), 'accommodation-type' ); |
|
| 709 | + if (!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) { |
|
| 710 | + $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type'); |
|
| 711 | 711 | |
| 712 | - if ( is_wp_error( $term ) ) { |
|
| 712 | + if (is_wp_error($term)) { |
|
| 713 | 713 | // @codingStandardsIgnoreLine |
| 714 | 714 | echo $term->get_error_message(); |
| 715 | 715 | } |
| 716 | - } else { |
|
| 717 | - wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type', true ); |
|
| 716 | + }else { |
|
| 717 | + wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true); |
|
| 718 | 718 | } |
| 719 | - } else { |
|
| 720 | - wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type', true ); |
|
| 719 | + }else { |
|
| 720 | + wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true); |
|
| 721 | 721 | } |
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | /** |
| 725 | 725 | * Saves the room data |
| 726 | 726 | */ |
| 727 | - public function set_room_data( $data, $id ) { |
|
| 728 | - if ( ! empty( $data[0]['rooms'] ) && is_array( $data[0]['rooms'] ) ) { |
|
| 727 | + public function set_room_data($data, $id) { |
|
| 728 | + if (!empty($data[0]['rooms']) && is_array($data[0]['rooms'])) { |
|
| 729 | 729 | $rooms = false; |
| 730 | 730 | |
| 731 | - foreach ( $data[0]['rooms'] as $room ) { |
|
| 731 | + foreach ($data[0]['rooms'] as $room) { |
|
| 732 | 732 | $temp_room = array(); |
| 733 | 733 | |
| 734 | - if ( isset( $room['name'] ) ) { |
|
| 734 | + if (isset($room['name'])) { |
|
| 735 | 735 | $temp_room['title'] = $room['name']; |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | - if ( isset( $room['description'] ) ) { |
|
| 739 | - $temp_room['description'] = strip_tags( $room['description'] ); |
|
| 738 | + if (isset($room['description'])) { |
|
| 739 | + $temp_room['description'] = strip_tags($room['description']); |
|
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | $temp_room['price'] = 0; |
| 743 | 743 | $temp_room['type'] = 'room'; |
| 744 | 744 | |
| 745 | - if ( ! empty( $room['images'] ) && is_array( $room['images'] ) ) { |
|
| 745 | + if (!empty($room['images']) && is_array($room['images'])) { |
|
| 746 | 746 | $temp_room['gallery'] = array(); |
| 747 | - $temp_room['gallery'][] = $this->attach_image( $room['images'][0], $id ); |
|
| 747 | + $temp_room['gallery'][] = $this->attach_image($room['images'][0], $id); |
|
| 748 | 748 | } |
| 749 | 749 | $rooms[] = $temp_room; |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | - if ( false !== $id && '0' !== $id ) { |
|
| 753 | - delete_post_meta( $id, 'units' ); |
|
| 752 | + if (false !== $id && '0' !== $id) { |
|
| 753 | + delete_post_meta($id, 'units'); |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | - foreach ( $rooms as $room ) { |
|
| 757 | - add_post_meta( $id, 'units', $room, false ); |
|
| 756 | + foreach ($rooms as $room) { |
|
| 757 | + add_post_meta($id, 'units', $room, false); |
|
| 758 | 758 | } |
| 759 | 759 | |
| 760 | - if ( isset( $data[0]['features'] ) && isset( $data[0]['features']['rooms'] ) ) { |
|
| 760 | + if (isset($data[0]['features']) && isset($data[0]['features']['rooms'])) { |
|
| 761 | 761 | $room_count = $data[0]['features']['rooms']; |
| 762 | - } else { |
|
| 763 | - $room_count = count( $data[0]['rooms'] ); |
|
| 762 | + }else { |
|
| 763 | + $room_count = count($data[0]['rooms']); |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | - if ( false !== $id && '0' !== $id ) { |
|
| 767 | - $prev_rooms = get_post_meta( $id, 'number_of_rooms', true ); |
|
| 768 | - update_post_meta( $id, 'number_of_rooms', $room_count, $prev_rooms ); |
|
| 769 | - } else { |
|
| 770 | - add_post_meta( $id, 'number_of_rooms', $room_count, true ); |
|
| 766 | + if (false !== $id && '0' !== $id) { |
|
| 767 | + $prev_rooms = get_post_meta($id, 'number_of_rooms', true); |
|
| 768 | + update_post_meta($id, 'number_of_rooms', $room_count, $prev_rooms); |
|
| 769 | + }else { |
|
| 770 | + add_post_meta($id, 'number_of_rooms', $room_count, true); |
|
| 771 | 771 | } |
| 772 | 772 | } |
| 773 | 773 | } |
@@ -775,33 +775,33 @@ discard block |
||
| 775 | 775 | /** |
| 776 | 776 | * Set the ratings |
| 777 | 777 | */ |
| 778 | - public function set_rating( $data, $id ) { |
|
| 779 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['star_authority'] ) ) { |
|
| 778 | + public function set_rating($data, $id) { |
|
| 779 | + if (!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])) { |
|
| 780 | 780 | $rating_type = $data[0]['features']['star_authority']; |
| 781 | - } else { |
|
| 781 | + }else { |
|
| 782 | 782 | $rating_type = 'Unspecified2'; |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | - $this->save_custom_field( $rating_type, 'rating_type', $id ); |
|
| 785 | + $this->save_custom_field($rating_type, 'rating_type', $id); |
|
| 786 | 786 | |
| 787 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['stars'] ) ) { |
|
| 788 | - $this->save_custom_field( $data[0]['features']['stars'], 'rating', $id, true ); |
|
| 787 | + if (!empty($data[0]['features']) && isset($data[0]['features']['stars'])) { |
|
| 788 | + $this->save_custom_field($data[0]['features']['stars'], 'rating', $id, true); |
|
| 789 | 789 | } |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | /** |
| 793 | 793 | * Set the spoken_languages |
| 794 | 794 | */ |
| 795 | - public function set_spoken_languages( $data, $id ) { |
|
| 796 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['spoken_languages'] ) && ! empty( $data[0]['features']['spoken_languages'] ) ) { |
|
| 795 | + public function set_spoken_languages($data, $id) { |
|
| 796 | + if (!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])) { |
|
| 797 | 797 | $languages = false; |
| 798 | 798 | |
| 799 | - foreach ( $data[0]['features']['spoken_languages'] as $spoken_language ) { |
|
| 800 | - $languages[] = sanitize_title( $spoken_language ); |
|
| 799 | + foreach ($data[0]['features']['spoken_languages'] as $spoken_language) { |
|
| 800 | + $languages[] = sanitize_title($spoken_language); |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | - if ( false !== $languages ) { |
|
| 804 | - $this->save_custom_field( $languages, 'spoken_languages', $id ); |
|
| 803 | + if (false !== $languages) { |
|
| 804 | + $this->save_custom_field($languages, 'spoken_languages', $id); |
|
| 805 | 805 | } |
| 806 | 806 | } |
| 807 | 807 | } |
@@ -809,16 +809,16 @@ discard block |
||
| 809 | 809 | /** |
| 810 | 810 | * Set the friendly |
| 811 | 811 | */ |
| 812 | - public function set_friendly( $data, $id ) { |
|
| 813 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['suggested_visitor_types'] ) && ! empty( $data[0]['features']['suggested_visitor_types'] ) ) { |
|
| 812 | + public function set_friendly($data, $id) { |
|
| 813 | + if (!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])) { |
|
| 814 | 814 | $friendly_options = false; |
| 815 | 815 | |
| 816 | - foreach ( $data[0]['features']['suggested_visitor_types'] as $visitor_type ) { |
|
| 817 | - $friendly_options[] = sanitize_title( $visitor_type ); |
|
| 816 | + foreach ($data[0]['features']['suggested_visitor_types'] as $visitor_type) { |
|
| 817 | + $friendly_options[] = sanitize_title($visitor_type); |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | - if ( false !== $friendly_options ) { |
|
| 821 | - $this->save_custom_field( $friendly_options, 'suggested_visitor_types', $id ); |
|
| 820 | + if (false !== $friendly_options) { |
|
| 821 | + $this->save_custom_field($friendly_options, 'suggested_visitor_types', $id); |
|
| 822 | 822 | } |
| 823 | 823 | } |
| 824 | 824 | } |
@@ -826,16 +826,16 @@ discard block |
||
| 826 | 826 | /** |
| 827 | 827 | * Set the special interests |
| 828 | 828 | */ |
| 829 | - public function set_special_interests( $data, $id ) { |
|
| 830 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['special_interests'] ) && ! empty( $data[0]['features']['special_interests'] ) ) { |
|
| 829 | + public function set_special_interests($data, $id) { |
|
| 830 | + if (!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])) { |
|
| 831 | 831 | $interests = false; |
| 832 | 832 | |
| 833 | - foreach ( $data[0]['features']['special_interests'] as $special_interest ) { |
|
| 834 | - $interests[] = sanitize_title( $special_interest ); |
|
| 833 | + foreach ($data[0]['features']['special_interests'] as $special_interest) { |
|
| 834 | + $interests[] = sanitize_title($special_interest); |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | - if ( false !== $interests ) { |
|
| 838 | - $this->save_custom_field( $interests, 'special_interests', $id ); |
|
| 837 | + if (false !== $interests) { |
|
| 838 | + $this->save_custom_field($interests, 'special_interests', $id); |
|
| 839 | 839 | } |
| 840 | 840 | } |
| 841 | 841 | } |
@@ -843,24 +843,24 @@ discard block |
||
| 843 | 843 | /** |
| 844 | 844 | * Set the Check in and Check out Date |
| 845 | 845 | */ |
| 846 | - public function set_checkin_checkout( $data, $id ) { |
|
| 847 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_in_time'] ) ) { |
|
| 848 | - $time = str_replace( 'h', ':', $data[0]['features']['check_in_time'] ); |
|
| 849 | - $time = date( 'h:ia', strtotime( $time ) ); |
|
| 850 | - $this->save_custom_field( $time, 'checkin_time', $id ); |
|
| 846 | + public function set_checkin_checkout($data, $id) { |
|
| 847 | + if (!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])) { |
|
| 848 | + $time = str_replace('h', ':', $data[0]['features']['check_in_time']); |
|
| 849 | + $time = date('h:ia', strtotime($time)); |
|
| 850 | + $this->save_custom_field($time, 'checkin_time', $id); |
|
| 851 | 851 | } |
| 852 | 852 | |
| 853 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_out_time'] ) ) { |
|
| 854 | - $time = str_replace( 'h', ':', $data[0]['features']['check_out_time'] ); |
|
| 855 | - $time = date( 'h:ia', strtotime( $time ) ); |
|
| 856 | - $this->save_custom_field( $time, 'checkout_time', $id ); |
|
| 853 | + if (!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])) { |
|
| 854 | + $time = str_replace('h', ':', $data[0]['features']['check_out_time']); |
|
| 855 | + $time = date('h:ia', strtotime($time)); |
|
| 856 | + $this->save_custom_field($time, 'checkout_time', $id); |
|
| 857 | 857 | } |
| 858 | 858 | } |
| 859 | 859 | |
| 860 | 860 | /** |
| 861 | 861 | * Set the Facilities |
| 862 | 862 | */ |
| 863 | - public function set_facilities( $data, $id ) { |
|
| 863 | + public function set_facilities($data, $id) { |
|
| 864 | 864 | $parent_facilities = array( |
| 865 | 865 | 'available_services' => 'Available Services', |
| 866 | 866 | 'property_facilities' => 'Property Facilities', |
@@ -868,15 +868,15 @@ discard block |
||
| 868 | 868 | 'activities_on_site' => 'Activities on Site', |
| 869 | 869 | ); |
| 870 | 870 | |
| 871 | - foreach ( $parent_facilities as $key => $label ) { |
|
| 871 | + foreach ($parent_facilities as $key => $label) { |
|
| 872 | 872 | $terms = false; |
| 873 | 873 | |
| 874 | - if ( isset( $data[0]['features'] ) && isset( $data[0]['features'][ $key ] ) ) { |
|
| 875 | - $parent_id = $this->set_term( $id, $label, 'facility' ); |
|
| 874 | + if (isset($data[0]['features']) && isset($data[0]['features'][$key])) { |
|
| 875 | + $parent_id = $this->set_term($id, $label, 'facility'); |
|
| 876 | 876 | } |
| 877 | 877 | |
| 878 | - foreach ( $data[0]['features'][ $key ] as $child_facility ) { |
|
| 879 | - $this->set_term( $id, $child_facility, 'facility', $parent_id ); |
|
| 878 | + foreach ($data[0]['features'][$key] as $child_facility) { |
|
| 879 | + $this->set_term($id, $child_facility, 'facility', $parent_id); |
|
| 880 | 880 | } |
| 881 | 881 | } |
| 882 | 882 | } |
@@ -17,14 +17,14 @@ discard block |
||
| 17 | 17 | * @return array |
| 18 | 18 | */ |
| 19 | 19 | function get_options() { |
| 20 | - $options = get_option( 'wetu_importer_settings', array() ); |
|
| 21 | - if ( empty( $options ) ) { |
|
| 20 | + $options = get_option('wetu_importer_settings', array()); |
|
| 21 | + if (empty($options)) { |
|
| 22 | 22 | // Check for any previous options. |
| 23 | - $temp_options = get_option( '_lsx-to_settings', false ); |
|
| 24 | - if ( false !== $temp_options && isset( $temp_options['wetu-importer'] ) && ! empty( $temp_options['wetu-importer'] ) ) { |
|
| 23 | + $temp_options = get_option('_lsx-to_settings', false); |
|
| 24 | + if (false !== $temp_options && isset($temp_options['wetu-importer']) && !empty($temp_options['wetu-importer'])) { |
|
| 25 | 25 | $options = $temp_options['wetu-importer']; |
| 26 | 26 | } |
| 27 | - if ( false !== $temp_options && isset( $temp_options['api']['wetu_api_key'] ) && '' !== $temp_options['api']['wetu_api_key'] ) { |
|
| 27 | + if (false !== $temp_options && isset($temp_options['api']['wetu_api_key']) && '' !== $temp_options['api']['wetu_api_key']) { |
|
| 28 | 28 | $options['api_key'] = $temp_options['api']['wetu_api_key']; |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -38,12 +38,12 @@ discard block |
||
| 38 | 38 | * @param string $post_status |
| 39 | 39 | * @return void |
| 40 | 40 | */ |
| 41 | -function get_post_count( $post_type = '', $post_status = '' ) { |
|
| 41 | +function get_post_count($post_type = '', $post_status = '') { |
|
| 42 | 42 | global $wpdb; |
| 43 | 43 | $count = '0'; |
| 44 | - if ( '' !== $post_type && '' !== $post_status ) { |
|
| 45 | - $result = $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(`ID`) FROM %s WHERE `post_status` = %s AND `post_type` = %s ', array( $wpdb->posts, $post_status, $post_type ) ) ); |
|
| 46 | - if ( false !== $result && '' !== $result ) { |
|
| 44 | + if ('' !== $post_type && '' !== $post_status) { |
|
| 45 | + $result = $wpdb->get_var($wpdb->prepare('SELECT COUNT(`ID`) FROM %s WHERE `post_status` = %s AND `post_type` = %s ', array($wpdb->posts, $post_status, $post_type))); |
|
| 46 | + if (false !== $result && '' !== $result) { |
|
| 47 | 47 | $count = $result; |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -56,11 +56,11 @@ discard block |
||
| 56 | 56 | * @param string $post_type |
| 57 | 57 | * @return void |
| 58 | 58 | */ |
| 59 | -function get_wetu_queue_count( $post_type = '' ) { |
|
| 59 | +function get_wetu_queue_count($post_type = '') { |
|
| 60 | 60 | $count = '0'; |
| 61 | - $queued_imports = get_option( 'wetu_importer_que', array() ); |
|
| 62 | - if ( isset( $queued_imports[ $post_type ] ) ) { |
|
| 63 | - $count = count( $queued_imports[ $post_type ] ); |
|
| 61 | + $queued_imports = get_option('wetu_importer_que', array()); |
|
| 62 | + if (isset($queued_imports[$post_type])) { |
|
| 63 | + $count = count($queued_imports[$post_type]); |
|
| 64 | 64 | } |
| 65 | 65 | return $count; |
| 66 | 66 | } |
@@ -71,11 +71,11 @@ discard block |
||
| 71 | 71 | * @param string $post_type |
| 72 | 72 | * @return void |
| 73 | 73 | */ |
| 74 | -function get_wetu_tour_count( $post_type = '' ) { |
|
| 74 | +function get_wetu_tour_count($post_type = '') { |
|
| 75 | 75 | $count = '0'; |
| 76 | - $wetu_tours = get_transient( 'lsx_ti_tours', array() ); |
|
| 77 | - if ( ! empty( $wetu_tours ) ) { |
|
| 78 | - $count = count( $wetu_tours ); |
|
| 76 | + $wetu_tours = get_transient('lsx_ti_tours', array()); |
|
| 77 | + if (!empty($wetu_tours)) { |
|
| 78 | + $count = count($wetu_tours); |
|
| 79 | 79 | } |
| 80 | 80 | return $count; |
| 81 | 81 | } |