@@ -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,118 +136,118 @@ 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> |
|
| 156 | - <?php if ( class_exists( 'LSX_TO_Maps' ) ) { ?> |
|
| 155 | + value="gallery"/> <?php esc_html_e('Main Gallery', 'lsx-wetu-importer'); ?></li> |
|
| 156 | + <?php if (class_exists('LSX_TO_Maps')) { ?> |
|
| 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' ); ?></li> |
|
| 160 | + value="location"/> <?php esc_html_e('Location', 'lsx-wetu-importer'); ?></li> |
|
| 161 | 161 | <?php } ?> |
| 162 | 162 | |
| 163 | - <?php if ( class_exists( 'LSX_TO_Videos' ) ) { ?> |
|
| 163 | + <?php if (class_exists('LSX_TO_Videos')) { ?> |
|
| 164 | 164 | <li> |
| 165 | - <input class="content" <?php $this->checked( $this->destination_options, 'videos' ); ?> |
|
| 165 | + <input class="content" <?php $this->checked($this->destination_options, 'videos'); ?> |
|
| 166 | 166 | type="checkbox" name="content[]" |
| 167 | - value="videos"/> <?php esc_html_e( 'Videos', 'lsx-wetu-importer' ); ?></li> |
|
| 167 | + value="videos"/> <?php esc_html_e('Videos', 'lsx-wetu-importer'); ?></li> |
|
| 168 | 168 | <?php } ?> |
| 169 | 169 | |
| 170 | 170 | </ul> |
| 171 | - <h4><?php esc_html_e( 'Additional Content' ); ?></h4> |
|
| 171 | + <h4><?php esc_html_e('Additional Content'); ?></h4> |
|
| 172 | 172 | <ul> |
| 173 | 173 | <li> |
| 174 | - <input class="content" <?php $this->checked( $this->destination_options, 'country' ); ?> |
|
| 174 | + <input class="content" <?php $this->checked($this->destination_options, 'country'); ?> |
|
| 175 | 175 | type="checkbox" name="content[]" |
| 176 | - value="country"/> <?php esc_html_e( 'Set Country', 'lsx-wetu-importer' ); ?></li> |
|
| 176 | + value="country"/> <?php esc_html_e('Set Country', 'lsx-wetu-importer'); ?></li> |
|
| 177 | 177 | <li> |
| 178 | - <input class="content" <?php $this->checked( $this->destination_options, 'continent' ); ?> |
|
| 178 | + <input class="content" <?php $this->checked($this->destination_options, 'continent'); ?> |
|
| 179 | 179 | type="checkbox" name="content[]" |
| 180 | - value="continent"/> <?php esc_html_e( 'Set Continent', 'lsx-wetu-importer' ); ?></li> |
|
| 180 | + value="continent"/> <?php esc_html_e('Set Continent', 'lsx-wetu-importer'); ?></li> |
|
| 181 | 181 | |
| 182 | 182 | <li> |
| 183 | - <input class="content" <?php $this->checked( $this->destination_options, 'featured_image' ); ?> |
|
| 183 | + <input class="content" <?php $this->checked($this->destination_options, 'featured_image'); ?> |
|
| 184 | 184 | type="checkbox" name="content[]" |
| 185 | - value="featured_image"/> <?php esc_html_e( 'Set Featured Image', 'lsx-wetu-importer' ); ?> |
|
| 185 | + value="featured_image"/> <?php esc_html_e('Set Featured Image', 'lsx-wetu-importer'); ?> |
|
| 186 | 186 | </li> |
| 187 | - <?php if ( class_exists( 'LSX_Banners' ) ) { ?> |
|
| 187 | + <?php if (class_exists('LSX_Banners')) { ?> |
|
| 188 | 188 | <li> |
| 189 | - <input class="content" <?php $this->checked( $this->destination_options, 'banner_image' ); ?> |
|
| 189 | + <input class="content" <?php $this->checked($this->destination_options, 'banner_image'); ?> |
|
| 190 | 190 | type="checkbox" name="content[]" |
| 191 | - value="banner_image"/> <?php esc_html_e( 'Set Banner Image', 'lsx-wetu-importer' ); ?> |
|
| 191 | + value="banner_image"/> <?php esc_html_e('Set Banner Image', 'lsx-wetu-importer'); ?> |
|
| 192 | 192 | </li> |
| 193 | 193 | <li> |
| 194 | - <input class="content" <?php $this->checked( $this->destination_options, 'unique_banner_image' ); ?> |
|
| 194 | + <input class="content" <?php $this->checked($this->destination_options, 'unique_banner_image'); ?> |
|
| 195 | 195 | type="checkbox" name="content[]" |
| 196 | - value="unique_banner_image"/> <?php esc_html_e( 'Use the WETU banner field', 'lsx-wetu-importer' ); ?> |
|
| 196 | + value="unique_banner_image"/> <?php esc_html_e('Use the WETU banner field', 'lsx-wetu-importer'); ?> |
|
| 197 | 197 | </li> |
| 198 | 198 | <?php } ?> |
| 199 | 199 | |
| 200 | 200 | <li> |
| 201 | - <input class="content" <?php $this->checked( $this->destination_options, 'strip_tags' ); ?> |
|
| 201 | + <input class="content" <?php $this->checked($this->destination_options, 'strip_tags'); ?> |
|
| 202 | 202 | type="checkbox" name="content[]" |
| 203 | - value="strip_tags"/> <?php esc_html_e( 'Strip HTML from the description', 'lsx-wetu-importer' ); ?></li> |
|
| 203 | + value="strip_tags"/> <?php esc_html_e('Strip HTML from the description', 'lsx-wetu-importer'); ?></li> |
|
| 204 | 204 | </ul> |
| 205 | 205 | </div> |
| 206 | 206 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 207 | - <h3><?php esc_html_e( 'Travel Information' ); ?></h3> |
|
| 207 | + <h3><?php esc_html_e('Travel Information'); ?></h3> |
|
| 208 | 208 | <ul> |
| 209 | 209 | <li> |
| 210 | - <input class="content" <?php $this->checked( $this->destination_options, 'electricity' ); ?> |
|
| 210 | + <input class="content" <?php $this->checked($this->destination_options, 'electricity'); ?> |
|
| 211 | 211 | type="checkbox" name="content[]" |
| 212 | - value="electricity"/> <?php esc_html_e( 'Electricity', 'lsx-wetu-importer' ); ?></li> |
|
| 212 | + value="electricity"/> <?php esc_html_e('Electricity', 'lsx-wetu-importer'); ?></li> |
|
| 213 | 213 | <li> |
| 214 | - <input class="content" <?php $this->checked( $this->destination_options, 'banking' ); ?> |
|
| 214 | + <input class="content" <?php $this->checked($this->destination_options, 'banking'); ?> |
|
| 215 | 215 | type="checkbox" name="content[]" |
| 216 | - value="banking"/> <?php esc_html_e( 'Banking', 'lsx-wetu-importer' ); ?></li> |
|
| 216 | + value="banking"/> <?php esc_html_e('Banking', 'lsx-wetu-importer'); ?></li> |
|
| 217 | 217 | <li> |
| 218 | - <input class="content" <?php $this->checked( $this->destination_options, 'cuisine' ); ?> |
|
| 218 | + <input class="content" <?php $this->checked($this->destination_options, 'cuisine'); ?> |
|
| 219 | 219 | type="checkbox" name="content[]" |
| 220 | - value="cuisine"/> <?php esc_html_e( 'Cuisine', 'lsx-wetu-importer' ); ?></li> |
|
| 220 | + value="cuisine"/> <?php esc_html_e('Cuisine', 'lsx-wetu-importer'); ?></li> |
|
| 221 | 221 | <li> |
| 222 | - <input class="content" <?php $this->checked( $this->destination_options, 'climate' ); ?> |
|
| 222 | + <input class="content" <?php $this->checked($this->destination_options, 'climate'); ?> |
|
| 223 | 223 | type="checkbox" name="content[]" |
| 224 | - value="climate"/> <?php esc_html_e( 'Climate', 'lsx-wetu-importer' ); ?></li> |
|
| 224 | + value="climate"/> <?php esc_html_e('Climate', 'lsx-wetu-importer'); ?></li> |
|
| 225 | 225 | <li> |
| 226 | - <input class="content" <?php $this->checked( $this->destination_options, 'transport' ); ?> |
|
| 226 | + <input class="content" <?php $this->checked($this->destination_options, 'transport'); ?> |
|
| 227 | 227 | type="checkbox" name="content[]" |
| 228 | - value="transport"/> <?php esc_html_e( 'Transport', 'lsx-wetu-importer' ); ?></li> |
|
| 229 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'dress' ); ?> |
|
| 228 | + value="transport"/> <?php esc_html_e('Transport', 'lsx-wetu-importer'); ?></li> |
|
| 229 | + <li><input class="content" <?php $this->checked($this->destination_options, 'dress'); ?> |
|
| 230 | 230 | type="checkbox" name="content[]" |
| 231 | - value="dress"/> <?php esc_html_e( 'Dress', 'lsx-wetu-importer' ); ?></li> |
|
| 232 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'health' ); ?> |
|
| 231 | + value="dress"/> <?php esc_html_e('Dress', 'lsx-wetu-importer'); ?></li> |
|
| 232 | + <li><input class="content" <?php $this->checked($this->destination_options, 'health'); ?> |
|
| 233 | 233 | type="checkbox" name="content[]" |
| 234 | - value="health"/> <?php esc_html_e( 'Health', 'lsx-wetu-importer' ); ?></li> |
|
| 235 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'safety' ); ?> |
|
| 234 | + value="health"/> <?php esc_html_e('Health', 'lsx-wetu-importer'); ?></li> |
|
| 235 | + <li><input class="content" <?php $this->checked($this->destination_options, 'safety'); ?> |
|
| 236 | 236 | type="checkbox" name="content[]" |
| 237 | - value="safety"/> <?php esc_html_e( 'Safety', 'lsx-wetu-importer' ); ?></li> |
|
| 238 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'visa' ); ?> |
|
| 237 | + value="safety"/> <?php esc_html_e('Safety', 'lsx-wetu-importer'); ?></li> |
|
| 238 | + <li><input class="content" <?php $this->checked($this->destination_options, 'visa'); ?> |
|
| 239 | 239 | type="checkbox" name="content[]" |
| 240 | - value="visa"/> <?php esc_html_e( 'Visa', 'lsx-wetu-importer' ); ?></li> |
|
| 241 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'additional_info' ); ?> |
|
| 240 | + value="visa"/> <?php esc_html_e('Visa', 'lsx-wetu-importer'); ?></li> |
|
| 241 | + <li><input class="content" <?php $this->checked($this->destination_options, 'additional_info'); ?> |
|
| 242 | 242 | type="checkbox" name="content[]" |
| 243 | - value="additional_info"/> <?php esc_html_e( 'General', 'lsx-wetu-importer' ); ?></li> |
|
| 243 | + value="additional_info"/> <?php esc_html_e('General', 'lsx-wetu-importer'); ?></li> |
|
| 244 | 244 | </ul> |
| 245 | 245 | </div> |
| 246 | 246 | |
| 247 | - <?php if ( class_exists( 'LSX_TO_Team' ) ) { ?> |
|
| 247 | + <?php if (class_exists('LSX_TO_Team')) { ?> |
|
| 248 | 248 | <div style="width:30%;display:block;float:left;"> |
| 249 | - <h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3> |
|
| 250 | - <?php $this->team_member_checkboxes( $this->destination_options ); ?> |
|
| 249 | + <h3><?php esc_html_e('Assign a Team Member'); ?></h3> |
|
| 250 | + <?php $this->team_member_checkboxes($this->destination_options); ?> |
|
| 251 | 251 | </div> |
| 252 | 252 | <?php } ?> |
| 253 | 253 | |
@@ -255,9 +255,9 @@ discard block |
||
| 255 | 255 | </div> |
| 256 | 256 | |
| 257 | 257 | |
| 258 | - <h3><?php esc_html_e( 'Your List' ); ?></h3> |
|
| 258 | + <h3><?php esc_html_e('Your List'); ?></h3> |
|
| 259 | 259 | <p><input class="button button-primary" type="submit" |
| 260 | - value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>"/></p> |
|
| 260 | + value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>"/></p> |
|
| 261 | 261 | <table class="wp-list-table widefat fixed posts"> |
| 262 | 262 | <?php $this->table_header(); ?> |
| 263 | 263 | |
@@ -270,12 +270,12 @@ discard block |
||
| 270 | 270 | </table> |
| 271 | 271 | |
| 272 | 272 | <p><input class="button button-primary" type="submit" |
| 273 | - value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>"/></p> |
|
| 273 | + value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>"/></p> |
|
| 274 | 274 | </form> |
| 275 | 275 | </div> |
| 276 | 276 | |
| 277 | 277 | <div style="display:none;" class="completed-list-wrapper"> |
| 278 | - <h3><?php esc_html_e( 'Completed' ); ?></h3> |
|
| 278 | + <h3><?php esc_html_e('Completed'); ?></h3> |
|
| 279 | 279 | <ul> |
| 280 | 280 | </ul> |
| 281 | 281 | </div> |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | /** |
| 287 | 287 | * Grab all the current destination posts via the lsx_wetu_id field. |
| 288 | 288 | */ |
| 289 | - public function find_current_destination( $post_type = 'destination' ) { |
|
| 289 | + public function find_current_destination($post_type = 'destination') { |
|
| 290 | 290 | global $wpdb; |
| 291 | 291 | $return = array(); |
| 292 | 292 | |
@@ -305,9 +305,9 @@ discard block |
||
| 305 | 305 | "); |
| 306 | 306 | // @codingStandardsIgnoreEnd |
| 307 | 307 | |
| 308 | - if ( null !== $current_destination && ! empty( $current_destination ) ) { |
|
| 309 | - foreach ( $current_destination as $accom ) { |
|
| 310 | - $return[ $accom->meta_value ] = $accom; |
|
| 308 | + if (null !== $current_destination && !empty($current_destination)) { |
|
| 309 | + foreach ($current_destination as $accom) { |
|
| 310 | + $return[$accom->meta_value] = $accom; |
|
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
@@ -319,117 +319,117 @@ discard block |
||
| 319 | 319 | */ |
| 320 | 320 | public function process_ajax_search() { |
| 321 | 321 | $return = false; |
| 322 | - check_ajax_referer( 'lsx_wetu_ajax_action', 'security' ); |
|
| 323 | - if ( isset( $_POST['action'] ) && 'lsx_tour_importer' === $_POST['action'] && isset( $_POST['type'] ) && 'destination' === $_POST['type'] ) { |
|
| 322 | + check_ajax_referer('lsx_wetu_ajax_action', 'security'); |
|
| 323 | + if (isset($_POST['action']) && 'lsx_tour_importer' === $_POST['action'] && isset($_POST['type']) && 'destination' === $_POST['type']) { |
|
| 324 | 324 | |
| 325 | 325 | $searched_items = false; |
| 326 | - if ( isset( $_POST['keyword'] ) ) { |
|
| 327 | - $keyphrases = array_map( 'sanitize_text_field', wp_unslash( $_POST['keyword'] ) ); |
|
| 328 | - } else { |
|
| 329 | - $keyphrases = array( 0 ); |
|
| 326 | + if (isset($_POST['keyword'])) { |
|
| 327 | + $keyphrases = array_map('sanitize_text_field', wp_unslash($_POST['keyword'])); |
|
| 328 | + }else { |
|
| 329 | + $keyphrases = array(0); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - if ( ! is_array( $keyphrases ) ) { |
|
| 333 | - $keyphrases = array( $keyphrases ); |
|
| 332 | + if (!is_array($keyphrases)) { |
|
| 333 | + $keyphrases = array($keyphrases); |
|
| 334 | 334 | } |
| 335 | - foreach ( $keyphrases as &$keyword ) { |
|
| 336 | - $keyword = ltrim( rtrim( $keyword ) ); |
|
| 335 | + foreach ($keyphrases as &$keyword) { |
|
| 336 | + $keyword = ltrim(rtrim($keyword)); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | $post_status = false; |
| 340 | 340 | |
| 341 | - if ( in_array( 'publish', $keyphrases ) ) { |
|
| 341 | + if (in_array('publish', $keyphrases)) { |
|
| 342 | 342 | $post_status = 'publish'; |
| 343 | 343 | } |
| 344 | - if ( in_array( 'pending', $keyphrases ) ) { |
|
| 344 | + if (in_array('pending', $keyphrases)) { |
|
| 345 | 345 | $post_status = 'pending'; |
| 346 | 346 | } |
| 347 | - if ( in_array( 'draft', $keyphrases ) ) { |
|
| 347 | + if (in_array('draft', $keyphrases)) { |
|
| 348 | 348 | $post_status = 'draft'; |
| 349 | 349 | } |
| 350 | - if ( in_array( 'import', $keyphrases ) ) { |
|
| 350 | + if (in_array('import', $keyphrases)) { |
|
| 351 | 351 | $post_status = 'import'; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | // If there is a post status use it. |
| 355 | - if ( false !== $post_status ) { |
|
| 355 | + if (false !== $post_status) { |
|
| 356 | 356 | |
| 357 | 357 | $accommodation = array(); |
| 358 | - $current_accommodation = $this->find_current_accommodation( 'destination' ); |
|
| 359 | - if ( ! empty( $current_accommodation ) ) { |
|
| 360 | - foreach ( $current_accommodation as $cs_key => $ccs_id ) { |
|
| 361 | - $accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id ); |
|
| 358 | + $current_accommodation = $this->find_current_accommodation('destination'); |
|
| 359 | + if (!empty($current_accommodation)) { |
|
| 360 | + foreach ($current_accommodation as $cs_key => $ccs_id) { |
|
| 361 | + $accommodation[] = $this->prepare_row_attributes($cs_key, $ccs_id->post_id); |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | // Run through each accommodation and use it. |
| 366 | - if ( ! empty( $accommodation ) ) { |
|
| 367 | - foreach ( $accommodation as $row_key => $row ) { |
|
| 368 | - if ( 'import' === $post_status ) { |
|
| 369 | - |
|
| 370 | - if ( is_array( $this->queued_imports ) && in_array( $row['post_id'], $this->queued_imports ) ) { |
|
| 371 | - $current_status = get_post_status( $row['post_id'] ); |
|
| 372 | - if ( 'draft' === $current_status ) { |
|
| 373 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
|
| 366 | + if (!empty($accommodation)) { |
|
| 367 | + foreach ($accommodation as $row_key => $row) { |
|
| 368 | + if ('import' === $post_status) { |
|
| 369 | + |
|
| 370 | + if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) { |
|
| 371 | + $current_status = get_post_status($row['post_id']); |
|
| 372 | + if ('draft' === $current_status) { |
|
| 373 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
|
| 374 | 374 | } |
| 375 | - } else { |
|
| 375 | + }else { |
|
| 376 | 376 | continue; |
| 377 | 377 | } |
| 378 | - } else { |
|
| 379 | - if ( 0 === $row['post_id'] ) { |
|
| 378 | + }else { |
|
| 379 | + if (0 === $row['post_id']) { |
|
| 380 | 380 | continue; |
| 381 | - } else { |
|
| 382 | - $current_status = get_post_status( $row['post_id'] ); |
|
| 381 | + }else { |
|
| 382 | + $current_status = get_post_status($row['post_id']); |
|
| 383 | 383 | |
| 384 | - if ( $current_status !== $post_status ) { |
|
| 384 | + if ($current_status !== $post_status) { |
|
| 385 | 385 | continue; |
| 386 | 386 | } |
| 387 | 387 | } |
| 388 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
|
| 388 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
|
| 389 | 389 | } |
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | - } else { |
|
| 392 | + }else { |
|
| 393 | 393 | |
| 394 | - $key_string_search = implode( '+', $keyphrases ); |
|
| 395 | - $search_data = wp_remote_get( $this->url . '/Search/' . $key_string_search . '/?all=include' ); |
|
| 394 | + $key_string_search = implode('+', $keyphrases); |
|
| 395 | + $search_data = wp_remote_get($this->url.'/Search/'.$key_string_search.'/?all=include'); |
|
| 396 | 396 | |
| 397 | - if ( ! empty( $search_data ) && isset( $search_data['response'] ) && isset( $search_data['response']['code'] ) && 200 === $search_data['response']['code'] ) { |
|
| 398 | - $search_data = json_decode( $search_data['body'], true ); |
|
| 399 | - foreach ( $search_data as $sdata ) { |
|
| 397 | + if (!empty($search_data) && isset($search_data['response']) && isset($search_data['response']['code']) && 200 === $search_data['response']['code']) { |
|
| 398 | + $search_data = json_decode($search_data['body'], true); |
|
| 399 | + foreach ($search_data as $sdata) { |
|
| 400 | 400 | |
| 401 | - if ( 'Destination' !== trim( $sdata['type'] ) ) { |
|
| 401 | + if ('Destination' !== trim($sdata['type'])) { |
|
| 402 | 402 | continue; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - $temp_id = $this->get_post_id_by_key_value( $sdata['id'] ); |
|
| 406 | - if ( false === $temp_id ) { |
|
| 405 | + $temp_id = $this->get_post_id_by_key_value($sdata['id']); |
|
| 406 | + if (false === $temp_id) { |
|
| 407 | 407 | $sdata['post_id'] = 0; |
| 408 | - } else { |
|
| 408 | + }else { |
|
| 409 | 409 | $sdata['post_id'] = $temp_id; |
| 410 | 410 | } |
| 411 | - $searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata ); |
|
| 411 | + $searched_items[sanitize_title($sdata['name']).'-'.$sdata['id']] = $this->format_row($sdata); |
|
| 412 | 412 | } |
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - if ( false !== $searched_items ) { |
|
| 417 | - ksort( $searched_items ); |
|
| 418 | - $return = implode( $searched_items ); |
|
| 416 | + if (false !== $searched_items) { |
|
| 417 | + ksort($searched_items); |
|
| 418 | + $return = implode($searched_items); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - print_r( $return ); |
|
| 421 | + print_r($return); |
|
| 422 | 422 | } |
| 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,28 +438,28 @@ discard block |
||
| 438 | 438 | /** |
| 439 | 439 | * Formats the row for output on the screen. |
| 440 | 440 | */ |
| 441 | - public function format_row( $row = false ) { |
|
| 442 | - if ( false !== $row ) { |
|
| 441 | + public function format_row($row = false) { |
|
| 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="post-title page-title column-title"> |
| 456 | - <strong>' . $row['name'] . '</strong> - ' . $status . ' |
|
| 456 | + <strong>' . $row['name'].'</strong> - '.$status.' |
|
| 457 | 457 | </td> |
| 458 | 458 | <td class="date column-date"> |
| 459 | - <abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified |
|
| 459 | + <abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
| 460 | 460 | </td> |
| 461 | 461 | <td class="ssid column-ssid"> |
| 462 | - ' . $row['id'] . ' |
|
| 462 | + ' . $row['id'].' |
|
| 463 | 463 | </td> |
| 464 | 464 | </tr>'; |
| 465 | 465 | return $row_html; |
@@ -472,44 +472,44 @@ discard block |
||
| 472 | 472 | public function process_ajax_import() { |
| 473 | 473 | $return = false; |
| 474 | 474 | |
| 475 | - check_ajax_referer( 'lsx_wetu_ajax_action', 'security' ); |
|
| 476 | - if ( isset( $_POST['action'] ) && 'lsx_import_items' === $_POST['action'] && isset( $_POST['type'] ) && 'destination' === $_POST['type'] && isset( $_POST['wetu_id'] ) ) { |
|
| 475 | + check_ajax_referer('lsx_wetu_ajax_action', 'security'); |
|
| 476 | + if (isset($_POST['action']) && 'lsx_import_items' === $_POST['action'] && isset($_POST['type']) && 'destination' === $_POST['type'] && isset($_POST['wetu_id'])) { |
|
| 477 | 477 | |
| 478 | - $wetu_id = sanitize_text_field( $_POST['wetu_id'] ); |
|
| 478 | + $wetu_id = sanitize_text_field($_POST['wetu_id']); |
|
| 479 | 479 | |
| 480 | - if ( isset( $_POST['post_id'] ) ) { |
|
| 481 | - $post_id = sanitize_text_field( $_POST['post_id'] ); |
|
| 482 | - $this->current_post = get_post( $post_id ); |
|
| 483 | - } else { |
|
| 480 | + if (isset($_POST['post_id'])) { |
|
| 481 | + $post_id = sanitize_text_field($_POST['post_id']); |
|
| 482 | + $this->current_post = get_post($post_id); |
|
| 483 | + }else { |
|
| 484 | 484 | $post_id = 0; |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | - if ( isset( $_POST['team_members'] ) ) { |
|
| 488 | - $team_members = sanitize_text_field( $_POST['team_members'] ); |
|
| 489 | - } else { |
|
| 487 | + if (isset($_POST['team_members'])) { |
|
| 488 | + $team_members = sanitize_text_field($_POST['team_members']); |
|
| 489 | + }else { |
|
| 490 | 490 | $team_members = false; |
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | $safari_brands = false; |
| 494 | 494 | |
| 495 | - delete_option( 'lsx_wetu_importer_destination_settings' ); |
|
| 495 | + delete_option('lsx_wetu_importer_destination_settings'); |
|
| 496 | 496 | |
| 497 | - if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) { |
|
| 498 | - $content = array_map( 'sanitize_text_field', wp_unslash( $_POST['content'] ) ); |
|
| 499 | - add_option( 'lsx_wetu_importer_destination_settings', $content ); |
|
| 500 | - } else { |
|
| 497 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
| 498 | + $content = array_map('sanitize_text_field', wp_unslash($_POST['content'])); |
|
| 499 | + add_option('lsx_wetu_importer_destination_settings', $content); |
|
| 500 | + }else { |
|
| 501 | 501 | $content = false; |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - $jdata = wp_remote_get( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
| 504 | + $jdata = wp_remote_get($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id); |
|
| 505 | 505 | |
| 506 | - if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) { |
|
| 507 | - $adata = json_decode( $jdata['body'], true ); |
|
| 508 | - $return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands ); |
|
| 509 | - $this->remove_from_queue( $return ); |
|
| 510 | - $this->format_completed_row( $return ); |
|
| 511 | - } else { |
|
| 512 | - $this->format_error( esc_html__( 'There was a problem importing your destination, please try refreshing the page.', 'lsx-wetu-importer' ) ); |
|
| 506 | + if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) { |
|
| 507 | + $adata = json_decode($jdata['body'], true); |
|
| 508 | + $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
|
| 509 | + $this->remove_from_queue($return); |
|
| 510 | + $this->format_completed_row($return); |
|
| 511 | + }else { |
|
| 512 | + $this->format_error(esc_html__('There was a problem importing your destination, please try refreshing the page.', 'lsx-wetu-importer')); |
|
| 513 | 513 | } |
| 514 | 514 | } |
| 515 | 515 | } |
@@ -517,14 +517,14 @@ discard block |
||
| 517 | 517 | /** |
| 518 | 518 | * Saves the queue to the option. |
| 519 | 519 | */ |
| 520 | - public function remove_from_queue( $id ) { |
|
| 521 | - if ( ! empty( $this->queued_imports ) ) { |
|
| 522 | - $key = array_search( $id, $this->queued_imports ); |
|
| 523 | - if ( false !== $key ) { |
|
| 524 | - unset( $this->queued_imports[ $key ] ); |
|
| 520 | + public function remove_from_queue($id) { |
|
| 521 | + if (!empty($this->queued_imports)) { |
|
| 522 | + $key = array_search($id, $this->queued_imports); |
|
| 523 | + if (false !== $key) { |
|
| 524 | + unset($this->queued_imports[$key]); |
|
| 525 | 525 | |
| 526 | - delete_option( 'lsx_wetu_importer_que' ); |
|
| 527 | - update_option( 'lsx_wetu_importer_que', $this->queued_imports ); |
|
| 526 | + delete_option('lsx_wetu_importer_que'); |
|
| 527 | + update_option('lsx_wetu_importer_que', $this->queued_imports); |
|
| 528 | 528 | } |
| 529 | 529 | } |
| 530 | 530 | } |
@@ -532,8 +532,8 @@ discard block |
||
| 532 | 532 | /** |
| 533 | 533 | * Connect to wetu |
| 534 | 534 | */ |
| 535 | - public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false ) { |
|
| 536 | - if ( 'Destination' === trim( $data[0]['type'] ) ) { |
|
| 535 | + public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false) { |
|
| 536 | + if ('Destination' === trim($data[0]['type'])) { |
|
| 537 | 537 | $post_name = ''; |
| 538 | 538 | $data_post_content = ''; |
| 539 | 539 | $data_post_excerpt = ''; |
@@ -542,132 +542,132 @@ discard block |
||
| 542 | 542 | 'post_type' => 'destination', |
| 543 | 543 | ); |
| 544 | 544 | |
| 545 | - if ( ! empty( $importable_content ) && in_array( 'country', $importable_content ) ) { |
|
| 546 | - $parent = $this->check_for_parent( $data ); |
|
| 547 | - if ( false !== $parent ) { |
|
| 545 | + if (!empty($importable_content) && in_array('country', $importable_content)) { |
|
| 546 | + $parent = $this->check_for_parent($data); |
|
| 547 | + if (false !== $parent) { |
|
| 548 | 548 | $post['post_parent'] = $parent; |
| 549 | 549 | } |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | // Set the post_content. |
| 553 | - if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) { |
|
| 554 | - if ( isset( $data[0]['content']['general_description'] ) ) { |
|
| 553 | + if (!empty($importable_content) && in_array('description', $importable_content)) { |
|
| 554 | + if (isset($data[0]['content']['general_description'])) { |
|
| 555 | 555 | |
| 556 | - if ( in_array( 'strip_tags', $importable_content ) ) { |
|
| 557 | - $post['post_content'] = wp_strip_all_tags( $data[0]['content']['general_description'] ); |
|
| 558 | - } else { |
|
| 556 | + if (in_array('strip_tags', $importable_content)) { |
|
| 557 | + $post['post_content'] = wp_strip_all_tags($data[0]['content']['general_description']); |
|
| 558 | + }else { |
|
| 559 | 559 | $post['post_content'] = $data[0]['content']['general_description']; |
| 560 | 560 | } |
| 561 | 561 | } |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | - if ( false !== $id && '0' !== $id ) { |
|
| 564 | + if (false !== $id && '0' !== $id) { |
|
| 565 | 565 | $post['ID'] = $id; |
| 566 | 566 | |
| 567 | - if ( isset( $data[0]['name'] ) ) { |
|
| 567 | + if (isset($data[0]['name'])) { |
|
| 568 | 568 | $post['post_title'] = $data[0]['name']; |
| 569 | 569 | $post['post_status'] = 'publish'; |
| 570 | - $post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 ); |
|
| 570 | + $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0); |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | - $id = wp_update_post( $post ); |
|
| 574 | - $prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true ); |
|
| 575 | - update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date ); |
|
| 576 | - } else { |
|
| 573 | + $id = wp_update_post($post); |
|
| 574 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
| 575 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date); |
|
| 576 | + }else { |
|
| 577 | 577 | // Set the name. |
| 578 | - if ( isset( $data[0]['name'] ) ) { |
|
| 579 | - $post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 ); |
|
| 578 | + if (isset($data[0]['name'])) { |
|
| 579 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0); |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | $post['post_name'] = $post_name; |
| 583 | 583 | $post['post_title'] = $data[0]['name']; |
| 584 | 584 | $post['post_status'] = 'publish'; |
| 585 | - $id = wp_insert_post( $post ); |
|
| 585 | + $id = wp_insert_post($post); |
|
| 586 | 586 | |
| 587 | 587 | // Save the WETU ID and the Last date it was modified. |
| 588 | - if ( false !== $id ) { |
|
| 589 | - add_post_meta( $id, 'lsx_wetu_id', $wetu_id ); |
|
| 590 | - add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) ); |
|
| 588 | + if (false !== $id) { |
|
| 589 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
| 590 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified'])); |
|
| 591 | 591 | } |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - $this->find_attachments( $id ); |
|
| 594 | + $this->find_attachments($id); |
|
| 595 | 595 | |
| 596 | 596 | // Set the team member if it is there. |
| 597 | - if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) { |
|
| 598 | - $this->set_team_member( $id, $team_members ); |
|
| 597 | + if (post_type_exists('team') && false !== $team_members && '' !== $team_members) { |
|
| 598 | + $this->set_team_member($id, $team_members); |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | - if ( class_exists( 'LSX_TO_Maps' ) ) { |
|
| 602 | - $this->set_map_data( $data, $id, 9 ); |
|
| 601 | + if (class_exists('LSX_TO_Maps')) { |
|
| 602 | + $this->set_map_data($data, $id, 9); |
|
| 603 | 603 | } |
| 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 | } |