@@ -70,17 +70,17 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function set_variables() { |
| 72 | 72 | parent::set_variables(); |
| 73 | - $this->url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
| 73 | + $this->url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
| 74 | 74 | $this->url_qs = 'all=include'; |
| 75 | - $temp_options = get_option( '_lsx-to_settings', false ); |
|
| 75 | + $temp_options = get_option('_lsx-to_settings', false); |
|
| 76 | 76 | |
| 77 | - if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) { |
|
| 78 | - $this->options = $temp_options[ $this->plugin_slug ]; |
|
| 77 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
| 78 | + $this->options = $temp_options[$this->plugin_slug]; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - $destination_options = get_option( 'lsx_wetu_importer_destination_settings', false ); |
|
| 81 | + $destination_options = get_option('lsx_wetu_importer_destination_settings', false); |
|
| 82 | 82 | |
| 83 | - if ( false !== $destination_options ) { |
|
| 83 | + if (false !== $destination_options) { |
|
| 84 | 84 | $this->destination_options = $destination_options; |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | </div> |
| 99 | 99 | |
| 100 | 100 | <form method="get" action="" id="posts-filter"> |
| 101 | - <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>"/> |
|
| 101 | + <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>"/> |
|
| 102 | 102 | |
| 103 | 103 | <table class="wp-list-table widefat fixed posts"> |
| 104 | 104 | <?php $this->table_header(); ?> |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | <tr class="post-0 type-tour status-none" id="post-0"> |
| 108 | 108 | <th class="check-column" scope="row"> |
| 109 | 109 | <label for="cb-select-0" |
| 110 | - class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter', 'lsx-wetu-importer' ); ?></label> |
|
| 110 | + class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'lsx-wetu-importer'); ?></label> |
|
| 111 | 111 | </th> |
| 112 | 112 | <td class="post-title page-title column-title"> |
| 113 | 113 | <strong> |
| 114 | - <?php esc_html_e( 'Enter a title to search for', 'lsx-wetu-importer' ); ?> |
|
| 114 | + <?php esc_html_e('Enter a title to search for', 'lsx-wetu-importer'); ?> |
|
| 115 | 115 | </strong> |
| 116 | 116 | </td> |
| 117 | 117 | <td class="date column-date"> |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | </table> |
| 127 | 127 | |
| 128 | 128 | <p><input class="button button-primary add" type="button" |
| 129 | - value="<?php esc_html_e( 'Add to List', 'lsx-wetu-importer' ); ?>"/> |
|
| 129 | + value="<?php esc_html_e('Add to List', 'lsx-wetu-importer'); ?>"/> |
|
| 130 | 130 | <input class="button button-primary clear" type="button" |
| 131 | - value="<?php esc_html_e( 'Clear', 'lsx-wetu-importer' ); ?>"/> |
|
| 131 | + value="<?php esc_html_e('Clear', 'lsx-wetu-importer'); ?>"/> |
|
| 132 | 132 | </p> |
| 133 | 133 | </form> |
| 134 | 134 | |
@@ -138,115 +138,115 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | <div class="row"> |
| 140 | 140 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 141 | - <h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3> |
|
| 141 | + <h3><?php esc_html_e('What content to Sync from WETU'); ?></h3> |
|
| 142 | 142 | <ul> |
| 143 | - <?php if ( isset( $this->options ) && isset( $this->options['disable_destination_descriptions'] ) && 'on' !== $this->options['disable_destination_descriptions'] ) { ?> |
|
| 143 | + <?php if (isset($this->options) && isset($this->options['disable_destination_descriptions']) && 'on' !== $this->options['disable_destination_descriptions']) { ?> |
|
| 144 | 144 | <li> |
| 145 | 145 | <input class="content" checked="checked" |
| 146 | 146 | type="checkbox" name="content[]" |
| 147 | - value="description"/> <?php esc_html_e( 'Description', 'lsx-wetu-importer' ); ?></li> |
|
| 147 | + value="description"/> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li> |
|
| 148 | 148 | <?php } ?> |
| 149 | 149 | |
| 150 | 150 | <li> |
| 151 | 151 | <input class="content" checked="checked" |
| 152 | 152 | type="checkbox" name="content[]" |
| 153 | - value="gallery"/> <?php esc_html_e( 'Main Gallery', 'lsx-wetu-importer' ); ?></li> |
|
| 153 | + value="gallery"/> <?php esc_html_e('Main Gallery', 'lsx-wetu-importer'); ?></li> |
|
| 154 | 154 | |
| 155 | 155 | <li> |
| 156 | 156 | <input class="content" checked="checked" |
| 157 | 157 | type="checkbox" name="content[]" |
| 158 | - value="location"/> <?php esc_html_e( 'Location', 'lsx-wetu-importer' ); ?> |
|
| 158 | + value="location"/> <?php esc_html_e('Location', 'lsx-wetu-importer'); ?> |
|
| 159 | 159 | </li> |
| 160 | 160 | |
| 161 | 161 | |
| 162 | - <?php if ( class_exists( 'LSX_TO_Videos' ) ) { ?> |
|
| 162 | + <?php if (class_exists('LSX_TO_Videos')) { ?> |
|
| 163 | 163 | <li> |
| 164 | 164 | <input class="content" checked="checked" |
| 165 | 165 | type="checkbox" name="content[]" |
| 166 | - value="videos"/> <?php esc_html_e( 'Videos', 'lsx-wetu-importer' ); ?></li> |
|
| 166 | + value="videos"/> <?php esc_html_e('Videos', 'lsx-wetu-importer'); ?></li> |
|
| 167 | 167 | <?php } ?> |
| 168 | 168 | |
| 169 | 169 | </ul> |
| 170 | - <h4><?php esc_html_e( 'Additional Content' ); ?></h4> |
|
| 170 | + <h4><?php esc_html_e('Additional Content'); ?></h4> |
|
| 171 | 171 | <ul> |
| 172 | 172 | <li> |
| 173 | 173 | <input class="content" checked="checked" |
| 174 | 174 | type="checkbox" name="content[]" |
| 175 | - value="country"/> <?php esc_html_e( 'Set Country', 'lsx-wetu-importer' ); ?></li> |
|
| 175 | + value="country"/> <?php esc_html_e('Set Country', 'lsx-wetu-importer'); ?></li> |
|
| 176 | 176 | <li> |
| 177 | 177 | <input class="content" checked="checked" |
| 178 | 178 | type="checkbox" name="content[]" |
| 179 | - value="continent"/> <?php esc_html_e( 'Set Continent', 'lsx-wetu-importer' ); ?></li> |
|
| 179 | + value="continent"/> <?php esc_html_e('Set Continent', 'lsx-wetu-importer'); ?></li> |
|
| 180 | 180 | |
| 181 | 181 | <li> |
| 182 | 182 | <input class="content" checked="checked" |
| 183 | 183 | type="checkbox" name="content[]" |
| 184 | - value="featured_image"/> <?php esc_html_e( 'Set Featured Image', 'lsx-wetu-importer' ); ?> |
|
| 184 | + value="featured_image"/> <?php esc_html_e('Set Featured Image', 'lsx-wetu-importer'); ?> |
|
| 185 | 185 | </li> |
| 186 | - <?php if ( class_exists( 'LSX_Banners' ) ) { ?> |
|
| 186 | + <?php if (class_exists('LSX_Banners')) { ?> |
|
| 187 | 187 | <li> |
| 188 | 188 | <input class="content" checked="checked" |
| 189 | 189 | type="checkbox" name="content[]" |
| 190 | - value="banner_image"/> <?php esc_html_e( 'Set Banner Image', 'lsx-wetu-importer' ); ?> |
|
| 190 | + value="banner_image"/> <?php esc_html_e('Set Banner Image', 'lsx-wetu-importer'); ?> |
|
| 191 | 191 | </li> |
| 192 | 192 | <li> |
| 193 | 193 | <input class="content" checked="checked" |
| 194 | 194 | type="checkbox" name="content[]" |
| 195 | - value="unique_banner_image"/> <?php esc_html_e( 'Use the WETU banner field', 'lsx-wetu-importer' ); ?> |
|
| 195 | + value="unique_banner_image"/> <?php esc_html_e('Use the WETU banner field', 'lsx-wetu-importer'); ?> |
|
| 196 | 196 | </li> |
| 197 | 197 | <?php } ?> |
| 198 | 198 | |
| 199 | 199 | <li> |
| 200 | 200 | <input class="content" checked="checked" |
| 201 | 201 | type="checkbox" name="content[]" |
| 202 | - value="strip_tags"/> <?php esc_html_e( 'Strip HTML from the description', 'lsx-wetu-importer' ); ?></li> |
|
| 202 | + value="strip_tags"/> <?php esc_html_e('Strip HTML from the description', 'lsx-wetu-importer'); ?></li> |
|
| 203 | 203 | </ul> |
| 204 | 204 | </div> |
| 205 | 205 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 206 | - <h3><?php esc_html_e( 'Travel Information' ); ?></h3> |
|
| 206 | + <h3><?php esc_html_e('Travel Information'); ?></h3> |
|
| 207 | 207 | <ul> |
| 208 | 208 | <li> |
| 209 | 209 | <input class="content" checked="checked" |
| 210 | 210 | type="checkbox" name="content[]" |
| 211 | - value="electricity"/> <?php esc_html_e( 'Electricity', 'lsx-wetu-importer' ); ?></li> |
|
| 211 | + value="electricity"/> <?php esc_html_e('Electricity', 'lsx-wetu-importer'); ?></li> |
|
| 212 | 212 | <li> |
| 213 | 213 | <input class="content" checked="checked" |
| 214 | 214 | type="checkbox" name="content[]" |
| 215 | - value="banking"/> <?php esc_html_e( 'Banking', 'lsx-wetu-importer' ); ?></li> |
|
| 215 | + value="banking"/> <?php esc_html_e('Banking', 'lsx-wetu-importer'); ?></li> |
|
| 216 | 216 | <li> |
| 217 | 217 | <input class="content" checked="checked" |
| 218 | 218 | type="checkbox" name="content[]" |
| 219 | - value="cuisine"/> <?php esc_html_e( 'Cuisine', 'lsx-wetu-importer' ); ?></li> |
|
| 219 | + value="cuisine"/> <?php esc_html_e('Cuisine', 'lsx-wetu-importer'); ?></li> |
|
| 220 | 220 | <li> |
| 221 | 221 | <input class="content" checked="checked" |
| 222 | 222 | type="checkbox" name="content[]" |
| 223 | - value="climate"/> <?php esc_html_e( 'Climate', 'lsx-wetu-importer' ); ?></li> |
|
| 223 | + value="climate"/> <?php esc_html_e('Climate', 'lsx-wetu-importer'); ?></li> |
|
| 224 | 224 | <li> |
| 225 | 225 | <input class="content" checked="checked" |
| 226 | 226 | type="checkbox" name="content[]" |
| 227 | - value="transport"/> <?php esc_html_e( 'Transport', 'lsx-wetu-importer' ); ?></li> |
|
| 227 | + value="transport"/> <?php esc_html_e('Transport', 'lsx-wetu-importer'); ?></li> |
|
| 228 | 228 | <li><input class="content" checked="checked" |
| 229 | 229 | type="checkbox" name="content[]" |
| 230 | - value="dress"/> <?php esc_html_e( 'Dress', 'lsx-wetu-importer' ); ?></li> |
|
| 230 | + value="dress"/> <?php esc_html_e('Dress', 'lsx-wetu-importer'); ?></li> |
|
| 231 | 231 | <li><input class="content" checked="checked" |
| 232 | 232 | type="checkbox" name="content[]" |
| 233 | - value="health"/> <?php esc_html_e( 'Health', 'lsx-wetu-importer' ); ?></li> |
|
| 233 | + value="health"/> <?php esc_html_e('Health', 'lsx-wetu-importer'); ?></li> |
|
| 234 | 234 | <li><input class="content" checked="checked" |
| 235 | 235 | type="checkbox" name="content[]" |
| 236 | - value="safety"/> <?php esc_html_e( 'Safety', 'lsx-wetu-importer' ); ?></li> |
|
| 236 | + value="safety"/> <?php esc_html_e('Safety', 'lsx-wetu-importer'); ?></li> |
|
| 237 | 237 | <li><input class="content" checked="checked" |
| 238 | 238 | type="checkbox" name="content[]" |
| 239 | - value="visa"/> <?php esc_html_e( 'Visa', 'lsx-wetu-importer' ); ?></li> |
|
| 239 | + value="visa"/> <?php esc_html_e('Visa', 'lsx-wetu-importer'); ?></li> |
|
| 240 | 240 | <li><input class="content" checked="checked" |
| 241 | 241 | type="checkbox" name="content[]" |
| 242 | - value="additional_info"/> <?php esc_html_e( 'General', 'lsx-wetu-importer' ); ?></li> |
|
| 242 | + value="additional_info"/> <?php esc_html_e('General', 'lsx-wetu-importer'); ?></li> |
|
| 243 | 243 | </ul> |
| 244 | 244 | </div> |
| 245 | 245 | |
| 246 | - <?php if ( class_exists( 'LSX_TO_Team' ) ) { ?> |
|
| 246 | + <?php if (class_exists('LSX_TO_Team')) { ?> |
|
| 247 | 247 | <div style="width:30%;display:block;float:left;"> |
| 248 | - <h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3> |
|
| 249 | - <?php $this->team_member_checkboxes( $this->destination_options ); ?> |
|
| 248 | + <h3><?php esc_html_e('Assign a Team Member'); ?></h3> |
|
| 249 | + <?php $this->team_member_checkboxes($this->destination_options); ?> |
|
| 250 | 250 | </div> |
| 251 | 251 | <?php } ?> |
| 252 | 252 | |
@@ -254,9 +254,9 @@ discard block |
||
| 254 | 254 | </div> |
| 255 | 255 | |
| 256 | 256 | |
| 257 | - <h3><?php esc_html_e( 'Your List' ); ?></h3> |
|
| 257 | + <h3><?php esc_html_e('Your List'); ?></h3> |
|
| 258 | 258 | <p><input class="button button-primary" type="submit" |
| 259 | - value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>"/></p> |
|
| 259 | + value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>"/></p> |
|
| 260 | 260 | <table class="wp-list-table widefat fixed posts"> |
| 261 | 261 | <?php $this->table_header(); ?> |
| 262 | 262 | |
@@ -269,12 +269,12 @@ discard block |
||
| 269 | 269 | </table> |
| 270 | 270 | |
| 271 | 271 | <p><input class="button button-primary" type="submit" |
| 272 | - value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>"/></p> |
|
| 272 | + value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>"/></p> |
|
| 273 | 273 | </form> |
| 274 | 274 | </div> |
| 275 | 275 | |
| 276 | 276 | <div style="display:none;" class="completed-list-wrapper"> |
| 277 | - <h3><?php esc_html_e( 'Completed' ); ?></h3> |
|
| 277 | + <h3><?php esc_html_e('Completed'); ?></h3> |
|
| 278 | 278 | <ul> |
| 279 | 279 | </ul> |
| 280 | 280 | </div> |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | /** |
| 286 | 286 | * Grab all the current destination posts via the lsx_wetu_id field. |
| 287 | 287 | */ |
| 288 | - public function find_current_destination( $post_type = 'destination' ) { |
|
| 288 | + public function find_current_destination($post_type = 'destination') { |
|
| 289 | 289 | global $wpdb; |
| 290 | 290 | $return = array(); |
| 291 | 291 | |
@@ -304,9 +304,9 @@ discard block |
||
| 304 | 304 | "); |
| 305 | 305 | // @codingStandardsIgnoreEnd |
| 306 | 306 | |
| 307 | - if ( null !== $current_destination && ! empty( $current_destination ) ) { |
|
| 308 | - foreach ( $current_destination as $accom ) { |
|
| 309 | - $return[ $accom->meta_value ] = $accom; |
|
| 307 | + if (null !== $current_destination && !empty($current_destination)) { |
|
| 308 | + foreach ($current_destination as $accom) { |
|
| 309 | + $return[$accom->meta_value] = $accom; |
|
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | |
@@ -318,118 +318,118 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | public function process_ajax_search() { |
| 320 | 320 | $return = false; |
| 321 | - check_ajax_referer( 'lsx_wetu_ajax_action', 'security' ); |
|
| 322 | - if ( isset( $_POST['action'] ) && 'lsx_tour_importer' === $_POST['action'] && isset( $_POST['type'] ) && 'destination' === $_POST['type'] ) { |
|
| 321 | + check_ajax_referer('lsx_wetu_ajax_action', 'security'); |
|
| 322 | + if (isset($_POST['action']) && 'lsx_tour_importer' === $_POST['action'] && isset($_POST['type']) && 'destination' === $_POST['type']) { |
|
| 323 | 323 | |
| 324 | 324 | $searched_items = false; |
| 325 | - if ( isset( $_POST['keyword'] ) ) { |
|
| 326 | - $keyphrases = array_map( 'sanitize_text_field', wp_unslash( $_POST['keyword'] ) ); |
|
| 327 | - } else { |
|
| 328 | - $keyphrases = array( 0 ); |
|
| 325 | + if (isset($_POST['keyword'])) { |
|
| 326 | + $keyphrases = array_map('sanitize_text_field', wp_unslash($_POST['keyword'])); |
|
| 327 | + }else { |
|
| 328 | + $keyphrases = array(0); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - if ( ! is_array( $keyphrases ) ) { |
|
| 332 | - $keyphrases = array( $keyphrases ); |
|
| 331 | + if (!is_array($keyphrases)) { |
|
| 332 | + $keyphrases = array($keyphrases); |
|
| 333 | 333 | } |
| 334 | - foreach ( $keyphrases as &$keyword ) { |
|
| 335 | - $keyword = ltrim( rtrim( $keyword ) ); |
|
| 334 | + foreach ($keyphrases as &$keyword) { |
|
| 335 | + $keyword = ltrim(rtrim($keyword)); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | $post_status = false; |
| 339 | 339 | |
| 340 | - if ( in_array( 'publish', $keyphrases ) ) { |
|
| 340 | + if (in_array('publish', $keyphrases)) { |
|
| 341 | 341 | $post_status = 'publish'; |
| 342 | 342 | } |
| 343 | - if ( in_array( 'pending', $keyphrases ) ) { |
|
| 343 | + if (in_array('pending', $keyphrases)) { |
|
| 344 | 344 | $post_status = 'pending'; |
| 345 | 345 | } |
| 346 | - if ( in_array( 'draft', $keyphrases ) ) { |
|
| 346 | + if (in_array('draft', $keyphrases)) { |
|
| 347 | 347 | $post_status = 'draft'; |
| 348 | 348 | } |
| 349 | - if ( in_array( 'import', $keyphrases ) ) { |
|
| 349 | + if (in_array('import', $keyphrases)) { |
|
| 350 | 350 | $post_status = 'import'; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | // If there is a post status use it. |
| 354 | - if ( false !== $post_status ) { |
|
| 354 | + if (false !== $post_status) { |
|
| 355 | 355 | |
| 356 | 356 | $accommodation = array(); |
| 357 | - $current_accommodation = $this->find_current_accommodation( 'destination' ); |
|
| 358 | - if ( ! empty( $current_accommodation ) ) { |
|
| 359 | - foreach ( $current_accommodation as $cs_key => $ccs_id ) { |
|
| 360 | - $accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id ); |
|
| 357 | + $current_accommodation = $this->find_current_accommodation('destination'); |
|
| 358 | + if (!empty($current_accommodation)) { |
|
| 359 | + foreach ($current_accommodation as $cs_key => $ccs_id) { |
|
| 360 | + $accommodation[] = $this->prepare_row_attributes($cs_key, $ccs_id->post_id); |
|
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | // Run through each accommodation and use it. |
| 365 | - if ( ! empty( $accommodation ) ) { |
|
| 366 | - foreach ( $accommodation as $row_key => $row ) { |
|
| 365 | + if (!empty($accommodation)) { |
|
| 366 | + foreach ($accommodation as $row_key => $row) { |
|
| 367 | 367 | $row['post_title'] = $row['name']; |
| 368 | - if ( 'import' === $post_status ) { |
|
| 369 | - if ( is_array( $this->queued_imports ) && in_array( $row['post_id'], $this->queued_imports ) ) { |
|
| 370 | - $current_status = get_post_status( $row['post_id'] ); |
|
| 371 | - if ( 'draft' === $current_status ) { |
|
| 372 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row, $row_key ); |
|
| 368 | + if ('import' === $post_status) { |
|
| 369 | + if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) { |
|
| 370 | + $current_status = get_post_status($row['post_id']); |
|
| 371 | + if ('draft' === $current_status) { |
|
| 372 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row, $row_key); |
|
| 373 | 373 | } |
| 374 | - } else { |
|
| 374 | + }else { |
|
| 375 | 375 | continue; |
| 376 | 376 | } |
| 377 | - } else { |
|
| 378 | - if ( 0 === $row['post_id'] ) { |
|
| 377 | + }else { |
|
| 378 | + if (0 === $row['post_id']) { |
|
| 379 | 379 | continue; |
| 380 | - } else { |
|
| 381 | - $current_status = get_post_status( $row['post_id'] ); |
|
| 380 | + }else { |
|
| 381 | + $current_status = get_post_status($row['post_id']); |
|
| 382 | 382 | |
| 383 | - if ( $current_status !== $post_status ) { |
|
| 383 | + if ($current_status !== $post_status) { |
|
| 384 | 384 | continue; |
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row, $row_key ); |
|
| 387 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row, $row_key); |
|
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | 390 | } |
| 391 | - } else { |
|
| 391 | + }else { |
|
| 392 | 392 | |
| 393 | - $key_string_search = implode( '+', $keyphrases ); |
|
| 394 | - $search_data = wp_remote_get( $this->url . '/Search/' . $key_string_search . '/?all=include' ); |
|
| 393 | + $key_string_search = implode('+', $keyphrases); |
|
| 394 | + $search_data = wp_remote_get($this->url.'/Search/'.$key_string_search.'/?all=include'); |
|
| 395 | 395 | |
| 396 | - if ( ! is_wp_error( $search_data ) || ! empty( $search_data ) && isset( $search_data['response'] ) && isset( $search_data['response']['code'] ) && 200 === $search_data['response']['code'] ) { |
|
| 397 | - $search_data = json_decode( $search_data['body'], true ); |
|
| 398 | - foreach ( $search_data as $sdata_key => $sdata ) { |
|
| 396 | + if (!is_wp_error($search_data) || !empty($search_data) && isset($search_data['response']) && isset($search_data['response']['code']) && 200 === $search_data['response']['code']) { |
|
| 397 | + $search_data = json_decode($search_data['body'], true); |
|
| 398 | + foreach ($search_data as $sdata_key => $sdata) { |
|
| 399 | 399 | |
| 400 | - if ( isset( $sdata['type'] ) && ( 'Destination' !== trim( $sdata['type'] ) || 'Area' !== trim( $sdata['type'] ) ) ) { |
|
| 400 | + if (isset($sdata['type']) && ('Destination' !== trim($sdata['type']) || 'Area' !== trim($sdata['type']))) { |
|
| 401 | 401 | continue; |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - $temp_id = $this->get_post_id_by_key_value( $sdata['id'] ); |
|
| 405 | - if ( false === $temp_id ) { |
|
| 404 | + $temp_id = $this->get_post_id_by_key_value($sdata['id']); |
|
| 405 | + if (false === $temp_id) { |
|
| 406 | 406 | $sdata['post_id'] = 0; |
| 407 | 407 | $sdata['post_title'] = $sdata['name']; |
| 408 | - } else { |
|
| 408 | + }else { |
|
| 409 | 409 | $sdata['post_id'] = $temp_id; |
| 410 | - $sdata['post_title'] = get_the_title( $temp_id ); |
|
| 410 | + $sdata['post_title'] = get_the_title($temp_id); |
|
| 411 | 411 | } |
| 412 | - $searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata, $sdata_key ); |
|
| 412 | + $searched_items[sanitize_title($sdata['name']).'-'.$sdata['id']] = $this->format_row($sdata, $sdata_key); |
|
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - if ( false !== $searched_items ) { |
|
| 418 | - $return = implode( $searched_items ); |
|
| 417 | + if (false !== $searched_items) { |
|
| 418 | + $return = implode($searched_items); |
|
| 419 | 419 | } |
| 420 | - print_r( $return ); |
|
| 421 | - } else { |
|
| 422 | - echo esc_attr( 'None found' ); |
|
| 420 | + print_r($return); |
|
| 421 | + }else { |
|
| 422 | + echo esc_attr('None found'); |
|
| 423 | 423 | } |
| 424 | 424 | die(); |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - public function prepare_row_attributes( $cs_key, $ccs_id ) { |
|
| 427 | + public function prepare_row_attributes($cs_key, $ccs_id) { |
|
| 428 | 428 | $row_item = array( |
| 429 | 429 | 'id' => $cs_key, |
| 430 | 430 | 'type' => 'Destination', |
| 431 | - 'name' => get_the_title( $ccs_id ), |
|
| 432 | - 'last_modified' => date( 'Y-m-d', strtotime( 'now' ) ), |
|
| 431 | + 'name' => get_the_title($ccs_id), |
|
| 432 | + 'last_modified' => date('Y-m-d', strtotime('now')), |
|
| 433 | 433 | 'post_id' => $ccs_id, |
| 434 | 434 | ); |
| 435 | 435 | return $row_item; |
@@ -438,31 +438,31 @@ discard block |
||
| 438 | 438 | /** |
| 439 | 439 | * Formats the row for output on the screen. |
| 440 | 440 | */ |
| 441 | - public function format_row( $row = false, $row_key = '' ) { |
|
| 442 | - if ( false !== $row ) { |
|
| 441 | + public function format_row($row = false, $row_key = '') { |
|
| 442 | + if (false !== $row) { |
|
| 443 | 443 | |
| 444 | 444 | $status = 'import'; |
| 445 | - if ( 0 !== $row['post_id'] ) { |
|
| 446 | - $status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>'; |
|
| 445 | + if (0 !== $row['post_id']) { |
|
| 446 | + $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | $row_html = ' |
| 450 | - <tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '"> |
|
| 450 | + <tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'"> |
|
| 451 | 451 | <th class="check-column" scope="row"> |
| 452 | - <label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label> |
|
| 453 | - <input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '"> |
|
| 452 | + <label for="cb-select-' . $row['id'].'" class="screen-reader-text">'.$row['name'].'</label> |
|
| 453 | + <input type="checkbox" data-identifier="' . $row['id'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['id'].'"> |
|
| 454 | 454 | </th> |
| 455 | 455 | <td class="column-order"> |
| 456 | - ' . ( $row_key + 1 ) . ' |
|
| 456 | + ' . ($row_key + 1).' |
|
| 457 | 457 | </td> |
| 458 | 458 | <td class="post-title page-title column-title"> |
| 459 | - <strong>' . $row['post_title'] . '</strong> - ' . $status . ' |
|
| 459 | + <strong>' . $row['post_title'].'</strong> - '.$status.' |
|
| 460 | 460 | </td> |
| 461 | 461 | <td class="date column-date"> |
| 462 | - <abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified |
|
| 462 | + <abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
| 463 | 463 | </td> |
| 464 | 464 | <td class="ssid column-ssid"> |
| 465 | - ' . $row['id'] . ' |
|
| 465 | + ' . $row['id'].' |
|
| 466 | 466 | </td> |
| 467 | 467 | </tr>'; |
| 468 | 468 | return $row_html; |
@@ -475,44 +475,44 @@ discard block |
||
| 475 | 475 | public function process_ajax_import() { |
| 476 | 476 | $return = false; |
| 477 | 477 | |
| 478 | - check_ajax_referer( 'lsx_wetu_ajax_action', 'security' ); |
|
| 479 | - if ( isset( $_POST['action'] ) && 'lsx_import_items' === $_POST['action'] && isset( $_POST['type'] ) && 'destination' === $_POST['type'] && isset( $_POST['wetu_id'] ) ) { |
|
| 478 | + check_ajax_referer('lsx_wetu_ajax_action', 'security'); |
|
| 479 | + if (isset($_POST['action']) && 'lsx_import_items' === $_POST['action'] && isset($_POST['type']) && 'destination' === $_POST['type'] && isset($_POST['wetu_id'])) { |
|
| 480 | 480 | |
| 481 | - $wetu_id = sanitize_text_field( $_POST['wetu_id'] ); |
|
| 481 | + $wetu_id = sanitize_text_field($_POST['wetu_id']); |
|
| 482 | 482 | |
| 483 | - if ( isset( $_POST['post_id'] ) ) { |
|
| 484 | - $post_id = sanitize_text_field( $_POST['post_id'] ); |
|
| 485 | - $this->current_post = get_post( $post_id ); |
|
| 486 | - } else { |
|
| 483 | + if (isset($_POST['post_id'])) { |
|
| 484 | + $post_id = sanitize_text_field($_POST['post_id']); |
|
| 485 | + $this->current_post = get_post($post_id); |
|
| 486 | + }else { |
|
| 487 | 487 | $post_id = 0; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - if ( isset( $_POST['team_members'] ) ) { |
|
| 491 | - $team_members = array_map( 'sanitize_text_field', wp_unslash( $_POST['team_members'] ) ); |
|
| 492 | - } else { |
|
| 490 | + if (isset($_POST['team_members'])) { |
|
| 491 | + $team_members = array_map('sanitize_text_field', wp_unslash($_POST['team_members'])); |
|
| 492 | + }else { |
|
| 493 | 493 | $team_members = false; |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | $safari_brands = false; |
| 497 | 497 | |
| 498 | - delete_option( 'lsx_wetu_importer_destination_settings' ); |
|
| 498 | + delete_option('lsx_wetu_importer_destination_settings'); |
|
| 499 | 499 | |
| 500 | - if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) { |
|
| 501 | - $content = array_map( 'sanitize_text_field', wp_unslash( $_POST['content'] ) ); |
|
| 502 | - add_option( 'lsx_wetu_importer_destination_settings', $content ); |
|
| 503 | - } else { |
|
| 500 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
| 501 | + $content = array_map('sanitize_text_field', wp_unslash($_POST['content'])); |
|
| 502 | + add_option('lsx_wetu_importer_destination_settings', $content); |
|
| 503 | + }else { |
|
| 504 | 504 | $content = false; |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - $jdata = wp_remote_get( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
| 507 | + $jdata = wp_remote_get($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id); |
|
| 508 | 508 | |
| 509 | - if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) { |
|
| 510 | - $adata = json_decode( $jdata['body'], true ); |
|
| 511 | - $return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands ); |
|
| 512 | - $this->remove_from_queue( $return ); |
|
| 513 | - $this->format_completed_row( $return ); |
|
| 514 | - } else { |
|
| 515 | - $this->format_error( esc_html__( 'There was a problem importing your destination, please try refreshing the page.', 'lsx-wetu-importer' ) ); |
|
| 509 | + if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) { |
|
| 510 | + $adata = json_decode($jdata['body'], true); |
|
| 511 | + $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
|
| 512 | + $this->remove_from_queue($return); |
|
| 513 | + $this->format_completed_row($return); |
|
| 514 | + }else { |
|
| 515 | + $this->format_error(esc_html__('There was a problem importing your destination, please try refreshing the page.', 'lsx-wetu-importer')); |
|
| 516 | 516 | } |
| 517 | 517 | } |
| 518 | 518 | die(); |
@@ -521,14 +521,14 @@ discard block |
||
| 521 | 521 | /** |
| 522 | 522 | * Saves the queue to the option. |
| 523 | 523 | */ |
| 524 | - public function remove_from_queue( $id ) { |
|
| 525 | - if ( ! empty( $this->queued_imports ) ) { |
|
| 526 | - $key = array_search( $id, $this->queued_imports ); |
|
| 527 | - if ( false !== $key ) { |
|
| 528 | - unset( $this->queued_imports[ $key ] ); |
|
| 524 | + public function remove_from_queue($id) { |
|
| 525 | + if (!empty($this->queued_imports)) { |
|
| 526 | + $key = array_search($id, $this->queued_imports); |
|
| 527 | + if (false !== $key) { |
|
| 528 | + unset($this->queued_imports[$key]); |
|
| 529 | 529 | |
| 530 | - delete_option( 'lsx_wetu_importer_que' ); |
|
| 531 | - update_option( 'lsx_wetu_importer_que', $this->queued_imports ); |
|
| 530 | + delete_option('lsx_wetu_importer_que'); |
|
| 531 | + update_option('lsx_wetu_importer_que', $this->queued_imports); |
|
| 532 | 532 | } |
| 533 | 533 | } |
| 534 | 534 | } |
@@ -536,8 +536,8 @@ discard block |
||
| 536 | 536 | /** |
| 537 | 537 | * Connect to wetu |
| 538 | 538 | */ |
| 539 | - public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false ) { |
|
| 540 | - if ( 'Destination' === trim( $data[0]['type'] ) || 'Area' === trim( $data[0]['type'] ) ) { |
|
| 539 | + public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false) { |
|
| 540 | + if ('Destination' === trim($data[0]['type']) || 'Area' === trim($data[0]['type'])) { |
|
| 541 | 541 | $post_name = ''; |
| 542 | 542 | $data_post_content = ''; |
| 543 | 543 | $data_post_excerpt = ''; |
@@ -546,129 +546,129 @@ discard block |
||
| 546 | 546 | 'post_type' => 'destination', |
| 547 | 547 | ); |
| 548 | 548 | |
| 549 | - if ( ! empty( $importable_content ) && in_array( 'country', $importable_content ) ) { |
|
| 550 | - $parent = $this->check_for_parent( $data ); |
|
| 551 | - if ( false !== $parent ) { |
|
| 549 | + if (!empty($importable_content) && in_array('country', $importable_content)) { |
|
| 550 | + $parent = $this->check_for_parent($data); |
|
| 551 | + if (false !== $parent) { |
|
| 552 | 552 | $post['post_parent'] = $parent; |
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | // Set the post_content. |
| 557 | - if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) { |
|
| 558 | - if ( isset( $data[0]['content']['general_description'] ) ) { |
|
| 557 | + if (!empty($importable_content) && in_array('description', $importable_content)) { |
|
| 558 | + if (isset($data[0]['content']['general_description'])) { |
|
| 559 | 559 | |
| 560 | - if ( in_array( 'strip_tags', $importable_content ) ) { |
|
| 561 | - $post['post_content'] = wp_strip_all_tags( $data[0]['content']['general_description'] ); |
|
| 562 | - } else { |
|
| 560 | + if (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 | - if ( isset( $this->options ) && 'on' !== $this->options['disable_destination_title'] && isset( $data[0]['name'] ) ) { |
|
| 570 | + if (isset($this->options) && 'on' !== $this->options['disable_destination_title'] && isset($data[0]['name'])) { |
|
| 571 | 571 | $post['post_title'] = $data[0]['name']; |
| 572 | - $post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 ); |
|
| 572 | + $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0); |
|
| 573 | 573 | } |
| 574 | 574 | $post['post_status'] = 'publish'; |
| 575 | 575 | |
| 576 | - $id = wp_update_post( $post ); |
|
| 577 | - $prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true ); |
|
| 578 | - update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date ); |
|
| 579 | - } else { |
|
| 576 | + $id = wp_update_post($post); |
|
| 577 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
| 578 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date); |
|
| 579 | + }else { |
|
| 580 | 580 | // Set the name. |
| 581 | - if ( isset( $data[0]['name'] ) ) { |
|
| 582 | - $post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 ); |
|
| 581 | + if (isset($data[0]['name'])) { |
|
| 582 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0); |
|
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | $post['post_name'] = $post_name; |
| 586 | 586 | $post['post_title'] = $data[0]['name']; |
| 587 | 587 | $post['post_status'] = 'publish'; |
| 588 | - $id = wp_insert_post( $post ); |
|
| 588 | + $id = wp_insert_post($post); |
|
| 589 | 589 | |
| 590 | 590 | // Save the WETU ID and the Last date it was modified. |
| 591 | - if ( false !== $id ) { |
|
| 592 | - add_post_meta( $id, 'lsx_wetu_id', $wetu_id ); |
|
| 593 | - add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) ); |
|
| 591 | + if (false !== $id) { |
|
| 592 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
| 593 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified'])); |
|
| 594 | 594 | } |
| 595 | 595 | } |
| 596 | 596 | |
| 597 | - $this->find_attachments( $id ); |
|
| 597 | + $this->find_attachments($id); |
|
| 598 | 598 | |
| 599 | 599 | // Set the team member if it is there. |
| 600 | - if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) { |
|
| 601 | - $this->set_team_member( $id, $team_members ); |
|
| 600 | + if (post_type_exists('team') && false !== $team_members && '' !== $team_members) { |
|
| 601 | + $this->set_team_member($id, $team_members); |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | - $this->set_map_data( $data, $id, 9 ); |
|
| 604 | + $this->set_map_data($data, $id, 9); |
|
| 605 | 605 | |
| 606 | 606 | // Set the Room Data. |
| 607 | - if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) { |
|
| 608 | - $this->set_video_data( $data, $id ); |
|
| 607 | + if (false !== $importable_content && in_array('videos', $importable_content)) { |
|
| 608 | + $this->set_video_data($data, $id); |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | // Set the Electricity. |
| 612 | - if ( false !== $importable_content && in_array( 'electricity', $importable_content ) ) { |
|
| 613 | - $this->set_travel_info( $data, $id, 'electricity', $importable_content ); |
|
| 612 | + if (false !== $importable_content && in_array('electricity', $importable_content)) { |
|
| 613 | + $this->set_travel_info($data, $id, 'electricity', $importable_content); |
|
| 614 | 614 | } |
| 615 | 615 | // Set the cuisine. |
| 616 | - if ( false !== $importable_content && in_array( 'cuisine', $importable_content ) ) { |
|
| 617 | - $this->set_travel_info( $data, $id, 'cuisine', $importable_content ); |
|
| 616 | + if (false !== $importable_content && in_array('cuisine', $importable_content)) { |
|
| 617 | + $this->set_travel_info($data, $id, 'cuisine', $importable_content); |
|
| 618 | 618 | } |
| 619 | 619 | // Set the banking. |
| 620 | - if ( false !== $importable_content && in_array( 'banking', $importable_content ) ) { |
|
| 621 | - $this->set_travel_info( $data, $id, 'banking', $importable_content ); |
|
| 620 | + if (false !== $importable_content && in_array('banking', $importable_content)) { |
|
| 621 | + $this->set_travel_info($data, $id, 'banking', $importable_content); |
|
| 622 | 622 | } |
| 623 | 623 | // Set the transport. |
| 624 | - if ( false !== $importable_content && in_array( 'transport', $importable_content ) ) { |
|
| 625 | - $this->set_travel_info( $data, $id, 'transport', $importable_content ); |
|
| 624 | + if (false !== $importable_content && in_array('transport', $importable_content)) { |
|
| 625 | + $this->set_travel_info($data, $id, 'transport', $importable_content); |
|
| 626 | 626 | } |
| 627 | 627 | // Set the dress. |
| 628 | - if ( false !== $importable_content && in_array( 'dress', $importable_content ) ) { |
|
| 629 | - $this->set_travel_info( $data, $id, 'dress', $importable_content ); |
|
| 628 | + if (false !== $importable_content && in_array('dress', $importable_content)) { |
|
| 629 | + $this->set_travel_info($data, $id, 'dress', $importable_content); |
|
| 630 | 630 | } |
| 631 | 631 | // Set the climate. |
| 632 | - if ( false !== $importable_content && in_array( 'climate', $importable_content ) ) { |
|
| 633 | - $this->set_travel_info( $data, $id, 'climate', $importable_content ); |
|
| 632 | + if (false !== $importable_content && in_array('climate', $importable_content)) { |
|
| 633 | + $this->set_travel_info($data, $id, 'climate', $importable_content); |
|
| 634 | 634 | } |
| 635 | 635 | // Set the Health. |
| 636 | - if ( false !== $importable_content && in_array( 'health', $importable_content ) ) { |
|
| 637 | - $this->set_travel_info( $data, $id, 'health', $importable_content ); |
|
| 636 | + if (false !== $importable_content && in_array('health', $importable_content)) { |
|
| 637 | + $this->set_travel_info($data, $id, 'health', $importable_content); |
|
| 638 | 638 | } |
| 639 | 639 | // Set the Safety. |
| 640 | - if ( false !== $importable_content && in_array( 'safety', $importable_content ) ) { |
|
| 641 | - $this->set_travel_info( $data, $id, 'safety', $importable_content ); |
|
| 640 | + if (false !== $importable_content && in_array('safety', $importable_content)) { |
|
| 641 | + $this->set_travel_info($data, $id, 'safety', $importable_content); |
|
| 642 | 642 | } |
| 643 | 643 | // Set the Visa. |
| 644 | - if ( false !== $importable_content && in_array( 'visa', $importable_content ) ) { |
|
| 645 | - $this->set_travel_info( $data, $id, 'visa', $importable_content ); |
|
| 644 | + if (false !== $importable_content && in_array('visa', $importable_content)) { |
|
| 645 | + $this->set_travel_info($data, $id, 'visa', $importable_content); |
|
| 646 | 646 | } |
| 647 | 647 | // Set the General. |
| 648 | - if ( false !== $importable_content && in_array( 'additional_info', $importable_content ) ) { |
|
| 649 | - $this->set_travel_info( $data, $id, 'additional_info', $importable_content ); |
|
| 648 | + if (false !== $importable_content && in_array('additional_info', $importable_content)) { |
|
| 649 | + $this->set_travel_info($data, $id, 'additional_info', $importable_content); |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | // Setup some default for use in the import. |
| 653 | - if ( false !== $importable_content && (in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content )) ) { |
|
| 654 | - $this->find_attachments( $id ); |
|
| 653 | + if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) { |
|
| 654 | + $this->find_attachments($id); |
|
| 655 | 655 | |
| 656 | 656 | // Set the featured image. |
| 657 | - if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) { |
|
| 658 | - $this->set_featured_image( $data, $id ); |
|
| 657 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
| 658 | + $this->set_featured_image($data, $id); |
|
| 659 | 659 | } |
| 660 | - if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) { |
|
| 661 | - $this->set_banner_image( $data, $id, $importable_content ); |
|
| 660 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
| 661 | + $this->set_banner_image($data, $id, $importable_content); |
|
| 662 | 662 | } |
| 663 | 663 | // Import the main gallery. |
| 664 | - if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) { |
|
| 665 | - $this->create_main_gallery( $data, $id ); |
|
| 664 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
| 665 | + $this->create_main_gallery($data, $id); |
|
| 666 | 666 | } |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | // Set the continent. |
| 670 | - if ( false !== $importable_content && in_array( 'continent', $importable_content ) ) { |
|
| 671 | - $this->set_continent( $data, $id ); |
|
| 670 | + if (false !== $importable_content && in_array('continent', $importable_content)) { |
|
| 671 | + $this->set_continent($data, $id); |
|
| 672 | 672 | } |
| 673 | 673 | } |
| 674 | 674 | |
@@ -678,43 +678,43 @@ discard block |
||
| 678 | 678 | /** |
| 679 | 679 | * Saves the room data |
| 680 | 680 | */ |
| 681 | - public function set_travel_info( $data, $id, $meta_key, $importable = array( 'none' ) ) { |
|
| 682 | - if ( ! empty( $data[0]['travel_information'] ) && isset( $data[0]['travel_information'][ $meta_key ] ) ) { |
|
| 683 | - $content = $data[0]['travel_information'][ $meta_key ]; |
|
| 681 | + public function set_travel_info($data, $id, $meta_key, $importable = array('none')) { |
|
| 682 | + if (!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])) { |
|
| 683 | + $content = $data[0]['travel_information'][$meta_key]; |
|
| 684 | 684 | |
| 685 | - if ( in_array( 'strip_tags', $importable ) ) { |
|
| 686 | - $content = strip_tags( $content ); |
|
| 685 | + if (in_array('strip_tags', $importable)) { |
|
| 686 | + $content = strip_tags($content); |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | - $this->save_custom_field( $content, $meta_key, $id ); |
|
| 689 | + $this->save_custom_field($content, $meta_key, $id); |
|
| 690 | 690 | } |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | /** |
| 694 | 694 | * Set the Travel Style |
| 695 | 695 | */ |
| 696 | - public function set_continent( $data, $id ) { |
|
| 696 | + public function set_continent($data, $id) { |
|
| 697 | 697 | |
| 698 | - if ( isset( $data[0]['position']['country'] ) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id'] ) { |
|
| 698 | + if (isset($data[0]['position']['country']) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id']) { |
|
| 699 | 699 | // Get the continent code. |
| 700 | - $country_code = to_country_data( $data[0]['position']['country'], false ); |
|
| 701 | - $continent_code = to_continent_code( $country_code ); |
|
| 702 | - $continent_label = to_continent_label( $continent_code ); |
|
| 700 | + $country_code = to_country_data($data[0]['position']['country'], false); |
|
| 701 | + $continent_code = to_continent_code($country_code); |
|
| 702 | + $continent_label = to_continent_label($continent_code); |
|
| 703 | 703 | |
| 704 | - if ( ! empty( tour_operator()->options['display']['enable_search_region_filter'] ) ) { |
|
| 705 | - $continent_label = to_continent_region_label( $country_code ); |
|
| 704 | + if (!empty(tour_operator()->options['display']['enable_search_region_filter'])) { |
|
| 705 | + $continent_label = to_continent_region_label($country_code); |
|
| 706 | 706 | } |
| 707 | 707 | |
| 708 | - if ( '' !== $continent_label ) { |
|
| 709 | - $term = term_exists( trim( $continent_label ), 'continent' ); |
|
| 710 | - if ( ! $term ) { |
|
| 711 | - $term = wp_insert_term( trim( $continent_label ), 'continent' ); |
|
| 708 | + if ('' !== $continent_label) { |
|
| 709 | + $term = term_exists(trim($continent_label), 'continent'); |
|
| 710 | + if (!$term) { |
|
| 711 | + $term = wp_insert_term(trim($continent_label), 'continent'); |
|
| 712 | 712 | |
| 713 | - if ( is_wp_error( $term ) ) { |
|
| 714 | - echo wp_kses_post( $term->get_error_message() ); |
|
| 713 | + if (is_wp_error($term)) { |
|
| 714 | + echo wp_kses_post($term->get_error_message()); |
|
| 715 | 715 | } |
| 716 | - } else { |
|
| 717 | - wp_set_object_terms( $id, sanitize_title( $continent_label ), 'continent', true ); |
|
| 716 | + }else { |
|
| 717 | + wp_set_object_terms($id, sanitize_title($continent_label), 'continent', true); |
|
| 718 | 718 | } |
| 719 | 719 | } |
| 720 | 720 | } |
@@ -723,12 +723,12 @@ discard block |
||
| 723 | 723 | /** |
| 724 | 724 | * Save the list of Accommodation into an option |
| 725 | 725 | */ |
| 726 | - public function check_for_parent( $data = array() ) { |
|
| 726 | + public function check_for_parent($data = array()) { |
|
| 727 | 727 | global $wpdb; |
| 728 | 728 | |
| 729 | - if ( $data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id'] ) { |
|
| 730 | - $result = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'lsx_wetu_id' AND meta_value = '%s'", array( $data[0]['position']['country_content_entity_id'] ) ) ); |
|
| 731 | - if ( ! empty( $result ) && '' !== $result && false !== $result ) { |
|
| 729 | + if ($data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id']) { |
|
| 730 | + $result = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'lsx_wetu_id' AND meta_value = '%s'", array($data[0]['position']['country_content_entity_id']))); |
|
| 731 | + if (!empty($result) && '' !== $result && false !== $result) { |
|
| 732 | 732 | return $result; |
| 733 | 733 | } |
| 734 | 734 | } |