@@ -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 = ''; |
| 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,109 +325,109 @@ 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 | $current_accommodation = $this->find_current_destination(); |
| 370 | 370 | |
| 371 | - foreach ( $accommodation as $row_key => $row ) { |
|
| 371 | + foreach ($accommodation as $row_key => $row) { |
|
| 372 | 372 | |
| 373 | - if ( 'Destination' !== trim( $row[0]['type'] ) ) { |
|
| 373 | + if ('Destination' !== trim($row[0]['type'])) { |
|
| 374 | 374 | continue; |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | //If this is a current tour, add its ID to the row. |
| 378 | 378 | $row['post_id'] = 0; |
| 379 | 379 | |
| 380 | - if ( false !== $current_accommodation && array_key_exists( $row['id'], $current_accommodation ) ) { |
|
| 381 | - $row['post_id'] = $current_accommodation[ $row['id'] ]->post_id; |
|
| 380 | + if (false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)) { |
|
| 381 | + $row['post_id'] = $current_accommodation[$row['id']]->post_id; |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | //If we are searching for |
| 385 | - if ( false !== $post_status ) { |
|
| 386 | - if ( 'import' === $post_status ) { |
|
| 385 | + if (false !== $post_status) { |
|
| 386 | + if ('import' === $post_status) { |
|
| 387 | 387 | |
| 388 | - if ( is_array( $this->queued_imports ) && in_array( $row['post_id'],$this->queued_imports ) ) { |
|
| 389 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
|
| 390 | - } else { |
|
| 388 | + if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) { |
|
| 389 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
|
| 390 | + }else { |
|
| 391 | 391 | continue; |
| 392 | 392 | } |
| 393 | - } else { |
|
| 394 | - if ( 0 === $row['post_id'] ) { |
|
| 393 | + }else { |
|
| 394 | + if (0 === $row['post_id']) { |
|
| 395 | 395 | continue; |
| 396 | - } else { |
|
| 397 | - $current_status = get_post_status( $row['post_id'] ); |
|
| 396 | + }else { |
|
| 397 | + $current_status = get_post_status($row['post_id']); |
|
| 398 | 398 | |
| 399 | - if ( $current_status !== $post_status ) { |
|
| 399 | + if ($current_status !== $post_status) { |
|
| 400 | 400 | continue; |
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
|
| 404 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
|
| 405 | 405 | } |
| 406 | - } else { |
|
| 406 | + }else { |
|
| 407 | 407 | //Search through each keyword. |
| 408 | - foreach ( $keyphrases as $keyphrase ) { |
|
| 408 | + foreach ($keyphrases as $keyphrase) { |
|
| 409 | 409 | //Make sure the keyphrase is turned into an array |
| 410 | - $keywords = explode( ' ',$keyphrase ); |
|
| 410 | + $keywords = explode(' ', $keyphrase); |
|
| 411 | 411 | |
| 412 | - if ( ! is_array( $keywords ) ) { |
|
| 413 | - $keywords = array( $keywords ); |
|
| 412 | + if (!is_array($keywords)) { |
|
| 413 | + $keywords = array($keywords); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - if ( $this->multineedle_stripos( ltrim( rtrim( $row['name'] ) ), $keywords ) !== false ) { |
|
| 417 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
|
| 416 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
| 417 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
|
| 418 | 418 | } |
| 419 | 419 | } |
| 420 | 420 | } |
| 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->meta_value . '" class="screen-reader-text">' . $row->name . '</label> |
|
| 451 | - <input type="checkbox" data-identifier="' . $row->meta_value . '" value="' . $row->post_id . '" name="post[]" id="cb-select-' . $row->meta_value . '"> |
|
| 450 | + <label for="cb-select-' . $row->meta_value.'" class="screen-reader-text">'.$row->name.'</label> |
|
| 451 | + <input type="checkbox" data-identifier="' . $row->meta_value.'" value="'.$row->post_id.'" name="post[]" id="cb-select-'.$row->meta_value.'"> |
|
| 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->meta_value . ' |
|
| 460 | + ' . $row->meta_value.' |
|
| 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 | |
@@ -729,11 +729,11 @@ discard block |
||
| 729 | 729 | * search_form |
| 730 | 730 | */ |
| 731 | 731 | public function update_options_form() { |
| 732 | - echo '<div style="display:none;" class="wetu-status"><h3>' . esc_html__( 'Wetu Status', 'wetu-importer' ) . '</h3>'; |
|
| 732 | + echo '<div style="display:none;" class="wetu-status"><h3>'.esc_html__('Wetu Status', 'wetu-importer').'</h3>'; |
|
| 733 | 733 | |
| 734 | - $accommodation = get_transient( 'lsx_ti_accommodation' ); |
|
| 734 | + $accommodation = get_transient('lsx_ti_accommodation'); |
|
| 735 | 735 | |
| 736 | - if ( '' === $accommodation || false === $accommodation || isset( $_GET['refresh_accommodation'] ) ) { |
|
| 736 | + if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) { |
|
| 737 | 737 | $this->update_options(); |
| 738 | 738 | } |
| 739 | 739 | |
@@ -744,14 +744,14 @@ discard block |
||
| 744 | 744 | * Save the list of Accommodation into an option |
| 745 | 745 | */ |
| 746 | 746 | public function update_options() { |
| 747 | - $data = file_get_contents( $this->url . '/List?' . $this->url_qs ); |
|
| 747 | + $data = file_get_contents($this->url.'/List?'.$this->url_qs); |
|
| 748 | 748 | |
| 749 | - $accommodation = json_decode( $data, true ); |
|
| 749 | + $accommodation = json_decode($data, true); |
|
| 750 | 750 | |
| 751 | - if ( isset( $accommodation['error'] ) ) { |
|
| 751 | + if (isset($accommodation['error'])) { |
|
| 752 | 752 | return $accommodation['error']; |
| 753 | - } elseif ( isset( $accommodation ) && ! empty( $accommodation ) ) { |
|
| 754 | - set_transient( 'lsx_ti_accommodation',$accommodation,60 * 60 * 2 ); |
|
| 753 | + } elseif (isset($accommodation) && !empty($accommodation)) { |
|
| 754 | + set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2); |
|
| 755 | 755 | return true; |
| 756 | 756 | } |
| 757 | 757 | } |