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