@@ -70,17 +70,17 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function set_variables() { |
| 72 | 72 | parent::set_variables(); |
| 73 | - $this->url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
| 73 | + $this->url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
| 74 | 74 | $this->url_qs = 'all=include'; |
| 75 | - $temp_options = get_option( '_lsx-to_settings', false ); |
|
| 75 | + $temp_options = get_option('_lsx-to_settings', false); |
|
| 76 | 76 | |
| 77 | - if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) { |
|
| 78 | - $this->options = $temp_options[ $this->plugin_slug ]; |
|
| 77 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
| 78 | + $this->options = $temp_options[$this->plugin_slug]; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - $destination_options = get_option( 'lsx_wetu_importer_destination_settings', false ); |
|
| 81 | + $destination_options = get_option('lsx_wetu_importer_destination_settings', false); |
|
| 82 | 82 | |
| 83 | - if ( false !== $destination_options ) { |
|
| 83 | + if (false !== $destination_options) { |
|
| 84 | 84 | $this->destination_options = $destination_options; |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | </div> |
| 99 | 99 | |
| 100 | 100 | <form method="get" action="" id="posts-filter"> |
| 101 | - <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>"/> |
|
| 101 | + <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>"/> |
|
| 102 | 102 | |
| 103 | 103 | <table class="wp-list-table widefat fixed posts"> |
| 104 | 104 | <?php $this->table_header(); ?> |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | <tr class="post-0 type-tour status-none" id="post-0"> |
| 108 | 108 | <th class="check-column" scope="row"> |
| 109 | 109 | <label for="cb-select-0" |
| 110 | - class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter', 'lsx-wetu-importer' ); ?></label> |
|
| 110 | + class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'lsx-wetu-importer'); ?></label> |
|
| 111 | 111 | </th> |
| 112 | 112 | <td class="post-title page-title column-title"> |
| 113 | 113 | <strong> |
| 114 | - <?php esc_html_e( 'Enter a title to search for', 'lsx-wetu-importer' ); ?> |
|
| 114 | + <?php esc_html_e('Enter a title to search for', 'lsx-wetu-importer'); ?> |
|
| 115 | 115 | </strong> |
| 116 | 116 | </td> |
| 117 | 117 | <td class="date column-date"> |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | </table> |
| 127 | 127 | |
| 128 | 128 | <p><input class="button button-primary add" type="button" |
| 129 | - value="<?php esc_html_e( 'Add to List', 'lsx-wetu-importer' ); ?>"/> |
|
| 129 | + value="<?php esc_html_e('Add to List', 'lsx-wetu-importer'); ?>"/> |
|
| 130 | 130 | <input class="button button-primary clear" type="button" |
| 131 | - value="<?php esc_html_e( 'Clear', 'lsx-wetu-importer' ); ?>"/> |
|
| 131 | + value="<?php esc_html_e('Clear', 'lsx-wetu-importer'); ?>"/> |
|
| 132 | 132 | </p> |
| 133 | 133 | </form> |
| 134 | 134 | |
@@ -138,119 +138,119 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | <div class="row"> |
| 140 | 140 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 141 | - <h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3> |
|
| 141 | + <h3><?php esc_html_e('What content to Sync from WETU'); ?></h3> |
|
| 142 | 142 | <ul> |
| 143 | 143 | <li> |
| 144 | - <input class="content select-all" <?php $this->checked( $this->destination_options, 'all' ); ?> |
|
| 144 | + <input class="content select-all" <?php $this->checked($this->destination_options, 'all'); ?> |
|
| 145 | 145 | type="checkbox" name="content[]" |
| 146 | - value="all"/> <?php esc_html_e( 'Select All', 'lsx-wetu-importer' ); ?></li> |
|
| 147 | - <?php if ( isset( $this->options ) && isset( $this->options['disable_destination_descriptions'] ) && 'on' !== $this->options['disable_destination_descriptions'] ) { ?> |
|
| 146 | + value="all"/> <?php esc_html_e('Select All', 'lsx-wetu-importer'); ?></li> |
|
| 147 | + <?php if (isset($this->options) && isset($this->options['disable_destination_descriptions']) && 'on' !== $this->options['disable_destination_descriptions']) { ?> |
|
| 148 | 148 | <li> |
| 149 | - <input class="content" <?php $this->checked( $this->destination_options, 'description' ); ?> |
|
| 149 | + <input class="content" <?php $this->checked($this->destination_options, 'description'); ?> |
|
| 150 | 150 | type="checkbox" name="content[]" |
| 151 | - value="description"/> <?php esc_html_e( 'Description', 'lsx-wetu-importer' ); ?></li> |
|
| 151 | + value="description"/> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li> |
|
| 152 | 152 | <?php } ?> |
| 153 | 153 | |
| 154 | 154 | <li> |
| 155 | - <input class="content" <?php $this->checked( $this->destination_options, 'gallery' ); ?> |
|
| 155 | + <input class="content" <?php $this->checked($this->destination_options, 'gallery'); ?> |
|
| 156 | 156 | type="checkbox" name="content[]" |
| 157 | - value="gallery"/> <?php esc_html_e( 'Main Gallery', 'lsx-wetu-importer' ); ?></li> |
|
| 157 | + value="gallery"/> <?php esc_html_e('Main Gallery', 'lsx-wetu-importer'); ?></li> |
|
| 158 | 158 | |
| 159 | 159 | <li> |
| 160 | - <input class="content" <?php $this->checked( $this->destination_options, 'location' ); ?> |
|
| 160 | + <input class="content" <?php $this->checked($this->destination_options, 'location'); ?> |
|
| 161 | 161 | type="checkbox" name="content[]" |
| 162 | - value="location"/> <?php esc_html_e( 'Location', 'lsx-wetu-importer' ); ?> |
|
| 162 | + value="location"/> <?php esc_html_e('Location', 'lsx-wetu-importer'); ?> |
|
| 163 | 163 | </li> |
| 164 | 164 | |
| 165 | 165 | |
| 166 | - <?php if ( class_exists( 'LSX_TO_Videos' ) ) { ?> |
|
| 166 | + <?php if (class_exists('LSX_TO_Videos')) { ?> |
|
| 167 | 167 | <li> |
| 168 | - <input class="content" <?php $this->checked( $this->destination_options, 'videos' ); ?> |
|
| 168 | + <input class="content" <?php $this->checked($this->destination_options, 'videos'); ?> |
|
| 169 | 169 | type="checkbox" name="content[]" |
| 170 | - value="videos"/> <?php esc_html_e( 'Videos', 'lsx-wetu-importer' ); ?></li> |
|
| 170 | + value="videos"/> <?php esc_html_e('Videos', 'lsx-wetu-importer'); ?></li> |
|
| 171 | 171 | <?php } ?> |
| 172 | 172 | |
| 173 | 173 | </ul> |
| 174 | - <h4><?php esc_html_e( 'Additional Content' ); ?></h4> |
|
| 174 | + <h4><?php esc_html_e('Additional Content'); ?></h4> |
|
| 175 | 175 | <ul> |
| 176 | 176 | <li> |
| 177 | - <input class="content" <?php $this->checked( $this->destination_options, 'country' ); ?> |
|
| 177 | + <input class="content" <?php $this->checked($this->destination_options, 'country'); ?> |
|
| 178 | 178 | type="checkbox" name="content[]" |
| 179 | - value="country"/> <?php esc_html_e( 'Set Country', 'lsx-wetu-importer' ); ?></li> |
|
| 179 | + value="country"/> <?php esc_html_e('Set Country', 'lsx-wetu-importer'); ?></li> |
|
| 180 | 180 | <li> |
| 181 | - <input class="content" <?php $this->checked( $this->destination_options, 'continent' ); ?> |
|
| 181 | + <input class="content" <?php $this->checked($this->destination_options, 'continent'); ?> |
|
| 182 | 182 | type="checkbox" name="content[]" |
| 183 | - value="continent"/> <?php esc_html_e( 'Set Continent', 'lsx-wetu-importer' ); ?></li> |
|
| 183 | + value="continent"/> <?php esc_html_e('Set Continent', 'lsx-wetu-importer'); ?></li> |
|
| 184 | 184 | |
| 185 | 185 | <li> |
| 186 | - <input class="content" <?php $this->checked( $this->destination_options, 'featured_image' ); ?> |
|
| 186 | + <input class="content" <?php $this->checked($this->destination_options, 'featured_image'); ?> |
|
| 187 | 187 | type="checkbox" name="content[]" |
| 188 | - value="featured_image"/> <?php esc_html_e( 'Set Featured Image', 'lsx-wetu-importer' ); ?> |
|
| 188 | + value="featured_image"/> <?php esc_html_e('Set Featured Image', 'lsx-wetu-importer'); ?> |
|
| 189 | 189 | </li> |
| 190 | - <?php if ( class_exists( 'LSX_Banners' ) ) { ?> |
|
| 190 | + <?php if (class_exists('LSX_Banners')) { ?> |
|
| 191 | 191 | <li> |
| 192 | - <input class="content" <?php $this->checked( $this->destination_options, 'banner_image' ); ?> |
|
| 192 | + <input class="content" <?php $this->checked($this->destination_options, 'banner_image'); ?> |
|
| 193 | 193 | type="checkbox" name="content[]" |
| 194 | - value="banner_image"/> <?php esc_html_e( 'Set Banner Image', 'lsx-wetu-importer' ); ?> |
|
| 194 | + value="banner_image"/> <?php esc_html_e('Set Banner Image', 'lsx-wetu-importer'); ?> |
|
| 195 | 195 | </li> |
| 196 | 196 | <li> |
| 197 | - <input class="content" <?php $this->checked( $this->destination_options, 'unique_banner_image' ); ?> |
|
| 197 | + <input class="content" <?php $this->checked($this->destination_options, 'unique_banner_image'); ?> |
|
| 198 | 198 | type="checkbox" name="content[]" |
| 199 | - value="unique_banner_image"/> <?php esc_html_e( 'Use the WETU banner field', 'lsx-wetu-importer' ); ?> |
|
| 199 | + value="unique_banner_image"/> <?php esc_html_e('Use the WETU banner field', 'lsx-wetu-importer'); ?> |
|
| 200 | 200 | </li> |
| 201 | 201 | <?php } ?> |
| 202 | 202 | |
| 203 | 203 | <li> |
| 204 | - <input class="content" <?php $this->checked( $this->destination_options, 'strip_tags' ); ?> |
|
| 204 | + <input class="content" <?php $this->checked($this->destination_options, 'strip_tags'); ?> |
|
| 205 | 205 | type="checkbox" name="content[]" |
| 206 | - value="strip_tags"/> <?php esc_html_e( 'Strip HTML from the description', 'lsx-wetu-importer' ); ?></li> |
|
| 206 | + value="strip_tags"/> <?php esc_html_e('Strip HTML from the description', 'lsx-wetu-importer'); ?></li> |
|
| 207 | 207 | </ul> |
| 208 | 208 | </div> |
| 209 | 209 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 210 | - <h3><?php esc_html_e( 'Travel Information' ); ?></h3> |
|
| 210 | + <h3><?php esc_html_e('Travel Information'); ?></h3> |
|
| 211 | 211 | <ul> |
| 212 | 212 | <li> |
| 213 | - <input class="content" <?php $this->checked( $this->destination_options, 'electricity' ); ?> |
|
| 213 | + <input class="content" <?php $this->checked($this->destination_options, 'electricity'); ?> |
|
| 214 | 214 | type="checkbox" name="content[]" |
| 215 | - value="electricity"/> <?php esc_html_e( 'Electricity', 'lsx-wetu-importer' ); ?></li> |
|
| 215 | + value="electricity"/> <?php esc_html_e('Electricity', 'lsx-wetu-importer'); ?></li> |
|
| 216 | 216 | <li> |
| 217 | - <input class="content" <?php $this->checked( $this->destination_options, 'banking' ); ?> |
|
| 217 | + <input class="content" <?php $this->checked($this->destination_options, 'banking'); ?> |
|
| 218 | 218 | type="checkbox" name="content[]" |
| 219 | - value="banking"/> <?php esc_html_e( 'Banking', 'lsx-wetu-importer' ); ?></li> |
|
| 219 | + value="banking"/> <?php esc_html_e('Banking', 'lsx-wetu-importer'); ?></li> |
|
| 220 | 220 | <li> |
| 221 | - <input class="content" <?php $this->checked( $this->destination_options, 'cuisine' ); ?> |
|
| 221 | + <input class="content" <?php $this->checked($this->destination_options, 'cuisine'); ?> |
|
| 222 | 222 | type="checkbox" name="content[]" |
| 223 | - value="cuisine"/> <?php esc_html_e( 'Cuisine', 'lsx-wetu-importer' ); ?></li> |
|
| 223 | + value="cuisine"/> <?php esc_html_e('Cuisine', 'lsx-wetu-importer'); ?></li> |
|
| 224 | 224 | <li> |
| 225 | - <input class="content" <?php $this->checked( $this->destination_options, 'climate' ); ?> |
|
| 225 | + <input class="content" <?php $this->checked($this->destination_options, 'climate'); ?> |
|
| 226 | 226 | type="checkbox" name="content[]" |
| 227 | - value="climate"/> <?php esc_html_e( 'Climate', 'lsx-wetu-importer' ); ?></li> |
|
| 227 | + value="climate"/> <?php esc_html_e('Climate', 'lsx-wetu-importer'); ?></li> |
|
| 228 | 228 | <li> |
| 229 | - <input class="content" <?php $this->checked( $this->destination_options, 'transport' ); ?> |
|
| 229 | + <input class="content" <?php $this->checked($this->destination_options, 'transport'); ?> |
|
| 230 | 230 | type="checkbox" name="content[]" |
| 231 | - value="transport"/> <?php esc_html_e( 'Transport', 'lsx-wetu-importer' ); ?></li> |
|
| 232 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'dress' ); ?> |
|
| 231 | + value="transport"/> <?php esc_html_e('Transport', 'lsx-wetu-importer'); ?></li> |
|
| 232 | + <li><input class="content" <?php $this->checked($this->destination_options, 'dress'); ?> |
|
| 233 | 233 | type="checkbox" name="content[]" |
| 234 | - value="dress"/> <?php esc_html_e( 'Dress', 'lsx-wetu-importer' ); ?></li> |
|
| 235 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'health' ); ?> |
|
| 234 | + value="dress"/> <?php esc_html_e('Dress', 'lsx-wetu-importer'); ?></li> |
|
| 235 | + <li><input class="content" <?php $this->checked($this->destination_options, 'health'); ?> |
|
| 236 | 236 | type="checkbox" name="content[]" |
| 237 | - value="health"/> <?php esc_html_e( 'Health', 'lsx-wetu-importer' ); ?></li> |
|
| 238 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'safety' ); ?> |
|
| 237 | + value="health"/> <?php esc_html_e('Health', 'lsx-wetu-importer'); ?></li> |
|
| 238 | + <li><input class="content" <?php $this->checked($this->destination_options, 'safety'); ?> |
|
| 239 | 239 | type="checkbox" name="content[]" |
| 240 | - value="safety"/> <?php esc_html_e( 'Safety', 'lsx-wetu-importer' ); ?></li> |
|
| 241 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'visa' ); ?> |
|
| 240 | + value="safety"/> <?php esc_html_e('Safety', 'lsx-wetu-importer'); ?></li> |
|
| 241 | + <li><input class="content" <?php $this->checked($this->destination_options, 'visa'); ?> |
|
| 242 | 242 | type="checkbox" name="content[]" |
| 243 | - value="visa"/> <?php esc_html_e( 'Visa', 'lsx-wetu-importer' ); ?></li> |
|
| 244 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'additional_info' ); ?> |
|
| 243 | + value="visa"/> <?php esc_html_e('Visa', 'lsx-wetu-importer'); ?></li> |
|
| 244 | + <li><input class="content" <?php $this->checked($this->destination_options, 'additional_info'); ?> |
|
| 245 | 245 | type="checkbox" name="content[]" |
| 246 | - value="additional_info"/> <?php esc_html_e( 'General', 'lsx-wetu-importer' ); ?></li> |
|
| 246 | + value="additional_info"/> <?php esc_html_e('General', 'lsx-wetu-importer'); ?></li> |
|
| 247 | 247 | </ul> |
| 248 | 248 | </div> |
| 249 | 249 | |
| 250 | - <?php if ( class_exists( 'LSX_TO_Team' ) ) { ?> |
|
| 250 | + <?php if (class_exists('LSX_TO_Team')) { ?> |
|
| 251 | 251 | <div style="width:30%;display:block;float:left;"> |
| 252 | - <h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3> |
|
| 253 | - <?php $this->team_member_checkboxes( $this->destination_options ); ?> |
|
| 252 | + <h3><?php esc_html_e('Assign a Team Member'); ?></h3> |
|
| 253 | + <?php $this->team_member_checkboxes($this->destination_options); ?> |
|
| 254 | 254 | </div> |
| 255 | 255 | <?php } ?> |
| 256 | 256 | |
@@ -258,9 +258,9 @@ discard block |
||
| 258 | 258 | </div> |
| 259 | 259 | |
| 260 | 260 | |
| 261 | - <h3><?php esc_html_e( 'Your List' ); ?></h3> |
|
| 261 | + <h3><?php esc_html_e('Your List'); ?></h3> |
|
| 262 | 262 | <p><input class="button button-primary" type="submit" |
| 263 | - value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>"/></p> |
|
| 263 | + value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>"/></p> |
|
| 264 | 264 | <table class="wp-list-table widefat fixed posts"> |
| 265 | 265 | <?php $this->table_header(); ?> |
| 266 | 266 | |
@@ -273,12 +273,12 @@ discard block |
||
| 273 | 273 | </table> |
| 274 | 274 | |
| 275 | 275 | <p><input class="button button-primary" type="submit" |
| 276 | - value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>"/></p> |
|
| 276 | + value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>"/></p> |
|
| 277 | 277 | </form> |
| 278 | 278 | </div> |
| 279 | 279 | |
| 280 | 280 | <div style="display:none;" class="completed-list-wrapper"> |
| 281 | - <h3><?php esc_html_e( 'Completed' ); ?></h3> |
|
| 281 | + <h3><?php esc_html_e('Completed'); ?></h3> |
|
| 282 | 282 | <ul> |
| 283 | 283 | </ul> |
| 284 | 284 | </div> |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | /** |
| 290 | 290 | * Grab all the current destination posts via the lsx_wetu_id field. |
| 291 | 291 | */ |
| 292 | - public function find_current_destination( $post_type = 'destination' ) { |
|
| 292 | + public function find_current_destination($post_type = 'destination') { |
|
| 293 | 293 | global $wpdb; |
| 294 | 294 | $return = array(); |
| 295 | 295 | |
@@ -308,9 +308,9 @@ discard block |
||
| 308 | 308 | "); |
| 309 | 309 | // @codingStandardsIgnoreEnd |
| 310 | 310 | |
| 311 | - if ( null !== $current_destination && ! empty( $current_destination ) ) { |
|
| 312 | - foreach ( $current_destination as $accom ) { |
|
| 313 | - $return[ $accom->meta_value ] = $accom; |
|
| 311 | + if (null !== $current_destination && !empty($current_destination)) { |
|
| 312 | + foreach ($current_destination as $accom) { |
|
| 313 | + $return[$accom->meta_value] = $accom; |
|
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | |
@@ -322,118 +322,118 @@ discard block |
||
| 322 | 322 | */ |
| 323 | 323 | public function process_ajax_search() { |
| 324 | 324 | $return = false; |
| 325 | - check_ajax_referer( 'lsx_wetu_ajax_action', 'security' ); |
|
| 326 | - if ( isset( $_POST['action'] ) && 'lsx_tour_importer' === $_POST['action'] && isset( $_POST['type'] ) && 'destination' === $_POST['type'] ) { |
|
| 325 | + check_ajax_referer('lsx_wetu_ajax_action', 'security'); |
|
| 326 | + if (isset($_POST['action']) && 'lsx_tour_importer' === $_POST['action'] && isset($_POST['type']) && 'destination' === $_POST['type']) { |
|
| 327 | 327 | |
| 328 | 328 | $searched_items = false; |
| 329 | - if ( isset( $_POST['keyword'] ) ) { |
|
| 330 | - $keyphrases = array_map( 'sanitize_text_field', wp_unslash( $_POST['keyword'] ) ); |
|
| 331 | - } else { |
|
| 332 | - $keyphrases = array( 0 ); |
|
| 329 | + if (isset($_POST['keyword'])) { |
|
| 330 | + $keyphrases = array_map('sanitize_text_field', wp_unslash($_POST['keyword'])); |
|
| 331 | + }else { |
|
| 332 | + $keyphrases = array(0); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - if ( ! is_array( $keyphrases ) ) { |
|
| 336 | - $keyphrases = array( $keyphrases ); |
|
| 335 | + if (!is_array($keyphrases)) { |
|
| 336 | + $keyphrases = array($keyphrases); |
|
| 337 | 337 | } |
| 338 | - foreach ( $keyphrases as &$keyword ) { |
|
| 339 | - $keyword = ltrim( rtrim( $keyword ) ); |
|
| 338 | + foreach ($keyphrases as &$keyword) { |
|
| 339 | + $keyword = ltrim(rtrim($keyword)); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | $post_status = false; |
| 343 | 343 | |
| 344 | - if ( in_array( 'publish', $keyphrases ) ) { |
|
| 344 | + if (in_array('publish', $keyphrases)) { |
|
| 345 | 345 | $post_status = 'publish'; |
| 346 | 346 | } |
| 347 | - if ( in_array( 'pending', $keyphrases ) ) { |
|
| 347 | + if (in_array('pending', $keyphrases)) { |
|
| 348 | 348 | $post_status = 'pending'; |
| 349 | 349 | } |
| 350 | - if ( in_array( 'draft', $keyphrases ) ) { |
|
| 350 | + if (in_array('draft', $keyphrases)) { |
|
| 351 | 351 | $post_status = 'draft'; |
| 352 | 352 | } |
| 353 | - if ( in_array( 'import', $keyphrases ) ) { |
|
| 353 | + if (in_array('import', $keyphrases)) { |
|
| 354 | 354 | $post_status = 'import'; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | // If there is a post status use it. |
| 358 | - if ( false !== $post_status ) { |
|
| 358 | + if (false !== $post_status) { |
|
| 359 | 359 | |
| 360 | 360 | $accommodation = array(); |
| 361 | - $current_accommodation = $this->find_current_accommodation( 'destination' ); |
|
| 362 | - if ( ! empty( $current_accommodation ) ) { |
|
| 363 | - foreach ( $current_accommodation as $cs_key => $ccs_id ) { |
|
| 364 | - $accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id ); |
|
| 361 | + $current_accommodation = $this->find_current_accommodation('destination'); |
|
| 362 | + if (!empty($current_accommodation)) { |
|
| 363 | + foreach ($current_accommodation as $cs_key => $ccs_id) { |
|
| 364 | + $accommodation[] = $this->prepare_row_attributes($cs_key, $ccs_id->post_id); |
|
| 365 | 365 | } |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | // Run through each accommodation and use it. |
| 369 | - if ( ! empty( $accommodation ) ) { |
|
| 370 | - foreach ( $accommodation as $row_key => $row ) { |
|
| 369 | + if (!empty($accommodation)) { |
|
| 370 | + foreach ($accommodation as $row_key => $row) { |
|
| 371 | 371 | $row['post_title'] = $row['name']; |
| 372 | - if ( 'import' === $post_status ) { |
|
| 373 | - if ( is_array( $this->queued_imports ) && in_array( $row['post_id'], $this->queued_imports ) ) { |
|
| 374 | - $current_status = get_post_status( $row['post_id'] ); |
|
| 375 | - if ( 'draft' === $current_status ) { |
|
| 376 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row, $row_key ); |
|
| 372 | + if ('import' === $post_status) { |
|
| 373 | + if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) { |
|
| 374 | + $current_status = get_post_status($row['post_id']); |
|
| 375 | + if ('draft' === $current_status) { |
|
| 376 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row, $row_key); |
|
| 377 | 377 | } |
| 378 | - } else { |
|
| 378 | + }else { |
|
| 379 | 379 | continue; |
| 380 | 380 | } |
| 381 | - } else { |
|
| 382 | - if ( 0 === $row['post_id'] ) { |
|
| 381 | + }else { |
|
| 382 | + if (0 === $row['post_id']) { |
|
| 383 | 383 | continue; |
| 384 | - } else { |
|
| 385 | - $current_status = get_post_status( $row['post_id'] ); |
|
| 384 | + }else { |
|
| 385 | + $current_status = get_post_status($row['post_id']); |
|
| 386 | 386 | |
| 387 | - if ( $current_status !== $post_status ) { |
|
| 387 | + if ($current_status !== $post_status) { |
|
| 388 | 388 | continue; |
| 389 | 389 | } |
| 390 | 390 | } |
| 391 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row, $row_key ); |
|
| 391 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row, $row_key); |
|
| 392 | 392 | } |
| 393 | 393 | } |
| 394 | 394 | } |
| 395 | - } else { |
|
| 395 | + }else { |
|
| 396 | 396 | |
| 397 | - $key_string_search = implode( '+', $keyphrases ); |
|
| 398 | - $search_data = wp_remote_get( $this->url . '/Search/' . $key_string_search . '/?all=include' ); |
|
| 397 | + $key_string_search = implode('+', $keyphrases); |
|
| 398 | + $search_data = wp_remote_get($this->url.'/Search/'.$key_string_search.'/?all=include'); |
|
| 399 | 399 | |
| 400 | - if ( ! is_wp_error( $search_data ) || ! empty( $search_data ) && isset( $search_data['response'] ) && isset( $search_data['response']['code'] ) && 200 === $search_data['response']['code'] ) { |
|
| 401 | - $search_data = json_decode( $search_data['body'], true ); |
|
| 402 | - foreach ( $search_data as $sdata_key => $sdata ) { |
|
| 400 | + if (!is_wp_error($search_data) || !empty($search_data) && isset($search_data['response']) && isset($search_data['response']['code']) && 200 === $search_data['response']['code']) { |
|
| 401 | + $search_data = json_decode($search_data['body'], true); |
|
| 402 | + foreach ($search_data as $sdata_key => $sdata) { |
|
| 403 | 403 | |
| 404 | - if ( isset( $sdata['type'] ) && 'Destination' !== trim( $sdata['type'] ) ) { |
|
| 404 | + if (isset($sdata['type']) && 'Destination' !== trim($sdata['type'])) { |
|
| 405 | 405 | continue; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | - $temp_id = $this->get_post_id_by_key_value( $sdata['id'] ); |
|
| 409 | - if ( false === $temp_id ) { |
|
| 408 | + $temp_id = $this->get_post_id_by_key_value($sdata['id']); |
|
| 409 | + if (false === $temp_id) { |
|
| 410 | 410 | $sdata['post_id'] = 0; |
| 411 | 411 | $sdata['post_title'] = $sdata['name']; |
| 412 | - } else { |
|
| 412 | + }else { |
|
| 413 | 413 | $sdata['post_id'] = $temp_id; |
| 414 | - $sdata['post_title'] = get_the_title( $temp_id ); |
|
| 414 | + $sdata['post_title'] = get_the_title($temp_id); |
|
| 415 | 415 | } |
| 416 | - $searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata, $sdata_key ); |
|
| 416 | + $searched_items[sanitize_title($sdata['name']).'-'.$sdata['id']] = $this->format_row($sdata, $sdata_key); |
|
| 417 | 417 | } |
| 418 | 418 | } |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | - if ( false !== $searched_items ) { |
|
| 422 | - $return = implode( $searched_items ); |
|
| 421 | + if (false !== $searched_items) { |
|
| 422 | + $return = implode($searched_items); |
|
| 423 | 423 | } |
| 424 | - print_r( $return ); |
|
| 425 | - } else { |
|
| 426 | - echo esc_attr( 'None found' ); |
|
| 424 | + print_r($return); |
|
| 425 | + }else { |
|
| 426 | + echo esc_attr('None found'); |
|
| 427 | 427 | } |
| 428 | 428 | die(); |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - public function prepare_row_attributes( $cs_key, $ccs_id ) { |
|
| 431 | + public function prepare_row_attributes($cs_key, $ccs_id) { |
|
| 432 | 432 | $row_item = array( |
| 433 | 433 | 'id' => $cs_key, |
| 434 | 434 | 'type' => 'Destination', |
| 435 | - 'name' => get_the_title( $ccs_id ), |
|
| 436 | - 'last_modified' => date( 'Y-m-d', strtotime( 'now' ) ), |
|
| 435 | + 'name' => get_the_title($ccs_id), |
|
| 436 | + 'last_modified' => date('Y-m-d', strtotime('now')), |
|
| 437 | 437 | 'post_id' => $ccs_id, |
| 438 | 438 | ); |
| 439 | 439 | return $row_item; |
@@ -442,31 +442,31 @@ discard block |
||
| 442 | 442 | /** |
| 443 | 443 | * Formats the row for output on the screen. |
| 444 | 444 | */ |
| 445 | - public function format_row( $row = false, $row_key = '' ) { |
|
| 446 | - if ( false !== $row ) { |
|
| 445 | + public function format_row($row = false, $row_key = '') { |
|
| 446 | + if (false !== $row) { |
|
| 447 | 447 | |
| 448 | 448 | $status = 'import'; |
| 449 | - if ( 0 !== $row['post_id'] ) { |
|
| 450 | - $status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>'; |
|
| 449 | + if (0 !== $row['post_id']) { |
|
| 450 | + $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | $row_html = ' |
| 454 | - <tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '"> |
|
| 454 | + <tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'"> |
|
| 455 | 455 | <th class="check-column" scope="row"> |
| 456 | - <label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label> |
|
| 457 | - <input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '"> |
|
| 456 | + <label for="cb-select-' . $row['id'].'" class="screen-reader-text">'.$row['name'].'</label> |
|
| 457 | + <input type="checkbox" data-identifier="' . $row['id'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['id'].'"> |
|
| 458 | 458 | </th> |
| 459 | 459 | <td class="column-order"> |
| 460 | - ' . ( $row_key + 1 ) . ' |
|
| 460 | + ' . ($row_key + 1).' |
|
| 461 | 461 | </td> |
| 462 | 462 | <td class="post-title page-title column-title"> |
| 463 | - <strong>' . $row['post_title'] . '</strong> - ' . $status . ' |
|
| 463 | + <strong>' . $row['post_title'].'</strong> - '.$status.' |
|
| 464 | 464 | </td> |
| 465 | 465 | <td class="date column-date"> |
| 466 | - <abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified |
|
| 466 | + <abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
| 467 | 467 | </td> |
| 468 | 468 | <td class="ssid column-ssid"> |
| 469 | - ' . $row['id'] . ' |
|
| 469 | + ' . $row['id'].' |
|
| 470 | 470 | </td> |
| 471 | 471 | </tr>'; |
| 472 | 472 | return $row_html; |
@@ -479,44 +479,44 @@ discard block |
||
| 479 | 479 | public function process_ajax_import() { |
| 480 | 480 | $return = false; |
| 481 | 481 | |
| 482 | - check_ajax_referer( 'lsx_wetu_ajax_action', 'security' ); |
|
| 483 | - if ( isset( $_POST['action'] ) && 'lsx_import_items' === $_POST['action'] && isset( $_POST['type'] ) && 'destination' === $_POST['type'] && isset( $_POST['wetu_id'] ) ) { |
|
| 482 | + check_ajax_referer('lsx_wetu_ajax_action', 'security'); |
|
| 483 | + if (isset($_POST['action']) && 'lsx_import_items' === $_POST['action'] && isset($_POST['type']) && 'destination' === $_POST['type'] && isset($_POST['wetu_id'])) { |
|
| 484 | 484 | |
| 485 | - $wetu_id = sanitize_text_field( $_POST['wetu_id'] ); |
|
| 485 | + $wetu_id = sanitize_text_field($_POST['wetu_id']); |
|
| 486 | 486 | |
| 487 | - if ( isset( $_POST['post_id'] ) ) { |
|
| 488 | - $post_id = sanitize_text_field( $_POST['post_id'] ); |
|
| 489 | - $this->current_post = get_post( $post_id ); |
|
| 490 | - } else { |
|
| 487 | + if (isset($_POST['post_id'])) { |
|
| 488 | + $post_id = sanitize_text_field($_POST['post_id']); |
|
| 489 | + $this->current_post = get_post($post_id); |
|
| 490 | + }else { |
|
| 491 | 491 | $post_id = 0; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - if ( isset( $_POST['team_members'] ) ) { |
|
| 495 | - $team_members = array_map( 'sanitize_text_field', wp_unslash( $_POST['team_members'] ) ); |
|
| 496 | - } else { |
|
| 494 | + if (isset($_POST['team_members'])) { |
|
| 495 | + $team_members = array_map('sanitize_text_field', wp_unslash($_POST['team_members'])); |
|
| 496 | + }else { |
|
| 497 | 497 | $team_members = false; |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | $safari_brands = false; |
| 501 | 501 | |
| 502 | - delete_option( 'lsx_wetu_importer_destination_settings' ); |
|
| 502 | + delete_option('lsx_wetu_importer_destination_settings'); |
|
| 503 | 503 | |
| 504 | - if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) { |
|
| 505 | - $content = array_map( 'sanitize_text_field', wp_unslash( $_POST['content'] ) ); |
|
| 506 | - add_option( 'lsx_wetu_importer_destination_settings', $content ); |
|
| 507 | - } else { |
|
| 504 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
| 505 | + $content = array_map('sanitize_text_field', wp_unslash($_POST['content'])); |
|
| 506 | + add_option('lsx_wetu_importer_destination_settings', $content); |
|
| 507 | + }else { |
|
| 508 | 508 | $content = false; |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - $jdata = wp_remote_get( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
| 511 | + $jdata = wp_remote_get($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id); |
|
| 512 | 512 | |
| 513 | - if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) { |
|
| 514 | - $adata = json_decode( $jdata['body'], true ); |
|
| 515 | - $return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands ); |
|
| 516 | - $this->remove_from_queue( $return ); |
|
| 517 | - $this->format_completed_row( $return ); |
|
| 518 | - } else { |
|
| 519 | - $this->format_error( esc_html__( 'There was a problem importing your destination, please try refreshing the page.', 'lsx-wetu-importer' ) ); |
|
| 513 | + if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) { |
|
| 514 | + $adata = json_decode($jdata['body'], true); |
|
| 515 | + $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
|
| 516 | + $this->remove_from_queue($return); |
|
| 517 | + $this->format_completed_row($return); |
|
| 518 | + }else { |
|
| 519 | + $this->format_error(esc_html__('There was a problem importing your destination, please try refreshing the page.', 'lsx-wetu-importer')); |
|
| 520 | 520 | } |
| 521 | 521 | } |
| 522 | 522 | die(); |
@@ -525,14 +525,14 @@ discard block |
||
| 525 | 525 | /** |
| 526 | 526 | * Saves the queue to the option. |
| 527 | 527 | */ |
| 528 | - public function remove_from_queue( $id ) { |
|
| 529 | - if ( ! empty( $this->queued_imports ) ) { |
|
| 530 | - $key = array_search( $id, $this->queued_imports ); |
|
| 531 | - if ( false !== $key ) { |
|
| 532 | - unset( $this->queued_imports[ $key ] ); |
|
| 528 | + public function remove_from_queue($id) { |
|
| 529 | + if (!empty($this->queued_imports)) { |
|
| 530 | + $key = array_search($id, $this->queued_imports); |
|
| 531 | + if (false !== $key) { |
|
| 532 | + unset($this->queued_imports[$key]); |
|
| 533 | 533 | |
| 534 | - delete_option( 'lsx_wetu_importer_que' ); |
|
| 535 | - update_option( 'lsx_wetu_importer_que', $this->queued_imports ); |
|
| 534 | + delete_option('lsx_wetu_importer_que'); |
|
| 535 | + update_option('lsx_wetu_importer_que', $this->queued_imports); |
|
| 536 | 536 | } |
| 537 | 537 | } |
| 538 | 538 | } |
@@ -540,8 +540,8 @@ discard block |
||
| 540 | 540 | /** |
| 541 | 541 | * Connect to wetu |
| 542 | 542 | */ |
| 543 | - public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false ) { |
|
| 544 | - if ( 'Destination' === trim( $data[0]['type'] ) ) { |
|
| 543 | + public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $safari_brands = false) { |
|
| 544 | + if ('Destination' === trim($data[0]['type'])) { |
|
| 545 | 545 | $post_name = ''; |
| 546 | 546 | $data_post_content = ''; |
| 547 | 547 | $data_post_excerpt = ''; |
@@ -550,129 +550,129 @@ discard block |
||
| 550 | 550 | 'post_type' => 'destination', |
| 551 | 551 | ); |
| 552 | 552 | |
| 553 | - if ( ! empty( $importable_content ) && in_array( 'country', $importable_content ) ) { |
|
| 554 | - $parent = $this->check_for_parent( $data ); |
|
| 555 | - if ( false !== $parent ) { |
|
| 553 | + if (!empty($importable_content) && in_array('country', $importable_content)) { |
|
| 554 | + $parent = $this->check_for_parent($data); |
|
| 555 | + if (false !== $parent) { |
|
| 556 | 556 | $post['post_parent'] = $parent; |
| 557 | 557 | } |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | // Set the post_content. |
| 561 | - if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) { |
|
| 562 | - if ( isset( $data[0]['content']['general_description'] ) ) { |
|
| 561 | + if (!empty($importable_content) && in_array('description', $importable_content)) { |
|
| 562 | + if (isset($data[0]['content']['general_description'])) { |
|
| 563 | 563 | |
| 564 | - if ( in_array( 'strip_tags', $importable_content ) ) { |
|
| 565 | - $post['post_content'] = wp_strip_all_tags( $data[0]['content']['general_description'] ); |
|
| 566 | - } else { |
|
| 564 | + if (in_array('strip_tags', $importable_content)) { |
|
| 565 | + $post['post_content'] = wp_strip_all_tags($data[0]['content']['general_description']); |
|
| 566 | + }else { |
|
| 567 | 567 | $post['post_content'] = $data[0]['content']['general_description']; |
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | - if ( false !== $id && '0' !== $id ) { |
|
| 572 | + if (false !== $id && '0' !== $id) { |
|
| 573 | 573 | $post['ID'] = $id; |
| 574 | - if ( isset( $this->options ) && 'on' !== $this->options['disable_destination_title'] && isset( $data[0]['name'] ) ) { |
|
| 574 | + if (isset($this->options) && 'on' !== $this->options['disable_destination_title'] && isset($data[0]['name'])) { |
|
| 575 | 575 | $post['post_title'] = $data[0]['name']; |
| 576 | - $post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 ); |
|
| 576 | + $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0); |
|
| 577 | 577 | } |
| 578 | 578 | $post['post_status'] = 'publish'; |
| 579 | 579 | |
| 580 | - $id = wp_update_post( $post ); |
|
| 581 | - $prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true ); |
|
| 582 | - update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date ); |
|
| 583 | - } else { |
|
| 580 | + $id = wp_update_post($post); |
|
| 581 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
| 582 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date); |
|
| 583 | + }else { |
|
| 584 | 584 | // Set the name. |
| 585 | - if ( isset( $data[0]['name'] ) ) { |
|
| 586 | - $post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 ); |
|
| 585 | + if (isset($data[0]['name'])) { |
|
| 586 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0); |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | $post['post_name'] = $post_name; |
| 590 | 590 | $post['post_title'] = $data[0]['name']; |
| 591 | 591 | $post['post_status'] = 'publish'; |
| 592 | - $id = wp_insert_post( $post ); |
|
| 592 | + $id = wp_insert_post($post); |
|
| 593 | 593 | |
| 594 | 594 | // Save the WETU ID and the Last date it was modified. |
| 595 | - if ( false !== $id ) { |
|
| 596 | - add_post_meta( $id, 'lsx_wetu_id', $wetu_id ); |
|
| 597 | - add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) ); |
|
| 595 | + if (false !== $id) { |
|
| 596 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
| 597 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified'])); |
|
| 598 | 598 | } |
| 599 | 599 | } |
| 600 | 600 | |
| 601 | - $this->find_attachments( $id ); |
|
| 601 | + $this->find_attachments($id); |
|
| 602 | 602 | |
| 603 | 603 | // Set the team member if it is there. |
| 604 | - if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) { |
|
| 605 | - $this->set_team_member( $id, $team_members ); |
|
| 604 | + if (post_type_exists('team') && false !== $team_members && '' !== $team_members) { |
|
| 605 | + $this->set_team_member($id, $team_members); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | - $this->set_map_data( $data, $id, 9 ); |
|
| 608 | + $this->set_map_data($data, $id, 9); |
|
| 609 | 609 | |
| 610 | 610 | // Set the Room Data. |
| 611 | - if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) { |
|
| 612 | - $this->set_video_data( $data, $id ); |
|
| 611 | + if (false !== $importable_content && in_array('videos', $importable_content)) { |
|
| 612 | + $this->set_video_data($data, $id); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | // Set the Electricity. |
| 616 | - if ( false !== $importable_content && in_array( 'electricity', $importable_content ) ) { |
|
| 617 | - $this->set_travel_info( $data, $id, 'electricity', $importable_content ); |
|
| 616 | + if (false !== $importable_content && in_array('electricity', $importable_content)) { |
|
| 617 | + $this->set_travel_info($data, $id, 'electricity', $importable_content); |
|
| 618 | 618 | } |
| 619 | 619 | // Set the cuisine. |
| 620 | - if ( false !== $importable_content && in_array( 'cuisine', $importable_content ) ) { |
|
| 621 | - $this->set_travel_info( $data, $id, 'cuisine', $importable_content ); |
|
| 620 | + if (false !== $importable_content && in_array('cuisine', $importable_content)) { |
|
| 621 | + $this->set_travel_info($data, $id, 'cuisine', $importable_content); |
|
| 622 | 622 | } |
| 623 | 623 | // Set the banking. |
| 624 | - if ( false !== $importable_content && in_array( 'banking', $importable_content ) ) { |
|
| 625 | - $this->set_travel_info( $data, $id, 'banking', $importable_content ); |
|
| 624 | + if (false !== $importable_content && in_array('banking', $importable_content)) { |
|
| 625 | + $this->set_travel_info($data, $id, 'banking', $importable_content); |
|
| 626 | 626 | } |
| 627 | 627 | // Set the transport. |
| 628 | - if ( false !== $importable_content && in_array( 'transport', $importable_content ) ) { |
|
| 629 | - $this->set_travel_info( $data, $id, 'transport', $importable_content ); |
|
| 628 | + if (false !== $importable_content && in_array('transport', $importable_content)) { |
|
| 629 | + $this->set_travel_info($data, $id, 'transport', $importable_content); |
|
| 630 | 630 | } |
| 631 | 631 | // Set the dress. |
| 632 | - if ( false !== $importable_content && in_array( 'dress', $importable_content ) ) { |
|
| 633 | - $this->set_travel_info( $data, $id, 'dress', $importable_content ); |
|
| 632 | + if (false !== $importable_content && in_array('dress', $importable_content)) { |
|
| 633 | + $this->set_travel_info($data, $id, 'dress', $importable_content); |
|
| 634 | 634 | } |
| 635 | 635 | // Set the climate. |
| 636 | - if ( false !== $importable_content && in_array( 'climate', $importable_content ) ) { |
|
| 637 | - $this->set_travel_info( $data, $id, 'climate', $importable_content ); |
|
| 636 | + if (false !== $importable_content && in_array('climate', $importable_content)) { |
|
| 637 | + $this->set_travel_info($data, $id, 'climate', $importable_content); |
|
| 638 | 638 | } |
| 639 | 639 | // Set the Health. |
| 640 | - if ( false !== $importable_content && in_array( 'health', $importable_content ) ) { |
|
| 641 | - $this->set_travel_info( $data, $id, 'health', $importable_content ); |
|
| 640 | + if (false !== $importable_content && in_array('health', $importable_content)) { |
|
| 641 | + $this->set_travel_info($data, $id, 'health', $importable_content); |
|
| 642 | 642 | } |
| 643 | 643 | // Set the Safety. |
| 644 | - if ( false !== $importable_content && in_array( 'safety', $importable_content ) ) { |
|
| 645 | - $this->set_travel_info( $data, $id, 'safety', $importable_content ); |
|
| 644 | + if (false !== $importable_content && in_array('safety', $importable_content)) { |
|
| 645 | + $this->set_travel_info($data, $id, 'safety', $importable_content); |
|
| 646 | 646 | } |
| 647 | 647 | // Set the Visa. |
| 648 | - if ( false !== $importable_content && in_array( 'visa', $importable_content ) ) { |
|
| 649 | - $this->set_travel_info( $data, $id, 'visa', $importable_content ); |
|
| 648 | + if (false !== $importable_content && in_array('visa', $importable_content)) { |
|
| 649 | + $this->set_travel_info($data, $id, 'visa', $importable_content); |
|
| 650 | 650 | } |
| 651 | 651 | // Set the General. |
| 652 | - if ( false !== $importable_content && in_array( 'additional_info', $importable_content ) ) { |
|
| 653 | - $this->set_travel_info( $data, $id, 'additional_info', $importable_content ); |
|
| 652 | + if (false !== $importable_content && in_array('additional_info', $importable_content)) { |
|
| 653 | + $this->set_travel_info($data, $id, 'additional_info', $importable_content); |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | // Setup some default for use in the import. |
| 657 | - if ( false !== $importable_content && (in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content )) ) { |
|
| 658 | - $this->find_attachments( $id ); |
|
| 657 | + if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) { |
|
| 658 | + $this->find_attachments($id); |
|
| 659 | 659 | |
| 660 | 660 | // Set the featured image. |
| 661 | - if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) { |
|
| 662 | - $this->set_featured_image( $data, $id ); |
|
| 661 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
| 662 | + $this->set_featured_image($data, $id); |
|
| 663 | 663 | } |
| 664 | - if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) { |
|
| 665 | - $this->set_banner_image( $data, $id, $importable_content ); |
|
| 664 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
| 665 | + $this->set_banner_image($data, $id, $importable_content); |
|
| 666 | 666 | } |
| 667 | 667 | // Import the main gallery. |
| 668 | - if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) { |
|
| 669 | - $this->create_main_gallery( $data, $id ); |
|
| 668 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
| 669 | + $this->create_main_gallery($data, $id); |
|
| 670 | 670 | } |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | // Set the continent. |
| 674 | - if ( false !== $importable_content && in_array( 'continent', $importable_content ) ) { |
|
| 675 | - $this->set_continent( $data, $id ); |
|
| 674 | + if (false !== $importable_content && in_array('continent', $importable_content)) { |
|
| 675 | + $this->set_continent($data, $id); |
|
| 676 | 676 | } |
| 677 | 677 | } |
| 678 | 678 | |
@@ -682,54 +682,54 @@ discard block |
||
| 682 | 682 | /** |
| 683 | 683 | * Set the team memberon each item. |
| 684 | 684 | */ |
| 685 | - public function set_team_member( $id, $team_members ) { |
|
| 686 | - delete_post_meta( $id, 'team_to_' . $this->tab_slug ); |
|
| 685 | + public function set_team_member($id, $team_members) { |
|
| 686 | + delete_post_meta($id, 'team_to_'.$this->tab_slug); |
|
| 687 | 687 | |
| 688 | - foreach ( $team_members as $team ) { |
|
| 689 | - add_post_meta( $id, 'team_to_' . $this->tab_slug, $team ); |
|
| 688 | + foreach ($team_members as $team) { |
|
| 689 | + add_post_meta($id, 'team_to_'.$this->tab_slug, $team); |
|
| 690 | 690 | } |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | /** |
| 694 | 694 | * Saves the room data |
| 695 | 695 | */ |
| 696 | - public function set_travel_info( $data, $id, $meta_key, $importable = array( 'none' ) ) { |
|
| 697 | - if ( ! empty( $data[0]['travel_information'] ) && isset( $data[0]['travel_information'][ $meta_key ] ) ) { |
|
| 698 | - $content = $data[0]['travel_information'][ $meta_key ]; |
|
| 696 | + public function set_travel_info($data, $id, $meta_key, $importable = array('none')) { |
|
| 697 | + if (!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])) { |
|
| 698 | + $content = $data[0]['travel_information'][$meta_key]; |
|
| 699 | 699 | |
| 700 | - if ( in_array( 'strip_tags', $importable ) ) { |
|
| 701 | - $content = strip_tags( $content ); |
|
| 700 | + if (in_array('strip_tags', $importable)) { |
|
| 701 | + $content = strip_tags($content); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | - $this->save_custom_field( $content, $meta_key, $id ); |
|
| 704 | + $this->save_custom_field($content, $meta_key, $id); |
|
| 705 | 705 | } |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | /** |
| 709 | 709 | * Set the Travel Style |
| 710 | 710 | */ |
| 711 | - public function set_continent( $data, $id ) { |
|
| 711 | + public function set_continent($data, $id) { |
|
| 712 | 712 | |
| 713 | - if ( isset( $data[0]['position']['country'] ) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id'] ) { |
|
| 713 | + if (isset($data[0]['position']['country']) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id']) { |
|
| 714 | 714 | // Get the continent code. |
| 715 | - $country_code = to_country_data( $data[0]['position']['country'], false ); |
|
| 716 | - $continent_code = to_continent_code( $country_code ); |
|
| 717 | - $continent_label = to_continent_label( $continent_code ); |
|
| 715 | + $country_code = to_country_data($data[0]['position']['country'], false); |
|
| 716 | + $continent_code = to_continent_code($country_code); |
|
| 717 | + $continent_label = to_continent_label($continent_code); |
|
| 718 | 718 | |
| 719 | - if ( ! empty( tour_operator()->options['display']['enable_search_region_filter'] ) ) { |
|
| 720 | - $continent_label = to_continent_region_label( $country_code ); |
|
| 719 | + if (!empty(tour_operator()->options['display']['enable_search_region_filter'])) { |
|
| 720 | + $continent_label = to_continent_region_label($country_code); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - if ( '' !== $continent_label ) { |
|
| 724 | - $term = term_exists( trim( $continent_label ), 'continent' ); |
|
| 725 | - if ( ! $term ) { |
|
| 726 | - $term = wp_insert_term( trim( $continent_label ), 'continent' ); |
|
| 723 | + if ('' !== $continent_label) { |
|
| 724 | + $term = term_exists(trim($continent_label), 'continent'); |
|
| 725 | + if (!$term) { |
|
| 726 | + $term = wp_insert_term(trim($continent_label), 'continent'); |
|
| 727 | 727 | |
| 728 | - if ( is_wp_error( $term ) ) { |
|
| 729 | - echo wp_kses_post( $term->get_error_message() ); |
|
| 728 | + if (is_wp_error($term)) { |
|
| 729 | + echo wp_kses_post($term->get_error_message()); |
|
| 730 | 730 | } |
| 731 | - } else { |
|
| 732 | - wp_set_object_terms( $id, sanitize_title( $continent_label ), 'continent', true ); |
|
| 731 | + }else { |
|
| 732 | + wp_set_object_terms($id, sanitize_title($continent_label), 'continent', true); |
|
| 733 | 733 | } |
| 734 | 734 | } |
| 735 | 735 | } |
@@ -739,10 +739,10 @@ discard block |
||
| 739 | 739 | * Save the list of Accommodation into an option |
| 740 | 740 | */ |
| 741 | 741 | public function update_options() { |
| 742 | - $data = wp_remote_get( $this->url . '/List?' . $this->url_qs ); |
|
| 743 | - if ( ! empty( $data ) && isset( $data['response'] ) && isset( $data['response']['code'] ) && 200 === $data['response']['code'] ) { |
|
| 744 | - $accommodation = json_decode( $data['body'], true ); |
|
| 745 | - set_transient( 'lsx_ti_accommodation', $accommodation, 60 * 60 * 2 ); |
|
| 742 | + $data = wp_remote_get($this->url.'/List?'.$this->url_qs); |
|
| 743 | + if (!empty($data) && isset($data['response']) && isset($data['response']['code']) && 200 === $data['response']['code']) { |
|
| 744 | + $accommodation = json_decode($data['body'], true); |
|
| 745 | + set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2); |
|
| 746 | 746 | return true; |
| 747 | 747 | } |
| 748 | 748 | } |
@@ -751,11 +751,11 @@ discard block |
||
| 751 | 751 | * search_form |
| 752 | 752 | */ |
| 753 | 753 | public function update_options_form() { |
| 754 | - echo '<div style="display:none;" class="wetu-status"><h3>' . esc_html__( 'Wetu Status', 'lsx-wetu-importer' ) . '</h3>'; |
|
| 754 | + echo '<div style="display:none;" class="wetu-status"><h3>'.esc_html__('Wetu Status', 'lsx-wetu-importer').'</h3>'; |
|
| 755 | 755 | |
| 756 | - $accommodation = get_transient( 'lsx_ti_accommodation' ); |
|
| 756 | + $accommodation = get_transient('lsx_ti_accommodation'); |
|
| 757 | 757 | |
| 758 | - if ( '' === $accommodation || false === $accommodation || isset( $_GET['refresh_accommodation'] ) ) { |
|
| 758 | + if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) { |
|
| 759 | 759 | $this->update_options(); |
| 760 | 760 | } |
| 761 | 761 | |
@@ -765,12 +765,12 @@ discard block |
||
| 765 | 765 | /** |
| 766 | 766 | * Save the list of Accommodation into an option |
| 767 | 767 | */ |
| 768 | - public function check_for_parent( $data = array() ) { |
|
| 768 | + public function check_for_parent($data = array()) { |
|
| 769 | 769 | global $wpdb; |
| 770 | 770 | |
| 771 | - if ( $data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id'] ) { |
|
| 772 | - $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'] ) ) ); |
|
| 773 | - if ( ! empty( $result ) && '' !== $result && false !== $result ) { |
|
| 771 | + if ($data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id']) { |
|
| 772 | + $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']))); |
|
| 773 | + if (!empty($result) && '' !== $result && false !== $result) { |
|
| 774 | 774 | return $result; |
| 775 | 775 | } |
| 776 | 776 | } |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function set_variables() { |
| 99 | 99 | parent::set_variables(); |
| 100 | - if ( false !== $this->api_key ) { |
|
| 101 | - $this->url = 'https://wetu.com/API/Itinerary/' . $this->api_key; |
|
| 100 | + if (false !== $this->api_key) { |
|
| 101 | + $this->url = 'https://wetu.com/API/Itinerary/'.$this->api_key; |
|
| 102 | 102 | $this->url_qs = ''; |
| 103 | 103 | } |
| 104 | - $tour_options = get_option( 'lsx_wetu_importer_tour_settings',false ); |
|
| 105 | - if ( false !== $tour_options ) { |
|
| 104 | + $tour_options = get_option('lsx_wetu_importer_tour_settings', false); |
|
| 105 | + if (false !== $tour_options) { |
|
| 106 | 106 | $this->tour_options = $tour_options; |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | </div> |
| 127 | 127 | |
| 128 | 128 | <form method="get" action="" id="posts-filter"> |
| 129 | - <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" /> |
|
| 129 | + <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" /> |
|
| 130 | 130 | |
| 131 | 131 | <table class="wp-list-table widefat fixed posts"> |
| 132 | 132 | <?php $this->table_header(); ?> |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | <tr class="post-0 type-tour status-none" id="post-0"> |
| 136 | 136 | <td class="date column-date column-ref" colspan="5"> |
| 137 | 137 | <strong> |
| 138 | - <?php esc_html_e( 'Search for tours using the search form above','lsx-wetu-importer' ); ?> |
|
| 138 | + <?php esc_html_e('Search for tours using the search form above', 'lsx-wetu-importer'); ?> |
|
| 139 | 139 | </strong> |
| 140 | 140 | </td> |
| 141 | 141 | </tr> |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | </table> |
| 147 | 147 | |
| 148 | - <p><input class="button button-primary add" type="button" value="<?php esc_html_e( 'Add to List','lsx-wetu-importer' ); ?>" /> |
|
| 149 | - <input class="button button-primary clear" type="button" value="<?php esc_html_e( 'Clear','lsx-wetu-importer' ); ?>" /> |
|
| 148 | + <p><input class="button button-primary add" type="button" value="<?php esc_html_e('Add to List', 'lsx-wetu-importer'); ?>" /> |
|
| 149 | + <input class="button button-primary clear" type="button" value="<?php esc_html_e('Clear', 'lsx-wetu-importer'); ?>" /> |
|
| 150 | 150 | </p> |
| 151 | 151 | </form> |
| 152 | 152 | |
@@ -156,52 +156,52 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | <div class="row"> |
| 158 | 158 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 159 | - <h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3> |
|
| 159 | + <h3><?php esc_html_e('What content to Sync from WETU'); ?></h3> |
|
| 160 | 160 | <ul> |
| 161 | - <li><input class="content select-all" <?php $this->checked( $this->tour_options, 'all' ); ?> type="checkbox"name="content[]" value="all" /> <?php esc_html_e( 'Select All','lsx-wetu-importer' ); ?></li> |
|
| 161 | + <li><input class="content select-all" <?php $this->checked($this->tour_options, 'all'); ?> type="checkbox"name="content[]" value="all" /> <?php esc_html_e('Select All', 'lsx-wetu-importer'); ?></li> |
|
| 162 | 162 | |
| 163 | - <?php if ( isset( $this->options ) && ! isset( $this->options['disable_tour_descriptions'] ) ) { ?> |
|
| 164 | - <li><input class="content" <?php $this->checked( $this->tour_options, 'description' ); ?> type="checkbox" name="content[]" value="description" /> <?php esc_html_e( 'Description','lsx-wetu-importer' ); ?></li> |
|
| 163 | + <?php if (isset($this->options) && !isset($this->options['disable_tour_descriptions'])) { ?> |
|
| 164 | + <li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li> |
|
| 165 | 165 | <?php } ?> |
| 166 | 166 | |
| 167 | - <li><input class="content" <?php $this->checked( $this->tour_options, 'price' ); ?> type="checkbox" name="content[]" value="price" /> <?php esc_html_e( 'Price','lsx-wetu-importer' ); ?></li> |
|
| 168 | - <li><input class="content" <?php $this->checked( $this->tour_options, 'duration' ); ?> type="checkbox" name="content[]" value="duration" /> <?php esc_html_e( 'Duration','lsx-wetu-importer' ); ?></li> |
|
| 169 | - <li><input class="content" <?php $this->checked( $this->tour_options, 'group_size' ); ?> type="checkbox" name="content[]" value="group_size" /> <?php esc_html_e( 'Group Size','lsx-wetu-importer' ); ?></li> |
|
| 170 | - <li><input class="content" <?php $this->checked( $this->tour_options, 'category' ); ?> type="checkbox" name="content[]" value="category" /> <?php esc_html_e( 'Category','lsx-wetu-importer' ); ?></li> |
|
| 171 | - <?php if ( isset( $this->options ) && ! isset( $this->options['disable_tour_tags'] ) ) { ?> |
|
| 172 | - <li><input class="content" <?php $this->checked( $this->tour_options, 'tags' ); ?> type="checkbox" name="content[]" value="tags" /> <?php esc_html_e( 'Tags','lsx-wetu-importer' ); ?></li> |
|
| 167 | + <li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php esc_html_e('Price', 'lsx-wetu-importer'); ?></li> |
|
| 168 | + <li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php esc_html_e('Duration', 'lsx-wetu-importer'); ?></li> |
|
| 169 | + <li><input class="content" <?php $this->checked($this->tour_options, 'group_size'); ?> type="checkbox" name="content[]" value="group_size" /> <?php esc_html_e('Group Size', 'lsx-wetu-importer'); ?></li> |
|
| 170 | + <li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php esc_html_e('Category', 'lsx-wetu-importer'); ?></li> |
|
| 171 | + <?php if (isset($this->options) && !isset($this->options['disable_tour_tags'])) { ?> |
|
| 172 | + <li><input class="content" <?php $this->checked($this->tour_options, 'tags'); ?> type="checkbox" name="content[]" value="tags" /> <?php esc_html_e('Tags', 'lsx-wetu-importer'); ?></li> |
|
| 173 | 173 | <?php } ?> |
| 174 | - <li><input class="content" <?php $this->checked( $this->tour_options, 'itineraries' ); ?> type="checkbox" name="content[]" value="itineraries" /> <?php esc_html_e( 'Itinerary Days','lsx-wetu-importer' ); ?></li> |
|
| 174 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php esc_html_e('Itinerary Days', 'lsx-wetu-importer'); ?></li> |
|
| 175 | 175 | </ul> |
| 176 | 176 | </div> |
| 177 | 177 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 178 | - <h3><?php esc_html_e( 'Itinerary Info' ); ?></h3> |
|
| 178 | + <h3><?php esc_html_e('Itinerary Info'); ?></h3> |
|
| 179 | 179 | <ul> |
| 180 | - <li><input class="content" <?php $this->checked( $this->tour_options, 'itinerary_description' ); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php esc_html_e( 'Description','lsx-wetu-importer' ); ?></li> |
|
| 181 | - <li><input class="content" <?php $this->checked( $this->tour_options, 'itinerary_included' ); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php esc_html_e( 'Included','lsx-wetu-importer' ); ?></li> |
|
| 182 | - <li><input class="content" <?php $this->checked( $this->tour_options, 'itinerary_excluded' ); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php esc_html_e( 'Excluded','lsx-wetu-importer' ); ?></li> |
|
| 180 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php esc_html_e('Description', 'lsx-wetu-importer'); ?></li> |
|
| 181 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php esc_html_e('Included', 'lsx-wetu-importer'); ?></li> |
|
| 182 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php esc_html_e('Excluded', 'lsx-wetu-importer'); ?></li> |
|
| 183 | 183 | </ul> |
| 184 | 184 | |
| 185 | - <h4><?php esc_html_e( 'Additional Content' ); ?></h4> |
|
| 185 | + <h4><?php esc_html_e('Additional Content'); ?></h4> |
|
| 186 | 186 | <ul> |
| 187 | - <li><input class="content" <?php $this->checked( $this->tour_options, 'accommodation' ); ?> type="checkbox" name="content[]" value="accommodation" /> <?php esc_html_e( 'Sync Accommodation','lsx-wetu-importer' ); ?></li> |
|
| 188 | - <li><input class="content" <?php $this->checked( $this->tour_options, 'destination' ); ?> type="checkbox" name="content[]" value="destination" /> <?php esc_html_e( 'Sync Destinations','lsx-wetu-importer' ); ?></li> |
|
| 189 | - <li><input class="content" <?php $this->checked( $this->tour_options, 'featured_image' ); ?> type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e( 'Featured Image','lsx-wetu-importer' ); ?></li> |
|
| 190 | - <li><input class="content" <?php $this->checked( $this->tour_options, 'banner_image' ); ?> type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e( 'Banner Image','lsx-wetu-importer' ); ?></li> |
|
| 187 | + <li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php esc_html_e('Sync Accommodation', 'lsx-wetu-importer'); ?></li> |
|
| 188 | + <li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php esc_html_e('Sync Destinations', 'lsx-wetu-importer'); ?></li> |
|
| 189 | + <li><input class="content" <?php $this->checked($this->tour_options, 'featured_image'); ?> type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e('Featured Image', 'lsx-wetu-importer'); ?></li> |
|
| 190 | + <li><input class="content" <?php $this->checked($this->tour_options, 'banner_image'); ?> type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e('Banner Image', 'lsx-wetu-importer'); ?></li> |
|
| 191 | 191 | </ul> |
| 192 | 192 | </div> |
| 193 | - <?php if ( class_exists( 'LSX_TO_Team' ) ) { ?> |
|
| 193 | + <?php if (class_exists('LSX_TO_Team')) { ?> |
|
| 194 | 194 | <div style="width:30%;display:block;float:left;"> |
| 195 | - <h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3> |
|
| 196 | - <?php $this->team_member_checkboxes( $this->tour_options ); ?> |
|
| 195 | + <h3><?php esc_html_e('Assign a Team Member'); ?></h3> |
|
| 196 | + <?php $this->team_member_checkboxes($this->tour_options); ?> |
|
| 197 | 197 | </div> |
| 198 | 198 | <?php } ?> |
| 199 | 199 | |
| 200 | 200 | <br clear="both" /> |
| 201 | 201 | </div> |
| 202 | 202 | |
| 203 | - <h3><?php esc_html_e( 'Your List' ); ?></h3> |
|
| 204 | - <p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>" /></p> |
|
| 203 | + <h3><?php esc_html_e('Your List'); ?></h3> |
|
| 204 | + <p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>" /></p> |
|
| 205 | 205 | <table class="wp-list-table widefat fixed posts"> |
| 206 | 206 | <?php $this->table_header(); ?> |
| 207 | 207 | |
@@ -213,12 +213,12 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | </table> |
| 215 | 215 | |
| 216 | - <p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?>" /></p> |
|
| 216 | + <p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'lsx-wetu-importer'); ?>" /></p> |
|
| 217 | 217 | </form> |
| 218 | 218 | </div> |
| 219 | 219 | |
| 220 | 220 | <div style="display:none;" class="completed-list-wrapper"> |
| 221 | - <h3><?php esc_html_e( 'Completed', 'lsx-wetu-importer' ); ?> - <small><?php esc_html_e( 'Import your', 'lsx-wetu-importer' ); ?> <a href="<?php echo esc_attr( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->plugin_slug ); ?>&tab=accommodation"><?php esc_html_e( 'accommodation' ); ?></a> <?php esc_html_e( 'next','lsx-wetu-importer' ); ?></small></h3> |
|
| 221 | + <h3><?php esc_html_e('Completed', 'lsx-wetu-importer'); ?> - <small><?php esc_html_e('Import your', 'lsx-wetu-importer'); ?> <a href="<?php echo esc_attr(admin_url('admin.php')); ?>?page=<?php echo esc_attr($this->plugin_slug); ?>&tab=accommodation"><?php esc_html_e('accommodation'); ?></a> <?php esc_html_e('next', 'lsx-wetu-importer'); ?></small></h3> |
|
| 222 | 222 | <ul> |
| 223 | 223 | </ul> |
| 224 | 224 | </div> |
@@ -232,23 +232,23 @@ discard block |
||
| 232 | 232 | * @return void |
| 233 | 233 | */ |
| 234 | 234 | public function update_options_form() { |
| 235 | - $form_options = get_option( 'lsx_ti_tours_api_options' ); |
|
| 236 | - if ( false === $form_options ) { |
|
| 237 | - $form_options = array( 'sample' ); |
|
| 235 | + $form_options = get_option('lsx_ti_tours_api_options'); |
|
| 236 | + if (false === $form_options) { |
|
| 237 | + $form_options = array('sample'); |
|
| 238 | 238 | } |
| 239 | 239 | ?> |
| 240 | 240 | <form method="get" class="tour-refresh-form"> |
| 241 | - <input type="hidden" name="page" value="<?php echo esc_attr( $this->plugin_slug ); ?>" /> |
|
| 241 | + <input type="hidden" name="page" value="<?php echo esc_attr($this->plugin_slug); ?>" /> |
|
| 242 | 242 | <input type="hidden" name="tab" value="tour" /> |
| 243 | 243 | <input type="hidden" name="refresh_tours" value="true" /> |
| 244 | 244 | <input class="content" type="hidden" name="own" value="true" /> |
| 245 | 245 | |
| 246 | 246 | <select name="type"> |
| 247 | - <option <?php if ( in_array( 'allitineraries', $form_options ) ) { echo esc_attr( 'selected="selected"' ); } ?> value="allitineraries"><?php esc_html_e( 'All Itineraries','lsx-wetu-importer' ); ?></option> |
|
| 248 | - <option <?php if ( in_array( 'sample', $form_options ) ) { echo esc_attr( 'selected="selected"' ); } ?>value="sample"><?php esc_html_e( 'Sample','lsx-wetu-importer' ); ?></option> |
|
| 249 | - <option <?php if ( in_array( 'personal', $form_options ) ) { echo esc_attr( 'selected="selected"' ); } ?>value="personal"><?php esc_html_e( 'Personal','lsx-wetu-importer' ); ?></option> |
|
| 247 | + <option <?php if (in_array('allitineraries', $form_options)) { echo esc_attr('selected="selected"'); } ?> value="allitineraries"><?php esc_html_e('All Itineraries', 'lsx-wetu-importer'); ?></option> |
|
| 248 | + <option <?php if (in_array('sample', $form_options)) { echo esc_attr('selected="selected"'); } ?>value="sample"><?php esc_html_e('Sample', 'lsx-wetu-importer'); ?></option> |
|
| 249 | + <option <?php if (in_array('personal', $form_options)) { echo esc_attr('selected="selected"'); } ?>value="personal"><?php esc_html_e('Personal', 'lsx-wetu-importer'); ?></option> |
|
| 250 | 250 | </select> |
| 251 | - <input class="button submit" type="submit" value="<?php esc_attr_e( 'Refresh', 'lsx-wetu-importer' ); ?>" /> |
|
| 251 | + <input class="button submit" type="submit" value="<?php esc_attr_e('Refresh', 'lsx-wetu-importer'); ?>" /> |
|
| 252 | 252 | </form> |
| 253 | 253 | <?php |
| 254 | 254 | } |
@@ -273,9 +273,9 @@ discard block |
||
| 273 | 273 | LIMIT 0,500 |
| 274 | 274 | "); |
| 275 | 275 | |
| 276 | - if ( null !== $current_tours && ! empty( $current_tours ) ) { |
|
| 277 | - foreach ( $current_tours as $tour ) { |
|
| 278 | - $return[ $tour->meta_value ] = $tour; |
|
| 276 | + if (null !== $current_tours && !empty($current_tours)) { |
|
| 277 | + foreach ($current_tours as $tour) { |
|
| 278 | + $return[$tour->meta_value] = $tour; |
|
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | 281 | |
@@ -287,45 +287,45 @@ discard block |
||
| 287 | 287 | */ |
| 288 | 288 | public function process_ajax_search() { |
| 289 | 289 | $return = false; |
| 290 | - check_ajax_referer( 'lsx_wetu_ajax_action', 'security' ); |
|
| 290 | + check_ajax_referer('lsx_wetu_ajax_action', 'security'); |
|
| 291 | 291 | |
| 292 | - if ( isset( $_POST['action'] ) && 'lsx_tour_importer' === $_POST['action'] && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug ) { |
|
| 293 | - $tours = get_transient( 'lsx_ti_tours' ); |
|
| 292 | + if (isset($_POST['action']) && 'lsx_tour_importer' === $_POST['action'] && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) { |
|
| 293 | + $tours = get_transient('lsx_ti_tours'); |
|
| 294 | 294 | |
| 295 | - if ( false !== $tours ) { |
|
| 295 | + if (false !== $tours) { |
|
| 296 | 296 | $searched_items = false; |
| 297 | - if ( isset( $_POST['keyword'] ) ) { |
|
| 298 | - $keyphrases = array_map( 'sanitize_text_field', wp_unslash( $_POST['keyword'] ) ); |
|
| 299 | - } else { |
|
| 300 | - $keyphrases = array( 0 ); |
|
| 297 | + if (isset($_POST['keyword'])) { |
|
| 298 | + $keyphrases = array_map('sanitize_text_field', wp_unslash($_POST['keyword'])); |
|
| 299 | + }else { |
|
| 300 | + $keyphrases = array(0); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - if ( ! is_array( $keyphrases ) ) { |
|
| 304 | - $keyphrases = array( $keyphrases ); |
|
| 303 | + if (!is_array($keyphrases)) { |
|
| 304 | + $keyphrases = array($keyphrases); |
|
| 305 | 305 | } |
| 306 | - foreach ( $keyphrases as &$keyword ) { |
|
| 307 | - $keyword = ltrim( rtrim( $keyword ) ); |
|
| 306 | + foreach ($keyphrases as &$keyword) { |
|
| 307 | + $keyword = ltrim(rtrim($keyword)); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | $post_status = false; |
| 311 | - if ( in_array( 'publish',$keyphrases ) ) { |
|
| 311 | + if (in_array('publish', $keyphrases)) { |
|
| 312 | 312 | $post_status = 'publish'; |
| 313 | 313 | } |
| 314 | - if ( in_array( 'pending',$keyphrases ) ) { |
|
| 314 | + if (in_array('pending', $keyphrases)) { |
|
| 315 | 315 | $post_status = 'pending'; |
| 316 | 316 | } |
| 317 | - if ( in_array( 'draft',$keyphrases ) ) { |
|
| 317 | + if (in_array('draft', $keyphrases)) { |
|
| 318 | 318 | $post_status = 'draft'; |
| 319 | 319 | } |
| 320 | - if ( in_array( 'import',$keyphrases ) ) { |
|
| 320 | + if (in_array('import', $keyphrases)) { |
|
| 321 | 321 | $post_status = 'import'; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - if ( ! empty( $tours ) ) { |
|
| 324 | + if (!empty($tours)) { |
|
| 325 | 325 | $current_tours = $this->find_current_tours(); |
| 326 | 326 | |
| 327 | - foreach ( $tours as $row_key => $row ) { |
|
| 328 | - if ( isset( $row['is_disabled'] ) && true === $row['is_disabled'] ) { |
|
| 327 | + foreach ($tours as $row_key => $row) { |
|
| 328 | + if (isset($row['is_disabled']) && true === $row['is_disabled']) { |
|
| 329 | 329 | continue; |
| 330 | 330 | } |
| 331 | 331 | |
@@ -333,60 +333,60 @@ discard block |
||
| 333 | 333 | $row['post_id'] = 0; |
| 334 | 334 | $row['post_title'] = $row['name']; |
| 335 | 335 | |
| 336 | - if ( false !== $current_tours && array_key_exists( $row['identifier'], $current_tours ) ) { |
|
| 337 | - $row['post_id'] = $current_tours[ $row['identifier'] ]->post_id; |
|
| 338 | - $row['post_title'] = $current_tours[ $row['identifier'] ]->post_title; |
|
| 336 | + if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) { |
|
| 337 | + $row['post_id'] = $current_tours[$row['identifier']]->post_id; |
|
| 338 | + $row['post_title'] = $current_tours[$row['identifier']]->post_title; |
|
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | // If we are searching for. |
| 342 | - if ( false !== $post_status ) { |
|
| 343 | - if ( 'import' === $post_status ) { |
|
| 342 | + if (false !== $post_status) { |
|
| 343 | + if ('import' === $post_status) { |
|
| 344 | 344 | |
| 345 | - if ( 0 !== $row['post_id'] ) { |
|
| 345 | + if (0 !== $row['post_id']) { |
|
| 346 | 346 | continue; |
| 347 | - } else { |
|
| 348 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row, $row_key ); |
|
| 347 | + }else { |
|
| 348 | + $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row, $row_key); |
|
| 349 | 349 | } |
| 350 | - } else { |
|
| 351 | - if ( 0 === $row['post_id'] ) { |
|
| 350 | + }else { |
|
| 351 | + if (0 === $row['post_id']) { |
|
| 352 | 352 | continue; |
| 353 | - } else { |
|
| 354 | - $current_status = get_post_status( $row['post_id'] ); |
|
| 353 | + }else { |
|
| 354 | + $current_status = get_post_status($row['post_id']); |
|
| 355 | 355 | |
| 356 | - if ( $current_status !== $post_status ) { |
|
| 356 | + if ($current_status !== $post_status) { |
|
| 357 | 357 | continue; |
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row, $row_key ); |
|
| 361 | + $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row, $row_key); |
|
| 362 | 362 | } |
| 363 | - } else { |
|
| 363 | + }else { |
|
| 364 | 364 | // Search through each keyword. |
| 365 | - foreach ( $keyphrases as $keyphrase ) { |
|
| 365 | + foreach ($keyphrases as $keyphrase) { |
|
| 366 | 366 | |
| 367 | 367 | // Make sure the keyphrase is turned into an array. |
| 368 | - $keywords = explode( ' ',$keyphrase ); |
|
| 369 | - if ( ! is_array( $keywords ) ) { |
|
| 370 | - $keywords = array( $keywords ); |
|
| 368 | + $keywords = explode(' ', $keyphrase); |
|
| 369 | + if (!is_array($keywords)) { |
|
| 370 | + $keywords = array($keywords); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - if ( $this->multineedle_stripos( ltrim( rtrim( $row['name'] ) ), $keywords ) !== false ) { |
|
| 374 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row, $row_key ); |
|
| 375 | - } else if ( $this->multineedle_stripos( ltrim( rtrim( $row['reference_number'] ) ), $keywords ) !== false ) { |
|
| 376 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row, $row_key ); |
|
| 377 | - } else if ( $this->multineedle_stripos( ltrim( rtrim( $row['identifier_key'] ) ), $keywords ) !== false ) { |
|
| 378 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row, $row_key ); |
|
| 373 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
| 374 | + $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row, $row_key); |
|
| 375 | + }else if ($this->multineedle_stripos(ltrim(rtrim($row['reference_number'])), $keywords) !== false) { |
|
| 376 | + $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row, $row_key); |
|
| 377 | + }else if ($this->multineedle_stripos(ltrim(rtrim($row['identifier_key'])), $keywords) !== false) { |
|
| 378 | + $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row, $row_key); |
|
| 379 | 379 | } |
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - if ( false !== $searched_items ) { |
|
| 386 | - $return = implode( $searched_items ); |
|
| 385 | + if (false !== $searched_items) { |
|
| 386 | + $return = implode($searched_items); |
|
| 387 | 387 | } |
| 388 | 388 | } |
| 389 | - print_r( $return ); |
|
| 389 | + print_r($return); |
|
| 390 | 390 | die(); |
| 391 | 391 | } |
| 392 | 392 | } |
@@ -394,34 +394,34 @@ discard block |
||
| 394 | 394 | /** |
| 395 | 395 | * Formats the row for output on the screen. |
| 396 | 396 | */ |
| 397 | - public function format_row( $row = false, $row_key = '' ) { |
|
| 398 | - if ( false !== $row ) { |
|
| 397 | + public function format_row($row = false, $row_key = '') { |
|
| 398 | + if (false !== $row) { |
|
| 399 | 399 | $status = 'import'; |
| 400 | 400 | |
| 401 | - if ( 0 !== $row['post_id'] ) { |
|
| 402 | - $status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>'; |
|
| 401 | + if (0 !== $row['post_id']) { |
|
| 402 | + $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | $row_html = ' |
| 406 | - <tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '"> |
|
| 406 | + <tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'"> |
|
| 407 | 407 | <th class="check-column" scope="row"> |
| 408 | - <label for="cb-select-' . $row['identifier'] . '" class="screen-reader-text">' . $row['post_title'] . '</label> |
|
| 409 | - <input type="checkbox" data-identifier="' . $row['identifier'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['identifier'] . '"> |
|
| 408 | + <label for="cb-select-' . $row['identifier'].'" class="screen-reader-text">'.$row['post_title'].'</label> |
|
| 409 | + <input type="checkbox" data-identifier="' . $row['identifier'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['identifier'].'"> |
|
| 410 | 410 | </th> |
| 411 | 411 | <td class="column-order"> |
| 412 | - ' . ( $row_key + 1 ) . ' |
|
| 412 | + ' . ($row_key + 1).' |
|
| 413 | 413 | </td> |
| 414 | 414 | <td class="post-title page-title column-title"> |
| 415 | - ' . $row['post_title'] . ' - ' . $status . ' |
|
| 415 | + ' . $row['post_title'].' - '.$status.' |
|
| 416 | 416 | </td> |
| 417 | 417 | <td class="date column-date"> |
| 418 | - ' . $row['reference_number'] . ' |
|
| 418 | + ' . $row['reference_number'].' |
|
| 419 | 419 | </td> |
| 420 | 420 | <td class="date column-date"> |
| 421 | - <abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified |
|
| 421 | + <abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
| 422 | 422 | </td> |
| 423 | 423 | <td class="ssid column-ssid"> |
| 424 | - ' . $row['identifier'] . ' |
|
| 424 | + ' . $row['identifier'].' |
|
| 425 | 425 | </td> |
| 426 | 426 | </tr>'; |
| 427 | 427 | return $row_html; |
@@ -431,44 +431,44 @@ discard block |
||
| 431 | 431 | /** |
| 432 | 432 | * Connect to wetu |
| 433 | 433 | */ |
| 434 | - public function process_ajax_import( $force = false ) { |
|
| 434 | + public function process_ajax_import($force = false) { |
|
| 435 | 435 | $return = false; |
| 436 | - check_ajax_referer( 'lsx_wetu_ajax_action', 'security' ); |
|
| 437 | - if ( isset( $_POST['action'] ) && 'lsx_import_items' === $_POST['action'] && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug && isset( $_POST['wetu_id'] ) ) { |
|
| 436 | + check_ajax_referer('lsx_wetu_ajax_action', 'security'); |
|
| 437 | + if (isset($_POST['action']) && 'lsx_import_items' === $_POST['action'] && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) { |
|
| 438 | 438 | |
| 439 | - $wetu_id = sanitize_text_field( $_POST['wetu_id'] ); |
|
| 440 | - if ( isset( $_POST['post_id'] ) ) { |
|
| 441 | - $post_id = sanitize_text_field( $_POST['post_id'] ); |
|
| 442 | - } else { |
|
| 439 | + $wetu_id = sanitize_text_field($_POST['wetu_id']); |
|
| 440 | + if (isset($_POST['post_id'])) { |
|
| 441 | + $post_id = sanitize_text_field($_POST['post_id']); |
|
| 442 | + }else { |
|
| 443 | 443 | $post_id = 0; |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - delete_option( 'lsx_wetu_importer_tour_settings' ); |
|
| 446 | + delete_option('lsx_wetu_importer_tour_settings'); |
|
| 447 | 447 | |
| 448 | - if ( isset( $_POST['team_members'] ) ) { |
|
| 449 | - $team_members = array_map( 'sanitize_text_field', wp_unslash( $_POST['team_members'] ) ); |
|
| 450 | - } else { |
|
| 448 | + if (isset($_POST['team_members'])) { |
|
| 449 | + $team_members = array_map('sanitize_text_field', wp_unslash($_POST['team_members'])); |
|
| 450 | + }else { |
|
| 451 | 451 | $team_members = false; |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | - if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) { |
|
| 455 | - $content = array_map( 'sanitize_text_field', wp_unslash( $_POST['content'] ) ); |
|
| 456 | - add_option( 'lsx_wetu_importer_tour_settings',$content ); |
|
| 457 | - } else { |
|
| 454 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
| 455 | + $content = array_map('sanitize_text_field', wp_unslash($_POST['content'])); |
|
| 456 | + add_option('lsx_wetu_importer_tour_settings', $content); |
|
| 457 | + }else { |
|
| 458 | 458 | $content = false; |
| 459 | 459 | } |
| 460 | - $jdata = wp_remote_get( 'https://wetu.com/API/Itinerary/V8/Get?id=' . $wetu_id ); |
|
| 460 | + $jdata = wp_remote_get('https://wetu.com/API/Itinerary/V8/Get?id='.$wetu_id); |
|
| 461 | 461 | |
| 462 | - if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) { |
|
| 463 | - $jdata = json_decode( $jdata['body'], true ); |
|
| 464 | - $return = $this->import_row( $jdata, $wetu_id, $post_id, $team_members, $content ); |
|
| 465 | - $this->format_completed_row( $return ); |
|
| 462 | + if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) { |
|
| 463 | + $jdata = json_decode($jdata['body'], true); |
|
| 464 | + $return = $this->import_row($jdata, $wetu_id, $post_id, $team_members, $content); |
|
| 465 | + $this->format_completed_row($return); |
|
| 466 | 466 | $this->save_queue(); |
| 467 | 467 | $this->cleanup_posts(); |
| 468 | - $this->attach_destination_images( $content ); |
|
| 469 | - $this->clean_attached_destinations( $return ); |
|
| 470 | - } else { |
|
| 471 | - $this->format_error( esc_html__( 'There was a problem importing your tour, please contact support.', 'lsx-wetu-importer' ) ); |
|
| 468 | + $this->attach_destination_images($content); |
|
| 469 | + $this->clean_attached_destinations($return); |
|
| 470 | + }else { |
|
| 471 | + $this->format_error(esc_html__('There was a problem importing your tour, please contact support.', 'lsx-wetu-importer')); |
|
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | 474 | } |
@@ -479,13 +479,13 @@ discard block |
||
| 479 | 479 | * @param $id string |
| 480 | 480 | * @return void |
| 481 | 481 | */ |
| 482 | - public function clean_attached_destinations( $id ) { |
|
| 483 | - $current_connections = get_post_meta( $id, 'destination_to_tour', false ); |
|
| 484 | - delete_post_meta( $id,'destination_to_tour' ); |
|
| 485 | - $current_connections = array_unique( $current_connections ); |
|
| 482 | + public function clean_attached_destinations($id) { |
|
| 483 | + $current_connections = get_post_meta($id, 'destination_to_tour', false); |
|
| 484 | + delete_post_meta($id, 'destination_to_tour'); |
|
| 485 | + $current_connections = array_unique($current_connections); |
|
| 486 | 486 | |
| 487 | - foreach ( $current_connections as $connection ) { |
|
| 488 | - add_post_meta( $id, 'destination_to_tour',$connection, false ); |
|
| 487 | + foreach ($current_connections as $connection) { |
|
| 488 | + add_post_meta($id, 'destination_to_tour', $connection, false); |
|
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | 491 | |
@@ -495,12 +495,12 @@ discard block |
||
| 495 | 495 | * @param $data array |
| 496 | 496 | * @param $wetu_id string |
| 497 | 497 | */ |
| 498 | - public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $old1 = false, $old2 = false ) { |
|
| 498 | + public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = array(), $old1 = false, $old2 = false) { |
|
| 499 | 499 | $post_name = ''; |
| 500 | 500 | $data_post_content = ''; |
| 501 | 501 | $data_post_excerpt = ''; |
| 502 | 502 | |
| 503 | - $current_post = get_post( $id ); |
|
| 503 | + $current_post = get_post($id); |
|
| 504 | 504 | |
| 505 | 505 | $post = array( |
| 506 | 506 | 'post_type' => 'tour', |
@@ -508,72 +508,72 @@ discard block |
||
| 508 | 508 | |
| 509 | 509 | $content_used_general_description = false; |
| 510 | 510 | |
| 511 | - if ( ! empty( $importable_content ) && in_array( 'description', $importable_content ) ) { |
|
| 511 | + if (!empty($importable_content) && in_array('description', $importable_content)) { |
|
| 512 | 512 | $data_post_content = $current_post->post_content; |
| 513 | - if ( isset( $data['summary'] ) && ! empty( $data['summary'] ) ) { |
|
| 513 | + if (isset($data['summary']) && !empty($data['summary'])) { |
|
| 514 | 514 | $data_post_content = $data['summary']; |
| 515 | 515 | } |
| 516 | 516 | $post['post_content'] = $data_post_content; |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | // Create or update the post. |
| 520 | - if ( false !== $id && '0' !== $id ) { |
|
| 520 | + if (false !== $id && '0' !== $id) { |
|
| 521 | 521 | $post['ID'] = $id; |
| 522 | 522 | $post['post_status'] = 'publish'; |
| 523 | - if ( isset( $this->options ) && 'on' !== $this->options['disable_accommodation_title'] ) { |
|
| 523 | + if (isset($this->options) && 'on' !== $this->options['disable_accommodation_title']) { |
|
| 524 | 524 | $post['post_title'] = $data['name']; |
| 525 | 525 | } |
| 526 | - $id = wp_update_post( $post ); |
|
| 527 | - } else { |
|
| 526 | + $id = wp_update_post($post); |
|
| 527 | + }else { |
|
| 528 | 528 | // Set the name. |
| 529 | - if ( isset( $data['name'] ) ) { |
|
| 530 | - $post_name = wp_unique_post_slug( sanitize_title( $data['name'] ), $id, 'draft', 'tour', 0 ); |
|
| 529 | + if (isset($data['name'])) { |
|
| 530 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - if ( ! isset( $post['post_content'] ) ) { |
|
| 533 | + if (!isset($post['post_content'])) { |
|
| 534 | 534 | $post['post_content'] = ' '; |
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | $post['post_name'] = $post_name; |
| 538 | 538 | $post['post_title'] = $data['name']; |
| 539 | 539 | $post['post_status'] = 'publish'; |
| 540 | - $id = wp_insert_post( $post ); |
|
| 540 | + $id = wp_insert_post($post); |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | // Set reference number. |
| 544 | - $this->set_reference_number( $data, $id ); |
|
| 544 | + $this->set_reference_number($data, $id); |
|
| 545 | 545 | |
| 546 | 546 | // Set the team member if it is there. |
| 547 | - if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) { |
|
| 548 | - $this->set_team_member( $id, $team_members ); |
|
| 547 | + if (post_type_exists('team') && false !== $team_members && '' !== $team_members) { |
|
| 548 | + $this->set_team_member($id, $team_members); |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | // Set the price. |
| 552 | - if ( false !== $importable_content && in_array( 'price', $importable_content ) ) { |
|
| 553 | - $this->set_price( $data, $id ); |
|
| 552 | + if (false !== $importable_content && in_array('price', $importable_content)) { |
|
| 553 | + $this->set_price($data, $id); |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | // Set the Duration. |
| 557 | - if ( false !== $importable_content && in_array( 'duration', $importable_content ) ) { |
|
| 558 | - $this->set_duration( $data, $id ); |
|
| 557 | + if (false !== $importable_content && in_array('duration', $importable_content)) { |
|
| 558 | + $this->set_duration($data, $id); |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | // Set the Group Size. |
| 562 | - if ( false !== $importable_content && in_array( 'group_size', $importable_content ) ) { |
|
| 563 | - $this->set_group_size( $data, $id ); |
|
| 562 | + if (false !== $importable_content && in_array('group_size', $importable_content)) { |
|
| 563 | + $this->set_group_size($data, $id); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | // Set the Group Size. |
| 567 | - if ( false !== $importable_content && in_array( 'tags', $importable_content ) ) { |
|
| 568 | - $this->set_travel_styles( $id, $data ); |
|
| 567 | + if (false !== $importable_content && in_array('tags', $importable_content)) { |
|
| 568 | + $this->set_travel_styles($id, $data); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - if ( false !== $importable_content && in_array( 'itineraries', $importable_content ) && isset( $data['legs'] ) && ! empty( $data['legs'] ) ) { |
|
| 572 | - $this->process_itineraries( $data, $id, $importable_content ); |
|
| 571 | + if (false !== $importable_content && in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) { |
|
| 572 | + $this->process_itineraries($data, $id, $importable_content); |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - if ( in_array( 'map', $importable_content ) && isset( $data['routes'] ) && ! empty( $data['routes'] ) ) { |
|
| 576 | - $this->set_map_data( $data, $id ); |
|
| 575 | + if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) { |
|
| 576 | + $this->set_map_data($data, $id); |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | return $id; |
@@ -582,195 +582,195 @@ discard block |
||
| 582 | 582 | /** |
| 583 | 583 | * A loop which runs through each leg on the tour. |
| 584 | 584 | */ |
| 585 | - public function process_itineraries( $data, $id, $importable_content ) { |
|
| 585 | + public function process_itineraries($data, $id, $importable_content) { |
|
| 586 | 586 | $day_counter = 1; |
| 587 | 587 | $leg_counter = 0; |
| 588 | 588 | |
| 589 | - delete_post_meta( $id, 'itinerary' ); |
|
| 589 | + delete_post_meta($id, 'itinerary'); |
|
| 590 | 590 | |
| 591 | - if ( false !== $importable_content && in_array( 'accommodation', $importable_content ) ) { |
|
| 592 | - delete_post_meta( $id, 'accommodation_to_tour' ); |
|
| 591 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
| 592 | + delete_post_meta($id, 'accommodation_to_tour'); |
|
| 593 | 593 | } |
| 594 | - if ( false !== $importable_content && in_array( 'destination', $importable_content ) ) { |
|
| 595 | - delete_post_meta( $id, 'departs_from' ); |
|
| 596 | - delete_post_meta( $id, 'ends_in' ); |
|
| 594 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
| 595 | + delete_post_meta($id, 'departs_from'); |
|
| 596 | + delete_post_meta($id, 'ends_in'); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | $departs_from = false; |
| 600 | 600 | $ends_in = false; |
| 601 | 601 | |
| 602 | - foreach ( $data['legs'] as $leg ) { |
|
| 602 | + foreach ($data['legs'] as $leg) { |
|
| 603 | 603 | // Itinerary Accommodation. |
| 604 | 604 | $current_accommodation = false; |
| 605 | - if ( false !== $importable_content && in_array( 'accommodation', $importable_content ) ) { |
|
| 606 | - $current_accommodation = $this->set_accommodation( $leg, $id ); |
|
| 605 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
| 606 | + $current_accommodation = $this->set_accommodation($leg, $id); |
|
| 607 | 607 | } |
| 608 | 608 | |
| 609 | 609 | // Itinerary Destination. |
| 610 | 610 | $current_destination = false; |
| 611 | - if ( false !== $importable_content && in_array( 'destination', $importable_content ) ) { |
|
| 612 | - $current_destination = $this->set_destination( $leg, $id, $leg_counter ); |
|
| 611 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
| 612 | + $current_destination = $this->set_destination($leg, $id, $leg_counter); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | // If the Nights are the same mount of days in the array, then it isnt "By Destination". |
| 616 | - if ( ( ( 1 <= (int) $leg['nights'] && isset( $leg['periods'] ) ) ) || 0 === $leg['itinerary_leg_id'] ) { |
|
| 617 | - foreach ( $leg['periods'] as $day ) { |
|
| 616 | + if (((1 <= (int) $leg['nights'] && isset($leg['periods']))) || 0 === $leg['itinerary_leg_id']) { |
|
| 617 | + foreach ($leg['periods'] as $day) { |
|
| 618 | 618 | $current_day = array(); |
| 619 | - $current_day['title'] = esc_attr( 'Day ', 'lsx-wetu-importer' ) . $day_counter; |
|
| 619 | + $current_day['title'] = esc_attr('Day ', 'lsx-wetu-importer').$day_counter; |
|
| 620 | 620 | |
| 621 | 621 | //print_r('<pre>');print_r($day['notes']);print_r('</pre>'); |
| 622 | 622 | |
| 623 | 623 | // Description. |
| 624 | - if ( false !== $importable_content && in_array( 'itinerary_description', $importable_content ) && isset( $day['notes'] ) ) { |
|
| 624 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) { |
|
| 625 | 625 | $current_day['description'] = $day['notes']; |
| 626 | - } else { |
|
| 626 | + }else { |
|
| 627 | 627 | $current_day['description'] = ''; |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | // Itinerary Gallery. |
| 631 | - if ( false !== $importable_content && in_array( 'itinerary_gallery', $importable_content ) && isset( $day['images'] ) ) { |
|
| 631 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) { |
|
| 632 | 632 | $current_day['featured_image'] = ''; |
| 633 | - } else { |
|
| 633 | + }else { |
|
| 634 | 634 | $current_day['featured_image'] = ''; |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | // Accommodation. |
| 638 | - if ( false !== $current_accommodation ) { |
|
| 639 | - $current_day['accommodation_to_tour'] = array( $current_accommodation ); |
|
| 640 | - } else { |
|
| 638 | + if (false !== $current_accommodation) { |
|
| 639 | + $current_day['accommodation_to_tour'] = array($current_accommodation); |
|
| 640 | + }else { |
|
| 641 | 641 | $current_day['accommodation_to_tour'] = array(); |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | // Destination. |
| 645 | - if ( false !== $current_destination ) { |
|
| 646 | - $current_day['destination_to_tour'] = array( $current_destination ); |
|
| 647 | - } else { |
|
| 645 | + if (false !== $current_destination) { |
|
| 646 | + $current_day['destination_to_tour'] = array($current_destination); |
|
| 647 | + }else { |
|
| 648 | 648 | $current_day['destination_to_tour'] = array(); |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | // Included. |
| 652 | - if ( false !== $importable_content && in_array( 'itinerary_included', $importable_content ) && isset( $day['included'] ) && '' !== $day['included'] ) { |
|
| 652 | + if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) { |
|
| 653 | 653 | $current_day['included'] = $day['included']; |
| 654 | - } else { |
|
| 654 | + }else { |
|
| 655 | 655 | $current_day['included'] = ''; |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | // Excluded. |
| 659 | - if ( false !== $importable_content && in_array( 'itinerary_excluded', $importable_content ) && isset( $day['excluded'] ) && '' !== $day['excluded'] ) { |
|
| 659 | + if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) { |
|
| 660 | 660 | $current_day['excluded'] = $day['excluded']; |
| 661 | - } else { |
|
| 661 | + }else { |
|
| 662 | 662 | $current_day['excluded'] = ''; |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | - $this->set_itinerary_day( $current_day,$id ); |
|
| 665 | + $this->set_itinerary_day($current_day, $id); |
|
| 666 | 666 | $day_counter++; |
| 667 | 667 | } |
| 668 | - } else { |
|
| 668 | + }else { |
|
| 669 | 669 | // This is for the by destination. |
| 670 | 670 | |
| 671 | 671 | $current_day = array(); |
| 672 | 672 | $next_day_count = $day_counter + (int) $leg['nights']; |
| 673 | 673 | $day_count_label = $next_day_count - 1; |
| 674 | 674 | |
| 675 | - $current_day['title'] = esc_attr( 'Day ', 'lsx-wetu-importer' ) . $day_counter; |
|
| 675 | + $current_day['title'] = esc_attr('Day ', 'lsx-wetu-importer').$day_counter; |
|
| 676 | 676 | |
| 677 | - if ( 0 !== (int) $leg['nights'] ) { |
|
| 678 | - $current_day['title'] .= ' - ' . $day_count_label; |
|
| 677 | + if (0 !== (int) $leg['nights']) { |
|
| 678 | + $current_day['title'] .= ' - '.$day_count_label; |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | // Description. |
| 682 | - if ( false !== $importable_content && in_array( 'itinerary_description', $importable_content ) && isset( $leg['notes'] ) ) { |
|
| 682 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($leg['notes'])) { |
|
| 683 | 683 | $current_day['description'] = $leg['notes']; |
| 684 | - } else { |
|
| 684 | + }else { |
|
| 685 | 685 | $current_day['description'] = ''; |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | // Itinerary Gallery. |
| 689 | - if ( false !== $importable_content && in_array( 'itinerary_gallery', $importable_content ) && isset( $leg['images'] ) ) { |
|
| 689 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($leg['images'])) { |
|
| 690 | 690 | $current_day['featured_image'] = ''; |
| 691 | - } else { |
|
| 691 | + }else { |
|
| 692 | 692 | $current_day['featured_image'] = ''; |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | // Accommodation. |
| 696 | - if ( false !== $current_accommodation ) { |
|
| 697 | - $current_day['accommodation_to_tour'] = array( $current_accommodation ); |
|
| 698 | - } else { |
|
| 696 | + if (false !== $current_accommodation) { |
|
| 697 | + $current_day['accommodation_to_tour'] = array($current_accommodation); |
|
| 698 | + }else { |
|
| 699 | 699 | $current_day['accommodation_to_tour'] = array(); |
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | // Destination. |
| 703 | - if ( false !== $current_destination ) { |
|
| 704 | - $current_day['destination_to_tour'] = array( $current_destination ); |
|
| 705 | - } else { |
|
| 703 | + if (false !== $current_destination) { |
|
| 704 | + $current_day['destination_to_tour'] = array($current_destination); |
|
| 705 | + }else { |
|
| 706 | 706 | $current_day['destination_to_tour'] = array(); |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | // Included. |
| 710 | - if ( false !== $importable_content && in_array( 'itinerary_included', $importable_content ) && isset( $leg['included'] ) && '' !== $leg['included'] ) { |
|
| 710 | + if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($leg['included']) && '' !== $leg['included']) { |
|
| 711 | 711 | $current_day['included'] = $leg['included']; |
| 712 | - } else { |
|
| 712 | + }else { |
|
| 713 | 713 | $current_day['included'] = ''; |
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | // Excluded. |
| 717 | - if ( false !== $importable_content && in_array( 'itinerary_excluded', $importable_content ) && isset( $leg['excluded'] ) && '' !== $leg['excluded'] ) { |
|
| 717 | + if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($leg['excluded']) && '' !== $leg['excluded']) { |
|
| 718 | 718 | $current_day['excluded'] = $leg['excluded']; |
| 719 | - } else { |
|
| 719 | + }else { |
|
| 720 | 720 | $current_day['excluded'] = ''; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - $this->set_itinerary_day( $current_day,$id ); |
|
| 723 | + $this->set_itinerary_day($current_day, $id); |
|
| 724 | 724 | $day_counter = $next_day_count; |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | // If we are in the first leg, and the destination was attached then save it as the departure field. |
| 728 | - if ( 0 === $leg_counter && false !== $current_destination ) { |
|
| 728 | + if (0 === $leg_counter && false !== $current_destination) { |
|
| 729 | 729 | $departs_from = $current_destination; |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | // If its the last leg then save it as the ends in. |
| 733 | - if ( ( count( $data['legs'] ) - 2 ) === $leg_counter && false !== $current_destination ) { |
|
| 733 | + if ((count($data['legs']) - 2) === $leg_counter && false !== $current_destination) { |
|
| 734 | 734 | $ends_in = $current_destination; |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | $leg_counter++; |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | - if ( false !== $departs_from ) { |
|
| 741 | - add_post_meta( $id, 'departs_from', $departs_from, true ); |
|
| 740 | + if (false !== $departs_from) { |
|
| 741 | + add_post_meta($id, 'departs_from', $departs_from, true); |
|
| 742 | 742 | } |
| 743 | - if ( false !== $ends_in ) { |
|
| 744 | - add_post_meta( $id, 'ends_in', $ends_in, true ); |
|
| 743 | + if (false !== $ends_in) { |
|
| 744 | + add_post_meta($id, 'ends_in', $ends_in, true); |
|
| 745 | 745 | } |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | /** |
| 749 | 749 | * Run through your routes and save the points as a KML file. |
| 750 | 750 | */ |
| 751 | - public function set_map_data( $data, $id, $zoom = 9 ) { |
|
| 752 | - if ( ! empty( $data['routes'] ) ) { |
|
| 753 | - delete_post_meta( $id,'wetu_map_points' ); |
|
| 751 | + public function set_map_data($data, $id, $zoom = 9) { |
|
| 752 | + if (!empty($data['routes'])) { |
|
| 753 | + delete_post_meta($id, 'wetu_map_points'); |
|
| 754 | 754 | |
| 755 | 755 | $points = array(); |
| 756 | 756 | |
| 757 | - foreach ( $data['routes'] as $route ) { |
|
| 757 | + foreach ($data['routes'] as $route) { |
|
| 758 | 758 | |
| 759 | - if ( isset( $route['points'] ) && '' !== $route['points'] ) { |
|
| 759 | + if (isset($route['points']) && '' !== $route['points']) { |
|
| 760 | 760 | |
| 761 | - $temp_points = explode( ';',$route['points'] ); |
|
| 762 | - $point_counter = count( $temp_points ); |
|
| 761 | + $temp_points = explode(';', $route['points']); |
|
| 762 | + $point_counter = count($temp_points); |
|
| 763 | 763 | |
| 764 | - for ( $x = 0; $x <= $point_counter; $x++ ) { |
|
| 764 | + for ($x = 0; $x <= $point_counter; $x++) { |
|
| 765 | 765 | $y = $x + 1; |
| 766 | - $points[] = $temp_points[ $x ] . ',' . $temp_points[ $y ]; |
|
| 766 | + $points[] = $temp_points[$x].','.$temp_points[$y]; |
|
| 767 | 767 | $x++; |
| 768 | 768 | } |
| 769 | 769 | } |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | - if ( ! empty( $points ) ) { |
|
| 773 | - $this->save_custom_field( implode( ' ',$points ),'wetu_map_points',$id,false,true ); |
|
| 772 | + if (!empty($points)) { |
|
| 773 | + $this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true); |
|
| 774 | 774 | } |
| 775 | 775 | } |
| 776 | 776 | |
@@ -781,64 +781,64 @@ discard block |
||
| 781 | 781 | /** |
| 782 | 782 | * Set the Itinerary Day. |
| 783 | 783 | */ |
| 784 | - public function set_itinerary_day( $day, $id ) { |
|
| 785 | - $this->save_custom_field( $day, 'itinerary', $id, false, false ); |
|
| 784 | + public function set_itinerary_day($day, $id) { |
|
| 785 | + $this->save_custom_field($day, 'itinerary', $id, false, false); |
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | /** |
| 789 | 789 | * Set the ref number |
| 790 | 790 | */ |
| 791 | - public function set_reference_number( $data, $id ) { |
|
| 792 | - if ( isset( $data['reference_number'] ) && '' !== $data['reference_number'] ) { |
|
| 793 | - $this->save_custom_field( $data['reference_number'], 'lsx_wetu_ref', $id ); |
|
| 791 | + public function set_reference_number($data, $id) { |
|
| 792 | + if (isset($data['reference_number']) && '' !== $data['reference_number']) { |
|
| 793 | + $this->save_custom_field($data['reference_number'], 'lsx_wetu_ref', $id); |
|
| 794 | 794 | } |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | /** |
| 798 | 798 | * Set the price. |
| 799 | 799 | */ |
| 800 | - public function set_price( $data, $id ) { |
|
| 800 | + public function set_price($data, $id) { |
|
| 801 | 801 | // Price. |
| 802 | - if ( isset( $data['price'] ) && '' !== $data['price'] ) { |
|
| 802 | + if (isset($data['price']) && '' !== $data['price']) { |
|
| 803 | 803 | $price = $data['price']; |
| 804 | - if ( false === apply_filters( 'lsx_wetu_importer_disable_tour_price_filter', false ) ) { |
|
| 805 | - $price = preg_replace( '/[^0-9,.]/', '', $price ); |
|
| 804 | + if (false === apply_filters('lsx_wetu_importer_disable_tour_price_filter', false)) { |
|
| 805 | + $price = preg_replace('/[^0-9,.]/', '', $price); |
|
| 806 | 806 | } |
| 807 | - $meta_key = apply_filters( 'lsx_wetu_importer_price_meta_key', 'price' ); |
|
| 808 | - $this->save_custom_field( $price, $meta_key, $id ); |
|
| 807 | + $meta_key = apply_filters('lsx_wetu_importer_price_meta_key', 'price'); |
|
| 808 | + $this->save_custom_field($price, $meta_key, $id); |
|
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | // Price includes. |
| 812 | - if ( isset( $data['price_includes'] ) && '' !== $data['price_includes'] ) { |
|
| 813 | - $meta_key = apply_filters( 'lsx_wetu_importer_included_meta_key', 'included' ); |
|
| 814 | - $this->save_custom_field( $data['price_includes'], $meta_key, $id ); |
|
| 812 | + if (isset($data['price_includes']) && '' !== $data['price_includes']) { |
|
| 813 | + $meta_key = apply_filters('lsx_wetu_importer_included_meta_key', 'included'); |
|
| 814 | + $this->save_custom_field($data['price_includes'], $meta_key, $id); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | // Price Excludes. |
| 818 | - if ( isset( $data['price_excludes'] ) && '' !== $data['price_excludes'] ) { |
|
| 819 | - $meta_key = apply_filters( 'lsx_wetu_importer_not_included_meta_key', 'not_included' ); |
|
| 820 | - $this->save_custom_field( $data['price_excludes'], $meta_key, $id ); |
|
| 818 | + if (isset($data['price_excludes']) && '' !== $data['price_excludes']) { |
|
| 819 | + $meta_key = apply_filters('lsx_wetu_importer_not_included_meta_key', 'not_included'); |
|
| 820 | + $this->save_custom_field($data['price_excludes'], $meta_key, $id); |
|
| 821 | 821 | } |
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | /** |
| 825 | 825 | * Set the duration. |
| 826 | 826 | */ |
| 827 | - public function set_duration( $data, $id ) { |
|
| 828 | - if ( isset( $data['days'] ) && ! empty( $data['days'] ) ) { |
|
| 827 | + public function set_duration($data, $id) { |
|
| 828 | + if (isset($data['days']) && !empty($data['days'])) { |
|
| 829 | 829 | $price = $data['days']; |
| 830 | - $price = preg_replace( '/[^0-9,.]/', '', $price ); |
|
| 831 | - $this->save_custom_field( $price, 'duration', $id ); |
|
| 830 | + $price = preg_replace('/[^0-9,.]/', '', $price); |
|
| 831 | + $this->save_custom_field($price, 'duration', $id); |
|
| 832 | 832 | } |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | /** |
| 836 | 836 | * Set the group size |
| 837 | 837 | */ |
| 838 | - public function set_group_size( $data, $id ) { |
|
| 839 | - if ( isset( $data['group_size'] ) && ! empty( $data['group_size'] ) ) { |
|
| 838 | + public function set_group_size($data, $id) { |
|
| 839 | + if (isset($data['group_size']) && !empty($data['group_size'])) { |
|
| 840 | 840 | $group_size = $data['group_size']; |
| 841 | - $this->save_custom_field( $group_size,'group_size',$id ); |
|
| 841 | + $this->save_custom_field($group_size, 'group_size', $id); |
|
| 842 | 842 | } |
| 843 | 843 | } |
| 844 | 844 | |
@@ -849,10 +849,10 @@ discard block |
||
| 849 | 849 | * @param array $travel_styles |
| 850 | 850 | * @return void |
| 851 | 851 | */ |
| 852 | - public function set_travel_styles( $id, $data ) { |
|
| 853 | - if ( isset( $data['tags'] ) ) { |
|
| 854 | - foreach ( $data['tags'] as $tag ) { |
|
| 855 | - $this->set_term( $id, $tag, 'travel-style' ); |
|
| 852 | + public function set_travel_styles($id, $data) { |
|
| 853 | + if (isset($data['tags'])) { |
|
| 854 | + foreach ($data['tags'] as $tag) { |
|
| 855 | + $this->set_term($id, $tag, 'travel-style'); |
|
| 856 | 856 | } |
| 857 | 857 | } |
| 858 | 858 | } |
@@ -860,27 +860,27 @@ discard block |
||
| 860 | 860 | /** |
| 861 | 861 | * Connects the Accommodation if its available |
| 862 | 862 | */ |
| 863 | - public function set_accommodation( $day, $id ) { |
|
| 863 | + public function set_accommodation($day, $id) { |
|
| 864 | 864 | $ac_id = false; |
| 865 | 865 | $this->current_accommodation = $this->find_current_accommodation(); |
| 866 | 866 | |
| 867 | - if ( isset( $day['content_entity_id'] ) && ! empty( $day['content_entity_id'] ) ) { |
|
| 868 | - if ( false !== $this->current_accommodation && ! empty( $this->current_accommodation ) && array_key_exists( $day['content_entity_id'],$this->current_accommodation ) ) { |
|
| 869 | - $ac_id = $this->current_accommodation[ $day['content_entity_id'] ]; |
|
| 870 | - } else { |
|
| 867 | + if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) { |
|
| 868 | + if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) { |
|
| 869 | + $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
| 870 | + }else { |
|
| 871 | 871 | $ac_id = wp_insert_post(array( |
| 872 | 872 | 'post_type' => 'accommodation', |
| 873 | 873 | 'post_status' => 'draft', |
| 874 | 874 | 'post_title' => $day['content_entity_id'], |
| 875 | 875 | )); |
| 876 | 876 | |
| 877 | - $this->save_custom_field( $day['content_entity_id'],'lsx_wetu_id',$ac_id ); |
|
| 877 | + $this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id); |
|
| 878 | 878 | } |
| 879 | 879 | |
| 880 | - if ( '' !== $ac_id && false !== $ac_id ) { |
|
| 881 | - $this->save_custom_field( $ac_id,'accommodation_to_tour',$id,false,false ); |
|
| 882 | - $this->save_custom_field( $id,'tour_to_accommodation',$ac_id,false,false ); |
|
| 883 | - $this->queue_item( $ac_id ); |
|
| 880 | + if ('' !== $ac_id && false !== $ac_id) { |
|
| 881 | + $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false); |
|
| 882 | + $this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false); |
|
| 883 | + $this->queue_item($ac_id); |
|
| 884 | 884 | } |
| 885 | 885 | } |
| 886 | 886 | return $ac_id; |
@@ -892,14 +892,14 @@ discard block |
||
| 892 | 892 | * @param $post_type string |
| 893 | 893 | * @return boolean / array |
| 894 | 894 | */ |
| 895 | - public function find_current_accommodation( $post_type = 'accommodation' ) { |
|
| 895 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
| 896 | 896 | global $wpdb; |
| 897 | - $accommodation = parent::find_current_accommodation( $post_type ); |
|
| 897 | + $accommodation = parent::find_current_accommodation($post_type); |
|
| 898 | 898 | $return = false; |
| 899 | 899 | |
| 900 | - if ( ! empty( $accommodation ) ) { |
|
| 901 | - foreach ( $accommodation as $key => $acc ) { |
|
| 902 | - $return[ $acc->meta_value ] = $acc->post_id; |
|
| 900 | + if (!empty($accommodation)) { |
|
| 901 | + foreach ($accommodation as $key => $acc) { |
|
| 902 | + $return[$acc->meta_value] = $acc->post_id; |
|
| 903 | 903 | } |
| 904 | 904 | } |
| 905 | 905 | |
@@ -911,7 +911,7 @@ discard block |
||
| 911 | 911 | * @return boolean / array |
| 912 | 912 | */ |
| 913 | 913 | public function find_current_destinations() { |
| 914 | - return $this->find_current_accommodation( 'destination' ); |
|
| 914 | + return $this->find_current_accommodation('destination'); |
|
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | /** |
@@ -921,44 +921,44 @@ discard block |
||
| 921 | 921 | * @param $id string |
| 922 | 922 | * @return boolean / string |
| 923 | 923 | */ |
| 924 | - public function set_destination( $day, $id, $leg_counter ) { |
|
| 924 | + public function set_destination($day, $id, $leg_counter) { |
|
| 925 | 925 | $dest_id = false; |
| 926 | 926 | $country_id = false; |
| 927 | 927 | |
| 928 | 928 | $this->current_destinations = $this->find_current_destinations(); |
| 929 | 929 | |
| 930 | - if ( isset( $day['destination_content_entity_id'] ) && ! empty( $day['destination_content_entity_id'] ) ) { |
|
| 931 | - if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $day['destination_content_entity_id'], $this->current_destinations ) ) { |
|
| 932 | - $dest_id = $this->current_destinations[ $day['destination_content_entity_id'] ]; |
|
| 930 | + if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) { |
|
| 931 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) { |
|
| 932 | + $dest_id = $this->current_destinations[$day['destination_content_entity_id']]; |
|
| 933 | 933 | |
| 934 | 934 | //TODO Check for attachments here. |
| 935 | - $this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] ); |
|
| 935 | + $this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']); |
|
| 936 | 936 | |
| 937 | 937 | //Check if there is a country asigned. |
| 938 | - $potential_id = wp_get_post_parent_id( $dest_id ); |
|
| 939 | - $country_wetu_id = get_post_meta( $potential_id, 'lsx_wetu_id', true ); |
|
| 938 | + $potential_id = wp_get_post_parent_id($dest_id); |
|
| 939 | + $country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true); |
|
| 940 | 940 | |
| 941 | - if ( false !== $country_wetu_id ) { |
|
| 942 | - $country_id = $this->set_country( $country_wetu_id, $id ); |
|
| 941 | + if (false !== $country_wetu_id) { |
|
| 942 | + $country_id = $this->set_country($country_wetu_id, $id); |
|
| 943 | 943 | } |
| 944 | - } else { |
|
| 945 | - $destination_json = wp_remote_get( 'https://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $day['destination_content_entity_id'] ); |
|
| 944 | + }else { |
|
| 945 | + $destination_json = wp_remote_get('https://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$day['destination_content_entity_id']); |
|
| 946 | 946 | |
| 947 | - if ( ! empty( $destination_json ) && isset( $destination_json['response'] ) && isset( $destination_json['response']['code'] ) && 200 === $destination_json['response']['code'] ) { |
|
| 947 | + if (!empty($destination_json) && isset($destination_json['response']) && isset($destination_json['response']['code']) && 200 === $destination_json['response']['code']) { |
|
| 948 | 948 | |
| 949 | - $destination_data = json_decode( $destination_json['body'], true ); |
|
| 949 | + $destination_data = json_decode($destination_json['body'], true); |
|
| 950 | 950 | |
| 951 | - if ( ! empty( $destination_data ) && ! isset( $destination_data['error'] ) ) { |
|
| 951 | + if (!empty($destination_data) && !isset($destination_data['error'])) { |
|
| 952 | 952 | $destination_title = $day['destination_content_entity_id']; |
| 953 | 953 | |
| 954 | - if ( isset( $destination_data[0]['name'] ) ) { |
|
| 954 | + if (isset($destination_data[0]['name'])) { |
|
| 955 | 955 | $destination_title = $destination_data[0]['name']; |
| 956 | 956 | } |
| 957 | 957 | |
| 958 | - if ( isset( $destination_data[0]['map_object_id'] ) && isset( $destination_data[0]['position']['country_content_entity_id'] ) |
|
| 959 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id'] ) { |
|
| 958 | + if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
| 959 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) { |
|
| 960 | 960 | |
| 961 | - $country_id = $this->set_country( $destination_data[0]['position']['country_content_entity_id'], $id ); |
|
| 961 | + $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
|
| 962 | 962 | // Save the destination so we can grab the tour featured image and banner from them. |
| 963 | 963 | } |
| 964 | 964 | |
@@ -968,40 +968,40 @@ discard block |
||
| 968 | 968 | 'post_title' => $destination_title, |
| 969 | 969 | ); |
| 970 | 970 | |
| 971 | - if ( false !== $country_id ) { |
|
| 971 | + if (false !== $country_id) { |
|
| 972 | 972 | $dest_post['post_parent'] = $country_id; |
| 973 | 973 | } |
| 974 | - $dest_id = wp_insert_post( $dest_post ); |
|
| 974 | + $dest_id = wp_insert_post($dest_post); |
|
| 975 | 975 | |
| 976 | 976 | // Make sure we register the. |
| 977 | - $this->current_destinations[ $day['destination_content_entity_id'] ] = $dest_id; |
|
| 977 | + $this->current_destinations[$day['destination_content_entity_id']] = $dest_id; |
|
| 978 | 978 | |
| 979 | 979 | // If there are images attached then use the destination. |
| 980 | - if ( isset( $destination_data[0]['content']['images'] ) && ! empty( $destination_data[0]['content']['images'] ) ) { |
|
| 981 | - $this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] ); |
|
| 980 | + if (isset($destination_data[0]['content']['images']) && !empty($destination_data[0]['content']['images'])) { |
|
| 981 | + $this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']); |
|
| 982 | 982 | } |
| 983 | 983 | |
| 984 | - $this->save_custom_field( $day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id ); |
|
| 984 | + $this->save_custom_field($day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id); |
|
| 985 | 985 | } |
| 986 | 986 | } |
| 987 | 987 | } |
| 988 | 988 | |
| 989 | - if ( '' !== $dest_id && false !== $dest_id ) { |
|
| 990 | - $this->save_custom_field( $dest_id, 'destination_to_tour', $id, false, false ); |
|
| 991 | - $this->save_custom_field( $id, 'tour_to_destination', $dest_id, false, false ); |
|
| 989 | + if ('' !== $dest_id && false !== $dest_id) { |
|
| 990 | + $this->save_custom_field($dest_id, 'destination_to_tour', $id, false, false); |
|
| 991 | + $this->save_custom_field($id, 'tour_to_destination', $dest_id, false, false); |
|
| 992 | 992 | |
| 993 | 993 | //Save the item to display in the queue |
| 994 | - $this->queue_item( $dest_id ); |
|
| 994 | + $this->queue_item($dest_id); |
|
| 995 | 995 | |
| 996 | 996 | //Save the item to clean up the amount of connections. |
| 997 | - $this->cleanup_posts[ $dest_id ] = 'tour_to_destination'; |
|
| 997 | + $this->cleanup_posts[$dest_id] = 'tour_to_destination'; |
|
| 998 | 998 | |
| 999 | 999 | //Add this relation info so we can make sure certain items are set as countries. |
| 1000 | - if ( 0 !== $country_id && false !== $country_id ) { |
|
| 1001 | - $this->relation_meta[ $dest_id ] = $country_id; |
|
| 1002 | - $this->relation_meta[ $country_id ] = 0; |
|
| 1003 | - } else { |
|
| 1004 | - $this->relation_meta[ $dest_id ] = 0; |
|
| 1000 | + if (0 !== $country_id && false !== $country_id) { |
|
| 1001 | + $this->relation_meta[$dest_id] = $country_id; |
|
| 1002 | + $this->relation_meta[$country_id] = 0; |
|
| 1003 | + }else { |
|
| 1004 | + $this->relation_meta[$dest_id] = 0; |
|
| 1005 | 1005 | } |
| 1006 | 1006 | } |
| 1007 | 1007 | } |
@@ -1017,23 +1017,23 @@ discard block |
||
| 1017 | 1017 | * |
| 1018 | 1018 | * @return string |
| 1019 | 1019 | */ |
| 1020 | - public function set_country( $country_wetu_id, $id ) { |
|
| 1020 | + public function set_country($country_wetu_id, $id) { |
|
| 1021 | 1021 | $country_id = false; |
| 1022 | 1022 | $this->current_destinations = $this->find_current_destinations(); |
| 1023 | 1023 | |
| 1024 | - if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $country_wetu_id, $this->current_destinations ) ) { |
|
| 1025 | - $country_id = $this->current_destinations[ $country_wetu_id ]; |
|
| 1026 | - $this->destination_images[ $id ][] = array( $country_id, $country_wetu_id ); |
|
| 1027 | - } else { |
|
| 1028 | - $country_json = wp_remote_get( 'https://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $country_wetu_id ); |
|
| 1024 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
| 1025 | + $country_id = $this->current_destinations[$country_wetu_id]; |
|
| 1026 | + $this->destination_images[$id][] = array($country_id, $country_wetu_id); |
|
| 1027 | + }else { |
|
| 1028 | + $country_json = wp_remote_get('https://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$country_wetu_id); |
|
| 1029 | 1029 | |
| 1030 | - if ( ! empty( $country_json ) && isset( $country_json['response'] ) && isset( $country_json['response']['code'] ) && 200 === $country_json['response']['code'] ) { |
|
| 1031 | - $country_data = json_decode( $country_json['body'], true ); |
|
| 1030 | + if (!empty($country_json) && isset($country_json['response']) && isset($country_json['response']['code']) && 200 === $country_json['response']['code']) { |
|
| 1031 | + $country_data = json_decode($country_json['body'], true); |
|
| 1032 | 1032 | |
| 1033 | 1033 | // Format the title of the destination if its available, otherwise default to the WETU ID. |
| 1034 | 1034 | $country_title = $country_wetu_id; |
| 1035 | 1035 | |
| 1036 | - if ( isset( $country_data[0]['name'] ) ) { |
|
| 1036 | + if (isset($country_data[0]['name'])) { |
|
| 1037 | 1037 | $country_title = $country_data[0]['name']; |
| 1038 | 1038 | } |
| 1039 | 1039 | |
@@ -1044,23 +1044,23 @@ discard block |
||
| 1044 | 1044 | )); |
| 1045 | 1045 | |
| 1046 | 1046 | //add the country to the current destination stack |
| 1047 | - $this->current_destinations[ $country_wetu_id ] = $country_id; |
|
| 1047 | + $this->current_destinations[$country_wetu_id] = $country_id; |
|
| 1048 | 1048 | |
| 1049 | 1049 | // Check if there are images and save fore use later. |
| 1050 | - if ( isset( $country_data[0]['content']['images'] ) && ! empty( $country_data[0]['content']['images'] ) ) { |
|
| 1051 | - $this->destination_images[ $id ][] = array( $country_id,$country_wetu_id ); |
|
| 1050 | + if (isset($country_data[0]['content']['images']) && !empty($country_data[0]['content']['images'])) { |
|
| 1051 | + $this->destination_images[$id][] = array($country_id, $country_wetu_id); |
|
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | 1054 | //Save the wetu field |
| 1055 | - $this->save_custom_field( $country_wetu_id, 'lsx_wetu_id', $country_id ); |
|
| 1055 | + $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
| 1056 | 1056 | } |
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | - if ( '' !== $country_id && false !== $country_id ) { |
|
| 1060 | - $this->save_custom_field( $country_id, 'destination_to_tour', $id, false, false ); |
|
| 1061 | - $this->save_custom_field( $id, 'tour_to_destination', $country_id, false, false ); |
|
| 1062 | - $this->queue_item( $country_id ); |
|
| 1063 | - $this->cleanup_posts[ $country_id ] = 'tour_to_destination'; |
|
| 1059 | + if ('' !== $country_id && false !== $country_id) { |
|
| 1060 | + $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
| 1061 | + $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
| 1062 | + $this->queue_item($country_id); |
|
| 1063 | + $this->cleanup_posts[$country_id] = 'tour_to_destination'; |
|
| 1064 | 1064 | |
| 1065 | 1065 | return $country_id; |
| 1066 | 1066 | } |
@@ -1075,44 +1075,44 @@ discard block |
||
| 1075 | 1075 | * |
| 1076 | 1076 | * @return string |
| 1077 | 1077 | */ |
| 1078 | - public function attach_destination_images( $importable_content = array() ) { |
|
| 1079 | - if ( false !== $this->destination_images ) { |
|
| 1080 | - $this->shuffle_assoc( $this->destination_images ); |
|
| 1078 | + public function attach_destination_images($importable_content = array()) { |
|
| 1079 | + if (false !== $this->destination_images) { |
|
| 1080 | + $this->shuffle_assoc($this->destination_images); |
|
| 1081 | 1081 | |
| 1082 | - foreach ( $this->destination_images as $tour => $destinations ) { |
|
| 1082 | + foreach ($this->destination_images as $tour => $destinations) { |
|
| 1083 | 1083 | //$this->shuffle_assoc( $destinations ); |
| 1084 | 1084 | |
| 1085 | 1085 | $image_set = false; |
| 1086 | 1086 | $forced = false; |
| 1087 | 1087 | |
| 1088 | - foreach ( $destinations as $destination ) { |
|
| 1089 | - if ( false === $image_set && false === $forced ) { |
|
| 1090 | - $url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
| 1088 | + foreach ($destinations as $destination) { |
|
| 1089 | + if (false === $image_set && false === $forced) { |
|
| 1090 | + $url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
| 1091 | 1091 | $url_qs = ''; |
| 1092 | 1092 | |
| 1093 | - $jdata = wp_remote_get( $url . '/Get?' . $url_qs . '&ids=' . $destination[1] ); |
|
| 1093 | + $jdata = wp_remote_get($url.'/Get?'.$url_qs.'&ids='.$destination[1]); |
|
| 1094 | 1094 | |
| 1095 | - if ( ! empty( $jdata ) && isset( $jdata['response'] ) && isset( $jdata['response']['code'] ) && 200 === $jdata['response']['code'] ) { |
|
| 1096 | - $adata = json_decode( $jdata['body'], true ); |
|
| 1095 | + if (!empty($jdata) && isset($jdata['response']) && isset($jdata['response']['code']) && 200 === $jdata['response']['code']) { |
|
| 1096 | + $adata = json_decode($jdata['body'], true); |
|
| 1097 | 1097 | |
| 1098 | - if ( ! empty( $adata ) && ! empty( $adata[0]['content']['images'] ) ) { |
|
| 1099 | - $this->find_attachments( $destination[0] ); |
|
| 1098 | + if (!empty($adata) && !empty($adata[0]['content']['images'])) { |
|
| 1099 | + $this->find_attachments($destination[0]); |
|
| 1100 | 1100 | |
| 1101 | 1101 | //Set the featured image |
| 1102 | - if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) { |
|
| 1103 | - $image_set = $this->set_featured_image( $adata, $tour ); |
|
| 1104 | - if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) { |
|
| 1105 | - $image_set = $this->set_banner_image( $adata, $tour ); |
|
| 1102 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
| 1103 | + $image_set = $this->set_featured_image($adata, $tour); |
|
| 1104 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
| 1105 | + $image_set = $this->set_banner_image($adata, $tour); |
|
| 1106 | 1106 | $forced = true; |
| 1107 | 1107 | } |
| 1108 | 1108 | continue; |
| 1109 | 1109 | } |
| 1110 | - if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) { |
|
| 1111 | - $image_set = $this->set_banner_image( $adata, $tour ); |
|
| 1110 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
| 1111 | + $image_set = $this->set_banner_image($adata, $tour); |
|
| 1112 | 1112 | } |
| 1113 | 1113 | } |
| 1114 | 1114 | } |
| 1115 | - } else { |
|
| 1115 | + }else { |
|
| 1116 | 1116 | continue; |
| 1117 | 1117 | } |
| 1118 | 1118 | } |
@@ -1123,28 +1123,28 @@ discard block |
||
| 1123 | 1123 | /** |
| 1124 | 1124 | * Creates the main gallery data |
| 1125 | 1125 | */ |
| 1126 | - public function set_featured_image( $data, $id ) { |
|
| 1126 | + public function set_featured_image($data, $id) { |
|
| 1127 | 1127 | $image_set = false; |
| 1128 | 1128 | $counter = 0; |
| 1129 | 1129 | |
| 1130 | - if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) { |
|
| 1131 | - foreach ( $data[0]['content']['images'] as $v ) { |
|
| 1130 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 1131 | + foreach ($data[0]['content']['images'] as $v) { |
|
| 1132 | 1132 | /*print_r('<pre>'); |
| 1133 | 1133 | print_r( $v ); |
| 1134 | 1134 | print_r('</pre>');*/ |
| 1135 | 1135 | |
| 1136 | - if ( true === $image_set ) { |
|
| 1136 | + if (true === $image_set) { |
|
| 1137 | 1137 | $counter++; |
| 1138 | 1138 | continue; |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | - if ( ! $this->check_if_image_is_used( $v ) ) { |
|
| 1142 | - $temp_featured_image = $this->attach_image( $v , $id ); |
|
| 1141 | + if (!$this->check_if_image_is_used($v)) { |
|
| 1142 | + $temp_featured_image = $this->attach_image($v, $id); |
|
| 1143 | 1143 | |
| 1144 | - if ( false !== $temp_featured_image ) { |
|
| 1144 | + if (false !== $temp_featured_image) { |
|
| 1145 | 1145 | $this->featured_image = $temp_featured_image; |
| 1146 | - delete_post_meta( $id, '_thumbnail_id' ); |
|
| 1147 | - add_post_meta( $id, '_thumbnail_id', $this->featured_image, true ); |
|
| 1146 | + delete_post_meta($id, '_thumbnail_id'); |
|
| 1147 | + add_post_meta($id, '_thumbnail_id', $this->featured_image, true); |
|
| 1148 | 1148 | $image_set = true; |
| 1149 | 1149 | } |
| 1150 | 1150 | } |
@@ -1158,40 +1158,40 @@ discard block |
||
| 1158 | 1158 | /** |
| 1159 | 1159 | * Sets a banner image |
| 1160 | 1160 | */ |
| 1161 | - public function set_banner_image( $data, $id, $content = array( 'none' ) ) { |
|
| 1161 | + public function set_banner_image($data, $id, $content = array('none')) { |
|
| 1162 | 1162 | $image_set = false; |
| 1163 | 1163 | $counter = 0; |
| 1164 | 1164 | |
| 1165 | - if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) { |
|
| 1165 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 1166 | 1166 | |
| 1167 | - foreach ( $data[0]['content']['images'] as $v ) { |
|
| 1167 | + foreach ($data[0]['content']['images'] as $v) { |
|
| 1168 | 1168 | /*print_r('<pre>'); |
| 1169 | 1169 | print_r( $v ); |
| 1170 | 1170 | print_r('</pre>');*/ |
| 1171 | 1171 | |
| 1172 | - if ( true === $image_set || 0 === $counter ) { |
|
| 1172 | + if (true === $image_set || 0 === $counter) { |
|
| 1173 | 1173 | $counter++; |
| 1174 | 1174 | continue; |
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | - if ( ! $this->check_if_image_is_used( $v ) ) { |
|
| 1178 | - $temp_banner = $this->attach_image( $v, $id, array( |
|
| 1177 | + if (!$this->check_if_image_is_used($v)) { |
|
| 1178 | + $temp_banner = $this->attach_image($v, $id, array( |
|
| 1179 | 1179 | 'width' => '1920', |
| 1180 | 1180 | 'height' => '600', |
| 1181 | 1181 | 'cropping' => 'c', |
| 1182 | - ) ); |
|
| 1182 | + )); |
|
| 1183 | 1183 | |
| 1184 | - if ( false !== $temp_banner ) { |
|
| 1184 | + if (false !== $temp_banner) { |
|
| 1185 | 1185 | $this->banner_image = $temp_banner; |
| 1186 | 1186 | |
| 1187 | - delete_post_meta( $id,'image_group' ); |
|
| 1187 | + delete_post_meta($id, 'image_group'); |
|
| 1188 | 1188 | |
| 1189 | 1189 | $new_banner = array( |
| 1190 | 1190 | 'banner_image' => array( |
| 1191 | 1191 | 'cmb-field-0' => $this->banner_image, |
| 1192 | 1192 | ), |
| 1193 | 1193 | ); |
| 1194 | - add_post_meta( $id,'image_group',$new_banner,true ); |
|
| 1194 | + add_post_meta($id, 'image_group', $new_banner, true); |
|
| 1195 | 1195 | $image_set = true; |
| 1196 | 1196 | } |
| 1197 | 1197 | } |
@@ -1205,36 +1205,36 @@ discard block |
||
| 1205 | 1205 | /** |
| 1206 | 1206 | * Grabs all of the current used featured images on the site. |
| 1207 | 1207 | */ |
| 1208 | - public function check_if_image_is_used( $v ) { |
|
| 1208 | + public function check_if_image_is_used($v) { |
|
| 1209 | 1209 | global $wpdb; |
| 1210 | 1210 | |
| 1211 | - $temp_fragment = explode( '/', $v['url_fragment'] ); |
|
| 1212 | - $url_filename = $temp_fragment[ count( $temp_fragment ) - 1 ]; |
|
| 1213 | - $url_filename = str_replace( array( '.jpg', '.png', '.jpeg' ), '', $url_filename ); |
|
| 1214 | - $url_filename = trim( $url_filename ); |
|
| 1215 | - $url_filename = str_replace( ' ', '_', $url_filename ); |
|
| 1211 | + $temp_fragment = explode('/', $v['url_fragment']); |
|
| 1212 | + $url_filename = $temp_fragment[count($temp_fragment) - 1]; |
|
| 1213 | + $url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename); |
|
| 1214 | + $url_filename = trim($url_filename); |
|
| 1215 | + $url_filename = str_replace(' ', '_', $url_filename); |
|
| 1216 | 1216 | |
| 1217 | - if ( in_array( $url_filename, $this->found_attachments ) ) { |
|
| 1217 | + if (in_array($url_filename, $this->found_attachments)) { |
|
| 1218 | 1218 | // check to see if there is a featured image set with this ID. |
| 1219 | - $found_id = array_search( $url_filename, $this->found_attachments ); |
|
| 1219 | + $found_id = array_search($url_filename, $this->found_attachments); |
|
| 1220 | 1220 | |
| 1221 | - $results = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value = '%s' AND meta_key = '_thumbnail_id'", array( $found_id ) ) ); |
|
| 1222 | - if ( ! empty( $results ) ) { |
|
| 1221 | + $results = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value = '%s' AND meta_key = '_thumbnail_id'", array($found_id))); |
|
| 1222 | + if (!empty($results)) { |
|
| 1223 | 1223 | return true; |
| 1224 | - } else { |
|
| 1224 | + }else { |
|
| 1225 | 1225 | return false; |
| 1226 | 1226 | } |
| 1227 | - } else { |
|
| 1228 | - $results = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = '%s'", array( $url_filename ) ) ); |
|
| 1227 | + }else { |
|
| 1228 | + $results = $wpdb->get_results($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_name = '%s'", array($url_filename))); |
|
| 1229 | 1229 | |
| 1230 | - if ( ! empty( $results ) ) { |
|
| 1231 | - $results = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value = '%s' AND meta_key = '_thumbnail_id'", array( $results[0]->ID ) ) ); |
|
| 1232 | - if ( ! empty( $results ) ) { |
|
| 1230 | + if (!empty($results)) { |
|
| 1231 | + $results = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value = '%s' AND meta_key = '_thumbnail_id'", array($results[0]->ID))); |
|
| 1232 | + if (!empty($results)) { |
|
| 1233 | 1233 | return true; |
| 1234 | - } else { |
|
| 1234 | + }else { |
|
| 1235 | 1235 | return false; |
| 1236 | 1236 | } |
| 1237 | - } else { |
|
| 1237 | + }else { |
|
| 1238 | 1238 | return false; |
| 1239 | 1239 | } |
| 1240 | 1240 | } |
@@ -1245,10 +1245,10 @@ discard block |
||
| 1245 | 1245 | * |
| 1246 | 1246 | * @param $id int |
| 1247 | 1247 | */ |
| 1248 | - public function queue_item( $id ) { |
|
| 1249 | - if ( is_array( $this->import_queue ) && ! in_array( $id, $this->import_queue ) ) { |
|
| 1248 | + public function queue_item($id) { |
|
| 1249 | + if (is_array($this->import_queue) && !in_array($id, $this->import_queue)) { |
|
| 1250 | 1250 | $this->import_queue[] = $id; |
| 1251 | - } else { |
|
| 1251 | + }else { |
|
| 1252 | 1252 | $this->import_queue[] = $id; |
| 1253 | 1253 | } |
| 1254 | 1254 | } |
@@ -1257,18 +1257,18 @@ discard block |
||
| 1257 | 1257 | * Saves the queue to the option. |
| 1258 | 1258 | */ |
| 1259 | 1259 | public function save_queue() { |
| 1260 | - if ( ! empty( $this->import_queue ) ) { |
|
| 1261 | - if ( ! empty( $this->queued_imports ) ) { |
|
| 1262 | - $saved_imports = array_merge( $this->queued_imports, $this->import_queue ); |
|
| 1263 | - } else { |
|
| 1260 | + if (!empty($this->import_queue)) { |
|
| 1261 | + if (!empty($this->queued_imports)) { |
|
| 1262 | + $saved_imports = array_merge($this->queued_imports, $this->import_queue); |
|
| 1263 | + }else { |
|
| 1264 | 1264 | $saved_imports = $this->import_queue; |
| 1265 | 1265 | } |
| 1266 | 1266 | |
| 1267 | - delete_option( 'lsx_wetu_importer_que' ); |
|
| 1267 | + delete_option('lsx_wetu_importer_que'); |
|
| 1268 | 1268 | |
| 1269 | - if ( ! empty( $saved_imports ) ) { |
|
| 1270 | - $saved_imports = array_unique( $saved_imports ); |
|
| 1271 | - update_option( 'lsx_wetu_importer_que', $saved_imports ); |
|
| 1269 | + if (!empty($saved_imports)) { |
|
| 1270 | + $saved_imports = array_unique($saved_imports); |
|
| 1271 | + update_option('lsx_wetu_importer_que', $saved_imports); |
|
| 1272 | 1272 | } |
| 1273 | 1273 | } |
| 1274 | 1274 | } |
@@ -1281,14 +1281,14 @@ discard block |
||
| 1281 | 1281 | <thead> |
| 1282 | 1282 | <tr> |
| 1283 | 1283 | <th style="" class="manage-column column-cb check-column no-sort" id="cb" scope="col"> |
| 1284 | - <label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'lsx-wetu-importer' ); ?></label> |
|
| 1284 | + <label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'lsx-wetu-importer'); ?></label> |
|
| 1285 | 1285 | <input type="checkbox" id="cb-select-all-1"> |
| 1286 | 1286 | </th> |
| 1287 | - <th style="" class="manage-column column-order " id="order"><?php esc_attr_e( 'Order', 'lsx-wetu-importer' ); ?></th> |
|
| 1288 | - <th style="" class="manage-column column-title " id="title" scope="col"><?php esc_attr_e( 'Title', 'lsx-wetu-importer' ); ?></th> |
|
| 1289 | - <th style="" class="manage-column column-date" id="ref" scope="col"><?php esc_attr_e( 'Ref', 'lsx-wetu-importer' ); ?></th> |
|
| 1290 | - <th style="" class="manage-column column-date" id="date" scope="col"><?php esc_attr_e( 'Date', 'lsx-wetu-importer' ); ?></th> |
|
| 1291 | - <th style="" class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'lsx-wetu-importer' ); ?></th> |
|
| 1287 | + <th style="" class="manage-column column-order " id="order"><?php esc_attr_e('Order', 'lsx-wetu-importer'); ?></th> |
|
| 1288 | + <th style="" class="manage-column column-title " id="title" scope="col"><?php esc_attr_e('Title', 'lsx-wetu-importer'); ?></th> |
|
| 1289 | + <th style="" class="manage-column column-date" id="ref" scope="col"><?php esc_attr_e('Ref', 'lsx-wetu-importer'); ?></th> |
|
| 1290 | + <th style="" class="manage-column column-date" id="date" scope="col"><?php esc_attr_e('Date', 'lsx-wetu-importer'); ?></th> |
|
| 1291 | + <th style="" class="manage-column column-ssid" id="ssid" scope="col"><?php esc_attr_e('WETU ID', 'lsx-wetu-importer'); ?></th> |
|
| 1292 | 1292 | </tr> |
| 1293 | 1293 | </thead> |
| 1294 | 1294 | <?php |
@@ -1302,14 +1302,14 @@ discard block |
||
| 1302 | 1302 | <tfoot> |
| 1303 | 1303 | <tr> |
| 1304 | 1304 | <th style="" class="manage-column column-cb check-column" id="cb" scope="col"> |
| 1305 | - <label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e( 'Select All', 'lsx-wetu-importer' ); ?></label> |
|
| 1305 | + <label for="cb-select-all-1" class="screen-reader-text"><?php esc_attr_e('Select All', 'lsx-wetu-importer'); ?></label> |
|
| 1306 | 1306 | <input type="checkbox" id="cb-select-all-1"> |
| 1307 | 1307 | </th> |
| 1308 | - <th style="" class="manage-column column-order " id="order"><?php esc_attr_e( 'Order', 'lsx-wetu-importer' ); ?></th> |
|
| 1309 | - <th style="" class="manage-column column-title" scope="col"><?php esc_attr_e( 'Title', 'lsx-wetu-importer' ); ?></th> |
|
| 1310 | - <th style="" class="manage-column column-date" id="ref" scope="col"><?php esc_attr_e( 'Ref', 'lsx-wetu-importer' ); ?></th> |
|
| 1311 | - <th style="" class="manage-column column-date" scope="col"><?php esc_attr_e( 'Date', 'lsx-wetu-importer' ); ?></th> |
|
| 1312 | - <th style="" class="manage-column column-ssid" scope="col"><?php esc_attr_e( 'WETU ID', 'lsx-wetu-importer' ); ?></th> |
|
| 1308 | + <th style="" class="manage-column column-order " id="order"><?php esc_attr_e('Order', 'lsx-wetu-importer'); ?></th> |
|
| 1309 | + <th style="" class="manage-column column-title" scope="col"><?php esc_attr_e('Title', 'lsx-wetu-importer'); ?></th> |
|
| 1310 | + <th style="" class="manage-column column-date" id="ref" scope="col"><?php esc_attr_e('Ref', 'lsx-wetu-importer'); ?></th> |
|
| 1311 | + <th style="" class="manage-column column-date" scope="col"><?php esc_attr_e('Date', 'lsx-wetu-importer'); ?></th> |
|
| 1312 | + <th style="" class="manage-column column-ssid" scope="col"><?php esc_attr_e('WETU ID', 'lsx-wetu-importer'); ?></th> |
|
| 1313 | 1313 | </tr> |
| 1314 | 1314 | </tfoot> |
| 1315 | 1315 | <?php |