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