@@ -639,6 +639,7 @@ discard block |
||
| 639 | 639 | |
| 640 | 640 | /** |
| 641 | 641 | * Set the team memberon each item. |
| 642 | + * @param boolean $team_members |
|
| 642 | 643 | */ |
| 643 | 644 | public function set_team_member( $id, $team_members ) { |
| 644 | 645 | delete_post_meta( $id, 'team_to_' . $this->tab_slug ); |
@@ -650,6 +651,7 @@ discard block |
||
| 650 | 651 | |
| 651 | 652 | /** |
| 652 | 653 | * Set the safari brand |
| 654 | + * @param boolean $safari_brands |
|
| 653 | 655 | */ |
| 654 | 656 | public function set_safari_brands( $id, $safari_brands ) { |
| 655 | 657 | foreach ( $safari_brands as $safari_brand ) { |
@@ -76,19 +76,19 @@ discard block |
||
| 76 | 76 | // $this->url = 'https://wetu.com/API/Pins/'; |
| 77 | 77 | // $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
| 78 | 78 | //} elseif ( false !== $this->api_key ) { |
| 79 | - $this->url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
| 79 | + $this->url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
| 80 | 80 | $this->url_qs = 'all=include'; |
| 81 | 81 | //} |
| 82 | 82 | |
| 83 | - $temp_options = get_option( '_lsx-to_settings', false ); |
|
| 83 | + $temp_options = get_option('_lsx-to_settings', false); |
|
| 84 | 84 | |
| 85 | - if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) { |
|
| 86 | - $this->options = $temp_options[ $this->plugin_slug ]; |
|
| 85 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
| 86 | + $this->options = $temp_options[$this->plugin_slug]; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - $accommodation_options = get_option( 'wetu_importer_accommodation_settings',false ); |
|
| 89 | + $accommodation_options = get_option('wetu_importer_accommodation_settings', false); |
|
| 90 | 90 | |
| 91 | - if ( false !== $accommodation_options ) { |
|
| 91 | + if (false !== $accommodation_options) { |
|
| 92 | 92 | $this->accommodation_options = $accommodation_options; |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -99,17 +99,17 @@ discard block |
||
| 99 | 99 | public function display_page() { |
| 100 | 100 | ?> |
| 101 | 101 | <div class="wrap"> |
| 102 | - <?php $this->navigation( 'accommodation' ); ?> |
|
| 102 | + <?php $this->navigation('accommodation'); ?> |
|
| 103 | 103 | |
| 104 | 104 | <?php $this->update_options_form(); ?> |
| 105 | 105 | |
| 106 | 106 | <?php $this->search_form(); ?> |
| 107 | 107 | |
| 108 | 108 | <form method="get" action="" id="posts-filter"> |
| 109 | - <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" /> |
|
| 109 | + <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" /> |
|
| 110 | 110 | |
| 111 | - <p><input class="button button-primary add" type="button" value="<?php esc_attr_e( 'Add to List', 'wetu-importer' ); ?>" /> |
|
| 112 | - <input class="button button-primary clear" type="button" value="<?php esc_attr_e( 'Clear', 'wetu-importer' ); ?>" /> |
|
| 111 | + <p><input class="button button-primary add" type="button" value="<?php esc_attr_e('Add to List', 'wetu-importer'); ?>" /> |
|
| 112 | + <input class="button button-primary clear" type="button" value="<?php esc_attr_e('Clear', 'wetu-importer'); ?>" /> |
|
| 113 | 113 | </p> |
| 114 | 114 | |
| 115 | 115 | <table class="wp-list-table widefat fixed posts"> |
@@ -118,11 +118,11 @@ discard block |
||
| 118 | 118 | <tbody id="the-list"> |
| 119 | 119 | <tr class="post-0 type-tour status-none" id="post-0"> |
| 120 | 120 | <th class="check-column" scope="row"> |
| 121 | - <label for="cb-select-0" class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter', 'wetu-importer' ); ?></label> |
|
| 121 | + <label for="cb-select-0" 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"> |
@@ -136,8 +136,8 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | </table> |
| 138 | 138 | |
| 139 | - <p><input class="button button-primary add" type="button" value="<?php esc_attr_e( 'Add to List', 'wetu-importer' ); ?>" /> |
|
| 140 | - <input class="button button-primary clear" type="button" value="<?php esc_attr_e( 'Clear', 'wetu-importer' ); ?>" /> |
|
| 139 | + <p><input class="button button-primary add" type="button" value="<?php esc_attr_e('Add to List', 'wetu-importer'); ?>" /> |
|
| 140 | + <input class="button button-primary clear" type="button" value="<?php esc_attr_e('Clear', 'wetu-importer'); ?>" /> |
|
| 141 | 141 | </p> |
| 142 | 142 | </form> |
| 143 | 143 | |
@@ -147,66 +147,66 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | <div class="row"> |
| 149 | 149 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 150 | - <h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3> |
|
| 150 | + <h3><?php esc_html_e('What content to Sync from WETU'); ?></h3> |
|
| 151 | 151 | <ul> |
| 152 | - <li><input class="content select-all" <?php $this->checked( $this->accommodation_options, 'all' ); ?> type="checkbox" name="content[]" value="all" /> <?php esc_html_e( 'Select All', 'wetu-importer' ); ?></li> |
|
| 153 | - <?php if ( ! isset( $this->options['disable_accommodation_descriptions'] ) ) { ?> |
|
| 154 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'description' ); ?>" type="checkbox" name="content[]" value="description" /> <?php esc_html_e( 'Description', 'wetu-importer' ); ?></li> |
|
| 152 | + <li><input class="content select-all" <?php $this->checked($this->accommodation_options, 'all'); ?> type="checkbox" name="content[]" value="all" /> <?php esc_html_e('Select All', 'wetu-importer'); ?></li> |
|
| 153 | + <?php if (!isset($this->options['disable_accommodation_descriptions'])) { ?> |
|
| 154 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'description'); ?>" type="checkbox" name="content[]" value="description" /> <?php esc_html_e('Description', 'wetu-importer'); ?></li> |
|
| 155 | 155 | <?php } ?> |
| 156 | - <?php if ( ! isset( $this->options['disable_accommodation_excerpts'] ) ) { ?> |
|
| 157 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'excerpt' ); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php esc_html_e( 'Excerpt', 'wetu-importer' ); ?></li> |
|
| 156 | + <?php if (!isset($this->options['disable_accommodation_excerpts'])) { ?> |
|
| 157 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'excerpt'); ?>" type="checkbox" name="content[]" value="excerpt" /> <?php esc_html_e('Excerpt', 'wetu-importer'); ?></li> |
|
| 158 | 158 | <?php } ?> |
| 159 | 159 | |
| 160 | - <?php if ( ! isset( $this->accommodation_settings['disable_single'] ) ) { ?> |
|
| 161 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'gallery' ); ?>" type="checkbox" name="content[]" value="gallery" /> <?php esc_html_e( 'Main Gallery', 'wetu-importer' ); ?></li> |
|
| 160 | + <?php if (!isset($this->accommodation_settings['disable_single'])) { ?> |
|
| 161 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'gallery'); ?>" type="checkbox" name="content[]" value="gallery" /> <?php esc_html_e('Main Gallery', 'wetu-importer'); ?></li> |
|
| 162 | 162 | <?php } ?> |
| 163 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'category' ); ?>" type="checkbox" name="content[]" value="category" /> <?php esc_html_e( 'Category', 'wetu-importer' ); ?></li> |
|
| 164 | - <?php if ( class_exists( 'LSX_TO_Maps' ) && ! isset( $this->accommodation_settings['disable_single'] ) ) { ?> |
|
| 165 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'location' ); ?>" type="checkbox" name="content[]" value="location" /> <?php esc_html_e( 'Location', 'wetu-importer' ); ?></li> |
|
| 163 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'category'); ?>" type="checkbox" name="content[]" value="category" /> <?php esc_html_e('Category', 'wetu-importer'); ?></li> |
|
| 164 | + <?php if (class_exists('LSX_TO_Maps') && !isset($this->accommodation_settings['disable_single'])) { ?> |
|
| 165 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'location'); ?>" type="checkbox" name="content[]" value="location" /> <?php esc_html_e('Location', 'wetu-importer'); ?></li> |
|
| 166 | 166 | <?php } ?> |
| 167 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'destination' ); ?>" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e( 'Connect Destinations', 'wetu-importer' ); ?></li> |
|
| 168 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'rating' ); ?>" type="checkbox" name="content[]" value="rating" /> <?php esc_html_e( 'Rating', 'wetu-importer' ); ?></li> |
|
| 169 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'rooms' ); ?>" type="checkbox" name="content[]" value="rooms" /> <?php esc_html_e( 'Rooms', 'wetu-importer' ); ?></li> |
|
| 170 | - |
|
| 171 | - <?php if ( ! isset( $this->accommodation_settings['disable_single'] ) ) { ?> |
|
| 172 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'checkin' ); ?>" type="checkbox" name="content[]" value="checkin" /> <?php esc_html_e( 'Check In / Check Out', 'wetu-importer' ); ?></li> |
|
| 173 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'facilities' ); ?>" type="checkbox" name="content[]" value="facilities" /> <?php esc_html_e( 'Facilities', 'wetu-importer' ); ?></li> |
|
| 174 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'friendly' ); ?>" type="checkbox" name="content[]" value="friendly" /> <?php esc_html_e( 'Friendly', 'wetu-importer' ); ?></li> |
|
| 167 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'destination'); ?>" type="checkbox" name="content[]" value="destination" /> <?php esc_html_e('Connect Destinations', 'wetu-importer'); ?></li> |
|
| 168 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rating'); ?>" type="checkbox" name="content[]" value="rating" /> <?php esc_html_e('Rating', 'wetu-importer'); ?></li> |
|
| 169 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'rooms'); ?>" type="checkbox" name="content[]" value="rooms" /> <?php esc_html_e('Rooms', 'wetu-importer'); ?></li> |
|
| 170 | + |
|
| 171 | + <?php if (!isset($this->accommodation_settings['disable_single'])) { ?> |
|
| 172 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'checkin'); ?>" type="checkbox" name="content[]" value="checkin" /> <?php esc_html_e('Check In / Check Out', 'wetu-importer'); ?></li> |
|
| 173 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'facilities'); ?>" type="checkbox" name="content[]" value="facilities" /> <?php esc_html_e('Facilities', 'wetu-importer'); ?></li> |
|
| 174 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'friendly'); ?>" type="checkbox" name="content[]" value="friendly" /> <?php esc_html_e('Friendly', 'wetu-importer'); ?></li> |
|
| 175 | 175 | <?php } ?> |
| 176 | 176 | |
| 177 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'special_interests' ); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php esc_html_e( 'Special Interests', 'wetu-importer' ); ?></li> |
|
| 178 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'spoken_languages' ); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php esc_html_e( 'Spoken Languages', 'wetu-importer' ); ?></li> |
|
| 177 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'special_interests'); ?>" type="checkbox" name="content[]" value="special_interests" /> <?php esc_html_e('Special Interests', 'wetu-importer'); ?></li> |
|
| 178 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'spoken_languages'); ?>" type="checkbox" name="content[]" value="spoken_languages" /> <?php esc_html_e('Spoken Languages', 'wetu-importer'); ?></li> |
|
| 179 | 179 | |
| 180 | - <?php if ( class_exists( 'LSX_TO_Videos' ) && ! isset( $this->accommodation_settings['disable_single'] ) ) { ?> |
|
| 181 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'videos' ); ?>" type="checkbox" name="content[]" value="videos" /> <?php esc_html_e( 'Videos', 'wetu-importer' ); ?></li> |
|
| 180 | + <?php if (class_exists('LSX_TO_Videos') && !isset($this->accommodation_settings['disable_single'])) { ?> |
|
| 181 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'videos'); ?>" type="checkbox" name="content[]" value="videos" /> <?php esc_html_e('Videos', 'wetu-importer'); ?></li> |
|
| 182 | 182 | <?php } ?> |
| 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 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'featured_image' ); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e( 'Set Featured Image', 'wetu-importer' ); ?></li> |
|
| 187 | - <?php if ( class_exists( 'LSX_Banners' ) && ! isset( $this->accommodation_settings['disable_single'] ) ) { ?> |
|
| 188 | - <li><input class="content" checked="<?php $this->checked( $this->accommodation_options,'banner_image' ); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e( 'Set Banner Image', 'wetu-importer' ); ?></li> |
|
| 186 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'featured_image'); ?>" type="checkbox" name="content[]" value="featured_image" /> <?php esc_html_e('Set Featured Image', 'wetu-importer'); ?></li> |
|
| 187 | + <?php if (class_exists('LSX_Banners') && !isset($this->accommodation_settings['disable_single'])) { ?> |
|
| 188 | + <li><input class="content" checked="<?php $this->checked($this->accommodation_options, 'banner_image'); ?>" type="checkbox" name="content[]" value="banner_image" /> <?php esc_html_e('Set Banner Image', 'wetu-importer'); ?></li> |
|
| 189 | 189 | <?php } ?> |
| 190 | 190 | </ul> |
| 191 | 191 | </div> |
| 192 | 192 | <div style="width:30%;display:block;float:left;"> |
| 193 | - <h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3> |
|
| 194 | - <?php $this->team_member_checkboxes( $this->accommodation_options ); ?> |
|
| 193 | + <h3><?php esc_html_e('Assign a Team Member'); ?></h3> |
|
| 194 | + <?php $this->team_member_checkboxes($this->accommodation_options); ?> |
|
| 195 | 195 | </div> |
| 196 | 196 | |
| 197 | 197 | <div style="width:30%;display:block;float:left;"> |
| 198 | - <h3><?php esc_html_e( 'Assign a Safari Brand' ); ?></h3> |
|
| 198 | + <h3><?php esc_html_e('Assign a Safari Brand'); ?></h3> |
|
| 199 | 199 | <?php |
| 200 | 200 | // @codingStandardsIgnoreLine |
| 201 | - echo $this->taxonomy_checkboxes( 'accommodation-brand', $this->accommodation_options ); |
|
| 201 | + echo $this->taxonomy_checkboxes('accommodation-brand', $this->accommodation_options); |
|
| 202 | 202 | ?> |
| 203 | 203 | </div> |
| 204 | 204 | |
| 205 | 205 | <br clear="both" /> |
| 206 | 206 | </div> |
| 207 | 207 | |
| 208 | - <h3><?php esc_html_e( 'Your List' ); ?></h3> |
|
| 209 | - <p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'wetu-importer' ); ?>" /></p> |
|
| 208 | + <h3><?php esc_html_e('Your List'); ?></h3> |
|
| 209 | + <p><input class="button button-primary" type="submit" value="<?php esc_attr_e('Sync', 'wetu-importer'); ?>" /></p> |
|
| 210 | 210 | <table class="wp-list-table widefat fixed posts"> |
| 211 | 211 | <?php $this->table_header(); ?> |
| 212 | 212 | |
@@ -218,12 +218,12 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | </table> |
| 220 | 220 | |
| 221 | - <p><input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Sync', 'wetu-importer' ); ?>" /></p> |
|
| 221 | + <p><input class="button button-primary" type="submit" value="<?php esc_attr_e('Sync', 'wetu-importer'); ?>" /></p> |
|
| 222 | 222 | </form> |
| 223 | 223 | </div> |
| 224 | 224 | |
| 225 | 225 | <div style="display:none;" class="completed-list-wrapper"> |
| 226 | - <h3><?php esc_html_e( 'Completed' ); ?> - <small><?php esc_html_e( 'Import your', 'wetu-importer' ); ?> <a href="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->plugin_slug ); ?>&tab=destination"><?php esc_html_e( 'destinations' ); ?></a> <?php esc_html_e( 'next', 'wetu-importer' ); ?></small></h3> |
|
| 226 | + <h3><?php esc_html_e('Completed'); ?> - <small><?php esc_html_e('Import your', 'wetu-importer'); ?> <a href="<?php echo esc_url(admin_url('admin.php')); ?>?page=<?php echo esc_attr($this->plugin_slug); ?>&tab=destination"><?php esc_html_e('destinations'); ?></a> <?php esc_html_e('next', 'wetu-importer'); ?></small></h3> |
|
| 227 | 227 | <ul> |
| 228 | 228 | </ul> |
| 229 | 229 | </div> |
@@ -235,11 +235,11 @@ discard block |
||
| 235 | 235 | * search_form |
| 236 | 236 | */ |
| 237 | 237 | public function update_options_form() { |
| 238 | - echo '<div style="display:none;" class="wetu-status"><h3>' . esc_html__( 'Wetu Status', 'wetu-importer' ) . '</h3>'; |
|
| 238 | + echo '<div style="display:none;" class="wetu-status"><h3>'.esc_html__('Wetu Status', 'wetu-importer').'</h3>'; |
|
| 239 | 239 | |
| 240 | - $accommodation = get_transient( 'lsx_ti_accommodation' ); |
|
| 240 | + $accommodation = get_transient('lsx_ti_accommodation'); |
|
| 241 | 241 | |
| 242 | - if ( '' === $accommodation || false === $accommodation || isset( $_GET['refresh_accommodation'] ) ) { |
|
| 242 | + if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) { |
|
| 243 | 243 | $this->update_options(); |
| 244 | 244 | } |
| 245 | 245 | |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | * Save the list of Accommodation into an option |
| 251 | 251 | */ |
| 252 | 252 | public function update_options() { |
| 253 | - $data = file_get_contents( $this->url . '/List?' . $this->url_qs ); |
|
| 253 | + $data = file_get_contents($this->url.'/List?'.$this->url_qs); |
|
| 254 | 254 | |
| 255 | - $accommodation = json_decode( $data, true ); |
|
| 255 | + $accommodation = json_decode($data, true); |
|
| 256 | 256 | |
| 257 | - if ( isset( $accommodation['error'] ) ) { |
|
| 257 | + if (isset($accommodation['error'])) { |
|
| 258 | 258 | return $accommodation['error']; |
| 259 | - } elseif ( isset( $accommodation ) && ! empty( $accommodation ) ) { |
|
| 260 | - set_transient( 'lsx_ti_accommodation',$accommodation,60 * 60 * 2 ); |
|
| 259 | + } elseif (isset($accommodation) && !empty($accommodation)) { |
|
| 260 | + set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2); |
|
| 261 | 261 | return true; |
| 262 | 262 | } |
| 263 | 263 | } |
@@ -269,104 +269,104 @@ discard block |
||
| 269 | 269 | $return = false; |
| 270 | 270 | |
| 271 | 271 | // @codingStandardsIgnoreLine |
| 272 | - if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_tour_importer' && isset( $_POST['type'] ) && $_POST['type'] === 'accommodation' ) { |
|
| 273 | - $accommodation = get_transient( 'lsx_ti_accommodation' ); |
|
| 272 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'accommodation') { |
|
| 273 | + $accommodation = get_transient('lsx_ti_accommodation'); |
|
| 274 | 274 | |
| 275 | - if ( false === $accommodation ) { |
|
| 275 | + if (false === $accommodation) { |
|
| 276 | 276 | $this->update_options(); |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - if ( false !== $accommodation ) { |
|
| 279 | + if (false !== $accommodation) { |
|
| 280 | 280 | $searched_items = false; |
| 281 | 281 | |
| 282 | 282 | // @codingStandardsIgnoreLine |
| 283 | - if ( isset( $_POST['keyword'] ) ) { |
|
| 283 | + if (isset($_POST['keyword'])) { |
|
| 284 | 284 | // @codingStandardsIgnoreLine |
| 285 | 285 | $keyphrases = $_POST['keyword']; |
| 286 | - } else { |
|
| 287 | - $keyphrases = array( 0 ); |
|
| 286 | + }else { |
|
| 287 | + $keyphrases = array(0); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | - if ( ! is_array( $keyphrases ) ) { |
|
| 291 | - $keyphrases = array( $keyphrases ); |
|
| 290 | + if (!is_array($keyphrases)) { |
|
| 291 | + $keyphrases = array($keyphrases); |
|
| 292 | 292 | } |
| 293 | - foreach ( $keyphrases as &$keyword ) { |
|
| 294 | - $keyword = ltrim( rtrim( $keyword ) ); |
|
| 293 | + foreach ($keyphrases as &$keyword) { |
|
| 294 | + $keyword = ltrim(rtrim($keyword)); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | $post_status = false; |
| 298 | 298 | |
| 299 | - if ( in_array( 'publish',$keyphrases ) ) { |
|
| 299 | + if (in_array('publish', $keyphrases)) { |
|
| 300 | 300 | $post_status = 'publish'; |
| 301 | 301 | } |
| 302 | - if ( in_array( 'pending',$keyphrases ) ) { |
|
| 302 | + if (in_array('pending', $keyphrases)) { |
|
| 303 | 303 | $post_status = 'pending'; |
| 304 | 304 | } |
| 305 | - if ( in_array( 'draft',$keyphrases ) ) { |
|
| 305 | + if (in_array('draft', $keyphrases)) { |
|
| 306 | 306 | $post_status = 'draft'; |
| 307 | 307 | } |
| 308 | - if ( in_array( 'import',$keyphrases ) ) { |
|
| 308 | + if (in_array('import', $keyphrases)) { |
|
| 309 | 309 | $post_status = 'import'; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - if ( ! empty( $accommodation ) ) { |
|
| 312 | + if (!empty($accommodation)) { |
|
| 313 | 313 | $current_accommodation = $this->find_current_accommodation(); |
| 314 | 314 | |
| 315 | - foreach ( $accommodation as $row_key => $row ) { |
|
| 315 | + foreach ($accommodation as $row_key => $row) { |
|
| 316 | 316 | //If this is a current tour, add its ID to the row. |
| 317 | 317 | $row['post_id'] = 0; |
| 318 | 318 | |
| 319 | - if ( false !== $current_accommodation && array_key_exists( $row['id'], $current_accommodation ) ) { |
|
| 320 | - $row['post_id'] = $current_accommodation[ $row['id'] ]->post_id; |
|
| 319 | + if (false !== $current_accommodation && array_key_exists($row['id'], $current_accommodation)) { |
|
| 320 | + $row['post_id'] = $current_accommodation[$row['id']]->post_id; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | //If we are searching for |
| 324 | - if ( false !== $post_status ) { |
|
| 325 | - if ( 'import' === $post_status ) { |
|
| 324 | + if (false !== $post_status) { |
|
| 325 | + if ('import' === $post_status) { |
|
| 326 | 326 | |
| 327 | - if ( is_array( $this->queued_imports ) && in_array( $row['post_id'],$this->queued_imports ) ) { |
|
| 328 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
|
| 329 | - } else { |
|
| 327 | + if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) { |
|
| 328 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
|
| 329 | + }else { |
|
| 330 | 330 | continue; |
| 331 | 331 | } |
| 332 | - } else { |
|
| 333 | - if ( 0 === $row['post_id'] ) { |
|
| 332 | + }else { |
|
| 333 | + if (0 === $row['post_id']) { |
|
| 334 | 334 | continue; |
| 335 | - } else { |
|
| 336 | - $current_status = get_post_status( $row['post_id'] ); |
|
| 335 | + }else { |
|
| 336 | + $current_status = get_post_status($row['post_id']); |
|
| 337 | 337 | |
| 338 | - if ( $current_status !== $post_status ) { |
|
| 338 | + if ($current_status !== $post_status) { |
|
| 339 | 339 | continue; |
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
|
| 343 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
|
| 344 | 344 | } |
| 345 | - } else { |
|
| 345 | + }else { |
|
| 346 | 346 | //Search through each keyword. |
| 347 | - foreach ( $keyphrases as $keyphrase ) { |
|
| 347 | + foreach ($keyphrases as $keyphrase) { |
|
| 348 | 348 | //Make sure the keyphrase is turned into an array |
| 349 | - $keywords = explode( ' ',$keyphrase ); |
|
| 349 | + $keywords = explode(' ', $keyphrase); |
|
| 350 | 350 | |
| 351 | - if ( ! is_array( $keywords ) ) { |
|
| 352 | - $keywords = array( $keywords ); |
|
| 351 | + if (!is_array($keywords)) { |
|
| 352 | + $keywords = array($keywords); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - if ( $this->multineedle_stripos( ltrim( rtrim( $row['name'] ) ), $keywords ) !== false ) { |
|
| 356 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
|
| 355 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
| 356 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
|
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - if ( false !== $searched_items ) { |
|
| 364 | - ksort( $searched_items ); |
|
| 365 | - $return = implode( $searched_items ); |
|
| 363 | + if (false !== $searched_items) { |
|
| 364 | + ksort($searched_items); |
|
| 365 | + $return = implode($searched_items); |
|
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - print_r( $return ); |
|
| 369 | + print_r($return); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | die(); |
@@ -375,28 +375,28 @@ discard block |
||
| 375 | 375 | /** |
| 376 | 376 | * Formats the row for output on the screen. |
| 377 | 377 | */ |
| 378 | - public function format_row( $row = false ) { |
|
| 379 | - if ( false !== $row ) { |
|
| 378 | + public function format_row($row = false) { |
|
| 379 | + if (false !== $row) { |
|
| 380 | 380 | |
| 381 | 381 | $status = 'import'; |
| 382 | - if ( 0 !== $row['post_id'] ) { |
|
| 383 | - $status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>'; |
|
| 382 | + if (0 !== $row['post_id']) { |
|
| 383 | + $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | $row_html = ' |
| 387 | - <tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '"> |
|
| 387 | + <tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'"> |
|
| 388 | 388 | <th class="check-column" scope="row"> |
| 389 | - <label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label> |
|
| 390 | - <input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '"> |
|
| 389 | + <label for="cb-select-' . $row['id'].'" class="screen-reader-text">'.$row['name'].'</label> |
|
| 390 | + <input type="checkbox" data-identifier="' . $row['id'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['id'].'"> |
|
| 391 | 391 | </th> |
| 392 | 392 | <td class="post-title page-title column-title"> |
| 393 | - <strong>' . $row['name'] . '</strong> - ' . $status . ' |
|
| 393 | + <strong>' . $row['name'].'</strong> - '.$status.' |
|
| 394 | 394 | </td> |
| 395 | 395 | <td class="date column-date"> |
| 396 | - <abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified |
|
| 396 | + <abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
| 397 | 397 | </td> |
| 398 | 398 | <td class="ssid column-ssid"> |
| 399 | - ' . $row['id'] . ' |
|
| 399 | + ' . $row['id'].' |
|
| 400 | 400 | </td> |
| 401 | 401 | </tr>'; |
| 402 | 402 | return $row_html; |
@@ -406,14 +406,14 @@ discard block |
||
| 406 | 406 | /** |
| 407 | 407 | * Saves the queue to the option. |
| 408 | 408 | */ |
| 409 | - public function remove_from_queue( $id ) { |
|
| 410 | - if ( ! empty( $this->queued_imports ) ) { |
|
| 409 | + public function remove_from_queue($id) { |
|
| 410 | + if (!empty($this->queued_imports)) { |
|
| 411 | 411 | // @codingStandardsIgnoreLine |
| 412 | - if ( ( $key = array_search( $id, $this->queued_imports ) ) !== false ) { |
|
| 413 | - unset( $this->queued_imports[ $key ] ); |
|
| 412 | + if (($key = array_search($id, $this->queued_imports)) !== false) { |
|
| 413 | + unset($this->queued_imports[$key]); |
|
| 414 | 414 | |
| 415 | - delete_option( 'wetu_importer_que' ); |
|
| 416 | - update_option( 'wetu_importer_que',$this->queued_imports ); |
|
| 415 | + delete_option('wetu_importer_que'); |
|
| 416 | + update_option('wetu_importer_que', $this->queued_imports); |
|
| 417 | 417 | } |
| 418 | 418 | } |
| 419 | 419 | } |
@@ -425,59 +425,59 @@ discard block |
||
| 425 | 425 | $return = false; |
| 426 | 426 | |
| 427 | 427 | // @codingStandardsIgnoreLine |
| 428 | - if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === 'accommodation' && isset( $_POST['wetu_id'] ) ) { |
|
| 428 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'accommodation' && isset($_POST['wetu_id'])) { |
|
| 429 | 429 | // @codingStandardsIgnoreLine |
| 430 | 430 | $wetu_id = $_POST['wetu_id']; |
| 431 | 431 | |
| 432 | 432 | // @codingStandardsIgnoreLine |
| 433 | - if ( isset( $_POST['post_id'] ) ) { |
|
| 433 | + if (isset($_POST['post_id'])) { |
|
| 434 | 434 | // @codingStandardsIgnoreLine |
| 435 | 435 | $post_id = $_POST['post_id']; |
| 436 | - } else { |
|
| 436 | + }else { |
|
| 437 | 437 | $post_id = 0; |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | // @codingStandardsIgnoreLine |
| 441 | - if ( isset( $_POST['team_members'] ) ) { |
|
| 441 | + if (isset($_POST['team_members'])) { |
|
| 442 | 442 | // @codingStandardsIgnoreLine |
| 443 | 443 | $team_members = $_POST['team_members']; |
| 444 | - } else { |
|
| 444 | + }else { |
|
| 445 | 445 | $team_members = false; |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | // @codingStandardsIgnoreLine |
| 449 | - if ( isset( $_POST['safari_brands'] ) ) { |
|
| 449 | + if (isset($_POST['safari_brands'])) { |
|
| 450 | 450 | // @codingStandardsIgnoreLine |
| 451 | 451 | $safari_brands = $_POST['safari_brands']; |
| 452 | - } else { |
|
| 452 | + }else { |
|
| 453 | 453 | $safari_brands = false; |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - delete_option( 'wetu_importer_accommodation_settings' ); |
|
| 456 | + delete_option('wetu_importer_accommodation_settings'); |
|
| 457 | 457 | |
| 458 | 458 | // @codingStandardsIgnoreLine |
| 459 | - if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) { |
|
| 459 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
| 460 | 460 | // @codingStandardsIgnoreLine |
| 461 | 461 | $content = $_POST['content']; |
| 462 | - add_option( 'wetu_importer_accommodation_settings',$content ); |
|
| 463 | - } else { |
|
| 462 | + add_option('wetu_importer_accommodation_settings', $content); |
|
| 463 | + }else { |
|
| 464 | 464 | $content = false; |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
| 467 | + $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id); |
|
| 468 | 468 | |
| 469 | - if ( $jdata ) { |
|
| 470 | - $adata = json_decode( $jdata,true ); |
|
| 471 | - if ( ! empty( $adata ) && ! isset( $adata['error'] ) ) { |
|
| 472 | - $return = $this->import_row( $adata,$wetu_id,$post_id,$team_members,$content,$safari_brands ); |
|
| 473 | - $this->format_completed_row( $return ); |
|
| 474 | - $this->remove_from_queue( $return ); |
|
| 469 | + if ($jdata) { |
|
| 470 | + $adata = json_decode($jdata, true); |
|
| 471 | + if (!empty($adata) && !isset($adata['error'])) { |
|
| 472 | + $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
|
| 473 | + $this->format_completed_row($return); |
|
| 474 | + $this->remove_from_queue($return); |
|
| 475 | 475 | $this->cleanup_posts(); |
| 476 | - } else { |
|
| 477 | - if ( isset( $adata['error'] ) ) { |
|
| 478 | - $this->format_error( $adata['error'] ); |
|
| 479 | - } else { |
|
| 480 | - $this->format_error( esc_html__( 'There was a problem importing your accommodation, please try refreshing the page.', 'wetu-importer' ) ); |
|
| 476 | + }else { |
|
| 477 | + if (isset($adata['error'])) { |
|
| 478 | + $this->format_error($adata['error']); |
|
| 479 | + }else { |
|
| 480 | + $this->format_error(esc_html__('There was a problem importing your accommodation, please try refreshing the page.', 'wetu-importer')); |
|
| 481 | 481 | } |
| 482 | 482 | } |
| 483 | 483 | } |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | /** |
| 488 | 488 | * Connect to wetu |
| 489 | 489 | */ |
| 490 | - public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false ) { |
|
| 490 | + public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false) { |
|
| 491 | 491 | $post_name = ''; |
| 492 | 492 | $data_post_content = ''; |
| 493 | 493 | $data_post_excerpt = ''; |
@@ -499,139 +499,139 @@ discard block |
||
| 499 | 499 | $content_used_general_description = false; |
| 500 | 500 | |
| 501 | 501 | //Set the post_content |
| 502 | - if ( false !== $importable_content && in_array( 'description',$importable_content ) ) { |
|
| 503 | - if ( isset( $data[0]['content']['extended_description'] ) ) { |
|
| 502 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
| 503 | + if (isset($data[0]['content']['extended_description'])) { |
|
| 504 | 504 | $data_post_content = $data[0]['content']['extended_description']; |
| 505 | - } elseif ( isset( $data[0]['content']['general_description'] ) ) { |
|
| 505 | + } elseif (isset($data[0]['content']['general_description'])) { |
|
| 506 | 506 | $data_post_content = $data[0]['content']['general_description']; |
| 507 | 507 | $content_used_general_description = true; |
| 508 | - } elseif ( isset( $data[0]['content']['teaser_description'] ) ) { |
|
| 508 | + } elseif (isset($data[0]['content']['teaser_description'])) { |
|
| 509 | 509 | $data_post_content = $data[0]['content']['teaser_description']; |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | - $post['post_content'] = wp_strip_all_tags( $data_post_content ); |
|
| 512 | + $post['post_content'] = wp_strip_all_tags($data_post_content); |
|
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | //set the post_excerpt |
| 516 | - if ( false !== $importable_content && in_array( 'excerpt',$importable_content ) ) { |
|
| 517 | - if ( isset( $data[0]['content']['teaser_description'] ) ) { |
|
| 516 | + if (false !== $importable_content && in_array('excerpt', $importable_content)) { |
|
| 517 | + if (isset($data[0]['content']['teaser_description'])) { |
|
| 518 | 518 | $data_post_excerpt = $data[0]['content']['teaser_description']; |
| 519 | - } elseif ( isset( $data[0]['content']['general_description'] ) && false === $content_used_general_description ) { |
|
| 519 | + } elseif (isset($data[0]['content']['general_description']) && false === $content_used_general_description) { |
|
| 520 | 520 | $data_post_excerpt = $data[0]['content']['general_description']; |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | $post['post_excerpt'] = $data_post_excerpt; |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - if ( false !== $id && '0' !== $id ) { |
|
| 526 | + if (false !== $id && '0' !== $id) { |
|
| 527 | 527 | $post['ID'] = $id; |
| 528 | 528 | |
| 529 | - if ( isset( $data[0]['name'] ) ) { |
|
| 529 | + if (isset($data[0]['name'])) { |
|
| 530 | 530 | $post['post_title'] = $data[0]['name']; |
| 531 | 531 | $post['post_status'] = 'publish'; |
| 532 | - $post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ),$id, 'draft', 'accommodation', 0 ); |
|
| 532 | + $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0); |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - $id = wp_update_post( $post ); |
|
| 536 | - $prev_date = get_post_meta( $id,'lsx_wetu_modified_date', true ); |
|
| 537 | - update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date ); |
|
| 538 | - } else { |
|
| 535 | + $id = wp_update_post($post); |
|
| 536 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
| 537 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date); |
|
| 538 | + }else { |
|
| 539 | 539 | //Set the name |
| 540 | - if ( isset( $data[0]['name'] ) ) { |
|
| 541 | - $post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ),$id, 'draft', 'accommodation', 0 ); |
|
| 540 | + if (isset($data[0]['name'])) { |
|
| 541 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'accommodation', 0); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | $post['post_name'] = $post_name; |
| 545 | 545 | $post['post_title'] = $data[0]['name']; |
| 546 | 546 | $post['post_status'] = 'publish'; |
| 547 | - $id = wp_insert_post( $post ); |
|
| 547 | + $id = wp_insert_post($post); |
|
| 548 | 548 | |
| 549 | 549 | //Save the WETU ID and the Last date it was modified. |
| 550 | - if ( false !== $id ) { |
|
| 551 | - add_post_meta( $id,'lsx_wetu_id',$wetu_id ); |
|
| 552 | - add_post_meta( $id,'lsx_wetu_modified_date',strtotime( $data[0]['last_modified'] ) ); |
|
| 550 | + if (false !== $id) { |
|
| 551 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
| 552 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified'])); |
|
| 553 | 553 | } |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | //Setup some default for use in the import |
| 557 | - if ( false !== $importable_content && (in_array( 'gallery',$importable_content ) || in_array( 'banner_image',$importable_content ) || in_array( 'featured_image',$importable_content )) ) { |
|
| 558 | - $this->find_attachments( $id ); |
|
| 557 | + if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) { |
|
| 558 | + $this->find_attachments($id); |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | //Set the team member if it is there |
| 562 | - if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) { |
|
| 563 | - $this->set_team_member( $id,$team_members ); |
|
| 562 | + if (post_type_exists('team') && false !== $team_members && '' !== $team_members) { |
|
| 563 | + $this->set_team_member($id, $team_members); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | //Set the safari brand |
| 567 | - if ( false !== $safari_brands && '' !== $safari_brands ) { |
|
| 568 | - $this->set_safari_brands( $id,$safari_brands ); |
|
| 567 | + if (false !== $safari_brands && '' !== $safari_brands) { |
|
| 568 | + $this->set_safari_brands($id, $safari_brands); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - if ( class_exists( 'LSX_TO_Maps' ) ) { |
|
| 572 | - $this->set_map_data( $data,$id,9 ); |
|
| 571 | + if (class_exists('LSX_TO_Maps')) { |
|
| 572 | + $this->set_map_data($data, $id, 9); |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - if ( post_type_exists( 'destination' ) && false !== $importable_content && in_array( 'destination',$importable_content ) ) { |
|
| 576 | - $this->connect_destinations( $data,$id ); |
|
| 575 | + if (post_type_exists('destination') && false !== $importable_content && in_array('destination', $importable_content)) { |
|
| 576 | + $this->connect_destinations($data, $id); |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - if ( false !== $importable_content && in_array( 'category',$importable_content ) ) { |
|
| 580 | - $this->set_taxonomy_style( $data,$id ); |
|
| 579 | + if (false !== $importable_content && in_array('category', $importable_content)) { |
|
| 580 | + $this->set_taxonomy_style($data, $id); |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | //Set the Room Data |
| 584 | - if ( false !== $importable_content && in_array( 'rooms',$importable_content ) ) { |
|
| 585 | - $this->set_room_data( $data,$id ); |
|
| 584 | + if (false !== $importable_content && in_array('rooms', $importable_content)) { |
|
| 585 | + $this->set_room_data($data, $id); |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | //Set the rating |
| 589 | - if ( false !== $importable_content && in_array( 'rating',$importable_content ) ) { |
|
| 590 | - $this->set_rating( $data,$id ); |
|
| 589 | + if (false !== $importable_content && in_array('rating', $importable_content)) { |
|
| 590 | + $this->set_rating($data, $id); |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | //Set the checkin checkout data |
| 594 | - if ( false !== $importable_content && in_array( 'checkin',$importable_content ) ) { |
|
| 595 | - $this->set_checkin_checkout( $data,$id ); |
|
| 594 | + if (false !== $importable_content && in_array('checkin', $importable_content)) { |
|
| 595 | + $this->set_checkin_checkout($data, $id); |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | //Set the Spoken Languages |
| 599 | - if ( false !== $importable_content && in_array( 'spoken_languages',$importable_content ) ) { |
|
| 600 | - $this->set_spoken_languages( $data,$id ); |
|
| 599 | + if (false !== $importable_content && in_array('spoken_languages', $importable_content)) { |
|
| 600 | + $this->set_spoken_languages($data, $id); |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | //Set the friendly options |
| 604 | - if ( false !== $importable_content && in_array( 'friendly',$importable_content ) ) { |
|
| 605 | - $this->set_friendly( $data,$id ); |
|
| 604 | + if (false !== $importable_content && in_array('friendly', $importable_content)) { |
|
| 605 | + $this->set_friendly($data, $id); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | //Set the special_interests |
| 609 | - if ( false !== $importable_content && in_array( 'special_interests',$importable_content ) ) { |
|
| 610 | - $this->set_special_interests( $data,$id ); |
|
| 609 | + if (false !== $importable_content && in_array('special_interests', $importable_content)) { |
|
| 610 | + $this->set_special_interests($data, $id); |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | //Import the videos |
| 614 | - if ( false !== $importable_content && in_array( 'videos',$importable_content ) ) { |
|
| 615 | - $this->set_video_data( $data,$id ); |
|
| 614 | + if (false !== $importable_content && in_array('videos', $importable_content)) { |
|
| 615 | + $this->set_video_data($data, $id); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | //Import the facilities |
| 619 | - if ( false !== $importable_content && in_array( 'facilities',$importable_content ) ) { |
|
| 620 | - $this->set_facilities( $data,$id ); |
|
| 619 | + if (false !== $importable_content && in_array('facilities', $importable_content)) { |
|
| 620 | + $this->set_facilities($data, $id); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | //Set the featured image |
| 624 | - if ( false !== $importable_content && in_array( 'featured_image',$importable_content ) ) { |
|
| 625 | - $this->set_featured_image( $data,$id ); |
|
| 624 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
| 625 | + $this->set_featured_image($data, $id); |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | - if ( false !== $importable_content && in_array( 'banner_image',$importable_content ) ) { |
|
| 629 | - $this->set_banner_image( $data,$id ); |
|
| 628 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
| 629 | + $this->set_banner_image($data, $id); |
|
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | //Import the main gallery |
| 633 | - if ( false !== $importable_content && in_array( 'gallery',$importable_content ) ) { |
|
| 634 | - $this->create_main_gallery( $data,$id ); |
|
| 633 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
| 634 | + $this->create_main_gallery($data, $id); |
|
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | return $id; |
@@ -640,58 +640,58 @@ discard block |
||
| 640 | 640 | /** |
| 641 | 641 | * Set the team memberon each item. |
| 642 | 642 | */ |
| 643 | - public function set_team_member( $id, $team_members ) { |
|
| 644 | - delete_post_meta( $id, 'team_to_' . $this->tab_slug ); |
|
| 643 | + public function set_team_member($id, $team_members) { |
|
| 644 | + delete_post_meta($id, 'team_to_'.$this->tab_slug); |
|
| 645 | 645 | |
| 646 | - foreach ( $team_members as $team ) { |
|
| 647 | - add_post_meta( $id,'team_to_' . $this->tab_slug,$team ); |
|
| 646 | + foreach ($team_members as $team) { |
|
| 647 | + add_post_meta($id, 'team_to_'.$this->tab_slug, $team); |
|
| 648 | 648 | } |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | /** |
| 652 | 652 | * Set the safari brand |
| 653 | 653 | */ |
| 654 | - public function set_safari_brands( $id, $safari_brands ) { |
|
| 655 | - foreach ( $safari_brands as $safari_brand ) { |
|
| 656 | - wp_set_object_terms( $id, intval( $safari_brand ), 'accommodation-brand',true ); |
|
| 654 | + public function set_safari_brands($id, $safari_brands) { |
|
| 655 | + foreach ($safari_brands as $safari_brand) { |
|
| 656 | + wp_set_object_terms($id, intval($safari_brand), 'accommodation-brand', true); |
|
| 657 | 657 | } |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | /** |
| 661 | 661 | * Connects the destinations post type |
| 662 | 662 | */ |
| 663 | - public function connect_destinations( $data, $id ) { |
|
| 664 | - if ( isset( $data[0]['position'] ) ) { |
|
| 663 | + public function connect_destinations($data, $id) { |
|
| 664 | + if (isset($data[0]['position'])) { |
|
| 665 | 665 | $destinations = false; |
| 666 | 666 | |
| 667 | - if ( isset( $data[0]['position']['country'] ) ) { |
|
| 667 | + if (isset($data[0]['position']['country'])) { |
|
| 668 | 668 | $destinations['country'] = $data[0]['position']['country']; |
| 669 | 669 | } |
| 670 | 670 | |
| 671 | - if ( isset( $data[0]['position']['destination'] ) ) { |
|
| 671 | + if (isset($data[0]['position']['destination'])) { |
|
| 672 | 672 | $destinations['destination'] = $data[0]['position']['destination']; |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | - if ( false !== $destinations ) { |
|
| 676 | - $prev_values = get_post_meta( $id,'destination_to_accommodation',false ); |
|
| 675 | + if (false !== $destinations) { |
|
| 676 | + $prev_values = get_post_meta($id, 'destination_to_accommodation', false); |
|
| 677 | 677 | |
| 678 | - if ( false === $prev_values || ! is_array( $prev_values ) ) { |
|
| 678 | + if (false === $prev_values || !is_array($prev_values)) { |
|
| 679 | 679 | $prev_values = array(); |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | - delete_post_meta( $id,'destination_to_accommodation',$prev_values ); |
|
| 682 | + delete_post_meta($id, 'destination_to_accommodation', $prev_values); |
|
| 683 | 683 | |
| 684 | 684 | //print_r($destinations); |
| 685 | - $destinations = array_unique( $destinations ); |
|
| 685 | + $destinations = array_unique($destinations); |
|
| 686 | 686 | //print_r($destinations); |
| 687 | 687 | |
| 688 | - foreach ( $destinations as $key => $value ) { |
|
| 689 | - $destination = get_page_by_title( ltrim( rtrim( $value ) ), 'OBJECT', 'destination' ); |
|
| 690 | - if ( null !== $destination ) { |
|
| 691 | - if ( ! in_array( $destination->ID,$prev_values ) ) { |
|
| 692 | - add_post_meta( $id,'destination_to_accommodation',$destination->ID,false ); |
|
| 693 | - add_post_meta( $destination->ID,'accommodation_to_destination',$id,false ); |
|
| 694 | - $this->cleanup_posts[ $destination->ID ] = 'accommodation_to_destination'; |
|
| 688 | + foreach ($destinations as $key => $value) { |
|
| 689 | + $destination = get_page_by_title(ltrim(rtrim($value)), 'OBJECT', 'destination'); |
|
| 690 | + if (null !== $destination) { |
|
| 691 | + if (!in_array($destination->ID, $prev_values)) { |
|
| 692 | + add_post_meta($id, 'destination_to_accommodation', $destination->ID, false); |
|
| 693 | + add_post_meta($destination->ID, 'accommodation_to_destination', $id, false); |
|
| 694 | + $this->cleanup_posts[$destination->ID] = 'accommodation_to_destination'; |
|
| 695 | 695 | } |
| 696 | 696 | } |
| 697 | 697 | } |
@@ -702,50 +702,50 @@ discard block |
||
| 702 | 702 | /** |
| 703 | 703 | * Set the Travel Style |
| 704 | 704 | */ |
| 705 | - public function set_taxonomy_style( $data, $id ) { |
|
| 705 | + public function set_taxonomy_style($data, $id) { |
|
| 706 | 706 | $terms = false; |
| 707 | 707 | |
| 708 | - if ( isset( $data[0]['category'] ) ) { |
|
| 708 | + if (isset($data[0]['category'])) { |
|
| 709 | 709 | // @codingStandardsIgnoreLine |
| 710 | - if ( ! $term = term_exists( trim( $data[0]['category'] ), 'accommodation-type' ) ) { |
|
| 711 | - $term = wp_insert_term( trim( $data[0]['category'] ), 'accommodation-type' ); |
|
| 710 | + if (!$term = term_exists(trim($data[0]['category']), 'accommodation-type')) { |
|
| 711 | + $term = wp_insert_term(trim($data[0]['category']), 'accommodation-type'); |
|
| 712 | 712 | |
| 713 | - if ( is_wp_error( $term ) ) { |
|
| 713 | + if (is_wp_error($term)) { |
|
| 714 | 714 | // @codingStandardsIgnoreLine |
| 715 | 715 | echo $term->get_error_message(); |
| 716 | 716 | } |
| 717 | - } else { |
|
| 718 | - wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type',true ); |
|
| 717 | + }else { |
|
| 718 | + wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true); |
|
| 719 | 719 | } |
| 720 | - } else { |
|
| 721 | - wp_set_object_terms( $id, intval( $term['term_id'] ), 'accommodation-type',true ); |
|
| 720 | + }else { |
|
| 721 | + wp_set_object_terms($id, intval($term['term_id']), 'accommodation-type', true); |
|
| 722 | 722 | } |
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | /** |
| 726 | 726 | * Saves the room data |
| 727 | 727 | */ |
| 728 | - public function set_room_data( $data, $id ) { |
|
| 729 | - if ( ! empty( $data[0]['rooms'] ) && is_array( $data[0]['rooms'] ) ) { |
|
| 728 | + public function set_room_data($data, $id) { |
|
| 729 | + if (!empty($data[0]['rooms']) && is_array($data[0]['rooms'])) { |
|
| 730 | 730 | $rooms = false; |
| 731 | 731 | |
| 732 | - foreach ( $data[0]['rooms'] as $room ) { |
|
| 732 | + foreach ($data[0]['rooms'] as $room) { |
|
| 733 | 733 | $temp_room = array(); |
| 734 | 734 | |
| 735 | - if ( isset( $room['name'] ) ) { |
|
| 735 | + if (isset($room['name'])) { |
|
| 736 | 736 | $temp_room['title'] = $room['name']; |
| 737 | 737 | } |
| 738 | 738 | |
| 739 | - if ( isset( $room['description'] ) ) { |
|
| 740 | - $temp_room['description'] = strip_tags( $room['description'] ); |
|
| 739 | + if (isset($room['description'])) { |
|
| 740 | + $temp_room['description'] = strip_tags($room['description']); |
|
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | $temp_room['price'] = 0; |
| 744 | 744 | $temp_room['type'] = 'room'; |
| 745 | 745 | |
| 746 | - if ( ! empty( $room['images'] ) && is_array( $room['images'] ) ) { |
|
| 746 | + if (!empty($room['images']) && is_array($room['images'])) { |
|
| 747 | 747 | $temp_room['gallery'] = array(); |
| 748 | - $temp_room['gallery'][] = $this->attach_image( $room['images'][0], $id ); |
|
| 748 | + $temp_room['gallery'][] = $this->attach_image($room['images'][0], $id); |
|
| 749 | 749 | |
| 750 | 750 | /*foreach($room['images'] as $image_data){ |
| 751 | 751 | $temp_room['gallery'][] = $this->attach_image($image_data,$id); |
@@ -755,25 +755,25 @@ discard block |
||
| 755 | 755 | $rooms[] = $temp_room; |
| 756 | 756 | } |
| 757 | 757 | |
| 758 | - if ( false !== $id && '0' !== $id ) { |
|
| 759 | - delete_post_meta( $id, 'units' ); |
|
| 758 | + if (false !== $id && '0' !== $id) { |
|
| 759 | + delete_post_meta($id, 'units'); |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | - foreach ( $rooms as $room ) { |
|
| 763 | - add_post_meta( $id,'units',$room,false ); |
|
| 762 | + foreach ($rooms as $room) { |
|
| 763 | + add_post_meta($id, 'units', $room, false); |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | - if ( isset( $data[0]['features'] ) && isset( $data[0]['features']['rooms'] ) ) { |
|
| 766 | + if (isset($data[0]['features']) && isset($data[0]['features']['rooms'])) { |
|
| 767 | 767 | $room_count = $data[0]['features']['rooms']; |
| 768 | - } else { |
|
| 769 | - $room_count = count( $data[0]['rooms'] ); |
|
| 768 | + }else { |
|
| 769 | + $room_count = count($data[0]['rooms']); |
|
| 770 | 770 | } |
| 771 | 771 | |
| 772 | - if ( false !== $id && '0' !== $id ) { |
|
| 773 | - $prev_rooms = get_post_meta( $id,'number_of_rooms',true ); |
|
| 774 | - update_post_meta( $id,'number_of_rooms',$room_count,$prev_rooms ); |
|
| 775 | - } else { |
|
| 776 | - add_post_meta( $id,'number_of_rooms',$room_count,true ); |
|
| 772 | + if (false !== $id && '0' !== $id) { |
|
| 773 | + $prev_rooms = get_post_meta($id, 'number_of_rooms', true); |
|
| 774 | + update_post_meta($id, 'number_of_rooms', $room_count, $prev_rooms); |
|
| 775 | + }else { |
|
| 776 | + add_post_meta($id, 'number_of_rooms', $room_count, true); |
|
| 777 | 777 | } |
| 778 | 778 | } |
| 779 | 779 | } |
@@ -781,33 +781,33 @@ discard block |
||
| 781 | 781 | /** |
| 782 | 782 | * Set the ratings |
| 783 | 783 | */ |
| 784 | - public function set_rating( $data, $id ) { |
|
| 785 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['star_authority'] ) ) { |
|
| 784 | + public function set_rating($data, $id) { |
|
| 785 | + if (!empty($data[0]['features']) && isset($data[0]['features']['star_authority'])) { |
|
| 786 | 786 | $rating_type = $data[0]['features']['star_authority']; |
| 787 | - } else { |
|
| 787 | + }else { |
|
| 788 | 788 | $rating_type = 'Unspecified2'; |
| 789 | 789 | } |
| 790 | 790 | |
| 791 | - $this->save_custom_field( $rating_type,'rating_type',$id ); |
|
| 791 | + $this->save_custom_field($rating_type, 'rating_type', $id); |
|
| 792 | 792 | |
| 793 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['stars'] ) ) { |
|
| 794 | - $this->save_custom_field( $data[0]['features']['stars'],'rating',$id,true ); |
|
| 793 | + if (!empty($data[0]['features']) && isset($data[0]['features']['stars'])) { |
|
| 794 | + $this->save_custom_field($data[0]['features']['stars'], 'rating', $id, true); |
|
| 795 | 795 | } |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | /** |
| 799 | 799 | * Set the spoken_languages |
| 800 | 800 | */ |
| 801 | - public function set_spoken_languages( $data, $id ) { |
|
| 802 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['spoken_languages'] ) && ! empty( $data[0]['features']['spoken_languages'] ) ) { |
|
| 801 | + public function set_spoken_languages($data, $id) { |
|
| 802 | + if (!empty($data[0]['features']) && isset($data[0]['features']['spoken_languages']) && !empty($data[0]['features']['spoken_languages'])) { |
|
| 803 | 803 | $languages = false; |
| 804 | 804 | |
| 805 | - foreach ( $data[0]['features']['spoken_languages'] as $spoken_language ) { |
|
| 806 | - $languages[] = sanitize_title( $spoken_language ); |
|
| 805 | + foreach ($data[0]['features']['spoken_languages'] as $spoken_language) { |
|
| 806 | + $languages[] = sanitize_title($spoken_language); |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | - if ( false !== $languages ) { |
|
| 810 | - $this->save_custom_field( $languages,'spoken_languages',$id ); |
|
| 809 | + if (false !== $languages) { |
|
| 810 | + $this->save_custom_field($languages, 'spoken_languages', $id); |
|
| 811 | 811 | } |
| 812 | 812 | } |
| 813 | 813 | } |
@@ -815,16 +815,16 @@ discard block |
||
| 815 | 815 | /** |
| 816 | 816 | * Set the friendly |
| 817 | 817 | */ |
| 818 | - public function set_friendly( $data, $id ) { |
|
| 819 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['suggested_visitor_types'] ) && ! empty( $data[0]['features']['suggested_visitor_types'] ) ) { |
|
| 818 | + public function set_friendly($data, $id) { |
|
| 819 | + if (!empty($data[0]['features']) && isset($data[0]['features']['suggested_visitor_types']) && !empty($data[0]['features']['suggested_visitor_types'])) { |
|
| 820 | 820 | $friendly_options = false; |
| 821 | 821 | |
| 822 | - foreach ( $data[0]['features']['suggested_visitor_types'] as $visitor_type ) { |
|
| 823 | - $friendly_options[] = sanitize_title( $visitor_type ); |
|
| 822 | + foreach ($data[0]['features']['suggested_visitor_types'] as $visitor_type) { |
|
| 823 | + $friendly_options[] = sanitize_title($visitor_type); |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | - if ( false !== $friendly_options ) { |
|
| 827 | - $this->save_custom_field( $friendly_options,'suggested_visitor_types',$id ); |
|
| 826 | + if (false !== $friendly_options) { |
|
| 827 | + $this->save_custom_field($friendly_options, 'suggested_visitor_types', $id); |
|
| 828 | 828 | } |
| 829 | 829 | } |
| 830 | 830 | } |
@@ -832,16 +832,16 @@ discard block |
||
| 832 | 832 | /** |
| 833 | 833 | * Set the special interests |
| 834 | 834 | */ |
| 835 | - public function set_special_interests( $data, $id ) { |
|
| 836 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['special_interests'] ) && ! empty( $data[0]['features']['special_interests'] ) ) { |
|
| 835 | + public function set_special_interests($data, $id) { |
|
| 836 | + if (!empty($data[0]['features']) && isset($data[0]['features']['special_interests']) && !empty($data[0]['features']['special_interests'])) { |
|
| 837 | 837 | $interests = false; |
| 838 | 838 | |
| 839 | - foreach ( $data[0]['features']['special_interests'] as $special_interest ) { |
|
| 840 | - $interests[] = sanitize_title( $special_interest ); |
|
| 839 | + foreach ($data[0]['features']['special_interests'] as $special_interest) { |
|
| 840 | + $interests[] = sanitize_title($special_interest); |
|
| 841 | 841 | } |
| 842 | 842 | |
| 843 | - if ( false !== $interests ) { |
|
| 844 | - $this->save_custom_field( $interests,'special_interests',$id ); |
|
| 843 | + if (false !== $interests) { |
|
| 844 | + $this->save_custom_field($interests, 'special_interests', $id); |
|
| 845 | 845 | } |
| 846 | 846 | } |
| 847 | 847 | } |
@@ -849,24 +849,24 @@ discard block |
||
| 849 | 849 | /** |
| 850 | 850 | * Set the Check in and Check out Date |
| 851 | 851 | */ |
| 852 | - public function set_checkin_checkout( $data, $id ) { |
|
| 853 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_in_time'] ) ) { |
|
| 854 | - $time = str_replace( 'h',':',$data[0]['features']['check_in_time'] ); |
|
| 855 | - $time = date( 'h:ia',strtotime( $time ) ); |
|
| 856 | - $this->save_custom_field( $time,'checkin_time',$id ); |
|
| 852 | + public function set_checkin_checkout($data, $id) { |
|
| 853 | + if (!empty($data[0]['features']) && isset($data[0]['features']['check_in_time'])) { |
|
| 854 | + $time = str_replace('h', ':', $data[0]['features']['check_in_time']); |
|
| 855 | + $time = date('h:ia', strtotime($time)); |
|
| 856 | + $this->save_custom_field($time, 'checkin_time', $id); |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | - if ( ! empty( $data[0]['features'] ) && isset( $data[0]['features']['check_out_time'] ) ) { |
|
| 860 | - $time = str_replace( 'h',':',$data[0]['features']['check_out_time'] ); |
|
| 861 | - $time = date( 'h:ia',strtotime( $time ) ); |
|
| 862 | - $this->save_custom_field( $time,'checkout_time',$id ); |
|
| 859 | + if (!empty($data[0]['features']) && isset($data[0]['features']['check_out_time'])) { |
|
| 860 | + $time = str_replace('h', ':', $data[0]['features']['check_out_time']); |
|
| 861 | + $time = date('h:ia', strtotime($time)); |
|
| 862 | + $this->save_custom_field($time, 'checkout_time', $id); |
|
| 863 | 863 | } |
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | /** |
| 867 | 867 | * Set the Facilities |
| 868 | 868 | */ |
| 869 | - public function set_facilities( $data, $id ) { |
|
| 869 | + public function set_facilities($data, $id) { |
|
| 870 | 870 | $parent_facilities = array( |
| 871 | 871 | 'available_services' => 'Available Services', |
| 872 | 872 | 'property_facilities' => 'Property Facilities', |
@@ -874,15 +874,15 @@ discard block |
||
| 874 | 874 | 'activities_on_site' => 'Activities on Site', |
| 875 | 875 | ); |
| 876 | 876 | |
| 877 | - foreach ( $parent_facilities as $key => $label ) { |
|
| 877 | + foreach ($parent_facilities as $key => $label) { |
|
| 878 | 878 | $terms = false; |
| 879 | 879 | |
| 880 | - if ( isset( $data[0]['features'] ) && isset( $data[0]['features'][ $key ] ) ) { |
|
| 881 | - $parent_id = $this->set_term( $id,$label,'facility' ); |
|
| 880 | + if (isset($data[0]['features']) && isset($data[0]['features'][$key])) { |
|
| 881 | + $parent_id = $this->set_term($id, $label, 'facility'); |
|
| 882 | 882 | } |
| 883 | 883 | |
| 884 | - foreach ( $data[0]['features'][ $key ] as $child_facility ) { |
|
| 885 | - $this->set_term( $id,$child_facility,'facility',$parent_id ); |
|
| 884 | + foreach ($data[0]['features'][$key] as $child_facility) { |
|
| 885 | + $this->set_term($id, $child_facility, 'facility', $parent_id); |
|
| 886 | 886 | } |
| 887 | 887 | } |
| 888 | 888 | } |
@@ -232,6 +232,9 @@ |
||
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | + /** |
|
| 236 | + * @param string $url |
|
| 237 | + */ |
|
| 235 | 238 | public function attach_external_image2( $url = null, $post_data = array() ) { |
| 236 | 239 | if ( ! $url ) { return new WP_Error( 'missing', 'Need a valid URL' ); } |
| 237 | 240 | |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | * @access private |
| 27 | 27 | */ |
| 28 | 28 | public function __construct() { |
| 29 | - add_action( 'wp_ajax_lsx_import_sync_banners',array( $this, 'sync_new_banner' ) ); |
|
| 30 | - add_action( 'wp_ajax_nopriv_lsx_import_sync_banners',array( $this, 'sync_new_banner' ) ); |
|
| 29 | + add_action('wp_ajax_lsx_import_sync_banners', array($this, 'sync_new_banner')); |
|
| 30 | + add_action('wp_ajax_nopriv_lsx_import_sync_banners', array($this, 'sync_new_banner')); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | public function display_page() { |
| 37 | 37 | ?> |
| 38 | 38 | <div class="wrap"> |
| 39 | - <h2><?php esc_html_e( 'Download new banners straight from WETU','wetu-importer' ); ?></h2> |
|
| 39 | + <h2><?php esc_html_e('Download new banners straight from WETU', 'wetu-importer'); ?></h2> |
|
| 40 | 40 | |
| 41 | 41 | <form method="get" action="" id="banners-filter"> |
| 42 | - <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" /> |
|
| 42 | + <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" /> |
|
| 43 | 43 | |
| 44 | 44 | <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;"> |
| 45 | - <img style="width:32px;" src="<?php echo esc_url( WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" /> |
|
| 45 | + <img style="width:32px;" src="<?php echo esc_url(WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" /> |
|
| 46 | 46 | </div> |
| 47 | 47 | |
| 48 | 48 | <table class="wp-list-table widefat fixed posts"> |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | <?php |
| 61 | 61 | $accommodation_args = array( |
| 62 | 62 | 'post_type' => 'accommodation', |
| 63 | - 'post_status' => array( 'publish','pending','draft','future','private' ), |
|
| 63 | + 'post_status' => array('publish', 'pending', 'draft', 'future', 'private'), |
|
| 64 | 64 | 'nopagin' => 'true', |
| 65 | 65 | 'posts_per_page' => '1000', |
| 66 | 66 | 'meta_query' => array( |
@@ -80,13 +80,13 @@ discard block |
||
| 80 | 80 | ), |
| 81 | 81 | ), |
| 82 | 82 | ); |
| 83 | - $accommodation = new WP_Query( $accommodation_args ); |
|
| 83 | + $accommodation = new WP_Query($accommodation_args); |
|
| 84 | 84 | ?> |
| 85 | 85 | |
| 86 | 86 | <tbody id="the-list"> |
| 87 | 87 | <?php |
| 88 | - if ( $accommodation->have_posts() ) { |
|
| 89 | - while ( $accommodation->have_posts() ) { |
|
| 88 | + if ($accommodation->have_posts()) { |
|
| 89 | + while ($accommodation->have_posts()) { |
|
| 90 | 90 | $accommodation->the_post(); |
| 91 | 91 | ?> |
| 92 | 92 | <tr class="post-<?php the_ID(); ?> type-tour status-none" id="post-<?php the_ID(); ?>"> |
@@ -95,26 +95,26 @@ discard block |
||
| 95 | 95 | $min_width = '1920'; |
| 96 | 96 | $min_height = '500'; |
| 97 | 97 | |
| 98 | - $img_group = get_post_meta( get_the_ID(),'image_group',true ); |
|
| 98 | + $img_group = get_post_meta(get_the_ID(), 'image_group', true); |
|
| 99 | 99 | |
| 100 | 100 | $thumbnails_html = false; |
| 101 | 101 | |
| 102 | - if ( false !== $img_group ) { |
|
| 103 | - foreach ( $img_group['banner_image'] as $banner_image ) { |
|
| 104 | - $large = wp_get_attachment_image_src( $banner_image,'full' ); |
|
| 102 | + if (false !== $img_group) { |
|
| 103 | + foreach ($img_group['banner_image'] as $banner_image) { |
|
| 104 | + $large = wp_get_attachment_image_src($banner_image, 'full'); |
|
| 105 | 105 | $real_width = $large[1]; |
| 106 | 106 | $real_height = $large[2]; |
| 107 | 107 | |
| 108 | 108 | $status = 'optimized'; |
| 109 | - if ( $real_width < intval( $real_width ) ) { |
|
| 109 | + if ($real_width < intval($real_width)) { |
|
| 110 | 110 | $status = 'width not enough.'; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - $thumbnail = wp_get_attachment_image_src( $banner_image,'thumbnail' ); |
|
| 113 | + $thumbnail = wp_get_attachment_image_src($banner_image, 'thumbnail'); |
|
| 114 | 114 | $thumbnails_html[] = ' |
| 115 | 115 | <div style="display:block;float:left;"> |
| 116 | - <img src="' . $thumbnail[0] . '" /> |
|
| 117 | - <p style="text-align:center;">' . $real_width . 'px by ' . $real_height . 'px</p> |
|
| 116 | + <img src="' . $thumbnail[0].'" /> |
|
| 117 | + <p style="text-align:center;">' . $real_width.'px by '.$real_height.'px</p> |
|
| 118 | 118 | </div>'; |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -124,16 +124,16 @@ discard block |
||
| 124 | 124 | <input type="checkbox" data-identifier="<?php the_ID(); ?>" value="<?php the_ID(); ?>" name="post[]" id="cb-select-<?php the_ID(); ?>"> |
| 125 | 125 | </th> |
| 126 | 126 | |
| 127 | - <td class="post-title page-title column-title"><?php echo '<a href="' . esc_url( admin_url( '/post.php?post=' . get_the_ID() . '&action=edit' ) ) . '" target="_blank">'; |
|
| 127 | + <td class="post-title page-title column-title"><?php echo '<a href="'.esc_url(admin_url('/post.php?post='.get_the_ID().'&action=edit')).'" target="_blank">'; |
|
| 128 | 128 | the_title(); |
| 129 | 129 | echo '</a>'; ?></td> |
| 130 | 130 | |
| 131 | 131 | <td colspan="2" class="thumbnails column-thumbnails"> |
| 132 | 132 | <?php |
| 133 | - if ( false !== $thumbnails_html ) { |
|
| 133 | + if (false !== $thumbnails_html) { |
|
| 134 | 134 | // @codingStandardsIgnoreLine |
| 135 | - echo implode( '', $thumbnails_html ); |
|
| 136 | - } else { |
|
| 135 | + echo implode('', $thumbnails_html); |
|
| 136 | + }else { |
|
| 137 | 137 | echo '<p>There was an error retrieving your images.</p>'; |
| 138 | 138 | } |
| 139 | 139 | ?> |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | </table> |
| 159 | 159 | |
| 160 | - <p><input class="button button-primary download" type="button" value="<?php esc_html_e( 'Download new Banners','wetu-importer' ); ?>" /> |
|
| 160 | + <p><input class="button button-primary download" type="button" value="<?php esc_html_e('Download new Banners', 'wetu-importer'); ?>" /> |
|
| 161 | 161 | </p> |
| 162 | 162 | </form> |
| 163 | 163 | </div> |
@@ -169,33 +169,33 @@ discard block |
||
| 169 | 169 | */ |
| 170 | 170 | public function sync_new_banner() { |
| 171 | 171 | // @codingStandardsIgnoreLine |
| 172 | - if ( isset( $_POST['action'] ) && 'lsx_import_sync_banners' === $_POST['action'] && isset( $_POST['post_id'] ) ) { |
|
| 172 | + if (isset($_POST['action']) && 'lsx_import_sync_banners' === $_POST['action'] && isset($_POST['post_id'])) { |
|
| 173 | 173 | // @codingStandardsIgnoreLine |
| 174 | - $banners = get_post_meta( $_POST['post_id'],'image_group',true ); |
|
| 174 | + $banners = get_post_meta($_POST['post_id'], 'image_group', true); |
|
| 175 | 175 | // @codingStandardsIgnoreLine |
| 176 | - $this->wetu_id = get_post_meta( $_POST['post_id'],'lsx_wetu_id',true ); |
|
| 176 | + $this->wetu_id = get_post_meta($_POST['post_id'], 'lsx_wetu_id', true); |
|
| 177 | 177 | |
| 178 | 178 | $new_banner_array = false; |
| 179 | 179 | $array_index = 0; |
| 180 | 180 | |
| 181 | - foreach ( $banners['banner_image'] as $banner_image ) { |
|
| 182 | - $image_id = $this->attach_external_image2( $this->format_wetu_url( $banner_image ) ); |
|
| 183 | - if ( null !== $image_id && '' !== $image_id ) { |
|
| 184 | - $new_banner_array['banner_image'][ 'cmb-field-' . $array_index ] = $image_id; |
|
| 181 | + foreach ($banners['banner_image'] as $banner_image) { |
|
| 182 | + $image_id = $this->attach_external_image2($this->format_wetu_url($banner_image)); |
|
| 183 | + if (null !== $image_id && '' !== $image_id) { |
|
| 184 | + $new_banner_array['banner_image']['cmb-field-'.$array_index] = $image_id; |
|
| 185 | 185 | $array_index++; |
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if ( false !== $new_banner_array ) { |
|
| 189 | + if (false !== $new_banner_array) { |
|
| 190 | 190 | // @codingStandardsIgnoreLine |
| 191 | - delete_post_meta( $_POST['post_id'],'image_group' ); |
|
| 191 | + delete_post_meta($_POST['post_id'], 'image_group'); |
|
| 192 | 192 | // @codingStandardsIgnoreLine |
| 193 | - add_post_meta( $_POST['post_id'],'image_group',$new_banner_array,true ); |
|
| 193 | + add_post_meta($_POST['post_id'], 'image_group', $new_banner_array, true); |
|
| 194 | 194 | echo true; |
| 195 | - } else { |
|
| 195 | + }else { |
|
| 196 | 196 | echo false; |
| 197 | 197 | } |
| 198 | - } else { |
|
| 198 | + }else { |
|
| 199 | 199 | echo false; |
| 200 | 200 | } |
| 201 | 201 | |
@@ -205,71 +205,71 @@ discard block |
||
| 205 | 205 | /** |
| 206 | 206 | * formats the url |
| 207 | 207 | */ |
| 208 | - public function format_wetu_url( $post_id ) { |
|
| 209 | - return 'https://wetu.com/ImageHandler/c1920x800/' . $this->wetu_id . '/' . $this->format_filename( $post_id ); |
|
| 208 | + public function format_wetu_url($post_id) { |
|
| 209 | + return 'https://wetu.com/ImageHandler/c1920x800/'.$this->wetu_id.'/'.$this->format_filename($post_id); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
| 213 | 213 | * formats the filename |
| 214 | 214 | */ |
| 215 | - public function format_filename( $post_id ) { |
|
| 216 | - $base = str_replace( '_',' ',get_the_title( $post_id ) ); |
|
| 217 | - $base = rawurlencode( $base ); |
|
| 218 | - $type = get_post_mime_type( $post_id ); |
|
| 215 | + public function format_filename($post_id) { |
|
| 216 | + $base = str_replace('_', ' ', get_the_title($post_id)); |
|
| 217 | + $base = rawurlencode($base); |
|
| 218 | + $type = get_post_mime_type($post_id); |
|
| 219 | 219 | |
| 220 | - switch ( $type ) { |
|
| 220 | + switch ($type) { |
|
| 221 | 221 | case 'image/jpeg': |
| 222 | - return $base . '.jpg'; |
|
| 222 | + return $base.'.jpg'; |
|
| 223 | 223 | break; |
| 224 | 224 | case 'image/png': |
| 225 | - return $base . '.png'; |
|
| 225 | + return $base.'.png'; |
|
| 226 | 226 | break; |
| 227 | 227 | case 'image/gif': |
| 228 | - return $base . '.gif'; |
|
| 228 | + return $base.'.gif'; |
|
| 229 | 229 | break; |
| 230 | 230 | default: |
| 231 | 231 | return false; |
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - public function attach_external_image2( $url = null, $post_data = array() ) { |
|
| 236 | - if ( ! $url ) { return new WP_Error( 'missing', 'Need a valid URL' ); } |
|
| 235 | + public function attach_external_image2($url = null, $post_data = array()) { |
|
| 236 | + if (!$url) { return new WP_Error('missing', 'Need a valid URL'); } |
|
| 237 | 237 | |
| 238 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
| 239 | - require_once( ABSPATH . 'wp-admin/includes/media.php' ); |
|
| 240 | - require_once( ABSPATH . 'wp-admin/includes/image.php' ); |
|
| 238 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
| 239 | + require_once(ABSPATH.'wp-admin/includes/media.php'); |
|
| 240 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
| 241 | 241 | |
| 242 | 242 | //var_dump($tmp); |
| 243 | - $tmp = tempnam( '/tmp', 'FOO' ); |
|
| 244 | - print_r( $url ); |
|
| 245 | - $image = file_get_contents( $url ); |
|
| 246 | - print_r( $image ); |
|
| 247 | - file_put_contents( $tmp, $image ); |
|
| 248 | - chmod( $tmp,'777' ); |
|
| 249 | - |
|
| 250 | - preg_match( '/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches ); // fix file filename for query strings |
|
| 251 | - $url_filename = basename( $matches[0] ); |
|
| 252 | - $url_filename = str_replace( '%20','_',$url_filename ); |
|
| 243 | + $tmp = tempnam('/tmp', 'FOO'); |
|
| 244 | + print_r($url); |
|
| 245 | + $image = file_get_contents($url); |
|
| 246 | + print_r($image); |
|
| 247 | + file_put_contents($tmp, $image); |
|
| 248 | + chmod($tmp, '777'); |
|
| 249 | + |
|
| 250 | + preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches); // fix file filename for query strings |
|
| 251 | + $url_filename = basename($matches[0]); |
|
| 252 | + $url_filename = str_replace('%20', '_', $url_filename); |
|
| 253 | 253 | // extract filename from url for title |
| 254 | - $url_type = wp_check_filetype( $url_filename ); // determine file type (ext and mime/type) |
|
| 254 | + $url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type) |
|
| 255 | 255 | |
| 256 | 256 | // assemble file data (should be built like $_FILES since wp_handle_sideload() will be using) |
| 257 | - $file_array['tmp_name'] = $tmp; // full server path to temp file |
|
| 257 | + $file_array['tmp_name'] = $tmp; // full server path to temp file |
|
| 258 | 258 | |
| 259 | - if ( ! empty( $filename ) && ' ' != $filename ) { |
|
| 260 | - $file_array['name'] = $filename . '.' . $url_type['ext']; // user given filename for title, add original URL extension |
|
| 261 | - } else { |
|
| 262 | - $file_array['name'] = $url_filename; // just use original URL filename |
|
| 259 | + if (!empty($filename) && ' ' != $filename) { |
|
| 260 | + $file_array['name'] = $filename.'.'.$url_type['ext']; // user given filename for title, add original URL extension |
|
| 261 | + }else { |
|
| 262 | + $file_array['name'] = $url_filename; // just use original URL filename |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | // set additional wp_posts columns |
| 266 | - if ( empty( $post_data['post_title'] ) ) { |
|
| 267 | - $url_filename = str_replace( '%20',' ',$url_filename ); |
|
| 268 | - $post_data['post_title'] = basename( $url_filename, '.' . $url_type['ext'] ); // just use the original filename (no extension) |
|
| 266 | + if (empty($post_data['post_title'])) { |
|
| 267 | + $url_filename = str_replace('%20', ' ', $url_filename); |
|
| 268 | + $post_data['post_title'] = basename($url_filename, '.'.$url_type['ext']); // just use the original filename (no extension) |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | // make sure gets tied to parent |
| 272 | - if ( empty( $post_data['post_parent'] ) ) { |
|
| 272 | + if (empty($post_data['post_parent'])) { |
|
| 273 | 273 | // @codingStandardsIgnoreLine |
| 274 | 274 | $post_data['post_parent'] = $_POST['post_id']; |
| 275 | 275 | } |
@@ -278,11 +278,11 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | // do the validation and storage stuff |
| 280 | 280 | // @codingStandardsIgnoreLine |
| 281 | - $att_id = media_handle_sideload( $file_array, $_POST['post_id'], null, $post_data ); // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status |
|
| 281 | + $att_id = media_handle_sideload($file_array, $_POST['post_id'], null, $post_data); // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status |
|
| 282 | 282 | |
| 283 | 283 | // If error storing permanently, unlink |
| 284 | - if ( is_wp_error( $att_id ) ) { |
|
| 285 | - unlink( $file_array['tmp_name'] ); // clean up |
|
| 284 | + if (is_wp_error($att_id)) { |
|
| 285 | + unlink($file_array['tmp_name']); // clean up |
|
| 286 | 286 | return false; // output wp_error |
| 287 | 287 | //return $att_id; // output wp_error |
| 288 | 288 | } |
@@ -214,6 +214,7 @@ |
||
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | 216 | * format the array |
| 217 | + * @param string $key |
|
| 217 | 218 | */ |
| 218 | 219 | public function format_array( $array, $key ) { |
| 219 | 220 | $new_array = array(); |
@@ -35,17 +35,17 @@ discard block |
||
| 35 | 35 | * @access private |
| 36 | 36 | */ |
| 37 | 37 | public function __construct() { |
| 38 | - $temp_options = get_option( '_lsx-to_settings',false ); |
|
| 38 | + $temp_options = get_option('_lsx-to_settings', false); |
|
| 39 | 39 | |
| 40 | - if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) { |
|
| 41 | - $this->options = $temp_options[ $this->plugin_slug ]; |
|
| 40 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
| 41 | + $this->options = $temp_options[$this->plugin_slug]; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - $this->url = 'http://wetu.com/API/Pins/' . $this->options['api_key'] . '/List'; |
|
| 44 | + $this->url = 'http://wetu.com/API/Pins/'.$this->options['api_key'].'/List'; |
|
| 45 | 45 | |
| 46 | - add_action( 'lsx_tour_importer_admin_tab_' . $this->tab_slug, array( $this, 'display_page' ) ); |
|
| 47 | - add_action( 'wp_ajax_lsx_import_connect_accommodation',array( $this, 'process_connection' ) ); |
|
| 48 | - add_action( 'wp_ajax_nopriv_lsx_import_connect_accommodation',array( $this, 'process_connection' ) ); |
|
| 46 | + add_action('lsx_tour_importer_admin_tab_'.$this->tab_slug, array($this, 'display_page')); |
|
| 47 | + add_action('wp_ajax_lsx_import_connect_accommodation', array($this, 'process_connection')); |
|
| 48 | + add_action('wp_ajax_nopriv_lsx_import_connect_accommodation', array($this, 'process_connection')); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -55,45 +55,45 @@ discard block |
||
| 55 | 55 | global $post; |
| 56 | 56 | ?> |
| 57 | 57 | <div class="wrap"> |
| 58 | - <h3><span class="dashicons dashicons-admin-multisite"></span> <?php esc_html_e( 'Connect your Accommodation','wetu-importer' ); ?></h3> |
|
| 58 | + <h3><span class="dashicons dashicons-admin-multisite"></span> <?php esc_html_e('Connect your Accommodation', 'wetu-importer'); ?></h3> |
|
| 59 | 59 | |
| 60 | 60 | <form method="get" action="" id="connect-accommodation-filter"> |
| 61 | - <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" /> |
|
| 61 | + <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" /> |
|
| 62 | 62 | |
| 63 | - <p><?php esc_html_e( 'Below is a list of your accommodation that does not contain a WETU ID, but its Title matches a name in the WETU DB. Connecting it will all you to pull through information from WETU.','wetu-importer' ); ?></p> |
|
| 63 | + <p><?php esc_html_e('Below is a list of your accommodation that does not contain a WETU ID, but its Title matches a name in the WETU DB. Connecting it will all you to pull through information from WETU.', 'wetu-importer'); ?></p> |
|
| 64 | 64 | |
| 65 | 65 | <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;"> |
| 66 | - <img style="width:32px;" src="<?php echo esc_url( WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" /> |
|
| 66 | + <img style="width:32px;" src="<?php echo esc_url(WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" /> |
|
| 67 | 67 | </div> |
| 68 | 68 | |
| 69 | 69 | <?php |
| 70 | 70 | $loose_accommodation = $this->find_current_accommodation(); |
| 71 | 71 | ?> |
| 72 | - <p><input class="button button-primary connect" type="button" value="<?php esc_html_e( 'Connect','wetu-importer' ); ?>" /></p> |
|
| 72 | + <p><input class="button button-primary connect" type="button" value="<?php esc_html_e('Connect', 'wetu-importer'); ?>" /></p> |
|
| 73 | 73 | <table class="wp-list-table widefat fixed posts"> |
| 74 | 74 | <?php $this->table_header(); ?> |
| 75 | 75 | |
| 76 | 76 | <tbody> |
| 77 | - <?php if ( false !== $loose_accommodation ) { |
|
| 77 | + <?php if (false !== $loose_accommodation) { |
|
| 78 | 78 | |
| 79 | 79 | $loose_args = array( |
| 80 | 80 | 'post_type' => 'accommodation', |
| 81 | - 'post_status' => array( 'publish','pending' ), |
|
| 81 | + 'post_status' => array('publish', 'pending'), |
|
| 82 | 82 | 'nopagin' => true, |
| 83 | 83 | 'post__in' => $loose_accommodation, |
| 84 | 84 | ); |
| 85 | - $loose_accommodation_query = new WP_Query( $loose_args ); |
|
| 86 | - $accommodation = get_transient( 'lsx_ti_accommodation' ); |
|
| 85 | + $loose_accommodation_query = new WP_Query($loose_args); |
|
| 86 | + $accommodation = get_transient('lsx_ti_accommodation'); |
|
| 87 | 87 | $identifier = ''; |
| 88 | 88 | |
| 89 | - if ( $loose_accommodation_query->have_posts() && false !== $accommodation ) { |
|
| 90 | - while ( $loose_accommodation_query->have_posts() ) { |
|
| 89 | + if ($loose_accommodation_query->have_posts() && false !== $accommodation) { |
|
| 90 | + while ($loose_accommodation_query->have_posts()) { |
|
| 91 | 91 | $loose_accommodation_query->the_post(); |
| 92 | 92 | |
| 93 | - foreach ( $accommodation as $row_key => $row ) { |
|
| 94 | - if ( stripos( ltrim( rtrim( $row->name ) ), $post->post_title ) !== false ) { |
|
| 93 | + foreach ($accommodation as $row_key => $row) { |
|
| 94 | + if (stripos(ltrim(rtrim($row->name)), $post->post_title) !== false) { |
|
| 95 | 95 | $identifier = $row->id; |
| 96 | - } else { |
|
| 96 | + }else { |
|
| 97 | 97 | continue; |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -101,15 +101,15 @@ discard block |
||
| 101 | 101 | <tr class="post-<?php the_ID(); ?> type-accommodation status-none" id="post-<?php the_ID(); ?>"> |
| 102 | 102 | <th class="check-column" scope="row"> |
| 103 | 103 | <label for="cb-select-<?php the_ID(); ?>" class="screen-reader-text"><?php the_title(); ?></label> |
| 104 | - <input type="checkbox" data-identifier="<?php echo esc_attr( $identifier ); ?>" value="<?php the_ID(); ?>" name="post[]" id="cb-select-<?php the_ID(); ?>"> |
|
| 104 | + <input type="checkbox" data-identifier="<?php echo esc_attr($identifier); ?>" value="<?php the_ID(); ?>" name="post[]" id="cb-select-<?php the_ID(); ?>"> |
|
| 105 | 105 | </th> |
| 106 | 106 | <td class="post-title page-title column-title"> |
| 107 | - <strong><?php the_title(); ?></strong> - <a href="<?php echo esc_url( admin_url( '/post.php?post=' . $post->ID . '&action=edit' ) ); ?>" target="_blank"><?php echo esc_html( $post->post_status ); ?></a> |
|
| 107 | + <strong><?php the_title(); ?></strong> - <a href="<?php echo esc_url(admin_url('/post.php?post='.$post->ID.'&action=edit')); ?>" target="_blank"><?php echo esc_html($post->post_status); ?></a> |
|
| 108 | 108 | </td> |
| 109 | 109 | <td class="excerpt column-excerpt"> |
| 110 | 110 | <?php |
| 111 | 111 | // @codingStandardsIgnoreLine |
| 112 | - echo strip_tags( get_the_excerpt() ); |
|
| 112 | + echo strip_tags(get_the_excerpt()); |
|
| 113 | 113 | ?> |
| 114 | 114 | </td> |
| 115 | 115 | </tr> |
@@ -122,12 +122,12 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | </table> |
| 124 | 124 | |
| 125 | - <p><input class="button button-primary connect" type="button" value="<?php esc_html_e( 'Connect','wetu-importer' ); ?>" /></p> |
|
| 125 | + <p><input class="button button-primary connect" type="button" value="<?php esc_html_e('Connect', 'wetu-importer'); ?>" /></p> |
|
| 126 | 126 | |
| 127 | 127 | </form> |
| 128 | 128 | |
| 129 | 129 | <div style="display:none;" class="completed-list-wrapper"> |
| 130 | - <h3><?php esc_html_e( 'Completed' ); ?></h3> |
|
| 130 | + <h3><?php esc_html_e('Completed'); ?></h3> |
|
| 131 | 131 | <ul> |
| 132 | 132 | </ul> |
| 133 | 133 | </div> |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | FROM {$wpdb->posts} |
| 184 | 184 | WHERE post_type = 'accommodation' |
| 185 | 185 | LIMIT 0,500 |
| 186 | - ",ARRAY_A); |
|
| 186 | + ", ARRAY_A); |
|
| 187 | 187 | |
| 188 | 188 | $current_accommodation = $wpdb->get_results(" |
| 189 | 189 | SELECT key1.post_id |
@@ -196,14 +196,14 @@ discard block |
||
| 196 | 196 | AND key2.post_type = 'accommodation' |
| 197 | 197 | |
| 198 | 198 | LIMIT 0,500 |
| 199 | - ",ARRAY_A); |
|
| 199 | + ", ARRAY_A); |
|
| 200 | 200 | |
| 201 | - if ( null !== $all_accommodation && ! empty( $all_accommodation ) ) { |
|
| 201 | + if (null !== $all_accommodation && !empty($all_accommodation)) { |
|
| 202 | 202 | //remove the extra accommodation |
| 203 | - if ( null !== $current_accommodation && ! empty( $current_accommodation ) ) { |
|
| 204 | - $all_accommodation = array_diff( $this->format_array( $all_accommodation,'ID' ), $this->format_array( $current_accommodation,'post_id' ) ); |
|
| 205 | - } elseif ( null !== $current_accommodation && empty( $current_accommodation ) ) { |
|
| 206 | - $all_accommodation = $this->format_array( $current_accommodation,'post_id' ); |
|
| 203 | + if (null !== $current_accommodation && !empty($current_accommodation)) { |
|
| 204 | + $all_accommodation = array_diff($this->format_array($all_accommodation, 'ID'), $this->format_array($current_accommodation, 'post_id')); |
|
| 205 | + } elseif (null !== $current_accommodation && empty($current_accommodation)) { |
|
| 206 | + $all_accommodation = $this->format_array($current_accommodation, 'post_id'); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | $return = $all_accommodation; |
@@ -215,11 +215,11 @@ discard block |
||
| 215 | 215 | /** |
| 216 | 216 | * format the array |
| 217 | 217 | */ |
| 218 | - public function format_array( $array, $key ) { |
|
| 218 | + public function format_array($array, $key) { |
|
| 219 | 219 | $new_array = array(); |
| 220 | 220 | |
| 221 | - foreach ( $array as $value ) { |
|
| 222 | - $new_array[] = $value[ $key ]; |
|
| 221 | + foreach ($array as $value) { |
|
| 222 | + $new_array[] = $value[$key]; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | return $new_array; |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | $return = false; |
| 233 | 233 | |
| 234 | 234 | // @codingStandardsIgnoreLine |
| 235 | - if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_connect_accommodation' && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug && isset( $_POST['post_id'] ) && isset( $_POST['wetu_id'] ) ) { |
|
| 235 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_connect_accommodation' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['post_id']) && isset($_POST['wetu_id'])) { |
|
| 236 | 236 | $post_id = false; |
| 237 | 237 | $matching_id = false; |
| 238 | 238 | |
@@ -241,11 +241,11 @@ discard block |
||
| 241 | 241 | // @codingStandardsIgnoreLine |
| 242 | 242 | $matching_id = $_POST['wetu_id']; |
| 243 | 243 | |
| 244 | - add_post_meta( $post_id,'lsx_wetu_id',$matching_id ); |
|
| 245 | - $return = '<li class="post-' . $post_id . '"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="' . get_permalink( $post_id ) . '">' . get_the_title( $post_id ) . '</a></li>'; |
|
| 244 | + add_post_meta($post_id, 'lsx_wetu_id', $matching_id); |
|
| 245 | + $return = '<li class="post-'.$post_id.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($post_id).'">'.get_the_title($post_id).'</a></li>'; |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - print_r( $return ); |
|
| 248 | + print_r($return); |
|
| 249 | 249 | die(); |
| 250 | 250 | } |
| 251 | 251 | |
@@ -656,6 +656,7 @@ discard block |
||
| 656 | 656 | |
| 657 | 657 | /** |
| 658 | 658 | * Set the team memberon each item. |
| 659 | + * @param boolean $team_members |
|
| 659 | 660 | */ |
| 660 | 661 | public function set_team_member( $id, $team_members ) { |
| 661 | 662 | delete_post_meta( $id, 'team_to_' . $this->tab_slug ); |
@@ -667,6 +668,7 @@ discard block |
||
| 667 | 668 | |
| 668 | 669 | /** |
| 669 | 670 | * Saves the room data |
| 671 | + * @param string $meta_key |
|
| 670 | 672 | */ |
| 671 | 673 | public function set_travel_info( $data, $id, $meta_key ) { |
| 672 | 674 | if ( ! empty( $data[0]['travel_information'] ) && isset( $data[0]['travel_information'][ $meta_key ] ) ) { |
@@ -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 = ''; |
| 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,109 +149,109 @@ 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, 'continent' ); ?> |
|
| 187 | + <input class="content" <?php $this->checked($this->destination_options, 'continent'); ?> |
|
| 188 | 188 | type="checkbox" name="content[]" |
| 189 | - value="continent"/> <?php esc_html_e( 'Set Continent', 'wetu-importer' ); ?></li> |
|
| 189 | + value="continent"/> <?php esc_html_e('Set Continent', 'wetu-importer'); ?></li> |
|
| 190 | 190 | |
| 191 | 191 | <li> |
| 192 | - <input class="content" <?php $this->checked( $this->destination_options, 'featured_image' ); ?> |
|
| 192 | + <input class="content" <?php $this->checked($this->destination_options, 'featured_image'); ?> |
|
| 193 | 193 | type="checkbox" name="content[]" |
| 194 | - value="featured_image"/> <?php esc_html_e( 'Set Featured Image', 'wetu-importer' ); ?> |
|
| 194 | + value="featured_image"/> <?php esc_html_e('Set Featured Image', 'wetu-importer'); ?> |
|
| 195 | 195 | </li> |
| 196 | - <?php if ( class_exists( 'LSX_Banners' ) ) { ?> |
|
| 196 | + <?php if (class_exists('LSX_Banners')) { ?> |
|
| 197 | 197 | <li> |
| 198 | - <input class="content" <?php $this->checked( $this->destination_options, 'banner_image' ); ?> |
|
| 198 | + <input class="content" <?php $this->checked($this->destination_options, 'banner_image'); ?> |
|
| 199 | 199 | type="checkbox" name="content[]" |
| 200 | - value="banner_image"/> <?php esc_html_e( 'Set Banner Image', 'wetu-importer' ); ?> |
|
| 200 | + value="banner_image"/> <?php esc_html_e('Set Banner Image', 'wetu-importer'); ?> |
|
| 201 | 201 | </li> |
| 202 | 202 | <?php } ?> |
| 203 | 203 | |
| 204 | 204 | <li> |
| 205 | - <input class="content" <?php $this->checked( $this->destination_options, 'strip_tags' ); ?> |
|
| 205 | + <input class="content" <?php $this->checked($this->destination_options, 'strip_tags'); ?> |
|
| 206 | 206 | type="checkbox" name="content[]" |
| 207 | - value="strip_tags"/> <?php esc_html_e( 'Strip HTML from the description', 'wetu-importer' ); ?></li> |
|
| 207 | + value="strip_tags"/> <?php esc_html_e('Strip HTML from the description', 'wetu-importer'); ?></li> |
|
| 208 | 208 | </ul> |
| 209 | 209 | </div> |
| 210 | 210 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 211 | - <h3><?php esc_html_e( 'Travel Information' ); ?></h3> |
|
| 211 | + <h3><?php esc_html_e('Travel Information'); ?></h3> |
|
| 212 | 212 | <ul> |
| 213 | 213 | <li> |
| 214 | - <input class="content" <?php $this->checked( $this->destination_options, 'electricity' ); ?> |
|
| 214 | + <input class="content" <?php $this->checked($this->destination_options, 'electricity'); ?> |
|
| 215 | 215 | type="checkbox" name="content[]" |
| 216 | - value="electricity"/> <?php esc_html_e( 'Electricity', 'wetu-importer' ); ?></li> |
|
| 216 | + value="electricity"/> <?php esc_html_e('Electricity', 'wetu-importer'); ?></li> |
|
| 217 | 217 | <li> |
| 218 | - <input class="content" <?php $this->checked( $this->destination_options, 'banking' ); ?> |
|
| 218 | + <input class="content" <?php $this->checked($this->destination_options, 'banking'); ?> |
|
| 219 | 219 | type="checkbox" name="content[]" |
| 220 | - value="banking"/> <?php esc_html_e( 'Banking', 'wetu-importer' ); ?></li> |
|
| 220 | + value="banking"/> <?php esc_html_e('Banking', 'wetu-importer'); ?></li> |
|
| 221 | 221 | <li> |
| 222 | - <input class="content" <?php $this->checked( $this->destination_options, 'cuisine' ); ?> |
|
| 222 | + <input class="content" <?php $this->checked($this->destination_options, 'cuisine'); ?> |
|
| 223 | 223 | type="checkbox" name="content[]" |
| 224 | - value="cuisine"/> <?php esc_html_e( 'Cuisine', 'wetu-importer' ); ?></li> |
|
| 224 | + value="cuisine"/> <?php esc_html_e('Cuisine', 'wetu-importer'); ?></li> |
|
| 225 | 225 | <li> |
| 226 | - <input class="content" <?php $this->checked( $this->destination_options, 'climate' ); ?> |
|
| 226 | + <input class="content" <?php $this->checked($this->destination_options, 'climate'); ?> |
|
| 227 | 227 | type="checkbox" name="content[]" |
| 228 | - value="climate"/> <?php esc_html_e( 'Climate', 'wetu-importer' ); ?></li> |
|
| 228 | + value="climate"/> <?php esc_html_e('Climate', 'wetu-importer'); ?></li> |
|
| 229 | 229 | <li> |
| 230 | - <input class="content" <?php $this->checked( $this->destination_options, 'transport' ); ?> |
|
| 230 | + <input class="content" <?php $this->checked($this->destination_options, 'transport'); ?> |
|
| 231 | 231 | type="checkbox" name="content[]" |
| 232 | - value="transport"/> <?php esc_html_e( 'Transport', 'wetu-importer' ); ?></li> |
|
| 233 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'dress' ); ?> |
|
| 232 | + value="transport"/> <?php esc_html_e('Transport', 'wetu-importer'); ?></li> |
|
| 233 | + <li><input class="content" <?php $this->checked($this->destination_options, 'dress'); ?> |
|
| 234 | 234 | type="checkbox" name="content[]" |
| 235 | - value="dress"/> <?php esc_html_e( 'Dress', 'wetu-importer' ); ?></li> |
|
| 236 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'health' ); ?> |
|
| 235 | + value="dress"/> <?php esc_html_e('Dress', 'wetu-importer'); ?></li> |
|
| 236 | + <li><input class="content" <?php $this->checked($this->destination_options, 'health'); ?> |
|
| 237 | 237 | type="checkbox" name="content[]" |
| 238 | - value="health"/> <?php esc_html_e( 'Health', 'wetu-importer' ); ?></li> |
|
| 239 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'safety' ); ?> |
|
| 238 | + value="health"/> <?php esc_html_e('Health', 'wetu-importer'); ?></li> |
|
| 239 | + <li><input class="content" <?php $this->checked($this->destination_options, 'safety'); ?> |
|
| 240 | 240 | type="checkbox" name="content[]" |
| 241 | - value="safety"/> <?php esc_html_e( 'Safety', 'wetu-importer' ); ?></li> |
|
| 242 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'visa' ); ?> |
|
| 241 | + value="safety"/> <?php esc_html_e('Safety', 'wetu-importer'); ?></li> |
|
| 242 | + <li><input class="content" <?php $this->checked($this->destination_options, 'visa'); ?> |
|
| 243 | 243 | type="checkbox" name="content[]" |
| 244 | - value="visa"/> <?php esc_html_e( 'Visa', 'wetu-importer' ); ?></li> |
|
| 245 | - <li><input class="content" <?php $this->checked( $this->destination_options, 'additional_info' ); ?> |
|
| 244 | + value="visa"/> <?php esc_html_e('Visa', 'wetu-importer'); ?></li> |
|
| 245 | + <li><input class="content" <?php $this->checked($this->destination_options, 'additional_info'); ?> |
|
| 246 | 246 | type="checkbox" name="content[]" |
| 247 | - value="additional_info"/> <?php esc_html_e( 'General', 'wetu-importer' ); ?></li> |
|
| 247 | + value="additional_info"/> <?php esc_html_e('General', 'wetu-importer'); ?></li> |
|
| 248 | 248 | </ul> |
| 249 | 249 | </div> |
| 250 | 250 | |
| 251 | - <?php if ( class_exists( 'LSX_TO_Team' ) ) { ?> |
|
| 251 | + <?php if (class_exists('LSX_TO_Team')) { ?> |
|
| 252 | 252 | <div style="width:30%;display:block;float:left;"> |
| 253 | - <h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3> |
|
| 254 | - <?php $this->team_member_checkboxes( $this->destination_options ); ?> |
|
| 253 | + <h3><?php esc_html_e('Assign a Team Member'); ?></h3> |
|
| 254 | + <?php $this->team_member_checkboxes($this->destination_options); ?> |
|
| 255 | 255 | </div> |
| 256 | 256 | <?php } ?> |
| 257 | 257 | |
@@ -259,9 +259,9 @@ discard block |
||
| 259 | 259 | </div> |
| 260 | 260 | |
| 261 | 261 | |
| 262 | - <h3><?php esc_html_e( 'Your List' ); ?></h3> |
|
| 262 | + <h3><?php esc_html_e('Your List'); ?></h3> |
|
| 263 | 263 | <p><input class="button button-primary" type="submit" |
| 264 | - value="<?php esc_html_e( 'Sync', 'wetu-importer' ); ?>"/></p> |
|
| 264 | + value="<?php esc_html_e('Sync', 'wetu-importer'); ?>"/></p> |
|
| 265 | 265 | <table class="wp-list-table widefat fixed posts"> |
| 266 | 266 | <?php $this->table_header(); ?> |
| 267 | 267 | |
@@ -274,12 +274,12 @@ discard block |
||
| 274 | 274 | </table> |
| 275 | 275 | |
| 276 | 276 | <p><input class="button button-primary" type="submit" |
| 277 | - value="<?php esc_html_e( 'Sync', 'wetu-importer' ); ?>"/></p> |
|
| 277 | + value="<?php esc_html_e('Sync', 'wetu-importer'); ?>"/></p> |
|
| 278 | 278 | </form> |
| 279 | 279 | </div> |
| 280 | 280 | |
| 281 | 281 | <div style="display:none;" class="completed-list-wrapper"> |
| 282 | - <h3><?php esc_html_e( 'Completed' ); ?></h3> |
|
| 282 | + <h3><?php esc_html_e('Completed'); ?></h3> |
|
| 283 | 283 | <ul> |
| 284 | 284 | </ul> |
| 285 | 285 | </div> |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | /** |
| 291 | 291 | * Grab all the current destination posts via the lsx_wetu_id field. |
| 292 | 292 | */ |
| 293 | - public function find_current_destination( $post_type = 'destination' ) { |
|
| 293 | + public function find_current_destination($post_type = 'destination') { |
|
| 294 | 294 | global $wpdb; |
| 295 | 295 | $return = array(); |
| 296 | 296 | |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | "); |
| 310 | 310 | // @codingStandardsIgnoreEnd |
| 311 | 311 | |
| 312 | - if ( null !== $current_destination && ! empty( $current_destination ) ) { |
|
| 313 | - foreach ( $current_destination as $accom ) { |
|
| 314 | - $return[ $accom->meta_value ] = $accom; |
|
| 312 | + if (null !== $current_destination && !empty($current_destination)) { |
|
| 313 | + foreach ($current_destination as $accom) { |
|
| 314 | + $return[$accom->meta_value] = $accom; |
|
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | |
@@ -325,86 +325,86 @@ discard block |
||
| 325 | 325 | $return = false; |
| 326 | 326 | |
| 327 | 327 | // @codingStandardsIgnoreLine |
| 328 | - if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_tour_importer' && isset( $_POST['type'] ) && $_POST['type'] === 'destination' ) { |
|
| 328 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'destination') { |
|
| 329 | 329 | |
| 330 | 330 | // @codingStandardsIgnoreLine |
| 331 | - if ( isset( $_POST['keyword'] ) ) { |
|
| 331 | + if (isset($_POST['keyword'])) { |
|
| 332 | 332 | $searched_items = false; |
| 333 | 333 | |
| 334 | 334 | // @codingStandardsIgnoreLine |
| 335 | - if ( isset( $_POST['keyword'] ) ) { |
|
| 335 | + if (isset($_POST['keyword'])) { |
|
| 336 | 336 | // @codingStandardsIgnoreLine |
| 337 | 337 | $keyphrases = $_POST['keyword']; |
| 338 | - } else { |
|
| 339 | - $keyphrases = array( 0 ); |
|
| 338 | + }else { |
|
| 339 | + $keyphrases = array(0); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - if ( ! is_array( $keyphrases ) ) { |
|
| 343 | - $keyphrases = array( $keyphrases ); |
|
| 342 | + if (!is_array($keyphrases)) { |
|
| 343 | + $keyphrases = array($keyphrases); |
|
| 344 | 344 | } |
| 345 | - foreach ( $keyphrases as &$keyword ) { |
|
| 346 | - $keyword = ltrim( rtrim( $keyword ) ); |
|
| 345 | + foreach ($keyphrases as &$keyword) { |
|
| 346 | + $keyword = ltrim(rtrim($keyword)); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | $post_status = false; |
| 350 | - if ( in_array( 'publish', $keyphrases ) ) { |
|
| 350 | + if (in_array('publish', $keyphrases)) { |
|
| 351 | 351 | $post_status = 'publish'; |
| 352 | 352 | } |
| 353 | - if ( in_array( 'pending', $keyphrases ) ) { |
|
| 353 | + if (in_array('pending', $keyphrases)) { |
|
| 354 | 354 | $post_status = 'pending'; |
| 355 | 355 | } |
| 356 | - if ( in_array( 'draft', $keyphrases ) ) { |
|
| 356 | + if (in_array('draft', $keyphrases)) { |
|
| 357 | 357 | $post_status = 'draft'; |
| 358 | 358 | } |
| 359 | - if ( in_array( 'import', $keyphrases ) ) { |
|
| 359 | + if (in_array('import', $keyphrases)) { |
|
| 360 | 360 | $post_status = 'import'; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | $destination = $this->find_current_destination(); |
| 364 | 364 | |
| 365 | - if ( ! empty( $destination ) ) { |
|
| 365 | + if (!empty($destination)) { |
|
| 366 | 366 | |
| 367 | - foreach ( $destination as $row ) { |
|
| 367 | + foreach ($destination as $row) { |
|
| 368 | 368 | |
| 369 | 369 | //If we are searching for |
| 370 | - if ( 'import' === $post_status ) { |
|
| 371 | - if ( is_array( $this->queued_imports ) && in_array( $row->post_id,$this->queued_imports ) ) { |
|
| 372 | - $searched_items[ sanitize_title( $row->name ) . '-' . $row->meta_value ] = $this->format_row( $row ); |
|
| 373 | - } else { |
|
| 370 | + if ('import' === $post_status) { |
|
| 371 | + if (is_array($this->queued_imports) && in_array($row->post_id, $this->queued_imports)) { |
|
| 372 | + $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row); |
|
| 373 | + }else { |
|
| 374 | 374 | continue; |
| 375 | 375 | } |
| 376 | - } else if ( false !== $post_status ) { |
|
| 376 | + }else if (false !== $post_status) { |
|
| 377 | 377 | |
| 378 | - $current_status = get_post_status( $row->post_id ); |
|
| 379 | - if ( $current_status !== $post_status ) { |
|
| 378 | + $current_status = get_post_status($row->post_id); |
|
| 379 | + if ($current_status !== $post_status) { |
|
| 380 | 380 | continue; |
| 381 | 381 | } |
| 382 | - $searched_items[ sanitize_title( $row->name ) . '-' . $row->meta_value ] = $this->format_row( $row ); |
|
| 382 | + $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row); |
|
| 383 | 383 | |
| 384 | - } else { |
|
| 384 | + }else { |
|
| 385 | 385 | //Search through each keyword. |
| 386 | - foreach ( $keyphrases as $keyphrase ) { |
|
| 386 | + foreach ($keyphrases as $keyphrase) { |
|
| 387 | 387 | |
| 388 | 388 | //Make sure the keyphrase is turned into an array |
| 389 | - $keywords = explode( ' ', $keyphrase ); |
|
| 390 | - if ( ! is_array( $keywords ) ) { |
|
| 391 | - $keywords = array( $keywords ); |
|
| 389 | + $keywords = explode(' ', $keyphrase); |
|
| 390 | + if (!is_array($keywords)) { |
|
| 391 | + $keywords = array($keywords); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - if ( $this->multineedle_stripos( ltrim( rtrim( $row->name ) ), $keywords ) !== false ) { |
|
| 395 | - $searched_items[ sanitize_title( $row->name ) . '-' . $row->meta_value ] = $this->format_row( $row ); |
|
| 394 | + if ($this->multineedle_stripos(ltrim(rtrim($row->name)), $keywords) !== false) { |
|
| 395 | + $searched_items[sanitize_title($row->name).'-'.$row->meta_value] = $this->format_row($row); |
|
| 396 | 396 | } |
| 397 | 397 | } |
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - if ( false !== $searched_items ) { |
|
| 403 | - ksort( $searched_items ); |
|
| 404 | - $return = implode( $searched_items ); |
|
| 402 | + if (false !== $searched_items) { |
|
| 403 | + ksort($searched_items); |
|
| 404 | + $return = implode($searched_items); |
|
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | - print_r( $return ); |
|
| 407 | + print_r($return); |
|
| 408 | 408 | die(); |
| 409 | 409 | } |
| 410 | 410 | } |
@@ -412,28 +412,28 @@ discard block |
||
| 412 | 412 | /** |
| 413 | 413 | * Formats the row for output on the screen. |
| 414 | 414 | */ |
| 415 | - public function format_row( $row = false ) { |
|
| 416 | - if ( false !== $row ) { |
|
| 415 | + public function format_row($row = false) { |
|
| 416 | + if (false !== $row) { |
|
| 417 | 417 | |
| 418 | 418 | $status = 'import'; |
| 419 | - if ( 0 !== $row->post_id ) { |
|
| 420 | - $status = '<a href="' . admin_url( '/post.php?post=' . $row->post_id . '&action=edit' ) . '" target="_blank">' . get_post_status( $row->post_id ) . '</a>'; |
|
| 419 | + if (0 !== $row->post_id) { |
|
| 420 | + $status = '<a href="'.admin_url('/post.php?post='.$row->post_id.'&action=edit').'" target="_blank">'.get_post_status($row->post_id).'</a>'; |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | $row_html = ' |
| 424 | - <tr class="post-' . $row->post_id . ' type-tour" id="post-' . $row->post_id . '"> |
|
| 424 | + <tr class="post-' . $row->post_id.' type-tour" id="post-'.$row->post_id.'"> |
|
| 425 | 425 | <th class="check-column" scope="row"> |
| 426 | - <label for="cb-select-' . $row->meta_value . '" class="screen-reader-text">' . $row->name . '</label> |
|
| 427 | - <input type="checkbox" data-identifier="' . $row->meta_value . '" value="' . $row->post_id . '" name="post[]" id="cb-select-' . $row->meta_value . '"> |
|
| 426 | + <label for="cb-select-' . $row->meta_value.'" class="screen-reader-text">'.$row->name.'</label> |
|
| 427 | + <input type="checkbox" data-identifier="' . $row->meta_value.'" value="'.$row->post_id.'" name="post[]" id="cb-select-'.$row->meta_value.'"> |
|
| 428 | 428 | </th> |
| 429 | 429 | <td class="post-title page-title column-title"> |
| 430 | - <strong>' . $row->name . '</strong> - ' . $status . ' |
|
| 430 | + <strong>' . $row->name.'</strong> - '.$status.' |
|
| 431 | 431 | </td> |
| 432 | 432 | <td class="date column-date"> |
| 433 | - <abbr title="' . date( 'Y/m/d', strtotime( $row->last_modified ) ) . '">' . date( 'Y/m/d', strtotime( $row->last_modified ) ) . '</abbr><br>Last Modified |
|
| 433 | + <abbr title="' . date('Y/m/d', strtotime($row->last_modified)).'">'.date('Y/m/d', strtotime($row->last_modified)).'</abbr><br>Last Modified |
|
| 434 | 434 | </td> |
| 435 | 435 | <td class="ssid column-ssid"> |
| 436 | - ' . $row->meta_value . ' |
|
| 436 | + ' . $row->meta_value.' |
|
| 437 | 437 | </td> |
| 438 | 438 | </tr>'; |
| 439 | 439 | return $row_html; |
@@ -447,54 +447,54 @@ discard block |
||
| 447 | 447 | $return = false; |
| 448 | 448 | |
| 449 | 449 | // @codingStandardsIgnoreLine |
| 450 | - if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === 'destination' && isset( $_POST['wetu_id'] ) ) { |
|
| 450 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'destination' && isset($_POST['wetu_id'])) { |
|
| 451 | 451 | // @codingStandardsIgnoreLine |
| 452 | 452 | $wetu_id = $_POST['wetu_id']; |
| 453 | 453 | |
| 454 | 454 | // @codingStandardsIgnoreLine |
| 455 | - if ( isset( $_POST['post_id'] ) ) { |
|
| 455 | + if (isset($_POST['post_id'])) { |
|
| 456 | 456 | // @codingStandardsIgnoreLine |
| 457 | 457 | $post_id = $_POST['post_id']; |
| 458 | - $this->current_post = get_post( $post_id ); |
|
| 459 | - } else { |
|
| 458 | + $this->current_post = get_post($post_id); |
|
| 459 | + }else { |
|
| 460 | 460 | $post_id = 0; |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | // @codingStandardsIgnoreLine |
| 464 | - if ( isset( $_POST['team_members'] ) ) { |
|
| 464 | + if (isset($_POST['team_members'])) { |
|
| 465 | 465 | // @codingStandardsIgnoreLine |
| 466 | 466 | $team_members = $_POST['team_members']; |
| 467 | - } else { |
|
| 467 | + }else { |
|
| 468 | 468 | $team_members = false; |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | $safari_brands = false; |
| 472 | 472 | |
| 473 | - delete_option( 'wetu_importer_destination_settings' ); |
|
| 473 | + delete_option('wetu_importer_destination_settings'); |
|
| 474 | 474 | |
| 475 | 475 | // @codingStandardsIgnoreLine |
| 476 | - if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) { |
|
| 476 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
| 477 | 477 | // @codingStandardsIgnoreLine |
| 478 | 478 | $content = $_POST['content']; |
| 479 | - add_option( 'wetu_importer_destination_settings', $content ); |
|
| 480 | - } else { |
|
| 479 | + add_option('wetu_importer_destination_settings', $content); |
|
| 480 | + }else { |
|
| 481 | 481 | $content = false; |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
| 484 | + $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id); |
|
| 485 | 485 | |
| 486 | - if ( $jdata ) { |
|
| 487 | - $adata = json_decode( $jdata, true ); |
|
| 486 | + if ($jdata) { |
|
| 487 | + $adata = json_decode($jdata, true); |
|
| 488 | 488 | |
| 489 | - if ( ! empty( $adata ) && ! isset( $adata['error'] ) ) { |
|
| 490 | - $return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands ); |
|
| 491 | - $this->remove_from_queue( $return ); |
|
| 492 | - $this->format_completed_row( $return ); |
|
| 493 | - } else { |
|
| 494 | - if ( isset( $adata['error'] ) ) { |
|
| 495 | - $this->format_error( $adata['error'] ); |
|
| 496 | - } else { |
|
| 497 | - $this->format_error( esc_html__( 'There was a problem importing your destination, please try refreshing the page.','wetu-importer' ) ); |
|
| 489 | + if (!empty($adata) && !isset($adata['error'])) { |
|
| 490 | + $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
|
| 491 | + $this->remove_from_queue($return); |
|
| 492 | + $this->format_completed_row($return); |
|
| 493 | + }else { |
|
| 494 | + if (isset($adata['error'])) { |
|
| 495 | + $this->format_error($adata['error']); |
|
| 496 | + }else { |
|
| 497 | + $this->format_error(esc_html__('There was a problem importing your destination, please try refreshing the page.', 'wetu-importer')); |
|
| 498 | 498 | } |
| 499 | 499 | } |
| 500 | 500 | } |
@@ -504,14 +504,14 @@ discard block |
||
| 504 | 504 | /** |
| 505 | 505 | * Saves the queue to the option. |
| 506 | 506 | */ |
| 507 | - public function remove_from_queue( $id ) { |
|
| 508 | - if ( ! empty( $this->queued_imports ) ) { |
|
| 507 | + public function remove_from_queue($id) { |
|
| 508 | + if (!empty($this->queued_imports)) { |
|
| 509 | 509 | // @codingStandardsIgnoreLine |
| 510 | - if ( ( $key = array_search( $id, $this->queued_imports ) ) !== false ) { |
|
| 511 | - unset( $this->queued_imports[ $key ] ); |
|
| 510 | + if (($key = array_search($id, $this->queued_imports)) !== false) { |
|
| 511 | + unset($this->queued_imports[$key]); |
|
| 512 | 512 | |
| 513 | - delete_option( 'wetu_importer_que' ); |
|
| 514 | - update_option( 'wetu_importer_que',$this->queued_imports ); |
|
| 513 | + delete_option('wetu_importer_que'); |
|
| 514 | + update_option('wetu_importer_que', $this->queued_imports); |
|
| 515 | 515 | } |
| 516 | 516 | } |
| 517 | 517 | } |
@@ -519,8 +519,8 @@ discard block |
||
| 519 | 519 | /** |
| 520 | 520 | * Connect to wetu |
| 521 | 521 | */ |
| 522 | - public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false ) { |
|
| 523 | - if ( 'Destination' === trim( $data[0]['type'] ) ) { |
|
| 522 | + public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false) { |
|
| 523 | + if ('Destination' === trim($data[0]['type'])) { |
|
| 524 | 524 | $post_name = ''; |
| 525 | 525 | $data_post_content = ''; |
| 526 | 526 | $data_post_excerpt = ''; |
@@ -530,124 +530,124 @@ discard block |
||
| 530 | 530 | ); |
| 531 | 531 | |
| 532 | 532 | //Set the post_content |
| 533 | - if ( false !== $importable_content && in_array( 'description', $importable_content ) ) { |
|
| 534 | - if ( isset( $data[0]['content']['general_description'] ) ) { |
|
| 533 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
| 534 | + if (isset($data[0]['content']['general_description'])) { |
|
| 535 | 535 | |
| 536 | - if ( false !== $importable_content && in_array( 'strip_tags', $importable_content ) ) { |
|
| 537 | - $post['post_content'] = wp_strip_all_tags( $data[0]['content']['general_description'] ); |
|
| 538 | - } else { |
|
| 536 | + if (false !== $importable_content && in_array('strip_tags', $importable_content)) { |
|
| 537 | + $post['post_content'] = wp_strip_all_tags($data[0]['content']['general_description']); |
|
| 538 | + }else { |
|
| 539 | 539 | $post['post_content'] = $data[0]['content']['general_description']; |
| 540 | 540 | } |
| 541 | 541 | } |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - if ( false !== $id && '0' !== $id ) { |
|
| 544 | + if (false !== $id && '0' !== $id) { |
|
| 545 | 545 | $post['ID'] = $id; |
| 546 | 546 | |
| 547 | - if ( isset( $data[0]['name'] ) ) { |
|
| 547 | + if (isset($data[0]['name'])) { |
|
| 548 | 548 | $post['post_title'] = $data[0]['name']; |
| 549 | 549 | $post['post_status'] = 'publish'; |
| 550 | - $post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 ); |
|
| 550 | + $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | - $id = wp_update_post( $post ); |
|
| 554 | - $prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true ); |
|
| 555 | - update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date ); |
|
| 556 | - } else { |
|
| 553 | + $id = wp_update_post($post); |
|
| 554 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
| 555 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date); |
|
| 556 | + }else { |
|
| 557 | 557 | //Set the name |
| 558 | - if ( isset( $data[0]['name'] ) ) { |
|
| 559 | - $post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 ); |
|
| 558 | + if (isset($data[0]['name'])) { |
|
| 559 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0); |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | $post['post_name'] = $post_name; |
| 563 | 563 | $post['post_title'] = $data[0]['name']; |
| 564 | 564 | $post['post_status'] = 'publish'; |
| 565 | - $id = wp_insert_post( $post ); |
|
| 565 | + $id = wp_insert_post($post); |
|
| 566 | 566 | |
| 567 | 567 | //Save the WETU ID and the Last date it was modified. |
| 568 | - if ( false !== $id ) { |
|
| 569 | - add_post_meta( $id, 'lsx_wetu_id', $wetu_id ); |
|
| 570 | - add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) ); |
|
| 568 | + if (false !== $id) { |
|
| 569 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
| 570 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified'])); |
|
| 571 | 571 | } |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - $this->find_attachments( $id ); |
|
| 574 | + $this->find_attachments($id); |
|
| 575 | 575 | |
| 576 | 576 | //Set the team member if it is there |
| 577 | - if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) { |
|
| 578 | - $this->set_team_member( $id, $team_members ); |
|
| 577 | + if (post_type_exists('team') && false !== $team_members && '' !== $team_members) { |
|
| 578 | + $this->set_team_member($id, $team_members); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - if ( class_exists( 'LSX_TO_Maps' ) ) { |
|
| 582 | - $this->set_map_data( $data, $id, 9 ); |
|
| 581 | + if (class_exists('LSX_TO_Maps')) { |
|
| 582 | + $this->set_map_data($data, $id, 9); |
|
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | //Set the Room Data |
| 586 | - if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) { |
|
| 587 | - $this->set_video_data( $data, $id ); |
|
| 586 | + if (false !== $importable_content && in_array('videos', $importable_content)) { |
|
| 587 | + $this->set_video_data($data, $id); |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | //Set the Electricity |
| 591 | - if ( false !== $importable_content && in_array( 'electricity', $importable_content ) ) { |
|
| 592 | - $this->set_travel_info( $data, $id, 'electricity' ); |
|
| 591 | + if (false !== $importable_content && in_array('electricity', $importable_content)) { |
|
| 592 | + $this->set_travel_info($data, $id, 'electricity'); |
|
| 593 | 593 | } |
| 594 | 594 | //Set the cuisine |
| 595 | - if ( false !== $importable_content && in_array( 'cuisine', $importable_content ) ) { |
|
| 596 | - $this->set_travel_info( $data, $id, 'cuisine' ); |
|
| 595 | + if (false !== $importable_content && in_array('cuisine', $importable_content)) { |
|
| 596 | + $this->set_travel_info($data, $id, 'cuisine'); |
|
| 597 | 597 | } |
| 598 | 598 | //Set the banking |
| 599 | - if ( false !== $importable_content && in_array( 'banking', $importable_content ) ) { |
|
| 600 | - $this->set_travel_info( $data, $id, 'banking' ); |
|
| 599 | + if (false !== $importable_content && in_array('banking', $importable_content)) { |
|
| 600 | + $this->set_travel_info($data, $id, 'banking'); |
|
| 601 | 601 | } |
| 602 | 602 | //Set the transport |
| 603 | - if ( false !== $importable_content && in_array( 'transport', $importable_content ) ) { |
|
| 604 | - $this->set_travel_info( $data, $id, 'transport' ); |
|
| 603 | + if (false !== $importable_content && in_array('transport', $importable_content)) { |
|
| 604 | + $this->set_travel_info($data, $id, 'transport'); |
|
| 605 | 605 | } |
| 606 | 606 | //Set the dress |
| 607 | - if ( false !== $importable_content && in_array( 'dress', $importable_content ) ) { |
|
| 608 | - $this->set_travel_info( $data, $id, 'dress' ); |
|
| 607 | + if (false !== $importable_content && in_array('dress', $importable_content)) { |
|
| 608 | + $this->set_travel_info($data, $id, 'dress'); |
|
| 609 | 609 | } |
| 610 | 610 | //Set the climate |
| 611 | - if ( false !== $importable_content && in_array( 'climate', $importable_content ) ) { |
|
| 612 | - $this->set_travel_info( $data, $id, 'climate' ); |
|
| 611 | + if (false !== $importable_content && in_array('climate', $importable_content)) { |
|
| 612 | + $this->set_travel_info($data, $id, 'climate'); |
|
| 613 | 613 | } |
| 614 | 614 | //Set the Health |
| 615 | - if ( false !== $importable_content && in_array( 'health', $importable_content ) ) { |
|
| 616 | - $this->set_travel_info( $data, $id, 'health' ); |
|
| 615 | + if (false !== $importable_content && in_array('health', $importable_content)) { |
|
| 616 | + $this->set_travel_info($data, $id, 'health'); |
|
| 617 | 617 | } |
| 618 | 618 | //Set the Safety |
| 619 | - if ( false !== $importable_content && in_array( 'safety', $importable_content ) ) { |
|
| 620 | - $this->set_travel_info( $data, $id, 'safety' ); |
|
| 619 | + if (false !== $importable_content && in_array('safety', $importable_content)) { |
|
| 620 | + $this->set_travel_info($data, $id, 'safety'); |
|
| 621 | 621 | } |
| 622 | 622 | //Set the Visa |
| 623 | - if ( false !== $importable_content && in_array( 'visa', $importable_content ) ) { |
|
| 624 | - $this->set_travel_info( $data, $id, 'visa' ); |
|
| 623 | + if (false !== $importable_content && in_array('visa', $importable_content)) { |
|
| 624 | + $this->set_travel_info($data, $id, 'visa'); |
|
| 625 | 625 | } |
| 626 | 626 | //Set the General |
| 627 | - if ( false !== $importable_content && in_array( 'additional_info', $importable_content ) ) { |
|
| 628 | - $this->set_travel_info( $data, $id, 'additional_info' ); |
|
| 627 | + if (false !== $importable_content && in_array('additional_info', $importable_content)) { |
|
| 628 | + $this->set_travel_info($data, $id, 'additional_info'); |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | //Setup some default for use in the import |
| 632 | - if ( false !== $importable_content && (in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content )) ) { |
|
| 633 | - $this->find_attachments( $id ); |
|
| 632 | + if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) { |
|
| 633 | + $this->find_attachments($id); |
|
| 634 | 634 | |
| 635 | 635 | //Set the featured image |
| 636 | - if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) { |
|
| 637 | - $this->set_featured_image( $data, $id ); |
|
| 636 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
| 637 | + $this->set_featured_image($data, $id); |
|
| 638 | 638 | } |
| 639 | - if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) { |
|
| 640 | - $this->set_banner_image( $data, $id ); |
|
| 639 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
| 640 | + $this->set_banner_image($data, $id); |
|
| 641 | 641 | } |
| 642 | 642 | //Import the main gallery |
| 643 | - if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) { |
|
| 644 | - $this->create_main_gallery( $data, $id ); |
|
| 643 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
| 644 | + $this->create_main_gallery($data, $id); |
|
| 645 | 645 | } |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | //Set the continent |
| 649 | - if ( false !== $importable_content && in_array( 'continent', $importable_content ) ) { |
|
| 650 | - $this->set_continent( $data, $id ); |
|
| 649 | + if (false !== $importable_content && in_array('continent', $importable_content)) { |
|
| 650 | + $this->set_continent($data, $id); |
|
| 651 | 651 | } |
| 652 | 652 | } |
| 653 | 653 | |
@@ -657,46 +657,46 @@ discard block |
||
| 657 | 657 | /** |
| 658 | 658 | * Set the team memberon each item. |
| 659 | 659 | */ |
| 660 | - public function set_team_member( $id, $team_members ) { |
|
| 661 | - delete_post_meta( $id, 'team_to_' . $this->tab_slug ); |
|
| 660 | + public function set_team_member($id, $team_members) { |
|
| 661 | + delete_post_meta($id, 'team_to_'.$this->tab_slug); |
|
| 662 | 662 | |
| 663 | - foreach ( $team_members as $team ) { |
|
| 664 | - add_post_meta( $id, 'team_to_' . $this->tab_slug, $team ); |
|
| 663 | + foreach ($team_members as $team) { |
|
| 664 | + add_post_meta($id, 'team_to_'.$this->tab_slug, $team); |
|
| 665 | 665 | } |
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | /** |
| 669 | 669 | * Saves the room data |
| 670 | 670 | */ |
| 671 | - public function set_travel_info( $data, $id, $meta_key ) { |
|
| 672 | - if ( ! empty( $data[0]['travel_information'] ) && isset( $data[0]['travel_information'][ $meta_key ] ) ) { |
|
| 673 | - $content = $data[0]['travel_information'][ $meta_key ]; |
|
| 674 | - $this->save_custom_field( $content, $meta_key, $id ); |
|
| 671 | + public function set_travel_info($data, $id, $meta_key) { |
|
| 672 | + if (!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])) { |
|
| 673 | + $content = $data[0]['travel_information'][$meta_key]; |
|
| 674 | + $this->save_custom_field($content, $meta_key, $id); |
|
| 675 | 675 | } |
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | /** |
| 679 | 679 | * Set the Travel Style |
| 680 | 680 | */ |
| 681 | - public function set_continent( $data, $id ) { |
|
| 682 | - if ( isset( $data[0]['position']['country'] ) ) { |
|
| 681 | + public function set_continent($data, $id) { |
|
| 682 | + if (isset($data[0]['position']['country'])) { |
|
| 683 | 683 | //get the continent code. |
| 684 | - $continent_code = to_continent_label( to_continent_code( to_country_data( $data[0]['position']['country'], false ) ) ); |
|
| 684 | + $continent_code = to_continent_label(to_continent_code(to_country_data($data[0]['position']['country'], false))); |
|
| 685 | 685 | |
| 686 | - if ( '' !== $continent_code ) { |
|
| 686 | + if ('' !== $continent_code) { |
|
| 687 | 687 | // @codingStandardsIgnoreLine |
| 688 | - if ( ! $term = term_exists( trim( $continent_code ), 'continent' ) ) { |
|
| 689 | - $term = wp_insert_term( trim( $continent_code ), 'continent' ); |
|
| 688 | + if (!$term = term_exists(trim($continent_code), 'continent')) { |
|
| 689 | + $term = wp_insert_term(trim($continent_code), 'continent'); |
|
| 690 | 690 | |
| 691 | - if ( is_wp_error( $term ) ) { |
|
| 691 | + if (is_wp_error($term)) { |
|
| 692 | 692 | // @codingStandardsIgnoreLine |
| 693 | 693 | echo $term->get_error_message(); |
| 694 | 694 | } |
| 695 | - } else { |
|
| 696 | - wp_set_object_terms( $id, intval( $term['term_id'] ), 'continent', true ); |
|
| 695 | + }else { |
|
| 696 | + wp_set_object_terms($id, intval($term['term_id']), 'continent', true); |
|
| 697 | 697 | } |
| 698 | - } else { |
|
| 699 | - wp_set_object_terms( $id, intval( $term['term_id'] ), 'continent', true ); |
|
| 698 | + }else { |
|
| 699 | + wp_set_object_terms($id, intval($term['term_id']), 'continent', true); |
|
| 700 | 700 | } |
| 701 | 701 | } |
| 702 | 702 | } |
@@ -649,6 +649,7 @@ discard block |
||
| 649 | 649 | |
| 650 | 650 | /** |
| 651 | 651 | * A loop which runs through each leg on the tour. |
| 652 | + * @param boolean $importable_content |
|
| 652 | 653 | */ |
| 653 | 654 | public function process_itineraries( $data, $id, $importable_content ) { |
| 654 | 655 | $day_counter = 1; |
@@ -949,6 +950,7 @@ discard block |
||
| 949 | 950 | * |
| 950 | 951 | * @param $day array |
| 951 | 952 | * @param $id string |
| 953 | + * @param integer $leg_counter |
|
| 952 | 954 | * @return boolean / string |
| 953 | 955 | */ |
| 954 | 956 | public function set_destination( $day, $id, $leg_counter ) { |
@@ -98,23 +98,23 @@ discard block |
||
| 98 | 98 | public function set_variables() { |
| 99 | 99 | parent::set_variables(); |
| 100 | 100 | |
| 101 | - if ( false !== $this->api_username && false !== $this->api_password ) { |
|
| 101 | + if (false !== $this->api_username && false !== $this->api_password) { |
|
| 102 | 102 | $this->url = 'https://wetu.com/API/Itinerary/'; |
| 103 | - $this->url_qs = 'username=' . $this->api_username . '&password=' . $this->api_password; |
|
| 104 | - } elseif ( false !== $this->api_key ) { |
|
| 105 | - $this->url = 'https://wetu.com/API/Itinerary/' . $this->api_key; |
|
| 103 | + $this->url_qs = 'username='.$this->api_username.'&password='.$this->api_password; |
|
| 104 | + } elseif (false !== $this->api_key) { |
|
| 105 | + $this->url = 'https://wetu.com/API/Itinerary/'.$this->api_key; |
|
| 106 | 106 | $this->url_qs = ''; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $temp_options = get_option( '_lsx-to_settings',false ); |
|
| 109 | + $temp_options = get_option('_lsx-to_settings', false); |
|
| 110 | 110 | |
| 111 | - if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) { |
|
| 112 | - $this->options = $temp_options[ $this->plugin_slug ]; |
|
| 111 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
| 112 | + $this->options = $temp_options[$this->plugin_slug]; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $tour_options = get_option( 'wetu_importer_tour_settings',false ); |
|
| 115 | + $tour_options = get_option('wetu_importer_tour_settings', false); |
|
| 116 | 116 | |
| 117 | - if ( false !== $tour_options ) { |
|
| 117 | + if (false !== $tour_options) { |
|
| 118 | 118 | $this->tour_options = $tour_options; |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -125,17 +125,17 @@ discard block |
||
| 125 | 125 | public function display_page() { |
| 126 | 126 | ?> |
| 127 | 127 | <div class="wrap"> |
| 128 | - <?php $this->navigation( 'tour' ); ?> |
|
| 128 | + <?php $this->navigation('tour'); ?> |
|
| 129 | 129 | |
| 130 | 130 | <?php $this->update_options_form(); ?> |
| 131 | 131 | |
| 132 | 132 | <?php $this->search_form(); ?> |
| 133 | 133 | |
| 134 | 134 | <form method="get" action="" id="posts-filter"> |
| 135 | - <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr( $this->tab_slug ); ?>" /> |
|
| 135 | + <input type="hidden" name="post_type" class="post_type" value="<?php echo esc_attr($this->tab_slug); ?>" /> |
|
| 136 | 136 | |
| 137 | - <p><input class="button button-primary add" type="button" value="<?php esc_html_e( 'Add to List','wetu-importer' ); ?>" /> |
|
| 138 | - <input class="button button-primary clear" type="button" value="<?php esc_html_e( 'Clear','wetu-importer' ); ?>" /> |
|
| 137 | + <p><input class="button button-primary add" type="button" value="<?php esc_html_e('Add to List', 'wetu-importer'); ?>" /> |
|
| 138 | + <input class="button button-primary clear" type="button" value="<?php esc_html_e('Clear', 'wetu-importer'); ?>" /> |
|
| 139 | 139 | </p> |
| 140 | 140 | |
| 141 | 141 | <table class="wp-list-table widefat fixed posts"> |
@@ -144,11 +144,11 @@ discard block |
||
| 144 | 144 | <tbody id="the-list"> |
| 145 | 145 | <tr class="post-0 type-tour status-none" id="post-0"> |
| 146 | 146 | <th class="check-column" scope="row"> |
| 147 | - <label for="cb-select-0" class="screen-reader-text"><?php esc_html_e( 'Enter a title to search for and press enter','wetu-importer' ); ?></label> |
|
| 147 | + <label for="cb-select-0" class="screen-reader-text"><?php esc_html_e('Enter a title to search for and press enter', 'wetu-importer'); ?></label> |
|
| 148 | 148 | </th> |
| 149 | 149 | <td class="post-title page-title column-title"> |
| 150 | 150 | <strong> |
| 151 | - <?php esc_html_e( 'Enter a title to search for','wetu-importer' ); ?> |
|
| 151 | + <?php esc_html_e('Enter a title to search for', 'wetu-importer'); ?> |
|
| 152 | 152 | </strong> |
| 153 | 153 | </td> |
| 154 | 154 | <td class="date column-date"> |
@@ -162,8 +162,8 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | </table> |
| 164 | 164 | |
| 165 | - <p><input class="button button-primary add" type="button" value="<?php esc_html_e( 'Add to List','wetu-importer' ); ?>" /> |
|
| 166 | - <input class="button button-primary clear" type="button" value="<?php esc_html_e( 'Clear','wetu-importer' ); ?>" /> |
|
| 165 | + <p><input class="button button-primary add" type="button" value="<?php esc_html_e('Add to List', 'wetu-importer'); ?>" /> |
|
| 166 | + <input class="button button-primary clear" type="button" value="<?php esc_html_e('Clear', 'wetu-importer'); ?>" /> |
|
| 167 | 167 | </p> |
| 168 | 168 | </form> |
| 169 | 169 | |
@@ -173,20 +173,20 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | <div class="row"> |
| 175 | 175 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 176 | - <h3><?php esc_html_e( 'What content to Sync from WETU' ); ?></h3> |
|
| 176 | + <h3><?php esc_html_e('What content to Sync from WETU'); ?></h3> |
|
| 177 | 177 | <ul> |
| 178 | - <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','wetu-importer' ); ?></li> |
|
| 178 | + <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', 'wetu-importer'); ?></li> |
|
| 179 | 179 | |
| 180 | - <?php if ( isset( $this->options ) && 'on' !== $this->options['disable_tour_descriptions'] ) { ?> |
|
| 181 | - <li><input class="content" <?php $this->checked( $this->tour_options,'description' ); ?> type="checkbox" name="content[]" value="description" /> <?php esc_html_e( 'Description','wetu-importer' ); ?></li> |
|
| 180 | + <?php if (isset($this->options) && 'on' !== $this->options['disable_tour_descriptions']) { ?> |
|
| 181 | + <li><input class="content" <?php $this->checked($this->tour_options, 'description'); ?> type="checkbox" name="content[]" value="description" /> <?php esc_html_e('Description', 'wetu-importer'); ?></li> |
|
| 182 | 182 | <?php } ?> |
| 183 | 183 | |
| 184 | - <li><input class="content" <?php $this->checked( $this->tour_options,'price' ); ?> type="checkbox" name="content[]" value="price" /> <?php esc_html_e( 'Price','wetu-importer' ); ?></li> |
|
| 185 | - <li><input class="content" <?php $this->checked( $this->tour_options,'duration' ); ?> type="checkbox" name="content[]" value="duration" /> <?php esc_html_e( 'Duration','wetu-importer' ); ?></li> |
|
| 184 | + <li><input class="content" <?php $this->checked($this->tour_options, 'price'); ?> type="checkbox" name="content[]" value="price" /> <?php esc_html_e('Price', 'wetu-importer'); ?></li> |
|
| 185 | + <li><input class="content" <?php $this->checked($this->tour_options, 'duration'); ?> type="checkbox" name="content[]" value="duration" /> <?php esc_html_e('Duration', 'wetu-importer'); ?></li> |
|
| 186 | 186 | |
| 187 | - <li><input class="content" <?php $this->checked( $this->tour_options,'category' ); ?> type="checkbox" name="content[]" value="category" /> <?php esc_html_e( 'Category','wetu-importer' ); ?></li> |
|
| 187 | + <li><input class="content" <?php $this->checked($this->tour_options, 'category'); ?> type="checkbox" name="content[]" value="category" /> <?php esc_html_e('Category', 'wetu-importer'); ?></li> |
|
| 188 | 188 | |
| 189 | - <li><input class="content" <?php $this->checked( $this->tour_options,'itineraries' ); ?> type="checkbox" name="content[]" value="itineraries" /> <?php esc_html_e( 'Itinerary Days','wetu-importer' ); ?></li> |
|
| 189 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itineraries'); ?> type="checkbox" name="content[]" value="itineraries" /> <?php esc_html_e('Itinerary Days', 'wetu-importer'); ?></li> |
|
| 190 | 190 | |
| 191 | 191 | <?php /*if(class_exists('LSX_TO_Maps')){ ?> |
| 192 | 192 | <li><input class="content" <?php $this->checked($this->tour_options,'map'); ?> type="checkbox" name="content[]" value="map" /> <?php esc_html_e('Map Coordinates (generates a KML file)','wetu-importer'); ?></li> |
@@ -194,33 +194,33 @@ discard block |
||
| 194 | 194 | </ul> |
| 195 | 195 | </div> |
| 196 | 196 | <div class="settings-all" style="width:30%;display:block;float:left;"> |
| 197 | - <h3><?php esc_html_e( 'Itinerary Info' ); ?></h3> |
|
| 197 | + <h3><?php esc_html_e('Itinerary Info'); ?></h3> |
|
| 198 | 198 | <ul> |
| 199 | - <li><input class="content" <?php $this->checked( $this->tour_options,'itinerary_description' ); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php esc_html_e( 'Description','wetu-importer' ); ?></li> |
|
| 200 | - <li><input class="content" <?php $this->checked( $this->tour_options,'itinerary_included' ); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php esc_html_e( 'Included','wetu-importer' ); ?></li> |
|
| 201 | - <li><input class="content" <?php $this->checked( $this->tour_options,'itinerary_excluded' ); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php esc_html_e( 'Excluded','wetu-importer' ); ?></li> |
|
| 199 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_description'); ?> type="checkbox" name="content[]" value="itinerary_description" /> <?php esc_html_e('Description', 'wetu-importer'); ?></li> |
|
| 200 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_included'); ?> type="checkbox" name="content[]" value="itinerary_included" /> <?php esc_html_e('Included', 'wetu-importer'); ?></li> |
|
| 201 | + <li><input class="content" <?php $this->checked($this->tour_options, 'itinerary_excluded'); ?> type="checkbox" name="content[]" value="itinerary_excluded" /> <?php esc_html_e('Excluded', 'wetu-importer'); ?></li> |
|
| 202 | 202 | </ul> |
| 203 | 203 | |
| 204 | - <h4><?php esc_html_e( 'Additional Content' ); ?></h4> |
|
| 204 | + <h4><?php esc_html_e('Additional Content'); ?></h4> |
|
| 205 | 205 | <ul> |
| 206 | - <li><input class="content" <?php $this->checked( $this->tour_options,'accommodation' ); ?> type="checkbox" name="content[]" value="accommodation" /> <?php esc_html_e( 'Sync Accommodation','wetu-importer' ); ?></li> |
|
| 207 | - <li><input class="content" <?php $this->checked( $this->tour_options,'destination' ); ?> type="checkbox" name="content[]" value="destination" /> <?php esc_html_e( 'Sync Destinations','wetu-importer' ); ?></li> |
|
| 208 | - <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','wetu-importer' ); ?></li> |
|
| 209 | - <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','wetu-importer' ); ?></li> |
|
| 206 | + <li><input class="content" <?php $this->checked($this->tour_options, 'accommodation'); ?> type="checkbox" name="content[]" value="accommodation" /> <?php esc_html_e('Sync Accommodation', 'wetu-importer'); ?></li> |
|
| 207 | + <li><input class="content" <?php $this->checked($this->tour_options, 'destination'); ?> type="checkbox" name="content[]" value="destination" /> <?php esc_html_e('Sync Destinations', 'wetu-importer'); ?></li> |
|
| 208 | + <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', 'wetu-importer'); ?></li> |
|
| 209 | + <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', 'wetu-importer'); ?></li> |
|
| 210 | 210 | </ul> |
| 211 | 211 | </div> |
| 212 | - <?php if ( class_exists( 'LSX_TO_Team' ) ) { ?> |
|
| 212 | + <?php if (class_exists('LSX_TO_Team')) { ?> |
|
| 213 | 213 | <div style="width:30%;display:block;float:left;"> |
| 214 | - <h3><?php esc_html_e( 'Assign a Team Member' ); ?></h3> |
|
| 215 | - <?php $this->team_member_checkboxes( $this->tour_options ); ?> |
|
| 214 | + <h3><?php esc_html_e('Assign a Team Member'); ?></h3> |
|
| 215 | + <?php $this->team_member_checkboxes($this->tour_options); ?> |
|
| 216 | 216 | </div> |
| 217 | 217 | <?php } ?> |
| 218 | 218 | |
| 219 | 219 | <br clear="both" /> |
| 220 | 220 | </div> |
| 221 | 221 | |
| 222 | - <h3><?php esc_html_e( 'Your List' ); ?></h3> |
|
| 223 | - <p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync','wetu-importer' ); ?>" /></p> |
|
| 222 | + <h3><?php esc_html_e('Your List'); ?></h3> |
|
| 223 | + <p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'wetu-importer'); ?>" /></p> |
|
| 224 | 224 | <table class="wp-list-table widefat fixed posts"> |
| 225 | 225 | <?php $this->table_header(); ?> |
| 226 | 226 | |
@@ -232,12 +232,12 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | </table> |
| 234 | 234 | |
| 235 | - <p><input class="button button-primary" type="submit" value="<?php esc_html_e( 'Sync','wetu-importer' ); ?>" /></p> |
|
| 235 | + <p><input class="button button-primary" type="submit" value="<?php esc_html_e('Sync', 'wetu-importer'); ?>" /></p> |
|
| 236 | 236 | </form> |
| 237 | 237 | </div> |
| 238 | 238 | |
| 239 | 239 | <div style="display:none;" class="completed-list-wrapper"> |
| 240 | - <h3><?php esc_html_e( 'Completed', 'wetu-importer' ); ?> - <small><?php esc_html_e( 'Import your', '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','wetu-importer' ); ?></small></h3> |
|
| 240 | + <h3><?php esc_html_e('Completed', 'wetu-importer'); ?> - <small><?php esc_html_e('Import your', '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', 'wetu-importer'); ?></small></h3> |
|
| 241 | 241 | <ul> |
| 242 | 242 | </ul> |
| 243 | 243 | </div> |
@@ -249,46 +249,46 @@ discard block |
||
| 249 | 249 | * search_form |
| 250 | 250 | */ |
| 251 | 251 | public function update_options_form() { |
| 252 | - $tours = get_transient( 'lsx_ti_tours' ); |
|
| 252 | + $tours = get_transient('lsx_ti_tours'); |
|
| 253 | 253 | |
| 254 | - echo '<div class="wetu-status tour-wetu-status"><h3>' . esc_html__( 'Wetu Status','wetu-importer' ) . ' - '; |
|
| 254 | + echo '<div class="wetu-status tour-wetu-status"><h3>'.esc_html__('Wetu Status', 'wetu-importer').' - '; |
|
| 255 | 255 | |
| 256 | - if ( '' === $tours || false === $tours || isset( $_GET['refresh_tours'] ) ) { |
|
| 256 | + if ('' === $tours || false === $tours || isset($_GET['refresh_tours'])) { |
|
| 257 | 257 | $result = $this->update_options(); |
| 258 | 258 | |
| 259 | - if ( true === $result ) { |
|
| 260 | - echo '<span style="color:green;">' . esc_attr( 'Connected','wetu-importer' ) . '</span>'; |
|
| 261 | - echo ' - <small><a href="#">' . esc_attr( 'Refresh','wetu-importer' ) . '</a></small>'; |
|
| 262 | - } else { |
|
| 263 | - echo '<span style="color:red;">' . wp_kses_post( $result ) . '</span>'; |
|
| 259 | + if (true === $result) { |
|
| 260 | + echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span>'; |
|
| 261 | + echo ' - <small><a href="#">'.esc_attr('Refresh', 'wetu-importer').'</a></small>'; |
|
| 262 | + }else { |
|
| 263 | + echo '<span style="color:red;">'.wp_kses_post($result).'</span>'; |
|
| 264 | 264 | } |
| 265 | - } else { |
|
| 266 | - echo '<span style="color:green;">' . esc_attr( 'Connected','wetu-importer' ) . '</span> - <small><a href="#">' . esc_attr( 'Refresh','wetu-importer' ) . '</a></small>'; |
|
| 265 | + }else { |
|
| 266 | + echo '<span style="color:green;">'.esc_attr('Connected', 'wetu-importer').'</span> - <small><a href="#">'.esc_attr('Refresh', 'wetu-importer').'</a></small>'; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | echo '</h3>'; |
| 270 | 270 | |
| 271 | - $form_options = get_option( 'lsx_ti_tours_api_options' ); |
|
| 272 | - if ( false === $form_options ) { |
|
| 273 | - $form_options = array( 0 ); |
|
| 271 | + $form_options = get_option('lsx_ti_tours_api_options'); |
|
| 272 | + if (false === $form_options) { |
|
| 273 | + $form_options = array(0); |
|
| 274 | 274 | } |
| 275 | 275 | ?> |
| 276 | - <form method="get" class="tour-refresh-form" action="<?php echo esc_attr( admin_url( 'admin.php' ) ); ?>"> |
|
| 277 | - <input type="hidden" name="page" value="<?php echo esc_attr( $this->plugin_slug ); ?>" /> |
|
| 276 | + <form method="get" class="tour-refresh-form" action="<?php echo esc_attr(admin_url('admin.php')); ?>"> |
|
| 277 | + <input type="hidden" name="page" value="<?php echo esc_attr($this->plugin_slug); ?>" /> |
|
| 278 | 278 | <input type="hidden" name="tab" value="tour" /> |
| 279 | 279 | <input type="hidden" name="refresh_tours" value="true" /> |
| 280 | 280 | |
| 281 | 281 | <p class="tour-search-options"> |
| 282 | - <label for="own"><input class="content" <?php if ( in_array( 'own',$form_options ) ) { echo 'checked'; } ?> type="checkbox" name="own" value="true" /> <?php esc_html_e( 'Own Tours','wetu-importer' ); ?> </label> |
|
| 282 | + <label for="own"><input class="content" <?php if (in_array('own', $form_options)) { echo 'checked'; } ?> type="checkbox" name="own" value="true" /> <?php esc_html_e('Own Tours', 'wetu-importer'); ?> </label> |
|
| 283 | 283 | </p> |
| 284 | 284 | |
| 285 | 285 | <p class="tour-search-options"> |
| 286 | - <label for="type"><input class="content" <?php if ( in_array( 'allitineraries',$form_options ) ) { echo 'checked'; } ?> type="radio" name="type[]" value="allitineraries" /> <?php esc_html_e( 'All','wetu-importer' ); ?></label> |
|
| 287 | - <label for="type"><input class="content" <?php if ( in_array( 'sample',$form_options ) ) { echo 'checked'; } ?> type="radio" name="type[]" value="sample" /> <?php esc_html_e( 'Sample','wetu-importer' ); ?></label> |
|
| 288 | - <label for="type"><input class="content" <?php if ( in_array( 'personal',$form_options ) ) { echo 'checked'; } ?> type="radio" name="type[]" value="personal" /> <?php esc_html_e( 'Personal','wetu-importer' ); ?></label> |
|
| 286 | + <label for="type"><input class="content" <?php if (in_array('allitineraries', $form_options)) { echo 'checked'; } ?> type="radio" name="type[]" value="allitineraries" /> <?php esc_html_e('All', 'wetu-importer'); ?></label> |
|
| 287 | + <label for="type"><input class="content" <?php if (in_array('sample', $form_options)) { echo 'checked'; } ?> type="radio" name="type[]" value="sample" /> <?php esc_html_e('Sample', 'wetu-importer'); ?></label> |
|
| 288 | + <label for="type"><input class="content" <?php if (in_array('personal', $form_options)) { echo 'checked'; } ?> type="radio" name="type[]" value="personal" /> <?php esc_html_e('Personal', 'wetu-importer'); ?></label> |
|
| 289 | 289 | </p> |
| 290 | 290 | |
| 291 | - <p><input class="button button-primary submit" type="submit" value="<?php echo esc_attr( 'Refresh Tours','wetu-importer' ); ?>"></p> |
|
| 291 | + <p><input class="button button-primary submit" type="submit" value="<?php echo esc_attr('Refresh Tours', 'wetu-importer'); ?>"></p> |
|
| 292 | 292 | </form> |
| 293 | 293 | <br /> |
| 294 | 294 | <?php |
@@ -302,30 +302,30 @@ discard block |
||
| 302 | 302 | $own = ''; |
| 303 | 303 | $options = array(); |
| 304 | 304 | |
| 305 | - delete_option( 'lsx_ti_tours_api_options' ); |
|
| 305 | + delete_option('lsx_ti_tours_api_options'); |
|
| 306 | 306 | |
| 307 | - if ( isset( $_GET['own'] ) ) { |
|
| 307 | + if (isset($_GET['own'])) { |
|
| 308 | 308 | $this->url_qs .= '&own=true'; |
| 309 | 309 | $options[] = 'own'; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - if ( isset( $_GET['type'] ) ) { |
|
| 313 | - $this->url_qs .= '&type=' . implode( '',$_GET['type'] ); |
|
| 314 | - $options[] = implode( '',$_GET['type'] ); |
|
| 312 | + if (isset($_GET['type'])) { |
|
| 313 | + $this->url_qs .= '&type='.implode('', $_GET['type']); |
|
| 314 | + $options[] = implode('', $_GET['type']); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | $this->url_qs .= '&results=2000'; |
| 318 | 318 | |
| 319 | - add_option( 'lsx_ti_tours_api_options',$options ); |
|
| 319 | + add_option('lsx_ti_tours_api_options', $options); |
|
| 320 | 320 | |
| 321 | - $data = file_get_contents( $this->url . '/V7/List?' . $this->url_qs ); |
|
| 321 | + $data = file_get_contents($this->url.'/V7/List?'.$this->url_qs); |
|
| 322 | 322 | |
| 323 | - $tours = json_decode( $data, true ); |
|
| 323 | + $tours = json_decode($data, true); |
|
| 324 | 324 | |
| 325 | - if ( isset( $tours['error'] ) ) { |
|
| 325 | + if (isset($tours['error'])) { |
|
| 326 | 326 | return $tours['error']; |
| 327 | - } elseif ( isset( $tours['itineraries'] ) && ! empty( $tours['itineraries'] ) ) { |
|
| 328 | - set_transient( 'lsx_ti_tours',$tours['itineraries'],60 * 60 * 2 ); |
|
| 327 | + } elseif (isset($tours['itineraries']) && !empty($tours['itineraries'])) { |
|
| 328 | + set_transient('lsx_ti_tours', $tours['itineraries'], 60 * 60 * 2); |
|
| 329 | 329 | return true; |
| 330 | 330 | } |
| 331 | 331 | } |
@@ -350,9 +350,9 @@ discard block |
||
| 350 | 350 | LIMIT 0,500 |
| 351 | 351 | "); |
| 352 | 352 | |
| 353 | - if ( null !== $current_tours && ! empty( $current_tours ) ) { |
|
| 354 | - foreach ( $current_tours as $tour ) { |
|
| 355 | - $return[ $tour->meta_value ] = $tour; |
|
| 353 | + if (null !== $current_tours && !empty($current_tours)) { |
|
| 354 | + foreach ($current_tours as $tour) { |
|
| 355 | + $return[$tour->meta_value] = $tour; |
|
| 356 | 356 | } |
| 357 | 357 | } |
| 358 | 358 | |
@@ -366,47 +366,47 @@ discard block |
||
| 366 | 366 | $return = false; |
| 367 | 367 | |
| 368 | 368 | // @codingStandardsIgnoreLine |
| 369 | - if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_tour_importer' && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug ) { |
|
| 370 | - $tours = get_transient( 'lsx_ti_tours' ); |
|
| 369 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug) { |
|
| 370 | + $tours = get_transient('lsx_ti_tours'); |
|
| 371 | 371 | |
| 372 | - if ( false !== $tours ) { |
|
| 372 | + if (false !== $tours) { |
|
| 373 | 373 | |
| 374 | 374 | $searched_items = false; |
| 375 | 375 | |
| 376 | 376 | // @codingStandardsIgnoreLine |
| 377 | - if ( isset( $_POST['keyword'] ) ) { |
|
| 377 | + if (isset($_POST['keyword'])) { |
|
| 378 | 378 | // @codingStandardsIgnoreLine |
| 379 | 379 | $keyphrases = $_POST['keyword']; |
| 380 | - } else { |
|
| 381 | - $keyphrases = array( 0 ); |
|
| 380 | + }else { |
|
| 381 | + $keyphrases = array(0); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | - if ( ! is_array( $keyphrases ) ) { |
|
| 385 | - $keyphrases = array( $keyphrases ); |
|
| 384 | + if (!is_array($keyphrases)) { |
|
| 385 | + $keyphrases = array($keyphrases); |
|
| 386 | 386 | } |
| 387 | - foreach ( $keyphrases as &$keyword ) { |
|
| 388 | - $keyword = ltrim( rtrim( $keyword ) ); |
|
| 387 | + foreach ($keyphrases as &$keyword) { |
|
| 388 | + $keyword = ltrim(rtrim($keyword)); |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | $post_status = false; |
| 392 | - if ( in_array( 'publish',$keyphrases ) ) { |
|
| 392 | + if (in_array('publish', $keyphrases)) { |
|
| 393 | 393 | $post_status = 'publish'; |
| 394 | 394 | } |
| 395 | - if ( in_array( 'pending',$keyphrases ) ) { |
|
| 395 | + if (in_array('pending', $keyphrases)) { |
|
| 396 | 396 | $post_status = 'pending'; |
| 397 | 397 | } |
| 398 | - if ( in_array( 'draft',$keyphrases ) ) { |
|
| 398 | + if (in_array('draft', $keyphrases)) { |
|
| 399 | 399 | $post_status = 'draft'; |
| 400 | 400 | } |
| 401 | - if ( in_array( 'import',$keyphrases ) ) { |
|
| 401 | + if (in_array('import', $keyphrases)) { |
|
| 402 | 402 | $post_status = 'import'; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - if ( ! empty( $tours ) ) { |
|
| 405 | + if (!empty($tours)) { |
|
| 406 | 406 | $current_tours = $this->find_current_tours(); |
| 407 | 407 | |
| 408 | - foreach ( $tours as $row_key => $row ) { |
|
| 409 | - if ( isset( $row['is_disabled'] ) && true === $row['is_disabled'] ) { |
|
| 408 | + foreach ($tours as $row_key => $row) { |
|
| 409 | + if (isset($row['is_disabled']) && true === $row['is_disabled']) { |
|
| 410 | 410 | continue; |
| 411 | 411 | } |
| 412 | 412 | |
@@ -417,56 +417,56 @@ discard block |
||
| 417 | 417 | //If this is a current tour, add its ID to the row. |
| 418 | 418 | $row['post_id'] = 0; |
| 419 | 419 | |
| 420 | - if ( false !== $current_tours && array_key_exists( $row['identifier'], $current_tours ) ) { |
|
| 421 | - $row['post_id'] = $current_tours[ $row['identifier'] ]->post_id; |
|
| 420 | + if (false !== $current_tours && array_key_exists($row['identifier'], $current_tours)) { |
|
| 421 | + $row['post_id'] = $current_tours[$row['identifier']]->post_id; |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | //If we are searching for |
| 425 | - if ( false !== $post_status ) { |
|
| 426 | - if ( 'import' === $post_status ) { |
|
| 425 | + if (false !== $post_status) { |
|
| 426 | + if ('import' === $post_status) { |
|
| 427 | 427 | |
| 428 | - if ( 0 !== $row['post_id'] ) { |
|
| 428 | + if (0 !== $row['post_id']) { |
|
| 429 | 429 | continue; |
| 430 | - } else { |
|
| 431 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row ); |
|
| 430 | + }else { |
|
| 431 | + $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
|
| 432 | 432 | } |
| 433 | - } else { |
|
| 434 | - if ( 0 === $row['post_id'] ) { |
|
| 433 | + }else { |
|
| 434 | + if (0 === $row['post_id']) { |
|
| 435 | 435 | continue; |
| 436 | - } else { |
|
| 437 | - $current_status = get_post_status( $row['post_id'] ); |
|
| 436 | + }else { |
|
| 437 | + $current_status = get_post_status($row['post_id']); |
|
| 438 | 438 | |
| 439 | - if ( $current_status !== $post_status ) { |
|
| 439 | + if ($current_status !== $post_status) { |
|
| 440 | 440 | continue; |
| 441 | 441 | } |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row ); |
|
| 444 | + $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
|
| 445 | 445 | } |
| 446 | - } else { |
|
| 446 | + }else { |
|
| 447 | 447 | //Search through each keyword. |
| 448 | - foreach ( $keyphrases as $keyphrase ) { |
|
| 448 | + foreach ($keyphrases as $keyphrase) { |
|
| 449 | 449 | |
| 450 | 450 | //Make sure the keyphrase is turned into an array |
| 451 | - $keywords = explode( ' ',$keyphrase ); |
|
| 452 | - if ( ! is_array( $keywords ) ) { |
|
| 453 | - $keywords = array( $keywords ); |
|
| 451 | + $keywords = explode(' ', $keyphrase); |
|
| 452 | + if (!is_array($keywords)) { |
|
| 453 | + $keywords = array($keywords); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - if ( $this->multineedle_stripos( ltrim( rtrim( $row['name'] ) ), $keywords ) !== false ) { |
|
| 457 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['identifier'] ] = $this->format_row( $row ); |
|
| 456 | + if ($this->multineedle_stripos(ltrim(rtrim($row['name'])), $keywords) !== false) { |
|
| 457 | + $searched_items[sanitize_title($row['name']).'-'.$row['identifier']] = $this->format_row($row); |
|
| 458 | 458 | } |
| 459 | 459 | } |
| 460 | 460 | } |
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - if ( false !== $searched_items ) { |
|
| 465 | - ksort( $searched_items ); |
|
| 466 | - $return = implode( $searched_items ); |
|
| 464 | + if (false !== $searched_items) { |
|
| 465 | + ksort($searched_items); |
|
| 466 | + $return = implode($searched_items); |
|
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | - print_r( $return ); |
|
| 469 | + print_r($return); |
|
| 470 | 470 | die(); |
| 471 | 471 | } |
| 472 | 472 | } |
@@ -474,28 +474,28 @@ discard block |
||
| 474 | 474 | /** |
| 475 | 475 | * Formats the row for output on the screen. |
| 476 | 476 | */ |
| 477 | - public function format_row( $row = false ) { |
|
| 478 | - if ( false !== $row ) { |
|
| 477 | + public function format_row($row = false) { |
|
| 478 | + if (false !== $row) { |
|
| 479 | 479 | $status = 'import'; |
| 480 | 480 | |
| 481 | - if ( 0 !== $row['post_id'] ) { |
|
| 482 | - $status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>'; |
|
| 481 | + if (0 !== $row['post_id']) { |
|
| 482 | + $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | $row_html = ' |
| 486 | - <tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '"> |
|
| 486 | + <tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'"> |
|
| 487 | 487 | <th class="check-column" scope="row"> |
| 488 | - <label for="cb-select-' . $row['identifier'] . '" class="screen-reader-text">' . $row['name'] . '</label> |
|
| 489 | - <input type="checkbox" data-identifier="' . $row['identifier'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['identifier'] . '"> |
|
| 488 | + <label for="cb-select-' . $row['identifier'].'" class="screen-reader-text">'.$row['name'].'</label> |
|
| 489 | + <input type="checkbox" data-identifier="' . $row['identifier'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['identifier'].'"> |
|
| 490 | 490 | </th> |
| 491 | 491 | <td class="post-title page-title column-title"> |
| 492 | - <strong>' . $row['name'] . '</strong> - ' . $status . ' |
|
| 492 | + <strong>' . $row['name'].'</strong> - '.$status.' |
|
| 493 | 493 | </td> |
| 494 | 494 | <td class="date column-date"> |
| 495 | - <abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified |
|
| 495 | + <abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
| 496 | 496 | </td> |
| 497 | 497 | <td class="ssid column-ssid"> |
| 498 | - ' . $row['identifier'] . ' |
|
| 498 | + ' . $row['identifier'].' |
|
| 499 | 499 | </td> |
| 500 | 500 | </tr>'; |
| 501 | 501 | return $row_html; |
@@ -505,50 +505,50 @@ discard block |
||
| 505 | 505 | /** |
| 506 | 506 | * Connect to wetu |
| 507 | 507 | */ |
| 508 | - public function process_ajax_import( $force = false ) { |
|
| 508 | + public function process_ajax_import($force = false) { |
|
| 509 | 509 | $return = false; |
| 510 | 510 | |
| 511 | 511 | // @codingStandardsIgnoreLine |
| 512 | - if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === $this->tab_slug && isset( $_POST['wetu_id'] ) ) { |
|
| 512 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === $this->tab_slug && isset($_POST['wetu_id'])) { |
|
| 513 | 513 | |
| 514 | 514 | // @codingStandardsIgnoreLine |
| 515 | 515 | $wetu_id = $_POST['wetu_id']; |
| 516 | 516 | |
| 517 | 517 | // @codingStandardsIgnoreLine |
| 518 | - if ( isset( $_POST['post_id'] ) ) { |
|
| 518 | + if (isset($_POST['post_id'])) { |
|
| 519 | 519 | // @codingStandardsIgnoreLine |
| 520 | 520 | $post_id = $_POST['post_id']; |
| 521 | - } else { |
|
| 521 | + }else { |
|
| 522 | 522 | $post_id = 0; |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | - delete_option( 'wetu_importer_tour_settings' ); |
|
| 525 | + delete_option('wetu_importer_tour_settings'); |
|
| 526 | 526 | |
| 527 | 527 | // @codingStandardsIgnoreLine |
| 528 | - if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) { |
|
| 528 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
| 529 | 529 | // @codingStandardsIgnoreLine |
| 530 | 530 | $content = $_POST['content']; |
| 531 | - add_option( 'wetu_importer_tour_settings',$content ); |
|
| 532 | - } else { |
|
| 531 | + add_option('wetu_importer_tour_settings', $content); |
|
| 532 | + }else { |
|
| 533 | 533 | $content = false; |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | - $jdata = file_get_contents( 'http://wetu.com/API/Itinerary/V7/Get?id=' . $wetu_id ); |
|
| 536 | + $jdata = file_get_contents('http://wetu.com/API/Itinerary/V7/Get?id='.$wetu_id); |
|
| 537 | 537 | |
| 538 | - if ( $jdata ) { |
|
| 539 | - $jdata = json_decode( $jdata,true ); |
|
| 540 | - if ( ! empty( $jdata ) && ! isset( $jdata['error'] ) ) { |
|
| 541 | - $return = $this->import_row( $jdata,$wetu_id,$post_id,$content ); |
|
| 542 | - $this->format_completed_row( $return ); |
|
| 538 | + if ($jdata) { |
|
| 539 | + $jdata = json_decode($jdata, true); |
|
| 540 | + if (!empty($jdata) && !isset($jdata['error'])) { |
|
| 541 | + $return = $this->import_row($jdata, $wetu_id, $post_id, $content); |
|
| 542 | + $this->format_completed_row($return); |
|
| 543 | 543 | $this->save_queue(); |
| 544 | 544 | $this->cleanup_posts(); |
| 545 | - $this->attach_destination_images( $content ); |
|
| 546 | - $this->clean_attached_destinations( $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 tour, please try refreshing the page.','wetu-importer' ) ); |
|
| 545 | + $this->attach_destination_images($content); |
|
| 546 | + $this->clean_attached_destinations($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 tour, please try refreshing the page.', 'wetu-importer')); |
|
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | 554 | } |
@@ -561,13 +561,13 @@ discard block |
||
| 561 | 561 | * @param $id string |
| 562 | 562 | * @return void |
| 563 | 563 | */ |
| 564 | - public function clean_attached_destinations( $id ) { |
|
| 565 | - $current_connections = get_post_meta( $id, 'destination_to_tour', false ); |
|
| 566 | - delete_post_meta( $id,'destination_to_tour' ); |
|
| 567 | - $current_connections = array_unique( $current_connections ); |
|
| 564 | + public function clean_attached_destinations($id) { |
|
| 565 | + $current_connections = get_post_meta($id, 'destination_to_tour', false); |
|
| 566 | + delete_post_meta($id, 'destination_to_tour'); |
|
| 567 | + $current_connections = array_unique($current_connections); |
|
| 568 | 568 | |
| 569 | - foreach ( $current_connections as $connection ) { |
|
| 570 | - add_post_meta( $id, 'destination_to_tour',$connection, false ); |
|
| 569 | + foreach ($current_connections as $connection) { |
|
| 570 | + add_post_meta($id, 'destination_to_tour', $connection, false); |
|
| 571 | 571 | } |
| 572 | 572 | } |
| 573 | 573 | |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | * @param $data array |
| 578 | 578 | * @param $wetu_id string |
| 579 | 579 | */ |
| 580 | - public function import_row( $data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false ) { |
|
| 580 | + public function import_row($data, $wetu_id, $id = 0, $importable_content = false, $old1 = false, $old2 = false) { |
|
| 581 | 581 | $post_name = ''; |
| 582 | 582 | $data_post_content = ''; |
| 583 | 583 | $data_post_excerpt = ''; |
@@ -589,12 +589,12 @@ discard block |
||
| 589 | 589 | //Set the post_content |
| 590 | 590 | $content_used_general_description = false; |
| 591 | 591 | |
| 592 | - if ( false !== $importable_content && in_array( 'description',$importable_content ) ) { |
|
| 592 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
| 593 | 593 | $data_post_content = ''; |
| 594 | 594 | |
| 595 | - if ( isset( $data['description'] ) ) { |
|
| 595 | + if (isset($data['description'])) { |
|
| 596 | 596 | $data_post_content = $data['description']; |
| 597 | - } elseif ( isset( $data['summary'] ) ) { |
|
| 597 | + } elseif (isset($data['summary'])) { |
|
| 598 | 598 | $data_post_content = $data['summary']; |
| 599 | 599 | } |
| 600 | 600 | |
@@ -602,46 +602,46 @@ discard block |
||
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | //Create or update the post |
| 605 | - if ( false !== $id && '0' !== $id ) { |
|
| 605 | + if (false !== $id && '0' !== $id) { |
|
| 606 | 606 | $post['ID'] = $id; |
| 607 | 607 | $post['post_status'] = 'publish'; |
| 608 | - $id = wp_update_post( $post ); |
|
| 609 | - $prev_date = get_post_meta( $id,'lsx_wetu_modified_date',true ); |
|
| 610 | - update_post_meta( $id,'lsx_wetu_modified_date',strtotime( $data['last_modified'] ),$prev_date ); |
|
| 611 | - } else { |
|
| 608 | + $id = wp_update_post($post); |
|
| 609 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
| 610 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']), $prev_date); |
|
| 611 | + }else { |
|
| 612 | 612 | //Set the name |
| 613 | - if ( isset( $data['name'] ) ) { |
|
| 614 | - $post_name = wp_unique_post_slug( sanitize_title( $data['name'] ),$id, 'draft', 'tour', 0 ); |
|
| 613 | + if (isset($data['name'])) { |
|
| 614 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0); |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | $post['post_name'] = $post_name; |
| 618 | 618 | $post['post_title'] = $data['name']; |
| 619 | 619 | $post['post_status'] = 'publish'; |
| 620 | - $id = wp_insert_post( $post ); |
|
| 620 | + $id = wp_insert_post($post); |
|
| 621 | 621 | |
| 622 | 622 | //Save the WETU ID and the Last date it was modified. |
| 623 | - if ( false !== $id ) { |
|
| 624 | - add_post_meta( $id,'lsx_wetu_id',$wetu_id ); |
|
| 625 | - add_post_meta( $id,'lsx_wetu_modified_date',strtotime( $data['last_modified'] ) ); |
|
| 623 | + if (false !== $id) { |
|
| 624 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
| 625 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified'])); |
|
| 626 | 626 | } |
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | //Set the price |
| 630 | - if ( false !== $importable_content && in_array( 'price',$importable_content ) ) { |
|
| 631 | - $this->set_price( $data,$id ); |
|
| 630 | + if (false !== $importable_content && in_array('price', $importable_content)) { |
|
| 631 | + $this->set_price($data, $id); |
|
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | //Set the Duration |
| 635 | - if ( false !== $importable_content && in_array( 'duration',$importable_content ) ) { |
|
| 636 | - $this->set_duration( $data,$id ); |
|
| 635 | + if (false !== $importable_content && in_array('duration', $importable_content)) { |
|
| 636 | + $this->set_duration($data, $id); |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | - if ( false !== $importable_content && in_array( 'itineraries',$importable_content ) && isset( $data['legs'] ) && ! empty( $data['legs'] ) ) { |
|
| 640 | - $this->process_itineraries( $data,$id,$importable_content ); |
|
| 639 | + if (false !== $importable_content && in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) { |
|
| 640 | + $this->process_itineraries($data, $id, $importable_content); |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | - if ( in_array( 'map',$importable_content ) && isset( $data['routes'] ) && ! empty( $data['routes'] ) ) { |
|
| 644 | - $this->set_map_data( $data,$id ); |
|
| 643 | + if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) { |
|
| 644 | + $this->set_map_data($data, $id); |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | return $id; |
@@ -650,197 +650,197 @@ discard block |
||
| 650 | 650 | /** |
| 651 | 651 | * A loop which runs through each leg on the tour. |
| 652 | 652 | */ |
| 653 | - public function process_itineraries( $data, $id, $importable_content ) { |
|
| 653 | + public function process_itineraries($data, $id, $importable_content) { |
|
| 654 | 654 | $day_counter = 1; |
| 655 | 655 | $leg_counter = 0; |
| 656 | 656 | |
| 657 | - delete_post_meta( $id,'itinerary' ); |
|
| 657 | + delete_post_meta($id, 'itinerary'); |
|
| 658 | 658 | |
| 659 | - if ( false !== $importable_content && in_array( 'accommodation',$importable_content ) ) { |
|
| 660 | - delete_post_meta( $id,'accommodation_to_tour' ); |
|
| 659 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
| 660 | + delete_post_meta($id, 'accommodation_to_tour'); |
|
| 661 | 661 | } |
| 662 | - if ( false !== $importable_content && in_array( 'destination',$importable_content ) ) { |
|
| 662 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
| 663 | 663 | //delete_post_meta($id,'destination_to_tour'); |
| 664 | - delete_post_meta( $id,'departs_from' ); |
|
| 665 | - delete_post_meta( $id,'ends_in' ); |
|
| 664 | + delete_post_meta($id, 'departs_from'); |
|
| 665 | + delete_post_meta($id, 'ends_in'); |
|
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | $departs_from = false; |
| 669 | 669 | $ends_in = false; |
| 670 | 670 | |
| 671 | - foreach ( $data['legs'] as $leg ) { |
|
| 671 | + foreach ($data['legs'] as $leg) { |
|
| 672 | 672 | //Itinerary Accommodation |
| 673 | 673 | $current_accommodation = false; |
| 674 | - if ( false !== $importable_content && in_array( 'accommodation',$importable_content ) ) { |
|
| 675 | - $current_accommodation = $this->set_accommodation( $leg,$id ); |
|
| 674 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
| 675 | + $current_accommodation = $this->set_accommodation($leg, $id); |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | //Itinerary Destination |
| 679 | 679 | $current_destination = false; |
| 680 | - if ( false !== $importable_content && in_array( 'destination',$importable_content ) ) { |
|
| 681 | - $current_destination = $this->set_destination( $leg,$id,$leg_counter ); |
|
| 680 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
| 681 | + $current_destination = $this->set_destination($leg, $id, $leg_counter); |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | //If the Nights are the same mount of days in the array, then it isnt "By Destination" |
| 685 | - if ( ((1 <= (int) $leg['nights'] && isset( $leg['days'] ))) || 0 === $leg['itinerary_leg_id'] ) { |
|
| 686 | - foreach ( $leg['days'] as $day ) { |
|
| 685 | + if (((1 <= (int) $leg['nights'] && isset($leg['days']))) || 0 === $leg['itinerary_leg_id']) { |
|
| 686 | + foreach ($leg['days'] as $day) { |
|
| 687 | 687 | $current_day = array(); |
| 688 | - $current_day['title'] = esc_attr( 'Day ', 'wetu-importer' ) . $day_counter; |
|
| 688 | + $current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter; |
|
| 689 | 689 | |
| 690 | 690 | //print_r('<pre>');print_r($day['notes']);print_r('</pre>'); |
| 691 | 691 | |
| 692 | 692 | //Description |
| 693 | - if ( false !== $importable_content && in_array( 'itinerary_description',$importable_content ) && isset( $day['notes'] ) ) { |
|
| 693 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) { |
|
| 694 | 694 | $current_day['description'] = $day['notes']; |
| 695 | - } else { |
|
| 695 | + }else { |
|
| 696 | 696 | $current_day['description'] = ''; |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | //Itinerary Gallery |
| 700 | - if ( false !== $importable_content && in_array( 'itinerary_gallery',$importable_content ) && isset( $day['images'] ) ) { |
|
| 700 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) { |
|
| 701 | 701 | $current_day['featured_image'] = ''; |
| 702 | - } else { |
|
| 702 | + }else { |
|
| 703 | 703 | $current_day['featured_image'] = ''; |
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | //Accommodation |
| 707 | - if ( false !== $current_accommodation ) { |
|
| 708 | - $current_day['accommodation_to_tour'] = array( $current_accommodation ); |
|
| 709 | - } else { |
|
| 707 | + if (false !== $current_accommodation) { |
|
| 708 | + $current_day['accommodation_to_tour'] = array($current_accommodation); |
|
| 709 | + }else { |
|
| 710 | 710 | $current_day['accommodation_to_tour'] = array(); |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | //Destination |
| 714 | - if ( false !== $current_destination ) { |
|
| 715 | - $current_day['destination_to_tour'] = array( $current_destination ); |
|
| 716 | - } else { |
|
| 714 | + if (false !== $current_destination) { |
|
| 715 | + $current_day['destination_to_tour'] = array($current_destination); |
|
| 716 | + }else { |
|
| 717 | 717 | $current_day['destination_to_tour'] = array(); |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | //Included |
| 721 | - if ( false !== $importable_content && in_array( 'itinerary_included',$importable_content ) && isset( $day['included'] ) && '' !== $day['included'] ) { |
|
| 721 | + if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) { |
|
| 722 | 722 | $current_day['included'] = $day['included']; |
| 723 | - } else { |
|
| 723 | + }else { |
|
| 724 | 724 | $current_day['included'] = ''; |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | //Excluded |
| 728 | - if ( false !== $importable_content && in_array( 'itinerary_excluded',$importable_content ) && isset( $day['excluded'] ) && '' !== $day['excluded'] ) { |
|
| 728 | + if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) { |
|
| 729 | 729 | $current_day['excluded'] = $day['excluded']; |
| 730 | - } else { |
|
| 730 | + }else { |
|
| 731 | 731 | $current_day['excluded'] = ''; |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | - $this->set_itinerary_day( $current_day,$id ); |
|
| 734 | + $this->set_itinerary_day($current_day, $id); |
|
| 735 | 735 | $day_counter++; |
| 736 | 736 | } |
| 737 | - } else { |
|
| 737 | + }else { |
|
| 738 | 738 | // This is for the by destination |
| 739 | 739 | |
| 740 | 740 | $current_day = array(); |
| 741 | 741 | $next_day_count = $day_counter + (int) $leg['nights']; |
| 742 | - $day_count_label = $next_day_count -1; |
|
| 742 | + $day_count_label = $next_day_count - 1; |
|
| 743 | 743 | |
| 744 | - $current_day['title'] = esc_attr( 'Day ','wetu-importer' ) . $day_counter; |
|
| 744 | + $current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter; |
|
| 745 | 745 | |
| 746 | - if ( 0 !== (int) $leg['nights'] ) { |
|
| 747 | - $current_day['title'] .= ' - ' . $day_count_label; |
|
| 746 | + if (0 !== (int) $leg['nights']) { |
|
| 747 | + $current_day['title'] .= ' - '.$day_count_label; |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | //Description |
| 751 | - if ( false !== $importable_content && in_array( 'itinerary_description',$importable_content ) && isset( $leg['notes'] ) ) { |
|
| 751 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($leg['notes'])) { |
|
| 752 | 752 | $current_day['description'] = $leg['notes']; |
| 753 | - } else { |
|
| 753 | + }else { |
|
| 754 | 754 | $current_day['description'] = ''; |
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | //Itinerary Gallery |
| 758 | - if ( false !== $importable_content && in_array( 'itinerary_gallery',$importable_content ) && isset( $leg['images'] ) ) { |
|
| 758 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($leg['images'])) { |
|
| 759 | 759 | $current_day['featured_image'] = ''; |
| 760 | - } else { |
|
| 760 | + }else { |
|
| 761 | 761 | $current_day['featured_image'] = ''; |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | //Accommodation |
| 765 | - if ( false !== $current_accommodation ) { |
|
| 766 | - $current_day['accommodation_to_tour'] = array( $current_accommodation ); |
|
| 767 | - } else { |
|
| 765 | + if (false !== $current_accommodation) { |
|
| 766 | + $current_day['accommodation_to_tour'] = array($current_accommodation); |
|
| 767 | + }else { |
|
| 768 | 768 | $current_day['accommodation_to_tour'] = array(); |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | //Destination |
| 772 | - if ( false !== $current_destination ) { |
|
| 773 | - $current_day['destination_to_tour'] = array( $current_destination ); |
|
| 774 | - } else { |
|
| 772 | + if (false !== $current_destination) { |
|
| 773 | + $current_day['destination_to_tour'] = array($current_destination); |
|
| 774 | + }else { |
|
| 775 | 775 | $current_day['destination_to_tour'] = array(); |
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | //Included |
| 779 | - if ( false !== $importable_content && in_array( 'itinerary_included',$importable_content ) && isset( $leg['included'] ) && '' !== $leg['included'] ) { |
|
| 779 | + if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($leg['included']) && '' !== $leg['included']) { |
|
| 780 | 780 | $current_day['included'] = $leg['included']; |
| 781 | - } else { |
|
| 781 | + }else { |
|
| 782 | 782 | $current_day['included'] = ''; |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | //Excluded |
| 786 | - if ( false !== $importable_content && in_array( 'itinerary_excluded',$importable_content ) && isset( $leg['excluded'] ) && '' !== $leg['excluded'] ) { |
|
| 786 | + if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($leg['excluded']) && '' !== $leg['excluded']) { |
|
| 787 | 787 | $current_day['excluded'] = $leg['excluded']; |
| 788 | - } else { |
|
| 788 | + }else { |
|
| 789 | 789 | $current_day['excluded'] = ''; |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | - $this->set_itinerary_day( $current_day,$id ); |
|
| 792 | + $this->set_itinerary_day($current_day, $id); |
|
| 793 | 793 | $day_counter = $next_day_count; |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | //If we are in the first leg, and the destination was attached then save it as the departure field. |
| 797 | - if ( 0 === $leg_counter && false !== $current_destination ) { |
|
| 797 | + if (0 === $leg_counter && false !== $current_destination) { |
|
| 798 | 798 | $departs_from = $current_destination; |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | //If its the last leg then save it as the ends in. |
| 802 | 802 | // @codingStandardsIgnoreLine |
| 803 | - if ( $leg_counter === (count( $data['legs'] ) -2) && false !== $current_destination ) { |
|
| 803 | + if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) { |
|
| 804 | 804 | $ends_in = $current_destination; |
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | $leg_counter++; |
| 808 | 808 | } |
| 809 | 809 | |
| 810 | - if ( false !== $departs_from ) { |
|
| 811 | - add_post_meta( $id,'departs_from',$departs_from,true ); |
|
| 810 | + if (false !== $departs_from) { |
|
| 811 | + add_post_meta($id, 'departs_from', $departs_from, true); |
|
| 812 | 812 | } |
| 813 | - if ( false !== $ends_in ) { |
|
| 814 | - add_post_meta( $id,'ends_in',$ends_in,true ); |
|
| 813 | + if (false !== $ends_in) { |
|
| 814 | + add_post_meta($id, 'ends_in', $ends_in, true); |
|
| 815 | 815 | } |
| 816 | 816 | } |
| 817 | 817 | |
| 818 | 818 | /** |
| 819 | 819 | * Run through your routes and save the points as a KML file. |
| 820 | 820 | */ |
| 821 | - public function set_map_data( $data, $id, $zoom = 9 ) { |
|
| 822 | - if ( ! empty( $data['routes'] ) ) { |
|
| 823 | - delete_post_meta( $id,'wetu_map_points' ); |
|
| 821 | + public function set_map_data($data, $id, $zoom = 9) { |
|
| 822 | + if (!empty($data['routes'])) { |
|
| 823 | + delete_post_meta($id, 'wetu_map_points'); |
|
| 824 | 824 | |
| 825 | 825 | $points = array(); |
| 826 | 826 | |
| 827 | - foreach ( $data['routes'] as $route ) { |
|
| 827 | + foreach ($data['routes'] as $route) { |
|
| 828 | 828 | |
| 829 | - if ( isset( $route['points'] ) && '' !== $route['points'] ) { |
|
| 829 | + if (isset($route['points']) && '' !== $route['points']) { |
|
| 830 | 830 | |
| 831 | - $temp_points = explode( ';',$route['points'] ); |
|
| 832 | - $point_counter = count( $temp_points ); |
|
| 831 | + $temp_points = explode(';', $route['points']); |
|
| 832 | + $point_counter = count($temp_points); |
|
| 833 | 833 | |
| 834 | - for ( $x = 0; $x <= $point_counter; $x++ ) { |
|
| 834 | + for ($x = 0; $x <= $point_counter; $x++) { |
|
| 835 | 835 | $y = $x + 1; |
| 836 | - $points[] = $temp_points[ $x ] . ',' . $temp_points[ $y ]; |
|
| 836 | + $points[] = $temp_points[$x].','.$temp_points[$y]; |
|
| 837 | 837 | $x++; |
| 838 | 838 | } |
| 839 | 839 | } |
| 840 | 840 | } |
| 841 | 841 | |
| 842 | - if ( ! empty( $points ) ) { |
|
| 843 | - $this->save_custom_field( implode( ' ',$points ),'wetu_map_points',$id,false,true ); |
|
| 842 | + if (!empty($points)) { |
|
| 843 | + $this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true); |
|
| 844 | 844 | } |
| 845 | 845 | } |
| 846 | 846 | |
@@ -851,66 +851,66 @@ discard block |
||
| 851 | 851 | /** |
| 852 | 852 | * Set the Itinerary Day |
| 853 | 853 | */ |
| 854 | - public function set_itinerary_day( $day, $id ) { |
|
| 855 | - $this->save_custom_field( $day,'itinerary',$id,false,false ); |
|
| 854 | + public function set_itinerary_day($day, $id) { |
|
| 855 | + $this->save_custom_field($day, 'itinerary', $id, false, false); |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | /** |
| 859 | 859 | * Set the price |
| 860 | 860 | */ |
| 861 | - public function set_price( $data, $id ) { |
|
| 861 | + public function set_price($data, $id) { |
|
| 862 | 862 | //Price |
| 863 | - if ( isset( $data['price'] ) && '' !== $data['price'] ) { |
|
| 864 | - $price = preg_replace( '/[^0-9,.]/', '', $data['price'] ); |
|
| 865 | - $this->save_custom_field( $price,'price',$id ); |
|
| 863 | + if (isset($data['price']) && '' !== $data['price']) { |
|
| 864 | + $price = preg_replace('/[^0-9,.]/', '', $data['price']); |
|
| 865 | + $this->save_custom_field($price, 'price', $id); |
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | //Price includes |
| 869 | - if ( isset( $data['price_includes'] ) && '' !== $data['price_includes'] ) { |
|
| 870 | - $this->save_custom_field( $data['price_includes'],'included',$id ); |
|
| 869 | + if (isset($data['price_includes']) && '' !== $data['price_includes']) { |
|
| 870 | + $this->save_custom_field($data['price_includes'], 'included', $id); |
|
| 871 | 871 | } |
| 872 | 872 | |
| 873 | 873 | //Price Excludes |
| 874 | - if ( isset( $data['price_excludes'] ) && '' !== $data['price_excludes'] ) { |
|
| 875 | - $this->save_custom_field( $data['price_excludes'],'not_included',$id ); |
|
| 874 | + if (isset($data['price_excludes']) && '' !== $data['price_excludes']) { |
|
| 875 | + $this->save_custom_field($data['price_excludes'], 'not_included', $id); |
|
| 876 | 876 | } |
| 877 | 877 | } |
| 878 | 878 | |
| 879 | 879 | /** |
| 880 | 880 | * Set the duration |
| 881 | 881 | */ |
| 882 | - public function set_duration( $data, $id ) { |
|
| 883 | - if ( isset( $data['days'] ) && ! empty( $data['days'] ) ) { |
|
| 882 | + public function set_duration($data, $id) { |
|
| 883 | + if (isset($data['days']) && !empty($data['days'])) { |
|
| 884 | 884 | $price = $data['days']; |
| 885 | - $price = preg_replace( '/[^0-9,.]/', '', $price ); |
|
| 886 | - $this->save_custom_field( $price,'duration',$id ); |
|
| 885 | + $price = preg_replace('/[^0-9,.]/', '', $price); |
|
| 886 | + $this->save_custom_field($price, 'duration', $id); |
|
| 887 | 887 | } |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | /** |
| 891 | 891 | * Connects the Accommodation if its available |
| 892 | 892 | */ |
| 893 | - public function set_accommodation( $day, $id ) { |
|
| 893 | + public function set_accommodation($day, $id) { |
|
| 894 | 894 | $ac_id = false; |
| 895 | 895 | $this->current_accommodation = $this->find_current_accommodation(); |
| 896 | 896 | |
| 897 | - if ( isset( $day['content_entity_id'] ) && ! empty( $day['content_entity_id'] ) ) { |
|
| 898 | - if ( false !== $this->current_accommodation && ! empty( $this->current_accommodation ) && array_key_exists( $day['content_entity_id'],$this->current_accommodation ) ) { |
|
| 899 | - $ac_id = $this->current_accommodation[ $day['content_entity_id'] ]; |
|
| 900 | - } else { |
|
| 897 | + if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) { |
|
| 898 | + if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) { |
|
| 899 | + $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
| 900 | + }else { |
|
| 901 | 901 | $ac_id = wp_insert_post(array( |
| 902 | 902 | 'post_type' => 'accommodation', |
| 903 | 903 | 'post_status' => 'draft', |
| 904 | 904 | 'post_title' => $day['content_entity_id'], |
| 905 | 905 | )); |
| 906 | 906 | |
| 907 | - $this->save_custom_field( $day['content_entity_id'],'lsx_wetu_id',$ac_id ); |
|
| 907 | + $this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id); |
|
| 908 | 908 | } |
| 909 | 909 | |
| 910 | - if ( '' !== $ac_id && false !== $ac_id ) { |
|
| 911 | - $this->save_custom_field( $ac_id,'accommodation_to_tour',$id,false,false ); |
|
| 912 | - $this->save_custom_field( $id,'tour_to_accommodation',$ac_id,false,false ); |
|
| 913 | - $this->queue_item( $ac_id ); |
|
| 910 | + if ('' !== $ac_id && false !== $ac_id) { |
|
| 911 | + $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false); |
|
| 912 | + $this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false); |
|
| 913 | + $this->queue_item($ac_id); |
|
| 914 | 914 | } |
| 915 | 915 | } |
| 916 | 916 | return $ac_id; |
@@ -922,14 +922,14 @@ discard block |
||
| 922 | 922 | * @param $post_type string |
| 923 | 923 | * @return boolean / array |
| 924 | 924 | */ |
| 925 | - public function find_current_accommodation( $post_type = 'accommodation' ) { |
|
| 925 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
| 926 | 926 | global $wpdb; |
| 927 | - $accommodation = parent::find_current_accommodation( $post_type ); |
|
| 927 | + $accommodation = parent::find_current_accommodation($post_type); |
|
| 928 | 928 | $return = false; |
| 929 | 929 | |
| 930 | - if ( ! empty( $accommodation ) ) { |
|
| 931 | - foreach ( $accommodation as $key => $acc ) { |
|
| 932 | - $return[ $acc->meta_value ] = $acc->post_id; |
|
| 930 | + if (!empty($accommodation)) { |
|
| 931 | + foreach ($accommodation as $key => $acc) { |
|
| 932 | + $return[$acc->meta_value] = $acc->post_id; |
|
| 933 | 933 | } |
| 934 | 934 | } |
| 935 | 935 | |
@@ -941,7 +941,7 @@ discard block |
||
| 941 | 941 | * @return boolean / array |
| 942 | 942 | */ |
| 943 | 943 | public function find_current_destinations() { |
| 944 | - return $this->find_current_accommodation( 'destination' ); |
|
| 944 | + return $this->find_current_accommodation('destination'); |
|
| 945 | 945 | } |
| 946 | 946 | |
| 947 | 947 | /** |
@@ -951,42 +951,42 @@ discard block |
||
| 951 | 951 | * @param $id string |
| 952 | 952 | * @return boolean / string |
| 953 | 953 | */ |
| 954 | - public function set_destination( $day, $id, $leg_counter ) { |
|
| 954 | + public function set_destination($day, $id, $leg_counter) { |
|
| 955 | 955 | $dest_id = false; |
| 956 | 956 | $country_id = false; |
| 957 | 957 | $this->current_destinations = $this->find_current_destinations(); |
| 958 | 958 | |
| 959 | - if ( isset( $day['destination_content_entity_id'] ) && ! empty( $day['destination_content_entity_id'] ) ) { |
|
| 960 | - if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $day['destination_content_entity_id'],$this->current_destinations ) ) { |
|
| 961 | - $dest_id = $this->current_destinations[ $day['destination_content_entity_id'] ]; |
|
| 959 | + if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) { |
|
| 960 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) { |
|
| 961 | + $dest_id = $this->current_destinations[$day['destination_content_entity_id']]; |
|
| 962 | 962 | |
| 963 | 963 | //TODO Check for attachments here. |
| 964 | - $this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] ); |
|
| 964 | + $this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']); |
|
| 965 | 965 | |
| 966 | 966 | //Check if there is a country asigned. |
| 967 | - $potential_id = wp_get_post_parent_id( $dest_id ); |
|
| 968 | - $country_wetu_id = get_post_meta( $potential_id,'lsx_wetu_id',true ); |
|
| 967 | + $potential_id = wp_get_post_parent_id($dest_id); |
|
| 968 | + $country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true); |
|
| 969 | 969 | |
| 970 | - if ( false !== $country_wetu_id ) { |
|
| 971 | - $country_id = $this->set_country( $country_wetu_id, $id ); |
|
| 970 | + if (false !== $country_wetu_id) { |
|
| 971 | + $country_id = $this->set_country($country_wetu_id, $id); |
|
| 972 | 972 | } |
| 973 | - } else { |
|
| 974 | - $destination_json = file_get_contents( 'http://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $day['destination_content_entity_id'] ); |
|
| 973 | + }else { |
|
| 974 | + $destination_json = file_get_contents('http://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$day['destination_content_entity_id']); |
|
| 975 | 975 | |
| 976 | - if ( $destination_json ) { |
|
| 977 | - $destination_data = json_decode( $destination_json, true ); |
|
| 976 | + if ($destination_json) { |
|
| 977 | + $destination_data = json_decode($destination_json, true); |
|
| 978 | 978 | |
| 979 | - if ( ! empty( $destination_data ) && ! isset( $destination_data['error'] ) ) { |
|
| 979 | + if (!empty($destination_data) && !isset($destination_data['error'])) { |
|
| 980 | 980 | $destination_title = $day['destination_content_entity_id']; |
| 981 | 981 | |
| 982 | - if ( isset( $destination_data[0]['name'] ) ) { |
|
| 982 | + if (isset($destination_data[0]['name'])) { |
|
| 983 | 983 | $destination_title = $destination_data[0]['name']; |
| 984 | 984 | } |
| 985 | 985 | |
| 986 | - if ( isset( $destination_data[0]['map_object_id'] ) && isset( $destination_data[0]['position']['country_content_entity_id'] ) |
|
| 987 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id'] ) { |
|
| 986 | + if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
| 987 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) { |
|
| 988 | 988 | |
| 989 | - $country_id = $this->set_country( $destination_data[0]['position']['country_content_entity_id'], $id ); |
|
| 989 | + $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
|
| 990 | 990 | // Save the destination so we can grab the tour featured image and banner from them |
| 991 | 991 | } |
| 992 | 992 | |
@@ -996,40 +996,40 @@ discard block |
||
| 996 | 996 | 'post_title' => $destination_title, |
| 997 | 997 | ); |
| 998 | 998 | |
| 999 | - if ( false !== $country_id ) { |
|
| 999 | + if (false !== $country_id) { |
|
| 1000 | 1000 | $dest_post['post_parent'] = $country_id; |
| 1001 | 1001 | } |
| 1002 | - $dest_id = wp_insert_post( $dest_post ); |
|
| 1002 | + $dest_id = wp_insert_post($dest_post); |
|
| 1003 | 1003 | |
| 1004 | 1004 | //Make sure we register the |
| 1005 | - $this->current_destinations[ $day['destination_content_entity_id'] ] = $dest_id; |
|
| 1005 | + $this->current_destinations[$day['destination_content_entity_id']] = $dest_id; |
|
| 1006 | 1006 | |
| 1007 | 1007 | //If there are images attached then use the destination |
| 1008 | - if ( isset( $destination_data[0]['content']['images'] ) && ! empty( $destination_data[0]['content']['images'] ) ) { |
|
| 1009 | - $this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] ); |
|
| 1008 | + if (isset($destination_data[0]['content']['images']) && !empty($destination_data[0]['content']['images'])) { |
|
| 1009 | + $this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']); |
|
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | - $this->save_custom_field( $day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id ); |
|
| 1012 | + $this->save_custom_field($day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id); |
|
| 1013 | 1013 | } |
| 1014 | 1014 | } |
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | - if ( '' !== $dest_id && false !== $dest_id ) { |
|
| 1018 | - $this->save_custom_field( $dest_id, 'destination_to_tour', $id, false, false ); |
|
| 1019 | - $this->save_custom_field( $id, 'tour_to_destination', $dest_id, false, false ); |
|
| 1017 | + if ('' !== $dest_id && false !== $dest_id) { |
|
| 1018 | + $this->save_custom_field($dest_id, 'destination_to_tour', $id, false, false); |
|
| 1019 | + $this->save_custom_field($id, 'tour_to_destination', $dest_id, false, false); |
|
| 1020 | 1020 | |
| 1021 | 1021 | //Save the item to display in the queue |
| 1022 | - $this->queue_item( $dest_id ); |
|
| 1022 | + $this->queue_item($dest_id); |
|
| 1023 | 1023 | |
| 1024 | 1024 | //Save the item to clean up the amount of connections. |
| 1025 | - $this->cleanup_posts[ $dest_id ] = 'tour_to_destination'; |
|
| 1025 | + $this->cleanup_posts[$dest_id] = 'tour_to_destination'; |
|
| 1026 | 1026 | |
| 1027 | 1027 | //Add this relation info so we can make sure certain items are set as countries. |
| 1028 | - if ( 0 !== $country_id && false !== $country_id ) { |
|
| 1029 | - $this->relation_meta[ $dest_id ] = $country_id; |
|
| 1030 | - $this->relation_meta[ $country_id ] = 0; |
|
| 1031 | - } else { |
|
| 1032 | - $this->relation_meta[ $dest_id ] = 0; |
|
| 1028 | + if (0 !== $country_id && false !== $country_id) { |
|
| 1029 | + $this->relation_meta[$dest_id] = $country_id; |
|
| 1030 | + $this->relation_meta[$country_id] = 0; |
|
| 1031 | + }else { |
|
| 1032 | + $this->relation_meta[$dest_id] = 0; |
|
| 1033 | 1033 | } |
| 1034 | 1034 | } |
| 1035 | 1035 | } |
@@ -1045,25 +1045,25 @@ discard block |
||
| 1045 | 1045 | * |
| 1046 | 1046 | * @return string |
| 1047 | 1047 | */ |
| 1048 | - public function set_country( $country_wetu_id, $id ) { |
|
| 1048 | + public function set_country($country_wetu_id, $id) { |
|
| 1049 | 1049 | $country_id = false; |
| 1050 | 1050 | $this->current_destinations = $this->find_current_destinations(); |
| 1051 | 1051 | |
| 1052 | - if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $country_wetu_id, $this->current_destinations ) ) { |
|
| 1053 | - $country_id = $this->current_destinations[ $country_wetu_id ]; |
|
| 1054 | - $this->destination_images[ $id ][] = array( $country_id, $country_wetu_id ); |
|
| 1055 | - } else { |
|
| 1056 | - $country_json = file_get_contents( 'http://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $country_wetu_id ); |
|
| 1052 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
| 1053 | + $country_id = $this->current_destinations[$country_wetu_id]; |
|
| 1054 | + $this->destination_images[$id][] = array($country_id, $country_wetu_id); |
|
| 1055 | + }else { |
|
| 1056 | + $country_json = file_get_contents('http://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$country_wetu_id); |
|
| 1057 | 1057 | |
| 1058 | - if ( $country_json ) { |
|
| 1059 | - $country_data = json_decode( $country_json, true ); |
|
| 1058 | + if ($country_json) { |
|
| 1059 | + $country_data = json_decode($country_json, true); |
|
| 1060 | 1060 | |
| 1061 | - if ( ! empty( $country_data ) && ! isset( $country_data['error'] ) ) { |
|
| 1061 | + if (!empty($country_data) && !isset($country_data['error'])) { |
|
| 1062 | 1062 | |
| 1063 | 1063 | //Format the title of the destination if its available, otherwise default to the WETU ID. |
| 1064 | 1064 | $country_title = $country_wetu_id; |
| 1065 | 1065 | |
| 1066 | - if ( isset( $country_data[0]['name'] ) ) { |
|
| 1066 | + if (isset($country_data[0]['name'])) { |
|
| 1067 | 1067 | $country_title = $country_data[0]['name']; |
| 1068 | 1068 | } |
| 1069 | 1069 | |
@@ -1074,24 +1074,24 @@ discard block |
||
| 1074 | 1074 | )); |
| 1075 | 1075 | |
| 1076 | 1076 | //add the country to the current destination stack |
| 1077 | - $this->current_destinations[ $country_wetu_id ] = $country_id; |
|
| 1077 | + $this->current_destinations[$country_wetu_id] = $country_id; |
|
| 1078 | 1078 | |
| 1079 | 1079 | // Check if there are images and save fore use later. |
| 1080 | - if ( isset( $country_data[0]['content']['images'] ) && ! empty( $country_data[0]['content']['images'] ) ) { |
|
| 1081 | - $this->destination_images[ $id ][] = array( $country_id,$country_wetu_id ); |
|
| 1080 | + if (isset($country_data[0]['content']['images']) && !empty($country_data[0]['content']['images'])) { |
|
| 1081 | + $this->destination_images[$id][] = array($country_id, $country_wetu_id); |
|
| 1082 | 1082 | } |
| 1083 | 1083 | |
| 1084 | 1084 | //Save the wetu field |
| 1085 | - $this->save_custom_field( $country_wetu_id, 'lsx_wetu_id', $country_id ); |
|
| 1085 | + $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
| 1086 | 1086 | } |
| 1087 | 1087 | } |
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | - if ( '' !== $country_id && false !== $country_id ) { |
|
| 1091 | - $this->save_custom_field( $country_id, 'destination_to_tour', $id, false, false ); |
|
| 1092 | - $this->save_custom_field( $id, 'tour_to_destination', $country_id, false, false ); |
|
| 1093 | - $this->queue_item( $country_id ); |
|
| 1094 | - $this->cleanup_posts[ $country_id ] = 'tour_to_destination'; |
|
| 1090 | + if ('' !== $country_id && false !== $country_id) { |
|
| 1091 | + $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
| 1092 | + $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
| 1093 | + $this->queue_item($country_id); |
|
| 1094 | + $this->cleanup_posts[$country_id] = 'tour_to_destination'; |
|
| 1095 | 1095 | |
| 1096 | 1096 | return $country_id; |
| 1097 | 1097 | } |
@@ -1106,12 +1106,12 @@ discard block |
||
| 1106 | 1106 | * |
| 1107 | 1107 | * @return string |
| 1108 | 1108 | */ |
| 1109 | - public function attach_destination_images( $importable_content = array() ) { |
|
| 1110 | - if ( false !== $this->destination_images ) { |
|
| 1111 | - $this->shuffle_assoc( $this->destination_images ); |
|
| 1109 | + public function attach_destination_images($importable_content = array()) { |
|
| 1110 | + if (false !== $this->destination_images) { |
|
| 1111 | + $this->shuffle_assoc($this->destination_images); |
|
| 1112 | 1112 | |
| 1113 | - foreach ( $this->destination_images as $tour => $destinations ) { |
|
| 1114 | - $this->shuffle_assoc( $destinations ); |
|
| 1113 | + foreach ($this->destination_images as $tour => $destinations) { |
|
| 1114 | + $this->shuffle_assoc($destinations); |
|
| 1115 | 1115 | |
| 1116 | 1116 | /*print_r('<pre>'); |
| 1117 | 1117 | print_r( $tour ); |
@@ -1120,29 +1120,29 @@ discard block |
||
| 1120 | 1120 | |
| 1121 | 1121 | $image_set = false; |
| 1122 | 1122 | |
| 1123 | - foreach ( $destinations as $destination ) { |
|
| 1124 | - if ( false === $image_set ) { |
|
| 1125 | - $url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
| 1123 | + foreach ($destinations as $destination) { |
|
| 1124 | + if (false === $image_set) { |
|
| 1125 | + $url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
| 1126 | 1126 | $url_qs = ''; |
| 1127 | 1127 | |
| 1128 | - $jdata = file_get_contents( $url . '/Get?' . $url_qs . '&ids=' . $destination[1] ); |
|
| 1128 | + $jdata = file_get_contents($url.'/Get?'.$url_qs.'&ids='.$destination[1]); |
|
| 1129 | 1129 | |
| 1130 | - if ( $jdata ) { |
|
| 1131 | - $adata = json_decode( $jdata, true ); |
|
| 1130 | + if ($jdata) { |
|
| 1131 | + $adata = json_decode($jdata, true); |
|
| 1132 | 1132 | |
| 1133 | - if ( ! empty( $adata ) && ! empty( $adata[0]['content']['images'] ) ) { |
|
| 1134 | - $this->find_attachments( $destination[0] ); |
|
| 1133 | + if (!empty($adata) && !empty($adata[0]['content']['images'])) { |
|
| 1134 | + $this->find_attachments($destination[0]); |
|
| 1135 | 1135 | |
| 1136 | 1136 | //Set the featured image |
| 1137 | - if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) { |
|
| 1138 | - $image_set = $this->set_featured_image( $adata, $tour ); |
|
| 1137 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
| 1138 | + $image_set = $this->set_featured_image($adata, $tour); |
|
| 1139 | 1139 | } |
| 1140 | - if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) { |
|
| 1141 | - $image_set = $this->set_banner_image( $adata, $tour ); |
|
| 1140 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
| 1141 | + $image_set = $this->set_banner_image($adata, $tour); |
|
| 1142 | 1142 | } |
| 1143 | 1143 | } |
| 1144 | 1144 | } |
| 1145 | - } else { |
|
| 1145 | + }else { |
|
| 1146 | 1146 | continue; |
| 1147 | 1147 | } |
| 1148 | 1148 | } |
@@ -1153,28 +1153,28 @@ discard block |
||
| 1153 | 1153 | /** |
| 1154 | 1154 | * Creates the main gallery data |
| 1155 | 1155 | */ |
| 1156 | - public function set_featured_image( $data, $id ) { |
|
| 1156 | + public function set_featured_image($data, $id) { |
|
| 1157 | 1157 | $image_set = false; |
| 1158 | 1158 | $counter = 0; |
| 1159 | 1159 | |
| 1160 | - if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) { |
|
| 1161 | - foreach ( $data[0]['content']['images'] as $v ) { |
|
| 1160 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 1161 | + foreach ($data[0]['content']['images'] as $v) { |
|
| 1162 | 1162 | /*print_r('<pre>'); |
| 1163 | 1163 | print_r( $v ); |
| 1164 | 1164 | print_r('</pre>');*/ |
| 1165 | 1165 | |
| 1166 | - if ( true === $image_set || 0 === $counter ) { |
|
| 1166 | + if (true === $image_set || 0 === $counter) { |
|
| 1167 | 1167 | $counter++; |
| 1168 | 1168 | continue; |
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | - if ( ! $this->check_if_image_is_used( $v ) ) { |
|
| 1172 | - $temp_featured_image = $this->attach_image( $v , $id ); |
|
| 1171 | + if (!$this->check_if_image_is_used($v)) { |
|
| 1172 | + $temp_featured_image = $this->attach_image($v, $id); |
|
| 1173 | 1173 | |
| 1174 | - if ( false !== $temp_featured_image ) { |
|
| 1174 | + if (false !== $temp_featured_image) { |
|
| 1175 | 1175 | $this->featured_image = $temp_featured_image; |
| 1176 | - delete_post_meta( $id, '_thumbnail_id' ); |
|
| 1177 | - add_post_meta( $id, '_thumbnail_id', $this->featured_image, true ); |
|
| 1176 | + delete_post_meta($id, '_thumbnail_id'); |
|
| 1177 | + add_post_meta($id, '_thumbnail_id', $this->featured_image, true); |
|
| 1178 | 1178 | $image_set = true; |
| 1179 | 1179 | } |
| 1180 | 1180 | } |
@@ -1188,20 +1188,20 @@ discard block |
||
| 1188 | 1188 | /** |
| 1189 | 1189 | * Sets a banner image |
| 1190 | 1190 | */ |
| 1191 | - public function set_banner_image( $data, $id ) { |
|
| 1191 | + public function set_banner_image($data, $id) { |
|
| 1192 | 1192 | $image_set = false; |
| 1193 | 1193 | |
| 1194 | - if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) { |
|
| 1195 | - $temp_banner = $this->attach_image( $data[0]['content']['images'][1], $id, array( |
|
| 1194 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 1195 | + $temp_banner = $this->attach_image($data[0]['content']['images'][1], $id, array( |
|
| 1196 | 1196 | 'width' => '1920', |
| 1197 | 1197 | 'height' => '600', |
| 1198 | 1198 | 'cropping' => 'c', |
| 1199 | - ) ); |
|
| 1199 | + )); |
|
| 1200 | 1200 | |
| 1201 | - if ( false !== $temp_banner ) { |
|
| 1201 | + if (false !== $temp_banner) { |
|
| 1202 | 1202 | $this->banner_image = $temp_banner; |
| 1203 | 1203 | |
| 1204 | - delete_post_meta( $id,'image_group' ); |
|
| 1204 | + delete_post_meta($id, 'image_group'); |
|
| 1205 | 1205 | |
| 1206 | 1206 | $new_banner = array( |
| 1207 | 1207 | 'banner_image' => array( |
@@ -1209,7 +1209,7 @@ discard block |
||
| 1209 | 1209 | ), |
| 1210 | 1210 | ); |
| 1211 | 1211 | |
| 1212 | - add_post_meta( $id,'image_group',$new_banner,true ); |
|
| 1212 | + add_post_meta($id, 'image_group', $new_banner, true); |
|
| 1213 | 1213 | $image_set = true; |
| 1214 | 1214 | } |
| 1215 | 1215 | } |
@@ -1220,18 +1220,18 @@ discard block |
||
| 1220 | 1220 | /** |
| 1221 | 1221 | * Grabs all of the current used featured images on the site. |
| 1222 | 1222 | */ |
| 1223 | - public function check_if_image_is_used( $v ) { |
|
| 1223 | + public function check_if_image_is_used($v) { |
|
| 1224 | 1224 | global $wpdb; |
| 1225 | 1225 | |
| 1226 | - $temp_fragment = explode( '/',$v['url_fragment'] ); |
|
| 1227 | - $url_filename = $temp_fragment[ count( $temp_fragment ) -1 ]; |
|
| 1228 | - $url_filename = str_replace( array( '.jpg', '.png', '.jpeg' ),'',$url_filename ); |
|
| 1229 | - $url_filename = trim( $url_filename ); |
|
| 1230 | - $url_filename = str_replace( ' ','_',$url_filename ); |
|
| 1226 | + $temp_fragment = explode('/', $v['url_fragment']); |
|
| 1227 | + $url_filename = $temp_fragment[count($temp_fragment) - 1]; |
|
| 1228 | + $url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename); |
|
| 1229 | + $url_filename = trim($url_filename); |
|
| 1230 | + $url_filename = str_replace(' ', '_', $url_filename); |
|
| 1231 | 1231 | |
| 1232 | - if ( in_array( $url_filename,$this->found_attachments ) ) { |
|
| 1232 | + if (in_array($url_filename, $this->found_attachments)) { |
|
| 1233 | 1233 | //check to see if there is a featured image set with this ID. |
| 1234 | - $found_id = array_search( $url_filename,$this->found_attachments ); |
|
| 1234 | + $found_id = array_search($url_filename, $this->found_attachments); |
|
| 1235 | 1235 | |
| 1236 | 1236 | $querystring = " |
| 1237 | 1237 | SELECT post_id |
@@ -1240,22 +1240,22 @@ discard block |
||
| 1240 | 1240 | AND meta_key = '_thumbnail_id' |
| 1241 | 1241 | "; |
| 1242 | 1242 | // @codingStandardsIgnoreLine |
| 1243 | - $results = $wpdb->get_results( $querystring ); |
|
| 1243 | + $results = $wpdb->get_results($querystring); |
|
| 1244 | 1244 | |
| 1245 | - if ( ! empty( $results ) ) { |
|
| 1245 | + if (!empty($results)) { |
|
| 1246 | 1246 | return true; |
| 1247 | - } else { |
|
| 1247 | + }else { |
|
| 1248 | 1248 | return false; |
| 1249 | 1249 | } |
| 1250 | - } else { |
|
| 1250 | + }else { |
|
| 1251 | 1251 | $querystring = " |
| 1252 | 1252 | SELECT ID |
| 1253 | 1253 | FROM {$wpdb->posts} |
| 1254 | 1254 | WHERE post_name = '{$url_filename}' |
| 1255 | 1255 | "; |
| 1256 | 1256 | // @codingStandardsIgnoreLine |
| 1257 | - $results = $wpdb->get_results( $querystring ); |
|
| 1258 | - if ( ! empty( $results ) ) { |
|
| 1257 | + $results = $wpdb->get_results($querystring); |
|
| 1258 | + if (!empty($results)) { |
|
| 1259 | 1259 | $querystring = " |
| 1260 | 1260 | SELECT post_id |
| 1261 | 1261 | FROM {$wpdb->postmeta} |
@@ -1263,13 +1263,13 @@ discard block |
||
| 1263 | 1263 | AND meta_key = '_thumbnail_id' |
| 1264 | 1264 | "; |
| 1265 | 1265 | // @codingStandardsIgnoreLine |
| 1266 | - $results = $wpdb->get_results( $querystring ); |
|
| 1267 | - if ( ! empty( $results ) ) { |
|
| 1266 | + $results = $wpdb->get_results($querystring); |
|
| 1267 | + if (!empty($results)) { |
|
| 1268 | 1268 | return true; |
| 1269 | - } else { |
|
| 1269 | + }else { |
|
| 1270 | 1270 | return false; |
| 1271 | 1271 | } |
| 1272 | - } else { |
|
| 1272 | + }else { |
|
| 1273 | 1273 | return false; |
| 1274 | 1274 | } |
| 1275 | 1275 | } |
@@ -1280,10 +1280,10 @@ discard block |
||
| 1280 | 1280 | * |
| 1281 | 1281 | * @param $id int |
| 1282 | 1282 | */ |
| 1283 | - public function queue_item( $id ) { |
|
| 1284 | - if ( is_array( $this->import_queue ) && ! in_array( $id,$this->import_queue ) ) { |
|
| 1283 | + public function queue_item($id) { |
|
| 1284 | + if (is_array($this->import_queue) && !in_array($id, $this->import_queue)) { |
|
| 1285 | 1285 | $this->import_queue[] = $id; |
| 1286 | - } else { |
|
| 1286 | + }else { |
|
| 1287 | 1287 | $this->import_queue[] = $id; |
| 1288 | 1288 | } |
| 1289 | 1289 | } |
@@ -1292,18 +1292,18 @@ discard block |
||
| 1292 | 1292 | * Saves the queue to the option. |
| 1293 | 1293 | */ |
| 1294 | 1294 | public function save_queue() { |
| 1295 | - if ( ! empty( $this->import_queue ) ) { |
|
| 1296 | - if ( ! empty( $this->queued_imports ) ) { |
|
| 1297 | - $saved_imports = array_merge( $this->queued_imports,$this->import_queue ); |
|
| 1298 | - } else { |
|
| 1295 | + if (!empty($this->import_queue)) { |
|
| 1296 | + if (!empty($this->queued_imports)) { |
|
| 1297 | + $saved_imports = array_merge($this->queued_imports, $this->import_queue); |
|
| 1298 | + }else { |
|
| 1299 | 1299 | $saved_imports = $this->import_queue; |
| 1300 | 1300 | } |
| 1301 | 1301 | |
| 1302 | - delete_option( 'wetu_importer_que' ); |
|
| 1302 | + delete_option('wetu_importer_que'); |
|
| 1303 | 1303 | |
| 1304 | - if ( ! empty( $saved_imports ) ) { |
|
| 1305 | - $saved_imports = array_unique( $saved_imports ); |
|
| 1306 | - update_option( 'wetu_importer_que',$saved_imports ); |
|
| 1304 | + if (!empty($saved_imports)) { |
|
| 1305 | + $saved_imports = array_unique($saved_imports); |
|
| 1306 | + update_option('wetu_importer_que', $saved_imports); |
|
| 1307 | 1307 | } |
| 1308 | 1308 | } |
| 1309 | 1309 | } |
@@ -769,6 +769,9 @@ discard block |
||
| 769 | 769 | return $result; |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | + /** |
|
| 773 | + * @return boolean |
|
| 774 | + */ |
|
| 772 | 775 | public function set_term( $id = false, $name = false, $taxonomy = false, $parent = false ) { |
| 773 | 776 | // @codingStandardsIgnoreLine |
| 774 | 777 | if ( ! $term = term_exists( $name, $taxonomy ) ) { |
@@ -1072,6 +1075,10 @@ discard block |
||
| 1072 | 1075 | return false; |
| 1073 | 1076 | } |
| 1074 | 1077 | |
| 1078 | + /** |
|
| 1079 | + * @param string $url |
|
| 1080 | + * @param string $thumb |
|
| 1081 | + */ |
|
| 1075 | 1082 | public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) { |
| 1076 | 1083 | if ( ! $url || ! $post_id ) { return new WP_Error( 'missing', 'Need a valid URL and post ID...' ); } |
| 1077 | 1084 | |
@@ -1182,6 +1189,7 @@ discard block |
||
| 1182 | 1189 | |
| 1183 | 1190 | /** |
| 1184 | 1191 | * Does a multine search |
| 1192 | + * @param string $haystack |
|
| 1185 | 1193 | */ |
| 1186 | 1194 | public function multineedle_stripos( $haystack, $needles, $offset = 0 ) { |
| 1187 | 1195 | $found = false; |
@@ -191,31 +191,31 @@ discard block |
||
| 191 | 191 | * @access private |
| 192 | 192 | */ |
| 193 | 193 | public function __construct() { |
| 194 | - add_action( 'admin_init', array( $this, 'compatible_version_check' ) ); |
|
| 194 | + add_action('admin_init', array($this, 'compatible_version_check')); |
|
| 195 | 195 | |
| 196 | 196 | // Don't run anything else in the plugin, if we're on an incompatible PHP version |
| 197 | - if ( ! self::compatible_version() ) { |
|
| 197 | + if (!self::compatible_version()) { |
|
| 198 | 198 | return; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | $this->set_variables(); |
| 202 | 202 | |
| 203 | - add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
|
| 204 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ,11 ); |
|
| 205 | - add_action( 'admin_menu', array( $this, 'register_importer_page' ),20 ); |
|
| 203 | + add_action('init', array($this, 'load_plugin_textdomain')); |
|
| 204 | + add_action('admin_enqueue_scripts', array($this, 'admin_scripts'), 11); |
|
| 205 | + add_action('admin_menu', array($this, 'register_importer_page'), 20); |
|
| 206 | 206 | |
| 207 | - require_once( WETU_IMPORTER_PATH . 'classes/class-wetu-importer-accommodation.php' ); |
|
| 208 | - require_once( WETU_IMPORTER_PATH . 'classes/class-wetu-importer-destination.php' ); |
|
| 209 | - require_once( WETU_IMPORTER_PATH . 'classes/class-wetu-importer-tours.php' ); |
|
| 207 | + require_once(WETU_IMPORTER_PATH.'classes/class-wetu-importer-accommodation.php'); |
|
| 208 | + require_once(WETU_IMPORTER_PATH.'classes/class-wetu-importer-destination.php'); |
|
| 209 | + require_once(WETU_IMPORTER_PATH.'classes/class-wetu-importer-tours.php'); |
|
| 210 | 210 | |
| 211 | - add_action( 'init', array( $this, 'load_class' ) ); |
|
| 211 | + add_action('init', array($this, 'load_class')); |
|
| 212 | 212 | |
| 213 | - if ( 'default' !== $this->tab_slug ) { |
|
| 214 | - add_action( 'wp_ajax_lsx_tour_importer',array( $this, 'process_ajax_search' ) ); |
|
| 215 | - add_action( 'wp_ajax_nopriv_lsx_tour_importer',array( $this, 'process_ajax_search' ) ); |
|
| 213 | + if ('default' !== $this->tab_slug) { |
|
| 214 | + add_action('wp_ajax_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
| 215 | + add_action('wp_ajax_nopriv_lsx_tour_importer', array($this, 'process_ajax_search')); |
|
| 216 | 216 | |
| 217 | - add_action( 'wp_ajax_lsx_import_items',array( $this, 'process_ajax_import' ) ); |
|
| 218 | - add_action( 'wp_ajax_nopriv_lsx_import_items',array( $this, 'process_ajax_import' ) ); |
|
| 217 | + add_action('wp_ajax_lsx_import_items', array($this, 'process_ajax_import')); |
|
| 218 | + add_action('wp_ajax_nopriv_lsx_import_items', array($this, 'process_ajax_import')); |
|
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
@@ -227,19 +227,19 @@ discard block |
||
| 227 | 227 | * @since 1.0.0 |
| 228 | 228 | */ |
| 229 | 229 | public function load_plugin_textdomain() { |
| 230 | - load_plugin_textdomain( 'wetu-importer', false, basename( WETU_IMPORTER_PATH ) . '/languages' ); |
|
| 230 | + load_plugin_textdomain('wetu-importer', false, basename(WETU_IMPORTER_PATH).'/languages'); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
| 234 | 234 | * Sets the variables used throughout the plugin. |
| 235 | 235 | */ |
| 236 | 236 | public function set_variables() { |
| 237 | - $this->post_types = array( 'accommodation','destination','tour' ); |
|
| 238 | - $temp_options = get_option( '_lsx-to_settings',false ); |
|
| 237 | + $this->post_types = array('accommodation', 'destination', 'tour'); |
|
| 238 | + $temp_options = get_option('_lsx-to_settings', false); |
|
| 239 | 239 | |
| 240 | 240 | //Set the options. |
| 241 | - if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) ) { |
|
| 242 | - $this->options = $temp_options[ $this->plugin_slug ]; |
|
| 241 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug])) { |
|
| 242 | + $this->options = $temp_options[$this->plugin_slug]; |
|
| 243 | 243 | |
| 244 | 244 | $this->accommodation_settings = $temp_options['accommodation']; |
| 245 | 245 | $this->tour_settings = $temp_options['tour']; |
@@ -249,59 +249,59 @@ discard block |
||
| 249 | 249 | $this->api_username = false; |
| 250 | 250 | $this->api_password = false; |
| 251 | 251 | |
| 252 | - if ( ! defined( 'WETU_API_KEY' ) ) { |
|
| 253 | - if ( isset( $temp_options['api']['wetu_api_key'] ) && '' !== $temp_options['api']['wetu_api_key'] ) { |
|
| 252 | + if (!defined('WETU_API_KEY')) { |
|
| 253 | + if (isset($temp_options['api']['wetu_api_key']) && '' !== $temp_options['api']['wetu_api_key']) { |
|
| 254 | 254 | $this->api_key = $temp_options['api']['wetu_api_key']; |
| 255 | 255 | } |
| 256 | - if ( isset( $temp_options['api']['wetu_api_username'] ) && '' !== $temp_options['api']['wetu_api_username'] ) { |
|
| 256 | + if (isset($temp_options['api']['wetu_api_username']) && '' !== $temp_options['api']['wetu_api_username']) { |
|
| 257 | 257 | $this->api_username = $temp_options['api']['wetu_api_username']; |
| 258 | 258 | } |
| 259 | - if ( isset( $temp_options['api']['wetu_api_password'] ) && '' !== $temp_options['api']['wetu_api_password'] ) { |
|
| 259 | + if (isset($temp_options['api']['wetu_api_password']) && '' !== $temp_options['api']['wetu_api_password']) { |
|
| 260 | 260 | $this->api_password = $temp_options['api']['wetu_api_password']; |
| 261 | 261 | } |
| 262 | - } else { |
|
| 262 | + }else { |
|
| 263 | 263 | $this->api_key = WETU_API_KEY; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | //Set the tab slug |
| 267 | 267 | // @codingStandardsIgnoreLine |
| 268 | - if ( isset( $_GET['tab'] ) || isset( $_POST['type'] ) ) { |
|
| 269 | - if ( isset( $_GET['tab'] ) ) { |
|
| 268 | + if (isset($_GET['tab']) || isset($_POST['type'])) { |
|
| 269 | + if (isset($_GET['tab'])) { |
|
| 270 | 270 | $this->tab_slug = $_GET['tab']; |
| 271 | - } else { |
|
| 271 | + }else { |
|
| 272 | 272 | // @codingStandardsIgnoreLine |
| 273 | 273 | $this->tab_slug = $_POST['type']; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | //If any tours were queued |
| 277 | - $this->queued_imports = get_option( 'wetu_importer_que', array() ); |
|
| 277 | + $this->queued_imports = get_option('wetu_importer_que', array()); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | //Set the scaling options |
| 281 | - if ( isset( $this->options ) && isset( $this->options['image_scaling'] ) ) { |
|
| 281 | + if (isset($this->options) && isset($this->options['image_scaling'])) { |
|
| 282 | 282 | $this->scale_images = true; |
| 283 | 283 | $width = '1024'; |
| 284 | 284 | |
| 285 | - if ( isset( $this->options['width'] ) && '' !== $this->options['width'] ) { |
|
| 285 | + if (isset($this->options['width']) && '' !== $this->options['width']) { |
|
| 286 | 286 | $width = $this->options['width']; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | $height = '768'; |
| 290 | 290 | |
| 291 | - if ( isset( $this->options['height'] ) && '' !== $this->options['height'] ) { |
|
| 291 | + if (isset($this->options['height']) && '' !== $this->options['height']) { |
|
| 292 | 292 | $height = $this->options['height']; |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | $cropping = 'w'; |
| 296 | 296 | |
| 297 | - if ( isset( $this->options['cropping'] ) && '' !== $this->options['cropping'] ) { |
|
| 297 | + if (isset($this->options['cropping']) && '' !== $this->options['cropping']) { |
|
| 298 | 298 | $cropping = $this->options['cropping']; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - $this->image_scaling_url = 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/'; |
|
| 301 | + $this->image_scaling_url = 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/'; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - if ( isset( $this->options ) && isset( $this->options['image_limit'] ) && '' !== $this->options['image_limit'] ) { |
|
| 304 | + if (isset($this->options) && isset($this->options['image_limit']) && '' !== $this->options['image_limit']) { |
|
| 305 | 305 | $this->image_limit = $this->options['image_limit']; |
| 306 | 306 | } |
| 307 | 307 | } |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | * @since 1.0.0 |
| 325 | 325 | */ |
| 326 | 326 | public static function compatible_version() { |
| 327 | - if ( version_compare( PHP_VERSION, '5.6', '<' ) ) { |
|
| 327 | + if (version_compare(PHP_VERSION, '5.6', '<')) { |
|
| 328 | 328 | return false; |
| 329 | 329 | } |
| 330 | 330 | |
@@ -338,13 +338,13 @@ discard block |
||
| 338 | 338 | * @since 1.0.0 |
| 339 | 339 | */ |
| 340 | 340 | public function compatible_version_check() { |
| 341 | - if ( ! self::compatible_version() ) { |
|
| 342 | - if ( is_plugin_active( plugin_basename( WETU_IMPORTER_CORE ) ) ) { |
|
| 343 | - deactivate_plugins( plugin_basename( WETU_IMPORTER_CORE ) ); |
|
| 344 | - add_action( 'admin_notices', array( $this, 'compatible_version_notice' ) ); |
|
| 341 | + if (!self::compatible_version()) { |
|
| 342 | + if (is_plugin_active(plugin_basename(WETU_IMPORTER_CORE))) { |
|
| 343 | + deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE)); |
|
| 344 | + add_action('admin_notices', array($this, 'compatible_version_notice')); |
|
| 345 | 345 | |
| 346 | - if ( isset( $_GET['activate'] ) ) { |
|
| 347 | - unset( $_GET['activate'] ); |
|
| 346 | + if (isset($_GET['activate'])) { |
|
| 347 | + unset($_GET['activate']); |
|
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | } |
@@ -357,8 +357,8 @@ discard block |
||
| 357 | 357 | */ |
| 358 | 358 | public function compatible_version_notice() { |
| 359 | 359 | $class = 'notice notice-error'; |
| 360 | - $message = esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' ); |
|
| 361 | - printf( '<div class="%1$s"><p>%2$s</p></div>', esc_html( $class ), esc_html( $message ) ); |
|
| 360 | + $message = esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer'); |
|
| 361 | + printf('<div class="%1$s"><p>%2$s</p></div>', esc_html($class), esc_html($message)); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -368,9 +368,9 @@ discard block |
||
| 368 | 368 | * @since 1.0.0 |
| 369 | 369 | */ |
| 370 | 370 | public static function compatible_version_check_on_activation() { |
| 371 | - if ( ! self::compatible_version() ) { |
|
| 372 | - deactivate_plugins( plugin_basename( WETU_IMPORTER_CORE ) ); |
|
| 373 | - wp_die( esc_html__( 'Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer' ) ); |
|
| 371 | + if (!self::compatible_version()) { |
|
| 372 | + deactivate_plugins(plugin_basename(WETU_IMPORTER_CORE)); |
|
| 373 | + wp_die(esc_html__('Wetu Importer Plugin requires PHP 5.6 or higher.', 'wetu-importer')); |
|
| 374 | 374 | } |
| 375 | 375 | } |
| 376 | 376 | |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | * Load the importer class you want to use |
| 381 | 381 | */ |
| 382 | 382 | public function load_class() { |
| 383 | - switch ( $this->tab_slug ) { |
|
| 383 | + switch ($this->tab_slug) { |
|
| 384 | 384 | case 'accommodation': |
| 385 | 385 | $this->current_importer = new WETU_Importer_Accommodation(); |
| 386 | 386 | break; |
@@ -403,27 +403,27 @@ discard block |
||
| 403 | 403 | * Registers the admin page which will house the importer form. |
| 404 | 404 | */ |
| 405 | 405 | public function register_importer_page() { |
| 406 | - add_submenu_page( 'tour-operator',esc_html__( 'Importer', 'tour-operator' ), esc_html__( 'Importer', 'tour-operator' ), 'manage_options', 'wetu-importer', array( $this, 'display_page' ) ); |
|
| 406 | + add_submenu_page('tour-operator', esc_html__('Importer', 'tour-operator'), esc_html__('Importer', 'tour-operator'), 'manage_options', 'wetu-importer', array($this, 'display_page')); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
| 410 | 410 | * Enqueue the JS needed to contact wetu and return your result. |
| 411 | 411 | */ |
| 412 | 412 | public function admin_scripts() { |
| 413 | - if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { |
|
| 413 | + if (defined('WP_DEBUG') && true === WP_DEBUG) { |
|
| 414 | 414 | $min = ''; |
| 415 | - } else { |
|
| 415 | + }else { |
|
| 416 | 416 | $min = '.min'; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | $min = ''; |
| 420 | 420 | |
| 421 | - if ( is_admin() && isset( $_GET['page'] ) && $this->plugin_slug === $_GET['page'] ) { |
|
| 422 | - wp_enqueue_script( 'wetu-importers-script', WETU_IMPORTER_URL . 'assets/js/wetu-importer' . $min . '.js', array( 'jquery' ), WETU_IMPORTER_VER, true ); |
|
| 421 | + if (is_admin() && isset($_GET['page']) && $this->plugin_slug === $_GET['page']) { |
|
| 422 | + wp_enqueue_script('wetu-importers-script', WETU_IMPORTER_URL.'assets/js/wetu-importer'.$min.'.js', array('jquery'), WETU_IMPORTER_VER, true); |
|
| 423 | 423 | |
| 424 | - wp_localize_script( 'wetu-importers-script', 'lsx_tour_importer_params', array( |
|
| 425 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 426 | - ) ); |
|
| 424 | + wp_localize_script('wetu-importers-script', 'lsx_tour_importer_params', array( |
|
| 425 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
| 426 | + )); |
|
| 427 | 427 | } |
| 428 | 428 | } |
| 429 | 429 | |
@@ -438,14 +438,14 @@ discard block |
||
| 438 | 438 | screen_icon(); |
| 439 | 439 | ?> |
| 440 | 440 | |
| 441 | - <?php if ( ! is_object( $this->current_importer ) ) { |
|
| 441 | + <?php if (!is_object($this->current_importer)) { |
|
| 442 | 442 | ?> |
| 443 | - <h2><?php esc_html_e( 'Welcome to the LSX Wetu Importer', 'wetu-importer' ); ?></h2> |
|
| 443 | + <h2><?php esc_html_e('Welcome to the LSX Wetu Importer', 'wetu-importer'); ?></h2> |
|
| 444 | 444 | <p>If this is the first time you are running the import, then follow the steps below.</p> |
| 445 | 445 | <ul> |
| 446 | - <li>Step 1 - Import your <a href="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->plugin_slug ); ?>&tab=tour"><?php esc_html_e( 'Tours', 'wetu-importer' ); ?></a></li> |
|
| 447 | - <li>Step 2 - The tour import will have created draft <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', 'wetu-importer' ); ?></a> that will need to be imported.</li> |
|
| 448 | - <li>Step 3 - Lastly import the <a href="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->plugin_slug ); ?>&tab=destination"><?php esc_html_e( 'destinations', 'wetu-importer' ); ?></a> draft posts created during the previous two steps.</li> |
|
| 446 | + <li>Step 1 - Import your <a href="<?php echo esc_url(admin_url('admin.php')); ?>?page=<?php echo esc_attr($this->plugin_slug); ?>&tab=tour"><?php esc_html_e('Tours', 'wetu-importer'); ?></a></li> |
|
| 447 | + <li>Step 2 - The tour import will have created draft <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', 'wetu-importer'); ?></a> that will need to be imported.</li> |
|
| 448 | + <li>Step 3 - Lastly import the <a href="<?php echo esc_url(admin_url('admin.php')); ?>?page=<?php echo esc_attr($this->plugin_slug); ?>&tab=destination"><?php esc_html_e('destinations', 'wetu-importer'); ?></a> draft posts created during the previous two steps.</li> |
|
| 449 | 449 | </ul> |
| 450 | 450 | |
| 451 | 451 | <?php /*<h3><?php esc_html_e('Additional Tools', 'wetu-importer'); ?></h3> |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | <?php } ?> |
| 457 | 457 | </ul> |
| 458 | 458 | <?php*/ |
| 459 | - } else { |
|
| 459 | + }else { |
|
| 460 | 460 | $this->current_importer->display_page(); |
| 461 | 461 | }; ?> |
| 462 | 462 | </div> |
@@ -468,42 +468,42 @@ discard block |
||
| 468 | 468 | */ |
| 469 | 469 | public function search_form() { |
| 470 | 470 | ?> |
| 471 | - <form class="ajax-form" id="<?php echo esc_attr( $this->plugin_slug ); ?>-search-form" method="get" action="tools.php" data-type="<?php echo esc_attr( $this->tab_slug ); ?>"> |
|
| 472 | - <input type="hidden" name="page" value="<?php echo esc_attr( $this->tab_slug ); ?>" /> |
|
| 471 | + <form class="ajax-form" id="<?php echo esc_attr($this->plugin_slug); ?>-search-form" method="get" action="tools.php" data-type="<?php echo esc_attr($this->tab_slug); ?>"> |
|
| 472 | + <input type="hidden" name="page" value="<?php echo esc_attr($this->tab_slug); ?>" /> |
|
| 473 | 473 | |
| 474 | - <h3><span class="dashicons dashicons-search"></span> <?php esc_html_e( 'Search', 'wetu-importer' ); ?></h3> |
|
| 474 | + <h3><span class="dashicons dashicons-search"></span> <?php esc_html_e('Search', 'wetu-importer'); ?></h3> |
|
| 475 | 475 | |
| 476 | - <?php do_action( 'wetu_importer_search_form',$this ); ?> |
|
| 476 | + <?php do_action('wetu_importer_search_form', $this); ?> |
|
| 477 | 477 | |
| 478 | 478 | <div class="normal-search"> |
| 479 | - <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php esc_html_e( 'Search', 'wetu-importer' ); ?>" /> |
|
| 479 | + <input pattern=".{3,}" placeholder="3 characters minimum" class="keyword" name="keyword" value=""> <input class="button button-primary submit" type="submit" value="<?php esc_html_e('Search', 'wetu-importer'); ?>" /> |
|
| 480 | 480 | </div> |
| 481 | 481 | |
| 482 | 482 | <div class="advanced-search hidden" style="display:none;"> |
| 483 | - <p><?php esc_html_e( 'Enter several keywords, each on a new line.', 'wetu-importer' ); ?></p> |
|
| 483 | + <p><?php esc_html_e('Enter several keywords, each on a new line.', 'wetu-importer'); ?></p> |
|
| 484 | 484 | <textarea rows="10" cols="40" name="bulk-keywords"></textarea> |
| 485 | - <input class="button button-primary submit" type="submit" value="<?php esc_attr_e( 'Search', 'wetu-importer' ); ?>" /> |
|
| 485 | + <input class="button button-primary submit" type="submit" value="<?php esc_attr_e('Search', 'wetu-importer'); ?>" /> |
|
| 486 | 486 | </div> |
| 487 | 487 | |
| 488 | 488 | <p> |
| 489 | - <a class="advanced-search-toggle" href="#"><?php esc_html_e( 'Bulk Search', 'wetu-importer' ); ?></a> | |
|
| 490 | - <a class="published search-toggle" href="#publish"><?php esc_attr_e( 'Published', 'wetu-importer' ); ?></a> | |
|
| 491 | - <a class="pending search-toggle" href="#pending"><?php esc_attr_e( 'Pending', 'wetu-importer' ); ?></a> | |
|
| 492 | - <a class="draft search-toggle" href="#draft"><?php esc_attr_e( 'Draft', 'wetu-importer' ); ?></a> |
|
| 493 | - |
|
| 494 | - <?php if ( 'tour' === $this->tab_slug ) { ?> |
|
| 495 | - | <a class="import search-toggle" href="#import"><?php esc_attr_e( 'WETU', 'wetu-importer' ); ?></a> |
|
| 496 | - <?php } else if ( ! empty( $this->queued_imports ) ) { ?> |
|
| 497 | - | <a class="import search-toggle" href="#import"><?php esc_attr_e( 'WETU Queue', 'wetu-importer' ); ?></a> |
|
| 489 | + <a class="advanced-search-toggle" href="#"><?php esc_html_e('Bulk Search', 'wetu-importer'); ?></a> | |
|
| 490 | + <a class="published search-toggle" href="#publish"><?php esc_attr_e('Published', 'wetu-importer'); ?></a> | |
|
| 491 | + <a class="pending search-toggle" href="#pending"><?php esc_attr_e('Pending', 'wetu-importer'); ?></a> | |
|
| 492 | + <a class="draft search-toggle" href="#draft"><?php esc_attr_e('Draft', 'wetu-importer'); ?></a> |
|
| 493 | + |
|
| 494 | + <?php if ('tour' === $this->tab_slug) { ?> |
|
| 495 | + | <a class="import search-toggle" href="#import"><?php esc_attr_e('WETU', 'wetu-importer'); ?></a> |
|
| 496 | + <?php }else if (!empty($this->queued_imports)) { ?> |
|
| 497 | + | <a class="import search-toggle" href="#import"><?php esc_attr_e('WETU Queue', 'wetu-importer'); ?></a> |
|
| 498 | 498 | <?php } ?> |
| 499 | 499 | </p> |
| 500 | 500 | |
| 501 | 501 | <div class="ajax-loader" style="display:none;width:100%;text-align:center;"> |
| 502 | - <img style="width:64px;" src="<?php echo esc_url( WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" /> |
|
| 502 | + <img style="width:64px;" src="<?php echo esc_url(WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" /> |
|
| 503 | 503 | </div> |
| 504 | 504 | |
| 505 | 505 | <div class="ajax-loader-small" style="display:none;width:100%;text-align:center;"> |
| 506 | - <img style="width:32px;" src="<?php echo esc_url( WETU_IMPORTER_URL . 'assets/images/ajaxloader.gif' ); ?>" /> |
|
| 506 | + <img style="width:32px;" src="<?php echo esc_url(WETU_IMPORTER_URL.'assets/images/ajaxloader.gif'); ?>" /> |
|
| 507 | 507 | </div> |
| 508 | 508 | </form> |
| 509 | 509 | <?php |
@@ -552,19 +552,19 @@ discard block |
||
| 552 | 552 | * |
| 553 | 553 | * @param $tab string |
| 554 | 554 | */ |
| 555 | - public function navigation( $tab = '' ) { |
|
| 555 | + public function navigation($tab = '') { |
|
| 556 | 556 | $post_types = array( |
| 557 | - 'tour' => esc_attr( 'Tours', 'wetu-importer' ), |
|
| 558 | - 'accommodation' => esc_attr( 'Accommodation', 'wetu-importer' ), |
|
| 559 | - 'destination' => esc_attr( 'Destinations', 'wetu-importer' ), |
|
| 557 | + 'tour' => esc_attr('Tours', 'wetu-importer'), |
|
| 558 | + 'accommodation' => esc_attr('Accommodation', 'wetu-importer'), |
|
| 559 | + 'destination' => esc_attr('Destinations', 'wetu-importer'), |
|
| 560 | 560 | ); |
| 561 | 561 | |
| 562 | 562 | // @codingStandardsIgnoreLine |
| 563 | - echo '<div class="wet-navigation"><div class="subsubsub"><a class="' . $this->itemd( $tab, '', 'current', false ) . '" href="' . admin_url( 'admin.php' ) . '?page=' . $this->plugin_slug . '">' . esc_attr__( 'Home', 'wetu-importer' ) . '</a>'; |
|
| 563 | + echo '<div class="wet-navigation"><div class="subsubsub"><a class="'.$this->itemd($tab, '', 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'">'.esc_attr__('Home', 'wetu-importer').'</a>'; |
|
| 564 | 564 | |
| 565 | - foreach ( $post_types as $post_type => $label ) { |
|
| 565 | + foreach ($post_types as $post_type => $label) { |
|
| 566 | 566 | // @codingStandardsIgnoreLine |
| 567 | - echo ' | <a class="' . $this->itemd( $tab, $post_type, 'current', false ) . '" href="' . admin_url( 'admin.php' ) . '?page=' . $this->plugin_slug . '&tab=' . $post_type . '">' . $label . '</a>'; |
|
| 567 | + echo ' | <a class="'.$this->itemd($tab, $post_type, 'current', false).'" href="'.admin_url('admin.php').'?page='.$this->plugin_slug.'&tab='.$post_type.'">'.$label.'</a>'; |
|
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | echo '</div><br clear="both"/></div>'; |
@@ -573,8 +573,8 @@ discard block |
||
| 573 | 573 | /** |
| 574 | 574 | * set_taxonomy with some terms |
| 575 | 575 | */ |
| 576 | - public function team_member_checkboxes( $selected = array() ) { |
|
| 577 | - if ( post_type_exists( 'team' ) ) { ?> |
|
| 576 | + public function team_member_checkboxes($selected = array()) { |
|
| 577 | + if (post_type_exists('team')) { ?> |
|
| 578 | 578 | <ul> |
| 579 | 579 | <?php |
| 580 | 580 | $team_args = array( |
@@ -584,15 +584,15 @@ discard block |
||
| 584 | 584 | 'fields' => 'ids', |
| 585 | 585 | ); |
| 586 | 586 | |
| 587 | - $team_members = new WP_Query( $team_args ); |
|
| 587 | + $team_members = new WP_Query($team_args); |
|
| 588 | 588 | |
| 589 | - if ( $team_members->have_posts() ) { |
|
| 590 | - foreach ( $team_members->posts as $member ) { |
|
| 589 | + if ($team_members->have_posts()) { |
|
| 590 | + foreach ($team_members->posts as $member) { |
|
| 591 | 591 | // @codingStandardsIgnoreLine ?> |
| 592 | - <li><input class="team" <?php $this->checked( $selected, $member ); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title( $member ); ?></li> |
|
| 592 | + <li><input class="team" <?php $this->checked($selected, $member); ?> type="checkbox" value="<?php echo $member; ?>" /> <?php echo get_the_title($member); ?></li> |
|
| 593 | 593 | <?php } |
| 594 | - } else { ?> |
|
| 595 | - <li><input class="team" type="checkbox" value="0" /> <?php esc_html_e( 'None', 'wetu-importer' ); ?></li> |
|
| 594 | + }else { ?> |
|
| 595 | + <li><input class="team" type="checkbox" value="0" /> <?php esc_html_e('None', 'wetu-importer'); ?></li> |
|
| 596 | 596 | <?php } |
| 597 | 597 | ?> |
| 598 | 598 | </ul> |
@@ -609,14 +609,14 @@ discard block |
||
| 609 | 609 | * @param $needle string |
| 610 | 610 | * @param $echo bool |
| 611 | 611 | */ |
| 612 | - public function checked( $haystack = false, $needle = '', $echo = true ) { |
|
| 613 | - $return = $this->itemd( $haystack,$needle, 'checked' ); |
|
| 612 | + public function checked($haystack = false, $needle = '', $echo = true) { |
|
| 613 | + $return = $this->itemd($haystack, $needle, 'checked'); |
|
| 614 | 614 | |
| 615 | - if ( '' !== $return ) { |
|
| 616 | - if ( true === $echo ) { |
|
| 615 | + if ('' !== $return) { |
|
| 616 | + if (true === $echo) { |
|
| 617 | 617 | // @codingStandardsIgnoreLine |
| 618 | 618 | echo $return; |
| 619 | - } else { |
|
| 619 | + }else { |
|
| 620 | 620 | return $return; |
| 621 | 621 | } |
| 622 | 622 | } |
@@ -629,14 +629,14 @@ discard block |
||
| 629 | 629 | * @param $needle string |
| 630 | 630 | * @param $echo bool |
| 631 | 631 | */ |
| 632 | - public function selected( $haystack = false, $needle = '', $echo = true ) { |
|
| 633 | - $return = $this->itemd( $haystack,$needle,'selected' ); |
|
| 632 | + public function selected($haystack = false, $needle = '', $echo = true) { |
|
| 633 | + $return = $this->itemd($haystack, $needle, 'selected'); |
|
| 634 | 634 | |
| 635 | - if ( '' !== $return ) { |
|
| 636 | - if ( true === $echo ) { |
|
| 635 | + if ('' !== $return) { |
|
| 636 | + if (true === $echo) { |
|
| 637 | 637 | // @codingStandardsIgnoreLine |
| 638 | 638 | echo $return; |
| 639 | - } else { |
|
| 639 | + }else { |
|
| 640 | 640 | return $return; |
| 641 | 641 | } |
| 642 | 642 | } |
@@ -651,17 +651,17 @@ discard block |
||
| 651 | 651 | * @param $wrap bool |
| 652 | 652 | * @return $html string |
| 653 | 653 | */ |
| 654 | - public function itemd( $haystack = false, $needle = '', $type = '', $wrap = true ) { |
|
| 654 | + public function itemd($haystack = false, $needle = '', $type = '', $wrap = true) { |
|
| 655 | 655 | $html = ''; |
| 656 | 656 | |
| 657 | - if ( '' !== $type ) { |
|
| 658 | - if ( ! is_array( $haystack ) ) { |
|
| 659 | - $haystack = array( $haystack ); |
|
| 657 | + if ('' !== $type) { |
|
| 658 | + if (!is_array($haystack)) { |
|
| 659 | + $haystack = array($haystack); |
|
| 660 | 660 | } |
| 661 | - if ( in_array( $needle, $haystack ) ) { |
|
| 662 | - if ( true === $wrap || 'true' === $wrap ) { |
|
| 663 | - $html = $type . '="' . $type . '"'; |
|
| 664 | - } else { |
|
| 661 | + if (in_array($needle, $haystack)) { |
|
| 662 | + if (true === $wrap || 'true' === $wrap) { |
|
| 663 | + $html = $type.'="'.$type.'"'; |
|
| 664 | + }else { |
|
| 665 | 665 | $html = $type; |
| 666 | 666 | } |
| 667 | 667 | } |
@@ -673,9 +673,9 @@ discard block |
||
| 673 | 673 | /** |
| 674 | 674 | * grabs any attachments for the current item |
| 675 | 675 | */ |
| 676 | - public function find_attachments( $id = false ) { |
|
| 677 | - if ( false !== $id ) { |
|
| 678 | - if ( empty( $this->found_attachments ) ) { |
|
| 676 | + public function find_attachments($id = false) { |
|
| 677 | + if (false !== $id) { |
|
| 678 | + if (empty($this->found_attachments)) { |
|
| 679 | 679 | $attachments_args = array( |
| 680 | 680 | 'post_parent' => $id, |
| 681 | 681 | 'post_status' => 'inherit', |
@@ -685,11 +685,11 @@ discard block |
||
| 685 | 685 | 'posts_per_page' => '-1', |
| 686 | 686 | ); |
| 687 | 687 | |
| 688 | - $attachments = new WP_Query( $attachments_args ); |
|
| 688 | + $attachments = new WP_Query($attachments_args); |
|
| 689 | 689 | |
| 690 | - if ( $attachments->have_posts() ) { |
|
| 691 | - foreach ( $attachments->posts as $attachment ) { |
|
| 692 | - $this->found_attachments[ $attachment->ID ] = str_replace( array( '.jpg', '.png', '.jpeg' ),'',$attachment->post_title ); |
|
| 690 | + if ($attachments->have_posts()) { |
|
| 691 | + foreach ($attachments->posts as $attachment) { |
|
| 692 | + $this->found_attachments[$attachment->ID] = str_replace(array('.jpg', '.png', '.jpeg'), '', $attachment->post_title); |
|
| 693 | 693 | //$this->gallery_meta[] = $attachment->ID; |
| 694 | 694 | } |
| 695 | 695 | } |
@@ -702,19 +702,19 @@ discard block |
||
| 702 | 702 | /** |
| 703 | 703 | * Saves the room data |
| 704 | 704 | */ |
| 705 | - public function save_custom_field( $value = false, $meta_key, $id, $decrease = false, $unique = true ) { |
|
| 706 | - if ( false !== $value ) { |
|
| 707 | - if ( false !== $decrease ) { |
|
| 708 | - $value = intval( $value ); |
|
| 705 | + public function save_custom_field($value = false, $meta_key, $id, $decrease = false, $unique = true) { |
|
| 706 | + if (false !== $value) { |
|
| 707 | + if (false !== $decrease) { |
|
| 708 | + $value = intval($value); |
|
| 709 | 709 | $value--; |
| 710 | 710 | } |
| 711 | 711 | |
| 712 | - $prev = get_post_meta( $id,$meta_key,true ); |
|
| 712 | + $prev = get_post_meta($id, $meta_key, true); |
|
| 713 | 713 | |
| 714 | - if ( false !== $id && '0' !== $id && false !== $prev && true === $unique ) { |
|
| 715 | - update_post_meta( $id,$meta_key,$value,$prev ); |
|
| 716 | - } else { |
|
| 717 | - add_post_meta( $id,$meta_key,$value,$unique ); |
|
| 714 | + if (false !== $id && '0' !== $id && false !== $prev && true === $unique) { |
|
| 715 | + update_post_meta($id, $meta_key, $value, $prev); |
|
| 716 | + }else { |
|
| 717 | + add_post_meta($id, $meta_key, $value, $unique); |
|
| 718 | 718 | } |
| 719 | 719 | } |
| 720 | 720 | } |
@@ -723,15 +723,15 @@ discard block |
||
| 723 | 723 | * Grabs the custom fields, and resaves an array of unique items. |
| 724 | 724 | */ |
| 725 | 725 | public function cleanup_posts() { |
| 726 | - if ( ! empty( $this->cleanup_posts ) ) { |
|
| 726 | + if (!empty($this->cleanup_posts)) { |
|
| 727 | 727 | |
| 728 | - foreach ( $this->cleanup_posts as $id => $key ) { |
|
| 729 | - $prev_items = get_post_meta( $id, $key, false ); |
|
| 730 | - $new_items = array_unique( $prev_items ); |
|
| 731 | - delete_post_meta( $id, $key ); |
|
| 728 | + foreach ($this->cleanup_posts as $id => $key) { |
|
| 729 | + $prev_items = get_post_meta($id, $key, false); |
|
| 730 | + $new_items = array_unique($prev_items); |
|
| 731 | + delete_post_meta($id, $key); |
|
| 732 | 732 | |
| 733 | - foreach ( $new_items as $new_item ) { |
|
| 734 | - add_post_meta( $id, $key, $new_item, false ); |
|
| 733 | + foreach ($new_items as $new_item) { |
|
| 734 | + add_post_meta($id, $key, $new_item, false); |
|
| 735 | 735 | } |
| 736 | 736 | } |
| 737 | 737 | } |
@@ -742,52 +742,52 @@ discard block |
||
| 742 | 742 | /** |
| 743 | 743 | * set_taxonomy with some terms |
| 744 | 744 | */ |
| 745 | - public function set_taxonomy( $taxonomy, $terms, $id ) { |
|
| 745 | + public function set_taxonomy($taxonomy, $terms, $id) { |
|
| 746 | 746 | $result = array(); |
| 747 | 747 | |
| 748 | - if ( ! empty( $data ) ) { |
|
| 749 | - foreach ( $data as $k ) { |
|
| 750 | - if ( $id ) { |
|
| 748 | + if (!empty($data)) { |
|
| 749 | + foreach ($data as $k) { |
|
| 750 | + if ($id) { |
|
| 751 | 751 | // @codingStandardsIgnoreLine |
| 752 | - if ( ! $term = term_exists( trim( $k ), $tax ) ) { |
|
| 753 | - $term = wp_insert_term( trim( $k ), $tax ); |
|
| 752 | + if (!$term = term_exists(trim($k), $tax)) { |
|
| 753 | + $term = wp_insert_term(trim($k), $tax); |
|
| 754 | 754 | |
| 755 | - if ( is_wp_error( $term ) ) { |
|
| 755 | + if (is_wp_error($term)) { |
|
| 756 | 756 | // @codingStandardsIgnoreLine |
| 757 | 757 | echo $term->get_error_message(); |
| 758 | - } else { |
|
| 759 | - wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true ); |
|
| 758 | + }else { |
|
| 759 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
| 760 | 760 | } |
| 761 | - } else { |
|
| 762 | - wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true ); |
|
| 761 | + }else { |
|
| 762 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
| 763 | 763 | } |
| 764 | - } else { |
|
| 765 | - $result[] = trim( $k ); |
|
| 764 | + }else { |
|
| 765 | + $result[] = trim($k); |
|
| 766 | 766 | } |
| 767 | 767 | } |
| 768 | 768 | } |
| 769 | 769 | return $result; |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | - public function set_term( $id = false, $name = false, $taxonomy = false, $parent = false ) { |
|
| 772 | + public function set_term($id = false, $name = false, $taxonomy = false, $parent = false) { |
|
| 773 | 773 | // @codingStandardsIgnoreLine |
| 774 | - if ( ! $term = term_exists( $name, $taxonomy ) ) { |
|
| 775 | - if ( false !== $parent ) { |
|
| 774 | + if (!$term = term_exists($name, $taxonomy)) { |
|
| 775 | + if (false !== $parent) { |
|
| 776 | 776 | $parent = array( |
| 777 | 777 | 'parent' => $parent, |
| 778 | 778 | ); |
| 779 | 779 | } |
| 780 | 780 | |
| 781 | - $term = wp_insert_term( trim( $name ), $taxonomy,$parent ); |
|
| 781 | + $term = wp_insert_term(trim($name), $taxonomy, $parent); |
|
| 782 | 782 | |
| 783 | - if ( is_wp_error( $term ) ) { |
|
| 783 | + if (is_wp_error($term)) { |
|
| 784 | 784 | // @codingStandardsIgnoreLine |
| 785 | 785 | echo $term->get_error_message(); |
| 786 | - } else { |
|
| 787 | - wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true ); |
|
| 786 | + }else { |
|
| 787 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
| 788 | 788 | } |
| 789 | - } else { |
|
| 790 | - wp_set_object_terms( $id, intval( $term['term_id'] ), $taxonomy,true ); |
|
| 789 | + }else { |
|
| 790 | + wp_set_object_terms($id, intval($term['term_id']), $taxonomy, true); |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | return $term['term_id']; |
@@ -796,22 +796,22 @@ discard block |
||
| 796 | 796 | /** |
| 797 | 797 | * set_taxonomy with some terms |
| 798 | 798 | */ |
| 799 | - public function taxonomy_checkboxes( $taxonomy = false, $selected = array() ) { |
|
| 799 | + public function taxonomy_checkboxes($taxonomy = false, $selected = array()) { |
|
| 800 | 800 | $return = ''; |
| 801 | 801 | |
| 802 | - if ( false !== $taxonomy ) { |
|
| 802 | + if (false !== $taxonomy) { |
|
| 803 | 803 | $return .= '<ul>'; |
| 804 | - $terms = get_terms( array( |
|
| 804 | + $terms = get_terms(array( |
|
| 805 | 805 | 'taxonomy' => $taxonomy, |
| 806 | 806 | 'hide_empty' => false, |
| 807 | - ) ); |
|
| 807 | + )); |
|
| 808 | 808 | |
| 809 | - if ( ! is_wp_error( $terms ) ) { |
|
| 810 | - foreach ( $terms as $term ) { |
|
| 811 | - $return .= '<li><input class="' . $taxonomy . '" ' . $this->checked( $selected,$term->term_id,false ) . ' type="checkbox" value="' . $term->term_id . '" /> ' . $term->name . '</li>'; |
|
| 809 | + if (!is_wp_error($terms)) { |
|
| 810 | + foreach ($terms as $term) { |
|
| 811 | + $return .= '<li><input class="'.$taxonomy.'" '.$this->checked($selected, $term->term_id, false).' type="checkbox" value="'.$term->term_id.'" /> '.$term->name.'</li>'; |
|
| 812 | 812 | } |
| 813 | - } else { |
|
| 814 | - $return .= '<li><input type="checkbox" value="" /> ' . __( 'None', 'wetu-importer' ) . '</li>'; |
|
| 813 | + }else { |
|
| 814 | + $return .= '<li><input type="checkbox" value="" /> '.__('None', 'wetu-importer').'</li>'; |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | $return .= '</ul>'; |
@@ -825,44 +825,44 @@ discard block |
||
| 825 | 825 | /** |
| 826 | 826 | * Saves the longitude and lattitude, as well as sets the map marker. |
| 827 | 827 | */ |
| 828 | - public function set_map_data( $data, $id, $zoom = '10' ) { |
|
| 828 | + public function set_map_data($data, $id, $zoom = '10') { |
|
| 829 | 829 | $longitude = false; |
| 830 | 830 | $latitude = false; |
| 831 | 831 | $address = false; |
| 832 | 832 | |
| 833 | - if ( isset( $data[0]['position'] ) ) { |
|
| 834 | - if ( isset( $data[0]['position']['driving_latitude'] ) ) { |
|
| 833 | + if (isset($data[0]['position'])) { |
|
| 834 | + if (isset($data[0]['position']['driving_latitude'])) { |
|
| 835 | 835 | $latitude = $data[0]['position']['driving_latitude']; |
| 836 | - } elseif ( isset( $data[0]['position']['latitude'] ) ) { |
|
| 836 | + } elseif (isset($data[0]['position']['latitude'])) { |
|
| 837 | 837 | $latitude = $data[0]['position']['latitude']; |
| 838 | 838 | } |
| 839 | 839 | |
| 840 | - if ( isset( $data[0]['position']['driving_longitude'] ) ) { |
|
| 840 | + if (isset($data[0]['position']['driving_longitude'])) { |
|
| 841 | 841 | $longitude = $data[0]['position']['driving_longitude']; |
| 842 | - } elseif ( isset( $data[0]['position']['longitude'] ) ) { |
|
| 842 | + } elseif (isset($data[0]['position']['longitude'])) { |
|
| 843 | 843 | $longitude = $data[0]['position']['longitude']; |
| 844 | 844 | } |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | - if ( isset( $data[0]['content'] ) && isset( $data[0]['content']['contact_information'] ) ) { |
|
| 848 | - if ( isset( $data[0]['content']['contact_information']['address'] ) ) { |
|
| 849 | - $address = strip_tags( $data[0]['content']['contact_information']['address'] ); |
|
| 850 | - $address = explode( "\n", $address ); |
|
| 847 | + if (isset($data[0]['content']) && isset($data[0]['content']['contact_information'])) { |
|
| 848 | + if (isset($data[0]['content']['contact_information']['address'])) { |
|
| 849 | + $address = strip_tags($data[0]['content']['contact_information']['address']); |
|
| 850 | + $address = explode("\n", $address); |
|
| 851 | 851 | |
| 852 | - foreach ( $address as $bitkey => $bit ) { |
|
| 853 | - $bit = ltrim( rtrim( $bit ) ); |
|
| 852 | + foreach ($address as $bitkey => $bit) { |
|
| 853 | + $bit = ltrim(rtrim($bit)); |
|
| 854 | 854 | |
| 855 | - if ( false === $bit || '' === $bit || null === $bit || empty( $bit ) ) { |
|
| 856 | - unset( $address[ $bitkey ] ); |
|
| 855 | + if (false === $bit || '' === $bit || null === $bit || empty($bit)) { |
|
| 856 | + unset($address[$bitkey]); |
|
| 857 | 857 | } |
| 858 | 858 | } |
| 859 | 859 | |
| 860 | - $address = implode( ', ',$address ); |
|
| 861 | - $address = str_replace( ', , ', ', ', $address ); |
|
| 860 | + $address = implode(', ', $address); |
|
| 861 | + $address = str_replace(', , ', ', ', $address); |
|
| 862 | 862 | } |
| 863 | 863 | } |
| 864 | 864 | |
| 865 | - if ( false !== $longitude ) { |
|
| 865 | + if (false !== $longitude) { |
|
| 866 | 866 | $location_data = array( |
| 867 | 867 | 'address' => (string) $address, |
| 868 | 868 | 'lat' => (string) $latitude, |
@@ -871,11 +871,11 @@ discard block |
||
| 871 | 871 | 'elevation' => '', |
| 872 | 872 | ); |
| 873 | 873 | |
| 874 | - if ( false !== $id && '0' !== $id ) { |
|
| 875 | - $prev = get_post_meta( $id,'location',true ); |
|
| 876 | - update_post_meta( $id,'location',$location_data,$prev ); |
|
| 877 | - } else { |
|
| 878 | - add_post_meta( $id,'location',$location_data,true ); |
|
| 874 | + if (false !== $id && '0' !== $id) { |
|
| 875 | + $prev = get_post_meta($id, 'location', true); |
|
| 876 | + update_post_meta($id, 'location', $location_data, $prev); |
|
| 877 | + }else { |
|
| 878 | + add_post_meta($id, 'location', $location_data, true); |
|
| 879 | 879 | } |
| 880 | 880 | } |
| 881 | 881 | } |
@@ -885,17 +885,17 @@ discard block |
||
| 885 | 885 | /** |
| 886 | 886 | * Creates the main gallery data |
| 887 | 887 | */ |
| 888 | - public function set_featured_image( $data, $id ) { |
|
| 889 | - if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) { |
|
| 890 | - $this->featured_image = $this->attach_image( $data[0]['content']['images'][0], $id, array( |
|
| 888 | + public function set_featured_image($data, $id) { |
|
| 889 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 890 | + $this->featured_image = $this->attach_image($data[0]['content']['images'][0], $id, array( |
|
| 891 | 891 | 'width' => '800', |
| 892 | 892 | 'height' => '600', |
| 893 | 893 | 'cropping' => 'h', |
| 894 | - ) ); |
|
| 894 | + )); |
|
| 895 | 895 | |
| 896 | - if ( false !== $this->featured_image ) { |
|
| 897 | - delete_post_meta( $id,'_thumbnail_id' ); |
|
| 898 | - add_post_meta( $id,'_thumbnail_id',$this->featured_image,true ); |
|
| 896 | + if (false !== $this->featured_image) { |
|
| 897 | + delete_post_meta($id, '_thumbnail_id'); |
|
| 898 | + add_post_meta($id, '_thumbnail_id', $this->featured_image, true); |
|
| 899 | 899 | } |
| 900 | 900 | } |
| 901 | 901 | } |
@@ -903,27 +903,27 @@ discard block |
||
| 903 | 903 | /** |
| 904 | 904 | * Sets a banner image |
| 905 | 905 | */ |
| 906 | - public function set_banner_image( $data, $id ) { |
|
| 907 | - if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) { |
|
| 908 | - if ( isset( $data[0]['destination_image'] ) && is_array( $data[0]['destination_image'] ) ) { |
|
| 909 | - $temp_banner = $this->attach_image( $data[0]['destination_image'], $id, array( |
|
| 906 | + public function set_banner_image($data, $id) { |
|
| 907 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 908 | + if (isset($data[0]['destination_image']) && is_array($data[0]['destination_image'])) { |
|
| 909 | + $temp_banner = $this->attach_image($data[0]['destination_image'], $id, array( |
|
| 910 | 910 | 'width' => '1920', |
| 911 | 911 | 'height' => '600', |
| 912 | 912 | 'cropping' => 'c', |
| 913 | - ) ); |
|
| 914 | - } else { |
|
| 915 | - $temp_banner = $this->attach_image( $data[0]['content']['images'][1], $id, array( |
|
| 913 | + )); |
|
| 914 | + }else { |
|
| 915 | + $temp_banner = $this->attach_image($data[0]['content']['images'][1], $id, array( |
|
| 916 | 916 | 'width' => '1920', |
| 917 | 917 | 'height' => '600', |
| 918 | 918 | 'cropping' => 'c', |
| 919 | - ) ); |
|
| 919 | + )); |
|
| 920 | 920 | |
| 921 | 921 | } |
| 922 | 922 | |
| 923 | - if ( false !== $temp_banner ) { |
|
| 923 | + if (false !== $temp_banner) { |
|
| 924 | 924 | $this->banner_image = $temp_banner; |
| 925 | 925 | |
| 926 | - delete_post_meta( $id,'image_group' ); |
|
| 926 | + delete_post_meta($id, 'image_group'); |
|
| 927 | 927 | |
| 928 | 928 | $new_banner = array( |
| 929 | 929 | 'banner_image' => array( |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | ), |
| 932 | 932 | ); |
| 933 | 933 | |
| 934 | - add_post_meta( $id,'image_group',$new_banner,true ); |
|
| 934 | + add_post_meta($id, 'image_group', $new_banner, true); |
|
| 935 | 935 | } |
| 936 | 936 | } |
| 937 | 937 | } |
@@ -939,17 +939,17 @@ discard block |
||
| 939 | 939 | /** |
| 940 | 940 | * Creates the main gallery data |
| 941 | 941 | */ |
| 942 | - public function create_main_gallery( $data, $id ) { |
|
| 943 | - if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) { |
|
| 944 | - if ( isset( $this->options['image_replacing'] ) && 'on' === $this->options['image_replacing'] ) { |
|
| 945 | - $current_gallery = get_post_meta( $id, 'gallery', false ); |
|
| 942 | + public function create_main_gallery($data, $id) { |
|
| 943 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 944 | + if (isset($this->options['image_replacing']) && 'on' === $this->options['image_replacing']) { |
|
| 945 | + $current_gallery = get_post_meta($id, 'gallery', false); |
|
| 946 | 946 | |
| 947 | - if ( false !== $current_gallery && ! empty( $current_gallery ) ) { |
|
| 948 | - foreach ( $current_gallery as $g ) { |
|
| 949 | - delete_post_meta( $id,'gallery', $g ); |
|
| 947 | + if (false !== $current_gallery && !empty($current_gallery)) { |
|
| 948 | + foreach ($current_gallery as $g) { |
|
| 949 | + delete_post_meta($id, 'gallery', $g); |
|
| 950 | 950 | |
| 951 | - if ( 'attachment' === get_post_type( $g ) ) { |
|
| 952 | - wp_delete_attachment( $g, true ); |
|
| 951 | + if ('attachment' === get_post_type($g)) { |
|
| 952 | + wp_delete_attachment($g, true); |
|
| 953 | 953 | } |
| 954 | 954 | } |
| 955 | 955 | } |
@@ -957,32 +957,32 @@ discard block |
||
| 957 | 957 | |
| 958 | 958 | $counter = 0; |
| 959 | 959 | |
| 960 | - foreach ( $data[0]['content']['images'] as $image_data ) { |
|
| 961 | - if ( ( 0 === $counter && false !== $this->featured_image ) || ( 1 === $counter && false !== $this->banner_image ) ) { |
|
| 960 | + foreach ($data[0]['content']['images'] as $image_data) { |
|
| 961 | + if ((0 === $counter && false !== $this->featured_image) || (1 === $counter && false !== $this->banner_image)) { |
|
| 962 | 962 | $counter++; |
| 963 | 963 | |
| 964 | - if ( false !== $this->image_limit && false !== $this->image_limit ) { |
|
| 964 | + if (false !== $this->image_limit && false !== $this->image_limit) { |
|
| 965 | 965 | $this->image_limit++; |
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | continue; |
| 969 | 969 | } |
| 970 | 970 | |
| 971 | - if ( false !== $this->image_limit && $counter >= $this->image_limit ) { |
|
| 971 | + if (false !== $this->image_limit && $counter >= $this->image_limit) { |
|
| 972 | 972 | continue; |
| 973 | 973 | } |
| 974 | 974 | |
| 975 | - $this->gallery_meta[] = $this->attach_image( $image_data,$id ); |
|
| 975 | + $this->gallery_meta[] = $this->attach_image($image_data, $id); |
|
| 976 | 976 | $counter++; |
| 977 | 977 | } |
| 978 | 978 | |
| 979 | - if ( ! empty( $this->gallery_meta ) ) { |
|
| 980 | - delete_post_meta( $id,'gallery' ); |
|
| 981 | - $this->gallery_meta = array_unique( $this->gallery_meta ); |
|
| 979 | + if (!empty($this->gallery_meta)) { |
|
| 980 | + delete_post_meta($id, 'gallery'); |
|
| 981 | + $this->gallery_meta = array_unique($this->gallery_meta); |
|
| 982 | 982 | |
| 983 | - foreach ( $this->gallery_meta as $gallery_id ) { |
|
| 984 | - if ( false !== $gallery_id && '' !== $gallery_id && ! is_array( $gallery_id ) ) { |
|
| 985 | - add_post_meta( $id,'gallery',$gallery_id,false ); |
|
| 983 | + foreach ($this->gallery_meta as $gallery_id) { |
|
| 984 | + if (false !== $gallery_id && '' !== $gallery_id && !is_array($gallery_id)) { |
|
| 985 | + add_post_meta($id, 'gallery', $gallery_id, false); |
|
| 986 | 986 | } |
| 987 | 987 | } |
| 988 | 988 | } |
@@ -992,7 +992,7 @@ discard block |
||
| 992 | 992 | /** |
| 993 | 993 | * search_form |
| 994 | 994 | */ |
| 995 | - public function get_scaling_url( $args = array() ) { |
|
| 995 | + public function get_scaling_url($args = array()) { |
|
| 996 | 996 | $defaults = array( |
| 997 | 997 | 'width' => '1024', |
| 998 | 998 | 'height' => '768', |
@@ -1000,58 +1000,58 @@ discard block |
||
| 1000 | 1000 | 'cropping' => 'h', |
| 1001 | 1001 | ); |
| 1002 | 1002 | |
| 1003 | - if ( false !== $this->options ) { |
|
| 1004 | - if ( isset( $this->options['width'] ) && '' !== $this->options['width'] ) { |
|
| 1003 | + if (false !== $this->options) { |
|
| 1004 | + if (isset($this->options['width']) && '' !== $this->options['width']) { |
|
| 1005 | 1005 | $defaults['width'] = $this->options['width']; |
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | - if ( isset( $this->options['height'] ) && '' !== $this->options['height'] ) { |
|
| 1008 | + if (isset($this->options['height']) && '' !== $this->options['height']) { |
|
| 1009 | 1009 | $defaults['height'] = $this->options['height']; |
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | - if ( isset( $this->options['cropping'] ) && '' !== $this->options['cropping'] ) { |
|
| 1012 | + if (isset($this->options['cropping']) && '' !== $this->options['cropping']) { |
|
| 1013 | 1013 | $defaults['cropping'] = $this->options['cropping']; |
| 1014 | 1014 | } |
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1017 | + $args = wp_parse_args($args, $defaults); |
|
| 1018 | 1018 | $cropping = $args['cropping']; |
| 1019 | 1019 | $width = $args['width']; |
| 1020 | 1020 | $height = $args['height']; |
| 1021 | 1021 | |
| 1022 | - return 'https://wetu.com/ImageHandler/' . $cropping . $width . 'x' . $height . '/'; |
|
| 1022 | + return 'https://wetu.com/ImageHandler/'.$cropping.$width.'x'.$height.'/'; |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | /** |
| 1026 | 1026 | * Attaches 1 image |
| 1027 | 1027 | */ |
| 1028 | - public function attach_image( $v = false, $parent_id, $image_sizes = false ) { |
|
| 1029 | - if ( false !== $v ) { |
|
| 1030 | - $temp_fragment = explode( '/',$v['url_fragment'] ); |
|
| 1031 | - $url_filename = $temp_fragment[ count( $temp_fragment ) -1 ]; |
|
| 1032 | - $url_filename = str_replace( array( '.jpg', '.png', '.jpeg' ),'',$url_filename ); |
|
| 1033 | - $url_filename = trim( $url_filename ); |
|
| 1034 | - $url_filename = str_replace( ' ','_',$url_filename ); |
|
| 1035 | - |
|
| 1036 | - if ( ! isset( $this->options['image_replacing'] ) && in_array( $url_filename, $this->found_attachments ) ) { |
|
| 1037 | - return array_search( $url_filename,$this->found_attachments ); |
|
| 1028 | + public function attach_image($v = false, $parent_id, $image_sizes = false) { |
|
| 1029 | + if (false !== $v) { |
|
| 1030 | + $temp_fragment = explode('/', $v['url_fragment']); |
|
| 1031 | + $url_filename = $temp_fragment[count($temp_fragment) - 1]; |
|
| 1032 | + $url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename); |
|
| 1033 | + $url_filename = trim($url_filename); |
|
| 1034 | + $url_filename = str_replace(' ', '_', $url_filename); |
|
| 1035 | + |
|
| 1036 | + if (!isset($this->options['image_replacing']) && in_array($url_filename, $this->found_attachments)) { |
|
| 1037 | + return array_search($url_filename, $this->found_attachments); |
|
| 1038 | 1038 | } |
| 1039 | 1039 | |
| 1040 | 1040 | $postdata = array(); |
| 1041 | 1041 | |
| 1042 | - if ( empty( $v['label'] ) ) { |
|
| 1042 | + if (empty($v['label'])) { |
|
| 1043 | 1043 | $v['label'] = ''; |
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | - if ( ! empty( $v['description'] ) ) { |
|
| 1047 | - $desc = wp_strip_all_tags( $v['description'] ); |
|
| 1046 | + if (!empty($v['description'])) { |
|
| 1047 | + $desc = wp_strip_all_tags($v['description']); |
|
| 1048 | 1048 | $posdata = array( |
| 1049 | 1049 | 'post_excerpt' => $desc, |
| 1050 | 1050 | ); |
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | - if ( ! empty( $v['section'] ) ) { |
|
| 1054 | - $desc = wp_strip_all_tags( $v['section'] ); |
|
| 1053 | + if (!empty($v['section'])) { |
|
| 1054 | + $desc = wp_strip_all_tags($v['section']); |
|
| 1055 | 1055 | $posdata = array( |
| 1056 | 1056 | 'post_excerpt' => $desc, |
| 1057 | 1057 | ); |
@@ -1059,86 +1059,86 @@ discard block |
||
| 1059 | 1059 | |
| 1060 | 1060 | $attach_id = null; |
| 1061 | 1061 | //Resizor - add option to setting if required |
| 1062 | - $fragment = str_replace( ' ','%20',$v['url_fragment'] ); |
|
| 1063 | - $url = $this->get_scaling_url( $image_sizes ) . $fragment; |
|
| 1062 | + $fragment = str_replace(' ', '%20', $v['url_fragment']); |
|
| 1063 | + $url = $this->get_scaling_url($image_sizes).$fragment; |
|
| 1064 | 1064 | |
| 1065 | - $attach_id = $this->attach_external_image2( $url,$parent_id,'',$v['label'],$postdata ); |
|
| 1065 | + $attach_id = $this->attach_external_image2($url, $parent_id, '', $v['label'], $postdata); |
|
| 1066 | 1066 | |
| 1067 | 1067 | //echo($attach_id.' add image'); |
| 1068 | - if ( ! empty( $attach_id ) ) { |
|
| 1068 | + if (!empty($attach_id)) { |
|
| 1069 | 1069 | return $attach_id; |
| 1070 | 1070 | } |
| 1071 | 1071 | } |
| 1072 | 1072 | return false; |
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | - public function attach_external_image2( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) { |
|
| 1076 | - if ( ! $url || ! $post_id ) { return new WP_Error( 'missing', 'Need a valid URL and post ID...' ); } |
|
| 1075 | + public function attach_external_image2($url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array()) { |
|
| 1076 | + if (!$url || !$post_id) { return new WP_Error('missing', 'Need a valid URL and post ID...'); } |
|
| 1077 | 1077 | |
| 1078 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
| 1079 | - require_once( ABSPATH . 'wp-admin/includes/media.php' ); |
|
| 1080 | - require_once( ABSPATH . 'wp-admin/includes/image.php' ); |
|
| 1078 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
| 1079 | + require_once(ABSPATH.'wp-admin/includes/media.php'); |
|
| 1080 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
| 1081 | 1081 | // Download file to temp location, returns full server path to temp file |
| 1082 | 1082 | //$tmp = download_url( $url ); |
| 1083 | 1083 | |
| 1084 | 1084 | //var_dump($tmp); |
| 1085 | - $tmp = tempnam( '/tmp', 'FOO' ); |
|
| 1085 | + $tmp = tempnam('/tmp', 'FOO'); |
|
| 1086 | 1086 | |
| 1087 | - $image = file_get_contents( $url ); |
|
| 1088 | - file_put_contents( $tmp, $image ); |
|
| 1089 | - chmod( $tmp,'777' ); |
|
| 1087 | + $image = file_get_contents($url); |
|
| 1088 | + file_put_contents($tmp, $image); |
|
| 1089 | + chmod($tmp, '777'); |
|
| 1090 | 1090 | |
| 1091 | - preg_match( '/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches ); // fix file filename for query strings |
|
| 1092 | - $url_filename = basename( $matches[0] ); |
|
| 1093 | - $url_filename = str_replace( '%20','_',$url_filename ); |
|
| 1091 | + preg_match('/[^\?]+\.(tif|TIFF|jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG|pdf|PDF|bmp|BMP)/', $url, $matches); // fix file filename for query strings |
|
| 1092 | + $url_filename = basename($matches[0]); |
|
| 1093 | + $url_filename = str_replace('%20', '_', $url_filename); |
|
| 1094 | 1094 | // extract filename from url for title |
| 1095 | - $url_type = wp_check_filetype( $url_filename ); // determine file type (ext and mime/type) |
|
| 1095 | + $url_type = wp_check_filetype($url_filename); // determine file type (ext and mime/type) |
|
| 1096 | 1096 | |
| 1097 | 1097 | // override filename if given, reconstruct server path |
| 1098 | - if ( ! empty( $filename ) && ' ' != $filename ) { |
|
| 1099 | - $filename = sanitize_file_name( $filename ); |
|
| 1100 | - $tmppath = pathinfo( $tmp ); |
|
| 1098 | + if (!empty($filename) && ' ' != $filename) { |
|
| 1099 | + $filename = sanitize_file_name($filename); |
|
| 1100 | + $tmppath = pathinfo($tmp); |
|
| 1101 | 1101 | |
| 1102 | 1102 | $extension = ''; |
| 1103 | - if ( isset( $tmppath['extension'] ) ) { |
|
| 1103 | + if (isset($tmppath['extension'])) { |
|
| 1104 | 1104 | $extension = $tmppath['extension']; |
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | - $new = $tmppath['dirname'] . '/' . $filename . '.' . $extension; |
|
| 1108 | - rename( $tmp, $new ); // renames temp file on server |
|
| 1109 | - $tmp = $new; // push new filename (in path) to be used in file array later |
|
| 1107 | + $new = $tmppath['dirname'].'/'.$filename.'.'.$extension; |
|
| 1108 | + rename($tmp, $new); // renames temp file on server |
|
| 1109 | + $tmp = $new; // push new filename (in path) to be used in file array later |
|
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | 1112 | // assemble file data (should be built like $_FILES since wp_handle_sideload() will be using) |
| 1113 | - $file_array['tmp_name'] = $tmp; // full server path to temp file |
|
| 1113 | + $file_array['tmp_name'] = $tmp; // full server path to temp file |
|
| 1114 | 1114 | |
| 1115 | - if ( ! empty( $filename ) && ' ' != $filename ) { |
|
| 1116 | - $file_array['name'] = $filename . '.' . $url_type['ext']; // user given filename for title, add original URL extension |
|
| 1117 | - } else { |
|
| 1118 | - $file_array['name'] = $url_filename; // just use original URL filename |
|
| 1115 | + if (!empty($filename) && ' ' != $filename) { |
|
| 1116 | + $file_array['name'] = $filename.'.'.$url_type['ext']; // user given filename for title, add original URL extension |
|
| 1117 | + }else { |
|
| 1118 | + $file_array['name'] = $url_filename; // just use original URL filename |
|
| 1119 | 1119 | } |
| 1120 | 1120 | |
| 1121 | 1121 | // set additional wp_posts columns |
| 1122 | - if ( empty( $post_data['post_title'] ) ) { |
|
| 1122 | + if (empty($post_data['post_title'])) { |
|
| 1123 | 1123 | |
| 1124 | - $url_filename = str_replace( '%20',' ',$url_filename ); |
|
| 1124 | + $url_filename = str_replace('%20', ' ', $url_filename); |
|
| 1125 | 1125 | |
| 1126 | - $post_data['post_title'] = basename( $url_filename, '.' . $url_type['ext'] ); // just use the original filename (no extension) |
|
| 1126 | + $post_data['post_title'] = basename($url_filename, '.'.$url_type['ext']); // just use the original filename (no extension) |
|
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | 1129 | // make sure gets tied to parent |
| 1130 | - if ( empty( $post_data['post_parent'] ) ) { |
|
| 1130 | + if (empty($post_data['post_parent'])) { |
|
| 1131 | 1131 | $post_data['post_parent'] = $post_id; |
| 1132 | 1132 | } |
| 1133 | 1133 | |
| 1134 | 1134 | // required libraries for media_handle_sideload |
| 1135 | 1135 | |
| 1136 | 1136 | // do the validation and storage stuff |
| 1137 | - $att_id = media_handle_sideload( $file_array, $post_id, null, $post_data ); // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status |
|
| 1137 | + $att_id = media_handle_sideload($file_array, $post_id, null, $post_data); // $post_data can override the items saved to wp_posts table, like post_mime_type, guid, post_parent, post_title, post_content, post_status |
|
| 1138 | 1138 | |
| 1139 | 1139 | // If error storing permanently, unlink |
| 1140 | - if ( is_wp_error( $att_id ) ) { |
|
| 1141 | - unlink( $file_array['tmp_name'] ); // clean up |
|
| 1140 | + if (is_wp_error($att_id)) { |
|
| 1141 | + unlink($file_array['tmp_name']); // clean up |
|
| 1142 | 1142 | return false; // output wp_error |
| 1143 | 1143 | //return $att_id; // output wp_error |
| 1144 | 1144 | } |
@@ -1167,35 +1167,35 @@ discard block |
||
| 1167 | 1167 | /** |
| 1168 | 1168 | * Formats the row for the completed list. |
| 1169 | 1169 | */ |
| 1170 | - public function format_completed_row( $response ) { |
|
| 1170 | + public function format_completed_row($response) { |
|
| 1171 | 1171 | // @codingStandardsIgnoreLine |
| 1172 | - echo '<li class="post-' . $response . '"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="' . get_permalink( $response ) . '">' . get_the_title( $response ) . '</a></li>'; |
|
| 1172 | + echo '<li class="post-'.$response.'"><span class="dashicons dashicons-yes"></span> <a target="_blank" href="'.get_permalink($response).'">'.get_the_title($response).'</a></li>'; |
|
| 1173 | 1173 | } |
| 1174 | 1174 | |
| 1175 | 1175 | /** |
| 1176 | 1176 | * Formats the error. |
| 1177 | 1177 | */ |
| 1178 | - public function format_error( $response ) { |
|
| 1178 | + public function format_error($response) { |
|
| 1179 | 1179 | // @codingStandardsIgnoreLine |
| 1180 | - echo '<li class="post-error"><span class="dashicons dashicons-no"></span>' . $response . '</li>'; |
|
| 1180 | + echo '<li class="post-error"><span class="dashicons dashicons-no"></span>'.$response.'</li>'; |
|
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | 1183 | /** |
| 1184 | 1184 | * Does a multine search |
| 1185 | 1185 | */ |
| 1186 | - public function multineedle_stripos( $haystack, $needles, $offset = 0 ) { |
|
| 1186 | + public function multineedle_stripos($haystack, $needles, $offset = 0) { |
|
| 1187 | 1187 | $found = false; |
| 1188 | - $needle_count = count( $needles ); |
|
| 1188 | + $needle_count = count($needles); |
|
| 1189 | 1189 | |
| 1190 | - foreach ( $needles as $needle ) { |
|
| 1191 | - if ( false !== stripos( $haystack, $needle, $offset ) ) { |
|
| 1190 | + foreach ($needles as $needle) { |
|
| 1191 | + if (false !== stripos($haystack, $needle, $offset)) { |
|
| 1192 | 1192 | $found[] = true; |
| 1193 | 1193 | } |
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | - if ( false !== $found && count( $found ) === $needle_count ) { |
|
| 1196 | + if (false !== $found && count($found) === $needle_count) { |
|
| 1197 | 1197 | return true; |
| 1198 | - } else { |
|
| 1198 | + }else { |
|
| 1199 | 1199 | return false; |
| 1200 | 1200 | } |
| 1201 | 1201 | } |
@@ -1203,7 +1203,7 @@ discard block |
||
| 1203 | 1203 | /** |
| 1204 | 1204 | * Grab all the current accommodation posts via the lsx_wetu_id field. |
| 1205 | 1205 | */ |
| 1206 | - public function find_current_accommodation( $post_type = 'accommodation' ) { |
|
| 1206 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
| 1207 | 1207 | global $wpdb; |
| 1208 | 1208 | $return = array(); |
| 1209 | 1209 | |
@@ -1222,9 +1222,9 @@ discard block |
||
| 1222 | 1222 | "); |
| 1223 | 1223 | // @codingStandardsIgnoreEnd |
| 1224 | 1224 | |
| 1225 | - if ( null !== $current_accommodation && ! empty( $current_accommodation ) ) { |
|
| 1226 | - foreach ( $current_accommodation as $accom ) { |
|
| 1227 | - $return[ $accom->meta_value ] = $accom; |
|
| 1225 | + if (null !== $current_accommodation && !empty($current_accommodation)) { |
|
| 1226 | + foreach ($current_accommodation as $accom) { |
|
| 1227 | + $return[$accom->meta_value] = $accom; |
|
| 1228 | 1228 | } |
| 1229 | 1229 | } |
| 1230 | 1230 | |
@@ -1234,20 +1234,20 @@ discard block |
||
| 1234 | 1234 | /** |
| 1235 | 1235 | * Set the Video date |
| 1236 | 1236 | */ |
| 1237 | - public function set_video_data( $data, $id ) { |
|
| 1238 | - if ( ! empty( $data[0]['content']['youtube_videos'] ) && is_array( $data[0]['content']['youtube_videos'] ) ) { |
|
| 1237 | + public function set_video_data($data, $id) { |
|
| 1238 | + if (!empty($data[0]['content']['youtube_videos']) && is_array($data[0]['content']['youtube_videos'])) { |
|
| 1239 | 1239 | $videos = false; |
| 1240 | 1240 | |
| 1241 | - foreach ( $data[0]['content']['youtube_videos'] as $video ) { |
|
| 1241 | + foreach ($data[0]['content']['youtube_videos'] as $video) { |
|
| 1242 | 1242 | $temp_video = array(); |
| 1243 | 1243 | |
| 1244 | - if ( isset( $video['label'] ) ) { |
|
| 1244 | + if (isset($video['label'])) { |
|
| 1245 | 1245 | $temp_video['title'] = $video['label']; |
| 1246 | 1246 | } |
| 1247 | - if ( isset( $video['description'] ) ) { |
|
| 1248 | - $temp_video['description'] = strip_tags( $video['description'] ); |
|
| 1247 | + if (isset($video['description'])) { |
|
| 1248 | + $temp_video['description'] = strip_tags($video['description']); |
|
| 1249 | 1249 | } |
| 1250 | - if ( isset( $video['url'] ) ) { |
|
| 1250 | + if (isset($video['url'])) { |
|
| 1251 | 1251 | $temp_video['url'] = $video['url']; |
| 1252 | 1252 | } |
| 1253 | 1253 | |
@@ -1255,24 +1255,24 @@ discard block |
||
| 1255 | 1255 | $videos[] = $temp_video; |
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | - if ( false !== $id && '0' !== $id ) { |
|
| 1259 | - delete_post_meta( $id, 'videos' ); |
|
| 1258 | + if (false !== $id && '0' !== $id) { |
|
| 1259 | + delete_post_meta($id, 'videos'); |
|
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | - foreach ( $videos as $video ) { |
|
| 1263 | - add_post_meta( $id,'videos',$video,false ); |
|
| 1262 | + foreach ($videos as $video) { |
|
| 1263 | + add_post_meta($id, 'videos', $video, false); |
|
| 1264 | 1264 | } |
| 1265 | 1265 | } |
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | - public function shuffle_assoc( &$array ) { |
|
| 1268 | + public function shuffle_assoc(&$array) { |
|
| 1269 | 1269 | $new = array(); |
| 1270 | - $keys = array_keys( $array ); |
|
| 1270 | + $keys = array_keys($array); |
|
| 1271 | 1271 | |
| 1272 | - shuffle( $keys ); |
|
| 1272 | + shuffle($keys); |
|
| 1273 | 1273 | |
| 1274 | - foreach ( $keys as $key ) { |
|
| 1275 | - $new[ $key ] = $array[ $key ]; |
|
| 1274 | + foreach ($keys as $key) { |
|
| 1275 | + $new[$key] = $array[$key]; |
|
| 1276 | 1276 | } |
| 1277 | 1277 | |
| 1278 | 1278 | $array = $new; |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <div class="uix-field-wrapper"> |
| 2 | 2 | <ul class="ui-tab-nav"> |
| 3 | - <li><a href="#ui-general" class="active"><?php esc_html_e( 'General','tour-operator' ); ?></a></li> |
|
| 4 | - <li><a href="#ui-image-scaling"><?php esc_html_e( 'Image Settings','tour-operator' ); ?></a></li> |
|
| 3 | + <li><a href="#ui-general" class="active"><?php esc_html_e('General', 'tour-operator'); ?></a></li> |
|
| 4 | + <li><a href="#ui-image-scaling"><?php esc_html_e('Image Settings', 'tour-operator'); ?></a></li> |
|
| 5 | 5 | </ul> |
| 6 | 6 | |
| 7 | 7 | <div id="ui-general" class="ui-tab active"> |
@@ -17,26 +17,26 @@ discard block |
||
| 17 | 17 | * @access private |
| 18 | 18 | */ |
| 19 | 19 | public function __construct() { |
| 20 | - $temp_options = get_option( '_lsx-to_settings', false ); |
|
| 20 | + $temp_options = get_option('_lsx-to_settings', false); |
|
| 21 | 21 | |
| 22 | - if ( false !== $temp_options && isset( $temp_options[ $this->plugin_slug ] ) && ! empty( $temp_options[ $this->plugin_slug ] ) ) { |
|
| 23 | - $this->options = $temp_options[ $this->plugin_slug ]; |
|
| 22 | + if (false !== $temp_options && isset($temp_options[$this->plugin_slug]) && !empty($temp_options[$this->plugin_slug])) { |
|
| 23 | + $this->options = $temp_options[$this->plugin_slug]; |
|
| 24 | 24 | $this->set_variables(); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - add_filter( 'lsx_to_framework_settings_tabs', array( $this, 'settings_page_array' ) ); |
|
| 28 | - add_action( 'lsx_to_framework_api_tab_content',array( $this, 'api_settings' ),10,1 ); |
|
| 27 | + add_filter('lsx_to_framework_settings_tabs', array($this, 'settings_page_array')); |
|
| 28 | + add_action('lsx_to_framework_api_tab_content', array($this, 'api_settings'), 10, 1); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Returns the array of settings to the UIX Class in the lsx framework |
| 33 | 33 | */ |
| 34 | - public function settings_page_array( $tabs ) { |
|
| 35 | - $tabs[ $this->plugin_slug ] = array( |
|
| 34 | + public function settings_page_array($tabs) { |
|
| 35 | + $tabs[$this->plugin_slug] = array( |
|
| 36 | 36 | 'page_title' => '', |
| 37 | 37 | 'page_description' => '', |
| 38 | - 'menu_title' => __( 'Importer', 'wetu-importer' ), |
|
| 39 | - 'template' => WETU_IMPORTER_PATH . 'settings/wetu.php', |
|
| 38 | + 'menu_title' => __('Importer', 'wetu-importer'), |
|
| 39 | + 'template' => WETU_IMPORTER_PATH.'settings/wetu.php', |
|
| 40 | 40 | 'default' => false, |
| 41 | 41 | ); |
| 42 | 42 | |
@@ -46,16 +46,16 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * Adds the API key to the API Tab |
| 48 | 48 | */ |
| 49 | - public function api_settings( $tab = 'general' ) { |
|
| 50 | - if ( 'settings' === $tab ) { ?> |
|
| 49 | + public function api_settings($tab = 'general') { |
|
| 50 | + if ('settings' === $tab) { ?> |
|
| 51 | 51 | <tr class="form-field-wrap"> |
| 52 | 52 | <th class="tour-operator_table_heading" style="padding-bottom:0px;" scope="row" colspan="2"> |
| 53 | - <h4 style="margin-bottom:0px;"><span><?php esc_html_e( 'WETU API', 'wetu-importer' ); ?></span></h4> |
|
| 53 | + <h4 style="margin-bottom:0px;"><span><?php esc_html_e('WETU API', 'wetu-importer'); ?></span></h4> |
|
| 54 | 54 | </th> |
| 55 | 55 | </tr> |
| 56 | 56 | <tr class="form-field"> |
| 57 | 57 | <th scope="row"> |
| 58 | - <i class="dashicons-before dashicons-admin-network"></i> <label for="wetu_api_key"> <?php esc_html_e( 'Key', 'wetu-importer' ); ?></label> |
|
| 58 | + <i class="dashicons-before dashicons-admin-network"></i> <label for="wetu_api_key"> <?php esc_html_e('Key', 'wetu-importer'); ?></label> |
|
| 59 | 59 | </th> |
| 60 | 60 | <td> |
| 61 | 61 | <input type="text" {{#if wetu_api_key}} value="{{wetu_api_key}}" {{/if}} name="wetu_api_key" /> |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | </tr> |
| 64 | 64 | <tr class="form-field"> |
| 65 | 65 | <th scope="row"> |
| 66 | - <i class="dashicons-before dashicons-admin-users"></i> <label for="wetu_api_username"> <?php esc_html_e( 'Username', 'wetu-importer' ); ?></label> |
|
| 66 | + <i class="dashicons-before dashicons-admin-users"></i> <label for="wetu_api_username"> <?php esc_html_e('Username', 'wetu-importer'); ?></label> |
|
| 67 | 67 | </th> |
| 68 | 68 | <td> |
| 69 | 69 | <input type="text" {{#if wetu_api_username}} value="{{wetu_api_username}}" {{/if}} name="wetu_api_username" /> |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | </tr> |
| 72 | 72 | <tr class="form-field"> |
| 73 | 73 | <th scope="row"> |
| 74 | - <i class="dashicons-before dashicons-lock"></i> <label for="wetu_api_password"> <?php esc_html_e( 'Password', 'wetu-importer' ); ?></label> |
|
| 74 | + <i class="dashicons-before dashicons-lock"></i> <label for="wetu_api_password"> <?php esc_html_e('Password', 'wetu-importer'); ?></label> |
|
| 75 | 75 | </th> |
| 76 | 76 | <td> |
| 77 | 77 | <input type="text" {{#if wetu_api_password}} value="{{wetu_api_password}}" {{/if}} name="wetu_api_password" /> |
@@ -11,13 +11,13 @@ |
||
| 11 | 11 | * Domain Path: /languages/ |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -define( 'WETU_IMPORTER_PATH', plugin_dir_path( __FILE__ ) ); |
|
| 15 | -define( 'WETU_IMPORTER_CORE', __FILE__ ); |
|
| 16 | -define( 'WETU_IMPORTER_URL', plugin_dir_url( __FILE__ ) ); |
|
| 17 | -define( 'WETU_IMPORTER_VER', '1.0.0' ); |
|
| 14 | +define('WETU_IMPORTER_PATH', plugin_dir_path(__FILE__)); |
|
| 15 | +define('WETU_IMPORTER_CORE', __FILE__); |
|
| 16 | +define('WETU_IMPORTER_URL', plugin_dir_url(__FILE__)); |
|
| 17 | +define('WETU_IMPORTER_VER', '1.0.0'); |
|
| 18 | 18 | |
| 19 | -register_activation_hook( WETU_IMPORTER_CORE, array( 'WETU_Importer', 'register_activation_hook' ) ); |
|
| 19 | +register_activation_hook(WETU_IMPORTER_CORE, array('WETU_Importer', 'register_activation_hook')); |
|
| 20 | 20 | |
| 21 | -require_once( WETU_IMPORTER_PATH . 'classes/class-wetu-importer.php' ); |
|
| 21 | +require_once(WETU_IMPORTER_PATH.'classes/class-wetu-importer.php'); |
|
| 22 | 22 | //require_once(WETU_IMPORTER_PATH.'classes/class-wetu-importer-connect-accommodation.php'); |
| 23 | -require_once( WETU_IMPORTER_PATH . 'classes/class-wetu-importer-settings.php' ); |
|
| 23 | +require_once(WETU_IMPORTER_PATH.'classes/class-wetu-importer-settings.php'); |
|