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