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