@@ -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,112 +334,112 @@ discard block |
||
334 | 334 | $return = false; |
335 | 335 | |
336 | 336 | // @codingStandardsIgnoreLine |
337 | - if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_tour_importer' && isset( $_POST['type'] ) && $_POST['type'] === 'destination' ) { |
|
337 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_tour_importer' && isset($_POST['type']) && $_POST['type'] === 'destination') { |
|
338 | 338 | |
339 | 339 | $searched_items = false; |
340 | 340 | |
341 | 341 | // @codingStandardsIgnoreLine |
342 | - if ( isset( $_POST['keyword'] ) ) { |
|
342 | + if (isset($_POST['keyword'])) { |
|
343 | 343 | // @codingStandardsIgnoreLine |
344 | 344 | $keyphrases = $_POST['keyword']; |
345 | - } else { |
|
346 | - $keyphrases = array( 0 ); |
|
345 | + }else { |
|
346 | + $keyphrases = array(0); |
|
347 | 347 | } |
348 | 348 | |
349 | - if ( ! is_array( $keyphrases ) ) { |
|
350 | - $keyphrases = array( $keyphrases ); |
|
349 | + if (!is_array($keyphrases)) { |
|
350 | + $keyphrases = array($keyphrases); |
|
351 | 351 | } |
352 | - foreach ( $keyphrases as &$keyword ) { |
|
353 | - $keyword = ltrim( rtrim( $keyword ) ); |
|
352 | + foreach ($keyphrases as &$keyword) { |
|
353 | + $keyword = ltrim(rtrim($keyword)); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | $post_status = false; |
357 | 357 | |
358 | - if ( in_array( 'publish',$keyphrases ) ) { |
|
358 | + if (in_array('publish', $keyphrases)) { |
|
359 | 359 | $post_status = 'publish'; |
360 | 360 | } |
361 | - if ( in_array( 'pending',$keyphrases ) ) { |
|
361 | + if (in_array('pending', $keyphrases)) { |
|
362 | 362 | $post_status = 'pending'; |
363 | 363 | } |
364 | - if ( in_array( 'draft',$keyphrases ) ) { |
|
364 | + if (in_array('draft', $keyphrases)) { |
|
365 | 365 | $post_status = 'draft'; |
366 | 366 | } |
367 | - if ( in_array( 'import',$keyphrases ) ) { |
|
367 | + if (in_array('import', $keyphrases)) { |
|
368 | 368 | $post_status = 'import'; |
369 | 369 | } |
370 | 370 | |
371 | 371 | // If there is a post status use it. |
372 | - if ( false !== $post_status ) { |
|
372 | + if (false !== $post_status) { |
|
373 | 373 | |
374 | 374 | $accommodation = array(); |
375 | - $current_accommodation = $this->find_current_accommodation( 'destination' ); |
|
376 | - if ( ! empty( $current_accommodation ) ) { |
|
377 | - foreach ( $current_accommodation as $cs_key => $ccs_id ) { |
|
378 | - $accommodation[] = $this->prepare_row_attributes( $cs_key, $ccs_id->post_id ); |
|
375 | + $current_accommodation = $this->find_current_accommodation('destination'); |
|
376 | + if (!empty($current_accommodation)) { |
|
377 | + foreach ($current_accommodation as $cs_key => $ccs_id) { |
|
378 | + $accommodation[] = $this->prepare_row_attributes($cs_key, $ccs_id->post_id); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
382 | 382 | // Run through each accommodation and use it. |
383 | - if ( ! empty( $accommodation ) ) { |
|
384 | - foreach ( $accommodation as $row_key => $row ) { |
|
385 | - if ( 'import' === $post_status ) { |
|
383 | + if (!empty($accommodation)) { |
|
384 | + foreach ($accommodation as $row_key => $row) { |
|
385 | + if ('import' === $post_status) { |
|
386 | 386 | |
387 | - if ( is_array( $this->queued_imports ) && in_array( $row['post_id'],$this->queued_imports ) ) { |
|
388 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
|
389 | - } else { |
|
387 | + if (is_array($this->queued_imports) && in_array($row['post_id'], $this->queued_imports)) { |
|
388 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
|
389 | + }else { |
|
390 | 390 | continue; |
391 | 391 | } |
392 | - } else { |
|
393 | - if ( 0 === $row['post_id'] ) { |
|
392 | + }else { |
|
393 | + if (0 === $row['post_id']) { |
|
394 | 394 | continue; |
395 | - } else { |
|
396 | - $current_status = get_post_status( $row['post_id'] ); |
|
395 | + }else { |
|
396 | + $current_status = get_post_status($row['post_id']); |
|
397 | 397 | |
398 | - if ( $current_status !== $post_status ) { |
|
398 | + if ($current_status !== $post_status) { |
|
399 | 399 | continue; |
400 | 400 | } |
401 | 401 | } |
402 | - $searched_items[ sanitize_title( $row['name'] ) . '-' . $row['id'] ] = $this->format_row( $row ); |
|
402 | + $searched_items[sanitize_title($row['name']).'-'.$row['id']] = $this->format_row($row); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
407 | - } else { |
|
407 | + }else { |
|
408 | 408 | |
409 | - $key_string_search = implode( '+', $keyphrases ); |
|
410 | - $search_data = file_get_contents( $this->url . '/Search/' . $key_string_search . '/?all=include' ); |
|
411 | - $search_data = json_decode( $search_data, true ); |
|
409 | + $key_string_search = implode('+', $keyphrases); |
|
410 | + $search_data = file_get_contents($this->url.'/Search/'.$key_string_search.'/?all=include'); |
|
411 | + $search_data = json_decode($search_data, true); |
|
412 | 412 | |
413 | - if ( ! isset( $search_data['error'] ) ) { |
|
414 | - foreach ( $search_data as $sdata ) { |
|
413 | + if (!isset($search_data['error'])) { |
|
414 | + foreach ($search_data as $sdata) { |
|
415 | 415 | |
416 | - if ( 'Destination' !== trim( $sdata['type'] ) ) { |
|
416 | + if ('Destination' !== trim($sdata['type'])) { |
|
417 | 417 | continue; |
418 | 418 | } |
419 | 419 | |
420 | 420 | $sdata['post_id'] = 0; |
421 | - $searched_items[ sanitize_title( $sdata['name'] ) . '-' . $sdata['id'] ] = $this->format_row( $sdata ); |
|
421 | + $searched_items[sanitize_title($sdata['name']).'-'.$sdata['id']] = $this->format_row($sdata); |
|
422 | 422 | } |
423 | 423 | } |
424 | 424 | } |
425 | 425 | |
426 | - if ( false !== $searched_items ) { |
|
427 | - ksort( $searched_items ); |
|
428 | - $return = implode( $searched_items ); |
|
426 | + if (false !== $searched_items) { |
|
427 | + ksort($searched_items); |
|
428 | + $return = implode($searched_items); |
|
429 | 429 | } |
430 | 430 | |
431 | - print_r( $return ); |
|
431 | + print_r($return); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | die(); |
435 | 435 | } |
436 | 436 | |
437 | - public function prepare_row_attributes( $cs_key, $ccs_id ) { |
|
437 | + public function prepare_row_attributes($cs_key, $ccs_id) { |
|
438 | 438 | return $row_item = array( |
439 | 439 | 'id' => $cs_key, |
440 | 440 | 'type' => 'Destination', |
441 | - 'name' => get_the_title( $ccs_id ), |
|
442 | - 'last_modified' => date('Y-m-d', strtotime( 'now' ) ), |
|
441 | + 'name' => get_the_title($ccs_id), |
|
442 | + 'last_modified' => date('Y-m-d', strtotime('now')), |
|
443 | 443 | 'post_id' => $ccs_id, |
444 | 444 | ); |
445 | 445 | } |
@@ -447,28 +447,28 @@ discard block |
||
447 | 447 | /** |
448 | 448 | * Formats the row for output on the screen. |
449 | 449 | */ |
450 | - public function format_row( $row = false ) { |
|
451 | - if ( false !== $row ) { |
|
450 | + public function format_row($row = false) { |
|
451 | + if (false !== $row) { |
|
452 | 452 | |
453 | 453 | $status = 'import'; |
454 | - if ( 0 !== $row['post_id'] ) { |
|
455 | - $status = '<a href="' . admin_url( '/post.php?post=' . $row['post_id'] . '&action=edit' ) . '" target="_blank">' . get_post_status( $row['post_id'] ) . '</a>'; |
|
454 | + if (0 !== $row['post_id']) { |
|
455 | + $status = '<a href="'.admin_url('/post.php?post='.$row['post_id'].'&action=edit').'" target="_blank">'.get_post_status($row['post_id']).'</a>'; |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | $row_html = ' |
459 | - <tr class="post-' . $row['post_id'] . ' type-tour" id="post-' . $row['post_id'] . '"> |
|
459 | + <tr class="post-' . $row['post_id'].' type-tour" id="post-'.$row['post_id'].'"> |
|
460 | 460 | <th class="check-column" scope="row"> |
461 | - <label for="cb-select-' . $row['id'] . '" class="screen-reader-text">' . $row['name'] . '</label> |
|
462 | - <input type="checkbox" data-identifier="' . $row['id'] . '" value="' . $row['post_id'] . '" name="post[]" id="cb-select-' . $row['id'] . '"> |
|
461 | + <label for="cb-select-' . $row['id'].'" class="screen-reader-text">'.$row['name'].'</label> |
|
462 | + <input type="checkbox" data-identifier="' . $row['id'].'" value="'.$row['post_id'].'" name="post[]" id="cb-select-'.$row['id'].'"> |
|
463 | 463 | </th> |
464 | 464 | <td class="post-title page-title column-title"> |
465 | - <strong>' . $row['name'] . '</strong> - ' . $status . ' |
|
465 | + <strong>' . $row['name'].'</strong> - '.$status.' |
|
466 | 466 | </td> |
467 | 467 | <td class="date column-date"> |
468 | - <abbr title="' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '">' . date( 'Y/m/d',strtotime( $row['last_modified'] ) ) . '</abbr><br>Last Modified |
|
468 | + <abbr title="' . date('Y/m/d', strtotime($row['last_modified'])).'">'.date('Y/m/d', strtotime($row['last_modified'])).'</abbr><br>Last Modified |
|
469 | 469 | </td> |
470 | 470 | <td class="ssid column-ssid"> |
471 | - ' . $row['id'] . ' |
|
471 | + ' . $row['id'].' |
|
472 | 472 | </td> |
473 | 473 | </tr>'; |
474 | 474 | return $row_html; |
@@ -482,54 +482,54 @@ discard block |
||
482 | 482 | $return = false; |
483 | 483 | |
484 | 484 | // @codingStandardsIgnoreLine |
485 | - if ( isset( $_POST['action'] ) && $_POST['action'] === 'lsx_import_items' && isset( $_POST['type'] ) && $_POST['type'] === 'destination' && isset( $_POST['wetu_id'] ) ) { |
|
485 | + if (isset($_POST['action']) && $_POST['action'] === 'lsx_import_items' && isset($_POST['type']) && $_POST['type'] === 'destination' && isset($_POST['wetu_id'])) { |
|
486 | 486 | // @codingStandardsIgnoreLine |
487 | 487 | $wetu_id = $_POST['wetu_id']; |
488 | 488 | |
489 | 489 | // @codingStandardsIgnoreLine |
490 | - if ( isset( $_POST['post_id'] ) ) { |
|
490 | + if (isset($_POST['post_id'])) { |
|
491 | 491 | // @codingStandardsIgnoreLine |
492 | 492 | $post_id = $_POST['post_id']; |
493 | - $this->current_post = get_post( $post_id ); |
|
494 | - } else { |
|
493 | + $this->current_post = get_post($post_id); |
|
494 | + }else { |
|
495 | 495 | $post_id = 0; |
496 | 496 | } |
497 | 497 | |
498 | 498 | // @codingStandardsIgnoreLine |
499 | - if ( isset( $_POST['team_members'] ) ) { |
|
499 | + if (isset($_POST['team_members'])) { |
|
500 | 500 | // @codingStandardsIgnoreLine |
501 | 501 | $team_members = $_POST['team_members']; |
502 | - } else { |
|
502 | + }else { |
|
503 | 503 | $team_members = false; |
504 | 504 | } |
505 | 505 | |
506 | 506 | $safari_brands = false; |
507 | 507 | |
508 | - delete_option( 'wetu_importer_destination_settings' ); |
|
508 | + delete_option('wetu_importer_destination_settings'); |
|
509 | 509 | |
510 | 510 | // @codingStandardsIgnoreLine |
511 | - if ( isset( $_POST['content'] ) && is_array( $_POST['content'] ) && ! empty( $_POST['content'] ) ) { |
|
511 | + if (isset($_POST['content']) && is_array($_POST['content']) && !empty($_POST['content'])) { |
|
512 | 512 | // @codingStandardsIgnoreLine |
513 | 513 | $content = $_POST['content']; |
514 | - add_option( 'wetu_importer_destination_settings', $content ); |
|
515 | - } else { |
|
514 | + add_option('wetu_importer_destination_settings', $content); |
|
515 | + }else { |
|
516 | 516 | $content = false; |
517 | 517 | } |
518 | 518 | |
519 | - $jdata = file_get_contents( $this->url . '/Get?' . $this->url_qs . '&ids=' . $wetu_id ); |
|
519 | + $jdata = file_get_contents($this->url.'/Get?'.$this->url_qs.'&ids='.$wetu_id); |
|
520 | 520 | |
521 | - if ( $jdata ) { |
|
522 | - $adata = json_decode( $jdata, true ); |
|
521 | + if ($jdata) { |
|
522 | + $adata = json_decode($jdata, true); |
|
523 | 523 | |
524 | - if ( ! empty( $adata ) && ! isset( $adata['error'] ) ) { |
|
525 | - $return = $this->import_row( $adata, $wetu_id, $post_id, $team_members, $content, $safari_brands ); |
|
526 | - $this->remove_from_queue( $return ); |
|
527 | - $this->format_completed_row( $return ); |
|
528 | - } else { |
|
529 | - if ( isset( $adata['error'] ) ) { |
|
530 | - $this->format_error( $adata['error'] ); |
|
531 | - } else { |
|
532 | - $this->format_error( esc_html__( 'There was a problem importing your destination, please try refreshing the page.','wetu-importer' ) ); |
|
524 | + if (!empty($adata) && !isset($adata['error'])) { |
|
525 | + $return = $this->import_row($adata, $wetu_id, $post_id, $team_members, $content, $safari_brands); |
|
526 | + $this->remove_from_queue($return); |
|
527 | + $this->format_completed_row($return); |
|
528 | + }else { |
|
529 | + if (isset($adata['error'])) { |
|
530 | + $this->format_error($adata['error']); |
|
531 | + }else { |
|
532 | + $this->format_error(esc_html__('There was a problem importing your destination, please try refreshing the page.', 'wetu-importer')); |
|
533 | 533 | } |
534 | 534 | } |
535 | 535 | } |
@@ -539,14 +539,14 @@ discard block |
||
539 | 539 | /** |
540 | 540 | * Saves the queue to the option. |
541 | 541 | */ |
542 | - public function remove_from_queue( $id ) { |
|
543 | - if ( ! empty( $this->queued_imports ) ) { |
|
542 | + public function remove_from_queue($id) { |
|
543 | + if (!empty($this->queued_imports)) { |
|
544 | 544 | // @codingStandardsIgnoreLine |
545 | - if ( ( $key = array_search( $id, $this->queued_imports ) ) !== false ) { |
|
546 | - unset( $this->queued_imports[ $key ] ); |
|
545 | + if (($key = array_search($id, $this->queued_imports)) !== false) { |
|
546 | + unset($this->queued_imports[$key]); |
|
547 | 547 | |
548 | - delete_option( 'wetu_importer_que' ); |
|
549 | - update_option( 'wetu_importer_que',$this->queued_imports ); |
|
548 | + delete_option('wetu_importer_que'); |
|
549 | + update_option('wetu_importer_que', $this->queued_imports); |
|
550 | 550 | } |
551 | 551 | } |
552 | 552 | } |
@@ -554,8 +554,8 @@ discard block |
||
554 | 554 | /** |
555 | 555 | * Connect to wetu |
556 | 556 | */ |
557 | - public function import_row( $data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false ) { |
|
558 | - if ( 'Destination' === trim( $data[0]['type'] ) ) { |
|
557 | + public function import_row($data, $wetu_id, $id = 0, $team_members = false, $importable_content = false, $safari_brands = false) { |
|
558 | + if ('Destination' === trim($data[0]['type'])) { |
|
559 | 559 | $post_name = ''; |
560 | 560 | $data_post_content = ''; |
561 | 561 | $data_post_excerpt = ''; |
@@ -564,132 +564,132 @@ discard block |
||
564 | 564 | 'post_type' => 'destination', |
565 | 565 | ); |
566 | 566 | |
567 | - if ( false !== $importable_content && in_array( 'country', $importable_content ) ) { |
|
568 | - $parent = $this->check_for_parent( $data ); |
|
569 | - if( false !== $parent ) { |
|
567 | + if (false !== $importable_content && in_array('country', $importable_content)) { |
|
568 | + $parent = $this->check_for_parent($data); |
|
569 | + if (false !== $parent) { |
|
570 | 570 | $post['post_parent'] = $parent; |
571 | 571 | } |
572 | 572 | } |
573 | 573 | |
574 | 574 | //Set the post_content |
575 | - if ( false !== $importable_content && in_array( 'description', $importable_content ) ) { |
|
576 | - if ( isset( $data[0]['content']['general_description'] ) ) { |
|
575 | + if (false !== $importable_content && in_array('description', $importable_content)) { |
|
576 | + if (isset($data[0]['content']['general_description'])) { |
|
577 | 577 | |
578 | - if ( false !== $importable_content && in_array( 'strip_tags', $importable_content ) ) { |
|
579 | - $post['post_content'] = wp_strip_all_tags( $data[0]['content']['general_description'] ); |
|
580 | - } else { |
|
578 | + if (false !== $importable_content && in_array('strip_tags', $importable_content)) { |
|
579 | + $post['post_content'] = wp_strip_all_tags($data[0]['content']['general_description']); |
|
580 | + }else { |
|
581 | 581 | $post['post_content'] = $data[0]['content']['general_description']; |
582 | 582 | } |
583 | 583 | } |
584 | 584 | } |
585 | 585 | |
586 | - if ( false !== $id && '0' !== $id ) { |
|
586 | + if (false !== $id && '0' !== $id) { |
|
587 | 587 | $post['ID'] = $id; |
588 | 588 | |
589 | - if ( isset( $data[0]['name'] ) ) { |
|
589 | + if (isset($data[0]['name'])) { |
|
590 | 590 | $post['post_title'] = $data[0]['name']; |
591 | 591 | $post['post_status'] = 'publish'; |
592 | - $post['post_name'] = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 ); |
|
592 | + $post['post_name'] = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0); |
|
593 | 593 | } |
594 | 594 | |
595 | - $id = wp_update_post( $post ); |
|
596 | - $prev_date = get_post_meta( $id, 'lsx_wetu_modified_date', true ); |
|
597 | - update_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ), $prev_date ); |
|
598 | - } else { |
|
595 | + $id = wp_update_post($post); |
|
596 | + $prev_date = get_post_meta($id, 'lsx_wetu_modified_date', true); |
|
597 | + update_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified']), $prev_date); |
|
598 | + }else { |
|
599 | 599 | //Set the name |
600 | - if ( isset( $data[0]['name'] ) ) { |
|
601 | - $post_name = wp_unique_post_slug( sanitize_title( $data[0]['name'] ), $id, 'draft', 'destination', 0 ); |
|
600 | + if (isset($data[0]['name'])) { |
|
601 | + $post_name = wp_unique_post_slug(sanitize_title($data[0]['name']), $id, 'draft', 'destination', 0); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | $post['post_name'] = $post_name; |
605 | 605 | $post['post_title'] = $data[0]['name']; |
606 | 606 | $post['post_status'] = 'publish'; |
607 | - $id = wp_insert_post( $post ); |
|
607 | + $id = wp_insert_post($post); |
|
608 | 608 | |
609 | 609 | //Save the WETU ID and the Last date it was modified. |
610 | - if ( false !== $id ) { |
|
611 | - add_post_meta( $id, 'lsx_wetu_id', $wetu_id ); |
|
612 | - add_post_meta( $id, 'lsx_wetu_modified_date', strtotime( $data[0]['last_modified'] ) ); |
|
610 | + if (false !== $id) { |
|
611 | + add_post_meta($id, 'lsx_wetu_id', $wetu_id); |
|
612 | + add_post_meta($id, 'lsx_wetu_modified_date', strtotime($data[0]['last_modified'])); |
|
613 | 613 | } |
614 | 614 | } |
615 | 615 | |
616 | - $this->find_attachments( $id ); |
|
616 | + $this->find_attachments($id); |
|
617 | 617 | |
618 | 618 | //Set the team member if it is there |
619 | - if ( post_type_exists( 'team' ) && false !== $team_members && '' !== $team_members ) { |
|
620 | - $this->set_team_member( $id, $team_members ); |
|
619 | + if (post_type_exists('team') && false !== $team_members && '' !== $team_members) { |
|
620 | + $this->set_team_member($id, $team_members); |
|
621 | 621 | } |
622 | 622 | |
623 | - if ( class_exists( 'LSX_TO_Maps' ) ) { |
|
624 | - $this->set_map_data( $data, $id, 9 ); |
|
623 | + if (class_exists('LSX_TO_Maps')) { |
|
624 | + $this->set_map_data($data, $id, 9); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | //Set the Room Data |
628 | - if ( false !== $importable_content && in_array( 'videos', $importable_content ) ) { |
|
629 | - $this->set_video_data( $data, $id ); |
|
628 | + if (false !== $importable_content && in_array('videos', $importable_content)) { |
|
629 | + $this->set_video_data($data, $id); |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | //Set the Electricity |
633 | - if ( false !== $importable_content && in_array( 'electricity', $importable_content ) ) { |
|
634 | - $this->set_travel_info( $data, $id, 'electricity', $importable_content ); |
|
633 | + if (false !== $importable_content && in_array('electricity', $importable_content)) { |
|
634 | + $this->set_travel_info($data, $id, 'electricity', $importable_content); |
|
635 | 635 | } |
636 | 636 | //Set the cuisine |
637 | - if ( false !== $importable_content && in_array( 'cuisine', $importable_content ) ) { |
|
638 | - $this->set_travel_info( $data, $id, 'cuisine', $importable_content ); |
|
637 | + if (false !== $importable_content && in_array('cuisine', $importable_content)) { |
|
638 | + $this->set_travel_info($data, $id, 'cuisine', $importable_content); |
|
639 | 639 | } |
640 | 640 | //Set the banking |
641 | - if ( false !== $importable_content && in_array( 'banking', $importable_content ) ) { |
|
642 | - $this->set_travel_info( $data, $id, 'banking', $importable_content ); |
|
641 | + if (false !== $importable_content && in_array('banking', $importable_content)) { |
|
642 | + $this->set_travel_info($data, $id, 'banking', $importable_content); |
|
643 | 643 | } |
644 | 644 | //Set the transport |
645 | - if ( false !== $importable_content && in_array( 'transport', $importable_content ) ) { |
|
646 | - $this->set_travel_info( $data, $id, 'transport', $importable_content ); |
|
645 | + if (false !== $importable_content && in_array('transport', $importable_content)) { |
|
646 | + $this->set_travel_info($data, $id, 'transport', $importable_content); |
|
647 | 647 | } |
648 | 648 | //Set the dress |
649 | - if ( false !== $importable_content && in_array( 'dress', $importable_content ) ) { |
|
650 | - $this->set_travel_info( $data, $id, 'dress', $importable_content ); |
|
649 | + if (false !== $importable_content && in_array('dress', $importable_content)) { |
|
650 | + $this->set_travel_info($data, $id, 'dress', $importable_content); |
|
651 | 651 | } |
652 | 652 | //Set the climate |
653 | - if ( false !== $importable_content && in_array( 'climate', $importable_content ) ) { |
|
654 | - $this->set_travel_info( $data, $id, 'climate', $importable_content ); |
|
653 | + if (false !== $importable_content && in_array('climate', $importable_content)) { |
|
654 | + $this->set_travel_info($data, $id, 'climate', $importable_content); |
|
655 | 655 | } |
656 | 656 | //Set the Health |
657 | - if ( false !== $importable_content && in_array( 'health', $importable_content ) ) { |
|
658 | - $this->set_travel_info( $data, $id, 'health', $importable_content ); |
|
657 | + if (false !== $importable_content && in_array('health', $importable_content)) { |
|
658 | + $this->set_travel_info($data, $id, 'health', $importable_content); |
|
659 | 659 | } |
660 | 660 | //Set the Safety |
661 | - if ( false !== $importable_content && in_array( 'safety', $importable_content ) ) { |
|
662 | - $this->set_travel_info( $data, $id, 'safety', $importable_content ); |
|
661 | + if (false !== $importable_content && in_array('safety', $importable_content)) { |
|
662 | + $this->set_travel_info($data, $id, 'safety', $importable_content); |
|
663 | 663 | } |
664 | 664 | //Set the Visa |
665 | - if ( false !== $importable_content && in_array( 'visa', $importable_content ) ) { |
|
666 | - $this->set_travel_info( $data, $id, 'visa', $importable_content ); |
|
665 | + if (false !== $importable_content && in_array('visa', $importable_content)) { |
|
666 | + $this->set_travel_info($data, $id, 'visa', $importable_content); |
|
667 | 667 | } |
668 | 668 | //Set the General |
669 | - if ( false !== $importable_content && in_array( 'additional_info', $importable_content ) ) { |
|
670 | - $this->set_travel_info( $data, $id, 'additional_info', $importable_content ); |
|
669 | + if (false !== $importable_content && in_array('additional_info', $importable_content)) { |
|
670 | + $this->set_travel_info($data, $id, 'additional_info', $importable_content); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | //Setup some default for use in the import |
674 | - if ( false !== $importable_content && (in_array( 'gallery', $importable_content ) || in_array( 'banner_image', $importable_content ) || in_array( 'featured_image', $importable_content )) ) { |
|
675 | - $this->find_attachments( $id ); |
|
674 | + if (false !== $importable_content && (in_array('gallery', $importable_content) || in_array('banner_image', $importable_content) || in_array('featured_image', $importable_content))) { |
|
675 | + $this->find_attachments($id); |
|
676 | 676 | |
677 | 677 | //Set the featured image |
678 | - if ( false !== $importable_content && in_array( 'featured_image', $importable_content ) ) { |
|
679 | - $this->set_featured_image( $data, $id ); |
|
678 | + if (false !== $importable_content && in_array('featured_image', $importable_content)) { |
|
679 | + $this->set_featured_image($data, $id); |
|
680 | 680 | } |
681 | - if ( false !== $importable_content && in_array( 'banner_image', $importable_content ) ) { |
|
682 | - $this->set_banner_image( $data, $id, $importable_content ); |
|
681 | + if (false !== $importable_content && in_array('banner_image', $importable_content)) { |
|
682 | + $this->set_banner_image($data, $id, $importable_content); |
|
683 | 683 | } |
684 | 684 | //Import the main gallery |
685 | - if ( false !== $importable_content && in_array( 'gallery', $importable_content ) ) { |
|
686 | - $this->create_main_gallery( $data, $id ); |
|
685 | + if (false !== $importable_content && in_array('gallery', $importable_content)) { |
|
686 | + $this->create_main_gallery($data, $id); |
|
687 | 687 | } |
688 | 688 | } |
689 | 689 | |
690 | 690 | //Set the continent |
691 | - if ( false !== $importable_content && in_array( 'continent', $importable_content ) ) { |
|
692 | - $this->set_continent( $data, $id ); |
|
691 | + if (false !== $importable_content && in_array('continent', $importable_content)) { |
|
692 | + $this->set_continent($data, $id); |
|
693 | 693 | } |
694 | 694 | } |
695 | 695 | |
@@ -699,49 +699,49 @@ discard block |
||
699 | 699 | /** |
700 | 700 | * Set the team memberon each item. |
701 | 701 | */ |
702 | - public function set_team_member( $id, $team_members ) { |
|
703 | - delete_post_meta( $id, 'team_to_' . $this->tab_slug ); |
|
702 | + public function set_team_member($id, $team_members) { |
|
703 | + delete_post_meta($id, 'team_to_'.$this->tab_slug); |
|
704 | 704 | |
705 | - foreach ( $team_members as $team ) { |
|
706 | - add_post_meta( $id, 'team_to_' . $this->tab_slug, $team ); |
|
705 | + foreach ($team_members as $team) { |
|
706 | + add_post_meta($id, 'team_to_'.$this->tab_slug, $team); |
|
707 | 707 | } |
708 | 708 | } |
709 | 709 | |
710 | 710 | /** |
711 | 711 | * Saves the room data |
712 | 712 | */ |
713 | - public function set_travel_info( $data, $id, $meta_key, $importable = array( 'none' ) ) { |
|
714 | - if ( ! empty( $data[0]['travel_information'] ) && isset( $data[0]['travel_information'][ $meta_key ] ) ) { |
|
715 | - $content = $data[0]['travel_information'][ $meta_key ]; |
|
713 | + public function set_travel_info($data, $id, $meta_key, $importable = array('none')) { |
|
714 | + if (!empty($data[0]['travel_information']) && isset($data[0]['travel_information'][$meta_key])) { |
|
715 | + $content = $data[0]['travel_information'][$meta_key]; |
|
716 | 716 | |
717 | - if ( in_array( 'strip_tags', $importable ) ) { |
|
718 | - $content = strip_tags( $content ); |
|
717 | + if (in_array('strip_tags', $importable)) { |
|
718 | + $content = strip_tags($content); |
|
719 | 719 | } |
720 | 720 | |
721 | - $this->save_custom_field( $content, $meta_key, $id ); |
|
721 | + $this->save_custom_field($content, $meta_key, $id); |
|
722 | 722 | } |
723 | 723 | } |
724 | 724 | |
725 | 725 | /** |
726 | 726 | * Set the Travel Style |
727 | 727 | */ |
728 | - public function set_continent( $data, $id ) { |
|
728 | + public function set_continent($data, $id) { |
|
729 | 729 | |
730 | - if ( isset( $data[0]['position']['country'] ) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id'] ) { |
|
730 | + if (isset($data[0]['position']['country']) && $data[0]['map_object_id'] === $data[0]['position']['country_content_entity_id']) { |
|
731 | 731 | //get the continent code. |
732 | - $continent_code = to_continent_label( to_continent_code( to_country_data( $data[0]['position']['country'], false ) ) ); |
|
732 | + $continent_code = to_continent_label(to_continent_code(to_country_data($data[0]['position']['country'], false))); |
|
733 | 733 | |
734 | - if ( '' !== $continent_code ) { |
|
734 | + if ('' !== $continent_code) { |
|
735 | 735 | // @codingStandardsIgnoreLine |
736 | - if ( ! $term = term_exists( trim( $continent_code ), 'continent' ) ) { |
|
737 | - $term = wp_insert_term( trim( $continent_code ), 'continent' ); |
|
736 | + if (!$term = term_exists(trim($continent_code), 'continent')) { |
|
737 | + $term = wp_insert_term(trim($continent_code), 'continent'); |
|
738 | 738 | |
739 | - if ( is_wp_error( $term ) ) { |
|
739 | + if (is_wp_error($term)) { |
|
740 | 740 | // @codingStandardsIgnoreLine |
741 | 741 | echo $term->get_error_message(); |
742 | 742 | } |
743 | - } else { |
|
744 | - wp_set_object_terms( $id, sanitize_title( $continent_code ), 'continent', true ); |
|
743 | + }else { |
|
744 | + wp_set_object_terms($id, sanitize_title($continent_code), 'continent', true); |
|
745 | 745 | } |
746 | 746 | } |
747 | 747 | } |
@@ -751,14 +751,14 @@ discard block |
||
751 | 751 | * Save the list of Accommodation into an option |
752 | 752 | */ |
753 | 753 | public function update_options() { |
754 | - $data = file_get_contents( $this->url . '/List?' . $this->url_qs ); |
|
754 | + $data = file_get_contents($this->url.'/List?'.$this->url_qs); |
|
755 | 755 | |
756 | - $accommodation = json_decode( $data, true ); |
|
756 | + $accommodation = json_decode($data, true); |
|
757 | 757 | |
758 | - if ( isset( $accommodation['error'] ) ) { |
|
758 | + if (isset($accommodation['error'])) { |
|
759 | 759 | return $accommodation['error']; |
760 | - } elseif ( isset( $accommodation ) && ! empty( $accommodation ) ) { |
|
761 | - set_transient( 'lsx_ti_accommodation',$accommodation,60 * 60 * 2 ); |
|
760 | + } elseif (isset($accommodation) && !empty($accommodation)) { |
|
761 | + set_transient('lsx_ti_accommodation', $accommodation, 60 * 60 * 2); |
|
762 | 762 | return true; |
763 | 763 | } |
764 | 764 | } |
@@ -767,11 +767,11 @@ discard block |
||
767 | 767 | * search_form |
768 | 768 | */ |
769 | 769 | public function update_options_form() { |
770 | - echo '<div style="display:none;" class="wetu-status"><h3>' . esc_html__( 'Wetu Status', 'wetu-importer' ) . '</h3>'; |
|
770 | + echo '<div style="display:none;" class="wetu-status"><h3>'.esc_html__('Wetu Status', 'wetu-importer').'</h3>'; |
|
771 | 771 | |
772 | - $accommodation = get_transient( 'lsx_ti_accommodation' ); |
|
772 | + $accommodation = get_transient('lsx_ti_accommodation'); |
|
773 | 773 | |
774 | - if ( '' === $accommodation || false === $accommodation || isset( $_GET['refresh_accommodation'] ) ) { |
|
774 | + if ('' === $accommodation || false === $accommodation || isset($_GET['refresh_accommodation'])) { |
|
775 | 775 | $this->update_options(); |
776 | 776 | } |
777 | 777 | |
@@ -781,19 +781,19 @@ discard block |
||
781 | 781 | /** |
782 | 782 | * Save the list of Accommodation into an option |
783 | 783 | */ |
784 | - public function check_for_parent( $data = array() ) { |
|
784 | + public function check_for_parent($data = array()) { |
|
785 | 785 | global $wpdb; |
786 | 786 | |
787 | - if ( $data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id'] ) { |
|
787 | + if ($data[0]['position']['country_content_entity_id'] !== $data[0]['position']['destination_content_entity_id']) { |
|
788 | 788 | $query = " |
789 | 789 | SELECT post_id |
790 | 790 | FROM {$wpdb->postmeta} |
791 | 791 | WHERE meta_key = 'lsx_wetu_id' |
792 | 792 | AND meta_value = {$data[0]['position']['country_content_entity_id']}"; |
793 | 793 | |
794 | - $result = $wpdb->get_var( $query ); |
|
794 | + $result = $wpdb->get_var($query); |
|
795 | 795 | |
796 | - if( ! empty( $result ) && '' !== $result && false !== $result ) { |
|
796 | + if (!empty($result) && '' !== $result && false !== $result) { |
|
797 | 797 | return $result; |
798 | 798 | } |
799 | 799 | } |