@@ -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,12 +577,12 @@ 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 = ''; |
| 584 | 584 | |
| 585 | - $current_post = get_post( $id ); |
|
| 585 | + $current_post = get_post($id); |
|
| 586 | 586 | |
| 587 | 587 | $post = array( |
| 588 | 588 | 'post_type' => 'tour', |
@@ -591,11 +591,11 @@ discard block |
||
| 591 | 591 | //Set the post_content |
| 592 | 592 | $content_used_general_description = false; |
| 593 | 593 | |
| 594 | - if ( false !== $importable_content && in_array( 'description',$importable_content ) ) { |
|
| 594 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
| 595 | 595 | |
| 596 | 596 | $data_post_content = $current_post->post_content; |
| 597 | 597 | |
| 598 | - if ( isset( $data['summary'] ) && ! empty( $data['summary'] ) ) { |
|
| 598 | + if (isset($data['summary']) && !empty($data['summary'])) { |
|
| 599 | 599 | $data_post_content = $data['summary']; |
| 600 | 600 | } |
| 601 | 601 | |
@@ -603,25 +603,25 @@ discard block |
||
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | //Create or update the post |
| 606 | - if ( false !== $id && '0' !== $id ) { |
|
| 606 | + if (false !== $id && '0' !== $id) { |
|
| 607 | 607 | $post['ID'] = $id; |
| 608 | 608 | $post['post_status'] = 'publish'; |
| 609 | - $id = wp_update_post( $post ); |
|
| 610 | - $prev_date = get_post_meta( $id,'lsx_wetu_modified_date',true ); |
|
| 611 | - update_post_meta( $id,'lsx_wetu_modified_date',strtotime( $data['last_modified'] ),$prev_date ); |
|
| 609 | + $id = wp_update_post($post); |
|
| 610 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
| 611 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified']), $prev_date); |
|
| 612 | 612 | |
| 613 | 613 | //If the logger is enabled then log the data being saved. |
| 614 | - if ( $this->debug_enabled ) { |
|
| 615 | - $this->logger->log( 'wetu-importer', 'Creating Tour', print_r( $post, true ) ); |
|
| 614 | + if ($this->debug_enabled) { |
|
| 615 | + $this->logger->log('wetu-importer', 'Creating Tour', print_r($post, true)); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - } else { |
|
| 618 | + }else { |
|
| 619 | 619 | //Set the name |
| 620 | - if ( isset( $data['name'] ) ) { |
|
| 621 | - $post_name = wp_unique_post_slug( sanitize_title( $data['name'] ),$id, 'draft', 'tour', 0 ); |
|
| 620 | + if (isset($data['name'])) { |
|
| 621 | + $post_name = wp_unique_post_slug(sanitize_title($data['name']), $id, 'draft', 'tour', 0); |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | - if ( ! isset( $post['post_content'] ) ) { |
|
| 624 | + if (!isset($post['post_content'])) { |
|
| 625 | 625 | $post['post_content'] = " "; |
| 626 | 626 | } |
| 627 | 627 | |
@@ -630,34 +630,34 @@ discard block |
||
| 630 | 630 | $post['post_status'] = 'publish'; |
| 631 | 631 | |
| 632 | 632 | //If the logger is enabled then log the data being saved. |
| 633 | - if ( $this->debug_enabled ) { |
|
| 634 | - $this->logger->log( 'wetu-importer', 'Creating Tour', print_r( $post, true ) ); |
|
| 633 | + if ($this->debug_enabled) { |
|
| 634 | + $this->logger->log('wetu-importer', 'Creating Tour', print_r($post, true)); |
|
| 635 | 635 | } |
| 636 | - $id = wp_insert_post( $post ); |
|
| 636 | + $id = wp_insert_post($post); |
|
| 637 | 637 | |
| 638 | 638 | //Save the WETU ID and the Last date it was modified. |
| 639 | - if ( false !== $id ) { |
|
| 640 | - add_post_meta( $id,'lsx_wetu_id',$wetu_id ); |
|
| 641 | - add_post_meta( $id,'lsx_wetu_modified_date',strtotime( $data['last_modified'] ) ); |
|
| 639 | + if (false !== $id) { |
|
| 640 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
| 641 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data['last_modified'])); |
|
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | //Set the price |
| 646 | - if ( false !== $importable_content && in_array( 'price',$importable_content ) ) { |
|
| 647 | - $this->set_price( $data,$id ); |
|
| 646 | + if (false !== $importable_content && in_array('price', $importable_content)) { |
|
| 647 | + $this->set_price($data, $id); |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | //Set the Duration |
| 651 | - if ( false !== $importable_content && in_array( 'duration',$importable_content ) ) { |
|
| 652 | - $this->set_duration( $data,$id ); |
|
| 651 | + if (false !== $importable_content && in_array('duration', $importable_content)) { |
|
| 652 | + $this->set_duration($data, $id); |
|
| 653 | 653 | } |
| 654 | 654 | |
| 655 | - if ( false !== $importable_content && in_array( 'itineraries',$importable_content ) && isset( $data['legs'] ) && ! empty( $data['legs'] ) ) { |
|
| 656 | - $this->process_itineraries( $data,$id,$importable_content ); |
|
| 655 | + if (false !== $importable_content && in_array('itineraries', $importable_content) && isset($data['legs']) && !empty($data['legs'])) { |
|
| 656 | + $this->process_itineraries($data, $id, $importable_content); |
|
| 657 | 657 | } |
| 658 | 658 | |
| 659 | - if ( in_array( 'map',$importable_content ) && isset( $data['routes'] ) && ! empty( $data['routes'] ) ) { |
|
| 660 | - $this->set_map_data( $data,$id ); |
|
| 659 | + if (in_array('map', $importable_content) && isset($data['routes']) && !empty($data['routes'])) { |
|
| 660 | + $this->set_map_data($data, $id); |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | return $id; |
@@ -666,197 +666,197 @@ discard block |
||
| 666 | 666 | /** |
| 667 | 667 | * A loop which runs through each leg on the tour. |
| 668 | 668 | */ |
| 669 | - public function process_itineraries( $data, $id, $importable_content ) { |
|
| 669 | + public function process_itineraries($data, $id, $importable_content) { |
|
| 670 | 670 | $day_counter = 1; |
| 671 | 671 | $leg_counter = 0; |
| 672 | 672 | |
| 673 | - delete_post_meta( $id,'itinerary' ); |
|
| 673 | + delete_post_meta($id, 'itinerary'); |
|
| 674 | 674 | |
| 675 | - if ( false !== $importable_content && in_array( 'accommodation',$importable_content ) ) { |
|
| 676 | - delete_post_meta( $id,'accommodation_to_tour' ); |
|
| 675 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
| 676 | + delete_post_meta($id, 'accommodation_to_tour'); |
|
| 677 | 677 | } |
| 678 | - if ( false !== $importable_content && in_array( 'destination',$importable_content ) ) { |
|
| 678 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
| 679 | 679 | //delete_post_meta($id,'destination_to_tour'); |
| 680 | - delete_post_meta( $id,'departs_from' ); |
|
| 681 | - delete_post_meta( $id,'ends_in' ); |
|
| 680 | + delete_post_meta($id, 'departs_from'); |
|
| 681 | + delete_post_meta($id, 'ends_in'); |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | $departs_from = false; |
| 685 | 685 | $ends_in = false; |
| 686 | 686 | |
| 687 | - foreach ( $data['legs'] as $leg ) { |
|
| 687 | + foreach ($data['legs'] as $leg) { |
|
| 688 | 688 | //Itinerary Accommodation |
| 689 | 689 | $current_accommodation = false; |
| 690 | - if ( false !== $importable_content && in_array( 'accommodation',$importable_content ) ) { |
|
| 691 | - $current_accommodation = $this->set_accommodation( $leg,$id ); |
|
| 690 | + if (false !== $importable_content && in_array('accommodation', $importable_content)) { |
|
| 691 | + $current_accommodation = $this->set_accommodation($leg, $id); |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | //Itinerary Destination |
| 695 | 695 | $current_destination = false; |
| 696 | - if ( false !== $importable_content && in_array( 'destination',$importable_content ) ) { |
|
| 697 | - $current_destination = $this->set_destination( $leg,$id,$leg_counter ); |
|
| 696 | + if (false !== $importable_content && in_array('destination', $importable_content)) { |
|
| 697 | + $current_destination = $this->set_destination($leg, $id, $leg_counter); |
|
| 698 | 698 | } |
| 699 | 699 | |
| 700 | 700 | //If the Nights are the same mount of days in the array, then it isnt "By Destination" |
| 701 | - if ( ((1 <= (int) $leg['nights'] && isset( $leg['days'] ))) || 0 === $leg['itinerary_leg_id'] ) { |
|
| 702 | - foreach ( $leg['days'] as $day ) { |
|
| 701 | + if (((1 <= (int) $leg['nights'] && isset($leg['days']))) || 0 === $leg['itinerary_leg_id']) { |
|
| 702 | + foreach ($leg['days'] as $day) { |
|
| 703 | 703 | $current_day = array(); |
| 704 | - $current_day['title'] = esc_attr( 'Day ', 'wetu-importer' ) . $day_counter; |
|
| 704 | + $current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter; |
|
| 705 | 705 | |
| 706 | 706 | //print_r('<pre>');print_r($day['notes']);print_r('</pre>'); |
| 707 | 707 | |
| 708 | 708 | //Description |
| 709 | - if ( false !== $importable_content && in_array( 'itinerary_description',$importable_content ) && isset( $day['notes'] ) ) { |
|
| 709 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($day['notes'])) { |
|
| 710 | 710 | $current_day['description'] = $day['notes']; |
| 711 | - } else { |
|
| 711 | + }else { |
|
| 712 | 712 | $current_day['description'] = ''; |
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | //Itinerary Gallery |
| 716 | - if ( false !== $importable_content && in_array( 'itinerary_gallery',$importable_content ) && isset( $day['images'] ) ) { |
|
| 716 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($day['images'])) { |
|
| 717 | 717 | $current_day['featured_image'] = ''; |
| 718 | - } else { |
|
| 718 | + }else { |
|
| 719 | 719 | $current_day['featured_image'] = ''; |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | //Accommodation |
| 723 | - if ( false !== $current_accommodation ) { |
|
| 724 | - $current_day['accommodation_to_tour'] = array( $current_accommodation ); |
|
| 725 | - } else { |
|
| 723 | + if (false !== $current_accommodation) { |
|
| 724 | + $current_day['accommodation_to_tour'] = array($current_accommodation); |
|
| 725 | + }else { |
|
| 726 | 726 | $current_day['accommodation_to_tour'] = array(); |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | //Destination |
| 730 | - if ( false !== $current_destination ) { |
|
| 731 | - $current_day['destination_to_tour'] = array( $current_destination ); |
|
| 732 | - } else { |
|
| 730 | + if (false !== $current_destination) { |
|
| 731 | + $current_day['destination_to_tour'] = array($current_destination); |
|
| 732 | + }else { |
|
| 733 | 733 | $current_day['destination_to_tour'] = array(); |
| 734 | 734 | } |
| 735 | 735 | |
| 736 | 736 | //Included |
| 737 | - if ( false !== $importable_content && in_array( 'itinerary_included',$importable_content ) && isset( $day['included'] ) && '' !== $day['included'] ) { |
|
| 737 | + if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($day['included']) && '' !== $day['included']) { |
|
| 738 | 738 | $current_day['included'] = $day['included']; |
| 739 | - } else { |
|
| 739 | + }else { |
|
| 740 | 740 | $current_day['included'] = ''; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | //Excluded |
| 744 | - if ( false !== $importable_content && in_array( 'itinerary_excluded',$importable_content ) && isset( $day['excluded'] ) && '' !== $day['excluded'] ) { |
|
| 744 | + if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($day['excluded']) && '' !== $day['excluded']) { |
|
| 745 | 745 | $current_day['excluded'] = $day['excluded']; |
| 746 | - } else { |
|
| 746 | + }else { |
|
| 747 | 747 | $current_day['excluded'] = ''; |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | - $this->set_itinerary_day( $current_day,$id ); |
|
| 750 | + $this->set_itinerary_day($current_day, $id); |
|
| 751 | 751 | $day_counter++; |
| 752 | 752 | } |
| 753 | - } else { |
|
| 753 | + }else { |
|
| 754 | 754 | // This is for the by destination |
| 755 | 755 | |
| 756 | 756 | $current_day = array(); |
| 757 | 757 | $next_day_count = $day_counter + (int) $leg['nights']; |
| 758 | - $day_count_label = $next_day_count -1; |
|
| 758 | + $day_count_label = $next_day_count - 1; |
|
| 759 | 759 | |
| 760 | - $current_day['title'] = esc_attr( 'Day ','wetu-importer' ) . $day_counter; |
|
| 760 | + $current_day['title'] = esc_attr('Day ', 'wetu-importer').$day_counter; |
|
| 761 | 761 | |
| 762 | - if ( 0 !== (int) $leg['nights'] ) { |
|
| 763 | - $current_day['title'] .= ' - ' . $day_count_label; |
|
| 762 | + if (0 !== (int) $leg['nights']) { |
|
| 763 | + $current_day['title'] .= ' - '.$day_count_label; |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | //Description |
| 767 | - if ( false !== $importable_content && in_array( 'itinerary_description',$importable_content ) && isset( $leg['notes'] ) ) { |
|
| 767 | + if (false !== $importable_content && in_array('itinerary_description', $importable_content) && isset($leg['notes'])) { |
|
| 768 | 768 | $current_day['description'] = $leg['notes']; |
| 769 | - } else { |
|
| 769 | + }else { |
|
| 770 | 770 | $current_day['description'] = ''; |
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | //Itinerary Gallery |
| 774 | - if ( false !== $importable_content && in_array( 'itinerary_gallery',$importable_content ) && isset( $leg['images'] ) ) { |
|
| 774 | + if (false !== $importable_content && in_array('itinerary_gallery', $importable_content) && isset($leg['images'])) { |
|
| 775 | 775 | $current_day['featured_image'] = ''; |
| 776 | - } else { |
|
| 776 | + }else { |
|
| 777 | 777 | $current_day['featured_image'] = ''; |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | //Accommodation |
| 781 | - if ( false !== $current_accommodation ) { |
|
| 782 | - $current_day['accommodation_to_tour'] = array( $current_accommodation ); |
|
| 783 | - } else { |
|
| 781 | + if (false !== $current_accommodation) { |
|
| 782 | + $current_day['accommodation_to_tour'] = array($current_accommodation); |
|
| 783 | + }else { |
|
| 784 | 784 | $current_day['accommodation_to_tour'] = array(); |
| 785 | 785 | } |
| 786 | 786 | |
| 787 | 787 | //Destination |
| 788 | - if ( false !== $current_destination ) { |
|
| 789 | - $current_day['destination_to_tour'] = array( $current_destination ); |
|
| 790 | - } else { |
|
| 788 | + if (false !== $current_destination) { |
|
| 789 | + $current_day['destination_to_tour'] = array($current_destination); |
|
| 790 | + }else { |
|
| 791 | 791 | $current_day['destination_to_tour'] = array(); |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | //Included |
| 795 | - if ( false !== $importable_content && in_array( 'itinerary_included',$importable_content ) && isset( $leg['included'] ) && '' !== $leg['included'] ) { |
|
| 795 | + if (false !== $importable_content && in_array('itinerary_included', $importable_content) && isset($leg['included']) && '' !== $leg['included']) { |
|
| 796 | 796 | $current_day['included'] = $leg['included']; |
| 797 | - } else { |
|
| 797 | + }else { |
|
| 798 | 798 | $current_day['included'] = ''; |
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | //Excluded |
| 802 | - if ( false !== $importable_content && in_array( 'itinerary_excluded',$importable_content ) && isset( $leg['excluded'] ) && '' !== $leg['excluded'] ) { |
|
| 802 | + if (false !== $importable_content && in_array('itinerary_excluded', $importable_content) && isset($leg['excluded']) && '' !== $leg['excluded']) { |
|
| 803 | 803 | $current_day['excluded'] = $leg['excluded']; |
| 804 | - } else { |
|
| 804 | + }else { |
|
| 805 | 805 | $current_day['excluded'] = ''; |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | - $this->set_itinerary_day( $current_day,$id ); |
|
| 808 | + $this->set_itinerary_day($current_day, $id); |
|
| 809 | 809 | $day_counter = $next_day_count; |
| 810 | 810 | } |
| 811 | 811 | |
| 812 | 812 | //If we are in the first leg, and the destination was attached then save it as the departure field. |
| 813 | - if ( 0 === $leg_counter && false !== $current_destination ) { |
|
| 813 | + if (0 === $leg_counter && false !== $current_destination) { |
|
| 814 | 814 | $departs_from = $current_destination; |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | //If its the last leg then save it as the ends in. |
| 818 | 818 | // @codingStandardsIgnoreLine |
| 819 | - if ( $leg_counter === (count( $data['legs'] ) -2) && false !== $current_destination ) { |
|
| 819 | + if ($leg_counter === (count($data['legs']) - 2) && false !== $current_destination) { |
|
| 820 | 820 | $ends_in = $current_destination; |
| 821 | 821 | } |
| 822 | 822 | |
| 823 | 823 | $leg_counter++; |
| 824 | 824 | } |
| 825 | 825 | |
| 826 | - if ( false !== $departs_from ) { |
|
| 827 | - add_post_meta( $id,'departs_from',$departs_from,true ); |
|
| 826 | + if (false !== $departs_from) { |
|
| 827 | + add_post_meta($id, 'departs_from', $departs_from, true); |
|
| 828 | 828 | } |
| 829 | - if ( false !== $ends_in ) { |
|
| 830 | - add_post_meta( $id,'ends_in',$ends_in,true ); |
|
| 829 | + if (false !== $ends_in) { |
|
| 830 | + add_post_meta($id, 'ends_in', $ends_in, true); |
|
| 831 | 831 | } |
| 832 | 832 | } |
| 833 | 833 | |
| 834 | 834 | /** |
| 835 | 835 | * Run through your routes and save the points as a KML file. |
| 836 | 836 | */ |
| 837 | - public function set_map_data( $data, $id, $zoom = 9 ) { |
|
| 838 | - if ( ! empty( $data['routes'] ) ) { |
|
| 839 | - delete_post_meta( $id,'wetu_map_points' ); |
|
| 837 | + public function set_map_data($data, $id, $zoom = 9) { |
|
| 838 | + if (!empty($data['routes'])) { |
|
| 839 | + delete_post_meta($id, 'wetu_map_points'); |
|
| 840 | 840 | |
| 841 | 841 | $points = array(); |
| 842 | 842 | |
| 843 | - foreach ( $data['routes'] as $route ) { |
|
| 843 | + foreach ($data['routes'] as $route) { |
|
| 844 | 844 | |
| 845 | - if ( isset( $route['points'] ) && '' !== $route['points'] ) { |
|
| 845 | + if (isset($route['points']) && '' !== $route['points']) { |
|
| 846 | 846 | |
| 847 | - $temp_points = explode( ';',$route['points'] ); |
|
| 848 | - $point_counter = count( $temp_points ); |
|
| 847 | + $temp_points = explode(';', $route['points']); |
|
| 848 | + $point_counter = count($temp_points); |
|
| 849 | 849 | |
| 850 | - for ( $x = 0; $x <= $point_counter; $x++ ) { |
|
| 850 | + for ($x = 0; $x <= $point_counter; $x++) { |
|
| 851 | 851 | $y = $x + 1; |
| 852 | - $points[] = $temp_points[ $x ] . ',' . $temp_points[ $y ]; |
|
| 852 | + $points[] = $temp_points[$x].','.$temp_points[$y]; |
|
| 853 | 853 | $x++; |
| 854 | 854 | } |
| 855 | 855 | } |
| 856 | 856 | } |
| 857 | 857 | |
| 858 | - if ( ! empty( $points ) ) { |
|
| 859 | - $this->save_custom_field( implode( ' ',$points ),'wetu_map_points',$id,false,true ); |
|
| 858 | + if (!empty($points)) { |
|
| 859 | + $this->save_custom_field(implode(' ', $points), 'wetu_map_points', $id, false, true); |
|
| 860 | 860 | } |
| 861 | 861 | } |
| 862 | 862 | |
@@ -867,66 +867,66 @@ discard block |
||
| 867 | 867 | /** |
| 868 | 868 | * Set the Itinerary Day |
| 869 | 869 | */ |
| 870 | - public function set_itinerary_day( $day, $id ) { |
|
| 871 | - $this->save_custom_field( $day,'itinerary',$id,false,false ); |
|
| 870 | + public function set_itinerary_day($day, $id) { |
|
| 871 | + $this->save_custom_field($day, 'itinerary', $id, false, false); |
|
| 872 | 872 | } |
| 873 | 873 | |
| 874 | 874 | /** |
| 875 | 875 | * Set the price |
| 876 | 876 | */ |
| 877 | - public function set_price( $data, $id ) { |
|
| 877 | + public function set_price($data, $id) { |
|
| 878 | 878 | //Price |
| 879 | - if ( isset( $data['price'] ) && '' !== $data['price'] ) { |
|
| 880 | - $price = preg_replace( '/[^0-9,.]/', '', $data['price'] ); |
|
| 881 | - $this->save_custom_field( $price,'price',$id ); |
|
| 879 | + if (isset($data['price']) && '' !== $data['price']) { |
|
| 880 | + $price = preg_replace('/[^0-9,.]/', '', $data['price']); |
|
| 881 | + $this->save_custom_field($price, 'price', $id); |
|
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | //Price includes |
| 885 | - if ( isset( $data['price_includes'] ) && '' !== $data['price_includes'] ) { |
|
| 886 | - $this->save_custom_field( $data['price_includes'],'included',$id ); |
|
| 885 | + if (isset($data['price_includes']) && '' !== $data['price_includes']) { |
|
| 886 | + $this->save_custom_field($data['price_includes'], 'included', $id); |
|
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | //Price Excludes |
| 890 | - if ( isset( $data['price_excludes'] ) && '' !== $data['price_excludes'] ) { |
|
| 891 | - $this->save_custom_field( $data['price_excludes'],'not_included',$id ); |
|
| 890 | + if (isset($data['price_excludes']) && '' !== $data['price_excludes']) { |
|
| 891 | + $this->save_custom_field($data['price_excludes'], 'not_included', $id); |
|
| 892 | 892 | } |
| 893 | 893 | } |
| 894 | 894 | |
| 895 | 895 | /** |
| 896 | 896 | * Set the duration |
| 897 | 897 | */ |
| 898 | - public function set_duration( $data, $id ) { |
|
| 899 | - if ( isset( $data['days'] ) && ! empty( $data['days'] ) ) { |
|
| 898 | + public function set_duration($data, $id) { |
|
| 899 | + if (isset($data['days']) && !empty($data['days'])) { |
|
| 900 | 900 | $price = $data['days']; |
| 901 | - $price = preg_replace( '/[^0-9,.]/', '', $price ); |
|
| 902 | - $this->save_custom_field( $price,'duration',$id ); |
|
| 901 | + $price = preg_replace('/[^0-9,.]/', '', $price); |
|
| 902 | + $this->save_custom_field($price, 'duration', $id); |
|
| 903 | 903 | } |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | 906 | /** |
| 907 | 907 | * Connects the Accommodation if its available |
| 908 | 908 | */ |
| 909 | - public function set_accommodation( $day, $id ) { |
|
| 909 | + public function set_accommodation($day, $id) { |
|
| 910 | 910 | $ac_id = false; |
| 911 | 911 | $this->current_accommodation = $this->find_current_accommodation(); |
| 912 | 912 | |
| 913 | - if ( isset( $day['content_entity_id'] ) && ! empty( $day['content_entity_id'] ) ) { |
|
| 914 | - if ( false !== $this->current_accommodation && ! empty( $this->current_accommodation ) && array_key_exists( $day['content_entity_id'],$this->current_accommodation ) ) { |
|
| 915 | - $ac_id = $this->current_accommodation[ $day['content_entity_id'] ]; |
|
| 916 | - } else { |
|
| 913 | + if (isset($day['content_entity_id']) && !empty($day['content_entity_id'])) { |
|
| 914 | + if (false !== $this->current_accommodation && !empty($this->current_accommodation) && array_key_exists($day['content_entity_id'], $this->current_accommodation)) { |
|
| 915 | + $ac_id = $this->current_accommodation[$day['content_entity_id']]; |
|
| 916 | + }else { |
|
| 917 | 917 | $ac_id = wp_insert_post(array( |
| 918 | 918 | 'post_type' => 'accommodation', |
| 919 | 919 | 'post_status' => 'draft', |
| 920 | 920 | 'post_title' => $day['content_entity_id'], |
| 921 | 921 | )); |
| 922 | 922 | |
| 923 | - $this->save_custom_field( $day['content_entity_id'],'lsx_wetu_id',$ac_id ); |
|
| 923 | + $this->save_custom_field($day['content_entity_id'], 'lsx_wetu_id', $ac_id); |
|
| 924 | 924 | } |
| 925 | 925 | |
| 926 | - if ( '' !== $ac_id && false !== $ac_id ) { |
|
| 927 | - $this->save_custom_field( $ac_id,'accommodation_to_tour',$id,false,false ); |
|
| 928 | - $this->save_custom_field( $id,'tour_to_accommodation',$ac_id,false,false ); |
|
| 929 | - $this->queue_item( $ac_id ); |
|
| 926 | + if ('' !== $ac_id && false !== $ac_id) { |
|
| 927 | + $this->save_custom_field($ac_id, 'accommodation_to_tour', $id, false, false); |
|
| 928 | + $this->save_custom_field($id, 'tour_to_accommodation', $ac_id, false, false); |
|
| 929 | + $this->queue_item($ac_id); |
|
| 930 | 930 | } |
| 931 | 931 | } |
| 932 | 932 | return $ac_id; |
@@ -938,14 +938,14 @@ discard block |
||
| 938 | 938 | * @param $post_type string |
| 939 | 939 | * @return boolean / array |
| 940 | 940 | */ |
| 941 | - public function find_current_accommodation( $post_type = 'accommodation' ) { |
|
| 941 | + public function find_current_accommodation($post_type = 'accommodation') { |
|
| 942 | 942 | global $wpdb; |
| 943 | - $accommodation = parent::find_current_accommodation( $post_type ); |
|
| 943 | + $accommodation = parent::find_current_accommodation($post_type); |
|
| 944 | 944 | $return = false; |
| 945 | 945 | |
| 946 | - if ( ! empty( $accommodation ) ) { |
|
| 947 | - foreach ( $accommodation as $key => $acc ) { |
|
| 948 | - $return[ $acc->meta_value ] = $acc->post_id; |
|
| 946 | + if (!empty($accommodation)) { |
|
| 947 | + foreach ($accommodation as $key => $acc) { |
|
| 948 | + $return[$acc->meta_value] = $acc->post_id; |
|
| 949 | 949 | } |
| 950 | 950 | } |
| 951 | 951 | |
@@ -957,7 +957,7 @@ discard block |
||
| 957 | 957 | * @return boolean / array |
| 958 | 958 | */ |
| 959 | 959 | public function find_current_destinations() { |
| 960 | - return $this->find_current_accommodation( 'destination' ); |
|
| 960 | + return $this->find_current_accommodation('destination'); |
|
| 961 | 961 | } |
| 962 | 962 | |
| 963 | 963 | /** |
@@ -967,42 +967,42 @@ discard block |
||
| 967 | 967 | * @param $id string |
| 968 | 968 | * @return boolean / string |
| 969 | 969 | */ |
| 970 | - public function set_destination( $day, $id, $leg_counter ) { |
|
| 970 | + public function set_destination($day, $id, $leg_counter) { |
|
| 971 | 971 | $dest_id = false; |
| 972 | 972 | $country_id = false; |
| 973 | 973 | $this->current_destinations = $this->find_current_destinations(); |
| 974 | 974 | |
| 975 | - if ( isset( $day['destination_content_entity_id'] ) && ! empty( $day['destination_content_entity_id'] ) ) { |
|
| 976 | - if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $day['destination_content_entity_id'],$this->current_destinations ) ) { |
|
| 977 | - $dest_id = $this->current_destinations[ $day['destination_content_entity_id'] ]; |
|
| 975 | + if (isset($day['destination_content_entity_id']) && !empty($day['destination_content_entity_id'])) { |
|
| 976 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($day['destination_content_entity_id'], $this->current_destinations)) { |
|
| 977 | + $dest_id = $this->current_destinations[$day['destination_content_entity_id']]; |
|
| 978 | 978 | |
| 979 | 979 | //TODO Check for attachments here. |
| 980 | - $this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] ); |
|
| 980 | + $this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']); |
|
| 981 | 981 | |
| 982 | 982 | //Check if there is a country asigned. |
| 983 | - $potential_id = wp_get_post_parent_id( $dest_id ); |
|
| 984 | - $country_wetu_id = get_post_meta( $potential_id,'lsx_wetu_id',true ); |
|
| 983 | + $potential_id = wp_get_post_parent_id($dest_id); |
|
| 984 | + $country_wetu_id = get_post_meta($potential_id, 'lsx_wetu_id', true); |
|
| 985 | 985 | |
| 986 | - if ( false !== $country_wetu_id ) { |
|
| 987 | - $country_id = $this->set_country( $country_wetu_id, $id ); |
|
| 986 | + if (false !== $country_wetu_id) { |
|
| 987 | + $country_id = $this->set_country($country_wetu_id, $id); |
|
| 988 | 988 | } |
| 989 | - } else { |
|
| 990 | - $destination_json = file_get_contents( 'http://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $day['destination_content_entity_id'] ); |
|
| 989 | + }else { |
|
| 990 | + $destination_json = file_get_contents('http://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$day['destination_content_entity_id']); |
|
| 991 | 991 | |
| 992 | - if ( $destination_json ) { |
|
| 993 | - $destination_data = json_decode( $destination_json, true ); |
|
| 992 | + if ($destination_json) { |
|
| 993 | + $destination_data = json_decode($destination_json, true); |
|
| 994 | 994 | |
| 995 | - if ( ! empty( $destination_data ) && ! isset( $destination_data['error'] ) ) { |
|
| 995 | + if (!empty($destination_data) && !isset($destination_data['error'])) { |
|
| 996 | 996 | $destination_title = $day['destination_content_entity_id']; |
| 997 | 997 | |
| 998 | - if ( isset( $destination_data[0]['name'] ) ) { |
|
| 998 | + if (isset($destination_data[0]['name'])) { |
|
| 999 | 999 | $destination_title = $destination_data[0]['name']; |
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | - if ( isset( $destination_data[0]['map_object_id'] ) && isset( $destination_data[0]['position']['country_content_entity_id'] ) |
|
| 1003 | - && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id'] ) { |
|
| 1002 | + if (isset($destination_data[0]['map_object_id']) && isset($destination_data[0]['position']['country_content_entity_id']) |
|
| 1003 | + && $destination_data[0]['map_object_id'] !== $destination_data[0]['position']['country_content_entity_id']) { |
|
| 1004 | 1004 | |
| 1005 | - $country_id = $this->set_country( $destination_data[0]['position']['country_content_entity_id'], $id ); |
|
| 1005 | + $country_id = $this->set_country($destination_data[0]['position']['country_content_entity_id'], $id); |
|
| 1006 | 1006 | // Save the destination so we can grab the tour featured image and banner from them |
| 1007 | 1007 | } |
| 1008 | 1008 | |
@@ -1012,40 +1012,40 @@ discard block |
||
| 1012 | 1012 | 'post_title' => $destination_title, |
| 1013 | 1013 | ); |
| 1014 | 1014 | |
| 1015 | - if ( false !== $country_id ) { |
|
| 1015 | + if (false !== $country_id) { |
|
| 1016 | 1016 | $dest_post['post_parent'] = $country_id; |
| 1017 | 1017 | } |
| 1018 | - $dest_id = wp_insert_post( $dest_post ); |
|
| 1018 | + $dest_id = wp_insert_post($dest_post); |
|
| 1019 | 1019 | |
| 1020 | 1020 | //Make sure we register the |
| 1021 | - $this->current_destinations[ $day['destination_content_entity_id'] ] = $dest_id; |
|
| 1021 | + $this->current_destinations[$day['destination_content_entity_id']] = $dest_id; |
|
| 1022 | 1022 | |
| 1023 | 1023 | //If there are images attached then use the destination |
| 1024 | - if ( isset( $destination_data[0]['content']['images'] ) && ! empty( $destination_data[0]['content']['images'] ) ) { |
|
| 1025 | - $this->destination_images[ $id ][] = array( $dest_id, $day['destination_content_entity_id'] ); |
|
| 1024 | + if (isset($destination_data[0]['content']['images']) && !empty($destination_data[0]['content']['images'])) { |
|
| 1025 | + $this->destination_images[$id][] = array($dest_id, $day['destination_content_entity_id']); |
|
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | - $this->save_custom_field( $day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id ); |
|
| 1028 | + $this->save_custom_field($day['destination_content_entity_id'], 'lsx_wetu_id', $dest_id); |
|
| 1029 | 1029 | } |
| 1030 | 1030 | } |
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | - if ( '' !== $dest_id && false !== $dest_id ) { |
|
| 1034 | - $this->save_custom_field( $dest_id, 'destination_to_tour', $id, false, false ); |
|
| 1035 | - $this->save_custom_field( $id, 'tour_to_destination', $dest_id, false, false ); |
|
| 1033 | + if ('' !== $dest_id && false !== $dest_id) { |
|
| 1034 | + $this->save_custom_field($dest_id, 'destination_to_tour', $id, false, false); |
|
| 1035 | + $this->save_custom_field($id, 'tour_to_destination', $dest_id, false, false); |
|
| 1036 | 1036 | |
| 1037 | 1037 | //Save the item to display in the queue |
| 1038 | - $this->queue_item( $dest_id ); |
|
| 1038 | + $this->queue_item($dest_id); |
|
| 1039 | 1039 | |
| 1040 | 1040 | //Save the item to clean up the amount of connections. |
| 1041 | - $this->cleanup_posts[ $dest_id ] = 'tour_to_destination'; |
|
| 1041 | + $this->cleanup_posts[$dest_id] = 'tour_to_destination'; |
|
| 1042 | 1042 | |
| 1043 | 1043 | //Add this relation info so we can make sure certain items are set as countries. |
| 1044 | - if ( 0 !== $country_id && false !== $country_id ) { |
|
| 1045 | - $this->relation_meta[ $dest_id ] = $country_id; |
|
| 1046 | - $this->relation_meta[ $country_id ] = 0; |
|
| 1047 | - } else { |
|
| 1048 | - $this->relation_meta[ $dest_id ] = 0; |
|
| 1044 | + if (0 !== $country_id && false !== $country_id) { |
|
| 1045 | + $this->relation_meta[$dest_id] = $country_id; |
|
| 1046 | + $this->relation_meta[$country_id] = 0; |
|
| 1047 | + }else { |
|
| 1048 | + $this->relation_meta[$dest_id] = 0; |
|
| 1049 | 1049 | } |
| 1050 | 1050 | } |
| 1051 | 1051 | } |
@@ -1061,25 +1061,25 @@ discard block |
||
| 1061 | 1061 | * |
| 1062 | 1062 | * @return string |
| 1063 | 1063 | */ |
| 1064 | - public function set_country( $country_wetu_id, $id ) { |
|
| 1064 | + public function set_country($country_wetu_id, $id) { |
|
| 1065 | 1065 | $country_id = false; |
| 1066 | 1066 | $this->current_destinations = $this->find_current_destinations(); |
| 1067 | 1067 | |
| 1068 | - if ( false !== $this->current_destinations && ! empty( $this->current_destinations ) && array_key_exists( $country_wetu_id, $this->current_destinations ) ) { |
|
| 1069 | - $country_id = $this->current_destinations[ $country_wetu_id ]; |
|
| 1070 | - $this->destination_images[ $id ][] = array( $country_id, $country_wetu_id ); |
|
| 1071 | - } else { |
|
| 1072 | - $country_json = file_get_contents( 'http://wetu.com/API/Pins/' . $this->api_key . '/Get?ids=' . $country_wetu_id ); |
|
| 1068 | + if (false !== $this->current_destinations && !empty($this->current_destinations) && array_key_exists($country_wetu_id, $this->current_destinations)) { |
|
| 1069 | + $country_id = $this->current_destinations[$country_wetu_id]; |
|
| 1070 | + $this->destination_images[$id][] = array($country_id, $country_wetu_id); |
|
| 1071 | + }else { |
|
| 1072 | + $country_json = file_get_contents('http://wetu.com/API/Pins/'.$this->api_key.'/Get?ids='.$country_wetu_id); |
|
| 1073 | 1073 | |
| 1074 | - if ( $country_json ) { |
|
| 1075 | - $country_data = json_decode( $country_json, true ); |
|
| 1074 | + if ($country_json) { |
|
| 1075 | + $country_data = json_decode($country_json, true); |
|
| 1076 | 1076 | |
| 1077 | - if ( ! empty( $country_data ) && ! isset( $country_data['error'] ) ) { |
|
| 1077 | + if (!empty($country_data) && !isset($country_data['error'])) { |
|
| 1078 | 1078 | |
| 1079 | 1079 | //Format the title of the destination if its available, otherwise default to the WETU ID. |
| 1080 | 1080 | $country_title = $country_wetu_id; |
| 1081 | 1081 | |
| 1082 | - if ( isset( $country_data[0]['name'] ) ) { |
|
| 1082 | + if (isset($country_data[0]['name'])) { |
|
| 1083 | 1083 | $country_title = $country_data[0]['name']; |
| 1084 | 1084 | } |
| 1085 | 1085 | |
@@ -1090,24 +1090,24 @@ discard block |
||
| 1090 | 1090 | )); |
| 1091 | 1091 | |
| 1092 | 1092 | //add the country to the current destination stack |
| 1093 | - $this->current_destinations[ $country_wetu_id ] = $country_id; |
|
| 1093 | + $this->current_destinations[$country_wetu_id] = $country_id; |
|
| 1094 | 1094 | |
| 1095 | 1095 | // Check if there are images and save fore use later. |
| 1096 | - if ( isset( $country_data[0]['content']['images'] ) && ! empty( $country_data[0]['content']['images'] ) ) { |
|
| 1097 | - $this->destination_images[ $id ][] = array( $country_id,$country_wetu_id ); |
|
| 1096 | + if (isset($country_data[0]['content']['images']) && !empty($country_data[0]['content']['images'])) { |
|
| 1097 | + $this->destination_images[$id][] = array($country_id, $country_wetu_id); |
|
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | 1100 | //Save the wetu field |
| 1101 | - $this->save_custom_field( $country_wetu_id, 'lsx_wetu_id', $country_id ); |
|
| 1101 | + $this->save_custom_field($country_wetu_id, 'lsx_wetu_id', $country_id); |
|
| 1102 | 1102 | } |
| 1103 | 1103 | } |
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | - if ( '' !== $country_id && false !== $country_id ) { |
|
| 1107 | - $this->save_custom_field( $country_id, 'destination_to_tour', $id, false, false ); |
|
| 1108 | - $this->save_custom_field( $id, 'tour_to_destination', $country_id, false, false ); |
|
| 1109 | - $this->queue_item( $country_id ); |
|
| 1110 | - $this->cleanup_posts[ $country_id ] = 'tour_to_destination'; |
|
| 1106 | + if ('' !== $country_id && false !== $country_id) { |
|
| 1107 | + $this->save_custom_field($country_id, 'destination_to_tour', $id, false, false); |
|
| 1108 | + $this->save_custom_field($id, 'tour_to_destination', $country_id, false, false); |
|
| 1109 | + $this->queue_item($country_id); |
|
| 1110 | + $this->cleanup_posts[$country_id] = 'tour_to_destination'; |
|
| 1111 | 1111 | |
| 1112 | 1112 | return $country_id; |
| 1113 | 1113 | } |
@@ -1122,44 +1122,44 @@ discard block |
||
| 1122 | 1122 | * |
| 1123 | 1123 | * @return string |
| 1124 | 1124 | */ |
| 1125 | - public function attach_destination_images( $importable_content = array() ) { |
|
| 1126 | - if ( false !== $this->destination_images ) { |
|
| 1127 | - $this->shuffle_assoc( $this->destination_images ); |
|
| 1125 | + public function attach_destination_images($importable_content = array()) { |
|
| 1126 | + if (false !== $this->destination_images) { |
|
| 1127 | + $this->shuffle_assoc($this->destination_images); |
|
| 1128 | 1128 | |
| 1129 | - foreach ( $this->destination_images as $tour => $destinations ) { |
|
| 1129 | + foreach ($this->destination_images as $tour => $destinations) { |
|
| 1130 | 1130 | //$this->shuffle_assoc( $destinations ); |
| 1131 | 1131 | |
| 1132 | 1132 | $image_set = false; |
| 1133 | 1133 | $forced = false; |
| 1134 | 1134 | |
| 1135 | - foreach ( $destinations as $destination ) { |
|
| 1136 | - if ( false === $image_set && false === $forced ) { |
|
| 1137 | - $url = 'https://wetu.com/API/Pins/' . $this->api_key; |
|
| 1135 | + foreach ($destinations as $destination) { |
|
| 1136 | + if (false === $image_set && false === $forced) { |
|
| 1137 | + $url = 'https://wetu.com/API/Pins/'.$this->api_key; |
|
| 1138 | 1138 | $url_qs = ''; |
| 1139 | 1139 | |
| 1140 | - $jdata = file_get_contents( $url . '/Get?' . $url_qs . '&ids=' . $destination[1] ); |
|
| 1140 | + $jdata = file_get_contents($url.'/Get?'.$url_qs.'&ids='.$destination[1]); |
|
| 1141 | 1141 | |
| 1142 | - if ( $jdata ) { |
|
| 1143 | - $adata = json_decode( $jdata, true ); |
|
| 1142 | + if ($jdata) { |
|
| 1143 | + $adata = json_decode($jdata, true); |
|
| 1144 | 1144 | |
| 1145 | - if ( ! empty( $adata ) && ! empty( $adata[0]['content']['images'] ) ) { |
|
| 1146 | - $this->find_attachments( $destination[0] ); |
|
| 1145 | + if (!empty($adata) && !empty($adata[0]['content']['images'])) { |
|
| 1146 | + $this->find_attachments($destination[0]); |
|
| 1147 | 1147 | |
| 1148 | 1148 | //Set the featured image |
| 1149 | - if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) { |
|
| 1150 | - $image_set = $this->set_featured_image( $adata, $tour ); |
|
| 1151 | - if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) { |
|
| 1152 | - $image_set = $this->set_banner_image( $adata, $tour ); |
|
| 1149 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
| 1150 | + $image_set = $this->set_featured_image($adata, $tour); |
|
| 1151 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
| 1152 | + $image_set = $this->set_banner_image($adata, $tour); |
|
| 1153 | 1153 | $forced = true; |
| 1154 | 1154 | } |
| 1155 | 1155 | continue; |
| 1156 | 1156 | } |
| 1157 | - if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) { |
|
| 1158 | - $image_set = $this->set_banner_image( $adata, $tour ); |
|
| 1157 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
| 1158 | + $image_set = $this->set_banner_image($adata, $tour); |
|
| 1159 | 1159 | } |
| 1160 | 1160 | } |
| 1161 | 1161 | } |
| 1162 | - } else { |
|
| 1162 | + }else { |
|
| 1163 | 1163 | continue; |
| 1164 | 1164 | } |
| 1165 | 1165 | } |
@@ -1170,28 +1170,28 @@ discard block |
||
| 1170 | 1170 | /** |
| 1171 | 1171 | * Creates the main gallery data |
| 1172 | 1172 | */ |
| 1173 | - public function set_featured_image( $data, $id ) { |
|
| 1173 | + public function set_featured_image($data, $id) { |
|
| 1174 | 1174 | $image_set = false; |
| 1175 | 1175 | $counter = 0; |
| 1176 | 1176 | |
| 1177 | - if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) { |
|
| 1178 | - foreach ( $data[0]['content']['images'] as $v ) { |
|
| 1177 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 1178 | + foreach ($data[0]['content']['images'] as $v) { |
|
| 1179 | 1179 | /*print_r('<pre>'); |
| 1180 | 1180 | print_r( $v ); |
| 1181 | 1181 | print_r('</pre>');*/ |
| 1182 | 1182 | |
| 1183 | - if ( true === $image_set ) { |
|
| 1183 | + if (true === $image_set) { |
|
| 1184 | 1184 | $counter++; |
| 1185 | 1185 | continue; |
| 1186 | 1186 | } |
| 1187 | 1187 | |
| 1188 | - if ( ! $this->check_if_image_is_used( $v ) ) { |
|
| 1189 | - $temp_featured_image = $this->attach_image( $v , $id ); |
|
| 1188 | + if (!$this->check_if_image_is_used($v)) { |
|
| 1189 | + $temp_featured_image = $this->attach_image($v, $id); |
|
| 1190 | 1190 | |
| 1191 | - if ( false !== $temp_featured_image ) { |
|
| 1191 | + if (false !== $temp_featured_image) { |
|
| 1192 | 1192 | $this->featured_image = $temp_featured_image; |
| 1193 | - delete_post_meta( $id, '_thumbnail_id' ); |
|
| 1194 | - add_post_meta( $id, '_thumbnail_id', $this->featured_image, true ); |
|
| 1193 | + delete_post_meta($id, '_thumbnail_id'); |
|
| 1194 | + add_post_meta($id, '_thumbnail_id', $this->featured_image, true); |
|
| 1195 | 1195 | $image_set = true; |
| 1196 | 1196 | } |
| 1197 | 1197 | } |
@@ -1205,40 +1205,40 @@ discard block |
||
| 1205 | 1205 | /** |
| 1206 | 1206 | * Sets a banner image |
| 1207 | 1207 | */ |
| 1208 | - public function set_banner_image( $data, $id, $content = array( 'none' ) ) { |
|
| 1208 | + public function set_banner_image($data, $id, $content = array('none')) { |
|
| 1209 | 1209 | $image_set = false; |
| 1210 | 1210 | $counter = 0; |
| 1211 | 1211 | |
| 1212 | - if ( is_array( $data[0]['content']['images'] ) && ! empty( $data[0]['content']['images'] ) ) { |
|
| 1212 | + if (is_array($data[0]['content']['images']) && !empty($data[0]['content']['images'])) { |
|
| 1213 | 1213 | |
| 1214 | - foreach ( $data[0]['content']['images'] as $v ) { |
|
| 1214 | + foreach ($data[0]['content']['images'] as $v) { |
|
| 1215 | 1215 | /*print_r('<pre>'); |
| 1216 | 1216 | print_r( $v ); |
| 1217 | 1217 | print_r('</pre>');*/ |
| 1218 | 1218 | |
| 1219 | - if ( true === $image_set || 0 === $counter ) { |
|
| 1219 | + if (true === $image_set || 0 === $counter) { |
|
| 1220 | 1220 | $counter++; |
| 1221 | 1221 | continue; |
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | - if ( ! $this->check_if_image_is_used( $v ) ) { |
|
| 1225 | - $temp_banner = $this->attach_image( $v, $id, array( |
|
| 1224 | + if (!$this->check_if_image_is_used($v)) { |
|
| 1225 | + $temp_banner = $this->attach_image($v, $id, array( |
|
| 1226 | 1226 | 'width' => '1920', |
| 1227 | 1227 | 'height' => '600', |
| 1228 | 1228 | 'cropping' => 'c', |
| 1229 | - ) ); |
|
| 1229 | + )); |
|
| 1230 | 1230 | |
| 1231 | - if ( false !== $temp_banner ) { |
|
| 1231 | + if (false !== $temp_banner) { |
|
| 1232 | 1232 | $this->banner_image = $temp_banner; |
| 1233 | 1233 | |
| 1234 | - delete_post_meta( $id,'image_group' ); |
|
| 1234 | + delete_post_meta($id, 'image_group'); |
|
| 1235 | 1235 | |
| 1236 | 1236 | $new_banner = array( |
| 1237 | 1237 | 'banner_image' => array( |
| 1238 | 1238 | 'cmb-field-0' => $this->banner_image, |
| 1239 | 1239 | ), |
| 1240 | 1240 | ); |
| 1241 | - add_post_meta( $id,'image_group',$new_banner,true ); |
|
| 1241 | + add_post_meta($id, 'image_group', $new_banner, true); |
|
| 1242 | 1242 | $image_set = true; |
| 1243 | 1243 | } |
| 1244 | 1244 | } |
@@ -1252,18 +1252,18 @@ discard block |
||
| 1252 | 1252 | /** |
| 1253 | 1253 | * Grabs all of the current used featured images on the site. |
| 1254 | 1254 | */ |
| 1255 | - public function check_if_image_is_used( $v ) { |
|
| 1255 | + public function check_if_image_is_used($v) { |
|
| 1256 | 1256 | global $wpdb; |
| 1257 | 1257 | |
| 1258 | - $temp_fragment = explode( '/',$v['url_fragment'] ); |
|
| 1259 | - $url_filename = $temp_fragment[ count( $temp_fragment ) -1 ]; |
|
| 1260 | - $url_filename = str_replace( array( '.jpg', '.png', '.jpeg' ),'',$url_filename ); |
|
| 1261 | - $url_filename = trim( $url_filename ); |
|
| 1262 | - $url_filename = str_replace( ' ','_',$url_filename ); |
|
| 1258 | + $temp_fragment = explode('/', $v['url_fragment']); |
|
| 1259 | + $url_filename = $temp_fragment[count($temp_fragment) - 1]; |
|
| 1260 | + $url_filename = str_replace(array('.jpg', '.png', '.jpeg'), '', $url_filename); |
|
| 1261 | + $url_filename = trim($url_filename); |
|
| 1262 | + $url_filename = str_replace(' ', '_', $url_filename); |
|
| 1263 | 1263 | |
| 1264 | - if ( in_array( $url_filename,$this->found_attachments ) ) { |
|
| 1264 | + if (in_array($url_filename, $this->found_attachments)) { |
|
| 1265 | 1265 | //check to see if there is a featured image set with this ID. |
| 1266 | - $found_id = array_search( $url_filename,$this->found_attachments ); |
|
| 1266 | + $found_id = array_search($url_filename, $this->found_attachments); |
|
| 1267 | 1267 | |
| 1268 | 1268 | $querystring = " |
| 1269 | 1269 | SELECT post_id |
@@ -1272,22 +1272,22 @@ discard block |
||
| 1272 | 1272 | AND meta_key = '_thumbnail_id' |
| 1273 | 1273 | "; |
| 1274 | 1274 | // @codingStandardsIgnoreLine |
| 1275 | - $results = $wpdb->get_results( $querystring ); |
|
| 1275 | + $results = $wpdb->get_results($querystring); |
|
| 1276 | 1276 | |
| 1277 | - if ( ! empty( $results ) ) { |
|
| 1277 | + if (!empty($results)) { |
|
| 1278 | 1278 | return true; |
| 1279 | - } else { |
|
| 1279 | + }else { |
|
| 1280 | 1280 | return false; |
| 1281 | 1281 | } |
| 1282 | - } else { |
|
| 1282 | + }else { |
|
| 1283 | 1283 | $querystring = " |
| 1284 | 1284 | SELECT ID |
| 1285 | 1285 | FROM {$wpdb->posts} |
| 1286 | 1286 | WHERE post_name = '{$url_filename}' |
| 1287 | 1287 | "; |
| 1288 | 1288 | // @codingStandardsIgnoreLine |
| 1289 | - $results = $wpdb->get_results( $querystring ); |
|
| 1290 | - if ( ! empty( $results ) ) { |
|
| 1289 | + $results = $wpdb->get_results($querystring); |
|
| 1290 | + if (!empty($results)) { |
|
| 1291 | 1291 | $querystring = " |
| 1292 | 1292 | SELECT post_id |
| 1293 | 1293 | FROM {$wpdb->postmeta} |
@@ -1295,13 +1295,13 @@ discard block |
||
| 1295 | 1295 | AND meta_key = '_thumbnail_id' |
| 1296 | 1296 | "; |
| 1297 | 1297 | // @codingStandardsIgnoreLine |
| 1298 | - $results = $wpdb->get_results( $querystring ); |
|
| 1299 | - if ( ! empty( $results ) ) { |
|
| 1298 | + $results = $wpdb->get_results($querystring); |
|
| 1299 | + if (!empty($results)) { |
|
| 1300 | 1300 | return true; |
| 1301 | - } else { |
|
| 1301 | + }else { |
|
| 1302 | 1302 | return false; |
| 1303 | 1303 | } |
| 1304 | - } else { |
|
| 1304 | + }else { |
|
| 1305 | 1305 | return false; |
| 1306 | 1306 | } |
| 1307 | 1307 | } |
@@ -1312,10 +1312,10 @@ discard block |
||
| 1312 | 1312 | * |
| 1313 | 1313 | * @param $id int |
| 1314 | 1314 | */ |
| 1315 | - public function queue_item( $id ) { |
|
| 1316 | - if ( is_array( $this->import_queue ) && ! in_array( $id,$this->import_queue ) ) { |
|
| 1315 | + public function queue_item($id) { |
|
| 1316 | + if (is_array($this->import_queue) && !in_array($id, $this->import_queue)) { |
|
| 1317 | 1317 | $this->import_queue[] = $id; |
| 1318 | - } else { |
|
| 1318 | + }else { |
|
| 1319 | 1319 | $this->import_queue[] = $id; |
| 1320 | 1320 | } |
| 1321 | 1321 | } |
@@ -1324,18 +1324,18 @@ discard block |
||
| 1324 | 1324 | * Saves the queue to the option. |
| 1325 | 1325 | */ |
| 1326 | 1326 | public function save_queue() { |
| 1327 | - if ( ! empty( $this->import_queue ) ) { |
|
| 1328 | - if ( ! empty( $this->queued_imports ) ) { |
|
| 1329 | - $saved_imports = array_merge( $this->queued_imports,$this->import_queue ); |
|
| 1330 | - } else { |
|
| 1327 | + if (!empty($this->import_queue)) { |
|
| 1328 | + if (!empty($this->queued_imports)) { |
|
| 1329 | + $saved_imports = array_merge($this->queued_imports, $this->import_queue); |
|
| 1330 | + }else { |
|
| 1331 | 1331 | $saved_imports = $this->import_queue; |
| 1332 | 1332 | } |
| 1333 | 1333 | |
| 1334 | - delete_option( 'wetu_importer_que' ); |
|
| 1334 | + delete_option('wetu_importer_que'); |
|
| 1335 | 1335 | |
| 1336 | - if ( ! empty( $saved_imports ) ) { |
|
| 1337 | - $saved_imports = array_unique( $saved_imports ); |
|
| 1338 | - update_option( 'wetu_importer_que',$saved_imports ); |
|
| 1336 | + if (!empty($saved_imports)) { |
|
| 1337 | + $saved_imports = array_unique($saved_imports); |
|
| 1338 | + update_option('wetu_importer_que', $saved_imports); |
|
| 1339 | 1339 | } |
| 1340 | 1340 | } |
| 1341 | 1341 | } |